source: trunk/src/STGrid.h @ 2396

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

New Development: No

JIRA Issue: Yes CAS-2816

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...

Added min/max clipping functionality.
Introduced control parameter and methods for clipping.

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 "concurrent.h"
30//#include <tables/Tables/TableRow.h>
31
32// #include <measures/Measures/MDirection.h>
33
34// #include "Scantable.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
74private:
75  void init() ;
76
77  // actual gridding
78  void gridPerRow() ;
79  void gridPerRowWithClipping() ;
80  void gridPerPol() ;
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  void getDataPerPol( Array<Complex> &spectra,
111                      Array<Double> &direction,
112                      Array<Int> &flagtra,
113                      Array<Int> &rflag,
114                      Array<Float> &weight ) ;
115  void getDataPerPol( Array<Float> &spectra,
116                      Array<Double> &direction,
117                      Array<uChar> &flagtra,
118                      Array<uInt> &rflag,
119                      Array<Float> &weight ) ;
120  Int getDataChunk( IPosition const &wshape,
121                    IPosition const &vshape,
122                    IPosition const &dshape,
123                    Array<Complex> &spectra,
124                    Array<Double> &direction,
125                    Array<Int> &flagtra,
126                    Array<Int> &rflag,
127                    Array<Float> &weight ) ;
128  Int getDataChunk( Array<Complex> &spectra,
129                    Array<Double> &direction,
130                    Array<Int> &flagtra,
131                    Array<Int> &rflag,
132                    Array<Float> &weight ) ;
133  Int getDataChunk( Array<Float> &spectra,
134                    Array<Double> &direction,
135                    Array<uChar> &flagtra,
136                    Array<uInt> &rflag,
137                    Array<Float> &weight ) ;
138
139  void getWeight( Array<Float> &w,
140                  Array<Float> &tsys,
141                  Array<Double> &tint ) ;
142 
143  void toInt( Array<uChar> &u, Array<Int> &v ) ;
144  void toInt( Array<uInt> &u, Array<Int> &v ) ;
145
146  void toPixel( Array<Double> &world, Array<Double> &pixel ) ;
147 
148  void boxFunc( Vector<Float> &convFunc, Int &convSize ) ;
149  void spheroidalFunc( Vector<Float> &convFunc ) ;
150  void gaussFunc( Vector<Float> &convFunc ) ;
151  void pbFunc( Vector<Float> &convFunc ) ;
152  void setConvFunc( Vector<Float> &convFunc ) ;
153
154  void prepareTable( Table &tab, String &name ) ;
155
156//   Bool pastEnd() ;
157
158  void selectData() ;
159  void setupArray() ;
160
161  Bool examine() ;
162  void attach( Table &tab ) ;
163
164  void call_ggridsd( Array<Double> &xy,
165                     Array<Complex> &values,
166                     Int &nvispol,
167                     Int &nvischan,
168                     Array<Int> &flag,
169                     Array<Int> &rflag,
170                     Array<Float> &weight,
171                     Int &nrow,
172                     Int &irow,
173                     Array<Complex> &grid,
174                     Array<Float> &wgrid,
175                     Int &nx,
176                     Int &ny,
177                     Int &npol,
178                     Int &nchan,
179                     Int &support,
180                     Int &sampling,
181                     Vector<Float> &convFunc,
182                     Int *chanMap,
183                     Int *polMap ) ;
184  void call_ggridsd2( Array<Double> &xy,
185                      Array<Complex> &values,
186                      Int &nvispol,
187                      Int &nvischan,
188                      Array<Int> &flag,
189                      Array<Int> &rflag,
190                      Array<Float> &weight,
191                      Int &nrow,
192                      Int &irow,
193                      Array<Complex> &grid,
194                      Array<Float> &wgrid,
195                      Array<Int> &npoints,
196                      Array<Complex> &clipmin,
197                      Array<Float> &clipwmin,
198                      Array<Float> &clipcmin,
199                      Array<Complex> &clipmax,
200                      Array<Float> &clipwmax,
201                      Array<Float> &clipcmax,
202                      Int &nx,
203                      Int &ny,
204                      Int &npol,
205                      Int &nchan,
206                      Int &support,
207                      Int &sampling,
208                      Vector<Float> &convFunc,
209                      Int *chanMap,
210                      Int *polMap ) ;
211
212  void initPol( Int ipol ) ;
213  void initTable( uInt idx ) ;
214  Bool isMultiIF( Table &tab ) ;
215  static bool produceChunk(void *ctx) throw(concurrent::PCException);
216  static void consumeChunk(void *ctx) throw(concurrent::PCException);
217  static void consumeChunkWithClipping(void *ctx) throw(concurrent::PCException);
218
219
220  // user input
221  Int nxUI_ ;
222  Int nyUI_ ;
223  String cellxUI_ ;
224  String cellyUI_ ;
225  String centerUI_ ;
226
227  Block<String> infileList_ ;
228  uInt nfile_ ;
229  Int ifno_ ;
230  Bool doclip_ ;
231
232  Int nx_ ;
233  Int ny_ ;
234  Int npol_ ;
235  Int npolOrg_ ;
236  Int nchan_ ;
237  Double cellx_ ;
238  Double celly_ ;
239  Vector<Double> center_ ;
240  String convType_ ;
241  Int convSupport_ ;
242  Int userSupport_ ;
243  Int convSampling_ ;
244  Vector<uInt> pollist_ ;
245  Vector<uInt> scanlist_ ;
246  String wtype_ ;
247  Block<Table> tableList_ ;
248  Vector<uInt> rows_ ;
249  Int nchunk_ ;
250
251  /////////////// gridPerRow variable
252  IPosition vshape_;
253  IPosition wshape_;
254  IPosition dshape_;
255  // loop variable
256  Int nrow_ ;
257  Array<Float> data_ ;
258
259  Table tab_ ;
260  // per pol
261  Table ptab_ ;
262  ROArrayColumn<Float> spectraCol_ ;
263  ROArrayColumn<uChar> flagtraCol_ ;
264  ROArrayColumn<Double> directionCol_ ;
265  ROScalarColumn<uInt> flagRowCol_ ;
266  ROArrayColumn<Float> tsysCol_ ;
267  ROScalarColumn<Double> intervalCol_ ;
268
269  Int nprocessed_ ;
270
271
272  double eGetData_;
273  double eToPixel_;
274  double eGGridSD_;
275};
276}
277#endif
Note: See TracBrowser for help on using the repository browser.