PURIFY
Next-generation radio interferometric imaging
Classes | Functions | Variables
casacore.cc File Reference
#include "purify/casacore.h"
#include <boost/filesystem.hpp>
#include <casacore/ms/MeasurementSets/MeasurementSet.h>
#include <casacore/tables/TaQL/TableParse.h>
#include <casacore/tables/Tables/ArrColDesc.h>
#include <casacore/tables/Tables/ArrayColumn.h>
#include <casacore/tables/Tables/ColumnDesc.h>
#include <casacore/tables/Tables/ScaColDesc.h>
#include <casacore/tables/Tables/ScalarColumn.h>
#include <casacore/tables/Tables/SetupNewTab.h>
#include <casacore/tables/Tables/TableColumn.h>
#include "purify/directories.h"
#include "purify/types.h"
#include "purify/utilities.h"
#include "catch2/catch_all.hpp"
+ Include dependency graph for casacore.cc:

Go to the source code of this file.

Classes

class  TmpPath
 
class  TmpMS
 

Functions

 TEST_CASE ("Casacore")
 
 TEST_CASE ("Size/Number of channels")
 
 TEST_CASE ("Single channel")
 
 TEST_CASE ("Measurement channel")
 
 TEST_CASE ("Channel iteration")
 
 TEST_CASE ("Direction")
 

Variables

const std::string test_file = atca_filename("0332-391.ms")
 

Function Documentation

◆ TEST_CASE() [1/6]

TEST_CASE ( "Casacore"  )

Definition at line 20 of file casacore.cc.

20  {
21  // create the table descriptor
22  casa::TableDesc simpleDesc = casa::MS::requiredTableDesc();
23  // set up a new table
24  casa::SetupNewTable newTab("simpleTab", simpleDesc, casa::Table::New);
25  // create the MeasurementSet
26  casa::MeasurementSet simpleMS(newTab);
27  // now we need to define all required subtables
28  // the following call does this for us if we don't need to
29  // specify details of Storage Managers for columns.
30  simpleMS.createDefaultSubtables(casa::Table::New);
31  // fill MeasurementSet via its Table interface
32  // For example, construct one of the columns
33  casa::TableColumn feed(simpleMS, casa::MS::columnName(casa::MS::FEED1));
34  casa::uInt rownr = 0;
35  // add a row
36  simpleMS.addRow();
37  // set the values in that row, e.g. the feed column
38  feed.putScalar(rownr, 1);
39  // Access a subtable
40  casa::ArrayColumn<casa::Double> antpos(simpleMS.antenna(),
41  casa::MSAntenna::columnName(casa::MSAntenna::POSITION));
42  simpleMS.antenna().addRow();
43  casa::Array<casa::Double> position(casa::IPosition(1, 3));
44  position(casa::IPosition(1, 0)) = 1.;
45  position(casa::IPosition(1, 1)) = 2.;
46  position(casa::IPosition(1, 2)) = 3.;
47  antpos.put(0, position);
48 }

◆ TEST_CASE() [2/6]

TEST_CASE ( "Channel iteration"  )

Definition at line 168 of file casacore.cc.

