source: trunk/src/SDMath.h @ 154

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

function 'add' and 'multiply' now take arg. doAll to
indicate whether operation to be applied to
all spectral or cursor selection only.

Combine functions 'localMultiply' and 'localAdd' into
'localOperate'

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 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>
[2]38
[83]39namespace asap {
[2]40
41class SDMemTable;
42
[66]43namespace SDMath {
[152]44
45// Quotient
46
[125]47  casa::CountedPtr<SDMemTable> quotient(const casa::CountedPtr<SDMemTable>& on,
48                                         const casa::CountedPtr<SDMemTable>& off);
[152]49
50// Multiply
51
52  void multiplyInSitu(SDMemTable* in, casa::Float factor, casa::Bool all);
[125]53  casa::CountedPtr<SDMemTable> multiply(const casa::CountedPtr<SDMemTable>& in,
[152]54                                        casa::Float factor, casa::Bool all);
55
56// Addition
57
58  void addInSitu (SDMemTable* in, casa::Float offset, casa::Bool all);
[125]59  casa::CountedPtr<SDMemTable> add(const casa::CountedPtr<SDMemTable>& in,
[152]60                                   casa::Float offset, casa::Bool all);
61
62//  Hanning
63
[125]64  casa::CountedPtr<SDMemTable> hanning(const casa::CountedPtr<SDMemTable>& in);
[48]65
[152]66// Bin up
67
68  casa::CountedPtr<SDMemTable> bin(const casa::CountedPtr<SDMemTable>& in,
69                             casa::Int width);
70
71// Average in time
72
[144]73  casa::CountedPtr<SDMemTable>
74  average (const casa::Block<casa::CountedPtr<SDMemTable> >& in,
75           const casa::Vector<casa::Bool>& mask,
76           bool scanAverage, const std::string& weightStr);
[48]77
[152]78// Average polarizations
79
[125]80  casa::CountedPtr<SDMemTable>
81  averagePol(const casa::CountedPtr<SDMemTable>& in, const casa::Vector<casa::Bool>& mask);
[48]82
[152]83// Statistics
84
[130]85  std::vector<float> statistic(const casa::CountedPtr<SDMemTable>& in,
86                                const std::vector<bool>& mask, const std::string& which);
87
88// private (not actually...)
89
[152]90// Weighting type for time averaging
91
[144]92  enum weightType {NONE,VAR,TSYS};
93
[152]94// Function to use accumulate data during time averaging
95
[146]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
[152]105// Function to fill Scan Container when averaging in time
106
[144]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
[152]114// Function to normalize data when averaging in time
[144]115
[146]116  void normalize (casa::MaskedArray<casa::Float>& data,
117                  const casa::Array<casa::Float>& sumSq,
118                  const casa::Array<casa::Float>& nPts,
119                  weightType wtType, casa::Int axis, casa::Int nAxes);
[152]120
121// Functions for simple mathematical operations.  what=0 (mul) or 1 (add)
122
123  SDMemTable* localOperate (const SDMemTable& in, casa::Float offset,
124                            casa::Bool doAll, casa::uInt what);
125
126// Function to get the current cursor location
127   void getCursorLocation (casa::IPosition& start, casa::IPosition& end,
128                           const SDMemTable& in);
[2]129};
[125]130
[2]131} // namespace
132
133#endif
[146]134
135
136
137
138
Note: See TracBrowser for help on using the repository browser.