// // C++ Interface: STMath // // Description: // // // Author: Malte Marquarding , (C) 2006 // // Copyright: See COPYING file that comes with this distribution // // #ifndef ASAPSTMATH_H #define ASAPSTMATH_H #include #include #include #include #include #include #include #include "Scantable.h" #include "STDefs.h" #include "STPol.h" #include "Logger.h" namespace asap { /** * Mathmatical operations on Scantable objects * @author Malte Marquarding */ class STMath : private Logger { public: // typedef for long method name typedef casa::InterpolateArray1D::InterpolationMethod imethod; // typedef for std::map typedef std::map imap; /** * whether to operate on the given Scantable or return a new one * @param insitu the toggle for this behaviour */ STMath(bool insitu=true); virtual ~STMath(); /** * get the currnt @attr inistu_ state */ bool insitu() const { return insitu_;}; /** * set the currnt @attr inistu state * @param b the new state */ void setInsitu(bool b) { insitu_ = b; }; /** * average a vector of Scantables * @param in the vector of Scantables to average * @param mask an optional mask to apply on specific weights * @param weight weighting scheme * @param avmode the mode ov averaging. Per "SCAN" or "ALL". * @return a casa::CountedPtr which either holds a new Scantable * or returns the imput pointer. */ casa::CountedPtr average( const std::vector >& in, const std::vector& mask = std::vector(), const std::string& weight = "NONE", const std::string& avmode = "SCAN"); /** * median average a vector of Scantables. See also STMath::average * @param in the Scantable to average * @param mode the averaging mode. Currently only "MEDIAN" * @param avmode the mode ov averaging. Per "SCAN" or "ALL". * @return a casa::CountedPtr which either holds a new Scantable * or returns the imput pointer. */ casa::CountedPtr averageChannel( const casa::CountedPtr & in, const std::string& mode = "MEDIAN", const std::string& avmode = "SCAN"); /** * Average polarisations together. really only useful if only linears are * available. * @param in the input Scantable * @param mask an optional mask if weight allows one * @param weight weighting scheme * @return */ casa::CountedPtr< Scantable > averagePolarisations( const casa::CountedPtr< Scantable > & in, const std::vector& mask, const std::string& weight ); /** * Average beams together. * @param in the input Scantable * @param mask an optional mask if weight allows one * @param weight weighting scheme * @return */ casa::CountedPtr< Scantable > averageBeams( const casa::CountedPtr< Scantable > & in, const std::vector& mask, const std::string& weight ); casa::CountedPtr unaryOperate( const casa::CountedPtr& in, float val, const std::string& mode, bool tsys=false ); casa::CountedPtr autoQuotient(const casa::CountedPtr& in, const std::string& mode = "NEAREST", bool preserve = true); casa::CountedPtr quotient( const casa::CountedPtr& on, const casa::CountedPtr& off, bool preserve = true ); casa::CountedPtr freqSwitch( const casa::CountedPtr& in ); std::vector statistic(const casa::CountedPtr& in, const std::vector& mask, const std::string& which); casa::CountedPtr bin( const casa::CountedPtr& in, int width=5); casa::CountedPtr resample(const casa::CountedPtr& in, const std::string& method, float width); casa::CountedPtr smooth(const casa::CountedPtr& in, const std::string& kernel, float width); casa::CountedPtr gainElevation(const casa::CountedPtr& in, const std::vector& coeff, const std::string& fileName, const std::string& method); casa::CountedPtr convertFlux(const casa::CountedPtr& in, float d, float etaap, float jyperk); casa::CountedPtr opacity(const casa::CountedPtr& in, float tau); casa::CountedPtr merge(const std::vector >& in); casa::CountedPtr invertPhase( const casa::CountedPtr& in); casa::CountedPtr rotateXYPhase( const casa::CountedPtr& in, float phase); casa::CountedPtr rotateLinPolPhase( const casa::CountedPtr& in, float phase); casa::CountedPtr swapPolarisations(const casa::CountedPtr& in); casa::CountedPtr frequencyAlign( const casa::CountedPtr& in, const std::string& refTime = "", const std::string& method = "cubic" ); casa::CountedPtr convertPolarisation( const casa::CountedPtr& in, const std::string& newtype); casa::CountedPtr mxExtract( const casa::CountedPtr& in, const std::string& srctype = "on"); /** * "hard" flag the data, this flags everything selected in setSelection() * @param frequency the frequency to remove * @param width the number of lags to flag left to the side of the frequency */ casa::CountedPtr lagFlag( const casa::CountedPtr& in, double frequency, double width); private: casa::CountedPtr applyToPol( const casa::CountedPtr& in, STPol::polOperation fptr, casa::Float phase); static imethod stringToIMethod(const std::string& in); static WeightType stringToWeight(const std::string& in); void scaleByVector(casa::Table& in, const casa::Vector& factor, bool dotsys); void scaleFromAsciiTable(casa::Table& in, const std::string& filename, const std::string& method, const casa::Vector& xout, bool dotsys); void scaleFromTable(casa::Table& in, const casa::Table& table, const std::string& method, const casa::Vector& xout, bool dotsys); void convertBrightnessUnits(casa::CountedPtr& in, bool tokelvin, float cfac); casa::CountedPtr< Scantable > getScantable(const casa::CountedPtr< Scantable >& in, bool droprows); casa::MaskedArray maskedArray( const casa::Vector& s, const casa::Vector& f ); casa::Vector flagsFromMA(const casa::MaskedArray& ma); bool insitu_; }; } #endif