Skip to content

Commit 9af2790

Browse files
committed
Merge branch 'cfshape' into 'main'
roadrunner.cc: Print list of CF shape+fixed bug that created .tmp image See merge request ardg/libra!138
2 parents 4900cda + ea29828 commit 9af2790

24 files changed

+637
-217
lines changed

.gitlab-ci.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,18 @@ test-job:
150150
151151
# --- C++ GTest section ---
152152
cd ${base_path}/apps/src/tests/
153-
# Run C++ gtest binary if it exists
154-
if [ -x "${base_path}/install/bin/tests/LibRATests" ]; then
155-
"${base_path}/install/bin/tests/LibRATests" --gtest_output=xml:"${base_path}/libra-python/reports/cpp_report.xml"
156-
else
157-
echo "C++ test binary not found: ${base_path}/install/bin/tests/LibRATests"
158-
fi
153+
# Run C++ gtest binaries if they exist
154+
test_binaries=("LibRATests" "test_roadrunner_robustMinus2" "test_roadrunner_robustPlus2" "test_roadrunner_snrpsf" "test_roadrunner_weight")
159155
156+
for test_binary in "${test_binaries[@]}"; do
157+
if [ -x "${base_path}/install/bin/tests/${test_binary}" ]; then
158+
echo "Running ${test_binary}..."
159+
"${base_path}/install/bin/tests/${test_binary}" --gtest_output=xml:"${base_path}/libra-python/reports/cpp_${test_binary}_report.xml"
160+
else
161+
echo "C++ test binary not found: ${base_path}/install/bin/tests/${test_binary}"
162+
fi
163+
done
164+
160165
# --- Python pytest section ---
161166
cd "${base_path}/apps/src/tests/"
162167
pytest ${base_path}/libra-python/tests --junitxml=pytest_report.xml -v || echo "Pytest failed, but continuing for CI artifact collection"

