Skip to content
Snippets Groups Projects
Commit 871a2968 authored by Ger van Diepen's avatar Ger van Diepen
Browse files

bug 1660:

Optionally accept non-existinf AntennaField files
parent ec058d58
No related branches found
No related tags found
No related merge requests found
...@@ -56,7 +56,10 @@ namespace LOFAR { ...@@ -56,7 +56,10 @@ namespace LOFAR {
typedef pair<vector<size_t>, vector<double> > AFArray; typedef pair<vector<size_t>, vector<double> > AFArray;
// Read the AntennaField file. // Read the AntennaField file.
explicit AntField (const string& filename); // If <src>mustExist=true</src> an exception is thrown if the file does
// not exist. Otherwise an error message is logged and zero data is filled
// in for the various arrays.
explicit AntField (const string& filename, bool mustExist=true);
~AntField(); ~AntField();
...@@ -116,6 +119,17 @@ namespace LOFAR { ...@@ -116,6 +119,17 @@ namespace LOFAR {
// Get max nr of fields // Get max nr of fields
int maxFields() const; int maxFields() const;
// Read the arrays from the file.
void readFile (istream& inputStream, const string& fullFilename);
// Initialize all arrays to zero.
void setZeroes();
// Initialize an array to the given shape and fill with zeroes.
void initArray (AntField::AFArray& array, size_t n1);
void initArray (AntField::AFArray& array, size_t n1, size_t n2);
void initArray (AntField::AFArray& array, size_t n1, size_t n2, size_t n3);
// Helper function to read an array in Blitz format. // Helper function to read an array in Blitz format.
template<int NDIM> template<int NDIM>
static void readBlitzArray(AntField::AFArray& array, istream& is) static void readBlitzArray(AntField::AFArray& array, istream& is)
......
...@@ -64,15 +64,17 @@ namespace LOFAR { ...@@ -64,15 +64,17 @@ namespace LOFAR {
// itsxxxRCUPos[rcu,xyz] because some programs are antenna based, // itsxxxRCUPos[rcu,xyz] because some programs are antenna based,
// while others are rcu based. // while others are rcu based.
// //
AntField::AntField(const string& filename) AntField::AntField(const string& filename, bool mustExist)
{ {
// Locate the file (only done if no absolute path given). // Locate the file (only done if no absolute path given).
ConfigLocator cl; ConfigLocator cl;
string fullFilename(cl.locate(filename)); string fullFilename(cl.locate(filename));
ifstream inputStream (fullFilename.c_str()); ifstream inputStream (fullFilename.c_str());
ASSERTSTR(inputStream.good(), "File :" << fullFilename if (mustExist) {
<< " (extracted from: " << filename ASSERTSTR(inputStream.good(), "File :" << fullFilename
<< ") cannot be opened succesfully."); << " (extracted from: " << filename
<< ") cannot be opened succesfully.");
}
// Reserve space for expected info. // Reserve space for expected info.
itsAntPos.resize (MAX_FIELDS); itsAntPos.resize (MAX_FIELDS);
...@@ -81,6 +83,34 @@ namespace LOFAR { ...@@ -81,6 +83,34 @@ namespace LOFAR {
itsRotationMatrix.resize (MAX_FIELDS); itsRotationMatrix.resize (MAX_FIELDS);
itsRCULengths.resize (MAX_FIELDS); itsRCULengths.resize (MAX_FIELDS);
// Fill in zeroes if the file does not exist.
if (inputStream.good()) {
readFile (inputStream, fullFilename);
inputStream.close();
LOG_INFO_STR("Antenna position file " << fullFilename
<< " read in succesfully");
} else {
LOG_ERROR_STR("Antenna position file " << fullFilename
<< " not found; using zeroes instead");
setZeroes();
}
// Finally construct the HBA0 and HBA1 info if their centre positions
// are given.
if (! getShape(itsFieldCentres[HBA0_IDX]).empty()) {
LOG_DEBUG("Constructing HBA0 and HBA1 from HBA information");
makeSubField (HBA0_IDX);
makeSubField (HBA1_IDX);
}
}
AntField::~AntField()
{}
void AntField::readFile (istream& inputStream, const string& fullFilename)
{
string fieldName; string fieldName;
string inputLine; string inputLine;
int fieldIndex; int fieldIndex;
...@@ -160,8 +190,6 @@ namespace LOFAR { ...@@ -160,8 +190,6 @@ namespace LOFAR {
// Calculate length of RCU vectors. // Calculate length of RCU vectors.
makeRCULen (fieldIndex); makeRCULen (fieldIndex);
} // while not EOF } // while not EOF
inputStream.close();
ASSERTSTR(!getShape(itsAntPos[LBA_IDX]).empty() && ASSERTSTR(!getShape(itsAntPos[LBA_IDX]).empty() &&
!getShape(itsAntPos[HBA_IDX]).empty(), !getShape(itsAntPos[HBA_IDX]).empty(),
"File " << fullFilename << "File " << fullFilename <<
...@@ -170,22 +198,51 @@ namespace LOFAR { ...@@ -170,22 +198,51 @@ namespace LOFAR {
getShape(itsFieldCentres[HBA1_IDX]).empty(), getShape(itsFieldCentres[HBA1_IDX]).empty(),
"File " << fullFilename << "File " << fullFilename <<
"should contain definitions for both HBA0 and HBA1 or none"); "should contain definitions for both HBA0 and HBA1 or none");
}
// Finally construct the HBA0 and HBA1 info if their centre positions void AntField::setZeroes()
// are given. {
if (! getShape(itsFieldCentres[HBA0_IDX]).empty()) { for (int i=0; i<MAX_FIELDS; ++i) {
LOG_DEBUG("Constructing HBA0 and HBA1 from HBA information"); initArray (itsAntPos[i], 48, 2, 3);
makeSubField (HBA0_IDX); initArray (itsFieldCentres[i], 3);
makeSubField (HBA1_IDX); initArray (itsNormVectors[i], 3);
initArray (itsRotationMatrix[i], 3, 3);
initArray (itsRCULengths[i], 48*2);
} }
}
LOG_INFO_STR("Antenna positionfile " << fullFilename void AntField::initArray (AntField::AFArray& array, size_t n1)
<< " read in succesfully"); {
vector<size_t>& shape = AntField::getShape(array);
vector<double>& data = AntField::getData(array);
shape.resize (1);
shape[0] = n1;
data.resize (n1);
std::fill (data.begin(), data.end(), 0.);
} }
AntField::~AntField() void AntField::initArray (AntField::AFArray& array, size_t n1, size_t n2)
{
vector<size_t>& shape = AntField::getShape(array);
vector<double>& data = AntField::getData(array);
shape.resize (2);
shape[0] = n1;
shape[1] = n2;
data.resize (n1*n2);
std::fill (data.begin(), data.end(), 0.);
}
void AntField::initArray (AntField::AFArray& array,
size_t n1, size_t n2, size_t n3)
{ {
vector<size_t>& shape = AntField::getShape(array);
vector<double>& data = AntField::getData(array);
shape.resize (3);
shape[0] = n1;
shape[1] = n2;
shape[2] = n3;
data.resize (n1*n2*n3);
std::fill (data.begin(), data.end(), 0.);
} }
int AntField::name2Index(const string& fieldName) const int AntField::name2Index(const string& fieldName) const
......
...@@ -40,12 +40,10 @@ namespace LOFAR { ...@@ -40,12 +40,10 @@ namespace LOFAR {
using namespace LOFAR; using namespace LOFAR;
void show (const AntField& theAP)
int main()
{ {
AntField theAP("tAntField.in");
// Show the names of the sets. // Show the names of the sets.
cout << endl;
cout << "The tAntField.in file containes the following definitions:" << endl; cout << "The tAntField.in file containes the following definitions:" << endl;
cout << "LBA count : " << theAP.nrAnts("LBA") << endl; cout << "LBA count : " << theAP.nrAnts("LBA") << endl;
cout << "LBA centre : " << theAP.Centre("LBA") << endl; cout << "LBA centre : " << theAP.Centre("LBA") << endl;
...@@ -74,6 +72,24 @@ int main() ...@@ -74,6 +72,24 @@ int main()
cout << "HBA1 rot.Matrix : " << theAP.rotationMatrix("HBA1") << endl; cout << "HBA1 rot.Matrix : " << theAP.rotationMatrix("HBA1") << endl;
cout << "HBA1 Ant positions: " << theAP.AntPos("HBA1") << endl; cout << "HBA1 Ant positions: " << theAP.AntPos("HBA1") << endl;
cout << "HBA1 RCU lengths : " << theAP.RCULengths("HBA1") << endl; cout << "HBA1 RCU lengths : " << theAP.RCULengths("HBA1") << endl;
}
int main()
{
// Read an existing file.
AntField theAP1("tAntField.in", true);
show (theAP1);
AntField theAP2("tAntField.in", false);
// Accept a non-existing file.
AntField theAP3("tAntFielx.in", false);
show (theAP3);
bool failed = false;
try {
AntField theAP4("tAntFielx.in", true);
} catch (LOFAR::Exception&) {
failed = true;
}
ASSERT (failed);
return (0); return (0);
} }
......
The tAntField.in file containes the following definitions: The tAntField.in file containes the following definitions:
LBA count : 96 LBA count : 96
LBA centre : [3] [3.82658e+06,461023,5.06489e+06] LBA centre : [3] [3.82658e+06,461023,5.06489e+06]
...@@ -23,3 +24,29 @@ HBA1 normVector : [3] [0.598753,0.072099,0.797682] ...@@ -23,3 +24,29 @@ HBA1 normVector : [3] [0.598753,0.072099,0.797682]
HBA1 rot.Matrix : [3,3] [-0.119595,-0.791954,0.598753,0.992823,-0.095419,0.072099,3.3e-05,0.603078,0.797682] HBA1 rot.Matrix : [3,3] [-0.119595,-0.791954,0.598753,0.992823,-0.095419,0.072099,3.3e-05,0.603078,0.797682]
HBA1 Ant positions: [24,2,3] [-9.888,-3.785,7.765,-9.888,-3.785,7.765,-10.504,1.328,7.765,-10.504,1.328,7.765,-5.194,-8.407,4.659,-5.194,-8.407,4.659,-5.81,-3.294,4.659,-5.81,-3.294,4.659,-6.426,1.819,4.659,-6.426,1.819,4.659,-7.042,6.932,4.659,-7.042,6.932,4.659,-0.499,-13.028,1.553,-0.499,-13.028,1.553,-1.115,-7.915,1.553,-1.115,-7.915,1.553,-1.731,-2.802,1.553,-1.731,-2.802,1.553,-2.347,2.311,1.553,-2.347,2.311,1.553,-2.963,7.424,1.553,-2.963,7.424,1.553,-3.579,12.537,1.553,-3.579,12.537,1.553,3.579,-12.537,-1.553,3.579,-12.537,-1.553,2.963,-7.424,-1.553,2.963,-7.424,-1.553,2.347,-2.311,-1.553,2.347,-2.311,-1.553,1.731,2.802,-1.553,1.731,2.802,-1.553,1.115,7.915,-1.553,1.115,7.915,-1.553,0.499,13.028,-1.553,0.499,13.028,-1.553,7.042,-6.932,-4.659,7.042,-6.932,-4.659,6.426,-1.819,-4.659,6.426,-1.819,-4.659,5.81,3.294,-4.659,5.81,3.294,-4.659,5.194,8.407,-4.659,5.194,8.407,-4.659,10.504,-1.328,-7.765,10.504,-1.328,-7.765,9.888,3.785,-7.765,9.888,3.785,-7.765] HBA1 Ant positions: [24,2,3] [-9.888,-3.785,7.765,-9.888,-3.785,7.765,-10.504,1.328,7.765,-10.504,1.328,7.765,-5.194,-8.407,4.659,-5.194,-8.407,4.659,-5.81,-3.294,4.659,-5.81,-3.294,4.659,-6.426,1.819,4.659,-6.426,1.819,4.659,-7.042,6.932,4.659,-7.042,6.932,4.659,-0.499,-13.028,1.553,-0.499,-13.028,1.553,-1.115,-7.915,1.553,-1.115,-7.915,1.553,-1.731,-2.802,1.553,-1.731,-2.802,1.553,-2.347,2.311,1.553,-2.347,2.311,1.553,-2.963,7.424,1.553,-2.963,7.424,1.553,-3.579,12.537,1.553,-3.579,12.537,1.553,3.579,-12.537,-1.553,3.579,-12.537,-1.553,2.963,-7.424,-1.553,2.963,-7.424,-1.553,2.347,-2.311,-1.553,2.347,-2.311,-1.553,1.731,2.802,-1.553,1.731,2.802,-1.553,1.115,7.915,-1.553,1.115,7.915,-1.553,0.499,13.028,-1.553,0.499,13.028,-1.553,7.042,-6.932,-4.659,7.042,-6.932,-4.659,6.426,-1.819,-4.659,6.426,-1.819,-4.659,5.81,3.294,-4.659,5.81,3.294,-4.659,5.194,8.407,-4.659,5.194,8.407,-4.659,10.504,-1.328,-7.765,10.504,-1.328,-7.765,9.888,3.785,-7.765,9.888,3.785,-7.765]
HBA1 RCU lengths : [48] [13.1299,13.1299,13.1298,13.1298,10.9253,10.9253,8.14327,8.14327,8.143,8.143,10.9247,10.9247,13.1297,13.1297,8.14262,8.14262,3.64134,3.64134,3.64156,3.64156,8.14291,8.14291,13.13,13.13,13.13,13.13,8.14291,8.14291,3.64156,3.64156,3.64134,3.64134,8.14262,8.14262,13.1297,13.1297,10.9247,10.9247,8.143,8.143,8.14327,8.14327,10.9253,10.9253,13.1298,13.1298,13.1299,13.1299] HBA1 RCU lengths : [48] [13.1299,13.1299,13.1298,13.1298,10.9253,10.9253,8.14327,8.14327,8.143,8.143,10.9247,10.9247,13.1297,13.1297,8.14262,8.14262,3.64134,3.64134,3.64156,3.64156,8.14291,8.14291,13.13,13.13,13.13,13.13,8.14291,8.14291,3.64156,3.64156,3.64134,3.64134,8.14262,8.14262,13.1297,13.1297,10.9247,10.9247,8.143,8.143,8.14327,8.14327,10.9253,10.9253,13.1298,13.1298,13.1299,13.1299]
The tAntField.in file containes the following definitions:
LBA count : 48
LBA centre : [3] [0,0,0]
LBA normVector : [3] [0,0,0]
LBA rot.Matrix : [3,3] [0,0,0,0,0,0,0,0,0]
LBA Ant positions: [48,2,3] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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: [3] [0,0,0]
HBA1 rot.Matrix : [3,3] [0,0,0,0,0,0,0,0,0]
HBA1 Ant positions: [24,2,3] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
HBA1 RCU lengths : [48] [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
...@@ -59,11 +59,14 @@ namespace LOFAR { ...@@ -59,11 +59,14 @@ namespace LOFAR {
bool overwrite = false); bool overwrite = false);
// Fill the subtables. They should be empty. // Fill the subtables. They should be empty.
// <src>mustExist</src> tells if the AntennaField and iHBADelta file on
// an antenna must exist.
static void fill (casa::Table& ms, static void fill (casa::Table& ms,
const string& antennaSet, const string& antennaSet,
const string& antennaSetFileName, const string& antennaSetFileName,
const string& antennaFieldDir, const string& antennaFieldDir,
const string& iHBADeltaDir); const string& iHBADeltaDir,
bool mustExist=false);
// Write an AntennaField entry in the given row. // Write an AntennaField entry in the given row.
static void writeAntField (MSAntennaFieldColumns& columns, int rownr, static void writeAntField (MSAntennaFieldColumns& columns, int rownr,
...@@ -105,7 +108,8 @@ namespace LOFAR { ...@@ -105,7 +108,8 @@ namespace LOFAR {
static casa::Array<double> array2Casa (const AntField::AFArray& barray); static casa::Array<double> array2Casa (const AntField::AFArray& barray);
// Read the HBA dipole offsets. // Read the HBA dipole offsets.
static void getHBADeltas (const string& filename, AntField::AFArray&); static void getHBADeltas (const string& filename, AntField::AFArray&,
bool mustExist);
}; };
} //# end namespace } //# end namespace
......
...@@ -72,7 +72,8 @@ void BeamTables::fill (Table& ms, ...@@ -72,7 +72,8 @@ void BeamTables::fill (Table& ms,
const string& antennaSetName, const string& antennaSetName,
const string& antennaSetFileName, const string& antennaSetFileName,
const string& antennaFieldDir, const string& antennaFieldDir,
const string& iHBADeltaDir) const string& iHBADeltaDir,
bool mustExist)
{ {
// Open the AntennaSets file. // Open the AntennaSets file.
AntennaSets antennaSet(antennaSetFileName); AntennaSets antennaSet(antennaSetFileName);
...@@ -123,7 +124,8 @@ void BeamTables::fill (Table& ms, ...@@ -123,7 +124,8 @@ void BeamTables::fill (Table& ms,
int stationId = stationIdMap.size(); int stationId = stationIdMap.size();
stationIdMap[stationName] = stationId; stationIdMap[stationName] = stationId;
} }
AntField antField(antFieldPath + stationName + "-AntennaField.conf"); AntField antField(antFieldPath + stationName + "-AntennaField.conf",
mustExist);
// Get the station type from the station name (using StationInfo.h). // Get the station type from the station name (using StationInfo.h).
// Use it to get the bitset telling which elements are present for // Use it to get the bitset telling which elements are present for
// the given antennaSet. // the given antennaSet.
...@@ -135,7 +137,7 @@ void BeamTables::fill (Table& ms, ...@@ -135,7 +137,7 @@ void BeamTables::fill (Table& ms,
if (antFieldType == "HBA") { if (antFieldType == "HBA") {
// Get the offsets of HBA dipoles w.r.t. tile center. // Get the offsets of HBA dipoles w.r.t. tile center.
getHBADeltas (hbaDeltaPath + stationName + "-iHBADeltas.conf", getHBADeltas (hbaDeltaPath + stationName + "-iHBADeltas.conf",
hbaOffsets); hbaOffsets, mustExist);
} }
if (antFieldName == "HBA") { if (antFieldName == "HBA") {
// HBA can be split into HBA0 and HBA1. // HBA can be split into HBA0 and HBA1.
...@@ -336,19 +338,33 @@ void BeamTables::writeAntenna (Table& antTable, ...@@ -336,19 +338,33 @@ void BeamTables::writeAntenna (Table& antTable,
} }
void BeamTables::getHBADeltas (const string& fileName, void BeamTables::getHBADeltas (const string& fileName,
AntField::AFArray& deltas) AntField::AFArray& deltas,
bool mustExist)
{ {
ifstream file(fileName.c_str()); ifstream file(fileName.c_str());
ASSERTSTR(file.good(), "Can not open file " << fileName); if (mustExist) {
// The file may have comment lines at the top, starting with '#' ASSERTSTR(file.good(), "Cannot open file " << fileName);
// These must be skipped }
string line; if (file.good()) {
getline (file, line); // The file may have comment lines at the top, starting with '#'
while (line[0] == '#') { // These must be skipped
string line;
getline (file, line); getline (file, line);
while (line[0] == '#') {
getline (file, line);
}
// The array is stored after the name line which has just been read.
AntField::readBlitzArray<2> (deltas, file);
} else {
// File not found is acceptable; fill with zeroes.
vector<size_t>& shape = AntField::getShape(deltas);
vector<double>& data = AntField::getData(deltas);
shape.resize (2);
shape[0] = 16;
shape[1] = 3;
data.resize (16*3);
std::fill (data.begin(), data.end(), 0.);
} }
// The array is stored after the name line which has just been read.
AntField::readBlitzArray<2> (deltas, file);
ASSERTSTR (AntField::getShape(deltas)[1] == 3 && ASSERTSTR (AntField::getShape(deltas)[1] == 3 &&
(AntField::getShape(deltas)[0] == 16 || (AntField::getShape(deltas)[0] == 16 ||
AntField::getShape(deltas)[0] == 32), AntField::getShape(deltas)[0] == 32),
......
...@@ -63,7 +63,7 @@ int main (int argc, char* argv[]) ...@@ -63,7 +63,7 @@ int main (int argc, char* argv[])
Bool overwrite = inputs.getBool ("overwrite"); Bool overwrite = inputs.getBool ("overwrite");
MeasurementSet ms(msName, Table::Update); MeasurementSet ms(msName, Table::Update);
BeamTables::create (ms, overwrite); BeamTables::create (ms, overwrite);
BeamTables::fill (ms, antSet, antSetFile, antFieldDir, hbaDeltaDir); BeamTables::fill (ms, antSet, antSetFile, antFieldDir, hbaDeltaDir, true);
} catch (std::exception& x) { } catch (std::exception& x) {
cout << "Unexpected exception: " << x.what() << endl; cout << "Unexpected exception: " << x.what() << endl;
return 1; return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment