00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ATNF_ATCAFILLER_H
00029 #define ATNF_ATCAFILLER_H
00030
00031
00032 #include <casa/aips.h>
00033 #include <casa/Arrays/Matrix.h>
00034 #include <casa/Logging/LogIO.h>
00035 #include <tables/DataMan/TiledDataStManAccessor.h>
00036 #include <ms/MeasurementSets/MeasurementSet.h>
00037 #include <ms/MeasurementSets/MSColumns.h>
00038
00039 #include <casa/namespace.h>
00040 namespace casa {
00041 class String;
00042
00043 class ATCAFiller {
00044 public:
00045
00046
00047 ATCAFiller();
00048
00049 ~ATCAFiller();
00050
00051
00052
00053 static TableDesc atcaTableDesc(Bool compress);
00054
00055
00056 static MeasurementSet makeTable(const String& tableName, Bool compress,
00057 Bool cabb);
00058
00059
00060 static void makeSubTables(MS& ms, Table::TableOption option, Bool cabb);
00061
00062
00063
00064
00065 Bool open(const String& msName, const Vector<String>& rpfitsFiles,
00066 const Vector<String> & options, Int opcor=2);
00067
00068
00069 Bool fill();
00070
00071
00072 ATCAFiller & fields(const Vector<String> & fieldList);
00073
00074
00075
00076 ATCAFiller & freqRange(Double lowFreq, Double highFreq=0);
00077
00078
00079
00080 ATCAFiller & frequencies(Vector<Double> freqs, Double windowWidth=1e6);
00081
00082
00083
00084 ATCAFiller & scanRange(Int firstScan, Int lastScan=0);
00085
00086
00087
00088 ATCAFiller & chanRange(Int firstChan, Int lastChan, Int ChanInc=1);
00089
00090
00091 ATCAFiller & timeRange(Double firstTime, Double lastTime=0);
00092
00093
00094
00095 ATCAFiller & freqSel(const Vector<Int>& spws);
00096
00097
00098 ATCAFiller & bandwidth1(Int bandwidth1);
00099
00100
00101 ATCAFiller & numChan1(Int numchan1);
00102
00103
00104 ATCAFiller & shadow(Float diam);
00105
00106
00107 ATCAFiller & deselectAntenna(Vector<Int> antennas);
00108
00109
00110
00111 ATCAFiller & xyPhaseSmooth(Int window=9, Double tolerance=10.0);
00112
00113
00114 ATCAFiller & tsysSmooth(Int window=9);
00115
00116
00117 ATCAFiller & edge(Float edge);
00118
00119 private:
00120
00121
00122 ATCAFiller(const ATCAFiller &);
00123 ATCAFiller & operator=(const ATCAFiller &);
00124
00125
00126 void init();
00127
00128 void storeHeader();
00129 void storeATCAHeader();
00130 void storeSysCal();
00131
00132
00133 Bool fill1(const String & rpfitsname);
00134
00135
00136 void list();
00137
00138
00139 Bool samplerFlag(Int row, Double posNegTolerance=3.0,
00140 Double zeroTolerance=0.5);
00141
00142 Int birdChan(Double refFreq, Int refChan, Double chanSpac);
00143 void reweight();
00144 void storeData();
00145 Int checkSpW(Int ifNumber,Bool log=True);
00146 void checkField();
00147 void checkObservation();
00148
00149 void fillFeedTable();
00150 void fillObservationTable();
00151 void fillMeasureReferences();
00152 Bool selected(Int ifNum);
00153 void listScan(Double & mjd, Int scan, Double ut);
00154 Bool checkCABB(const String & rpfitsname);
00155 void rfiFlag(Matrix<Bool> & flags);
00156
00157
00158 String atcaPosToStation(Vector<Double>& xyz);
00159 void flush();
00160 void unlock();
00161
00162 void shadow(Int row, Bool last=False);
00163
00164
00165
00166 enum{MaxNChan=16385, MaxNPol=4};
00167
00168 MeasurementSet atms_p;
00169 MSColumns *msc_p;
00170
00171
00172 Vector<String> rpfitsFiles_p;
00173 Int opcor_p;
00174 String currentFile_p;
00175
00176
00177 Int nAnt_p;
00178
00179
00180 Int nScan_p, nSpW_p, nField_p;
00181
00182 Int scanNo_p, spWId_p, fieldId_p, prev_fieldId_p, obsId_p;
00183
00184
00185 Bool gotAN_p;
00186 Bool appendMode_p;
00187 Bool storedHeader_p;
00188 Bool skipScan_p;
00189 Bool skipData_p;
00190 Bool firstHeader_p;
00191 Bool listHeader_p;
00192 uInt fileSize_p;
00193 Bool eof_p;
00194 Bool birdie_p;
00195 Bool reweight_p;
00196 Bool noxycorr_p;
00197 Bool noac_p;
00198 Int obsType_p;
00199 Bool hires_p;
00200 Bool init_p;
00201 Bool cabb_p;
00202
00203
00204 Float vis[2*MaxNPol*MaxNChan];
00205 Float weight[MaxNPol*MaxNChan];
00206 Int baseline, flg, bin, if_no, sourceno;
00207 Float ut, u, v, w;
00208
00209
00210 TiledDataStManAccessor dataAccessor_p,sigmaAccessor_p,flagAccessor_p,
00211 flagCatAccessor_p;
00212 TiledDataStManAccessor modelDataAccessor_p,corrDataAccessor_p,imWtAccessor_p;
00213
00214
00215
00216
00217 ScalarColumn<Int> colSysCalIdAnt1, colSysCalIdAnt2;
00218 ScalarColumn<Float> colXYAmplitude,colTrackErrMax,colTrackErrRMS,
00219 colWeatherSeeMonPhase,colWeatherSeeMonRMS,colWeatherRainGauge;
00220 ScalarColumn<Int> colSamplerBits;
00221 ArrayColumn<Float> colSamplerStatsNeg, colSamplerStatsZero,
00222 colSamplerStatsPos;
00223 ArrayColumn<Float> colGTP, colSDO, colCalJy;
00224 ScalarColumn<Bool> colWeatherSeeMonFlag;
00225
00226 ScalarColumn<Int> colScanInfoAntId, colScanInfoScanId, colScanInfoSpWId,
00227 colScanInfoCacal;
00228 ArrayColumn<Int> colScanInfoFine, colScanInfoCoarse, colScanInfommAtt;
00229 ArrayColumn<Float> colScanInfoSubreflector;
00230 ScalarColumn<String> colScanInfoCorrConfig, colScanInfoScanType,
00231 colScanInfoCoordType,colScanInfoPointInfo;
00232 ScalarColumn<Bool> colScanInfoLineMode;
00233 Table msScanInfo_p;
00234 Matrix<Float> pointingCorr_p;
00235 Bool newPointingCorr_p;
00236
00237
00238 Double mjd0_p;
00239
00240
00241 Vector<Int> sysCalId_p;
00242 Float lastUT_p;
00243 Int lastSpWId_p;
00244 Bool gotSysCalId_p;
00245 Float lastWeatherUT_p;
00246 Int errCount_p;
00247
00248
00249 Vector<String> fieldSelection_p;
00250 Double lowFreq_p, highFreq_p;
00251 Vector<Double> freqs_p;
00252 Double windowWidth_p;
00253 Int firstScan_p, lastScan_p;
00254 Int firstChan_p, lastChan_p;
00255 Double firstTime_p, lastTime_p;
00256 Vector<Int> spws_p;
00257 Int bandWidth1_p, numChan1_p;
00258 Vector<Int> baselines_p, antennas_p;
00259
00260
00261 String sources_p;
00262 Int nsources_p;
00263
00264
00265 Matrix<Int> corrIndex_p;
00266
00267
00268 Float shadow_p;
00269 Float edge_p;
00270 Block<Int> rowCache_p;
00271 Int nRowCache_p;
00272 Double prevTime_p;
00273
00274
00275 Bool autoFlag_p,flagScanType_p;
00276 enum {COUNT=0, FLAG, ONLINE, SCANTYPE, SYSCAL, SHADOW, NFLAG};
00277 Vector<Int> flagCount_p;
00278
00279
00280 LogIO os_p;
00281
00282 };
00283
00284 }
00285
00286
00287 #endif