casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotMSAtm.h
Go to the documentation of this file.
1 //# PlotMSAtm.h: calculate atmospheric transmission curve
2 //# Copyright (C) 2017
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 
27 #ifndef PLOTMSATM_H_
28 #define PLOTMSATM_H_
29 
35 
36 namespace casa {
37 
38 // <summary>
39 // PlotMSAtm: plotms class for calculating atmospheric transmission curve
40 // for bandpass plots
41 // </summary>
42 
43 // <reviewed reviewer="" date="" tests="" demos="">
44 
45 // <prerequisite>
46 // <li> <linkto class="CalCache">CalCache</linkto> module
47 // </prerequisite>
48 //
49 // <etymology>
50 // From "plotms", "atmospheric".
51 // </etymology>
52 //
53 // <synopsis>
54 // The PlotMSAtm class computes atmospheric transmission curves based on the
55 // algorithm in the plotbandpass task. Needed information is obtained from
56 // the bandpass table and its MeasurementSet if possible, else defaults based
57 // on observatory are used. The calculated values are returned in a vector
58 // whose size is equal to the number of channels.
59 // </synopsis>
60 //
61 // <example>
62 // <srcblock>
63 // </srcblock>
64 // </example>
65 //
66 // <motivation>
67 // This class is used by the plotms CalCache class to obtain atmospheric
68 // transmission curve values for plotting the curve overlay on a bandpass
69 // plot.
70 // </motivation>
71 //
72 
73 class PlotMSAtm {
74 
75 public:
76 
77  // construct with bandpass table name
79  bool isMS, bool xAxisIsChan, PlotMSCacheBase* parent);
80  ~PlotMSAtm();
81 
82  // accessors
83  inline casacore::String filename() { return filename_; }
84  inline PlotMSSelection selection() { return selection_; }
85  inline bool showatm() { return showatm_; } // false is tsky
86  inline bool xAxisIsChan() { return xIsChan_; }
87 
88  inline void setShowAtm(bool showatm) { showatm_ = showatm; }
89  inline void setXAxisIsChan(bool isChan) { xIsChan_ = isChan; }
90 
91  // passes arguments through to calcOverlayCurve
93  casacore::Int spw, casacore::Int scan,
94  const casacore::Vector<casacore::Double>& chanFreqs);
95  // calculates image frequencies then calls calcOverlayCurve
97  casacore::Int spw, casacore::Int scan,
98  const casacore::Vector<casacore::Double>& chanFreqs);
99 
100  inline casacore::Double getPwv() { return pwv_; }
101  inline casacore::Double getAirmass() { return airmass_; }
102 
103  // image sideband curve helpers
104  inline bool canShowImageCurve() { return (hasReceiverTable() && canGetLOsForSpw()); }
105  bool hasReceiverTable();
106  bool canGetLOsForSpw();
107 
108 private:
109 
110  PlotMSAtm(const PlotMSAtm& other);
111  PlotMSAtm& operator= (const PlotMSAtm& other);
112 
113  // info from MS
114  void setUpMS(casacore::String filename, PlotMSSelection& userSel);
115  void getMSTimes(MeasurementSet& ms);
116  void getMSFields(MeasurementSet& ms);
117 
118  // info from cal tables
119  void setUpCalTable(casacore::String filename, PlotMSSelection& userSel);
120  void getCalTimes(NewCalTable& ct);
121  void getCalFields(NewCalTable& ct);
122  void getCalMS(); // uses original caltable_
123 
124  // common function for plotbandpass CalcAtmTransmission algorithm
125  // Returns curve vector (atm, tsky, image sideband);
127  casacore::Int spw, casacore::Int scan,
128  const casacore::Vector<casacore::Double>& chanFreqs);
129 
130  // for user selection then each chunk's spw and scan
132  casacore::MeasurementSet& selms);
134  NewCalTable& selct);
135 
136  // calculated values
137  void getMeanWeather(); // stored in weather_ Record
139  casacore::String tempUnits, casacore::String pressureUnits);
140  void getMedianPwv(); // stored in pwv_
143  casacore::Double getFieldElevation(casacore::Int fieldId); // no pointing table
145 
146  // atmosphere tool
147  atm::AtmProfile* getAtmProfile();
148 
149  // image sideband curve
150  bool getLO1FreqForSpw(double& freq, int spw);
152  casacore::Int spw, const casacore::Vector<casacore::Double>& chanFreqs);
153 
154  // utility functions
155  // Determine unique time values in input vector
158  // Sets fields_ = unique values in FIELD column
160  template <typename T>
163  casacore::Double maxtime);
164  template <typename T>
167  double mintime, double maxtime);
168  // use cal table times if available, else ms times
169  void getTimeRange(casacore::Double& mintime, casacore::Double& maxtime);
170 
172  bool showatm_; // true=showatm, false=showtsky
173  bool isMS_; // true=MS, false=CalTable
174  bool xIsChan_; // image curve changes for chan/freq x-axis
175  bool canCalculatePwv_; // has CALWVR or CALATMOSPHERE subtable
176  bool canCalculateWeather_; // has WEATHER subtable
177  PlotMSCacheBase* parent_; // for log messages
179  casacore::MeasurementSet *ms_, *selms_; // selected MS for each spw/scan
180  NewCalTable *caltable_, *selct_; // selected CT for each spw/scan
181 
182  // updated for every spw/scan selection:
188  std::map<int, double> loFreqForSpw_;
189  const unsigned int MAX_ATM_CALC_CHAN_;
190 };
191 
192 }
193 #endif
casacore::Double computeMeanAirmass()
void getUniqueFields(casacore::Vector< casacore::Int > allfields)
Sets fields_ = unique values in FIELD column.
int Int
Definition: aipstype.h:50
void setShowAtm(bool showatm)
Definition: PlotMSAtm.h:88
PlotMSSelection selection()
Definition: PlotMSAtm.h:84
casacore::Double getPointingElevation()
NewCalTable * caltable_
Definition: PlotMSAtm.h:180
void getMSTimes(MeasurementSet &ms)
Main interface class to a read/write table.
Definition: Table.h:153
casacore::String telescopeName_
Definition: PlotMSAtm.h:171
casacore::String filename()
accessors
Definition: PlotMSAtm.h:83
void setXAxisIsChan(bool isChan)
Definition: PlotMSAtm.h:89
bool showatm()
Definition: PlotMSAtm.h:85
Specifies an casacore::MS selection.
void calcImageCurve(casacore::Vector< casacore::Double > &curve, casacore::Int spw, casacore::Int scan, const casacore::Vector< casacore::Double > &chanFreqs)
calculates image frequencies then calls calcOverlayCurve
casacore::MeasurementSet * ms_
Definition: PlotMSAtm.h:179
void getTimeRange(casacore::Double &mintime, casacore::Double &maxtime)
use cal table times if available, else ms times
casacore::MeasurementSet * selms_
Definition: PlotMSAtm.h:179
casacore::Vector< casacore::Double > caltimes_
Definition: PlotMSAtm.h:185
void getCalTimes(NewCalTable &ct)
bool canShowImageCurve()
image sideband curve helpers
Definition: PlotMSAtm.h:104
void getCalFields(NewCalTable &ct)
void getUniqueTimes(casacore::Vector< casacore::Double > inputTimes, casacore::Vector< casacore::Double > &uniqueTimes)
utility functions Determine unique time values in input vector
bool canCalculateWeather_
Definition: PlotMSAtm.h:176
void setUpMS(casacore::String filename, PlotMSSelection &userSel)
info from MS
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
void applyMSSelection(PlotMSSelection &selection, casacore::MeasurementSet &selms)
for user selection then each chunk&#39;s spw and scan
void calcAtmTskyCurve(casacore::Vector< casacore::Double > &curve, casacore::Int spw, casacore::Int scan, const casacore::Vector< casacore::Double > &chanFreqs)
passes arguments through to calcOverlayCurve
casacore::Double pwv_
Definition: PlotMSAtm.h:184
casacore::String tableName_
Definition: PlotMSAtm.h:171
int selectedSpw_
updated for every spw/scan selection:
Definition: PlotMSAtm.h:183
double Double
Definition: aipstype.h:55
casacore::Double getFieldElevation(casacore::Int fieldId)
casacore::Vector< casacore::Double > mstimes_
Definition: PlotMSAtm.h:185
casacore::Vector< T > getValuesInTimeRange(casacore::Vector< T > inputCol, casacore::Vector< casacore::Double > timesCol, casacore::Double mintime, casacore::Double maxtime)
PlotMSAtm(casacore::String filename, PlotMSSelection &userSel, bool showatm, bool isMS, bool xAxisIsChan, PlotMSCacheBase *parent)
construct with bandpass table name
PlotMSAtm: plotms class for calculating atmospheric transmission curve for bandpass plots...
Definition: PlotMSAtm.h:73
bool hasReceiverTable()
A hierarchical collection of named fields of various types.
Definition: Record.h:180
PlotMSSelection selection_
Definition: PlotMSAtm.h:178
void getMSFields(MeasurementSet &ms)
casacore::Double getAirmass()
Definition: PlotMSAtm.h:101
bool getLO1FreqForSpw(double &freq, int spw)
image sideband curve
casacore::Double getPwv()
Definition: PlotMSAtm.h:100
std::map< int, double > loFreqForSpw_
Definition: PlotMSAtm.h:188
A Table intended to hold astronomical data (a set of Measurements).
casacore::Table selectWeatherTable(casacore::Table &intable, casacore::String tempUnits, casacore::String pressureUnits)
void getMeanWeather()
calculated values
NewCalTable * selct_
Definition: PlotMSAtm.h:180
PlotMSCacheBase * parent_
Definition: PlotMSAtm.h:177
casacore::Record weather_
Definition: PlotMSAtm.h:187
bool calcImageFrequencies(casacore::Vector< casacore::Double > &imageFreqs, casacore::Int spw, const casacore::Vector< casacore::Double > &chanFreqs)
casacore::Vector< casacore::Int > fields_
Definition: PlotMSAtm.h:186
bool canCalculatePwv_
Definition: PlotMSAtm.h:175
String: the storage and methods of handling collections of characters.
Definition: String.h:223
atm::AtmProfile * getAtmProfile()
atmosphere tool
casacore::Double airmass_
Definition: PlotMSAtm.h:184
casacore::Double getMeanScantime()
void applyCalSelection(PlotMSSelection &selection, NewCalTable &selct)
bool canGetLOsForSpw()
void getClosestValues(casacore::Vector< T > &values, casacore::Vector< casacore::Double > &times, casacore::Vector< T > &data, double mintime, double maxtime)
bool xAxisIsChan()
Definition: PlotMSAtm.h:86
void setUpCalTable(casacore::String filename, PlotMSSelection &userSel)
info from cal tables
const unsigned int MAX_ATM_CALC_CHAN_
Definition: PlotMSAtm.h:189
PlotMSAtm & operator=(const PlotMSAtm &other)
casacore::Vector< casacore::Double > calcOverlayCurve(casacore::Int spw, casacore::Int scan, const casacore::Vector< casacore::Double > &chanFreqs)
common function for plotbandpass CalcAtmTransmission algorithm Returns curve vector (atm...
casacore::String filename_
Definition: PlotMSAtm.h:171