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