source: trunk/src/STHeader.cpp @ 1439

Last change on this file since 1439 was 1439, checked in by Malte Marquarding, 16 years ago

added Header diff function. Don't use obstype for conformance test

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1//#---------------------------------------------------------------------------
2//# STHeader.cpp: A container class for single dish integrations
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# ATNF
6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//#        Internet email: Malte.Marquarding@csiro.au
23//#        Postal address: Malte Marquarding,
24//#                        Australia Telescope National Facility,
25//#                        P.O. Box 76,
26//#                        Epping, NSW, 2121,
27//#                        AUSTRALIA
28//#
29//# $Id:
30//#---------------------------------------------------------------------------
31
32#include <casa/aips.h>
33#include <casa/iostream.h>
34#include <casa/iomanip.h>
35#include <casa/Exceptions.h>
36#include <casa/Utilities/Assert.h>
37#include <casa/Arrays/IPosition.h>
38#include <casa/Quanta/MVTime.h>
39
40
41
42#include "STDefs.h"
43#include "STHeader.h"
44
45using namespace casa;
46using namespace asap;
47
48
49
50bool STHeader::conformant( const STHeader& other )
51{
52  bool conforms;
53  conforms = (this->antennaname == other.antennaname
54              && this->equinox == other.equinox
55              && this->fluxunit == other.fluxunit
56              );
57  return conforms;
58}
59
60String STHeader::diff( const STHeader& other )
61{
62  ostringstream thediff;
63  if ( this->equinox != other.equinox ) {
64    thediff  << "Equinox: "  << this->equinox << " <-> "
65             << other.equinox << endl;
66  }
67  if ( this->obstype != other.obstype ) {
68    thediff << "Obs. Type: " << this->obstype << " <-> "
69            << other.obstype << endl;
70  }
71  if ( this->fluxunit != other.fluxunit ) {
72    thediff << "Flux unit: " << this->fluxunit << " <-> "
73            << other.fluxunit << endl;
74  }
75  return String(thediff);
76}
77
78void STHeader::print() const {
79  MVTime mvt(this->utc);
80  mvt.setFormat(MVTime::YMD);
81  cout << "Observer: " << this->observer << endl
82       << "Project: " << this->project << endl
83       << "Obstype: " << this->obstype << endl
84       << "Antenna: " << this->antennaname << endl
85       << "Ant. Position: " << this->antennaposition << endl
86       << "Equinox: " << this->equinox << endl
87       << "Freq. ref.: " << this->freqref << endl
88       << "Ref. frequency: " << this->reffreq << endl
89       << "Bandwidth: "  << this->bandwidth << endl
90       << "Time (utc): "
91       << mvt
92       << endl;
93  //setprecision(10) << this->utc << endl;
94}
95
96// SDDataDesc
97
98uInt SDDataDesc::addEntry(const String& source, uInt ID,
99                          const MDirection& dir, uInt secID)
100{
101
102// See if already exists
103
104  if (n_ > 0) {
105    for (uInt i=0; i<n_; i++) {
106      if (source==source_[i] && ID==ID_[i]) {
107         return i;
108      }
109    }
110  }
111
112// Not found - add it
113
114  n_ += 1;
115  source_.resize(n_,True);
116  ID_.resize(n_,True);
117  secID_.resize(n_,True);
118  secDir_.resize(n_,True,True);
119//
120  source_[n_-1] = source;
121  ID_[n_-1] = ID;
122  secID_[n_-1] = secID;
123  secDir_[n_-1] = dir;
124//
125  return n_-1;
126}
127
128void SDDataDesc::summary() const
129{
130   if (n_>0) {
131      cerr << "Source    ID" << endl;
132      for (uInt i=0; i<n_; i++) {
133         cout << setw(11) << source_(i) << ID_(i) << endl;
134      }
135   }
136}
137
Note: See TracBrowser for help on using the repository browser.