source: trunk/src/SDMath.h@ 385

Last change on this file since 385 was 354, checked in by kil064, 20 years ago

rework convertFLux stuff using new SDAttr and looking up values
where possible

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.7 KB
RevLine 
[2]1//#---------------------------------------------------------------------------
2//# SDMath.h: A collection of single dish mathematical operations
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
[125]5//# ATNF
[2]6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//# Internet email: Malte.Marquarding@csiro.au
23//# Postal address: Malte Marquarding,
24//# Australia Telescope National Facility,
25//# P.O. Box 76,
26//# Epping, NSW, 2121,
27//# AUSTRALIA
28//#
29//# $Id:
30//#---------------------------------------------------------------------------
[125]31#ifndef SDMATH_H
32#define SDMATH_H
[2]33
[38]34#include <string>
35#include <vector>
[130]36#include <casa/aips.h>
[81]37#include <casa/Utilities/CountedPtr.h>
[309]38#include <coordinates/Coordinates/FrequencyAligner.h>
[294]39
[234]40#include "SDDefs.h"
[2]41
[227]42class casa::Table;
[272]43class casa::MEpoch;
[294]44class casa::MPosition;
45template<class T> class casa::PtrBlock;
[330]46template<class T> class casa::Matrix;
47template<class T> class casa::ROScalarColumn;
48template<class T> class casa::ROArrayColumn;
[227]49
[272]50
[330]51
[83]52namespace asap {
[2]53
54class SDMemTable;
[330]55class SDDataDesc;
[2]56
[170]57class SDMath {
[152]58
[170]59 public:
60
61// Default constructor
62 SDMath();
63
64// Copy Constructor (copy semantics)
65 SDMath (const SDMath& other);
66
67// Assignment (copy semantics)
68 SDMath &operator=(const SDMath& other);
69
[183]70// Destructor
71 ~SDMath();
72
[248]73// Binary Table operators. op=ADD, SUB, MUL, DIV, QUOTIENT
74 casa::CountedPtr<SDMemTable> binaryOperate (const casa::CountedPtr<SDMemTable>& left,
75 const casa::CountedPtr<SDMemTable>& right,
[294]76 const casa::String& op, casa::Bool preserve,
77 casa::Bool tSys) const;
[152]78
79// Average in time
[175]80 casa::CountedPtr<SDMemTable> average(const casa::Block<casa::CountedPtr<SDMemTable> >& in,
81 const casa::Vector<casa::Bool>& mask,
[234]82 casa::Bool scanAverage,
[248]83 const casa::String& weightStr,
[309]84 casa::Bool align=casa::False) const;
[48]85
[234]86// Statistics. If row<0, all rows are done otherwise, just the
87// specified row.
[170]88 std::vector<float> statistic(const casa::CountedPtr<SDMemTable>& in,
[234]89 const casa::Vector<casa::Bool>& mask,
90 const casa::String& which, casa::Int row) const;
[130]91
[171]92// Bin up spectra
[234]93 SDMemTable* bin(const SDMemTable& in, casa::Int width) const;
[171]94
[299]95// Resample spectra
96 SDMemTable* resample(const SDMemTable& in, const casa::String& method,
97 casa::Float factor) const;
98
[177]99// Smooth
100 SDMemTable* smooth (const SDMemTable& in, const casa::String& kernel,
[234]101 casa::Float width, casa::Bool doAll) const;
[177]102
[221]103// Flux conversion between Jansky and Kelvin
[354]104 SDMemTable* convertFlux (const SDMemTable& in, casa::Float D, casa::Float etaAp,
105 casa::Float JyPerK, casa::Bool doAll) const;
[221]106
[227]107// Gain-elevation correction
[234]108 SDMemTable* gainElevation (const SDMemTable& in, const casa::Vector<casa::Float>& coeffs,
109 const casa::String& fileName,
110 const casa::String& method, casa::Bool doAll) const;
[227]111
[309]112// Frequency Alignment
[317]113 SDMemTable* frequencyAlignment (const SDMemTable& in, const casa::String& refTime,
114 const casa::String& method) const;
[262]115
[234]116// Opacity correction
117 SDMemTable* opacity (const SDMemTable& in, casa::Float tau, casa::Bool doAll) const;
118
[248]119// Simple unary mathematical operations. what=0 (mul) or 1 (add)
120 SDMemTable* unaryOperate(const SDMemTable& in, casa::Float offset,
[294]121 casa::Bool doAll, casa::uInt what, casa::Bool tSys) const;
[169]122
123// Average polarizations
[315]124 SDMemTable* averagePol(const SDMemTable& in, const casa::Vector<casa::Bool>& mask,
125 const casa::String& wtStr) const;
[169]126
[170]127 private:
[169]128
[152]129// Weighting type for time averaging
130
[162]131 enum WeightType {NONE,VAR,TSYS};
[144]132
[152]133// Function to use accumulate data during time averaging
134
[146]135 void accumulate (casa::Double& timeSum, casa::Double& intSum, casa::Int& nAccum,
136 casa::MaskedArray<casa::Float>& sum, casa::Array<casa::Float>& sumSq,
137 casa::Array<casa::Float>& nPts, casa::Array<casa::Float>& tSysSum,
138 const casa::Array<casa::Float>& tSys, const casa::Array<casa::Float>& nInc,
139 const casa::Vector<casa::Bool>& mask, casa::Double time, casa::Double interval,
140 const casa::Block<casa::CountedPtr<SDMemTable> >& in,
141 casa::uInt iTab, casa::uInt iRow, casa::uInt axis, casa::uInt nAxesSub,
[227]142 casa::Bool useMask, WeightType wtType) const;
[146]143
[354]144// Work out conversion factor for converting Jy<->K per IF per row and apply
145 void convertBrightnessUnits (SDMemTable* pTabOut, const SDMemTable& in,
146 casa::Bool toKelvin, casa::Float sFac, casa::Bool doAll) const;
[152]147
[162]148// Convert weight string to enum value
149
[227]150 void convertWeightString (WeightType& wt, const casa::String& weightStr) const;
151
152// Convert interpolation type string
[317]153// void convertInterpString(casa::Int& type, const casa::String& interp) const;
154 void convertInterpString(casa::InterpolateArray1D<casa::Double,casa::Float>::InterpolationMethod& method,
155 const casa::String& interp) const;
[227]156
[230]157// Correct data from an ascii Table
[234]158 void correctFromAsciiTable(SDMemTable* pTabOut, const SDMemTable& in,
159 const casa::String& fileName,
160 const casa::String& col0, const casa::String& col1,
161 const casa::String& methodStr, casa::Bool doAll,
162 const casa::Vector<casa::Float>& xOut) const;
[230]163
164// Correct data from a Table
[234]165 void correctFromTable(SDMemTable* pTabOut, const SDMemTable& in, const casa::Table& tTable,
166 const casa::String& col0, const casa::String& col1,
167 const casa::String& methodStr, casa::Bool doAll,
168 const casa::Vector<casa::Float>& xOut) const;
[230]169
[234]170// Correct data from a Vector
171 void correctFromVector (SDMemTable* pTabOut, const SDMemTable& in,
172 casa::Bool doAll, const casa::Vector<casa::Float>& factor) const;
173
[354]174// Convert time String to Epoch
175 casa::MEpoch epochFromString (const casa::String& str, casa::MEpoch::Types timeRef) const;
[234]176
[354]177// Function to fill Scan Container when averaging in time
[234]178
[354]179 void fillSDC (SDContainer& sc, const casa::Array<casa::Bool>& mask,
180 const casa::Array<casa::Float>& data,
181 const casa::Array<casa::Float>& tSys,
182 casa::Int scanID, casa::Double timeStamp,
183 casa::Double interval, const casa::String& sourceName,
184 const casa::Vector<casa::uInt>& freqID) const;
185
186// Format EPoch
187 casa::String formatEpoch(const casa::MEpoch& epoch) const;
188
189// Align in Frequency
190 SDMemTable* frequencyAlign (const SDMemTable& in,
191 casa::MFrequency::Types system,
192 const casa::String& timeRef,
193 const casa::String& method) const;
194
[309]195// Generate frequency aligners
196 void generateFrequencyAligners (casa::PtrBlock<casa::FrequencyAligner<casa::Float>* >& a,
[330]197 const SDDataDesc& dDesc,
[309]198 const SDMemTable& in, casa::uInt nChan,
199 casa::MFrequency::Types system,
200 const casa::MPosition& refPos,
201 const casa::MEpoch& refEpoch) const;
[294]202
[330]203// Generate data description table (combines source and freqID)
204 void generateDataDescTable (casa::Matrix<casa::uInt>& ddIdx,
205 SDDataDesc& dDesc,
206 casa::uInt nIF,
207 const SDMemTable& in,
208 const casa::Table& tabIn,
209 const casa::ROScalarColumn<casa::String>& srcCol,
210 const casa::ROArrayColumn<casa::uInt>& fqIDCol) const;
211
[354]212// Function to get the current cursor location
213 void getCursorLocation (casa::IPosition& start, casa::IPosition& end,
214 const SDMemTable& in) const;
[272]215
[354]216// Function to normalize data when averaging in time
[272]217
[354]218 void normalize (casa::MaskedArray<casa::Float>& data,
219 const casa::Array<casa::Float>& sumSq,
220 const casa::Array<casa::Float>& nPts,
221 WeightType wtType, casa::Int axis, casa::Int nAxes) const;
222
223// Put the data and mask into the SDContainer
224 void putDataInSDC (SDContainer& sc, const casa::Array<casa::Float>& data,
225 const casa::Array<casa::Bool>& mask) const;
226
227// Read ascii file into a Table
228
229 casa::Table readAsciiFile (const casa::String& fileName) const;
[165]230};
[146]231
[330]232
233
234
[165]235} // namespace
[146]236
[165]237#endif
Note: See TracBrowser for help on using the repository browser.