PURIFY
Next-generation radio interferometric imaging
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
purify::casa::MeasurementSet Class Reference

Interface around measurement sets. More...

#include <casacore.h>

Classes

class  ChannelWrapper
 
class  const_iterator
 

Public Types

typedef Eigen::Array< t_real, 2, 1 > Direction
 Type for (RA, DEC) direction. More...
 

Public Member Functions

 MeasurementSet (std::string const filename)
 Constructs the interface around a given measurement set. More...
 
 MeasurementSet (MeasurementSet const &c)
 Shallow measurement set copy. More...
 
std::string const & filename () const
 Filename of the measurement set. More...
 
MeasurementSetfilename (std::string const &filename)
 Set new filename. More...
 
::casacore::Table const & table (std::string const &name="") const
 Gets table or subtable. More...
 
template<class T >
::casacore::ScalarColumn< T > scalar_column (std::string const &col, std::string const &tabname="") const
 Gets scalar column from table. More...
 
template<class T >
::casacore::ArrayColumn< T > array_column (std::string const &col, std::string const &tabname="") const
 Gets array column from table. More...
 
void clear ()
 Clear memory. More...
 
template<class T >
Matrix< T > column (std::string const &column, std::string const &filter="") const
 Data from a column. More...
 
std::size_t size () const
 Number of channels in the measurement set. More...
 
const_iterator begin (std::string const &filter="") const
 Iterates over channels. More...
 
const_iterator end (std::string const &filter="") const
 Iterates over channels. More...
 
ChannelWrapper operator[] (t_uint i) const
 Returns wrapper over specific channel. More...
 
ChannelWrapper operator[] (std::tuple< t_uint, std::string > const &i) const
 Returns wrapper over specific channel. More...
 
Direction direction (t_real tolerance=1e-8, std::string const &filter="") const
 Direction (RA, DEC) in radians. More...
 
Direction::Scalar right_ascension (t_real tolerance=1e-8, std::string const &filter="") const
 Right ascention in radians. More...
 
Direction::Scalar declination (t_real tolerance=1e-8, std::string const &filter="") const
 Declination in radians. More...
 

Static Public Attributes

static std::string const default_filter = "WHERE NOT ANY(FLAG)"
 Default filter specifying which data to accept. More...
 

Detailed Description

Interface around measurement sets.

Definition at line 27 of file casacore.h.

Member Typedef Documentation

◆ Direction

typedef Eigen::Array<t_real, 2, 1> purify::casa::MeasurementSet::Direction

Type for (RA, DEC) direction.

Definition at line 35 of file casacore.h.

Constructor & Destructor Documentation

◆ MeasurementSet() [1/2]

purify::casa::MeasurementSet::MeasurementSet ( std::string const  filename)
inline

Constructs the interface around a given measurement set.

Definition at line 38 of file casacore.h.

39  : filename_(filename),
40  tables_(std::make_shared<std::map<std::string, ::casacore::Table>>()){};
std::string const & filename() const
Filename of the measurement set.
Definition: casacore.h:44

◆ MeasurementSet() [2/2]

purify::casa::MeasurementSet::MeasurementSet ( MeasurementSet const &  c)
inline

Shallow measurement set copy.

Definition at line 42 of file casacore.h.

42 : filename_(c.filename_), tables_(c.tables_){};
const t_real c
speed of light in vacuum
Definition: types.h:72

Member Function Documentation

◆ array_column()

template<class T >
::casacore::ArrayColumn<T> purify::casa::MeasurementSet::array_column ( std::string const &  col,
std::string const &  tabname = "" 
) const
inline

Gets array column from table.

Definition at line 59 of file casacore.h.

60  {
61  return get_column<T, ::casacore::ArrayColumn>(col, tabname);
62  }

◆ begin()

MeasurementSet::const_iterator purify::casa::MeasurementSet::begin ( std::string const &  filter = "") const

Iterates over channels.

Definition at line 37 of file casacore.cc.

37  {
38  return const_iterator(0, *this, filter);
39 }

◆ clear()

void purify::casa::MeasurementSet::clear ( )
inline

Clear memory.

Definition at line 64 of file casacore.h.

64 { tables_ = std::make_shared<std::map<std::string, ::casacore::Table>>(); }

Referenced by filename().

◆ column()

template<class T >
Matrix<T> purify::casa::MeasurementSet::column ( std::string const &  column,
std::string const &  filter = "" 
) const
inline

Data from a column.

Definition at line 68 of file casacore.h.

68  {
69  return table_column<T>(this->table(), column, filter);
70  }
::casacore::Table const & table(std::string const &name="") const
Gets table or subtable.
Definition: casacore.cc:18
Matrix< T > column(std::string const &column, std::string const &filter="") const
Data from a column.
Definition: casacore.h:68

References table().

Referenced by purify::casa::MeasurementSet::ChannelWrapper::data_desc_id(), purify::casa::MeasurementSet::ChannelWrapper::field_ids(), and size().

◆ declination()

Direction::Scalar purify::casa::MeasurementSet::declination ( t_real  tolerance = 1e-8,
std::string const &  filter = "" 
) const
inline

Declination in radians.

Definition at line 90 of file casacore.h.

90  {
91  return direction(tolerance, filter)(1);
92  }
Direction direction(t_real tolerance=1e-8, std::string const &filter="") const
Direction (RA, DEC) in radians.
Definition: casacore.cc:102

References direction().

Referenced by purify::casa::MeasurementSet::ChannelWrapper::declination(), and purify::casa::read_measurementset().

◆ direction()

MeasurementSet::Direction purify::casa::MeasurementSet::direction ( t_real  tolerance = 1e-8,
std::string const &  filter = "" 
) const

Direction (RA, DEC) in radians.

Definition at line 102 of file casacore.cc.

