source: trunk/src/STGrid.h@ 2670

Last change on this file since 2670 was 2669, checked in by Takeshi Nakazato, 12 years ago

New Development: No

JIRA Issue: Yes CAS-4429

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Use DirectionCoordinate for conversion between world and pixel.


File size: 7.7 KB
Line 
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>
18#include <vector>
19
20#include <casa/BasicSL/String.h>
21#include <casa/Arrays/Array.h>
22#include <casa/Arrays/Vector.h>
23#include <casa/Containers/RecordField.h>
24#include <casa/Utilities/CountedPtr.h>
25
26#include <tables/Tables/Table.h>
27#include <tables/Tables/ScalarColumn.h>
28#include <tables/Tables/ArrayColumn.h>
29
30#include <coordinates/Coordinates/DirectionCoordinate.h>
31
32#include "ScantableWrapper.h"
33#include "Scantable.h"
34#include "concurrent.h"
35
36using namespace std ;
37using namespace casa ;
38
39namespace asap {
40class STGrid
41{
42public:
43 STGrid() ;
44 STGrid( const string infile ) ;
45 STGrid( const vector<string> infile ) ;
46 virtual ~STGrid() {} ;
47
48 void setFileIn( const string infile ) ;
49 void setFileList( const vector<string> infile ) ;
50
51 void setIF( unsigned int ifno ) { ifno_ = ifno ; } ;
52
53 void setPolList( vector<unsigned int> pols ) ;
54
55 void setScanList( vector<unsigned int> scans ) ;
56
57 void defineImage( int nx=-1,
58 int ny=-1,
59 string scellx="",
60 string scelly="",
61 string scenter="" ) ;
62 void setFunc( string convtype="box",
63 int convsupport=-1 ) ;
64
65 void setWeight( const string wType="uniform" ) ;
66
67 void enableClip() { doclip_ = True ; } ;
68 void disableClip() { doclip_ = False ; } ;
69
70 void grid() ;
71
72 string saveData( string outfile="" ) ;
73
74//private:
75protected:
76 void init() ;
77
78 // actual gridding
79 void gridPerRow() ;
80 void gridPerRowWithClipping() ;
81
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
94 void setupGrid() ;
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 &center ) ;
104 void mapExtent( Double &xmin, Double &xmax,
105 Double &ymin, Double &ymax ) ;
106
107 void setData( Array<Complex> &gdata,
108 Array<Float> &gwgt ) ;
109
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 ) ;
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 ) ;
128
129 void getWeight( Array<Float> &w,
130 Array<Float> &tsys,
131 Array<Double> &tint ) ;
132
133 void toInt( Array<uChar> &u, Array<Int> &v ) ;
134 void toInt( Array<uInt> &u, Array<Int> &v ) ;
135
136 void toPixel( Array<Double> &world, Array<Double> &pixel ) ;
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
144 void prepareTable( Table &tab, String &name ) ;
145
146 void selectData() ;
147 void setupArray() ;
148
149 void updateChunkShape() ;
150 void attach( Table &tab ) ;
151
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,
170 Int *chanMap,
171 Int *polMap ) ;
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 ) ;
199
200 void initPol( Int ipol ) ;
201 void initTable( uInt idx ) ;
202 Bool isMultiIF( Table &tab ) ;
203 void fillMainColumns( Table &tab ) ;
204 void fillTable( Table &tab ) ;
205 virtual void table( Table &tab, uInt i ) ;
206 static bool produceChunk(void *ctx) throw(concurrent::PCException);
207 static void consumeChunk(void *ctx) throw(concurrent::PCException);
208 static void consumeChunkWithClipping(void *ctx) throw(concurrent::PCException);
209
210
211 // user input
212 Int nxUI_ ;
213 Int nyUI_ ;
214 String cellxUI_ ;
215 String cellyUI_ ;
216 String centerUI_ ;
217
218 Block<String> infileList_ ;
219 uInt nfile_ ;
220 Int ifno_ ;
221 Bool doclip_ ;
222
223 Int nx_ ;
224 Int ny_ ;
225 Int npol_ ;
226 Int npolOrg_ ;
227 Int nchan_ ;
228 Double cellx_ ;
229 Double celly_ ;
230 Vector<Double> center_ ;
231 String convType_ ;
232 Int convSupport_ ;
233 Int userSupport_ ;
234 Int convSampling_ ;
235 Vector<uInt> pollist_ ;
236 Vector<uInt> scanlist_ ;
237 String wtype_ ;
238 Block<Table> tableList_ ;
239 Vector<uInt> rows_ ;
240 Int nchunk_ ;
241 CountedPtr<DirectionCoordinate> dircoord_;
242
243 /////////////// gridPerRow variable
244 IPosition vshape_;
245 IPosition wshape_;
246 IPosition dshape_;
247 // loop variable
248 Int nrow_ ;
249 Array<Float> data_ ;
250
251 Table tab_ ;
252 // per pol
253 Table ptab_ ;
254 ROArrayColumn<Float> spectraCol_ ;
255 ROArrayColumn<uChar> flagtraCol_ ;
256 ROArrayColumn<Double> directionCol_ ;
257 ROScalarColumn<uInt> flagRowCol_ ;
258 ROArrayColumn<Float> tsysCol_ ;
259 ROScalarColumn<Double> intervalCol_ ;
260
261 Int nprocessed_ ;
262
263
264 double eGetData_;
265 double eToPixel_;
266 double eGGridSD_;
267};
268
269class STGrid2 : public STGrid
270{
271public:
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 ) ;
279 ScantableWrapper getResultAsScantable( int tp ) ;
280
281private:
282 Block<ScantableWrapper> dataList_ ;
283};
284}
285#endif
Note: See TracBrowser for help on using the repository browser.