Skip to content
Snippets Groups Projects
Commit 01b92d5e authored by Ger van Diepen's avatar Ger van Diepen
Browse files

bug 1267:

Start and end times are needed by BBS instead of center times
parent 407129a8
No related branches found
No related tags found
No related merge requests found
......@@ -68,10 +68,11 @@ namespace LOFAR { namespace CEP {
// Change the base part of the name.
void changeBaseName (const string& newBaseName);
// Set the start and end time.
// Optionally the time centroid per time interval can be set.
// Set the observation start and end time.
// Optionally the start and end per time interval can be set.
void setTimes (double startTime, double endTime, double stepTime,
const vector<double>& centroid = vector<double>());
const vector<double>& starts = vector<double>(),
const vector<double>& ends = vector<double>());
// Add a band.
// <group>
......@@ -81,7 +82,7 @@ namespace LOFAR { namespace CEP {
// </group>
// Add an extra parameter. It is added to the subset 'Extra.'.
// If the paramter already exists, it is replaced.
// If the parameter already exists, it is replaced.
void addParm (const std::string& key, const std::string& value)
{ return itsParms.add (key, value); }
......@@ -108,8 +109,10 @@ namespace LOFAR { namespace CEP {
{ return itsEndTime; }
double getStepTime() const
{ return itsStepTime; }
const vector<double>& getTimeCentroids() const
{ return itsTimes; }
const vector<double>& getStartTimes() const
{ return itsStartTimes; }
const vector<double>& getEndTimes() const
{ return itsEndTimes; }
int getNBand() const
{ return itsNChan.size(); }
const std::vector<int>& getNChan() const
......@@ -132,7 +135,8 @@ namespace LOFAR { namespace CEP {
double itsStartTime;
double itsEndTime;
double itsStepTime;
std::vector<double> itsTimes;
std::vector<double> itsStartTimes;
std::vector<double> itsEndTimes;
std::vector<int32> itsNChan; //# nr of channels per band
std::vector<double> itsStartFreqs; //# start freq of each channel
std::vector<double> itsEndFreqs; //# end freq of each channel
......
......@@ -41,9 +41,14 @@ namespace LOFAR { namespace CEP {
timeStr = parset.getString ("EndTime");
ASSERT (MVTime::read (q, timeStr, true));
itsEndTime = q.getValue ("s");
itsTimes = parset.getDoubleVector ("dCentroid", vector<double>());
for (uint i=0; i<itsTimes.size(); ++i) {
itsTimes[i] += itsStartTime;
itsStartTimes = parset.getDoubleVector ("StartTimesDiff", vector<double>());
itsEndTimes = parset.getDoubleVector ("EndTimesDiff", vector<double>());
ASSERT (itsStartTimes.size() == itsEndTimes.size());
double diff = itsStartTime;
for (uint i=0; i<itsStartTimes.size(); ++i) {
itsStartTimes[i] += diff;
diff += itsStepTime;
itsEndTimes[i] += diff;
}
}
......@@ -58,12 +63,26 @@ namespace LOFAR { namespace CEP {
os << prefix << "EndTime = "
<< MVTime::Format(MVTime::YMD,9) << MVTime(itsEndTime/86400) << endl;
os << prefix << "StepTime = " << itsStepTime << endl;
if (! itsTimes.empty()) {
os << prefix << "dCentroid= [";
streamsize oldPrec = os.precision (8);
for (uint i=0; i<itsTimes.size(); ++i) {
if (! itsStartTimes.empty()) {
os << prefix << "StartTimesDiff=[";
streamsize oldPrec = os.precision (5);
double diff = itsStartTime;
for (uint i=0; i<itsStartTimes.size(); ++i) {
if (i!=0) os << ',';
os << itsTimes[i] - itsStartTime;
os << itsStartTimes[i] - diff;
diff += itsStepTime;
}
os << ']' << endl;
os.precision (oldPrec);
}
if (! itsEndTimes.empty()) {
os << prefix << "EndTimesDiff=[";
streamsize oldPrec = os.precision (5);
double diff = itsStartTime;
for (uint i=0; i<itsEndTimes.size(); ++i) {
if (i!=0) os << ',';
diff += itsStepTime;
os << itsEndTimes[i] - diff;
}
os << ']' << endl;
os.precision (oldPrec);
......@@ -99,12 +118,15 @@ namespace LOFAR { namespace CEP {
}
void VdsPartDesc::setTimes (double startTime, double endTime, double stepTime,
const vector<double>& centroids)
const vector<double>& startTimes,
const vector<double>& endTimes)
{
ASSERT (itsStartTimes.size() == itsEndTimes.size());
itsStartTime = startTime;
itsEndTime = endTime;
itsStepTime = stepTime;
itsTimes = centroids;
itsStartTimes = startTimes;
itsEndTimes = endTimes;
}
void VdsPartDesc::addBand (int nchan, double startFreq, double endFreq)
......@@ -134,7 +156,8 @@ namespace LOFAR { namespace CEP {
{
bs.putStart ("VdsPartDesc", 1);
bs << itsName << itsFileSys
<< itsStartTime << itsEndTime << itsStepTime << itsTimes
<< itsStartTime << itsEndTime << itsStepTime
<< itsStartTimes << itsEndTimes
<< itsNChan << itsStartFreqs << itsEndFreqs
<< itsParms;
bs.putEnd();
......@@ -145,7 +168,8 @@ namespace LOFAR { namespace CEP {
{
bs.getStart ("VdsPartDesc");
bs >> itsName >> itsFileSys
>> itsStartTime >> itsEndTime >> itsStepTime >> itsTimes
>> itsStartTime >> itsEndTime >> itsStepTime
>> itsStartTimes >> itsEndTimes
>> itsNChan >> itsStartFreqs >> itsEndFreqs
>> itsParms;
bs.getEnd();
......
......@@ -25,9 +25,13 @@ void check (const VdsPartDesc& vds, uint nTimes=0)
ASSERT (vds.getStartTime() == 0.5);
ASSERT (vds.getEndTime() == 1);
ASSERT (vds.getStepTime() == 0.25);
ASSERT (vds.getTimeCentroids().size() == nTimes);
ASSERT (vds.getStartTimes().size() == nTimes);
ASSERT (vds.getEndTimes().size() == nTimes);
if (nTimes > 0) {
ASSERT (vds.getTimeCentroids()[0] == 1.);
ASSERT (vds.getStartTimes()[0] == 1);
ASSERT (vds.getStartTimes()[nTimes-1] == 1);
ASSERT (vds.getEndTimes()[0] == 2);
ASSERT (vds.getEndTimes()[nTimes-1] == 2);
}
ASSERT (vds.getNChan().size() == 2);
ASSERT (vds.getNChan()[0] == 2);
......@@ -78,7 +82,7 @@ void doIt()
bis >> vdsb;
check (vdsb);
// Add some times and check again.
vdsb.setTimes (0.5, 1, 0.25, vector<double>(10,1));
vdsb.setTimes (0.5, 1, 0.25, vector<double>(10,1), vector<double>(10,2));
check (vdsb, 10);
// Check if times are written as well.
ofstream fos2("tVdsPartDesc_tmp.fil2");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment