[2356] | 1 | //
|
---|
| 2 | // C++ Interface: STGrid
|
---|
| 3 | //
|
---|
| 4 | // Description:
|
---|
| 5 | //
|
---|
| 6 | //
|
---|
| 7 | // Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2011
|
---|
| 8 | //
|
---|
| 9 | // Copyright: See COPYING file that comes with this distribution
|
---|
| 10 | //
|
---|
| 11 | //
|
---|
| 12 | #ifndef ASAPSTGRID_H
|
---|
| 13 | #define ASAPSTGRID_H
|
---|
| 14 |
|
---|
| 15 | #include <iostream>
|
---|
| 16 | #include <fstream>
|
---|
| 17 | #include <string>
|
---|
[2360] | 18 | #include <vector>
|
---|
[2356] | 19 |
|
---|
| 20 | #include <casa/BasicSL/String.h>
|
---|
[2381] | 21 | #include <casa/Arrays/Array.h>
|
---|
[2356] | 22 | #include <casa/Arrays/Vector.h>
|
---|
[2381] | 23 | #include <casa/Containers/RecordField.h>
|
---|
[2669] | 24 | #include <casa/Utilities/CountedPtr.h>
|
---|
[2356] | 25 |
|
---|
| 26 | #include <tables/Tables/Table.h>
|
---|
[2379] | 27 | #include <tables/Tables/ScalarColumn.h>
|
---|
| 28 | #include <tables/Tables/ArrayColumn.h>
|
---|
[2393] | 29 |
|
---|
[2669] | 30 | #include <coordinates/Coordinates/DirectionCoordinate.h>
|
---|
| 31 |
|
---|
[2593] | 32 | #include "ScantableWrapper.h"
|
---|
| 33 | #include "Scantable.h"
|
---|
[2393] | 34 | #include "concurrent.h"
|
---|
[2356] | 35 |
|
---|
| 36 | using namespace std ;
|
---|
| 37 | using namespace casa ;
|
---|
| 38 |
|
---|
| 39 | namespace asap {
|
---|
| 40 | class STGrid
|
---|
| 41 | {
|
---|
| 42 | public:
|
---|
| 43 | STGrid() ;
|
---|
| 44 | STGrid( const string infile ) ;
|
---|
[2390] | 45 | STGrid( const vector<string> infile ) ;
|
---|
[2356] | 46 | virtual ~STGrid() {} ;
|
---|
| 47 |
|
---|
| 48 | void setFileIn( const string infile ) ;
|
---|
[2390] | 49 | void setFileList( const vector<string> infile ) ;
|
---|
[2356] | 50 |
|
---|
[2362] | 51 | void setIF( unsigned int ifno ) { ifno_ = ifno ; } ;
|
---|
| 52 |
|
---|
[2360] | 53 | void setPolList( vector<unsigned int> pols ) ;
|
---|
| 54 |
|
---|
[2364] | 55 | void setScanList( vector<unsigned int> scans ) ;
|
---|
| 56 |
|
---|
[2356] | 57 | void defineImage( int nx=-1,
|
---|
| 58 | int ny=-1,
|
---|
| 59 | string scellx="",
|
---|
| 60 | string scelly="",
|
---|
| 61 | string scenter="" ) ;
|
---|
[2364] | 62 | void setFunc( string convtype="box",
|
---|
[2671] | 63 | int convsupport=-1,
|
---|
| 64 | string truncate="",
|
---|
| 65 | string gwidth="",
|
---|
| 66 | string jwidth="" ) ;
|
---|
[2361] | 67 |
|
---|
| 68 | void setWeight( const string wType="uniform" ) ;
|
---|
| 69 |
|
---|
[2396] | 70 | void enableClip() { doclip_ = True ; } ;
|
---|
| 71 | void disableClip() { doclip_ = False ; } ;
|
---|
| 72 |
|
---|
[2356] | 73 | void grid() ;
|
---|
| 74 |
|
---|
| 75 | string saveData( string outfile="" ) ;
|
---|
| 76 |
|
---|
[2671] | 77 | // support function to know how grid function looks like
|
---|
| 78 | vector<float> getConvFunc();
|
---|
| 79 |
|
---|
[2593] | 80 | //private:
|
---|
| 81 | protected:
|
---|
[2356] | 82 | void init() ;
|
---|
| 83 |
|
---|
[2382] | 84 | // actual gridding
|
---|
| 85 | void gridPerRow() ;
|
---|
[2396] | 86 | void gridPerRowWithClipping() ;
|
---|
[2382] | 87 |
|
---|
[2396] | 88 | // clipping
|
---|
| 89 | void clipMinMax( Array<Complex> &data,
|
---|
| 90 | Array<Float> &weight,
|
---|
| 91 | Array<Int> &npoints,
|
---|
| 92 | Array<Complex> &clipmin,
|
---|
| 93 | Array<Float> &clipwmin,
|
---|
| 94 | Array<Float> &clipcmin,
|
---|
| 95 | Array<Complex> &clipmax,
|
---|
| 96 | Array<Float> &clipwmax,
|
---|
| 97 | Array<Float> &clipcmax ) ;
|
---|
| 98 |
|
---|
| 99 |
|
---|
[2388] | 100 | void setupGrid() ;
|
---|
[2356] | 101 | void setupGrid( Int &nx,
|
---|
| 102 | Int &ny,
|
---|
| 103 | String &cellx,
|
---|
| 104 | String &celly,
|
---|
| 105 | Double &xmin,
|
---|
| 106 | Double &xmax,
|
---|
| 107 | Double &ymin,
|
---|
| 108 | Double &ymax,
|
---|
| 109 | String ¢er ) ;
|
---|
[2388] | 110 | void mapExtent( Double &xmin, Double &xmax,
|
---|
| 111 | Double &ymin, Double &ymax ) ;
|
---|
[2368] | 112 |
|
---|
[2378] | 113 | void setData( Array<Complex> &gdata,
|
---|
[2368] | 114 | Array<Float> &gwgt ) ;
|
---|
[2356] | 115 |
|
---|
[2393] | 116 | Int getDataChunk( IPosition const &wshape,
|
---|
| 117 | IPosition const &vshape,
|
---|
| 118 | IPosition const &dshape,
|
---|
| 119 | Array<Complex> &spectra,
|
---|
| 120 | Array<Double> &direction,
|
---|
| 121 | Array<Int> &flagtra,
|
---|
| 122 | Array<Int> &rflag,
|
---|
| 123 | Array<Float> &weight ) ;
|
---|
[2379] | 124 | Int getDataChunk( Array<Complex> &spectra,
|
---|
| 125 | Array<Double> &direction,
|
---|
| 126 | Array<Int> &flagtra,
|
---|
| 127 | Array<Int> &rflag,
|
---|
| 128 | Array<Float> &weight ) ;
|
---|
| 129 | Int getDataChunk( Array<Float> &spectra,
|
---|
| 130 | Array<Double> &direction,
|
---|
| 131 | Array<uChar> &flagtra,
|
---|
| 132 | Array<uInt> &rflag,
|
---|
| 133 | Array<Float> &weight ) ;
|
---|
[2356] | 134 |
|
---|
[2375] | 135 | void getWeight( Array<Float> &w,
|
---|
| 136 | Array<Float> &tsys,
|
---|
| 137 | Array<Double> &tint ) ;
|
---|
[2382] | 138 |
|
---|
[2375] | 139 | void toInt( Array<uChar> &u, Array<Int> &v ) ;
|
---|
| 140 | void toInt( Array<uInt> &u, Array<Int> &v ) ;
|
---|
[2356] | 141 |
|
---|
[2375] | 142 | void toPixel( Array<Double> &world, Array<Double> &pixel ) ;
|
---|
[2356] | 143 |
|
---|
| 144 | void boxFunc( Vector<Float> &convFunc, Int &convSize ) ;
|
---|
| 145 | void spheroidalFunc( Vector<Float> &convFunc ) ;
|
---|
[2671] | 146 | void gaussFunc( Vector<Float> &convFunc, Double hwhm, Double truncate ) ;
|
---|
| 147 | void gjincFunc( Vector<Float> &convFunc, Double hwhm, Double c, Double truncate );
|
---|
[2356] | 148 | void pbFunc( Vector<Float> &convFunc ) ;
|
---|
| 149 | void setConvFunc( Vector<Float> &convFunc ) ;
|
---|
| 150 |
|
---|
[2371] | 151 | void prepareTable( Table &tab, String &name ) ;
|
---|
| 152 |
|
---|
[2379] | 153 | void selectData() ;
|
---|
| 154 | void setupArray() ;
|
---|
[2378] | 155 |
|
---|
[2398] | 156 | void updateChunkShape() ;
|
---|
[2382] | 157 | void attach( Table &tab ) ;
|
---|
[2379] | 158 |
|
---|
[2384] | 159 | void call_ggridsd( Array<Double> &xy,
|
---|
| 160 | Array<Complex> &values,
|
---|
| 161 | Int &nvispol,
|
---|
| 162 | Int &nvischan,
|
---|
| 163 | Array<Int> &flag,
|
---|
| 164 | Array<Int> &rflag,
|
---|
| 165 | Array<Float> &weight,
|
---|
| 166 | Int &nrow,
|
---|
| 167 | Int &irow,
|
---|
| 168 | Array<Complex> &grid,
|
---|
| 169 | Array<Float> &wgrid,
|
---|
| 170 | Int &nx,
|
---|
| 171 | Int &ny,
|
---|
| 172 | Int &npol,
|
---|
| 173 | Int &nchan,
|
---|
| 174 | Int &support,
|
---|
| 175 | Int &sampling,
|
---|
| 176 | Vector<Float> &convFunc,
|
---|
[2381] | 177 | Int *chanMap,
|
---|
| 178 | Int *polMap ) ;
|
---|
[2396] | 179 | void call_ggridsd2( Array<Double> &xy,
|
---|
| 180 | Array<Complex> &values,
|
---|
| 181 | Int &nvispol,
|
---|
| 182 | Int &nvischan,
|
---|
| 183 | Array<Int> &flag,
|
---|
| 184 | Array<Int> &rflag,
|
---|
| 185 | Array<Float> &weight,
|
---|
| 186 | Int &nrow,
|
---|
| 187 | Int &irow,
|
---|
| 188 | Array<Complex> &grid,
|
---|
| 189 | Array<Float> &wgrid,
|
---|
| 190 | Array<Int> &npoints,
|
---|
| 191 | Array<Complex> &clipmin,
|
---|
| 192 | Array<Float> &clipwmin,
|
---|
| 193 | Array<Float> &clipcmin,
|
---|
| 194 | Array<Complex> &clipmax,
|
---|
| 195 | Array<Float> &clipwmax,
|
---|
| 196 | Array<Float> &clipcmax,
|
---|
| 197 | Int &nx,
|
---|
| 198 | Int &ny,
|
---|
| 199 | Int &npol,
|
---|
| 200 | Int &nchan,
|
---|
| 201 | Int &support,
|
---|
| 202 | Int &sampling,
|
---|
| 203 | Vector<Float> &convFunc,
|
---|
| 204 | Int *chanMap,
|
---|
| 205 | Int *polMap ) ;
|
---|
[2379] | 206 |
|
---|
[2382] | 207 | void initPol( Int ipol ) ;
|
---|
[2390] | 208 | void initTable( uInt idx ) ;
|
---|
[2386] | 209 | Bool isMultiIF( Table &tab ) ;
|
---|
[2413] | 210 | void fillMainColumns( Table &tab ) ;
|
---|
[2593] | 211 | void fillTable( Table &tab ) ;
|
---|
| 212 | virtual void table( Table &tab, uInt i ) ;
|
---|
[2393] | 213 | static bool produceChunk(void *ctx) throw(concurrent::PCException);
|
---|
| 214 | static void consumeChunk(void *ctx) throw(concurrent::PCException);
|
---|
[2396] | 215 | static void consumeChunkWithClipping(void *ctx) throw(concurrent::PCException);
|
---|
[2381] | 216 |
|
---|
[2382] | 217 |
|
---|
[2388] | 218 | // user input
|
---|
| 219 | Int nxUI_ ;
|
---|
| 220 | Int nyUI_ ;
|
---|
| 221 | String cellxUI_ ;
|
---|
| 222 | String cellyUI_ ;
|
---|
| 223 | String centerUI_ ;
|
---|
| 224 |
|
---|
[2389] | 225 | Block<String> infileList_ ;
|
---|
[2390] | 226 | uInt nfile_ ;
|
---|
[2362] | 227 | Int ifno_ ;
|
---|
[2396] | 228 | Bool doclip_ ;
|
---|
[2393] | 229 |
|
---|
[2356] | 230 | Int nx_ ;
|
---|
| 231 | Int ny_ ;
|
---|
[2361] | 232 | Int npol_ ;
|
---|
[2386] | 233 | Int npolOrg_ ;
|
---|
[2361] | 234 | Int nchan_ ;
|
---|
[2356] | 235 | Double cellx_ ;
|
---|
| 236 | Double celly_ ;
|
---|
| 237 | Vector<Double> center_ ;
|
---|
| 238 | String convType_ ;
|
---|
| 239 | Int convSupport_ ;
|
---|
| 240 | Int userSupport_ ;
|
---|
[2671] | 241 | String gwidth_;
|
---|
| 242 | String jwidth_;
|
---|
| 243 | String truncate_;
|
---|
[2356] | 244 | Int convSampling_ ;
|
---|
[2360] | 245 | Vector<uInt> pollist_ ;
|
---|
[2364] | 246 | Vector<uInt> scanlist_ ;
|
---|
[2361] | 247 | String wtype_ ;
|
---|
[2393] | 248 | Block<Table> tableList_ ;
|
---|
| 249 | Vector<uInt> rows_ ;
|
---|
| 250 | Int nchunk_ ;
|
---|
[2669] | 251 | CountedPtr<DirectionCoordinate> dircoord_;
|
---|
[2356] | 252 |
|
---|
[2393] | 253 | /////////////// gridPerRow variable
|
---|
| 254 | IPosition vshape_;
|
---|
| 255 | IPosition wshape_;
|
---|
| 256 | IPosition dshape_;
|
---|
| 257 | // loop variable
|
---|
| 258 | Int nrow_ ;
|
---|
| 259 | Array<Float> data_ ;
|
---|
| 260 |
|
---|
[2356] | 261 | Table tab_ ;
|
---|
[2393] | 262 | // per pol
|
---|
[2382] | 263 | Table ptab_ ;
|
---|
[2379] | 264 | ROArrayColumn<Float> spectraCol_ ;
|
---|
| 265 | ROArrayColumn<uChar> flagtraCol_ ;
|
---|
| 266 | ROArrayColumn<Double> directionCol_ ;
|
---|
| 267 | ROScalarColumn<uInt> flagRowCol_ ;
|
---|
| 268 | ROArrayColumn<Float> tsysCol_ ;
|
---|
| 269 | ROScalarColumn<Double> intervalCol_ ;
|
---|
[2393] | 270 |
|
---|
[2379] | 271 | Int nprocessed_ ;
|
---|
[2381] | 272 |
|
---|
| 273 |
|
---|
[2393] | 274 | double eGetData_;
|
---|
| 275 | double eToPixel_;
|
---|
| 276 | double eGGridSD_;
|
---|
[2356] | 277 | };
|
---|
[2593] | 278 |
|
---|
| 279 | class STGrid2 : public STGrid
|
---|
| 280 | {
|
---|
| 281 | public:
|
---|
| 282 | STGrid2() ;
|
---|
| 283 | STGrid2( const ScantableWrapper &s ) ;
|
---|
| 284 | STGrid2( const vector<ScantableWrapper> &v ) ;
|
---|
| 285 | void setScantable( const ScantableWrapper &s ) ;
|
---|
| 286 | void setScantableList( const vector<ScantableWrapper> &v ) ;
|
---|
| 287 | void selectData() ;
|
---|
| 288 | virtual void table( Table &tab, uInt i ) ;
|
---|
[2594] | 289 | ScantableWrapper getResultAsScantable( int tp ) ;
|
---|
[2593] | 290 |
|
---|
| 291 | private:
|
---|
| 292 | Block<ScantableWrapper> dataList_ ;
|
---|
| 293 | };
|
---|
[2356] | 294 | }
|
---|
| 295 | #endif
|
---|