Source
xxxxxxxxxx
gotblc = recToVec(regRec.asRecord("regions").asRecord("*1").asRecord("regions").asRecord("*1").asRecord("blc"));
//# tCasacRegionManager.cc: test the regions in the Regionhandler classes
//# Copyright (C) 2000,2001
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This program is free software; you can redistribute it and/or modify it
//# under the terms of the GNU General Public License as published by the Free
//# Software Foundation; either version 2 of the License, or(at your option)
//# any later version.
//#
//# This program is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
//# more details.
//#
//# You should have received a copy of the GNU General Public License along
//# with this program; if not, write to the Free Software Foundation, Inc.,
//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//# $Id: tRegionHandler.cc 20600 2009-05-11 09:33:40Z gervandiepen $
using namespace casa;
void writeTestString(const String& test) {
cout << "\n" << "*** " << test << " ***" << endl;
}
Vector<Double> recToVec(const Record& rec) {
uInt nfields = rec.nfields();
Vector<Double> vec(nfields);
vec[0] = rec.asRecord("*1").asDouble("value");
vec[1] = rec.asRecord("*2").asDouble("value");
if (nfields >= 3) {
vec[2] = rec.asRecord("*3").asDouble("value");
if (nfields >= 4) {
vec[3] = rec.asRecord("*4").asDouble("value");
}
}
return vec;
}
void compVecs(Vector<Double>& got, Vector<Double>& exp) {
Double epsilon = 1e-8;
for (uInt i=0; i<got.size(); i++) {
Double fracDiff = fabs((got[i]-exp[i])/exp[i]);
AlwaysAssert(fracDiff < epsilon, AipsError);
}
}
int main() {
String *parts = new String[2];
split(EnvironmentVariable::get("CASAPATH"), parts, 2, String(" "));
String datadir = parts[0] + "/data/regression/unittest/imageanalysis/Regions/";
delete [] parts;
const ImageInterface<Float> *myImage = new FITSImage(datadir + "imregion.fits");
const ImageInterface<Float> *myImageNoSpec = new FITSImage(datadir + "imregion_nospec.fits");
const ImageInterface<Float> *myImageDirOnly = new FITSImage(datadir + "imregion_dironly.fits");
String test, diagnostics, stokes, chans, box;
uInt nSelectedChannels;
Vector<uInt> chanEndPoints, polEndPoints;
CasacRegionManager::StokesControl stokesControl;
Record regRec;
CasacRegionManager rm(myImage->coordinates());
IPosition imShape = myImage->shape();
cout << "*** imShape " << imShape << endl;
Double box1 = 1.24795026;
Double box2 = 0.782552901;
Double box3 = 1.24794616;
Double box4 = 0.782555814;
Double box5 = 1.24794206;
Double box6 = 0.782558727;
Double box7 = 1.24793797;
Double box8 = 0.782561641;
Double chan0 = 4.73510000e+09;