103  {
104  auto const field_ids_raw = column<::casacore::Int>("FIELD_ID", filter);
105  auto const source_ids_raw = table_column<::casacore::Int>(table("FIELD"), "SOURCE_ID");
106  std::set<::casacore::Int> source_ids;
107  for (Eigen::DenseIndex i(0); i < field_ids_raw.size(); ++i) {
108  assert(field_ids_raw(i) < source_ids_raw.size());
109  source_ids.insert(source_ids_raw(field_ids_raw(i)));
110  }
111  if (source_ids.size() == 0 and source_ids_raw.size() > 0) {
112  PURIFY_DEBUG(
113  "Could not find sources. Try different filter, no matching data in channel. "
114  "Currently using filter: " +
115  filter);
116  Vector<t_real> original(2);
117  original(0) = 0.;
118  original(1) = 0.;
119  return original;
120  } else if (source_ids_raw.size() == 0)
121  throw std::runtime_error("Could not find sources. Cannot determine direction");
122  auto const directions = table_column<::casacore::Double>(table("SOURCE"), "DIRECTION");
123  auto const original = directions.row(*source_ids.begin());
124  for (auto const other : source_ids)
125  if (not directions.row(other).isApprox(original, tolerance))
126  throw std::runtime_error("Found more than one direction");
127  return original;
128 }
#define PURIFY_DEBUG(...)
\macro Output some debugging
Definition: logging.h:197

References PURIFY_DEBUG, and table().

Referenced by declination(), purify::casa::MeasurementSet::ChannelWrapper::direction(), and right_ascension().

◆ end()

MeasurementSet::const_iterator purify::casa::MeasurementSet::end ( std::string const &  filter = "") const

Iterates over channels.

Definition at line 40 of file casacore.cc.

40  {
41  return const_iterator(size(), *this, filter);
42 }
std::size_t size() const
Number of channels in the measurement set.
Definition: casacore.cc:27

References size().

Referenced by purify::casa::read_measurementset_channels().

◆ filename() [1/2]

std::string const& purify::casa::MeasurementSet::filename ( ) const
inline

Filename of the measurement set.

Definition at line 44 of file casacore.h.

44 { return filename_; }

Referenced by filename(), purify::casa::read_measurementset(), purify::casa::read_measurementset_channels(), and table().

◆ filename() [2/2]

MeasurementSet & purify::casa::MeasurementSet::filename ( std::string const &  filename)

Set new filename.

Definition at line 12 of file casacore.cc.

12  {
13  clear();
14  filename_ = filename;
15  return *this;
16 }
void clear()
Clear memory.
Definition: casacore.h:64

References clear(), and filename().

◆ operator[]() [1/2]

MeasurementSet::ChannelWrapper purify::casa::MeasurementSet::operator[] ( std::tuple< t_uint, std::string > const &  i) const

Returns wrapper over specific channel.

Definition at line 47 of file casacore.cc.

48  {
49  if (std::get<0>(i) >= size()) throw std::out_of_range("Not that many channels");
50  return ChannelWrapper(std::get<0>(i), *this, std::get<1>(i));
51 }

References size().

◆ operator[]() [2/2]

MeasurementSet::ChannelWrapper purify::casa::MeasurementSet::operator[] ( t_uint  i) const

Returns wrapper over specific channel.

Definition at line 43 of file casacore.cc.

43  {
44  return ChannelWrapper(i, *this, "");
45 }

◆ right_ascension()

Direction::Scalar purify::casa::MeasurementSet::right_ascension ( t_real  tolerance = 1e-8,
std::string const &  filter = "" 
) const
inline

Right ascention in radians.

Definition at line 86 of file casacore.h.

86  {
87  return direction(tolerance, filter)(0);
88  }

References direction().

Referenced by purify::casa::read_measurementset(), and purify::casa::MeasurementSet::ChannelWrapper::right_ascension().

◆ scalar_column()

template<class T >
::casacore::ScalarColumn<T> purify::casa::MeasurementSet::scalar_column ( std::string const &  col,
std::string const &  tabname = "" 
) const
inline

Gets scalar column from table.

Definition at line 53 of file casacore.h.

54  {
55  return get_column<T, ::casacore::ScalarColumn>(col, tabname);
56  }

◆ size()

std::size_t purify::casa::MeasurementSet::size ( ) const

Number of channels in the measurement set.

Definition at line 27 of file casacore.cc.

27  {
28  if (table().nrow() == 0) return 0;
29  auto const column = array_column<::casacore::Double>("CHAN_FREQ", "SPECTRAL_WINDOW");
30  auto const orig = column.shape(0);
31  for (t_uint i(1); i < column.nrow(); ++i)
32  if (orig != column.shape(i))
33  throw std::runtime_error("Can only do rectangular measurement set for now");
34  return orig(0);
35 }

References column(), and table().

Referenced by end(), operator[](), and purify::casa::read_measurementset().

◆ table()

casacore::Table const & purify::casa::MeasurementSet::table ( std::string const &  name = "") const

Gets table or subtable.

Definition at line 18 of file casacore.cc.

18  {
19  auto const tabname = name == "" ? filename() : filename() + "/" + name;
20  auto i_result = tables_->find(tabname);
21  if (i_result == tables_->end())
22  i_result = tables_->emplace(tabname, ::casacore::Table(tabname)).first;
23 
24  return i_result->second;
25 }

References filename().

Referenced by column(), direction(), purify::casa::MeasurementSet::const_iterator::same_measurement_set(), and size().

Member Data Documentation

◆ default_filter

std::string const purify::casa::MeasurementSet::default_filter = "WHERE NOT ANY(FLAG)"
static

Default filter specifying which data to accept.

Definition at line 33 of file casacore.h.


The documentation for this class was generated from the following files: