-
Notifications
You must be signed in to change notification settings - Fork 3
/
fixmwams.cpp
66 lines (54 loc) · 2.25 KB
/
fixmwams.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "mwams.h"
#include "mwaconfig.h"
#include "version.h"
#include <iostream>
int main(int argc, char* argv[])
{
if(argc != 3)
{
std::cout <<
"fixmwams will add several mwa-specific keywords to a measurement set that are normally added by Cotter.\n"
"This is for example useful when outputting to uvfits file and importing this later into a measurement set.\n\n"
"Syntax: fixmwams <ms> <metafitsfile>\n";
return -1;
}
const char* outputFilename = argv[1];
const char* metaFitsFilename = argv[2];
MWAMS mwaMs(outputFilename);
mwaMs.InitializeMWAFields();
MWAConfig mwaConfig;
mwaConfig.ReadMetaFits(metaFitsFilename, false);
size_t nAnt = mwaConfig.NAntennae();
for(size_t i=0; i!=nAnt; ++i)
{
const MWAAntenna &ant = mwaConfig.Antenna(i);
const MWAInput &inpX = mwaConfig.AntennaXInput(i);
const MWAInput &inpY = mwaConfig.AntennaYInput(i);
MWAMS::MWAAntennaInfo antennaInfo;
antennaInfo.inputX = inpX.inputIndex;
antennaInfo.inputY = inpY.inputIndex;
antennaInfo.tileNr = ant.tileNumber;
antennaInfo.receiver = ant.receiver;
antennaInfo.slotX = inpX.slot;
antennaInfo.slotY = inpY.slot;
antennaInfo.cableLengthX = inpX.cableLenDelta;
antennaInfo.cableLengthY = inpY.cableLenDelta;
mwaMs.UpdateMWAAntennaInfo(i, antennaInfo);
}
mwaMs.UpdateMWAFieldInfo(mwaConfig.HeaderExt().hasCalibrator);
MWAMS::MWAObservationInfo obsInfo;
obsInfo.gpsTime = mwaConfig.HeaderExt().gpsTime;
obsInfo.filename = mwaConfig.HeaderExt().filename;
obsInfo.observationMode = mwaConfig.HeaderExt().mode;
obsInfo.rawFileCreationDate = 0;
obsInfo.flagWindowSize = 0;
obsInfo.dateRequested = mwaConfig.HeaderExt().dateRequestedMJD*86400.0;
mwaMs.UpdateMWAObservationInfo(obsInfo);
mwaMs.UpdateSpectralWindowInfo(mwaConfig.CentreSubbandNumber());
mwaMs.WriteMWATilePointingInfo(mwaConfig.Header().GetStartDateMJD()*86400.0,
mwaConfig.Header().GetDateLastScanMJD()*86400.0, mwaConfig.HeaderExt().delays,
mwaConfig.HeaderExt().tilePointingRARad, mwaConfig.HeaderExt().tilePointingDecRad);
for(int i=0; i!=24; ++i)
mwaMs.WriteMWASubbandInfo(i, mwaConfig.HeaderExt().subbandGains[i], false);
mwaMs.WriteMWAKeywords(mwaConfig.HeaderExt().metaDataVersion, mwaConfig.HeaderExt().mwaPyVersion, COTTER_VERSION_STR, COTTER_VERSION_DATE);
}