casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MSFitsOutputAstron.h
Go to the documentation of this file.
00001 //# MSFitsOutputAstron.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: MSFitsOutputAstron.h 21105 2011-07-15 08:07:31Z gervandiepen $
00027 
00028 #ifndef MS_MSFITSOUTPUTASTRON_H
00029 #define MS_MSFITSOUTPUTASTRON_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 class Table;
00041 template<class T> class Block;
00042 template<class T> class Vector;
00043 
00044 
00045 // <summary>
00046 // Write a MeasurementSet to a random group uvfits file.
00047 // </summary>
00048 
00049 class MSFitsOutputAstron
00050 {
00051 public:
00052   // Convert a MeasurementSet to random group UVFITS,
00053   // specifying the column to write ("observed", "calibrated", "model") and
00054   // whether to write the system calibration table.
00055   // <br>If asMultiSource=True a multi-source UVFits file is written.
00056   // <br>If combineSpw=True, all spectral-windows of a frequency group
00057   // are combined.
00058   static Bool writeFitsFile(const String& fitsfile, const MeasurementSet& ms,
00059                             const String& column, Int startchan=-1, 
00060                             Int nchan=-1, Int stepchan=-1, 
00061                             Bool writeSysCal = False,
00062                             Bool asMultiSource = False, Bool combineSpw=False,
00063                             Bool writeStation=False, Double sensitivity = 1.0);
00064 
00065 
00066 private:
00067   // Write the main table.
00068   static FitsOutput *writeMain(Int& refPixelFreq, Double& refFreq,
00069                                Double& refFreq1, Double& chanbw,
00070                                const String& outFITSFile,
00071                                const MeasurementSet& rawms,
00072                                const String& column,
00073                                const Block<Int>& spwidMap,
00074                                Int nrspw,
00075                                Int startchan, Int nchan, Int stepchan,
00076                                const Block<Int>& fieldidMap,
00077                                Bool asMultiSource,
00078                                Bool combineSpw);
00079 
00080   // Write the FQ table.
00081   // If combineSpw is True, all spectral-windows are written in one
00082   // row of the FITS table.
00083   static Bool writeFQ(FitsOutput *output, const MeasurementSet& ms, 
00084                       const Block<Int>& spwidMap, Int nrspw,
00085                       Double refFreq, Int refPixelFreq, 
00086                       Double chanbw, Bool combineSpw);
00087 
00088   // Write the AN table.
00089   static Bool writeAN(FitsOutput *output, const MeasurementSet& ms,
00090                       Double refFreq, Bool writeStation);
00091 
00092   // Write the SU table.
00093   static Bool writeSU(FitsOutput *output, const MeasurementSet& ms,
00094                       const Block<Int>& fieldidMap, Int nrfield,
00095                       const Block<Int>& spwidMap, Int nrspw);
00096 
00097   // Write the TY table.
00098   static Bool writeTY(FitsOutput *output, const MeasurementSet& ms,
00099                       const Table& syscal, const Block<Int>& spwidMap,
00100                       uInt nrif, Bool combineSpw);
00101 
00102   // Write the GC table.
00103   static Bool writeGC(FitsOutput *output, const MeasurementSet& ms,
00104                       const Table& syscal, const Block<Int>& spwidMap,
00105                       uInt nrif, Bool combineSpw, Double sensitivity,
00106                       Int refPixelFreq, Double refFreq, Double chanbw);
00107 
00108   // Convert time to day and fraction.
00109   static void timeToDay(Int& day, Double& dayFraction, Double time);
00110 
00111   // Get the time and hourangle from the MS at the given row.
00112   // It uses the field-id and observation-id to calculate the hourangle.
00113   static void getStartHA (Double& startTime, Double& startHA,
00114                           const MeasurementSet& ms, uInt rownr);
00115 
00116   // Handle the SYSCAL table.
00117   // It skips the entries not needed and sorts it in the correct order.
00118   static Table handleSysCal (const MeasurementSet& ms,
00119                              const Vector<Int>& spwids, Bool isSubset);
00120 
00121   // Determine which ids are selected in the main table
00122   // (used for fields and spectral-window).
00123   // It fills a block for all possible ids, where -1 tells that the
00124   // id is not selected. Furthermore it fills a vector with the
00125   // selected id numbers.
00126   // The input is a vector containing all ids in the main table.
00127   // If isSubset is False the main table is not a selection, but
00128   // represents an entire MS. In that case the map and selids are
00129   // simply filled with values 0-nrid.
00130   static Int makeIdMap (Block<Int>& map, Vector<Int>& selids,
00131                         const Vector<Int>& allids, Bool isSubset);
00132 };
00133 
00134 
00135 
00136 } //# NAMESPACE CASA - END
00137 
00138 #endif