apps/src/Acme/acme_cl_interface.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void UI(Bool restart, int argc, char **argv, bool interactive,
6767
catch (clError x)
6868
{
6969
x << x << endl;
70-
clRetry();
70+
if (x.Severity() == CL_FATAL) {throw;} // Re-throw instead of exit - allows proper exception handling
7171
}
7272

7373
if (imageName=="")

apps/src/Chip/chip_cl_interface.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void UI(Bool restart, int argc, char **argv, bool interactive,
7272
catch (clError x)
7373
{
7474
x << x << endl;
75-
clRetry();
75+
if (x.Severity() == CL_FATAL) {throw;} // Re-throw instead of exit - allows proper exception handling
7676
}
7777
if ((imageName.size()==0) || ((imageName.size()==1) && (imageName[0]=="")))
7878
throw(AipsError("Input image name not set."));

apps/src/Coyote/coyote.cc

Lines changed: 9 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -30,79 +30,6 @@
3030
#include <libracore/MakeComponents.h>
3131

3232
#include <coyote.h>
33-
34-
//
35-
//--------------------------------------------------------------------------
36-
//
37-
PagedImage<Complex> makeEmptySkyImage4CF(VisibilityIterator2& vi2,
38-
const MeasurementSet& selectedMS,
39-
MSSelection& msSelection,
40-
const String& imageName,
41-
const Vector<Int>& imSize, const float& cellSize,
42-
const String& phaseCenter, const String& stokes,
43-
const String& refFreq)
44-
{
45-
Vector<Quantity> qCellSize(2);
46-
for (int i=0;i<2;i++)
47-
{
48-
String qUnit("arcsec");
49-
qCellSize[i]=Quantity(cellSize, qUnit);
50-
}
51-
52-
int imStokes=1;
53-
if (stokes=="I") imStokes=1;
54-
else if (stokes=="IV") imStokes=2;
55-
else if (stokes=="IQUV") imStokes=4;
56-
57-
int imNChan=1;
58-
59-
MDirection mphaseCenter;
60-
mdFromString(mphaseCenter, phaseCenter);
61-
62-
SynthesisParamsGrid gridParams;
63-
SynthesisParamsImage imageParams;
64-
imageParams.imageName=imageName;
65-
imageParams.imsize=imSize;
66-
imageParams.cellsize=qCellSize;
67-
imageParams.phaseCenter = mphaseCenter;
68-
imageParams.stokes=stokes;
69-
imageParams.mode=String("mfs");
70-
imageParams.frame=String("LSRK");
71-
imageParams.veltype=String("radio");
72-
73-
//
74-
// There are two items related to ref. freq. "reffreq" (a String) and "refFreq" (a Quantity).
75-
// Set them both.
76-
//
77-
if (refFreq != "")
78-
{
79-
imageParams.reffreq=refFreq;
80-
81-
// Parse the user string. It may be parse as a pure numerical
82-
// value, or as a numerical value with units.
83-
// If no units were provided, it is assumed to be Hz.
84-
//
85-
// refFreq element of the imageParams struct requires a Quantity
86-
// in GHz units. We provide it as such, without understanding
87-
// why it is required in these units, or even why this element
88-
// is required at all (given that imageParams.reffreq also
89-
// exist which takes the frequency as a string).
90-
try
91-
{
92-
imageParams.refFreq=SynthesisUtils::makeFreqQuantity(refFreq,"GHz");
93-
}
94-
catch (AipsError& e)
95-
{
96-
string msg("reffreq setting: "); msg+=e.what();
97-
throw(AipsError(msg));
98-
}
99-
}
100-
101-
casacore::Block<const casacore::MeasurementSet *> msList(1); msList[0]=&selectedMS;
102-
CoordinateSystem csys = imageParams.buildCoordinateSystem(vi2,makeTheChanSelMap(msSelection),msList);
103-
IPosition imshape(4,imSize(0),imSize(1),imStokes,imNChan);
104-
return PagedImage<Complex>(imshape, csys, imageParams.imageName);
105-
}
10633
//
10734
//--------------------------------------------------------------------------
10835
//
@@ -343,18 +270,22 @@ void Coyote(//bool &restartUI, int &argc, char **argv,
343270
// This is inherited from ImageInterface so should be able to pass
344271
// an image interface object from it.
345272
//
346-
PagedImage<Complex> cgrid =
347-
makeEmptySkyImage4CF(*(db.vi2_l), db.selectedMS, db.msSelection,
348-
imageName, imSize, cellSize, phaseCenter,
349-
stokes, refFreqStr);
273+
// PagedImage<Complex> cgrid =
274+
// makeEmptySkyImage4CF(*(db.vi2_l), db.selectedMS, db.msSelection,
275+
// imageName, imSize, cellSize, phaseCenter,
276+
// stokes, refFreqStr);
277+
TempImage<Complex> cgrid =
278+
makeEmptySkyImage(*(db.vi2_l), db.selectedMS, db.msSelection,
279+
imageName, String(""),imSize, cellSize, phaseCenter,
280+
stokes, refFreqStr,String("mfs"));
350281
//
351282
// Save the coordinate system in a record and make it persistent in
352283
// the CFCache.
353284
//
354285
// String targetName=String(cfCacheName);
355286
ImageInformation<Complex> imInfo(cgrid,casacore::String(cfCacheName));
356287
imInfo.save();
357-
cgrid.table().markForDelete();
288+
// cgrid.table().markForDelete();
358289

359290
//-------------------------------------------------------------------------------------------------
360291

apps/src/Coyote/coyote_cl_interface.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,8 @@ void UI(bool restart, int argc, char **argv, bool interactive,
144144
}
145145
catch (clError& x)
146146
{
147-
x << x << endl;
148-
if (x.Severity() == CL_FATAL) exit(1);
149-
//clRetry();
150-
RestartUI(REENTER);
147+
x << x << endl;
148+
if (x.Severity() == CL_FATAL) {throw;} // Re-throw instead of exit - allows proper exception handling
151149
}
152150
}
153151
//

apps/src/Dale/dale_cl_interface.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void UI(bool restart, int argc, char **argv, bool interactive,
8989
catch (clError x)
9090
{
9191
x << x << endl;
92-
clRetry();
92+
if (x.Severity() == CL_FATAL) {throw;} // Re-throw instead of exit - allows proper exception handling
9393
}
9494
if (imageName=="")
9595
throw(AipsError("Input image name not set."));

apps/src/Hummbee/hummbee_cl_interface.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ void UI(bool restart, int argc, char **argv, bool interactive,
176176
catch (clError& x)
177177
{
178178
x << x << endl;
179-
if (x.Severity() == CL_FATAL) exit(1);
180-
//clRetry();
181-
RestartUI(REENTER);
179+
if (x.Severity() == CL_FATAL) {throw;} // Re-throw instead of exit - allows proper exception handling
182180
}
183181
}
184182

apps/src/MSSplit/mssplit_cl_interface.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ void UI(Bool restart, int argc, char **argv, bool interactive, string& MSNBuf, s
6666
}
6767
catch (clError& x)
6868
{
69-
x << x << endl;
70-
if (x.Severity() == CL_FATAL) exit(1);
71-
//clRetry();
72-
RestartUI(REENTER);
69+
x << x << endl;
70+
if (x.Severity() == CL_FATAL) {throw;} // Re-throw instead of exit - allows proper exception handling
7371
}
7472
}
7573

apps/src/RoadRunner/roadrunner.cc

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ prepCFEngine(casa::refim::MakeCFArray& mkCF,
6262

6363
casacore::Vector<Int> wNdxList;
6464
casacore::Vector<Int> spwNdxList;
65+
std::vector<int> cfShapeList;
6566
std::chrono::time_point<std::chrono::steady_clock>
6667
startMkCF=std::chrono::steady_clock::now();
6768
auto ret=
@@ -79,8 +80,11 @@ prepCFEngine(casa::refim::MakeCFArray& mkCF,
7980
if (newCF)
8081
{
8182
casa::refim::MyCFArray cfArray;
83+
cfShapeList = std::get<4>(ret);
8284
cerr << "Make CF Array run time: " << runtimeMkCF.count() << " sec" << endl;
83-
cerr << "CF W list: " << wNdxList << endl << "CF SPW List: " << spwNdxList << endl;
85+
cerr << "CF W list: " << wNdxList << endl << "CF SPW List: " << spwNdxList << endl
86+
<< "CF Shapes: ";
87+
for(auto s : cfShapeList) cerr << s << " "; cerr << endl;
8488
cfsi_g = get<2>(ret);
8589

8690
dcf_sptr = std::get<3>(ret);
@@ -433,16 +437,26 @@ auto Roadrunner(//bool& restartUI, int& argc, char** argv,
433437
// pc.print(oss);
434438
// cerr << "PC = " << oss << endl;
435439

436-
PagedImage<Complex> cgrid=makeEmptySkyImage(*(db.vi2_l), db.selectedMS, db.msSelection,
440+
TempImage<Complex> cgrid=makeEmptySkyImage(*(db.vi2_l), db.selectedMS, db.msSelection,
437441
cmplxGridName, startModelImageName,
438442
imSize, cellSize, phaseCenter,
439443
stokes, refFreqStr, mode);
440444
PagedImage<Float> skyImage(cgrid.shape(),cgrid.coordinates(), imageName);
441445

442-
cgrid.table().markForDelete();
443-
446+
// set the default of rmode to be "norm"
447+
if (rmode =="")
448+
rmode = "norm";
449+
// put the guard here so in the UI() users don't need to correct `rmode` if they don't know how to
450+
if (rmode != "norm")
451+
{
452+
log_l << "'rmode' parameter is not set to 'norm'. Please verify this is intentional." << LogIO::WARN;
453+
log_l << "For Briggs weighting, `rmode` is automatically set to `norm` to ensure the robust parameter functions correctly." << LogIO::WARN;
454+
}
444455
if (weighting == "briggs" && rmode !="norm")
445-
throw(AipsError("Ensure `rmode` is set correctly. For Briggs weighting, use `rmode = norm` for the robust parameter to take effect."));
456+
rmode = "norm";
457+
458+
459+
// cgrid.table().markForDelete();
446460

447461
// Setup the weighting scheme in the supplied VI2
448462
weightor(*(db.vi2_l),

apps/src/RoadRunner/roadrunner_cl_interface.cc

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void UI(Bool restart, int argc, char **argv, bool interactive,
7979
// else
8080
// clRetry();
8181
REENTER:
82-
try
82+
// try
8383
{
8484
SMap watchPoints; VString exposedKeys;
8585
int i;
@@ -110,6 +110,8 @@ void UI(Bool restart, int argc, char **argv, bool interactive,
110110
clSetOptions("weighting",{"natural","uniform","briggs"});
111111

112112
i=1;clgetSValp("rmode", rmode,i);
113+
clSetOptions("rmode",{"abs","norm", "none"});
114+
113115
i=1;clgetValp("robust", robust,i);
114116

115117
i=1;clgetValp("wprojplanes", nW,i);
@@ -130,7 +132,8 @@ void UI(Bool restart, int argc, char **argv, bool interactive,
130132
// Expose the datacolumn parameter only for mode=residual
131133
// exposedKeys.push_back("datacolumn");
132134
// watchPoints["residual"]=exposedKeys;
133-
i=1;clgetSValp("mode", imagingMode,i,watchPoints); clSetOptions("mode",{"weight","psf","snrpsf","residual","predict"});
135+
std::vector<std::string> imagingModeOpts = {"weight","psf","snrpsf","residual","predict"};
136+
i=1;clgetSValp("mode", imagingMode,i,watchPoints); clSetOptions("mode",imagingModeOpts);
134137

135138
i=1;clgetValp("wbawp", WBAwp,i);
136139

@@ -159,6 +162,11 @@ void UI(Bool restart, int argc, char **argv, bool interactive,
159162

160163
// do some input parameter checking now.
161164
string mesgs;
165+
auto si=std::find(imagingModeOpts.begin(), imagingModeOpts.end(),imagingMode);
166+
if ((si != imagingModeOpts.end()) && (imagingMode != "predict"))
167+
if (imageName == "")
168+
mesgs += "Imaging mode="+imagingMode+" needs imagename to be set.\n";
169+
162170
if (CFCache == "")
163171
mesgs += "The cfcache parameter needs to be set.\n";
164172

@@ -176,27 +184,13 @@ void UI(Bool restart, int argc, char **argv, bool interactive,
176184

177185
if (mesgs != "")
178186
clThrowUp(mesgs,"###Fatal", CL_FATAL);
187+
179188
}
180-
catch (clError& x)
181-
{
182-
x << x << endl;
183-
// if (x.Severity() == CL_FATAL)
184-
exit(1);
185-
//clRetry();
186-
//RestartUI(REENTER);
187-
}
189+
// catch (clError& x)
190+
// {
191+
// if (x.Severity() == CL_FATAL) {throw;} // Re-throw instead of exit - allows proper exception handling
192+
// }
188193
}
189-
//
190-
//-------------------------------------------------------------------------
191-
//
192-
// Moving the embedded MPI interfaces out of the (visual) way. If
193-
// necessary in the future, MPI code should be implemented in a
194-
// separate class and this code appropriate re-factored to be used as
195-
// an API for MPI class. Ideally, MPI code should not be part of the
196-
// roadrunner (application layer) code.
197-
//#include <synthesis/TransformMachines2/test/RR_MPI.h>
198-
//
199-
200194
//
201195
//-------------------------------------------------------------------------
202196
// Experimantal code not yet working
@@ -229,9 +223,9 @@ int main(int argc, char **argv)
229223
imagingMode="residual",
230224
rmode="norm"; // set to "norm" to match rWeightor.h
231225

232-
float cellSize=0;//refFreq=3e09, freqBW=3e9;
226+
float cellSize=0;
233227
float robust=0.0;
234-
int NX=0, nW=1;//cfBufferSize=512, cfOversampling=20, nW=1;
228+
int NX=0, nW=1;
235229
bool WBAwp=true;
236230
bool restartUI=false;
237231
bool doPointing=false;
@@ -270,6 +264,10 @@ int main(int argc, char **argv)
270264
{
271265
cerr << er.what() << endl;
272266
}
267+
catch(std::exception& e)
268+
{
269+
cerr << e.what() << endl;
270+
}
273271

274272
// An example code below for extracting the info from RRRetrunType (a std::unordered_map).
275273
// cerr << rrr[MAKEVB_TIME] << " " << rrr[NVIS] << " " << rrr[DATA_VOLUME] << " " << rrr[IMAGING_RATE] << " " << rrr[NVIS]/rrr[CUMULATIVE_GRIDDING_ENGINE_TIME] << " vis/sec" << endl;

0 commit comments

Comments
 (0)