source: trunk/src/STGrid.h @ 2594

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

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: sdgrid unit test with sd.rcParamsscantable.storage?='memory'

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Bug fix on STGrid2.


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