source: trunk/src/SDMath.h@ 251

Last change on this file since 251 was 248, checked in by kil064, 20 years ago

remove function 'quotient' and put its functionality into
function 'binaryOperate'

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