Data Access Library (DAL)
/home/amesfoort/DAL/dal/lofar/Coordinates.h
00001 /* Copyright 2011-2012  ASTRON, Netherlands Institute for Radio Astronomy
00002  * This file is part of the Data Access Library (DAL).
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either 
00007  * version 3 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public 
00015  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #ifndef DAL_COORDINATES_H
00018 #define DAL_COORDINATES_H
00019 
00020 #include <string>
00021 #include <hdf5.h>
00022 #include "../hdf5/Attribute.h"
00023 #include "../hdf5/Group.h"
00024 
00025 /*
00026  * The coordinate system is described in ICD002, to closely match the FITS WCS (World Coordinate System) specification.
00027  *
00028  * Several types of coordinates exist:
00029  *      - Time
00030  *      - Spectral
00031  *      - Polarization
00032  *      - Direction
00033  *      - FaradayDepth
00034  * as well as any user-defined types, typically:
00035  *      - Direction
00036  *      - Linear
00037  *      - Tabular<P,W> (P = pixel type (unsigned/int/double), W = world type (double/string))
00038  */
00039 
00040 namespace dal {
00041 
00042 class Coordinate;
00043 
00047 class CoordinatesGroup: public Group {
00048 public:
00049   CoordinatesGroup( Group &parent, const std::string &name ): Group(parent, name) {}
00050 
00051   Attribute< std::vector<double> >      refLocationValue();
00052   Attribute< std::vector<std::string> > refLocationUnit();
00053   Attribute<std::string>  refLocationFrame();
00054 
00055   Attribute<double>       refTimeValue();
00056   Attribute<std::string>  refTimeUnit();
00057   Attribute<std::string>  refTimeFrame();
00058 
00059   Attribute<unsigned>     nofCoordinates();
00060   Attribute<unsigned>     nofAxes();
00061   Attribute< std::vector<std::string> > coordinateTypes();
00062 
00063   virtual Coordinate *    coordinate( unsigned nr );
00064 
00065 protected:
00066   std::string             coordinateType( unsigned nr );
00067   std::string             coordinateName( unsigned nr );
00068 };
00069 
00070 class Coordinate: public Group {
00071 public:
00072   Coordinate( Group &parent, const std::string &name ): Group(parent, name) {}
00073 
00074   Attribute<std::string>  coordinateType();
00075   Attribute< std::vector<std::string> > storageType();
00076 
00077   Attribute<unsigned>     nofAxes();
00078   Attribute< std::vector<std::string> > axisNames();
00079   Attribute< std::vector<std::string> > axisUnits();
00080 };
00081 
00086 class NumericalCoordinate: public Coordinate {
00087 public:
00088   NumericalCoordinate( Group &parent, const std::string &name ): Coordinate(parent, name) {}
00089 
00090   // linear coordinates use these attributes
00091   Attribute<double>                     referenceValue();
00092   Attribute<double>                     referencePixel();
00093   Attribute<double>                     increment();
00094   Attribute< std::vector<double> >      pc();
00095 
00096   // tabular coordinates use these attributes
00097   Attribute<unsigned>                   axisLength();
00098   Attribute< std::vector<unsigned> >    axisValuesPixel();
00099   Attribute< std::vector<double> >      axisValuesWorld();
00100 };
00101 
00106 class DirectionCoordinate: public Coordinate {
00107 public:
00108   DirectionCoordinate( Group &parent, const std::string &name ): Coordinate(parent, name) {}
00109 
00110   Attribute< std::vector<double> >      referenceValue();
00111   Attribute< std::vector<double> >      referencePixel();
00112   Attribute< std::vector<double> >      increment();
00113   Attribute< std::vector<double> >      pc();
00114 
00115   Attribute<std::string>                equinox();
00116   Attribute<std::string>                radecSys();
00117   Attribute<std::string>                projection();
00118   Attribute< std::vector<double> >      projectionParam();
00119   Attribute<double>                     lonPole();
00120   Attribute<double>                     latPole();
00121 };
00122 
00126 class StringCoordinate: public Coordinate {
00127 public:
00128   StringCoordinate( Group &parent, const std::string &name ): Coordinate(parent, name) {}
00129 
00130   Attribute<unsigned>                   axisLength();
00131   Attribute< std::vector<unsigned> >    axisValuesPixel();
00132   Attribute< std::vector<std::string> > axisValuesWorld();
00133 };
00134 
00135 class TimeCoordinate: public NumericalCoordinate {
00136 public:
00137   TimeCoordinate( Group &parent, const std::string &name ): NumericalCoordinate(parent, name) {}
00138 
00139   Attribute<std::string>                referenceFrame();
00140 };
00141 
00142 class SpectralCoordinate: public NumericalCoordinate {
00143 public:
00144   SpectralCoordinate( Group &parent, const std::string &name ): NumericalCoordinate(parent, name) {}
00145 
00146   Attribute<std::string>                referenceFrame();
00147 
00148   Attribute<double>                     restFrequency();
00149   Attribute<std::string>                restFrequencyUnit();
00150 
00151   Attribute<double>                     restWavelength();
00152   Attribute<std::string>                restWavelengthUnit();
00153 };
00154 
00155 class PolarizationCoordinate: public StringCoordinate {
00156 public:
00157   PolarizationCoordinate( Group &parent, const std::string &name ): StringCoordinate(parent, name) {}
00158 };
00159 
00160 }
00161 
00162 #endif
00163 
 All Classes Functions Variables Typedefs Friends