[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] | 39 | namespace asap {
|
---|
[2] | 40 |
|
---|
| 41 | class SDMemTable;
|
---|
| 42 |
|
---|
[66] | 43 | namespace 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,
|
---|
[165] | 69 | casa::Int width);
|
---|
[152] | 70 |
|
---|
| 71 | // Average in time
|
---|
| 72 |
|
---|
[165] | 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);
|
---|
[48] | 76 |
|
---|
[152] | 77 | // Average polarizations
|
---|
| 78 |
|
---|
[165] | 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);
|
---|
[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 |
|
---|
[155] | 88 | // private like functions (this is not a class so can't make them private)
|
---|
[130] | 89 |
|
---|
[152] | 90 | // Weighting type for time averaging
|
---|
| 91 |
|
---|
[162] | 92 | enum WeightType {NONE,VAR,TSYS};
|
---|
[144] | 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,
|
---|
[162] | 103 | casa::Bool useMask, WeightType wtType);
|
---|
[146] | 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 |
|
---|
[162] | 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 |
|
---|
[152] | 118 | // Function to normalize data when averaging in time
|
---|
[144] | 119 |
|
---|
[146] | 120 | void normalize (casa::MaskedArray<casa::Float>& data,
|
---|
| 121 | const casa::Array<casa::Float>& sumSq,
|
---|
| 122 | const casa::Array<casa::Float>& nPts,
|
---|
[162] | 123 | WeightType wtType, casa::Int axis, casa::Int nAxes);
|
---|
[152] | 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);
|
---|
[162] | 133 |
|
---|
| 134 | // Convert weight string to enum value
|
---|
| 135 |
|
---|
| 136 | void convertWeightString (WeightType& wt, const std::string& weightStr);
|
---|
[125] | 137 |
|
---|
[165] | 138 | // Function for simple mathematical operations. what=0 (mul) or 1 (add)
|
---|
[2] | 139 |
|
---|
[165] | 140 | SDMemTable* localOperate (const SDMemTable& in, casa::Float offset,
|
---|
| 141 | casa::Bool doAll, casa::uInt what);
|
---|
[146] | 142 |
|
---|
[165] | 143 | // Function to average polarizations
|
---|
[146] | 144 |
|
---|
[165] | 145 | SDMemTable* localAveragePol(const SDMemTable& in, const casa::Vector<casa::Bool>& mask);
|
---|
| 146 | };
|
---|
[146] | 147 |
|
---|
[165] | 148 | } // namespace
|
---|
[146] | 149 |
|
---|
[165] | 150 | #endif
|
---|