[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>
|
---|
[2381] | 28 | //#include <tables/Tables/TableRow.h>
|
---|
[2356] | 29 |
|
---|
| 30 | // #include <measures/Measures/MDirection.h>
|
---|
| 31 |
|
---|
| 32 | // #include "Scantable.h"
|
---|
| 33 |
|
---|
| 34 | using namespace std ;
|
---|
| 35 | using namespace casa ;
|
---|
| 36 |
|
---|
| 37 | namespace asap {
|
---|
| 38 | class STGrid
|
---|
| 39 | {
|
---|
| 40 | public:
|
---|
| 41 | STGrid() ;
|
---|
| 42 | STGrid( const string infile ) ;
|
---|
| 43 | virtual ~STGrid() {} ;
|
---|
| 44 |
|
---|
| 45 | void setFileIn( const string infile ) ;
|
---|
| 46 |
|
---|
[2362] | 47 | void setIF( unsigned int ifno ) { ifno_ = ifno ; } ;
|
---|
| 48 |
|
---|
[2360] | 49 | void setPolList( vector<unsigned int> pols ) ;
|
---|
| 50 |
|
---|
[2364] | 51 | void setScanList( vector<unsigned int> scans ) ;
|
---|
| 52 |
|
---|
[2356] | 53 | void defineImage( int nx=-1,
|
---|
| 54 | int ny=-1,
|
---|
| 55 | string scellx="",
|
---|
| 56 | string scelly="",
|
---|
| 57 | string scenter="" ) ;
|
---|
[2364] | 58 | void setFunc( string convtype="box",
|
---|
| 59 | int convsupport=-1 ) ;
|
---|
[2361] | 60 |
|
---|
| 61 | void setWeight( const string wType="uniform" ) ;
|
---|
| 62 |
|
---|
[2356] | 63 | void grid() ;
|
---|
| 64 |
|
---|
| 65 | string saveData( string outfile="" ) ;
|
---|
| 66 |
|
---|
| 67 | private:
|
---|
| 68 | void init() ;
|
---|
| 69 |
|
---|
[2382] | 70 | // actual gridding
|
---|
| 71 | void gridPerRow() ;
|
---|
| 72 | void gridPerPol() ;
|
---|
| 73 |
|
---|
[2356] | 74 | void setupGrid( Int &nx,
|
---|
| 75 | Int &ny,
|
---|
| 76 | String &cellx,
|
---|
| 77 | String &celly,
|
---|
| 78 | Double &xmin,
|
---|
| 79 | Double &xmax,
|
---|
| 80 | Double &ymin,
|
---|
| 81 | Double &ymax,
|
---|
| 82 | String ¢er ) ;
|
---|
[2368] | 83 |
|
---|
[2378] | 84 | void setData( Array<Complex> &gdata,
|
---|
[2368] | 85 | Array<Float> &gwgt ) ;
|
---|
[2356] | 86 |
|
---|
[2382] | 87 | void getDataPerPol( Array<Complex> &spectra,
|
---|
| 88 | Array<Double> &direction,
|
---|
| 89 | Array<Int> &flagtra,
|
---|
| 90 | Array<Int> &rflag,
|
---|
| 91 | Array<Float> &weight ) ;
|
---|
| 92 | void getDataPerPol( Array<Float> &spectra,
|
---|
| 93 | Array<Double> &direction,
|
---|
| 94 | Array<uChar> &flagtra,
|
---|
| 95 | Array<uInt> &rflag,
|
---|
| 96 | Array<Float> &weight ) ;
|
---|
[2379] | 97 | Int getDataChunk( Array<Complex> &spectra,
|
---|
| 98 | Array<Double> &direction,
|
---|
| 99 | Array<Int> &flagtra,
|
---|
| 100 | Array<Int> &rflag,
|
---|
| 101 | Array<Float> &weight ) ;
|
---|
| 102 | Int getDataChunk( Array<Float> &spectra,
|
---|
| 103 | Array<Double> &direction,
|
---|
| 104 | Array<uChar> &flagtra,
|
---|
| 105 | Array<uInt> &rflag,
|
---|
| 106 | Array<Float> &weight ) ;
|
---|
[2356] | 107 |
|
---|
[2375] | 108 | void getWeight( Array<Float> &w,
|
---|
| 109 | Array<Float> &tsys,
|
---|
| 110 | Array<Double> &tint ) ;
|
---|
[2382] | 111 | void getWeightPerPol( Array<Float> &w,
|
---|
| 112 | Array<Float> &tsys,
|
---|
| 113 | Array<Double> &tint ) ;
|
---|
| 114 |
|
---|
[2375] | 115 | void toInt( Array<uChar> &u, Array<Int> &v ) ;
|
---|
| 116 | void toInt( Array<uInt> &u, Array<Int> &v ) ;
|
---|
[2356] | 117 |
|
---|
[2375] | 118 | void toPixel( Array<Double> &world, Array<Double> &pixel ) ;
|
---|
[2356] | 119 |
|
---|
| 120 | void boxFunc( Vector<Float> &convFunc, Int &convSize ) ;
|
---|
| 121 | void spheroidalFunc( Vector<Float> &convFunc ) ;
|
---|
| 122 | void gaussFunc( Vector<Float> &convFunc ) ;
|
---|
| 123 | void pbFunc( Vector<Float> &convFunc ) ;
|
---|
| 124 | void setConvFunc( Vector<Float> &convFunc ) ;
|
---|
| 125 |
|
---|
[2369] | 126 | Float polMean( const Float *p ) ;
|
---|
| 127 | Double polMean( const Double *p ) ;
|
---|
| 128 |
|
---|
[2371] | 129 | void prepareTable( Table &tab, String &name ) ;
|
---|
| 130 |
|
---|
[2378] | 131 | Bool pastEnd() ;
|
---|
| 132 |
|
---|
[2379] | 133 | void selectData() ;
|
---|
| 134 | void setupArray() ;
|
---|
| 135 | void sortData() ;
|
---|
[2378] | 136 |
|
---|
[2379] | 137 | Bool examine() ;
|
---|
[2382] | 138 | void attach( Table &tab ) ;
|
---|
[2379] | 139 |
|
---|
[2381] | 140 | void call_ggridsd( Double* xy,
|
---|
| 141 | const Complex* values,
|
---|
| 142 | Int* nvispol,
|
---|
| 143 | Int* nvischan,
|
---|
| 144 | const Int* flag,
|
---|
| 145 | const Int* rflag,
|
---|
| 146 | const Float* weight,
|
---|
| 147 | Int* nrow,
|
---|
| 148 | Int* irow,
|
---|
| 149 | Complex* grid,
|
---|
| 150 | Float* wgrid,
|
---|
| 151 | Int* nx,
|
---|
| 152 | Int* ny,
|
---|
| 153 | Int * npol,
|
---|
| 154 | Int * nchan,
|
---|
| 155 | Int* support,
|
---|
| 156 | Int* sampling,
|
---|
| 157 | Float* convFunc,
|
---|
| 158 | Int *chanMap,
|
---|
| 159 | Int *polMap ) ;
|
---|
[2379] | 160 |
|
---|
[2382] | 161 | void initPol( Int ipol ) ;
|
---|
[2381] | 162 |
|
---|
[2382] | 163 |
|
---|
[2356] | 164 | String infile_ ;
|
---|
[2362] | 165 | Int ifno_ ;
|
---|
[2356] | 166 | Int nx_ ;
|
---|
| 167 | Int ny_ ;
|
---|
[2361] | 168 | Int npol_ ;
|
---|
| 169 | Int nchan_ ;
|
---|
| 170 | Int nrow_ ;
|
---|
[2356] | 171 | Double cellx_ ;
|
---|
| 172 | Double celly_ ;
|
---|
| 173 | Vector<Double> center_ ;
|
---|
| 174 | String convType_ ;
|
---|
| 175 | Int convSupport_ ;
|
---|
| 176 | Int userSupport_ ;
|
---|
| 177 | Int convSampling_ ;
|
---|
| 178 | Array<Float> data_ ;
|
---|
[2360] | 179 | Vector<uInt> pollist_ ;
|
---|
[2364] | 180 | Vector<uInt> scanlist_ ;
|
---|
[2361] | 181 | String wtype_ ;
|
---|
[2356] | 182 |
|
---|
| 183 | Table tab_ ;
|
---|
[2382] | 184 | Table ptab_ ;
|
---|
[2379] | 185 | ROArrayColumn<Float> spectraCol_ ;
|
---|
| 186 | ROArrayColumn<uChar> flagtraCol_ ;
|
---|
| 187 | ROArrayColumn<Double> directionCol_ ;
|
---|
| 188 | ROScalarColumn<uInt> flagRowCol_ ;
|
---|
| 189 | ROArrayColumn<Float> tsysCol_ ;
|
---|
| 190 | ROScalarColumn<Double> intervalCol_ ;
|
---|
[2381] | 191 | // ROTableRow row_ ;
|
---|
| 192 | // RORecordFieldPtr< Array<Float> > spectraRF_ ;
|
---|
| 193 | // RORecordFieldPtr< Array<uChar> > flagtraRF_ ;
|
---|
| 194 | // RORecordFieldPtr< Array<Double> > directionRF_ ;
|
---|
| 195 | // RORecordFieldPtr<uInt> flagRowRF_ ;
|
---|
| 196 | // RORecordFieldPtr< Array<Float> > tsysRF_ ;
|
---|
| 197 | // RORecordFieldPtr<Double> intervalRF_ ;
|
---|
[2379] | 198 | Int nprocessed_ ;
|
---|
| 199 | Vector<uInt> rows_ ;
|
---|
| 200 | Int nchunk_ ;
|
---|
[2381] | 201 |
|
---|
| 202 | Array<Float> spectraF_ ;
|
---|
| 203 | Array<uChar> flagtraUC_ ;
|
---|
| 204 | Array<uInt> rflagUI_ ;
|
---|
| 205 |
|
---|
| 206 | double subtime_ ;
|
---|
[2356] | 207 | };
|
---|
| 208 | }
|
---|
| 209 | #endif
|
---|