Line data Source code
1 : /** 2 : Bojan Nikolic <b.nikolic@mrao.cam.ac.uk>, <bojan@bnikolic.co.uk> 3 : Initial version January 2010. 4 : Maintained by ESO since 2013. 5 : 6 : This file is part of LibAIR and is licensed under GNU Public 7 : License Version 2 8 : 9 : \file arraydata.hpp 10 : Renamed arraydata.h 2023 11 : 12 : Structure to hold data from all WVRs in an array 13 : */ 14 : #ifndef _LIBAIR_APPS_ARRAYDATA_HPP__ 15 : #define _LIBAIR_APPS_ARRAYDATA_HPP__ 16 : 17 : #include <vector> 18 : #include <casacore/casa/Arrays/Cube.h> 19 : 20 : #include "antennautils.h" 21 : 22 : namespace LibAIR2 { 23 : 24 : 25 : /** \brief Observation from an array of WVRs which has been 26 : interpolated or sampled onto a common time base 27 : 28 : \note This number of time points and WVRs must be specified at 29 : construction of this object, it can not grow. 30 : 31 : */ 32 : class InterpArrayData { 33 : 34 : public: 35 : 36 : /// This is the type which is used to store the actual sky 37 : /// brightness data from all the WVRs 38 : typedef casacore::Cube<double> wvrdata_t; 39 : 40 : private: 41 : 42 : /// The time stamps of each data row 43 : std::vector<double> time; 44 : /// Elevation of each observing point 45 : std::vector<double> el; 46 : /// Azimuth of each observation 47 : std::vector<double> az; 48 : /// State ID ([sub-]scan intent) of each observation 49 : std::vector<size_t> state; 50 : /// Field ID of each observation 51 : std::vector<size_t> field; 52 : /// Source ID of each observation 53 : std::vector<size_t> source; 54 : 55 : /// The data itself 56 : wvrdata_t wvrdata; 57 : 58 : public: 59 : 60 : // ---------------------- Public data ------------------ 61 : 62 : /// Number of Antennas 63 : const size_t nAnts; 64 : 65 : 66 : // ----------------------- Construction/Destruction ------------- 67 : 68 : /** 69 : 70 : \param nAnts number of Ants for which the data are recorded 71 : 72 : */ 73 : InterpArrayData(const std::vector<double> &time, 74 : const std::vector<double> &el, 75 : const std::vector<double> &az, 76 : const std::vector<size_t> &state, 77 : const std::vector<size_t> &field, 78 : const std::vector<size_t> &source, 79 : size_t nAnts); 80 : 81 : // ----------------------- Public Interface ------------- 82 : 83 58211 : const std::vector<double> &g_time(void) const 84 : { 85 58211 : return time; 86 : } 87 : 88 1007 : const std::vector<double> &g_el(void) const 89 : { 90 1007 : return el; 91 : } 92 : 93 924 : const std::vector<double> &g_az(void) const 94 : { 95 924 : return az; 96 : } 97 : 98 4917 : const std::vector<size_t> &g_state(void) const 99 : { 100 4917 : return state; 101 : } 102 : 103 924 : const std::vector<size_t> &g_field(void) const 104 : { 105 924 : return field; 106 : } 107 : 108 997 : const std::vector<size_t> &g_source(void) const 109 : { 110 997 : return source; 111 : } 112 : 113 301484 : const wvrdata_t &g_wvrdata(void) const 114 : { 115 301484 : return wvrdata; 116 : } 117 : 118 : /** Set one element of the WVR data array 119 : */ 120 150564 : void set(size_t time, 121 : size_t wvr, 122 : size_t ch, 123 : double Tsky) 124 : { 125 150564 : wvrdata(time,wvr,ch)=Tsky; 126 150564 : } 127 : 128 : /** Number of time points in the data 129 : */ 130 75 : size_t nTimes(void) const 131 : { 132 75 : return time.size(); 133 : } 134 : 135 : /** Adjust time stamps for a timing offset relative to the 136 : interfermetric data . 137 : */ 138 : void offsetTime(double dt); 139 : 140 : 141 : }; 142 : 143 : /** Interpolate data for a bad antenna a by the mean of antennas aset 144 : */ 145 : void interpBadAnt(InterpArrayData &d, 146 : size_t a, 147 : const AntSet &aset); 148 : 149 : /** Interpolate data for a bad antenna a weighted average of nearby 150 : antennas 151 : */ 152 : void interpBadAntW(InterpArrayData &d, 153 : size_t a, 154 : const AntSetWeight &aset); 155 : 156 : /** \brief Create new array data with only states in it 157 : */ 158 : InterpArrayData *filterState(InterpArrayData &d, 159 : const std::set<size_t>& states); 160 : 161 : /** \brief Smooth the WVR data in time. The smoothing is symmetric 162 : in time. The initial and last nsample/2 are not smoothed 163 : 164 : The smoothing is broken at every change of source and state id 165 : to avoid smoothing across large change of airmass or when 166 : observing calibration loads. 167 : */ 168 : void smoothWVR(InterpArrayData &d, 169 : size_t nsample); 170 : 171 : 172 : } 173 : 174 : #endif