// // C++ Interface: STGrid // // Description: // // // Author: Takeshi Nakazato , (C) 2011 // // Copyright: See COPYING file that comes with this distribution // // #ifndef ASAPSTGRID_H #define ASAPSTGRID_H // ASAP // ScantableWrapper.h must be included first to avoid compiler warnings // related with _XOPEN_SOURCE #include "ScantableWrapper.h" #include "Scantable.h" #include "concurrent.h" #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std ; using namespace casa ; namespace asap { class STGrid { public: STGrid() ; STGrid( const string infile ) ; STGrid( const vector infile ) ; virtual ~STGrid() {} ; void setFileIn( const string infile ) ; void setFileList( const vector infile ) ; void setIF( unsigned int ifno ) { ifno_ = ifno ; } ; void setPolList( vector pols ) ; void setScanList( vector scans ) ; void defineImage( int nx=-1, int ny=-1, string scellx="", string scelly="", string scenter="" ) ; void setFunc( string convtype="box", int convsupport=-1, string truncate="", string gwidth="", string jwidth="" ) ; void setWeight( const string wType="uniform" ) ; void enableClip() { doclip_ = True ; } ; void disableClip() { doclip_ = False ; } ; void grid() ; string saveData( string outfile="" ) ; // support function to know how grid function looks like vector getConvFunc(); // for plotting vector getResultantMapSize(); vector getResultantCellSize(); //private: protected: void init() ; // actual gridding void gridPerRow() ; void gridPerRowWithClipping() ; // clipping void clipMinMax( Array &data, Array &weight, Array &npoints, Array &clipmin, Array &clipwmin, Array &clipcmin, Array &clipmax, Array &clipwmax, Array &clipcmax ) ; void setupGrid() ; void setupGrid( Int &nx, Int &ny, String &cellx, String &celly, Double &xmin, Double &xmax, Double &ymin, Double &ymax, String ¢er ) ; void mapExtent( Double &xmin, Double &xmax, Double &ymin, Double &ymax ) ; void setData( Array &gdata, Array &gwgt ) ; Int getDataChunk( IPosition const &wshape, IPosition const &vshape, IPosition const &dshape, Array &spectra, Array &direction, Array &flagtra, Array &rflag, Array &weight ) ; Int getDataChunk( Array &spectra, Array &direction, Array &flagtra, Array &rflag, Array &weight ) ; Int getDataChunk( Array &spectra, Array &direction, Array &flagtra, Array &rflag, Array &weight ) ; void getWeight( Array &w, Array &tsys, Array &tint ) ; void toInt( Array &u, Array &v ) ; void toInt( Array &u, Array &v ) ; void toPixel( Array &world, Array &pixel ) ; void boxFunc( Vector &convFunc, Int &convSize ) ; void spheroidalFunc( Vector &convFunc ) ; void gaussFunc( Vector &convFunc, Double hwhm, Double truncate ) ; void gjincFunc( Vector &convFunc, Double hwhm, Double c, Double truncate ); void pbFunc( Vector &convFunc ) ; void setConvFunc( Vector &convFunc ) ; void prepareTable( Table &tab, String &name ) ; void selectData() ; void setupArray() ; void updateChunkShape() ; void attach( Table &tab ) ; void call_ggridsd( Array &xy, Array &values, Int &nvispol, Int &nvischan, Array &flag, Array &rflag, Array &weight, Int &nrow, Int &irow, Array &grid, Array &wgrid, Int &nx, Int &ny, Int &npol, Int &nchan, Int &support, Int &sampling, Vector &convFunc, Int *chanMap, Int *polMap ) ; void call_ggridsd2( Array &xy, Array &values, Int &nvispol, Int &nvischan, Array &flag, Array &rflag, Array &weight, Int &nrow, Int &irow, Array &grid, Array &wgrid, Array &npoints, Array &clipmin, Array &clipwmin, Array &clipcmin, Array &clipmax, Array &clipwmax, Array &clipcmax, Int &nx, Int &ny, Int &npol, Int &nchan, Int &support, Int &sampling, Vector &convFunc, Int *chanMap, Int *polMap ) ; void initPol( Int ipol ) ; void initTable( uInt idx ) ; Bool isMultiIF( Table &tab ) ; void fillMainColumns( Table &tab ) ; void fillTable( Table &tab ) ; virtual void table( Table &tab, uInt i ) ; static bool produceChunk(void *ctx) throw(concurrent::PCException); static void consumeChunk(void *ctx) throw(concurrent::PCException); static void consumeChunkWithClipping(void *ctx) throw(concurrent::PCException); // user input Int nxUI_ ; Int nyUI_ ; String cellxUI_ ; String cellyUI_ ; String centerUI_ ; Block infileList_ ; uInt nfile_ ; Int ifno_ ; Bool doclip_ ; Int nx_ ; Int ny_ ; Int npol_ ; Int npolOrg_ ; Int nchan_ ; Double cellx_ ; Double celly_ ; Vector center_ ; String convType_ ; Int convSupport_ ; Int userSupport_ ; String gwidth_; String jwidth_; String truncate_; Int convSampling_ ; Vector pollist_ ; Vector scanlist_ ; String wtype_ ; Block tableList_ ; Vector rows_ ; Int nchunk_ ; CountedPtr dircoord_; /////////////// gridPerRow variable IPosition vshape_; IPosition wshape_; IPosition dshape_; // loop variable Int nrow_ ; Array data_ ; Array flag_ ; Table tab_ ; // per pol Table ptab_ ; ROArrayColumn spectraCol_ ; ROArrayColumn flagtraCol_ ; ROArrayColumn directionCol_ ; ROScalarColumn flagRowCol_ ; ROArrayColumn tsysCol_ ; ROScalarColumn intervalCol_ ; Int nprocessed_ ; double eGetData_; double eToPixel_; double eGGridSD_; }; class STGrid2 : public STGrid { public: STGrid2() ; STGrid2( const ScantableWrapper &s ) ; STGrid2( const vector &v ) ; void setScantable( const ScantableWrapper &s ) ; void setScantableList( const vector &v ) ; void selectData() ; virtual void table( Table &tab, uInt i ) ; ScantableWrapper getResultAsScantable( int tp ) ; private: Block dataList_ ; }; } #endif