casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Go to the documentation of this file.
1 // -*- C++ -*-
2 //# Utils.h: Definition of global functions in
3 //# Copyright (C) 1997,1998,1999,2000,2001,2002,2003
4 //# Associated Universities, Inc. Washington DC, USA.
5 //#
6 //# This library is free software; you can redistribute it and/or modify it
7 //# under the terms of the GNU Library General Public License as published by
8 //# the Free Software Foundation; either version 2 of the License, or (at your
9 //# option) any later version.
10 //#
11 //# This library is distributed in the hope that it will be useful, but WITHOUT
12 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 //# License for more details.
15 //#
16 //# You should have received a copy of the GNU Library General Public License
17 //# along with this library; if not, write to the Free Software Foundation,
18 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 //#
20 //# Correspondence concerning AIPS++ should be addressed as follows:
21 //# Internet email:
22 //# Postal address: AIPS++ Project Office
23 //# National Radio Astronomy Observatory
24 //# 520 Edgemont Road
25 //# Charlottesville, VA 22903-2475 USA
26 //#
27 //# $Id$
32 #include <casa/aips.h>
33 #include <casa/Exceptions/Error.h>
34 #include <msvis/MSVis/VisBuffer2.h>
35 #include <casa/Quanta/Quantum.h>
37 //#include <ms/MeasurementSets/MeasurementSet.h>
41 #include <casa/Arrays/Array.h>
42 #include <casa/Logging/LogIO.h>
43 #include <casa/iostream.h>
45 namespace casa
46 {
47  using namespace vi;
48  namespace refim {
51  casacore::Float& maxAbs,casacore::IPosition& posMaxAbs);
54  casacore::Float& maxAbs,casacore::IPosition& posMaxAbs,
55  casacore::Bool flip=false);
56  casacore::Double getCurrentTimeStamp(const VisBuffer2& vb);
58  casacore::Double getPA(const vi::VisBuffer2& vb);
65  casacore::Bool isVBNaN(const VisBuffer2& vb, casacore::String& mesg);
66  namespace SynthesisUtils
67  {
68  //using namespace vi;
72  casacore::Double dAngleRad,
73  casacore::String interpMathod=casacore::String("CUBIC"),
74  casacore::Bool modifyInCS=true);
84  inline casacore::Int nint(const casacore::Double& v) {return (casacore::Int)std::floor(v+0.5);}
85  inline casacore::Int nint(const casacore::Float& v) {return (casacore::Int)std::floor(v+0.5);}
86  inline casacore::Bool near(const casacore::Double& d1, const casacore::Double& d2,
87  const casacore::Double EPS=1E-6)
88  {
89  casacore::Bool b1=(fabs(d1-d2) < EPS)?true:false;
90  return b1;
91  }
92  template <class T>
93  inline void SETVEC(casacore::Vector<T>& lhs, const casacore::Vector<T>& rhs)
94  {lhs.resize(rhs.shape()); lhs = rhs;};
95  template <class T>
96  inline void SETVEC(casacore::Array<T>& lhs, const casacore::Array<T>& rhs)
97  {lhs.resize(rhs.shape()); lhs = rhs;};
99  template <class T>
100  T getenv(const char *name, const T defaultVal);
103  void makeFTCoordSys(const casacore::CoordinateSystem& coords,
104  const casacore::Int& convSize,
106  casacore::CoordinateSystem& ftCoords);
109  casacore::Matrix<casacore::Double>& expandedFreqList,
110  casacore::Matrix<casacore::Double>& expandedConjFreqList);
112  template <class T>
114  inline casacore::Double conjFreq(const casacore::Double& freq, const casacore::Double& refFreq)
115  {return sqrt(2*refFreq*refFreq - freq*freq);};
119  template <class T>
120  T stdNearestValue(const std::vector<T>& list, const T& val, casacore::Int& index);
127  void calcIntersection(const casacore::Int blc1[2], const casacore::Int trc1[2], const casacore::Float blc2[2], const casacore::Float trc2[2],
128  casacore::Float blc[2], casacore::Float trc[2]);
129  casacore::Bool checkIntersection(const casacore::Int blc1[2], const casacore::Int trc1[2], const casacore::Float blc2[2], const casacore::Float trc2[2]);
133  template<class Iterator>
134  Iterator Unique(Iterator first, Iterator last);
136  void showCS(const casacore::CoordinateSystem& cs, std::ostream& os, const casacore::String& msg=casacore::String());
138  const casacore::IPosition getCFShape(const casacore::String& Dir, const casacore::String& fileName);
140  void rotate2(const double& actualPA, CFCell& baseCFC, CFCell& cfc, const double& rotAngleIncr);
144  casacore::CoordinateSystem& coordSys,
145  casacore::Double& sampling,
146  casacore::Double& paVal,
147  casacore::Int& xSupport, casacore::Int& ySupport,
148  casacore::Double& fVal, casacore::Double& wVal, casacore::Int& mVal,
150  casacore::Bool loadPixels,
151  casacore::Bool loadMiscInfo=true);
155  }
160  //
161  // An interface class to detect changes in the VisBuffer
162  // Exact meaning of the "change" is defined in the derived classes
163  //
165  // return true if a change occurs in the given row since the last call of update
166  virtual casacore::Bool changed(const VisBuffer2 &vb, casacore::Int row) const = 0;
167  // start looking for a change from the given row of the VisBuffer
168  virtual void update(const VisBuffer2 &vb, casacore::Int row) = 0;
170  // reset to the state which exists just after construction
171  virtual void reset() = 0;
173  // some derived methods, which use the abstract virtual function changed(vb,row)
175  // return true if a change occurs somewhere in the buffer
176  casacore::Bool changed(const VisBuffer2 &vb) const;
177  // return true if a change occurs somewhere in the buffer starting from row1
178  // up to row2 (row2=-1 means up to the end of the buffer). The row number,
179  // where the change occurs is returned in the row2 parameter
180  casacore::Bool changedBuffer(const VisBuffer2 &vb, casacore::Int row1, casacore::Int &row2) const;
181  protected:
182  // a virtual destructor to make the compiler happy
183  virtual ~IChangeDetector();
184  };
185  //
189  //
190  // ParAngleChangeDetector - a class to detect a change in the parallactic
191  // angle.
192  //
194  casacore::Double pa_tolerance_p; // a parallactic angle tolerance. If exeeded,
195  // the angle is considered to be changed.
196  casacore::Double last_pa_p; // last value of the parallactic angle
197  public:
198  // The default constructor
199  ParAngleChangeDetector():pa_tolerance_p(0.0) {};
200  // set up the tolerance, which determines how much the position angle should
201  // change to report the change by this class
202  ParAngleChangeDetector(const casacore::Quantity &pa_tolerance);
204  virtual void setTolerance(const casacore::Quantity &pa_tolerance);
205  // reset to the state which exists just after construction
206  virtual void reset();
208  // return parallactic angle tolerance
209  casacore::Quantity getParAngleTolerance() const;
211  // implementation of the base class' virtual functions
213  // return true if a change occurs in the given row since the last call of update
214  virtual casacore::Bool changed(const VisBuffer2 &vb, casacore::Int row) const;
215  // start looking for a change from the given row of the VisBuffer
216  virtual void update(const VisBuffer2 &vb, casacore::Int row);
217  };
219  //
222  };
223 };
224 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
A Measure: astronomical direction.
Definition: MDirection.h:174
int Int
Definition: aipstype.h:50
const casacore::IPosition getCFShape(const casacore::String &Dir, const casacore::String &fileName)
casacore::Vector< casacore::String > parseBandName(const casacore::String &fullName)
void rotateComplexArray(casacore::LogIO &logIO, casacore::Array< casacore::Complex > &inArray, casacore::CoordinateSystem &inCS, casacore::Array< casacore::Complex > &outArray, casacore::Double dAngleRad, casacore::String interpMathod=casacore::String("CUBIC"), casacore::Bool modifyInCS=true)
casacore::Double getCurrentTimeStamp(const VisBuffer &vb)
virtual void reset()
Overrides PlotTool::reset().
casacore::Bool findMaxAbsLattice(const casacore::ImageInterface< casacore::Float > &lattice, casacore::Float &maxAbs, casacore::IPosition &posMaxAbs)
void SETVEC(casacore::Vector< T > &lhs, const casacore::Vector< T > &rhs)
Definition: Utils.h:89
casacore::Double last_pa_p
the angle is considered to be changed.
Definition: Utils.h:196
struct Node * first
Definition: malloc.h:330
Definition: Utils.h:193
casacore::Double getRefFreq(const VisBuffer &vb)
casacore::CoordinateSystem makeUVCoords(casacore::CoordinateSystem &imageCoordSys, casacore::IPosition &shape)
casacore::Double conjFreq(const casacore::Double &freq, const casacore::Double &refFreq)
Definition: Utils.h:110
const casacore::Array< casacore::Complex > getCFPixels(const casacore::String &Dir, const casacore::String &fileName)
ostream-like interface to creating log messages.
Definition: LogIO.h:167
casacore::Double pa_tolerance_p
Definition: Utils.h:194
TableExprNode mjd(const TableExprNode &node)
Definition: ExprNode.h:1464
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
LatticeExprNode floor(const LatticeExprNode &expr)
casacore::Double nearestValue(const casacore::Vector< casacore::Double > &list, const casacore::Double &val, casacore::Int &index)
void makeFTCoordSys(const casacore::CoordinateSystem &coords, const casacore::Int &convSize, const casacore::Vector< casacore::Double > &ftRef, casacore::CoordinateSystem &ftCoords)
virtual void resize()
Make this array a different shape.
casacore::Vector< casacore::Int > mapSpwIDToDDID(const VisBuffer &vb, const casacore::Int &spwID)
void expandFreqSelection(const casacore::Matrix< casacore::Double > &freqSelection, casacore::Matrix< casacore::Double > &expandedFreqList, casacore::Matrix< casacore::Double > &expandedConjFreqList)
casacore::TableRecord getCFParams(const casacore::String &dirName, const casacore::String &fileName, casacore::Array< casacore::Complex > &pixelBuffer, casacore::CoordinateSystem &coordSys, casacore::Double &sampling, casacore::Double &paVal, casacore::Int &xSupport, casacore::Int &ySupport, casacore::Double &fVal, casacore::Double &wVal, casacore::Int &mVal, casacore::Double &conjFreq, casacore::Int &conjPoln, casacore::Bool loadPixels, casacore::Bool loadMiscInfo=true)
casacore::String mjdToString(casacore::Time &mjd)
void getHADec(casacore::MeasurementSet &ms, const VisBuffer &vb, casacore::Double &HA, casacore::Double &RA, casacore::Double &Dec)
double Double
Definition: aipstype.h:55
const IPosition & shape() const
The length of the Vector.
Definition: Vector.h:293
casacore::Int nint(const casacore::Double &v)
Definition: Utils.h:80
LatticeExprNode sqrt(const LatticeExprNode &expr)
date and time enquiry functions, with some operations.
Definition: Time.h:88
casacore::Double getPA(const VisBuffer &vb)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void storeArrayAsImage(casacore::String fileName, const casacore::CoordinateSystem &coords, const casacore::Array< casacore::Complex > &cf)
void libreConvolver(casacore::Array< T > &c1, const casacore::Array< T > &c2)
casacore::Int getPhaseCenter(casacore::MeasurementSet &ms, casacore::MDirection &dir0, casacore::Int whichField=-1)
float Float
Definition: aipstype.h:54
The default constructor.
Definition: Utils.h:199
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
casacore::Bool isVBNaN(const VisBuffer &vb, casacore::String &mesg)
void storeImg(casacore::String fileName, casacore::ImageInterface< casacore::Complex > &theImg, casacore::Bool writeReIm=false)
A Table intended to hold astronomical data (a set of Measurements).
void showCS(const casacore::CoordinateSystem &cs, std::ostream &os, const casacore::String &msg=casacore::String())
VisBuffer2s encapsulate one chunk of visibility data for processing.
Definition: VisBuffer2.h:141
casacore::Vector< casacore::Int > mapSpwIDToPolID(const VisBuffer &vb, const casacore::Int &spwID)
T stdNearestValue(const std::vector< T > &list, const T &val, casacore::Int &index)
bool near(const SpectralElement &s1, const SpectralElement &s2, const casacore::Double tol)
void makeStokesAxis(casacore::Int npol_p, casacore::Vector< casacore::String > &polType, casacore::Vector< casacore::Int > &whichStokes)
casacore::Bool checkIntersection(const casacore::Int blc1[2], const casacore::Int trc1[2], const casacore::Float blc2[2], const casacore::Float trc2[2])
template &lt;class t&gt;=&quot;&quot;&gt;
Definition: CFCell.h:92
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void findLatticeMax(const casacore::Array< casacore::Complex > &lattice, casacore::Vector< casacore::Float > &maxAbs, casacore::Vector< casacore::IPosition > &posMaxAbs)
void resize(size_t len, Bool copyValues=False)
Definition: Vector.h:167
Iterator Unique(Iterator first, Iterator last)
void calcIntersection(const casacore::Int blc1[2], const casacore::Int trc1[2], const casacore::Float blc2[2], const casacore::Float trc2[2], casacore::Float blc[2], casacore::Float trc[2])
void rotate2(const double &actualPA, CFCell &baseCFC, CFCell &cfc, const double &rotAngleIncr)
Interconvert pixel and world coordinates.
T getenv(const char *name, const T defaultVal)
casacore::Float libreSpheroidal(casacore::Float nu)
const IPosition & shape() const
The length of each axis.
Definition: ArrayBase.h:121