[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>
|
---|
[2356] | 24 |
|
---|
| 25 | #include <tables/Tables/Table.h>
|
---|
[2379] | 26 | #include <tables/Tables/ScalarColumn.h>
|
---|
| 27 | #include <tables/Tables/ArrayColumn.h>
|
---|
[2393] | 28 |
|
---|
| 29 | #include "concurrent.h"
|
---|
[2356] | 30 |
|
---|
| 31 | using namespace std ;
|
---|
| 32 | using namespace casa ;
|
---|
| 33 |
|
---|
| 34 | namespace asap {
|
---|
| 35 | class STGrid
|
---|
| 36 | {
|
---|
| 37 | public:
|
---|
| 38 | STGrid() ;
|
---|
| 39 | STGrid( const string infile ) ;
|
---|
[2390] | 40 | STGrid( const vector<string> infile ) ;
|
---|
[2356] | 41 | virtual ~STGrid() {} ;
|
---|
| 42 |
|
---|
| 43 | void setFileIn( const string infile ) ;
|
---|
[2390] | 44 | void setFileList( const vector<string> infile ) ;
|
---|
[2356] | 45 |
|
---|
[2362] | 46 | void setIF( unsigned int ifno ) { ifno_ = ifno ; } ;
|
---|
| 47 |
|
---|
[2360] | 48 | void setPolList( vector<unsigned int> pols ) ;
|
---|
| 49 |
|
---|
[2364] | 50 | void setScanList( vector<unsigned int> scans ) ;
|
---|
| 51 |
|
---|
[2356] | 52 | void defineImage( int nx=-1,
|
---|
| 53 | int ny=-1,
|
---|
| 54 | string scellx="",
|
---|
| 55 | string scelly="",
|
---|
| 56 | string scenter="" ) ;
|
---|
[2364] | 57 | void setFunc( string convtype="box",
|
---|
| 58 | int convsupport=-1 ) ;
|
---|
[2361] | 59 |
|
---|
| 60 | void setWeight( const string wType="uniform" ) ;
|
---|
| 61 |
|
---|
[2396] | 62 | void enableClip() { doclip_ = True ; } ;
|
---|
| 63 | void disableClip() { doclip_ = False ; } ;
|
---|
| 64 |
|
---|
[2356] | 65 | void grid() ;
|
---|
| 66 |
|
---|
| 67 | string saveData( string outfile="" ) ;
|
---|
| 68 |
|
---|
| 69 | private:
|
---|
| 70 | void init() ;
|
---|
| 71 |
|
---|
[2382] | 72 | // actual gridding
|
---|
| 73 | void gridPerRow() ;
|
---|
[2396] | 74 | void gridPerRowWithClipping() ;
|
---|
[2382] | 75 |
|
---|
[2396] | 76 | // clipping
|
---|
| 77 | void clipMinMax( Array<Complex> &data,
|
---|
| 78 | Array<Float> &weight,
|
---|
| 79 | Array<Int> &npoints,
|
---|
| 80 | Array<Complex> &clipmin,
|
---|
| 81 | Array<Float> &clipwmin,
|
---|
| 82 | Array<Float> &clipcmin,
|
---|
| 83 | Array<Complex> &clipmax,
|
---|
| 84 | Array<Float> &clipwmax,
|
---|
| 85 | Array<Float> &clipcmax ) ;
|
---|
| 86 |
|
---|
| 87 |
|
---|
[2388] | 88 | void setupGrid() ;
|
---|
[2356] | 89 | void setupGrid( Int &nx,
|
---|
| 90 | Int &ny,
|
---|
| 91 | String &cellx,
|
---|
| 92 | String &celly,
|
---|
| 93 | Double &xmin,
|
---|
| 94 | Double &xmax,
|
---|
| 95 | Double &ymin,
|
---|
| 96 | Double &ymax,
|
---|
| 97 | String ¢er ) ;
|
---|
[2388] | 98 | void mapExtent( Double &xmin, Double &xmax,
|
---|
| 99 | Double &ymin, Double &ymax ) ;
|
---|
[2368] | 100 |
|
---|
[2378] | 101 | void setData( Array<Complex> &gdata,
|
---|
[2368] | 102 | Array<Float> &gwgt ) ;
|
---|
[2356] | 103 |
|
---|
[2393] | 104 | Int getDataChunk( IPosition const &wshape,
|
---|
| 105 | IPosition const &vshape,
|
---|
| 106 | IPosition const &dshape,
|
---|
| 107 | Array<Complex> &spectra,
|
---|
| 108 | Array<Double> &direction,
|
---|
| 109 | Array<Int> &flagtra,
|
---|
| 110 | Array<Int> &rflag,
|
---|
| 111 | Array<Float> &weight ) ;
|
---|
[2379] | 112 | Int getDataChunk( Array<Complex> &spectra,
|
---|
| 113 | Array<Double> &direction,
|
---|
| 114 | Array<Int> &flagtra,
|
---|
| 115 | Array<Int> &rflag,
|
---|
| 116 | Array<Float> &weight ) ;
|
---|
| 117 | Int getDataChunk( Array<Float> &spectra,
|
---|
| 118 | Array<Double> &direction,
|
---|
| 119 | Array<uChar> &flagtra,
|
---|
| 120 | Array<uInt> &rflag,
|
---|
| 121 | Array<Float> &weight ) ;
|
---|
[2356] | 122 |
|
---|
[2375] | 123 | void getWeight( Array<Float> &w,
|
---|
| 124 | Array<Float> &tsys,
|
---|
| 125 | Array<Double> &tint ) ;
|
---|
[2382] | 126 |
|
---|
[2375] | 127 | void toInt( Array<uChar> &u, Array<Int> &v ) ;
|
---|
| 128 | void toInt( Array<uInt> &u, Array<Int> &v ) ;
|
---|
[2356] | 129 |
|
---|
[2375] | 130 | void toPixel( Array<Double> &world, Array<Double> &pixel ) ;
|
---|
[2356] | 131 |
|
---|
| 132 | void boxFunc( Vector<Float> &convFunc, Int &convSize ) ;
|
---|
| 133 | void spheroidalFunc( Vector<Float> &convFunc ) ;
|
---|
| 134 | void gaussFunc( Vector<Float> &convFunc ) ;
|
---|
| 135 | void pbFunc( Vector<Float> &convFunc ) ;
|
---|
| 136 | void setConvFunc( Vector<Float> &convFunc ) ;
|
---|
| 137 |
|
---|
[2371] | 138 | void prepareTable( Table &tab, String &name ) ;
|
---|
| 139 |
|
---|
[2379] | 140 | void selectData() ;
|
---|
| 141 | void setupArray() ;
|
---|
[2378] | 142 |
|
---|
[2398] | 143 | void updateChunkShape() ;
|
---|
[2382] | 144 | void attach( Table &tab ) ;
|
---|
[2379] | 145 |
|
---|
[2384] | 146 | void call_ggridsd( Array<Double> &xy,
|
---|
| 147 | Array<Complex> &values,
|
---|
| 148 | Int &nvispol,
|
---|
| 149 | Int &nvischan,
|
---|
| 150 | Array<Int> &flag,
|
---|
| 151 | Array<Int> &rflag,
|
---|
| 152 | Array<Float> &weight,
|
---|
| 153 | Int &nrow,
|
---|
| 154 | Int &irow,
|
---|
| 155 | Array<Complex> &grid,
|
---|
| 156 | Array<Float> &wgrid,
|
---|
| 157 | Int &nx,
|
---|
| 158 | Int &ny,
|
---|
| 159 | Int &npol,
|
---|
| 160 | Int &nchan,
|
---|
| 161 | Int &support,
|
---|
| 162 | Int &sampling,
|
---|
| 163 | Vector<Float> &convFunc,
|
---|
[2381] | 164 | Int *chanMap,
|
---|
| 165 | Int *polMap ) ;
|
---|
[2396] | 166 | void call_ggridsd2( Array<Double> &xy,
|
---|
| 167 | Array<Complex> &values,
|
---|
| 168 | Int &nvispol,
|
---|
| 169 | Int &nvischan,
|
---|
| 170 | Array<Int> &flag,
|
---|
| 171 | Array<Int> &rflag,
|
---|
| 172 | Array<Float> &weight,
|
---|
| 173 | Int &nrow,
|
---|
| 174 | Int &irow,
|
---|
| 175 | Array<Complex> &grid,
|
---|
| 176 | Array<Float> &wgrid,
|
---|
| 177 | Array<Int> &npoints,
|
---|
| 178 | Array<Complex> &clipmin,
|
---|
| 179 | Array<Float> &clipwmin,
|
---|
| 180 | Array<Float> &clipcmin,
|
---|
| 181 | Array<Complex> &clipmax,
|
---|
| 182 | Array<Float> &clipwmax,
|
---|
| 183 | Array<Float> &clipcmax,
|
---|
| 184 | Int &nx,
|
---|
| 185 | Int &ny,
|
---|
| 186 | Int &npol,
|
---|
| 187 | Int &nchan,
|
---|
| 188 | Int &support,
|
---|
| 189 | Int &sampling,
|
---|
| 190 | Vector<Float> &convFunc,
|
---|
| 191 | Int *chanMap,
|
---|
| 192 | Int *polMap ) ;
|
---|
[2379] | 193 |
|
---|
[2382] | 194 | void initPol( Int ipol ) ;
|
---|
[2390] | 195 | void initTable( uInt idx ) ;
|
---|
[2386] | 196 | Bool isMultiIF( Table &tab ) ;
|
---|
[2393] | 197 | static bool produceChunk(void *ctx) throw(concurrent::PCException);
|
---|
| 198 | static void consumeChunk(void *ctx) throw(concurrent::PCException);
|
---|
[2396] | 199 | static void consumeChunkWithClipping(void *ctx) throw(concurrent::PCException);
|
---|
[2381] | 200 |
|
---|
[2382] | 201 |
|
---|
[2388] | 202 | // user input
|
---|
| 203 | Int nxUI_ ;
|
---|
| 204 | Int nyUI_ ;
|
---|
| 205 | String cellxUI_ ;
|
---|
| 206 | String cellyUI_ ;
|
---|
| 207 | String centerUI_ ;
|
---|
| 208 |
|
---|
[2389] | 209 | Block<String> infileList_ ;
|
---|
[2390] | 210 | uInt nfile_ ;
|
---|
[2362] | 211 | Int ifno_ ;
|
---|
[2396] | 212 | Bool doclip_ ;
|
---|
[2393] | 213 |
|
---|
[2356] | 214 | Int nx_ ;
|
---|
| 215 | Int ny_ ;
|
---|
[2361] | 216 | Int npol_ ;
|
---|
[2386] | 217 | Int npolOrg_ ;
|
---|
[2361] | 218 | Int nchan_ ;
|
---|
[2356] | 219 | Double cellx_ ;
|
---|
| 220 | Double celly_ ;
|
---|
| 221 | Vector<Double> center_ ;
|
---|
| 222 | String convType_ ;
|
---|
| 223 | Int convSupport_ ;
|
---|
| 224 | Int userSupport_ ;
|
---|
| 225 | Int convSampling_ ;
|
---|
[2360] | 226 | Vector<uInt> pollist_ ;
|
---|
[2364] | 227 | Vector<uInt> scanlist_ ;
|
---|
[2361] | 228 | String wtype_ ;
|
---|
[2393] | 229 | Block<Table> tableList_ ;
|
---|
| 230 | Vector<uInt> rows_ ;
|
---|
| 231 | Int nchunk_ ;
|
---|
[2356] | 232 |
|
---|
[2393] | 233 | /////////////// gridPerRow variable
|
---|
| 234 | IPosition vshape_;
|
---|
| 235 | IPosition wshape_;
|
---|
| 236 | IPosition dshape_;
|
---|
| 237 | // loop variable
|
---|
| 238 | Int nrow_ ;
|
---|
| 239 | Array<Float> data_ ;
|
---|
| 240 |
|
---|
[2356] | 241 | Table tab_ ;
|
---|
[2393] | 242 | // per pol
|
---|
[2382] | 243 | Table ptab_ ;
|
---|
[2379] | 244 | ROArrayColumn<Float> spectraCol_ ;
|
---|
| 245 | ROArrayColumn<uChar> flagtraCol_ ;
|
---|
| 246 | ROArrayColumn<Double> directionCol_ ;
|
---|
| 247 | ROScalarColumn<uInt> flagRowCol_ ;
|
---|
| 248 | ROArrayColumn<Float> tsysCol_ ;
|
---|
| 249 | ROScalarColumn<Double> intervalCol_ ;
|
---|
[2393] | 250 |
|
---|
[2379] | 251 | Int nprocessed_ ;
|
---|
[2381] | 252 |
|
---|
| 253 |
|
---|
[2393] | 254 | double eGetData_;
|
---|
| 255 | double eToPixel_;
|
---|
| 256 | double eGGridSD_;
|
---|
[2356] | 257 | };
|
---|
| 258 | }
|
---|
| 259 | #endif
|
---|