Skip to content
Snippets Groups Projects
Commit 905dbc1e authored by Mattia Mancini's avatar Mattia Mancini
Browse files

OSB-44: updating epic branch from trunk

parents a62a1082 8b1377d1
No related branches found
No related tags found
2 merge requests!89Monitoring maintenance Epic branch merge,!1Resolve OSB-13 "Monitoringmaintenance "
......@@ -146,6 +146,9 @@ namespace LOFAR
void MeasurementSetFormat::createMSTables(const string &MSname, unsigned subband)
{
try {
int subarray = itsPS.settings.subbands[subband].SAP;
string directionType = itsPS.settings.SAPs[subarray].direction.type;
TableDesc td = MS::requiredTableDesc();
MS::addColumnToDesc(td, MS::DATA, 2);
MS::addColumnToDesc(td, MS::WEIGHT_SPECTRUM, 2);
......@@ -153,9 +156,10 @@ namespace LOFAR
// Note it must be done here, because the UVW column in the MS is readonly
// (because LofarStMan is used).
{
ColumnDesc &col(td.rwColumnDesc("UVW"));
TableRecord rec = col.keywordSet().asRecord("MEASINFO");
rec.define("Ref", "J2000");
rec.define("Ref", directionType);
col.rwKeywordSet().defineRecord("MEASINFO", rec);
}
......@@ -182,9 +186,6 @@ namespace LOFAR
LOG_FATAL_STR("AipsError: " << ex.what());
}
// Get subarray id (formerly known as beam).
int subarray = itsPS.settings.subbands[subband].SAP;
fillAntenna(antMPos);
fillFeed();
fillField(subarray);
......
......@@ -5,9 +5,9 @@ include(LofarCTest)
if(UNITTEST++_FOUND)
lofar_add_test(tSubbandWriter tSubbandWriter.cc)
lofar_add_test(tOutputThread tOutputThread.cc)
lofar_add_test(tMeasurementSetFormat tMeasurementSetFormat.cc)
endif()
lofar_add_test(tMeasurementSetFormat tMeasurementSetFormat.cc)
lofar_add_test(tMSWriterDAL tMSWriterDAL.cc)
# The MS Writer needs the LOFAR Storage manager and static meta data files.
# For production, LOFARROOT is used, but build/source dir structure differs
......
......@@ -21,12 +21,16 @@
#include <lofar_config.h>
#include <string>
#include <cstdio>
#include <Common/LofarLogger.h>
#include <Common/Exception.h>
#include <OutputProc/MeasurementSetFormat.h>
#include <casa/IO/RegularFileIO.h>
#include <casacore/tables/Tables.h>
#include <UnitTest++.h>
#include <boost/format.hpp>
using namespace LOFAR;
using namespace LOFAR::Cobalt;
......@@ -36,28 +40,58 @@ using namespace std;
// Define handler that tries to print a backtrace.
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()
{
INIT_LOGGER("tMeasurementSetFormat");
const string suffixes[] = { "-j2000", "-sun" };
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;
return UnitTest::RunAllTests() > 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment