Skip to content
Snippets Groups Projects
Commit a3db9eb8 authored by Jan David Mol's avatar Jan David Mol
Browse files

COB-56: Added test to check for correct storage of UVW MEASINFO reference frame

parent 319129af
No related branches found
No related tags found
1 merge request!6Import cobalt2 into lofar4
...@@ -5,9 +5,9 @@ include(LofarCTest) ...@@ -5,9 +5,9 @@ include(LofarCTest)
if(UNITTEST++_FOUND) if(UNITTEST++_FOUND)
lofar_add_test(tSubbandWriter tSubbandWriter.cc) lofar_add_test(tSubbandWriter tSubbandWriter.cc)
lofar_add_test(tOutputThread tOutputThread.cc) lofar_add_test(tOutputThread tOutputThread.cc)
lofar_add_test(tMeasurementSetFormat tMeasurementSetFormat.cc)
endif() endif()
lofar_add_test(tMeasurementSetFormat tMeasurementSetFormat.cc)
lofar_add_test(tMSWriterDAL tMSWriterDAL.cc) lofar_add_test(tMSWriterDAL tMSWriterDAL.cc)
# The MS Writer needs the LOFAR Storage manager and static meta data files. # The MS Writer needs the LOFAR Storage manager and static meta data files.
# For production, LOFARROOT is used, but build/source dir structure differs # For production, LOFARROOT is used, but build/source dir structure differs
......
...@@ -21,12 +21,16 @@ ...@@ -21,12 +21,16 @@
#include <lofar_config.h> #include <lofar_config.h>
#include <string> #include <string>
#include <cstdio>
#include <Common/LofarLogger.h> #include <Common/LofarLogger.h>
#include <Common/Exception.h> #include <Common/Exception.h>
#include <OutputProc/MeasurementSetFormat.h> #include <OutputProc/MeasurementSetFormat.h>
#include <casacore/casa/IO/RegularFileIO.h> #include <casacore/casa/IO/RegularFileIO.h>
#include <casacore/tables/Tables.h>
#include <UnitTest++.h>
#include <boost/format.hpp>
using namespace LOFAR; using namespace LOFAR;
using namespace LOFAR::Cobalt; using namespace LOFAR::Cobalt;
...@@ -36,28 +40,58 @@ using namespace std; ...@@ -36,28 +40,58 @@ using namespace std;
// Define handler that tries to print a backtrace. // Define handler that tries to print a backtrace.
Exception::TerminateHandler t(Exception::terminate); Exception::TerminateHandler t(Exception::terminate);
// create a MS using settings for subband 0 from a parset
void createMS(const string &parsetName, const string &msName)
{
Parset parset(parsetName);
MeasurementSetFormat msf(parset);
msf.addSubband(msName, 0);
// Also create the data file, otherwise it is not a true table.
RegularFileIO file(String(msName + "/table.f0data"),
ByteIO::New);
}
string getMeasInfoRef(const string &msName)
{
TableDesc desc;
Table::getLayout(desc, msName);
ColumnDesc &col(desc.rwColumnDesc("UVW"));
TableRecord rec = col.keywordSet().asRecord("MEASINFO");
String ref;
rec.get("Ref", ref);
return ref;
}
TEST(J2000)
{
const string parsetName = "tMeasurementSetFormat.parset-j2000";
const string msName = "tMeasurementSetFormat_tmp-j2000.MS";
LOG_DEBUG_STR("Testing " << parsetName);
createMS(parsetName, msName);
CHECK_EQUAL("J2000", getMeasInfoRef(msName));
}
TEST(SUN)
{
const string parsetName = "tMeasurementSetFormat.parset-sun";
const string msName = "tMeasurementSetFormat_tmp-sun.MS";
LOG_DEBUG_STR("Testing " << parsetName);
createMS(parsetName, msName);
CHECK_EQUAL("SUN", getMeasInfoRef(msName));
}
int main() int main()
{ {
INIT_LOGGER("tMeasurementSetFormat"); INIT_LOGGER("tMeasurementSetFormat");
const string suffixes[] = { "-j2000", "-sun" };
return UnitTest::RunAllTests() > 0;
for( unsigned i = 0; i < sizeof suffixes / sizeof suffixes[0]; i++ )
{
const string parsetName = string("tMeasurementSetFormat.parset") + suffixes[i];
const string msName = string("tMeasurementSetFormat_tmp") + suffixes[i] + ".MS";
LOG_DEBUG_STR("Testing " << parsetName);
Parset parset(parsetName);
MeasurementSetFormat msf(parset);
msf.addSubband(msName, 0);
// Also create the data file, otherwise it is not a true table.
///FILE* file= fopen ("tMeasurementSetFormat_tmp.ms/f0data", "w");
///fclose (file);
RegularFileIO file(String(msName + "/table.f0data"),
ByteIO::New);
}
return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment