diff --git a/CEP/BB/PSS3/src/files/DH_DFTRequest.cc b/CEP/BB/PSS3/src/files/DH_DFTRequest.cc new file mode 100644 index 0000000000000000000000000000000000000000..843122686a41625abe69fad721f705006760b299 --- /dev/null +++ b/CEP/BB/PSS3/src/files/DH_DFTRequest.cc @@ -0,0 +1,120 @@ +// DH_DFTRequest.cc: +// +// Copyright (C) 2004 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@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 +// +// $Id$ + + +#include <PSS3/DH_DFTRequest.h> +#include <Common/LofarLogger.h> + +namespace LOFAR +{ + +DH_DFTRequest::DH_DFTRequest() +: DataHolder ("", "DH_DFTRequest"), + itsUVW (0) +{} + +DH_DFTRequest::DH_DFTRequest(const DH_DFTRequest& that) +: DataHolder (that), + itsUVW (0) +{} + +DH_DFTRequest::~DH_DFTRequest() +{} + +DataHolder* DH_DFTRequest::clone() const +{ + return new DH_DFTRequest(*this); +} + +void DH_DFTRequest::preprocess() +{ + // Add the fields to the data definition. + // The dimensionality of UVW is variable. + // Its axes are ntime and nantenna. + addField ("UVW", BlobField<double>(1, 0u, 0u)); + addField ("StartFreq", BlobField<double>(1)); + addField ("StepFreq", BlobField<double>(1)); + addField ("NFreq", BlobField<int32>(1)); + addField ("NTime", BlobField<int32>(1)); + addField ("StartTime", BlobField<double>(1)); + addField ("StepTime", BlobField<double>(1)); + addField ("L", BlobField<double>(1)); + addField ("M", BlobField<double>(1)); + addField ("N", BlobField<double>(1)); + // The Ant nrs tell the antenna pairs froming the baselines. + addField ("Ant1", BlobField<int32> (1, 0u)); + addField ("Ant2", BlobField<int32> (1, 0u)); +} + +void DH_DFTRequest::set (double startFreq, double stepFreq, int nFreq, + double startTime, double stepTime, int nTime, + int nAnt, int nBaseline) +{ + std::vector<uint32> shape(2); + shape[0] = nTime; + shape[1] = nAnt; + getDataField("UVW").setShape (shape); + getDataField("Ant").setShape (std::vector<uint32>(1,nAnt)); + getDataField("Ant1").setShape (std::vector<uint32>(1,nBaseline)); + getDataField("Ant2").setShape (std::vector<uint32>(1,nBaseline)); + // Create the data blob (which calls fillDataPointers). + createDataBlock(); + *itsStartFreq = startFreq; + *itsStepFreq = stepFreq; + *itsNFreq = nFreq; + *itsStartTime = startTime; + *itsStepTime = stepTime; + *itsNTime = nTime; +} + +void DH_DFTRequest::fillDataPointers() +{ + // Fill in the data pointers. + itsUVW = getData<double> ("UVW"); + itsNFreq = getData<uint32> ("NFreq"); + itsStartFreq = getData<double> ("StartFreq"); + itsStepFreq = getData<double> ("StepFreq"); + itsStartTime = getData<double> ("StartTime"); + itsStepTime = getData<double> ("StepTime"); + itsNTime = getData<uint32> ("NTime"); + itsL = getData<double> ("L"); + itsM = getData<double> ("M"); + itsN = getData<double> ("N"); + itsAnt = getData<int32> ("Ant"); + itsNAnt = getDataField("Ant").getNelem(); + itsAnt1 = getData<int32> ("Ant1"); + itsAnt2 = getData<int32> ("Ant2"); + itsNBaseline = getDataField("Ant1").getNelem(); + ASSERT (itsNBaseline == getDataField("Ant2").getNelem()); + const std::vector<uint32>& shape = getDataField("UVW").getShape(); + ASSERT (shape.size() == 2); + ASSERT (*itsNTime == shape[0]); + ASSERT (itsNAnt == shape[1]); +} + + +void DH_DFTRequest::postprocess() +{ + itsUVW = 0; +} + +} // end namespace diff --git a/CEP/BB/PSS3/src/files/DH_DFTRequest.h b/CEP/BB/PSS3/src/files/DH_DFTRequest.h new file mode 100644 index 0000000000000000000000000000000000000000..dfcf4dd6ac7c17fff297f22af9806d614a7cc798 --- /dev/null +++ b/CEP/BB/PSS3/src/files/DH_DFTRequest.h @@ -0,0 +1,159 @@ +//# DH_DFTRequest.h: Input DataHolder for the DFT +//# +//# Copyright (C) 2004 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@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 +//# +//# $Id$ + +#ifndef BB_DH_INDFT_H +#define BB_DH_INDFT_H + + +#include <Common/LofarTypes.h> +#include <Transport/DataHolder.h> + +namespace LOFAR +{ + + +class DH_DFTRequest: public DataHolder +{ +public: + explicit DH_DFTRequest(); + + DH_DFTRequest(const DH_DFTRequest&); + + virtual ~DH_DFTRequest(); + + DataHolder* clone() const; + + /// Allocate the buffers. + virtual void preprocess(); + + /// Deallocate the buffers. + virtual void postprocess(); + + /// Get read access to the various data fields. + // <group> + const double* getUVW() const; + double getStartFreq() const; + double getStepFreq() const; + int getNFreq() const; + double getStartTime() const; + double getStepTime() const; + int getNTime() const; + double getL() const; + double getM() const; + double getN() const; + const int32* getAnt() const; + int getNAnt() const; + const int32* getAnt1() const; + const int32* getAnt2() const; + int getNBaseline() const; + // </group> + + // Set the values of various fields. + // It will create the data block. + void set (double startFreq, double stepFreq, int nFreq, + double startTime, double stepTime, int nTime, + int nAnt, int nBaseline); + /// Give write access to the variable sized data fields. + // The set function should have been called before. + // <group> + double* accessUVW(); + int32* accessAnt(); + int32* accessAnt1(); + int32* accessAnt2(); + // </group> + +private: + /// Forbid assignment. + DH_DFTRequest& operator= (const DH_DFTRequest&); + + // Fill the pointers to the data in the blob. + virtual void fillDataPointers(); + + + double* itsUVW; + double* itsStartFreq; + double* itsStepFreq; + uint32* itsNFreq; + double* itsStartTime; + double* itsStepTime; + uint32* itsNTime; + double* itsL; + double* itsM; + double* itsN; + int32* itsAnt; + uint32 itsNAnt; + int32* itsAnt1; + int32* itsAnt2; + uint32 itsNBaseline; +}; + + +inline const double* DH_DFTRequest::getUVW() const + { return itsUVW; } + +inline double DH_DFTRequest::getStartFreq() const + { return *itsStartFreq; } +inline double DH_DFTRequest::getStepFreq() const + { return *itsStepFreq; } +inline int DH_DFTRequest::getNFreq() const + { return *itsNFreq; } + +inline double DH_DFTRequest::getStartTime() const + { return *itsStartTime; } +inline double DH_DFTRequest::getStepTime() const + { return *itsStepTime; } +inline int DH_DFTRequest::getNTime() const + { return *itsNTime; } + +inline double DH_DFTRequest::getL() const + { return *itsL; } +inline double DH_DFTRequest::getM() const + { return *itsM; } +inline double DH_DFTRequest::getN() const + { return *itsN; } + +inline const int32* DH_DFTRequest::getAnt() const + { return itsAnt; } +inline int DH_DFTRequest::getNAnt() const + { return itsNAnt; } + +inline const int32* DH_DFTRequest::getAnt1() const + { return itsAnt1; } +inline const int32* DH_DFTRequest::getAnt2() const + { return itsAnt2; } +inline int DH_DFTRequest::getNBaseline() const + { return itsNBaseline; } + +inline double* DH_DFTRequest::accessUVW() + { return itsUVW; } +inline int32* DH_DFTRequest::accessAnt() + { return itsAnt; } +inline int32* DH_DFTRequest::accessAnt1() + { return itsAnt1; } +inline int32* DH_DFTRequest::accessAnt2() + { return itsAnt2; } + + +} + +#endif + diff --git a/CEP/BB/PSS3/src/files/DH_DFTResult.cc b/CEP/BB/PSS3/src/files/DH_DFTResult.cc new file mode 100644 index 0000000000000000000000000000000000000000..99e8235bbaf2a391bc53756dda8c45640973bd93 --- /dev/null +++ b/CEP/BB/PSS3/src/files/DH_DFTResult.cc @@ -0,0 +1,87 @@ +// DH_DFTResult.cc: +// +// Copyright (C) 2004 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@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 +// +// $Id$ + + +#include <PSS3/DH_DFTResult.h> +#include <Common/LofarLogger.h> + +namespace LOFAR +{ + +DH_DFTResult::DH_DFTResult() +: DataHolder ("", "DH_DFTResult"), + itsValues (0) +{} + +DH_DFTResult::DH_DFTResult(const DH_DFTResult& that) +: DataHolder (that), + itsValues (0) +{} + +DH_DFTResult::~DH_DFTResult() +{} + +DataHolder* DH_DFTResult::clone() const +{ + return new DH_DFTResult(*this); +} + +void DH_DFTResult::preprocess() +{ + // Add the fields to the data definition. + // The dimensionality of Data is variable. + // Its axes are nfreq,ntime,nbaseline. + // Its data is complex<double> represented by 2 doubles. + addField ("Values", BlobField<double>(1, 0u, 0u, 0u, 2u)); +} + +void DH_DFTResult::set (int nFreq, int nTime, int nBaseline) +{ + std::vector<uint32> shape(4); + shape[0] = nFreq; + shape[1] = nTime; + shape[2] = nBaseline; + shape[3] = 2; + getDataField("Values").setShape (shape); + // Create the data blob (which calls fillDataPointers). + createDataBlock(); +} + +void DH_DFTResult::fillDataPointers() +{ + // Fill in the data pointer. + itsValues = getData<double> ("Values"); + const std::vector<uint32>& shape = getDataField("Values").getShape(); + ASSERT (shape.size() == 4); + itsNFreq = shape[0]; + itsNTime = shape[1]; + itsNBaseline = shape[2]; + ASSERT (shape[3] == 2); +} + + +void DH_DFTResult::postprocess() +{ + itsValues = 0; +} + +} // end namespace diff --git a/CEP/BB/PSS3/src/files/DH_DFTResult.h b/CEP/BB/PSS3/src/files/DH_DFTResult.h new file mode 100644 index 0000000000000000000000000000000000000000..4c7f3c4e90d3dd27df166108da71fd8562146792 --- /dev/null +++ b/CEP/BB/PSS3/src/files/DH_DFTResult.h @@ -0,0 +1,99 @@ +//# DH_DFTResult.h: Output DataHolder for the DFT +//# +//# Copyright (C) 2004 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@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 +//# +//# $Id$ + +#ifndef BB_DH_OUTDFT_H +#define BB_DH_OUTDFT_H + + +#include <Common/LofarTypes.h> +#include <Transport/DataHolder.h> + +namespace LOFAR +{ + + +class DH_DFTResult: public DataHolder +{ +public: + explicit DH_DFTResult(); + + DH_DFTResult(const DH_DFTResult&); + + virtual ~DH_DFTResult(); + + DataHolder* clone() const; + + /// Allocate the buffers. + virtual void preprocess(); + + /// Deallocate the buffers. + virtual void postprocess(); + + /// Get read access to the various data fields. + // The data is a double complex, but it is handled as 2 doubles. + // <group> + const double* getValues() const; + int getNFreq() const; + int getNTime() const; + int getNBaseline() const; + // </group> + + // Set the size of the data fields. + // It will create the data block. + void set (int nFreq, int nTime, int nBaseline); + + /// Give write access to the variable sized. + // The set function should have been called before. + // <group> + double* accessValues(); + + /// Forbid assignment. + DH_DFTResult& operator= (const DH_DFTResult&); + + // Fill the pointers to the data in the blob. + virtual void fillDataPointers(); + + + double* itsValues; + uint32 itsNTime; + uint32 itsNFreq; + uint32 itsNBaseline; +}; + + +inline const double* DH_DFTResult::getValues() const + { return itsValues; } +inline int DH_DFTResult::getNFreq() const + { return itsNFreq; } +inline int DH_DFTResult::getNTime() const + { return itsNTime; } +inline int DH_DFTResult::getNBaseline() const + { return itsNBaseline; } + +inline double* DH_DFTResult::accessValues() + { return itsValues; } + + +} + +#endif +