[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", |
---|
| 63 | int convsupport=-1 ) ; |
---|
[2361] | 64 | |
---|
| 65 | void setWeight( const string wType="uniform" ) ; |
---|
| 66 | |
---|
[2396] | 67 | void enableClip() { doclip_ = True ; } ; |
---|
| 68 | void disableClip() { doclip_ = False ; } ; |
---|
| 69 | |
---|
[2356] | 70 | void grid() ; |
---|
| 71 | |
---|
| 72 | string saveData( string outfile="" ) ; |
---|
| 73 | |
---|
[2593] | 74 | //private: |
---|
| 75 | protected: |
---|
[2356] | 76 | void init() ; |
---|
| 77 | |
---|
[2382] | 78 | // actual gridding |
---|
| 79 | void gridPerRow() ; |
---|
[2396] | 80 | void gridPerRowWithClipping() ; |
---|
[2382] | 81 | |
---|
[2396] | 82 | // clipping |
---|
| 83 | void clipMinMax( Array<Complex> &data, |
---|
| 84 | Array<Float> &weight, |
---|
| 85 | Array<Int> &npoints, |
---|
| 86 | Array<Complex> &clipmin, |
---|
| 87 | Array<Float> &clipwmin, |
---|
| 88 | Array<Float> &clipcmin, |
---|
| 89 | Array<Complex> &clipmax, |
---|
| 90 | Array<Float> &clipwmax, |
---|
| 91 | Array<Float> &clipcmax ) ; |
---|
| 92 | |
---|
| 93 | |
---|
[2388] | 94 | void setupGrid() ; |
---|
[2356] | 95 | void setupGrid( Int &nx, |
---|
| 96 | Int &ny, |
---|
| 97 | String &cellx, |
---|
| 98 | String &celly, |
---|
| 99 | Double &xmin, |
---|
| 100 | Double &xmax, |
---|
| 101 | Double &ymin, |
---|
| 102 | Double &ymax, |
---|
| 103 | String ¢er ) ; |
---|
[2388] | 104 | void mapExtent( Double &xmin, Double &xmax, |
---|
| 105 | Double &ymin, Double &ymax ) ; |
---|
[2368] | 106 | |
---|
[2378] | 107 | void setData( Array<Complex> &gdata, |
---|
[2368] | 108 | Array<Float> &gwgt ) ; |
---|
[2356] | 109 | |
---|
[2393] | 110 | Int getDataChunk( IPosition const &wshape, |
---|
| 111 | IPosition const &vshape, |
---|
| 112 | IPosition const &dshape, |
---|
| 113 | Array<Complex> &spectra, |
---|
| 114 | Array<Double> &direction, |
---|
| 115 | Array<Int> &flagtra, |
---|
| 116 | Array<Int> &rflag, |
---|
| 117 | Array<Float> &weight ) ; |
---|
[2379] | 118 | Int getDataChunk( Array<Complex> &spectra, |
---|
| 119 | Array<Double> &direction, |
---|
| 120 | Array<Int> &flagtra, |
---|
| 121 | Array<Int> &rflag, |
---|
| 122 | Array<Float> &weight ) ; |
---|
| 123 | Int getDataChunk( Array<Float> &spectra, |
---|
| 124 | Array<Double> &direction, |
---|
| 125 | Array<uChar> &flagtra, |
---|
| 126 | Array<uInt> &rflag, |
---|
| 127 | Array<Float> &weight ) ; |
---|
[2356] | 128 | |
---|
[2375] | 129 | void getWeight( Array<Float> &w, |
---|
| 130 | Array<Float> &tsys, |
---|
| 131 | Array<Double> &tint ) ; |
---|
[2382] | 132 | |
---|
[2375] | 133 | void toInt( Array<uChar> &u, Array<Int> &v ) ; |
---|
| 134 | void toInt( Array<uInt> &u, Array<Int> &v ) ; |
---|
[2356] | 135 | |
---|
[2375] | 136 | void toPixel( Array<Double> &world, Array<Double> &pixel ) ; |
---|
[2356] | 137 | |
---|
| 138 | void boxFunc( Vector<Float> &convFunc, Int &convSize ) ; |
---|
| 139 | void spheroidalFunc( Vector<Float> &convFunc ) ; |
---|
| 140 | void gaussFunc( Vector<Float> &convFunc ) ; |
---|
| 141 | void pbFunc( Vector<Float> &convFunc ) ; |
---|
| 142 | void setConvFunc( Vector<Float> &convFunc ) ; |
---|
| 143 | |
---|
[2371] | 144 | void prepareTable( Table &tab, String &name ) ; |
---|
| 145 | |
---|
[2379] | 146 | void selectData() ; |
---|
| 147 | void setupArray() ; |
---|
[2378] | 148 | |
---|
[2398] | 149 | void updateChunkShape() ; |
---|
[2382] | 150 | void attach( Table &tab ) ; |
---|
[2379] | 151 | |
---|
[2384] | 152 | void call_ggridsd( Array<Double> &xy, |
---|
| 153 | Array<Complex> &values, |
---|
| 154 | Int &nvispol, |
---|
| 155 | Int &nvischan, |
---|
| 156 | Array<Int> &flag, |
---|
| 157 | Array<Int> &rflag, |
---|
| 158 | Array<Float> &weight, |
---|
| 159 | Int &nrow, |
---|
| 160 | Int &irow, |
---|
| 161 | Array<Complex> &grid, |
---|
| 162 | Array<Float> &wgrid, |
---|
| 163 | Int &nx, |
---|
| 164 | Int &ny, |
---|
| 165 | Int &npol, |
---|
| 166 | Int &nchan, |
---|
| 167 | Int &support, |
---|
| 168 | Int &sampling, |
---|
| 169 | Vector<Float> &convFunc, |
---|
[2381] | 170 | Int *chanMap, |
---|
| 171 | Int *polMap ) ; |
---|
[2396] | 172 | void call_ggridsd2( Array<Double> &xy, |
---|
| 173 | Array<Complex> &values, |
---|
| 174 | Int &nvispol, |
---|
| 175 | Int &nvischan, |
---|
| 176 | Array<Int> &flag, |
---|
| 177 | Array<Int> &rflag, |
---|
| 178 | Array<Float> &weight, |
---|
| 179 | Int &nrow, |
---|
| 180 | Int &irow, |
---|
| 181 | Array<Complex> &grid, |
---|
| 182 | Array<Float> &wgrid, |
---|
| 183 | Array<Int> &npoints, |
---|
| 184 | Array<Complex> &clipmin, |
---|
| 185 | Array<Float> &clipwmin, |
---|
| 186 | Array<Float> &clipcmin, |
---|
| 187 | Array<Complex> &clipmax, |
---|
| 188 | Array<Float> &clipwmax, |
---|
| 189 | Array<Float> &clipcmax, |
---|
| 190 | Int &nx, |
---|
| 191 | Int &ny, |
---|
| 192 | Int &npol, |
---|
| 193 | Int &nchan, |
---|
| 194 | Int &support, |
---|
| 195 | Int &sampling, |
---|
| 196 | Vector<Float> &convFunc, |
---|
| 197 | Int *chanMap, |
---|
| 198 | Int *polMap ) ; |
---|
[2379] | 199 | |
---|
[2382] | 200 | void initPol( Int ipol ) ; |
---|
[2390] | 201 | void initTable( uInt idx ) ; |
---|
[2386] | 202 | Bool isMultiIF( Table &tab ) ; |
---|
[2413] | 203 | void fillMainColumns( Table &tab ) ; |
---|
[2593] | 204 | void fillTable( Table &tab ) ; |
---|
| 205 | virtual void table( Table &tab, uInt i ) ; |
---|
[2393] | 206 | static bool produceChunk(void *ctx) throw(concurrent::PCException); |
---|
| 207 | static void consumeChunk(void *ctx) throw(concurrent::PCException); |
---|
[2396] | 208 | static void consumeChunkWithClipping(void *ctx) throw(concurrent::PCException); |
---|
[2381] | 209 | |
---|
[2382] | 210 | |
---|
[2388] | 211 | // user input |
---|
| 212 | Int nxUI_ ; |
---|
| 213 | Int nyUI_ ; |
---|
| 214 | String cellxUI_ ; |
---|
| 215 | String cellyUI_ ; |
---|
| 216 | String centerUI_ ; |
---|
| 217 | |
---|
[2389] | 218 | Block<String> infileList_ ; |
---|
[2390] | 219 | uInt nfile_ ; |
---|
[2362] | 220 | Int ifno_ ; |
---|
[2396] | 221 | Bool doclip_ ; |
---|
[2393] | 222 | |
---|
[2356] | 223 | Int nx_ ; |
---|
| 224 | Int ny_ ; |
---|
[2361] | 225 | Int npol_ ; |
---|
[2386] | 226 | Int npolOrg_ ; |
---|
[2361] | 227 | Int nchan_ ; |
---|
[2356] | 228 | Double cellx_ ; |
---|
| 229 | Double celly_ ; |
---|
| 230 | Vector<Double> center_ ; |
---|
| 231 | String convType_ ; |
---|
| 232 | Int convSupport_ ; |
---|
| 233 | Int userSupport_ ; |
---|
| 234 | Int convSampling_ ; |
---|
[2360] | 235 | Vector<uInt> pollist_ ; |
---|
[2364] | 236 | Vector<uInt> scanlist_ ; |
---|
[2361] | 237 | String wtype_ ; |
---|
[2393] | 238 | Block<Table> tableList_ ; |
---|
| 239 | Vector<uInt> rows_ ; |
---|
| 240 | Int nchunk_ ; |
---|
[2669] | 241 | CountedPtr<DirectionCoordinate> dircoord_; |
---|
[2356] | 242 | |
---|
[2393] | 243 | /////////////// gridPerRow variable |
---|
| 244 | IPosition vshape_; |
---|
| 245 | IPosition wshape_; |
---|
| 246 | IPosition dshape_; |
---|
| 247 | // loop variable |
---|
| 248 | Int nrow_ ; |
---|
| 249 | Array<Float> data_ ; |
---|
| 250 | |
---|
[2356] | 251 | Table tab_ ; |
---|
[2393] | 252 | // per pol |
---|
[2382] | 253 | Table ptab_ ; |
---|
[2379] | 254 | ROArrayColumn<Float> spectraCol_ ; |
---|
| 255 | ROArrayColumn<uChar> flagtraCol_ ; |
---|
| 256 | ROArrayColumn<Double> directionCol_ ; |
---|
| 257 | ROScalarColumn<uInt> flagRowCol_ ; |
---|
| 258 | ROArrayColumn<Float> tsysCol_ ; |
---|
| 259 | ROScalarColumn<Double> intervalCol_ ; |
---|
[2393] | 260 | |
---|
[2379] | 261 | Int nprocessed_ ; |
---|
[2381] | 262 | |
---|
| 263 | |
---|
[2393] | 264 | double eGetData_; |
---|
| 265 | double eToPixel_; |
---|
| 266 | double eGGridSD_; |
---|
[2356] | 267 | }; |
---|
[2593] | 268 | |
---|
| 269 | class STGrid2 : public STGrid |
---|
| 270 | { |
---|
| 271 | public: |
---|
| 272 | STGrid2() ; |
---|
| 273 | STGrid2( const ScantableWrapper &s ) ; |
---|
| 274 | STGrid2( const vector<ScantableWrapper> &v ) ; |
---|
| 275 | void setScantable( const ScantableWrapper &s ) ; |
---|
| 276 | void setScantableList( const vector<ScantableWrapper> &v ) ; |
---|
| 277 | void selectData() ; |
---|
| 278 | virtual void table( Table &tab, uInt i ) ; |
---|
[2594] | 279 | ScantableWrapper getResultAsScantable( int tp ) ; |
---|
[2593] | 280 | |
---|
| 281 | private: |
---|
| 282 | Block<ScantableWrapper> dataList_ ; |
---|
| 283 | }; |
---|
[2356] | 284 | } |
---|
| 285 | #endif |
---|