Loading...
Searching...
No Matches
MSRange.h
Go to the documentation of this file.
//# MSRange.h: this defines MSRange, which determines ranges of ms values
//# Copyright (C) 1997,1998,1999,2000,2001
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: casa-feedback@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
#ifndef MS_MSRANGE_H
#define MS_MSRANGE_H
#include <casacore/casa/aips.h>
#include <casacore/casa/Arrays/Vector.h>
#include <casacore/ms/MeasurementSets/MeasurementSet.h>
#include <casacore/ms/MSSel/MSSelectionKeywords.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
template <class T> class ArrayColumn;
template <class T> class ScalarColumn;
class Record;
class MSSelector;
// <summary>
// MSRange determines ranges of values in a MeasurementSet
// </summary>
// <use visibility=export>
// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
// </reviewed>
// <prerequisite>
// <li> MeasurementSet
// <li> Record
// </prerequisite>
//
// <etymology>
// MSRange is a class that determines ranges of values in an MS
// </etymology>
//
// <synopsis>
// This class is used to determine the range of values present for
// the various columns in a MeasurementSet.
// This class is initialized from a MeasurementSet. If the MS contains more
// than one DATA_DESC_ID, it can be preselected on this to allow
// a consistent set of frequencies to be returned.
// The ms DO provides access to this class from glish and GUIs.
//
// <example> <srcblock>
// MSRange myRange(myMS);
// Vector<String> items(3);
// // fill in some fields
// items(0)="field_id";
// items(1)="time";
// items(2)="data_desc_id";
// // get the range of values for the items specified
// cout << myRange.range(items)<<endl;
// // sample output: range=[field_id=[0,1,2],time=[4.5e9, 4.51e9],
// // data_desc_id=[0,1,2]];
// // Now preselect on data_desc_id
// MSSelector mss(myMS);
// Vector<Int> dd(2); dd(0)=1; dd(1)=2;
// mss.selectinit(0,dd); // select data desc ids 1 and 2
// MSRange r2(mss);
// items(2)="amplitude";
// cout<< r2.range(items)<<endl;
// // sample output: [field_id=[0,1,2],time=[4.5e9, 4.51e9],
// // amplitude=[0.00132,1.543]]
// </srcblock></example>
// </synopsis>
//
// <motivation>
// Finding out the range of values in a column is often needed before a
// sensible selection of data can be made. This class, formerly part of
// MSSelector, separates out this functionality.
// </motivation>
//
// <thrown>
// <li>
// <li>
// </thrown>
//
// <todo asof="1998/11/25">
// <li> maybe add channel selection and polarization conversion
// </todo>
class MSRange
{
public:
enum {
// spectral window selection and shapes have not been checked
UNCHECKED = -3,
// multiple spectral windows with varying shapes
UNSELECTED = -2,
// multiple spectral windows with same shape
ALL = -1
};
// Default constructor, only useful to assign to.
MSRange();
// Construct from an MS.
explicit MSRange(const MeasurementSet& ms);
// construct from an MSSelector, if this constructor is used, the data
// will be channel selected and polarization converted as specified in
// the MSSelector object, and the current selection is used in the range.
explicit MSRange(const MSSelector& msSel);
// Copy constructor
MSRange(const MSRange& other);
// Assignment
MSRange& operator=(const MSRange& other);
// Return the range of values for each of the items specified in
// the record. For index-like items a list of values is returned,
// for non-index items the minimum and maximum are returned.
// Items with varying array shape will not be returned by this function (i.e.
// you may need to preselect the MS passed to MSRange).
// See the enum description in MSSelector for the list of supported items.
// Use the data flags if useFlags is True.
// Correct for one-based indexing if oneBased is True.
Record range(const Vector<String>& items,
Bool useFlags=True,
Bool OneBased=False);
// Same as previous function, with Vector of MSS::Field keys instead
// of Strings
Record range(const Vector<Int>& items,
Bool useFlags=True,
Bool OneBased=False);
// Similar to above, with a single enum, for convenience
Record range(MSS::Field item,
Bool useFlags=True);
// Set the block size (in Mbytes) to use when reading the data column.
// The default is 10 MB. Actual memory used is higher due to
// temporaries and caching.
void setBlockSize(Int blockSize=10);
protected:
// check the data description selection (one or more with same shape, or
// varying shape)
Bool checkShapes();
// get the range of a ScalarColumn<Int>, correct for 1-based
// indexing if oneBased is True, and add to out record.
void scalarRange(Record& out, const String& item,
const ScalarColumn<Int>& id, Bool oneBased);
// get the range of a ScalarColumn<Int>
Vector<Int> scalarRange(const ScalarColumn<Int>& id);
// get the minimum and maximum of a Complex data column, after
// application of some function to convert to Float (e.g., real,
// amplitude,...). This function reads the data in blocks of
// size blockSize, as set by the setBlockSize function.
void minMax(Matrix<Float>& minmax,
const Vector<Bool>& funcSel,
const ArrayColumn<Complex>& data1,
const ArrayColumn<Complex>& data2,
const ArrayColumn<Bool>& flag,
Int dataType,
Bool useFlags);
// get the minimum and maximum of a Float data column
// This function reads the data in blocks of
// size blockSize, as set by the setBlockSize function.
void minMax(Float& mini, Float& maxi,
const ArrayColumn<Float>& data,
const ArrayColumn<Bool>& flag,
Bool useFlags);
// Get the range of interferometer numbers given the antenna1 and antenna2
// columns.
Vector<Int> ifrNumbers(const ScalarColumn<Int>& ant1,
const ScalarColumn<Int>& ant2);
private:
// The function types
enum {Amp,Phase,Real,Imag,Data,nFuncType};
// The data types
enum {Observed,Corrected,Model,Ratio,Residual,ObsResidual,ObsFloat,nDataType};
MeasurementSet ms_p; // the original ms
Int blockSize_p;
Vector<Int> ddId_p;
Vector<uInt> spwId_p;
Vector<uInt> polId_p;
Bool constantShape_p;
const MSSelector* sel_p;
};
} //# NAMESPACE CASACORE - END
#endif
casacore::ArrayColumn
Definition ArrayColumn.h:98
casacore::MSRange::ms_p
MeasurementSet ms_p
Definition MSRange.h:205
casacore::MSRange::Amp
@ Amp
Definition MSRange.h:200
casacore::MSRange::Real
@ Real
Definition MSRange.h:200
casacore::MSRange::Imag
@ Imag
Definition MSRange.h:200
casacore::MSRange::nFuncType
@ nFuncType
Definition MSRange.h:200
casacore::MSRange::Phase
@ Phase
Definition MSRange.h:200
casacore::MSRange::Data
@ Data
Definition MSRange.h:200
casacore::MSRange::ifrNumbers
Vector< Int > ifrNumbers(const ScalarColumn< Int > &ant1, const ScalarColumn< Int > &ant2)
Get the range of interferometer numbers given the antenna1 and antenna2 columns.
casacore::MSRange::scalarRange
void scalarRange(Record &out, const String &item, const ScalarColumn< Int > &id, Bool oneBased)
get the range of a ScalarColumn<Int>, correct for 1-based indexing if oneBased is True,...
casacore::MSRange::operator=
MSRange & operator=(const MSRange &other)
Assignment.
casacore::MSRange::scalarRange
Vector< Int > scalarRange(const ScalarColumn< Int > &id)
get the range of a ScalarColumn<Int>
casacore::MSRange::minMax
void minMax(Matrix< Float > &minmax, const Vector< Bool > &funcSel, const ArrayColumn< Complex > &data1, const ArrayColumn< Complex > &data2, const ArrayColumn< Bool > &flag, Int dataType, Bool useFlags)
get the minimum and maximum of a Complex data column, after application of some function to convert t...
casacore::MSRange::MSRange
MSRange(const MSSelector &msSel)
construct from an MSSelector, if this constructor is used, the data will be channel selected and pola...
casacore::MSRange::ddId_p
Vector< Int > ddId_p
Definition MSRange.h:207
casacore::MSRange::sel_p
const MSSelector * sel_p
Definition MSRange.h:211
casacore::MSRange::ObsResidual
@ ObsResidual
Definition MSRange.h:203
casacore::MSRange::nDataType
@ nDataType
Definition MSRange.h:203
casacore::MSRange::Residual
@ Residual
Definition MSRange.h:203
casacore::MSRange::ObsFloat
@ ObsFloat
Definition MSRange.h:203
casacore::MSRange::Corrected
@ Corrected
Definition MSRange.h:203
casacore::MSRange::Ratio
@ Ratio
Definition MSRange.h:203
casacore::MSRange::Model
@ Model
Definition MSRange.h:203
casacore::MSRange::Observed
@ Observed
Definition MSRange.h:203
casacore::MSRange::blockSize_p
Int blockSize_p
Definition MSRange.h:206
casacore::MSRange::spwId_p
Vector< uInt > spwId_p
Definition MSRange.h:208
casacore::MSRange::minMax
void minMax(Float &mini, Float &maxi, const ArrayColumn< Float > &data, const ArrayColumn< Bool > &flag, Bool useFlags)
get the minimum and maximum of a Float data column This function reads the data in blocks of size blo...
casacore::MSRange::constantShape_p
Bool constantShape_p
Definition MSRange.h:210
casacore::MSRange::MSRange
MSRange()
Default constructor, only useful to assign to.
casacore::MSRange::range
Record range(const Vector< Int > &items, Bool useFlags=True, Bool OneBased=False)
Same as previous function, with Vector of MSS::Field keys instead of Strings.
casacore::MSRange::polId_p
Vector< uInt > polId_p
Definition MSRange.h:209
casacore::MSRange::MSRange
MSRange(const MeasurementSet &ms)
Construct from an MS.
casacore::MSRange::range
Record range(const Vector< String > &items, Bool useFlags=True, Bool OneBased=False)
Return the range of values for each of the items specified in the record.
casacore::MSRange::range
Record range(MSS::Field item, Bool useFlags=True)
Similar to above, with a single enum, for convenience.
casacore::MSRange::UNCHECKED
@ UNCHECKED
spectral window selection and shapes have not been checked
Definition MSRange.h:108
casacore::MSRange::ALL
@ ALL
multiple spectral windows with same shape
Definition MSRange.h:112
casacore::MSRange::UNSELECTED
@ UNSELECTED
multiple spectral windows with varying shapes
Definition MSRange.h:110
casacore::MSRange::setBlockSize
void setBlockSize(Int blockSize=10)
Set the block size (in Mbytes) to use when reading the data column.
casacore::MSRange::checkShapes
Bool checkShapes()
check the data description selection (one or more with same shape, or varying shape)
casacore::MSRange::MSRange
MSRange(const MSRange &other)
Copy constructor.
casacore::MSSelectionKeywords::Field
Field
The fields in the MS for which selection and range operations are defined.
Definition MSSelectionKeywords.h:92
casacore::MSSelector
Definition MSSelector.h:111
casacore::Matrix
Definition Matrix.h:87
casacore::MeasurementSet
Definition MeasurementSet.h:278
casacore::ScalarColumn
Definition ScalarColumn.h:83
casacore::String
String: the storage and methods of handling collections of characters.
Definition String.h:223
casacore::Vector
Definition Vector.h:82
casacore::Record
Record()
casacore
this file contains all the compiler specific defines
Definition mainpage.dox:28
casacore::False
const Bool False
Definition aipstype.h:42
casacore::Float
float Float
Definition aipstype.h:52
casacore::Int
int Int
Definition aipstype.h:48
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
casacore::True
const Bool True
Definition aipstype.h:41
casacore::dataType
DataType dataType(const RecordFieldId &) const