casa
$Rev:20696$
|
00001 //# MSFitsOutput.h: Write a MeasurementSet to a random group uvfits file 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2003 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This program is free software; you can redistribute it and/or modify 00006 //# it under the terms of the GNU General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or 00008 //# (at your option) any later version. 00009 //# 00010 //# This program is distributed in the hope that it will be useful, 00011 //# but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 //# GNU General Public License for more details. 00014 //# 00015 //# You should have received a copy of the GNU General Public License 00016 //# along with this program; if not, write to the Free Software 00017 //# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: MSFitsOutput.h 21298 2012-12-07 14:53:03Z gervandiepen $ 00027 00028 #ifndef MS_MSFITSOUTPUT_H 00029 #define MS_MSFITSOUTPUT_H 00030 00031 //# Includes 00032 #include <casa/aips.h> 00033 00034 namespace casa { //# NAMESPACE CASA - BEGIN 00035 00036 //# Forward Declarations 00037 class String; 00038 class FitsOutput; 00039 class MeasurementSet; 00040 template<class T> class ScalarColumn; 00041 class Table; 00042 template<class T> class Block; 00043 template<class T> class Vector; 00044 00045 00046 // <summary> 00047 // Write a MeasurementSet to a random group uvfits file. 00048 // </summary> 00049 00050 class MSFitsOutput 00051 { 00052 public: 00071 static Bool writeFitsFile(const String& fitsfile, const MeasurementSet& ms, 00072 const String& column, Int startchan=0, 00073 Int nchan=1, Int stepchan=1, 00074 Bool writeSysCal = False, 00075 Bool asMultiSource = False, Bool combineSpw=False, 00076 Bool writeStation=False, Double sensitivity = 1.0, 00077 const Bool padWithFlags=false, Int avgchan = 1); 00078 00079 private: 00080 // Write the main table. 00081 // @param refPixelFreq 00082 // @param refFreq 00083 // @param chanbw 00084 // @param outFITSFile 00085 // @param rawms 00086 // @param column data column to write 00087 // @param spwidMap spwidMap[inp_spw] = output_spw, if inp_spw is selected 00088 // -1 otherwise. 00089 // @param nrspw # of selected spws. 00090 // @param startchan First channel 00091 // @param nchan # of channels 00092 // @param stepchan channel stride 00093 // @param fieldidMap fieldidMap[inp_fld] = output_fld, if inp_fld is selected 00094 // -1 otherwise. 00095 // @param asMultiSource If true, write a multisource UVFITS file. 00096 // @param combineSpw If true, export the spectral window(s) as IF(s). 00097 // @param padWithFlags If true && combineSpw==true, pad the spws with 00098 // flags as necessary to fit the IF structure. 00099 static FitsOutput *writeMain(Int& refPixelFreq, Double& refFreq, 00100 Double& chanbw, 00101 const String& outFITSFile, 00102 const MeasurementSet& rawms, 00103 const String& column, 00104 const Block<Int>& spwidMap, 00105 Int nrspw, 00106 Int startchan, Int nchan, Int stepchan, 00107 const Block<Int>& fieldidMap, 00108 Bool asMultiSource, 00109 const Bool combineSpw, 00110 const Bool padWithFlags=true, 00111 Int avgchan=1); 00112 00113 // Write the FQ table. 00114 // If combineSpw is True, all spectral-windows are written in one 00115 // row of the FITS table. 00116 static Bool writeFQ(FitsOutput *output, const MeasurementSet& ms, 00117 const Block<Int>& spwidMap, Int nrspw, 00118 Double refFreq, Int refPixelFreq, 00119 Double chanbw, Bool combineSpw, 00120 Int chanstart = 0, Int nchan = -1, Int chanstep = 1, 00121 Int avgchan = 1); 00122 00123 // Write the AN table. 00124 static Bool writeAN(FitsOutput *output, const MeasurementSet& ms, 00125 Double refFreq, Bool writeStation); 00126 00127 // Write the SU table. 00128 static Bool writeSU(FitsOutput *output, const MeasurementSet& ms, 00129 const Block<Int>& fieldidMap, Int nrfield, 00130 const Block<Int>& spwidMap, Int nrspw); 00131 00132 // Write the TY table. 00133 static Bool writeTY(FitsOutput *output, const MeasurementSet& ms, 00134 const Table& syscal, const Block<Int>& spwidMap, 00135 uInt nrif, Bool combineSpw); 00136 00137 // Write the GC table. 00138 static Bool writeGC(FitsOutput *output, const MeasurementSet& ms, 00139 const Table& syscal, const Block<Int>& spwidMap, 00140 uInt nrif, Bool combineSpw, Double sensitivity, 00141 Int refPixelFreq, Double refFreq, Double chanbw); 00142 00143 // Write the WX table. 00144 static Bool writeWX(FitsOutput *output, const MeasurementSet& ms); 00145 00146 // Convert time to day and fraction. 00147 static void timeToDay(Int& day, Double& dayFraction, Double time); 00148 00149 // Get the time and hourangle from the MS at the given row. 00150 // It uses the field-id and observation-id to calculate the hourangle. 00151 static void getStartHA (Double& startTime, Double& startHA, 00152 const MeasurementSet& ms, uInt rownr); 00153 00154 // Discern the antenna numbers that go into UVFITS 00155 static void handleAntNumbers(const MeasurementSet& ms,Vector<Int>& antnumbers); 00156 00157 // Handle the SYSCAL table. 00158 // It skips the entries not needed and sorts it in the correct order. 00159 static Table handleSysCal (const MeasurementSet& ms, 00160 const Vector<Int>& spwids, Bool isSubset); 00161 00162 // Determine which ids are selected in the main table 00163 // (used for fields and spectral-window). 00164 // @param map (Really an output here, not an input.) 00165 // spwidMap[inp_id] = output_id, if inp_id is selected 00166 // -1 otherwise. 00167 // @param selids (Really an output here, not an input.) 00168 // A list of the selected input IDs. 00169 // @param allids (Really is an input, not an output!) 00170 // IDs to consider. 00171 // @return number of selected IDs in allids 00172 00173 static Int makeIdMap (Block<Int>& map, Vector<Int>& selids, 00174 const Vector<Int>& allids); 00175 00176 // Find the end of a group of rows with the same 00177 // time(_centroid) (within 0.25 * ininterval(rownr)), 00178 // baseline #, 00179 // and, if asMultiSource, field ID. 00180 // @param rownr Row # to start from. 00181 // @param nrow # of rows in the columns. 00182 // @param nif # of IFs 00183 // @param timec time(_centroid) col 00184 // @param ininterval used to set tolerance on changes in timec. 00185 // @param ant1 ID of baseline's antenna 1. 00186 // @param ant2 ID of baseline's antenna 2. 00187 // @param asMultiSource If false, treat fieldid as unattached + prone to segfault 00188 // @param fieldid 00189 // @return Last row # with the same time, baseline, and apparent field as rownr. 00190 // @warning Assumes that the columns are sorted by time(_centroid), ant1, 00191 // ant2 (, field, DDID). 00192 static uInt get_tbf_end(const uInt rownr, const uInt nrow, const uInt nif, 00193 const ScalarColumn<Double>& timec, 00194 const ScalarColumn<Double>& ininterval, 00195 const ScalarColumn<Int>& ant1, 00196 const ScalarColumn<Int>& ant2, 00197 const Bool asMultiSource, 00198 const ScalarColumn<Int>& fieldid); 00199 }; 00200 00201 00202 00203 } //# NAMESPACE CASA - END 00204 00205 #endif