source: trunk/src/SDMath.h@ 167

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

Reimplement 'bin' with insitu version as well

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 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
39namespace asap {
40
41class SDMemTable;
42
43namespace SDMath {
44
45// Quotient
46
47 casa::CountedPtr<SDMemTable> quotient(const casa::CountedPtr<SDMemTable>& on,
48 const casa::CountedPtr<SDMemTable>& off);
49
50// Multiply
51
52 void multiplyInSitu(SDMemTable* in, casa::Float factor, casa::Bool all);
53 casa::CountedPtr<SDMemTable> multiply(const casa::CountedPtr<SDMemTable>& in,
54 casa::Float factor, casa::Bool all);
55
56// Addition
57
58 void addInSitu (SDMemTable* in, casa::Float offset, casa::Bool all);
59 casa::CountedPtr<SDMemTable> add(const casa::CountedPtr<SDMemTable>& in,
60 casa::Float offset, casa::Bool all);
61
62// Hanning
63
64 casa::CountedPtr<SDMemTable> hanning(const casa::CountedPtr<SDMemTable>& in);
65
66// Bin up
67
68 void binInSitu (SDMemTable* in, casa::Int width);
69 casa::CountedPtr<SDMemTable> bin(const casa::CountedPtr<SDMemTable>& in, casa::Int width);
70
71// Average in time
72
73 casa::CountedPtr<SDMemTable> average (const casa::Block<casa::CountedPtr<SDMemTable> >& in,
74 const casa::Vector<casa::Bool>& mask,
75 bool scanAverage, const std::string& weightStr);
76
77// Average polarizations
78
79 void averagePolInSitu (SDMemTable* in, const casa::Vector<casa::Bool>& mask);
80 casa::CountedPtr<SDMemTable> averagePol(const casa::CountedPtr<SDMemTable>& in,
81 const casa::Vector<casa::Bool>& mask);
82
83// Statistics
84
85 std::vector<float> statistic(const casa::CountedPtr<SDMemTable>& in,
86 const std::vector<bool>& mask, const std::string& which);
87
88// private like functions (this is not a class so can't make them private)
89
90// Weighting type for time averaging
91
92 enum WeightType {NONE,VAR,TSYS};
93
94// Function to use accumulate data during time averaging
95
96 void accumulate (casa::Double& timeSum, casa::Double& intSum, casa::Int& nAccum,
97 casa::MaskedArray<casa::Float>& sum, casa::Array<casa::Float>& sumSq,
98 casa::Array<casa::Float>& nPts, casa::Array<casa::Float>& tSysSum,
99 const casa::Array<casa::Float>& tSys, const casa::Array<casa::Float>& nInc,
100 const casa::Vector<casa::Bool>& mask, casa::Double time, casa::Double interval,
101 const casa::Block<casa::CountedPtr<SDMemTable> >& in,
102 casa::uInt iTab, casa::uInt iRow, casa::uInt axis, casa::uInt nAxesSub,
103 casa::Bool useMask, WeightType wtType);
104
105// Function to fill Scan Container when averaging in time
106
107 void fillSDC (SDContainer& sc, const casa::Array<casa::Bool>& mask,
108 const casa::Array<casa::Float>& data,
109 const casa::Array<casa::Float>& tSys,
110 casa::Int scanID, casa::Double timeStamp,
111 casa::Double interval, const casa::String& sourceName,
112 const casa::Vector<casa::uInt>& freqID);
113
114// Put the data and mask into the SDContainer
115 void putDataInSDC (SDContainer& sc, const casa::Array<casa::Float>& data,
116 const casa::Array<casa::Bool>& mask);
117
118// Function to normalize data when averaging in time
119
120 void normalize (casa::MaskedArray<casa::Float>& data,
121 const casa::Array<casa::Float>& sumSq,
122 const casa::Array<casa::Float>& nPts,
123 WeightType wtType, casa::Int axis, casa::Int nAxes);
124
125// Functions for simple mathematical operations. what=0 (mul) or 1 (add)
126
127 SDMemTable* localOperate (const SDMemTable& in, casa::Float offset,
128 casa::Bool doAll, casa::uInt what);
129
130// Function to get the current cursor location
131 void getCursorLocation (casa::IPosition& start, casa::IPosition& end,
132 const SDMemTable& in);
133
134// Convert weight string to enum value
135
136 void convertWeightString (WeightType& wt, const std::string& weightStr);
137
138// Function for simple mathematical operations. what=0 (mul) or 1 (add)
139
140 SDMemTable* localOperate (const SDMemTable& in, casa::Float offset,
141 casa::Bool doAll, casa::uInt what);
142
143// Function to average polarizations
144
145 SDMemTable* localAveragePol(const SDMemTable& in, const casa::Vector<casa::Bool>& mask);
146
147// Function to bin up spectra
148
149 SDMemTable* localBin (const SDMemTable& in, casa::Int width);
150};
151
152} // namespace
153
154#endif
Note: See TracBrowser for help on using the repository browser.