source: trunk/src/STGrid.h@ 2394

Last change on this file since 2394 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
RevLine 
[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>
[2393]28
29#include "concurrent.h"
[2381]30//#include <tables/Tables/TableRow.h>
[2356]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 ) ;
[2390]45 STGrid( const vector<string> infile ) ;
[2356]46 virtual ~STGrid() {} ;
47
48 void setFileIn( const string infile ) ;
[2390]49 void setFileList( const vector<string> infile ) ;
[2356]50
[2362]51 void setIF( unsigned int ifno ) { ifno_ = ifno ; } ;
52
[2360]53 void setPolList( vector<unsigned int> pols ) ;
54
[2364]55 void setScanList( vector<unsigned int> scans ) ;
56
[2356]57 void defineImage( int nx=-1,
58 int ny=-1,
59 string scellx="",
60 string scelly="",
61 string scenter="" ) ;
[2364]62 void setFunc( string convtype="box",
63 int convsupport=-1 ) ;
[2361]64
65 void setWeight( const string wType="uniform" ) ;
66
[2356]67 void grid() ;
68
69 string saveData( string outfile="" ) ;
70
71private:
72 void init() ;
73
[2382]74 // actual gridding
75 void gridPerRow() ;
76 void gridPerPol() ;
77
[2388]78 void setupGrid() ;
[2356]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 ) ;
[2388]88 void mapExtent( Double &xmin, Double &xmax,
89 Double &ymin, Double &ymax ) ;
[2368]90
[2378]91 void setData( Array<Complex> &gdata,
[2368]92 Array<Float> &gwgt ) ;
[2356]93
[2382]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 ) ;
[2393]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 ) ;
[2379]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 ) ;
[2356]122
[2375]123 void getWeight( Array<Float> &w,
124 Array<Float> &tsys,
125 Array<Double> &tint ) ;
[2382]126
[2375]127 void toInt( Array<uChar> &u, Array<Int> &v ) ;
128 void toInt( Array<uInt> &u, Array<Int> &v ) ;
[2356]129
[2375]130 void toPixel( Array<Double> &world, Array<Double> &pixel ) ;
[2356]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
[2371]138 void prepareTable( Table &tab, String &name ) ;
139
[2393]140// Bool pastEnd() ;
[2378]141
[2379]142 void selectData() ;
143 void setupArray() ;
[2378]144
[2379]145 Bool examine() ;
[2382]146 void attach( Table &tab ) ;
[2379]147
[2384]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,
[2381]166 Int *chanMap,
167 Int *polMap ) ;
[2379]168
[2382]169 void initPol( Int ipol ) ;
[2390]170 void initTable( uInt idx ) ;
[2386]171 Bool isMultiIF( Table &tab ) ;
[2393]172 static bool produceChunk(void *ctx) throw(concurrent::PCException);
173 static void consumeChunk(void *ctx) throw(concurrent::PCException);
[2381]174
[2382]175
[2388]176 // user input
177 Int nxUI_ ;
178 Int nyUI_ ;
179 String cellxUI_ ;
180 String cellyUI_ ;
181 String centerUI_ ;
182
[2389]183 Block<String> infileList_ ;
[2390]184 uInt nfile_ ;
[2362]185 Int ifno_ ;
[2393]186
[2356]187 Int nx_ ;
188 Int ny_ ;
[2361]189 Int npol_ ;
[2386]190 Int npolOrg_ ;
[2361]191 Int nchan_ ;
[2356]192 Double cellx_ ;
193 Double celly_ ;
194 Vector<Double> center_ ;
195 String convType_ ;
196 Int convSupport_ ;
197 Int userSupport_ ;
198 Int convSampling_ ;
[2360]199 Vector<uInt> pollist_ ;
[2364]200 Vector<uInt> scanlist_ ;
[2361]201 String wtype_ ;
[2393]202 Block<Table> tableList_ ;
203 Vector<uInt> rows_ ;
204 Int nchunk_ ;
[2356]205
[2393]206 /////////////// gridPerRow variable
207 IPosition vshape_;
208 IPosition wshape_;
209 IPosition dshape_;
210 // loop variable
211 Int nrow_ ;
212 Array<Float> data_ ;
213
[2356]214 Table tab_ ;
[2393]215 // per pol
[2382]216 Table ptab_ ;
[2379]217 ROArrayColumn<Float> spectraCol_ ;
218 ROArrayColumn<uChar> flagtraCol_ ;
219 ROArrayColumn<Double> directionCol_ ;
220 ROScalarColumn<uInt> flagRowCol_ ;
221 ROArrayColumn<Float> tsysCol_ ;
222 ROScalarColumn<Double> intervalCol_ ;
[2393]223
[2379]224 Int nprocessed_ ;
[2381]225
226
[2393]227 double eGetData_;
228 double eToPixel_;
229 double eGGridSD_;
[2356]230};
231}
232#endif
Note: See TracBrowser for help on using the repository browser.