diff --git a/Appl/CEP/CS1/CS1_DFTImager/src/DFTImager.cc~ b/Appl/CEP/CS1/CS1_DFTImager/src/DFTImager.cc~ deleted file mode 100644 index b164325ffff69418fb173eb717e2fef46b9f7c3b..0000000000000000000000000000000000000000 --- a/Appl/CEP/CS1/CS1_DFTImager/src/DFTImager.cc~ +++ /dev/null @@ -1,295 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by ASTRON, Adriaan Renting * - * renting@astron.nl * - * * - * 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#include <tables/Tables.h> -#include <tables/Tables/TableIter.h> -#include "DFTImager.h" -#include <casa/Quanta/MVEpoch.h> - -using namespace casa; - -enum CorrelationTypes {None=0,I=1,Q=2,U=3,V=4,RR=5,RL=6,LR=7,LL=8,XX=9,XY=10,YX=11,YY=12}; //found somewhere in AIPS++, don't remember where - -//===============>>> itoa <<<=============== -//ANSI C++ doesn't seem to have a decent function for this, or I'm not aware of it. Need to rename it to IntToStr(), to avoid confusion -std::string itoa(int value, int base=10) -{ // found on http://www.jb.man.ac.uk/~slowe/cpp/itoa.html - //maybe copyright Robert Jan Schaper, Ray-Yuan Sheu, Rodrigo de Salvo Braz, Wes Garland and John Maloney - enum { kMaxDigits = 35 }; - std::string buf; - buf.reserve( kMaxDigits ); // Pre-allocate enough space. - // check that the base if valid - if (base < 2 || base > 16) return buf; - int quotient = value; - // Translating number to string with base: - do { - buf += "0123456789abcdef"[ std::abs( quotient % base ) ]; - quotient /= base; - } while ( quotient ); - // Append the negative sign for base 10 - if ( value < 0 && base == 10) buf += '-'; - std::reverse( buf.begin(), buf.end() ); - return buf; -} - -namespace LOFAR -{ - namespace CS1 - { - //===============>>> DFTImager::DFTImager <<<=============== - /* initialize some meta data and get the datastorage the right size. */ - DFTImager::DFTImager(MS_File* InputMSfile, - Image_File*InputImageFile) - { - MSfile = InputMSfile; - Imagefile = InputImageFile; - NumAntennae = (*MSfile).itsNumAntennae; - NumPairs = (*MSfile).itsNumPairs; - NumBands = (*MSfile).itsNumBands; - NumChannels = (*MSfile).itsNumChannels; - NumPolarizations = (*MSfile).itsNumPolarizations; - NumTimeslots = (*MSfile).itsNumTimeslots; - AntennaNames = (*MSfile).itsAntennaNames; - Resolution = 41; - - PairsIndex.resize(NumPairs); - // Statistics = Cube<int>(NumBands, NumAntennae, NumAntennae, 0); - // PolarizationsToCheck.resize(NumPolarizations); - // DeterminePolarizationsToCheck(UseOnlyXpolarizations); - - TimeslotData.resize(NumPairs*NumBands); - for (int i = 0; i < NumPairs*NumBands; i++) - { TimeslotData[i].resize(NumPolarizations, NumChannels, WindowSize); - } - - int index = 0; - for (int i = 0; i < NumAntennae; i++) - { for(int j = i; j < NumAntennae; j++) - { PairsIndex[index] = pairii(i, j); - BaselineIndex[pairii(i, j)] = index++; - } - } - ComputeBaselineLengths(); - } - - //===============>>> DFTImager::~DFTImager <<<=============== - - DFTImager::~DFTImager() - { - } - - //===============>>> DFTImager::DetermineCorrelationsToCheck <<<=============== - /* create a list of polarizations we want to check, maybe we only want to to XY, YX */ - // void DFTImager::DeterminePolarizationsToCheck(bool UseOnlyXpolarizations) - // { - // if (UseOnlyXpolarizations) - // { - // bool noCorrError = true; - // for (int i = 0; i < NumPolarizations; i++) - // { - // switch((*MSfile).itsPolarizations[i]) - // { - // case None: - // case I: - // case RR: - // case LL: - // case XX: - // case YY: - // if (UseOnlyXpolarizations) - // PolarizationsToCheck[i] = false; - // break; - // case Q: - // case U: - // case V: - // case RL: - // case LR: - // case XY: - // case YX: - // noCorrError = false; - // if (UseOnlyXpolarizations) - // PolarizationsToCheck[i] = true; - // break; - // } - // } - // if (noCorrError) - // { - // cout << "There are no crosspolarizations to flag!"; - // exit(1); - // } - // } - // else - // { - // for (int i = 0; i < NumPolarizations; i++) - // { PolarizationsToCheck[i] = true; - // } - // } - // } - - //===============>>> DFTImager::ComputeBaselineLengths <<<=============== - /* compute baseline lengths, and determine the longest one.*/ - void DFTImager::ComputeBaselineLengths() - { - MaxBaselineLength = 0.0; - BaselineLengths.resize(NumPairs); - //Antenna positions - MSAntenna antennas = (*MSfile).antennas(); - ROArrayColumn<Double> position(antennas, "POSITION"); - for (int i = 0; i < NumAntennae; i++ ) - { - for (int j = i; j < NumAntennae; j++) - { - Vector<Double> p(position(i) - position(j)); - double temp = sqrt(p(0)*p(0) + p(1)*p(1) + p(2)*p(2)); - BaselineLengths[BaselineIndex[pairii(i, j)]] = temp; - if (temp > MaxBaselineLength && temp < 3000000) //radius of the Earth in meters? WSRT sometimes has fake telescopes at 3854243 - { MaxBaselineLength = temp; // non-existent antenna's can have position (0,0,0) - } - } - } - } - - //===============>>> DFTImager::ImageTimeslot <<<=============== - /* This function iterates over baseline and band and uses FlagBaselineBand() to determine - for each one if it needs to be flagged. It treats the autocorrelations separately, - to detect entire malfunctioning telescopes. Finally it writes the flags. - */ -/* void DFTImager::ImageTimeslot() - { - Cube<bool> Image(NumPolarizations, NumChannels, NumPairs*NumBands, false); - vector<bool> test(NumPairs*NumBands); - for (int i = 0; i < NumBands; i++) - { - vector< vector<double> > CrossCorrRMS(NumPolarizations, NumPairs - NumAntennae); - for(int j = 0; j < NumAntennae; j++) - { - for(int k = j+1; k < NumAntennae; k++) - { - int index = i*NumPairs + BaselineIndex[pairii(j, k)]; - Matrix<Bool> image = Image.xyPlane(index); - if ((BaselineLengths[BaselineIndex[pairii(j, k)]] < 3000000))//radius of the Earth in meters? WSRT sometimes has fake telescopes at 3854243 m - { //we skip the non-existent telescopes - test = ImageBaselineBand(&image, - &(TimeslotData[index]), - Position); - } - } - } - //this code could be separated in to different functions - for(int j = 0; j < NumAntennae; j++) //write the data - { - for(int k = j; k < NumAntennae; k++) - { - int index = i*NumPairs + BaselineIndex[pairii(j, k)]; - Matrix<bool> image = Image.xyPlane(index); - (*Imagefile).WriteImageData(&image); - } - } - } - }*/ - - //===============>>> DFTImager::UpdateTimeslotData <<<=============== - /* This function reads the visibility data for one timeslot and checks if - a mosaicing mode is active*/ - /* The datastructure Timeslotdata is rather complex because it flattens - half-filled antenna x antenna x bands matrix into a vector of NumPairs X bands length. */ - bool DFTImager::UpdateTimeslotData(vector<int>* OldFields, - vector<int>* OldBands, - int* TimeCounter, - Table* TimeslotTable, - double* Time) - { - int rowcount = (*TimeslotTable).nrow(); - ROTableVector<Int> antenna1((*TimeslotTable), "ANTENNA1"); - ROTableVector<Int> antenna2((*TimeslotTable), "ANTENNA2"); - ROTableVector<Int> bandnr ((*TimeslotTable), "DATA_DESC_ID"); - ROTableVector<Int> fieldid ((*TimeslotTable), "FIELD_ID"); - ROTableVector<Double> time ((*TimeslotTable), "TIME_CENTROID");//for testing purposes - ROArrayColumn<Complex> data ((*TimeslotTable), "DATA"); - Cube<Complex> Data(NumPolarizations, NumChannels, rowcount); - - data.getColumn(Data); //We're not checking Data.nrow() Data.ncolumn(), assuming all data is the same size. - (*Time) = time(0);//for testing purposes, might be useful in the future - - bool NewField_or_Frequency = false; - - for (int i = 0; i < rowcount; i++) - { - int bi = BaselineIndex[pairii(antenna1(i), antenna2(i))]; - int field = fieldid(i); - int band = bandnr(i); - int index = (band % NumBands) * NumPairs + bi; - if ((*TimeCounter) > WindowSize - 1) - { - if (field != (*OldFields)[bi]) //pointing mosaicing - { NewField_or_Frequency = true; - } - if (band != (*OldBands)[index]) //frequency mosaicing - { NewField_or_Frequency = true; - } - } - (*OldFields)[bi] = field; - (*OldBands)[index] = band; - - TimeslotData[index].xyPlane((*TimeCounter) % WindowSize) = Data.xyPlane(i); //TimeslotData is only WindowSize size! - } - (*TimeCounter)++; //we want to reset if we detect a gap in DATA_DESC_ID or FIELD. Maybe TIME too??? - return NewField_or_Frequency; //assuming everybody is changing field or frequency at the same time! - } - - //===============>>> DFTImager::FlagDataOrBaselines <<<=============== - /* This function iterates over the data per timeslot and uses Flagtimeslot() - to actually flag datapoints (if flagDatapoints), and entire baselines (if flagRMS)*/ - void DFTImager::MakeImage(int Resolution) - { - TableIterator timeslot_iter = (*MSfile).TimeslotIterator(); - int TimeCounter = 0; - double Time = 0.0;//for testing purposes - vector<int> OldFields(NumPairs); //to check on multipointing and mosaicing - vector<int> OldBands(NumPairs*NumBands); //to check on multifrequency and freq mosaicing - vector< Cube<float> > Image(NumBands); - - int step = NumTimeslots / 10 + 1; //not exact but it'll do - int row = 0; - - while (!timeslot_iter.pastEnd()) - { - Table TimeslotTable = timeslot_iter.table(); - bool NewFieldorFreq = UpdateTimeslotData(&OldFields, - &OldBands, - &TimeCounter, - &TimeslotTable, - &Time); - if (NewFieldorFreq) - { - cout << "Error: current version can not handle multiple fields/frequqncies in dataset." << endl; - break; - } - cout << "Processing: " << MVTime(Time/(24*3600)).string(MVTime::YMD) << endl; //for testing purposes - - ImageTimeslot(); - timeslot_iter++; - if (row++ % step == 0) // to tell the user how much % we have processed, - { cout << 10*(row/step) << "%" << endl; //not very accurate for low numbers of timeslots, but it'll do for now - } - } - Imagefile->WriteImage(&Image); - } - //===============>>> DFTImager <<<=============== - } //namespace CS1 -}; //namespace LOFAR diff --git a/Appl/CEP/CS1/CS1_DFTImager/src/DFTImager.h~ b/Appl/CEP/CS1/CS1_DFTImager/src/DFTImager.h~ deleted file mode 100644 index a5abade15aa341c4490c8b96a1579b370f013de8..0000000000000000000000000000000000000000 --- a/Appl/CEP/CS1/CS1_DFTImager/src/DFTImager.h~ +++ /dev/null @@ -1,90 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by ASTRON, Adriaan Renting * - * renting@astron.nl * - * * - * 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#ifndef __IMAGER_DFTIMAGER_H__ -#define __IMAGER_DFTIMAGER_H__ - -#include <casa/Arrays.h> -#include <utility> -#include <vector> -#include <list> -#include <map> -#include "MS_File.h" -#include "Image_File.h" - -namespace LOFAR -{ - namespace CS1 - { - using casa::Cube; - using casa::Matrix; - using casa::Complex; - using casa::Int; - using casa::Double; - using casa::Bool; - using casa::Table; - using std::list; - using std::vector; - - typedef pair<int, int> pairii; - - class DFTImager - { - public: - DFTImager(MS_File* MSfile, - Image_File* Imagefile); - ~DFTImager(); - - void MakeImage(int Resolution); - - protected: - int NumAntennae; - int NumPairs; - int NumBands; - int NumChannels; - int NumPolarizations; - int WindowSize; - int NumTimeslots; - double MinThreshold; - double MaxThreshold; - double MaxBaselineLength; - vector<double> BaselineLengths; - vector<pairii> PairsIndex; - map<pairii, int> BaselineIndex; - vector< Cube<Complex> > TimeslotData; - vector<casa::String> AntennaNames; - Cube< int > Statistics; - int Resolution; - - MS_File* MSfile; - Image_File* Imagefile; - - private: - void ComputeBaselineLengths(); - bool UpdateTimeslotData(vector<int>* OldFields, - vector<int>* OldBands, - int* TimeCounter, - Table* TimeslotTable, - double* Time); - void ImageTimeslot(); - }; // DFTImager - }; // namespace CS1 -}; // namespace LOFAR - -#endif // __IMAGER_DFTIMAGER_H__ diff --git a/Appl/CEP/CS1/CS1_DFTImager/src/Image_File.cc~ b/Appl/CEP/CS1/CS1_DFTImager/src/Image_File.cc~ deleted file mode 100644 index 8f7f69363380df2479bc183bccbc1f4ad9bf6371..0000000000000000000000000000000000000000 --- a/Appl/CEP/CS1/CS1_DFTImager/src/Image_File.cc~ +++ /dev/null @@ -1,396 +0,0 @@ -//# tPagedImage.cc: This program tests the PagedImage class -//# Copyright (C) 1994,1995,1996,1999,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$ -//#-------------------------------------------------------------------------- - -#include<casa/aips.h> -#include <images/Images/PagedImage.h> -#include <images/Images/ImageInfo.h> -#include <images/Images/SubImage.h> -#include <images/Images/ImageUtilities.h> -//#include <trial/ImgCrdSys/ImageCoordinate.h> - -#include <casa/Arrays/Vector.h> -#include <casa/Arrays/Cube.h> -#include <casa/Exceptions/Error.h> -#include <casa/Arrays/IPosition.h> -#include <tables/Tables.h> -#include <casa/BasicSL/String.h> - -#include <casa/stdlib.h> -#include <casa/iostream.h> - -#include <casa/namespace.h> -#include "Image_File.h" - - -using namespace casa; - -namespace LOFAR -{ - namespace CS1 - { - - //===============>>> Image_file::Image_file <<<=============== - - Image_File::Image_File(const std::string& imagename) - { - ImageName = imagename; - } - - //===============>>> Image_file::~Image_file <<<=============== - - Image_File::~Image_File() - { - delete Image; - } - - //===============>>> Image_file::init <<<=============== - - void Image_File::init(casa::IPosition shape, size_t length) - { -// Image = new casa::PagedImage(shape, NULL, Table::Update); - } - - //===============>>> Image_file::~WriteImage <<<=============== - - void Image_File::WriteImage(std::vector< casa::Cube<float> >* image) - { - casa::Cube<float> Bal = (*image)[0]; - init(Bal.shape(), image->size()); - Image->putSlice((*image[0]), casa::IPosition(3, 0, 0, 0), casa::IPosition(3, 0, 0, 0)); - } - - - -/* -//#predeclarations -void getArguments(int argc, char **argv, Bool &verbose); -Bool fudgedEquality(Float a, Float b); -void deleteFile(const String &filename); -ImageCoordinate build3Dcoords(); -void createStandardImageOnDisk(const String &filename); -void describeImage(const String &message, const PagedImage<Float> &image); -void testConstructors(); -void testSetMemberFunctions(); -void testArrayofImagesAndAssignmentOperator(); - -//# define mega global variables -Bool verbose_; -const Float TEST_PIXEL_VALUE = 99.99; -const String STANDARD = "image-standard"; -const String NAME0 = "image-test-file_0"; -const String NAME1 = "image-test-file_1"; -const String NAME2 = "image-test-file_2"; -const String NAME3 = "image-test-file_3"; -const String NAME4 = "image-test-file_4"; -const String NAME5 = "image-test-file_5"; -const String NAME6 = "image-test-file_6"; -const String NAME7 = "image-test-file_7"; -const String NAME8 = "image-test-file_8"; -const String NAME9 = "image-test-file_9"; - -int main(int argc, char **argv) -{ - getArguments(argc, argv, verbose_); - createStandardImageOnDisk(STANDARD); - try { - testConstructors(); - testSetMemberFunctions(); - testArrayofImagesAndAssignmentOperator(); - deleteFile(STANDARD); - cout << "OK" << endl; - } catch (AipsError x) { - cerr << "Caught Exception: " << x.getMesg() << endl; - } - return 0; -} - -// fill debug variable -void getArguments(int argc, char **argv, Bool &verbose) -{ - verbose = False; - for(uInt i=0; i< argc; i++) - if(!strcmp(argv [i], "-v")) - verbose = True; -} - -// equality function for floats -Bool fudgedEquality(Float a, Float b) -{ - Float absA = fabs(a); - Float absB = fabs(b); - Float delta = fabs(absA - absB); - Float margin; - if(absA > absB) - margin = absA / 1.0e5; - else - margin = absB / 1.0e5; - if(delta > margin) { - return False; - } - else { - return True; - } -} - -// function which deletes files on disk -void deleteFile(const String &filename) -{ - String command = "rm -rf "; - command += filename; - system(command); -} - -// function to print Image data -void describeImage(const String &message, const PagedImage<Float> &image) -{ - cout << message << " shape: "<< image.shape() << endl; -// * - cout << "coordinates, axisNames: " - << image.coordinates().axisNames() << endl; - cout << " referencePixels: " - << image.coordinates().referencePixels() << endl; - cout << " referenceValues: " - << image.coordinates().referenceValues()<< endl; - cout << " deltas: " - << image.coordinates().deltas()<< endl; - cout << " shape: " - << image.coordinates().imageShape() << endl; -// * / - cout << " ok: "<< image.ok()<< endl; -} - -// build a set of ImageCoordinates in three dimensions -ImageCoordinate build3Dcoords() -{ - // we need to know a projection method - here it is Global Sinusoid - ProjectedPosition::Type myMethod(ProjectedPosition::GLS); - // we need to know what form the coordinates are in - here it is RA & Dec - SkyPosition::Type myVectorType(SkyPosition::EQUATORIAL); - // we need to know the epoch of the coordinates - SkyPosition::Epoch myEpoch(SkyPosition::J2000); - // we need to know the vector itself. - Vector<Double> myCoords(2); - myCoords(0) = 122.35; - myCoords(1) = -33.7764; - // we need to know the position of the observer. - // Let's create an EarthPosition with full description of all parameters. - // We need a type - GEOCENTRIC seems good. - EarthPosition::Type theType(EarthPosition::GEOCENTRIC); - // We need the time and date of the observation... - Double julianDate = 2449376.0; - // and we can add on the UT. - julianDate += 16.52/24.0; - // we need the coordinates of our position. - Vector<Double> ourPosition(3); - // geocentric longitude (in degrees) goes in the first field of the vector. - ourPosition(0) = 107.2334666; - // geocentric latitude (in degrees) goes in the second field. - ourPosition(1) = 34.1562394; - // geocentric radius (in meters) goes in the last field. - ourPosition(2) = 6372139.592; - // then use these to build our EarthPosition. - EarthPosition myObs(theType, julianDate, ourPosition); - // we need to know a rotation - here it is zero. - Double myRot = 0; - // we need to know where the spherical position is to be on our 2-d - // projection i.e. what pixel is associated with my object's position? - Vector<Double> thePixel(2); - thePixel(0) = 55.0; - thePixel(1) = 526.3; - // finally, we need to know the number of spherical units per integer on - // our 2-d projection (i.e. binning per pixel). - Vector<Double> theBinning(2); - theBinning(0) = 3.04e-03; - theBinning(1) = 3.6255e-03; - // Now we can make fruit of our labor - the ProjectedPosition itself. - ProjectedPosition myMapping(myMethod, myVectorType, myEpoch, myCoords, - myObs, myRot, thePixel, theBinning); - - // we need to know what the units are of the measured value - MeasuredValue::Type myValueUnit(MeasuredValue::RADIO_VELOCITY); - // we need to know what the above units are in reference - // here it is the velocity of the earth. - ReferenceValue myRefValue(ReferenceValue::VELOCITY, 9.56e+03); - // we need to know the value of the measurement - Double myValue(9.5688823e+03); - // we need to know the binning per "pixel" - Double myBin(5.63e-04); - // we need to know the position on the "number line" of our value - Double myValuePos(27.3); - // Now we may construct the LinearAxis itself. - LinearAxis myLinearAxis(myValueUnit,myValue,myRefValue,myBin,myValuePos); - - ImageCoordinate coords; - coords.addAxis(myMapping); - coords.addAxis(myLinearAxis); - return coords; -} - -// build an Image and store in a file on disk -void createStandardImageOnDisk(const String &filename) -{ - if(verbose_) cout<< "-- createStandardImageOnDisk --"<< endl; - - ImageCoordinate coords(build3Dcoords()); - IPosition imageShape(3, 50,47,31); - - PagedImage<Float> standard(imageShape, coords, filename); - standard.set(TEST_PIXEL_VALUE); - - if(verbose_) describeImage("standard image", standard); -} - -// these are the constructors to test: -// PagedImage(const IPosition &shape, const MinimalCoords &coordinateInfo, -// const String &nameOfNewFile, uInt rowNumber); -// PagedImage(const IPosition &shape, const Array<T> &array, -// const MinimalCoords &coordinateInfo, -// const String &nameOfNewFile, uInt rowNumber); -// PagedImage(const String &filename, uInt rowNumber); -// PagedImage(const PagedImage<T> &other); -// -void testConstructors() -{ - if (verbose_) cout << "-- testConstructors --" << endl; - { - IPosition shape(3,10,10,4); - ImageCoordinate coords(build3Dcoords()); - - PagedImage<Float> image1(shape, coords, NAME0); - if (verbose_) - describeImage("shape, coords, filename ctor: ", image1); - - PagedImage<Float> image2(shape, coords, NAME1, True); - - if (verbose_) - describeImage("array, array, coords, filename, masking? ctor: ", image2); - - PagedImage<Float> image3(STANDARD); - if (verbose_) describeImage("old file ctor: ", image3); - if (image3(IPosition(3,5,4,3)) != TEST_PIXEL_VALUE) - throw(AipsError("image3, file-constructed image, wrong pixel value")); - if (!image3.ok()) - throw(AipsError("file-constructed image not ok")); - - PagedImage<Float> *image4 = new PagedImage<Float>(image3); - if(verbose_) - describeImage("Copy ctor: ", *image4); - if((*image4)(IPosition(3,5,4,3)) != TEST_PIXEL_VALUE) - throw(AipsError("image4, file assigned image, wrong pixel value")); - if(!image4->ok()) - throw(AipsError("file-constructed image not ok")); - delete image4; - } - - deleteFile(NAME0); - deleteFile(NAME1); -} - -// test some of the data member manipulation functions -void testSetMemberFunctions() -{ - if(verbose_) cout<< "-- test set member functions --"<< endl; - { - ImageCoordinate coords; - { - PagedImage<Float> image6(IPosition(3,10,10,4), coords, NAME2); - - if(verbose_) describeImage("shape, coords, filename ctor: ", image6); - if(image6.ok()) - throw(AipsError("shape-constructed image6 is ok, but shouldn't be!")); - } - - coords = build3Dcoords(); - PagedImage<Float> image6(IPosition(3,10,10,4), coords, NAME2); - if(!image6.ok()) - throw(AipsError("shape-constructed image6 - is not ok!")); - image6.rename(NAME2); - if(verbose_) describeImage("image6, after rename", image6); - if(!image6.ok()) - throw(AipsError("image6 after rename - not ok")); - - image6.setCoordinateInfo(build3Dcoords()); - if(verbose_) describeImage("image6, after setCoordinates", image6); - if(!image6.ok()) - throw(AipsError("image6 after setCoordinates - not ok")); - } - - deleteFile(NAME2); -} - -// -void testArrayofImagesAndAssignmentOperator() -{ - if(verbose_) cout<< "-- test array of images --"<< endl; -// * - const uInt max = 10; - String filenames [max]; - filenames [0] = NAME0; - filenames [1] = NAME1; - filenames [2] = NAME2; - filenames [3] = NAME3; - filenames [4] = NAME4; - filenames [5] = NAME5; - filenames [6] = NAME6; - filenames [7] = NAME7; - filenames [8] = NAME8; - filenames [9] = NAME9; - { - Image<Float> images [max]; - for(uInt i=0; i< max; i++) { - if(verbose_) cout<< "-- image array "<< i<< " --"<< endl; - if(i%2) { - images [i] = Image<Float>(IPosition(2,10,10)); - images [i].setCoordinateInfo(MinimalCoords()); - images [i].setName(filenames [i]); - if(verbose_) - describeImage("shape constructed image, setCoords, setName in array", - images [i]); - } // if i is odd - else { - images [i] = - Image<Float>(IPosition(i+1,5), MinimalCoords(), filenames [i]); - if(verbose_) - describeImage("shape,coords,name constructed image in array,", - images [i]); - } // else - if(!images[i].ok()) - throw(AipsError("one of array of images not ok")); - } // for i - } // scope - - if(verbose_) cout<< "-- about to delete image files --"<< endl; - - for(uInt i=0; i< max; i++) - deleteFile(filenames [i]); -// * / -} -*/ - //===============>>> Image_File <<<=============== - } -} \ No newline at end of file diff --git a/Appl/CEP/CS1/CS1_DFTImager/src/Image_File.h~ b/Appl/CEP/CS1/CS1_DFTImager/src/Image_File.h~ deleted file mode 100644 index c3391201e618e6977c944cc7849615545dfad4c2..0000000000000000000000000000000000000000 --- a/Appl/CEP/CS1/CS1_DFTImager/src/Image_File.h~ +++ /dev/null @@ -1,370 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by ASTRON, Adriaan Renting * - * renting@astron.nl * - * * - * 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -//# based on tPagedImage.cc: This program tests the PagedImage class -//# Copyright (C) 1994,1995,1996,1999,2000,2001 -//# Associated Universities, Inc. Washington DC, USA. -//# -#ifndef __IMAGER_IMAGER_FILE_H__ -#define __IMAGER_IMAGER_FILE_H__ - -#include <vector> -#include <string> - -#include<casa/aips.h> -#include <images/Images/PagedImage.h> -//#include <trial/ImgCrdSys/ImageCoordinate.h> - -//#include <casa/Arrays/Vector.h> -#include <casa/Arrays/Cube.h> -//#include <casa/Exceptions/Error.h> -#include <casa/Arrays/IPosition.h> -//#include <tables/Tables.h> -//#include <casa/BasicSL/String.h> - -//#include <casa/stdlib.h> -//#include <casa/iostream.h> - -//#include <casa/namespace.h> -namespace LOFAR -{ - namespace CS1 - { - class Image_File - { - public: - Image_File(const std::string& imagename); - ~Image_File(); - void WriteImage(vector< casa::Cube<float> >* image); - - protected: - std::string ImageName; - casa::PagedImage<float>* Image; - void init(casa::IPosition shape); - private: - }; // Image_File - }; //namespace CS1 -}; //namespace LOFAR - -/* -//#predeclarations -void getArguments(int argc, char **argv, Bool &verbose); -Bool fudgedEquality(Float a, Float b); -void deleteFile(const String &filename); -ImageCoordinate build3Dcoords(); -void createStandardImageOnDisk(const String &filename); -void describeImage(const String &message, const PagedImage<Float> &image); -void testConstructors(); -void testSetMemberFunctions(); -void testArrayofImagesAndAssignmentOperator(); - -//# define mega global variables -Bool verbose_; -const Float TEST_PIXEL_VALUE = 99.99; -const String STANDARD = "image-standard"; -const String NAME0 = "image-test-file_0"; -const String NAME1 = "image-test-file_1"; -const String NAME2 = "image-test-file_2"; -const String NAME3 = "image-test-file_3"; -const String NAME4 = "image-test-file_4"; -const String NAME5 = "image-test-file_5"; -const String NAME6 = "image-test-file_6"; -const String NAME7 = "image-test-file_7"; -const String NAME8 = "image-test-file_8"; -const String NAME9 = "image-test-file_9"; - -int main(int argc, char **argv) -{ - getArguments(argc, argv, verbose_); - createStandardImageOnDisk(STANDARD); - try { - testConstructors(); - testSetMemberFunctions(); - testArrayofImagesAndAssignmentOperator(); - deleteFile(STANDARD); - cout << "OK" << endl; - } catch (AipsError x) { - cerr << "Caught Exception: " << x.getMesg() << endl; - } - return 0; -} - -// fill debug variable -void getArguments(int argc, char **argv, Bool &verbose) -{ - verbose = False; - for(uInt i=0; i< argc; i++) - if(!strcmp(argv [i], "-v")) - verbose = True; -} - -// equality function for floats -Bool fudgedEquality(Float a, Float b) -{ - Float absA = fabs(a); - Float absB = fabs(b); - Float delta = fabs(absA - absB); - Float margin; - if(absA > absB) - margin = absA / 1.0e5; - else - margin = absB / 1.0e5; - if(delta > margin) { - return False; - } - else { - return True; - } -} - -// function which deletes files on disk -void deleteFile(const String &filename) -{ - String command = "rm -rf "; - command += filename; - system(command); -} - -// function to print Image data -void describeImage(const String &message, const PagedImage<Float> &image) -{ - cout << message << " shape: "<< image.shape() << endl; -// * - cout << "coordinates, axisNames: " - << image.coordinates().axisNames() << endl; - cout << " referencePixels: " - << image.coordinates().referencePixels() << endl; - cout << " referenceValues: " - << image.coordinates().referenceValues()<< endl; - cout << " deltas: " - << image.coordinates().deltas()<< endl; - cout << " shape: " - << image.coordinates().imageShape() << endl; -// * / - cout << " ok: "<< image.ok()<< endl; -} - -// build a set of ImageCoordinates in three dimensions -ImageCoordinate build3Dcoords() -{ - // we need to know a projection method - here it is Global Sinusoid - ProjectedPosition::Type myMethod(ProjectedPosition::GLS); - // we need to know what form the coordinates are in - here it is RA & Dec - SkyPosition::Type myVectorType(SkyPosition::EQUATORIAL); - // we need to know the epoch of the coordinates - SkyPosition::Epoch myEpoch(SkyPosition::J2000); - // we need to know the vector itself. - Vector<Double> myCoords(2); - myCoords(0) = 122.35; - myCoords(1) = -33.7764; - // we need to know the position of the observer. - // Let's create an EarthPosition with full description of all parameters. - // We need a type - GEOCENTRIC seems good. - EarthPosition::Type theType(EarthPosition::GEOCENTRIC); - // We need the time and date of the observation... - Double julianDate = 2449376.0; - // and we can add on the UT. - julianDate += 16.52/24.0; - // we need the coordinates of our position. - Vector<Double> ourPosition(3); - // geocentric longitude (in degrees) goes in the first field of the vector. - ourPosition(0) = 107.2334666; - // geocentric latitude (in degrees) goes in the second field. - ourPosition(1) = 34.1562394; - // geocentric radius (in meters) goes in the last field. - ourPosition(2) = 6372139.592; - // then use these to build our EarthPosition. - EarthPosition myObs(theType, julianDate, ourPosition); - // we need to know a rotation - here it is zero. - Double myRot = 0; - // we need to know where the spherical position is to be on our 2-d - // projection i.e. what pixel is associated with my object's position? - Vector<Double> thePixel(2); - thePixel(0) = 55.0; - thePixel(1) = 526.3; - // finally, we need to know the number of spherical units per integer on - // our 2-d projection (i.e. binning per pixel). - Vector<Double> theBinning(2); - theBinning(0) = 3.04e-03; - theBinning(1) = 3.6255e-03; - // Now we can make fruit of our labor - the ProjectedPosition itself. - ProjectedPosition myMapping(myMethod, myVectorType, myEpoch, myCoords, - myObs, myRot, thePixel, theBinning); - - // we need to know what the units are of the measured value - MeasuredValue::Type myValueUnit(MeasuredValue::RADIO_VELOCITY); - // we need to know what the above units are in reference - // here it is the velocity of the earth. - ReferenceValue myRefValue(ReferenceValue::VELOCITY, 9.56e+03); - // we need to know the value of the measurement - Double myValue(9.5688823e+03); - // we need to know the binning per "pixel" - Double myBin(5.63e-04); - // we need to know the position on the "number line" of our value - Double myValuePos(27.3); - // Now we may construct the LinearAxis itself. - LinearAxis myLinearAxis(myValueUnit,myValue,myRefValue,myBin,myValuePos); - - ImageCoordinate coords; - coords.addAxis(myMapping); - coords.addAxis(myLinearAxis); - return coords; -} - -// build an Image and store in a file on disk -void createStandardImageOnDisk(const String &filename) -{ - if(verbose_) cout<< "-- createStandardImageOnDisk --"<< endl; - - ImageCoordinate coords(build3Dcoords()); - IPosition imageShape(3, 50,47,31); - - PagedImage<Float> standard(imageShape, coords, filename); - standard.set(TEST_PIXEL_VALUE); - - if(verbose_) describeImage("standard image", standard); -} - -// these are the constructors to test: -// PagedImage(const IPosition &shape, const MinimalCoords &coordinateInfo, -// const String &nameOfNewFile, uInt rowNumber); -// PagedImage(const IPosition &shape, const Array<T> &array, -// const MinimalCoords &coordinateInfo, -// const String &nameOfNewFile, uInt rowNumber); -// PagedImage(const String &filename, uInt rowNumber); -// PagedImage(const PagedImage<T> &other); -// -void testConstructors() -{ - if (verbose_) cout << "-- testConstructors --" << endl; - { - IPosition shape(3,10,10,4); - ImageCoordinate coords(build3Dcoords()); - - PagedImage<Float> image1(shape, coords, NAME0); - if (verbose_) - describeImage("shape, coords, filename ctor: ", image1); - - PagedImage<Float> image2(shape, coords, NAME1, True); - - if (verbose_) - describeImage("array, array, coords, filename, masking? ctor: ", image2); - - PagedImage<Float> image3(STANDARD); - if (verbose_) describeImage("old file ctor: ", image3); - if (image3(IPosition(3,5,4,3)) != TEST_PIXEL_VALUE) - throw(AipsError("image3, file-constructed image, wrong pixel value")); - if (!image3.ok()) - throw(AipsError("file-constructed image not ok")); - - PagedImage<Float> *image4 = new PagedImage<Float>(image3); - if(verbose_) - describeImage("Copy ctor: ", *image4); - if((*image4)(IPosition(3,5,4,3)) != TEST_PIXEL_VALUE) - throw(AipsError("image4, file assigned image, wrong pixel value")); - if(!image4->ok()) - throw(AipsError("file-constructed image not ok")); - delete image4; - } - - deleteFile(NAME0); - deleteFile(NAME1); -} - -// test some of the data member manipulation functions -void testSetMemberFunctions() -{ - if(verbose_) cout<< "-- test set member functions --"<< endl; - { - ImageCoordinate coords; - { - PagedImage<Float> image6(IPosition(3,10,10,4), coords, NAME2); - - if(verbose_) describeImage("shape, coords, filename ctor: ", image6); - if(image6.ok()) - throw(AipsError("shape-constructed image6 is ok, but shouldn't be!")); - } - - coords = build3Dcoords(); - PagedImage<Float> image6(IPosition(3,10,10,4), coords, NAME2); - if(!image6.ok()) - throw(AipsError("shape-constructed image6 - is not ok!")); - image6.rename(NAME2); - if(verbose_) describeImage("image6, after rename", image6); - if(!image6.ok()) - throw(AipsError("image6 after rename - not ok")); - - image6.setCoordinateInfo(build3Dcoords()); - if(verbose_) describeImage("image6, after setCoordinates", image6); - if(!image6.ok()) - throw(AipsError("image6 after setCoordinates - not ok")); - } - - deleteFile(NAME2); -} - -// -void testArrayofImagesAndAssignmentOperator() -{ - if(verbose_) cout<< "-- test array of images --"<< endl; -// * - const uInt max = 10; - String filenames [max]; - filenames [0] = NAME0; - filenames [1] = NAME1; - filenames [2] = NAME2; - filenames [3] = NAME3; - filenames [4] = NAME4; - filenames [5] = NAME5; - filenames [6] = NAME6; - filenames [7] = NAME7; - filenames [8] = NAME8; - filenames [9] = NAME9; - { - Image<Float> images [max]; - for(uInt i=0; i< max; i++) { - if(verbose_) cout<< "-- image array "<< i<< " --"<< endl; - if(i%2) { - images [i] = Image<Float>(IPosition(2,10,10)); - images [i].setCoordinateInfo(MinimalCoords()); - images [i].setName(filenames [i]); - if(verbose_) - describeImage("shape constructed image, setCoords, setName in array", - images [i]); - } // if i is odd - else { - images [i] = - Image<Float>(IPosition(i+1,5), MinimalCoords(), filenames [i]); - if(verbose_) - describeImage("shape,coords,name constructed image in array,", - images [i]); - } // else - if(!images[i].ok()) - throw(AipsError("one of array of images not ok")); - } // for i - } // scope - - if(verbose_) cout<< "-- about to delete image files --"<< endl; - - for(uInt i=0; i< max; i++) - deleteFile(filenames [i]); -// * / -} -*/ -#endif diff --git a/Appl/CEP/CS1/CS1_DFTImager/src/Imager.cc~ b/Appl/CEP/CS1/CS1_DFTImager/src/Imager.cc~ deleted file mode 100644 index 5db562e2d3e4d9e40bea8678f746bac6cad52c11..0000000000000000000000000000000000000000 --- a/Appl/CEP/CS1/CS1_DFTImager/src/Imager.cc~ +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by ASTRON, Adriaan Renting * - * renting@astron.nl * - * * - * 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <libgen.h> -#include <PLC/ACCmain.h> -#include <casa/Exceptions.h> -#include <CS1_Imager/ImagerProcessControl.h> - -int main(int argc, char *argv[]) -{ - try - { - INIT_LOGGER(basename(argv[0])); - LOFAR::CS1::ImagerProcessControl myProcess; - return LOFAR::ACC::PLC::ACCmain(argc, argv, &myProcess); - } //try - catch(casa::AipsError& err) - { - std::cerr << "Aips++ error detected: " << err.getMesg() << std::endl; - return -2; - } - catch(exception& e) - { - std::cerr << "** PROBLEM **: Unhandled exception caught: " << e.what() << std::endl; - return -3; - } - catch(...) - { - std::cerr << "** PROBLEM **: Unhandled unknown exception caught!" << std::endl; - return -4; - } -} diff --git a/Appl/CEP/CS1/CS1_DFTImager/src/ImagerProcessControl.cc~ b/Appl/CEP/CS1/CS1_DFTImager/src/ImagerProcessControl.cc~ deleted file mode 100644 index 026dc2ae71fb95ccf576870808f05b0bb4a9ff24..0000000000000000000000000000000000000000 --- a/Appl/CEP/CS1/CS1_DFTImager/src/ImagerProcessControl.cc~ +++ /dev/null @@ -1,151 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by ASTRON, Adriaan Renting * - * renting@astron.nl * - * * - * 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include <iostream> -#include <cstdlib> -#include <iostream> -#include <casa/Inputs/Input.h> -#include <ms/MeasurementSets.h> - -#include <CS1_DFTImager/ImagerProcessControl.h> -#include "MS_File.h" -#include "Image_File.h" -#include "DFTImager.h" - -#define IMAGER_VERSION "0.10" - -namespace LOFAR -{ - namespace CS1 - { - //===============>>> ImagerProcessControl::ImagerProcessControl <<<=============== - ImagerProcessControl::ImagerProcessControl() - : ProcessControl() - { - itsMS = NULL; - itsImage = NULL; - itsImager = NULL; - } - - //===============>>> ImagerProcessControl::~ImagerProcessControl <<<============== - ImagerProcessControl::~ImagerProcessControl() - { - if (itsMS) - { delete itsMS; - } - if (itsImage) - { delete itsImage; - } - if (itsImager) - { delete itsImager; - } - } - - //===============>>> ImagerProcessControl::define <<<============================== - tribool ImagerProcessControl::define() - { - LOFAR::ACC::APS::ParameterSet* ParamSet = LOFAR::ACC::APS::globalParameterSet(); - itsMSName = ParamSet->getString("ms"); - itsImageName = ParamSet->getString("image"); - itsResolution = ParamSet->getInt32("resolution"); - return true; - } - - //===============>>> ImagerProcessControl::run <<<================================= - tribool ImagerProcessControl::run() - { - try{ - std::cout << "Runnning Imager please wait..." << std::endl; - itsImager->MakeImage(); - } - catch(casa::AipsError& err) - { - std::cerr << "Aips++ error detected: " << err.getMesg() << std::endl; - return false; - } - return true; - } - - //===============>>> ImagerProcessControl::init <<<================================ - tribool ImagerProcessControl::init() - { - try { - using std::cout; - using std::cerr; - using std::endl; - - cout << string(IMAGER_VERSION) + string(" DFT Imager by Ronald Nijboer and Adriaan Renting\n") + - string("This is experimental software, please report errors or requests to renting@astron.nl\n") + - string("Documentation can be found at: www.astron.nl/~renting\n"); - cout << itsMS << endl; - itsMS = new MS_File(itsMSName); - itsImage = new Image_File(itsImageName); - itsImager = new DFTImager (itsMS, itsImage, itsResolution); - } - catch(casa::AipsError& err) - { - std::cerr << "Aips++ error detected: " << err.getMesg() << std::endl; - return false; - } - return true; - } - - //===============>>> ImagerProcessControl::pause <<<=============================== - tribool ImagerProcessControl::pause(const std::string&) - { return false; - } - - //===============>>> ImagerProcessControl::quit <<<================================ - tribool ImagerProcessControl::quit() - { - if (itsMS) - { - delete itsMS; - itsMS = NULL; - } - if (itsImager) - { - delete itsImager; - itsImager = NULL; - } - return true; - } - - //===============>>> ImagerProcessControl::recover <<<============================= - tribool ImagerProcessControl::recover(const std::string&) - { return false; - } - - //===============>>> ImagerProcessControl::reinit <<<============================== - tribool ImagerProcessControl::reinit(const std::string&) - { return false; - } - - //===============>>> ImagerProcessControl::askInfo <<<============================= - std::string ImagerProcessControl::askInfo(const std::string&) - { return std::string(""); - } - - //===============>>> ImagerProcessControl::snapshot <<<============================ - tribool ImagerProcessControl::snapshot(const std::string&) - { return false; - } - } //namespace CS1 -}; //namespace LOFAR diff --git a/Appl/CEP/CS1/CS1_DFTImager/src/MS_File.cc~ b/Appl/CEP/CS1/CS1_DFTImager/src/MS_File.cc~ deleted file mode 100644 index c00f61aed4b005381ae3bf16178cf13c55706450..0000000000000000000000000000000000000000 --- a/Appl/CEP/CS1/CS1_DFTImager/src/MS_File.cc~ +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by ASTRON, Adriaan Renting * - * renting@astron.nl * - * * - * 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#include <casa/BasicMath/Math.h> -#include <casa/Arrays.h> -//#include <casa/Quanta/MVTime.h> - -#include <iostream> - -#include "MS_File.h" - - -using namespace casa; - -namespace LOFAR -{ - namespace CS1 - { - - //===============>>> MS_File::MS_File <<<=============== - - MS_File::MS_File(const std::string& msname) - { - MSName = msname; - MS = new MeasurementSet(MSName, Table::Update); - init(); - } - - //===============>>> MS_File::~MS_File <<<=============== - - MS_File::~MS_File() - { - delete MS; - } - - //===============>>> MS_File::init <<<=============== - - void MS_File::init() - { - //Number of samples - itsNumSamples = (*MS).nrow(); - std::cout << "NumSamples" << itsNumSamples << std::endl; - //Number of Fields - MSField fields = (*MS).field(); - itsNumFields = fields.nrow(); - std::cout << "NumFields" << itsNumFields << std::endl; - - //Number of Antennae - MSAntenna antennae = (*MS).antenna(); - itsNumAntennae = antennae.nrow(); - std::cout << "NumAntennae" << itsNumAntennae << std::endl; - - //Antenna Names - ROScalarColumn<String> ANT_NAME_col(antennae, "NAME"); - Vector<String> ant_names = ANT_NAME_col.getColumn(); - ant_names.tovector(itsAntennaNames); - - //Number of channels in the Band - MSSpectralWindow spectral_window = (*MS).spectralWindow(); - ROScalarColumn<Int> NUM_CHAN_col(spectral_window, "NUM_CHAN"); - itsNumChannels = NUM_CHAN_col(0); - std::cout << "NumChannels" << itsNumChannels << std::endl; - - //Number of polarizations - MSPolarization polarization = (*MS).polarization(); - ROScalarColumn<Int> NUM_CORR_col(polarization, "NUM_CORR"); - itsNumPolarizations = NUM_CORR_col(0); - ROArrayColumn<Int> CORR_TYPE_col(polarization, "CORR_TYPE"); - itsPolarizations.resize(itsNumPolarizations); - CORR_TYPE_col.get(0, itsPolarizations); - std::cout << "NumPolarizations" << itsNumPolarizations << std::endl; - - //calculate theoretical noise level - ROScalarColumn<Double> EXPOSURE_col((*MS), "EXPOSURE"); - Double exposure = EXPOSURE_col(0); - - ROScalarColumn<Double> TOTAL_BANDWIDTH_col(spectral_window, "TOTAL_BANDWIDTH"); - Double bandwidth = TOTAL_BANDWIDTH_col(0) / itsNumChannels; - - itsNoiseLevel = 1.0 / sqrt(bandwidth * exposure); - std::cout << "Noiselevel" << itsNoiseLevel << std::endl; - - //calculate number of timeslots - ROScalarColumn<Double> INTERVAL_col((*MS), "INTERVAL"); - Double interval = INTERVAL_col(0); - - //Number of timeslots - ROScalarColumn<Double> TIME_CENTROID_col((*MS), "TIME_CENTROID"); - Double firstdate = TIME_CENTROID_col(0); - Double lastdate = TIME_CENTROID_col(itsNumSamples-1); - std::cout << "interval" << interval << std::endl; - - itsNumTimeslots = (int)((lastdate-firstdate)/interval) + 1; - std::cout << "Numtimeslots" << itsNumTimeslots << std::endl; - - //calculate number of baselines. - itsNumPairs = (itsNumAntennae) * (itsNumAntennae + 1) / 2; //Triangular numbers formula - std::cout << "NumPairs" << itsNumPairs << std::endl; - - //calculate number of Bands - itsNumBands = itsNumSamples / (itsNumPairs * itsNumTimeslots); - std::cout << "NumBands" << itsNumBands << std::endl; - - } - - //===============>>> MS_File::antennas <<<=============== - - MSAntenna MS_File::antennas() - { - return (*MS).antenna(); - } - - //===============>>> MS_File::BaselineIterator <<<=============== - /* Returns one timeslot at a time*/ - TableIterator MS_File::TimeslotIterator() - { - Block<String> ms_iteration_variables(1); - ms_iteration_variables[0] = "TIME_CENTROID"; - - return TableIterator((*MS), ms_iteration_variables); - } - - //===============>>> MS_File <<<=============== - } -} diff --git a/Appl/CEP/CS1/CS1_DFTImager/src/MS_File.h~ b/Appl/CEP/CS1/CS1_DFTImager/src/MS_File.h~ deleted file mode 100644 index 55b1c7469e67bec53ed2b363337e9b7e80a8b929..0000000000000000000000000000000000000000 --- a/Appl/CEP/CS1/CS1_DFTImager/src/MS_File.h~ +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by ASTRON, Adriaan Renting * - * renting@astron.nl * - * * - * 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#ifndef __IMAGER_MS_FILE_H__ -#define __IMAGER_MS_FILE_H__ - -#include <ms/MeasurementSets.h> -#include <vector> -#include <string> -#include <tables/Tables.h> -#include <tables/Tables/TableIter.h> - -namespace LOFAR -{ - namespace CS1 - { - class MS_File - { - public: - MS_File(const std::string& msname); - ~MS_File(); - - int itsNumSamples; - int itsNumAntennae; - int itsNumFields; - int itsNumBands; - int itsNumChannels; - int itsNumPolarizations; - int itsNumPairs; - int itsNumTimeslots; - double itsNoiseLevel; - std::vector<casa::String> itsAntennaNames; - casa::Vector<casa::Int> itsPolarizations; - - casa::TableIterator TimeslotIterator(); - casa::MSAntenna antennas(); - - protected: - string MSName; - casa::MeasurementSet* MS; - void init(); - private: - }; // MS_File - } //namespace CS1 -}; //namespace LOFAR - -#endif // __IMAGER_MS_FILE_H__