source: trunk/src/STGrid.h@ 2395

Last change on this file since 2395 was 2393, checked in by Takeshi Nakazato, 13 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...

Parallel version of STGrid. Implemented using concurrent module.
Two threads are running in parallel. Those are responsible for
retrieving data and processing data respectively.


File size: 5.8 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 grid() ;
68
69 string saveData( string outfile="" ) ;
70
71private:
72 void init() ;
73
74 // actual gridding
75 void gridPerRow() ;
76 void gridPerPol() ;
77
78 void setupGrid() ;
79 void setupGrid( Int &nx,
80 Int &ny,
81 String &cellx,
82 String &celly,
83 Double &xmin,
84 Double &xmax,
85 Double &ymin,
86 Double &ymax,
87 String &center ) ;
88 void mapExtent( Double &xmin, Double &xmax,
89 Double &ymin, Double &ymax ) ;
90
91 void setData( Array<Complex> &gdata,
92 Array<Float> &gwgt ) ;
93
94 void getDataPerPol( Array<Complex> &spectra,
95 Array<Double> &direction,
96 Array<Int> &flagtra,
97 Array<Int> &rflag,
98 Array<Float> &weight ) ;
99 void getDataPerPol( Array<Float> &spectra,
100 Array<Double> &direction,
101 Array<uChar> &flagtra,
102 Array<uInt> &rflag,
103 Array<Float> &weight ) ;
104 Int getDataChunk( IPosition const &wshape,
105 IPosition const &vshape,
106 IPosition const &dshape,
107 Array<Complex> &spectra,
108 Array<Double> &direction,
109 Array<Int> &flagtra,
110 Array<Int> &rflag,
111 Array<Float> &weight ) ;
112 Int getDataChunk( Array<Complex> &spectra,
113 Array<Double> &direction,
114 Array<Int> &flagtra,
115 Array<Int> &rflag,
116 Array<Float> &weight ) ;
117 Int getDataChunk( Array<Float> &spectra,
118 Array<Double> &direction,
119 Array<uChar> &flagtra,
120 Array<uInt> &rflag,
121 Array<Float> &weight ) ;
122
123 void getWeight( Array<Float> &w,
124 Array<Float> &tsys,
125 Array<Double> &tint ) ;
126
127 void toInt( Array<uChar> &u, Array<Int> &v ) ;
128 void toInt( Array<uInt> &u, Array<Int> &v ) ;
129
130 void toPixel( Array<Double> &world, Array<Double> &pixel ) ;
131
132 void boxFunc( Vector<Float> &convFunc, Int &convSize ) ;
133 void spheroidalFunc( Vector<Float> &convFunc ) ;
134 void gaussFunc( Vector<Float> &convFunc ) ;
135 void pbFunc( Vector<Float> &convFunc ) ;
136 void setConvFunc( Vector<Float> &convFunc ) ;
137
138 void prepareTable( Table &tab, String &name ) ;
139
140// Bool pastEnd() ;
141
142 void selectData() ;
143 void setupArray() ;
144
145 Bool examine() ;
146 void attach( Table &tab ) ;
147
148 void call_ggridsd( Array<Double> &xy,
149 Array<Complex> &values,
150 Int &nvispol,
151 Int &nvischan,
152 Array<Int> &flag,
153 Array<Int> &rflag,
154 Array<Float> &weight,
155 Int &nrow,
156 Int &irow,
157 Array<Complex> &grid,
158 Array<Float> &wgrid,
159 Int &nx,
160 Int &ny,
161 Int &npol,
162 Int &nchan,
163 Int &support,
164 Int &sampling,
165 Vector<Float> &convFunc,
166 Int *chanMap,
167 Int *polMap ) ;
168
169 void initPol( Int ipol ) ;
170 void initTable( uInt idx ) ;
171 Bool isMultiIF( Table &tab ) ;
172 static bool produceChunk(void *ctx) throw(concurrent::PCException);
173 static void consumeChunk(void *ctx) throw(concurrent::PCException);
174
175
176 // user input
177 Int nxUI_ ;
178 Int nyUI_ ;
179 String cellxUI_ ;
180 String cellyUI_ ;
181 String centerUI_ ;
182
183 Block<String> infileList_ ;
184 uInt nfile_ ;
185 Int ifno_ ;
186
187 Int nx_ ;
188 Int ny_ ;
189 Int npol_ ;
190 Int npolOrg_ ;
191 Int nchan_ ;
192 Double cellx_ ;
193 Double celly_ ;
194 Vector<Double> center_ ;
195 String convType_ ;
196 Int convSupport_ ;
197 Int userSupport_ ;
198 Int convSampling_ ;
199 Vector<uInt> pollist_ ;
200 Vector<uInt> scanlist_ ;
201 String wtype_ ;
202 Block<Table> tableList_ ;
203 Vector<uInt> rows_ ;
204 Int nchunk_ ;
205
206 /////////////// gridPerRow variable
207 IPosition vshape_;
208 IPosition wshape_;
209 IPosition dshape_;
210 // loop variable
211 Int nrow_ ;
212 Array<Float> data_ ;
213
214 Table tab_ ;
215 // per pol
216 Table ptab_ ;
217 ROArrayColumn<Float> spectraCol_ ;
218 ROArrayColumn<uChar> flagtraCol_ ;
219 ROArrayColumn<Double> directionCol_ ;
220 ROScalarColumn<uInt> flagRowCol_ ;
221 ROArrayColumn<Float> tsysCol_ ;
222 ROScalarColumn<Double> intervalCol_ ;
223
224 Int nprocessed_ ;
225
226
227 double eGetData_;
228 double eToPixel_;
229 double eGGridSD_;
230};
231}
232#endif
Note: See TracBrowser for help on using the repository browser.