source: trunk/src/SDMath.h@ 311

Last change on this file since 311 was 309, checked in by kil064, 20 years ago

remove 'velocityALignment' functions for new 'frequencyAlignment' ones

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.8 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;
[227]46
[272]47
[83]48namespace asap {
[2]49
50class SDMemTable;
51
[170]52class SDMath {
[152]53
[170]54 public:
55
56// Default constructor
57 SDMath();
58
59// Copy Constructor (copy semantics)
60 SDMath (const SDMath& other);
61
62// Assignment (copy semantics)
63 SDMath &operator=(const SDMath& other);
64
[183]65// Destructor
66 ~SDMath();
67
[248]68// Binary Table operators. op=ADD, SUB, MUL, DIV, QUOTIENT
69 casa::CountedPtr<SDMemTable> binaryOperate (const casa::CountedPtr<SDMemTable>& left,
70 const casa::CountedPtr<SDMemTable>& right,
[294]71 const casa::String& op, casa::Bool preserve,
72 casa::Bool tSys) const;
[152]73
74// Average in time
[175]75 casa::CountedPtr<SDMemTable> average(const casa::Block<casa::CountedPtr<SDMemTable> >& in,
76 const casa::Vector<casa::Bool>& mask,
[234]77 casa::Bool scanAverage,
[248]78 const casa::String& weightStr,
[309]79 casa::Bool align=casa::False) const;
[48]80
[234]81// Statistics. If row<0, all rows are done otherwise, just the
82// specified row.
[170]83 std::vector<float> statistic(const casa::CountedPtr<SDMemTable>& in,
[234]84 const casa::Vector<casa::Bool>& mask,
85 const casa::String& which, casa::Int row) const;
[130]86
[171]87// Bin up spectra
[234]88 SDMemTable* bin(const SDMemTable& in, casa::Int width) const;
[171]89
[299]90// Resample spectra
91 SDMemTable* resample(const SDMemTable& in, const casa::String& method,
92 casa::Float factor) const;
93
[177]94// Smooth
95 SDMemTable* smooth (const SDMemTable& in, const casa::String& kernel,
[234]96 casa::Float width, casa::Bool doAll) const;
[177]97
[221]98// Flux conversion between Jansky and Kelvin
99 SDMemTable* convertFlux (const SDMemTable& in, casa::Float area,
[234]100 casa::Float eta, casa::Bool doAll) const;
[221]101
[227]102// Gain-elevation correction
[234]103 SDMemTable* gainElevation (const SDMemTable& in, const casa::Vector<casa::Float>& coeffs,
104 const casa::String& fileName,
105 const casa::String& method, casa::Bool doAll) const;
[227]106
[309]107// Frequency Alignment
108 SDMemTable* frequencyAlignment (const SDMemTable& in, const casa::String& refTime) const;
[262]109
[234]110// Opacity correction
111 SDMemTable* opacity (const SDMemTable& in, casa::Float tau, casa::Bool doAll) const;
112
[248]113// Simple unary mathematical operations. what=0 (mul) or 1 (add)
114 SDMemTable* unaryOperate(const SDMemTable& in, casa::Float offset,
[294]115 casa::Bool doAll, casa::uInt what, casa::Bool tSys) const;
[169]116
117// Average polarizations
[234]118 SDMemTable* averagePol(const SDMemTable& in, const casa::Vector<casa::Bool>& mask) const;
[169]119
[170]120 private:
[169]121
[152]122// Weighting type for time averaging
123
[162]124 enum WeightType {NONE,VAR,TSYS};
[144]125
[152]126// Function to use accumulate data during time averaging
127
[146]128 void accumulate (casa::Double& timeSum, casa::Double& intSum, casa::Int& nAccum,
129 casa::MaskedArray<casa::Float>& sum, casa::Array<casa::Float>& sumSq,
130 casa::Array<casa::Float>& nPts, casa::Array<casa::Float>& tSysSum,
131 const casa::Array<casa::Float>& tSys, const casa::Array<casa::Float>& nInc,
132 const casa::Vector<casa::Bool>& mask, casa::Double time, casa::Double interval,
133 const casa::Block<casa::CountedPtr<SDMemTable> >& in,
134 casa::uInt iTab, casa::uInt iRow, casa::uInt axis, casa::uInt nAxesSub,
[227]135 casa::Bool useMask, WeightType wtType) const;
[146]136
[152]137// Function to fill Scan Container when averaging in time
138
[144]139 void fillSDC (SDContainer& sc, const casa::Array<casa::Bool>& mask,
140 const casa::Array<casa::Float>& data,
141 const casa::Array<casa::Float>& tSys,
142 casa::Int scanID, casa::Double timeStamp,
143 casa::Double interval, const casa::String& sourceName,
[227]144 const casa::Vector<casa::uInt>& freqID) const;
[144]145
[162]146// Put the data and mask into the SDContainer
147 void putDataInSDC (SDContainer& sc, const casa::Array<casa::Float>& data,
[227]148 const casa::Array<casa::Bool>& mask) const;
[162]149
[152]150// Function to normalize data when averaging in time
[144]151
[146]152 void normalize (casa::MaskedArray<casa::Float>& data,
153 const casa::Array<casa::Float>& sumSq,
154 const casa::Array<casa::Float>& nPts,
[227]155 WeightType wtType, casa::Int axis, casa::Int nAxes) const;
[152]156
157// Function to get the current cursor location
158 void getCursorLocation (casa::IPosition& start, casa::IPosition& end,
[227]159 const SDMemTable& in) const;
[162]160
161// Convert weight string to enum value
162
[227]163 void convertWeightString (WeightType& wt, const casa::String& weightStr) const;
164
165// Convert interpolation type string
166 void convertInterpString(casa::Int& type, const casa::String& interp) const;
167
[230]168// Correct data from an ascii Table
[234]169 void correctFromAsciiTable(SDMemTable* pTabOut, const SDMemTable& in,
170 const casa::String& fileName,
171 const casa::String& col0, const casa::String& col1,
172 const casa::String& methodStr, casa::Bool doAll,
173 const casa::Vector<casa::Float>& xOut) const;
[230]174
175// Correct data from a Table
[234]176 void correctFromTable(SDMemTable* pTabOut, const SDMemTable& in, const casa::Table& tTable,
177 const casa::String& col0, const casa::String& col1,
178 const casa::String& methodStr, casa::Bool doAll,
179 const casa::Vector<casa::Float>& xOut) const;
[230]180
[234]181// Correct data from a Vector
182 void correctFromVector (SDMemTable* pTabOut, const SDMemTable& in,
183 casa::Bool doAll, const casa::Vector<casa::Float>& factor) const;
184
[262]185// Read ascii file into a Table
[234]186
[262]187 casa::Table readAsciiFile (const casa::String& fileName) const;
[234]188
[262]189// Generate source table
190 void generateSourceTable (casa::Vector<casa::String>& srcTab,
191 casa::Vector<casa::uInt>& srcIdx,
192 casa::Vector<casa::uInt>& firstRow,
193 const casa::Vector<casa::String>& srcNames) const;
[230]194
[309]195// Generate frequency aligners
196 void generateFrequencyAligners (casa::PtrBlock<casa::FrequencyAligner<casa::Float>* >& a,
197 const SDMemTable& in, casa::uInt nChan,
198 casa::uInt nFreqIDs, casa::uInt nSrcTab,
199 const casa::Vector<casa::uInt>& firstRow,
200 casa::MFrequency::Types system,
201 const casa::MPosition& refPos,
202 const casa::MEpoch& refEpoch) const;
[294]203
[309]204// Align in Frequency
205 SDMemTable* frequencyAlign (const SDMemTable& in,
206 casa::MFrequency::Types system,
[272]207 const casa::String& timeRef) const;
208
209// Convert time String to Epoch
210 casa::MEpoch epochFromString (const casa::String& str, casa::MEpoch::Types timeRef) const;
211
212// Format EPoch
213 casa::String formatEpoch(const casa::MEpoch& epoch) const;
[165]214};
[146]215
[165]216} // namespace
[146]217
[165]218#endif
Note: See TracBrowser for help on using the repository browser.