source: trunk/src/SDMath.h@ 291

Last change on this file since 291 was 272, checked in by kil064, 20 years ago

add reference time arg. to function 'VelocityAlignment'

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