168  {
169  std::vector<int> const valids{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
171  auto i_channel = ms.begin();
172  auto const i_end = ms.end();
173  for (; i_channel < i_end; i_channel += 5) {
174  CHECK(i_channel->channel() < 13);
175  bool const is_valid =
176  std::find(valids.begin(), valids.end(), i_channel->channel()) != valids.end();
177  CHECK(is_valid == i_channel->is_valid());
178  }
179 }
#define CHECK(CONDITION, ERROR)
Definition: casa.cc:6
Interface around measurement sets.
Definition: casacore.h:27
const std::string test_file
Definition: casacore.cc:82

References CHECK, and test_file.

◆ TEST_CASE() [3/6]

TEST_CASE ( "Direction"  )

Definition at line 181 of file casacore.cc.

181  {
183  auto const direction = ms.direction();
184  auto const right_ascension = ms.right_ascension();
185  auto const declination = ms.declination();
186  CHECK(std::abs(right_ascension - 0.934273294000000031900299291010014712810516357421875) < 1e-8);
187  CHECK(std::abs(declination + 0.68069387400000003207622967238421551883220672607421875) < 1e-8);
188  CHECK(std::abs(direction[0] - 0.934273294000000031900299291010014712810516357421875) < 1e-8);
189  CHECK(std::abs(direction[1] + 0.68069387400000003207622967238421551883220672607421875) < 1e-8);
190 }

References CHECK, and test_file.

◆ TEST_CASE() [4/6]

TEST_CASE ( "Measurement channel"  )

Definition at line 158 of file casacore.cc.

158  {
159  using namespace purify;
160  auto const channel = purify::casa::MeasurementSet(test_file)[0];
161  REQUIRE(channel.is_valid());
162  auto const I = channel.I();
163  REQUIRE(I.size() == 20490);
164  CHECK(std::abs(I(0) - t_complex(-0.01469034608454, -0.00434834882617)) < 1e-12);
165  CHECK(std::abs(I(10) - t_complex(-0.09461227059364, -0.01139064785093)) < 1e-12);
166 }

References CHECK, purify::I, and test_file.

◆ TEST_CASE() [5/6]

TEST_CASE ( "Single channel"  )

Definition at line 88 of file casacore.cc.

88  {
89  namespace pc = purify::casa;
90  auto const ms = pc::MeasurementSet(test_file);
91  SECTION("Check channel validity") {
92  CHECK(pc::MeasurementSet::const_iterator::value_type(0, ms).is_valid());
93  CHECK(pc::MeasurementSet::const_iterator::value_type(4, ms).is_valid());
94  }
95  // Raw data from the measurement set "0332-391.ms" was read out using CASA's casabrowser
96  // executable. Then it was copied into this test.
97  SECTION("Raw UVW") {
98  auto const channel = pc::MeasurementSet::const_iterator::value_type(11, ms);
99  REQUIRE(channel.size() == 20541);
100  auto const u = channel.raw_u();
101  REQUIRE(u.size() == 20541);
102  CHECK(std::abs(u[0] - 3889.46519177759410013095475733280181884765625) < 1e-8);
103  CHECK(std::abs(u[3360] - 683.2842475491) < 1e-8);
104  auto const v = channel.raw_v();
105  REQUIRE(v.size() == 20541);
106  CHECK(std::abs(v[0] - 1346.20383349449502929928712546825408935546875) < 1e-8);
107  CHECK(std::abs(v[3360] + 785.8117311632) < 1e-8);
108  auto const w = channel.raw_w();
109  REQUIRE(w.size() == 20541);
110  CHECK(std::abs(w[0] - 1663.30025165469896819558925926685333251953125) < 1e-8);
111  CHECK(std::abs(w[3360] + 970.3123979733) < 1e-8);
112  }
113 
114  SECTION("Raw frequencies") {
115  auto const f0 = pc::MeasurementSet::const_iterator::value_type(0, ms).raw_frequencies();
116  CHECK(f0.size() == 1);
117  CHECK(std::abs(f0(0) - 1431999959.500274181365966796875) < 1e-1);
118 
119  auto const f11 = pc::MeasurementSet::const_iterator::value_type(11, ms).raw_frequencies();
120  CHECK(f11.size() == 1);
121  CHECK(std::abs(f11(0) - 1343999961.9890842437744140625) < 1e-1);
122  }
123 
124  SECTION("data desc id") {
125  REQUIRE(pc::MeasurementSet::const_iterator::value_type(0, ms).data_desc_id().size() == 20490);
126  REQUIRE(pc::MeasurementSet::const_iterator::value_type(4, ms).data_desc_id().size() == 20606);
127  }
128 
129  SECTION("I") {
130  using namespace purify;
131  auto const I = pc::MeasurementSet::const_iterator::value_type(11, ms).I();
132  REQUIRE(I.size() == 20541);
133  CHECK(std::abs(I(0) - t_complex(0.1666463911533, -0.05232101678848)) < 1e-12);
134  CHECK(std::abs(I(10) - t_complex(0.1421023607254, -0.04858251661062)) < 1e-12);
135 
136  REQUIRE(pc::MeasurementSet::const_iterator::value_type(0, ms).I().size() == 20490);
137  }
138 
139  SECTION("wI") {
140  using namespace purify;
141  auto const wI = pc::MeasurementSet::const_iterator::value_type(11, ms).wI();
142  REQUIRE(wI.size() == 20541);
143  CAPTURE(wI.head(5).transpose());
144  CHECK(wI.isApprox(0.5 * purify::Vector<t_real>::Ones(wI.size())));
145  }
146 
147  SECTION("frequencies") {
148  using namespace purify;
149  auto const f = pc::MeasurementSet::const_iterator::value_type(11, ms).frequencies();
150  REQUIRE(f.size() == 20541);
151  CHECK(std::abs(f(0) - 1343999961.989) < 1e-0);
152  CHECK(std::abs(f(1680) - 1343999961.989) < 1e-0);
153  CHECK(std::abs(f(3360) - 1343999961.989) < 1e-0);
154  CHECK(std::abs(f(5040) - 1343999961.989) < 1e-0);
155  }
156 }
const std::vector< t_real > u
data for u coordinate
Definition: operators.cc:18
const std::vector< t_real > v
data for v coordinate
Definition: operators.cc:20

References CHECK, purify::I, test_file, operators_test::u, and operators_test::v.

◆ TEST_CASE() [6/6]

TEST_CASE ( "Size/Number of channels"  )

Definition at line 84 of file casacore.cc.

84  {
86 }

References CHECK, and test_file.

Variable Documentation

◆ test_file

const std::string test_file = atca_filename("0332-391.ms")

Definition at line 82 of file casacore.cc.

Referenced by TEST_CASE().