Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psAstrometry.h

Go to the documentation of this file.
00001 /** @file  psAstrometry.h
00002 *
00003 *  @brief This file defines the basic types for astronomical coordinate
00004 *  transformation
00005 *
00006 *  @ingroup AstroImage
00007 *
00008 *  @author GLG, MHPCC
00009 *
00010 *  @version $Revision: 1.39 $ $Name: rel5_0 $
00011 *  @date $Date: 2005/03/31 23:01:46 $
00012 *
00013 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00014 */
00015 
00016 #ifndef PS_ASTROMETRY_H
00017 #define PS_ASTROMETRY_H
00018 
00019 #include "psType.h"
00020 #include "psImage.h"
00021 #include "psArray.h"
00022 #include "psList.h"
00023 #include "psFunctions.h"
00024 #include "psMetadata.h"
00025 #include "psCoord.h"
00026 #include "psPhotometry.h"
00027 
00028 struct psCell;
00029 struct psChip;
00030 struct psFPA;
00031 struct psExposure;
00032 
00033 /// @addtogroup AstroImage
00034 /// @{
00035 
00036 /** Wallace's Grommit
00037  *
00038  *  SLALib requires several elements to perform the transformations between
00039  *  the tangent plane and the sky.  Pre-computing these quantities for each
00040  *  exposure means that subsequent transformations are faster.  For historical
00041  *  reasons, this structure is known colloquially as "Wallace's Grommit".
00042  *
00043  */
00044 typedef struct
00045 {
00046     const double latitude;             ///< geodetic latitude (radians)
00047     const double sinLat;               ///< sine of geodetic latitude
00048     const double cosLat;               ///< cosine of geodetic latitude
00049     const double abberationMag;        ///< magnitude of diurnal aberration vector
00050     const double height;               ///< height (HM)
00051     const double temperature;          ///< ambient temperature (TDK)
00052     const double pressure;             ///< pressure (PMB)
00053     const double humidity;             ///< relative humidity (RH)
00054     const double wavelength;           ///< wavelength (WL)
00055     const double lapseRate;            ///< lapse rate (TLR)
00056     const double refractA;             ///< refraction constant A (radians)
00057     const double refractB;             ///< refraction constant B (radians)
00058     const double longitudeOffset;      ///< longitude + ... (radians)
00059     const double siderealTime;         ///< local apparent sidereal time (radians)
00060 }
00061 psGrommit;
00062 
00063 /** Fixed Pattern Corrections
00064  *
00065  *  The fixed pattern is a correction to the general astrometric solution
00066  *  formed by summing the residuals from many observations. The intent is to
00067  *  correct for higher-order distortions in the camera system on a coarse
00068  *  grid (larger than individual pixels, but smaller than a single cell).
00069  *  Hence, in addition to the offsets, we need to specify the size and scale
00070  *  of the grid in x and y as well as the origin of the grid.
00071  */
00072 typedef struct
00073 {
00074     psS32 nX;                            ///< Number of elements in x direction
00075     psS32 nY;                            ///< Number of elements in y direction
00076     double x0;                         ///< X Position of 0,0 corner on focal plane
00077     double y0;                         ///< Y Position of 0,0 corner on focal plane
00078     double xScale;                     ///< Scale of the grid in x direction
00079     double yScale;                     ///< Scale of the grid in x direction
00080     /// XXX: I added the following memvers to facilitate the psFreeing of the x,y data structures.
00081     psS32 p_ps_xRows;                    ///< Number of rows in the x member
00082     psS32 p_ps_xCols;                    ///< Number of cols in the x member
00083     psS32 p_ps_yRows;                    ///< Number of rows in the y member
00084     psS32 p_ps_yCols;                    ///< Number of cols in the y member
00085     double **x;                        ///< The grid of offsets in x
00086     double **y;                        ///< The grid of offsets in y
00087 }
00088 psFixedPattern;
00089 
00090 /** Readout data structure.
00091  *
00092  *  A readout is the result of a single read of a cell (or a portion thereof).
00093  *  It contains a pointer to the pixel data, and additional pointers to the
00094  *  objects found in the readout, and the readout metadata.  It also contains
00095  *  the offset from the lower-left corner of the chip, in the case that the
00096  *  CCD was windowed.
00097  *
00098  */
00099 typedef struct
00100 {
00101     const psS32 col0;                  ///< Offset from the left of chip.
00102     const psS32 row0;                  ///< Offset from the bottom of chip.
00103 
00104     const int colParity;               ///< Column Readout Direction
00105     const int rowParity;               ///< Row Readout Direction
00106 
00107     const psU32 colBins;               ///< Amount of binning in x-dimension
00108     const psU32 rowBins;               ///< Amount of binning in y-dimension
00109 
00110     psImage* image;                    ///< Imaging area of readout
00111     psImage* mask;                     ///< Mask area for readout
00112     psList* objects;                   ///< Objects derived from Readout
00113     psMetadata* metadata;              ///< Readout-level metadata
00114 }
00115 psReadout;
00116 
00117 /** Cell data structure
00118  *
00119  *  A cell consists of one or more readouts.  It also contains a pointer to the
00120  *  cell's metadata, and its parent chip.  On the astrometry side, it also
00121  *  contains coordinate transforms from the cell to chip, from the cell to
00122  *  focal-plane, as well as a "quick and dirty" tranform from the cell to
00123  *  sky coordinates.
00124  *
00125  */
00126 typedef struct
00127 {
00128     const psS32 col0;                  ///< Offset from the left of chip
00129     const psS32 row0;                  ///< Offset from the bottom of chip
00130 
00131     psArray* readouts;                 ///< readouts from the cell
00132 
00133     psMetadata* metadata;              ///< cell-level metadata
00134 
00135     psPlaneTransform* toChip;          ///< transformations from cell to chip coordinates
00136     psPlaneTransform* fromChip;        ///< transformations from cell to chip coordinates
00137     psPlaneTransform* toFPA;           ///< transformations from cell to FPA coordinates
00138     psPlaneTransform* toTP;            ///< transformations from cell to FPA coordinates
00139     psPlaneTransform* toSky;           ///< transformations from cell to tangent plane coordinates
00140 
00141     struct psChip* parent;             ///< chip in which contains this cell
00142 }
00143 psCell;
00144 
00145 /** Chip data structure
00146  *
00147  *  A chip consists of one or more cells (according to the number of amplifiers
00148  *  on the CCD). It contains a pointer to the chip's metadata, and a pointer
00149  *  to the parent focal plane.  For astrometry, it contains a coordinate
00150  *  transform from the chip to the focal plane, and vis-versa.
00151  *
00152  */
00153 typedef struct psChip
00154 {
00155     const psS32 col0;                  ///< Offset from the left of FPA
00156     const psS32 row0;                  ///< Offset from the bottom of FPA
00157 
00158     psArray* cells;                    ///< cells in the chip
00159 
00160     psMetadata* metadata;              ///< chip-level metadata
00161 
00162     psPlaneTransform* toFPA;           ///< transformation from chip to FPA coordinates
00163     psPlaneTransform* fromFPA;         ///< transformation from FPA to chip coordinates
00164 
00165     struct psFPA* parent;              ///< FPA which contains this chip
00166 }
00167 psChip;
00168 
00169 /** A Focal-Plane
00170  *
00171  *  A focal plane consists of one or more chips (according to the number of
00172  *  contiguous silicon).  It contains pointers to the focal-plane's metadata
00173  *  and the exposure information.  For astrometry, it contains a transformation
00174  *  from the focal plane to the tangent plane and the fixed pattern residuals.
00175  *  Since colors are involved in the transformation, it is necessary to specify
00176  *  the color the transformation is defined.  We also include some values to
00177  *  characterize the quality of the transformation: the root square deviation
00178  *  for the x and y transformation fits, and the chi-squared for the
00179  *  transformation fit.
00180  *
00181  */
00182 typedef struct psFPA
00183 {
00184     psArray* chips;                    ///< chips in the focal plane array
00185     psMetadata* metadata;              ///< focal-plane's metadata
00186 
00187     psPlaneDistort* fromTangentPlane;  ///< transformation from tangent plane to focal plane
00188     psPlaneDistort* toTangentPlane;    ///< transformation from focal plane to tangent plane
00189     psFixedPattern* pattern;           ///< fixed pattern residual offsets
00190 
00191     const struct psExposure* exposure; ///< information about this exposure
00192     psGrommit *grommit;                ///< Wallace's grommit
00193 
00194     psPhotSystem* colorPlus;           ///< Color reference
00195     psPhotSystem* colorMinus;          ///< Color reference
00196     psProjection *projection;          ///< projection
00197 
00198     float rmsX;                        ///< RMS for x transformation fits
00199     float rmsY;                        ///< RMS for y transformation fits
00200     float chi2;                        ///< chi^2 of astrometric solution
00201 }
00202 psFPA;
00203 
00204 /** Observatory Information
00205  *
00206  *  A container for the observatory data that doesn't change per exposure.
00207  *
00208  */
00209 typedef struct
00210 {
00211     const char* name;                  ///< Name of observatory
00212     const double latitude;             ///< Latitude of observatory, east positive (degrees?)
00213     const double longitude;            ///< Longitude of observatory (degrees?)
00214     const double height;               ///< Height of observatory in meters
00215     const double tlr;                  ///< Tropospheric Lapse Rate
00216 }
00217 psObservatory;
00218 
00219 /** Exposure Information
00220  *
00221  *  Several quantities from the telescope in order to make a first guess at
00222  *  the astrometric solution.  From these quantities, further quantities can
00223  *  be derivedand stored for later use.
00224  *
00225  */
00226 typedef struct psExposure
00227 {
00228     const double ra;                   ///< Telescope boresight, right ascention
00229     const double dec;                  ///< Telescope boresight, declination
00230     const double hourAngle;            ///< Hour angle
00231     const double zenithDistance;       ///< Zenith distance
00232     const double azimuth;              ///< Azimuth
00233     const psTime* time;                ///< Time of observation
00234     const float rotAngle;              ///< Rotator position angle in degrees? XXX: see bug#209
00235     const float temperature;           ///< Air temperature in Kelvin
00236     const float pressure;              ///< Air pressure in mB
00237     const float humidity;              ///< Relative humidity, for refraction
00238     const float exposureTime;          ///< Exposure time
00239     const float wavelength;            ///< Wavelength in microns
00240     const psObservatory* observatory;  ///< Observatory data
00241 
00242     /* Derived quantities */
00243     const double lst;                  ///< Local Sidereal Time
00244     const float positionAngle;         ///< Position angle
00245     const float parallacticAngle;      ///< Parallactic angle
00246     const float airmass;               ///< Airmass, calculated from zenith distance
00247     const float parallacticFactor;     ///< Parallactic factor
00248     const char* cameraName;            ///< name of camera which provided exposure
00249     const char* telescopeName;         ///< name of telescope which provided exposure
00250 }
00251 psExposure;
00252 
00253 /** Allocator for psFixedPattern struct
00254  *
00255  *  Allocates a new psFixedPattern struct with the attributes coorsponding
00256  *  to the parameters set to the said input values.
00257  *
00258  *  @return psFixedPattern*     New psFixedPattern struct.
00259  */
00260 psFixedPattern* psFixedPatternAlloc(
00261     double x0,           ///< X Position of 0,0 corner on focal plane
00262     double y0,           ///< Y Position of 0,0 corner on focal plane
00263     double xScale,       ///< Scale of the grid in x direction
00264     double yScale,       ///< Scale of the grid in x direction
00265     const psImage *x,    ///< The grid of offsets in x
00266     const psImage *y     ///< The grid of offsets in y
00267 );
00268 
00269 
00270 /** Allocator for psExposure
00271  *
00272  *  We need several quantities from the telescope in order to make a first
00273  *  guess at the astrometric solution. From these quantities, further
00274  *  quantities can be derived and stored for later use.
00275  *
00276  *  @return     psExposure*    New psExposure struct
00277  */
00278 psExposure* psExposureAlloc(
00279     double ra,                         ///< Telescope boresight, right ascention
00280     double dec,                        ///< Telescope boresight, declination
00281     double hourAngle,                  ///< Hour angle
00282     double zenithDistance,             ///< Zenith distance
00283     double azimuth,                    ///< Azimuth
00284     const psTime* time,                ///< time of observation
00285     float rotAngle,                    ///< Rotator position angle
00286     float temperature,                 ///< Temperature
00287     float pressure,                    ///< Pressure
00288     float humidity,                    ///< Relative humidity
00289     float exposureTime,                ///< Exposure time
00290     float wavelength,                  ///< wavelength
00291     const psObservatory* observatory   ///< Observatory data
00292 );
00293 
00294 /** Allocator for psObservatory
00295  *
00296  *  This function shall construct a new psObservatory with attributes
00297  *  cooresponding to the function parameters.
00298  *
00299  *  @return psObservatory*    new psObservatory struct
00300  */
00301 psObservatory* psObservatoryAlloc(
00302     const char* name,                  ///< Name of observatory
00303     double latitude,                   ///< Latitude of observatory, east positive
00304     double longitude,                  ///< Longitude of observatory
00305     double height,                     ///< Height of observatory
00306     double tlr                         ///< Tropospheric Lapse Rate
00307 );
00308 
00309 /** Allocator for psFPA
00310  *
00311  *  This function shall make an empty psFPA, with the nChips allocated
00312  *  pointers to psChips being set to NULL; all other pointers in the structure
00313  *  shall be initialized to NULL, apart from the grommit, which shall be
00314  *  constructed on the basis of the exp parameter.
00315  *
00316  *  @return psFPA*    a newly allocated psFPA
00317  */
00318 psFPA* psFPAAlloc(
00319     psS32 nChips,                        ///< number of chips in the FPA
00320     const psExposure* exp              ///< the exposure information
00321 );
00322 
00323 /** Allocates a psChip
00324  *
00325  *  This allocator shall make an empty psChip, with the nCells allocated
00326  *  pointers to psCells being set to NULL; all other pointers in the structure
00327  *  shall be initialized to NULL.
00328  *
00329  *  @return psChip*    newly allocated psChip
00330  */
00331 psChip* psChipAlloc(
00332     psS32 nCells,                        ///< number of cells in Chip
00333     psFPA* parentFPA                   ///< parent FPA
00334 );
00335 
00336 /** Allocates a psCell
00337  *
00338  *  The constructor shall make an empty psCell, with the nReadouts allocated
00339  *  pointers to psReadouts being set to NULL; all other pointers in the
00340  *  structure shall be initialized to NULL.
00341  *
00342  *  @return psCell*    newly allocated psCell
00343  */
00344 psCell* psCellAlloc(
00345     psS32 nReadouts,                     ///< number of readouts in cell
00346     psChip* parentChip                 ///< parent Chip
00347 );
00348 
00349 /** Allocates a psReadout
00350  *
00351  *  All pointers in the structure other than the image shall be initialized
00352  *  to NULL.
00353  *
00354  *  @return psReadout*    newly allocated psReadout with all internal pointers set to NULL
00355  */
00356 psReadout* psReadoutAlloc();
00357 
00358 /** Allocates a Wallace's Grommit structure.
00359  *
00360  *  The psGrommit is calculated from telescope information for the particular
00361  *  exposure.
00362  *
00363  *  @return psGrommit* New grommit structure.
00364  */
00365 psGrommit* psGrommitAlloc(
00366     const psExposure* exp              ///< the cooresponding exposure structure.
00367 );
00368 
00369 /** Find cooresponding cell for given FPA coordinate
00370  *
00371  *  @return psCell*    the cell cooresponding to the coord in FPA
00372  */
00373 psCell* psCellInFPA(
00374     const psPlane* coord,              ///< the coordinate in FPA plane
00375     const psFPA* FPA                   ///< the FPA to search for the cell
00376 );
00377 
00378 /** Find cooresponding chip for given FPA coordinate
00379  *
00380  *  @return psChip*    the chip cooresponding to coord
00381  */
00382 psChip* psChipInFPA(
00383     const psPlane* coord,              ///< the coordinate in FPA plane
00384     const psFPA* FPA                   ///< the FPA to search for the cell
00385 );
00386 
00387 /** Find cooresponding cell for given Chip coordinate
00388  *
00389  *  @return psCell*    the cell cooresponding to coord
00390  */
00391 psCell* psCellInChip(
00392     const psPlane* coord,              ///< the coordinate in Chip plane
00393     const psChip* chip                 ///< the chip to search for the cell
00394 );
00395 
00396 /** Translate a cell coordinate into a chip coordinate
00397  *
00398  *  @return psPlane*    the resulting chip coordinate
00399  */
00400 psPlane* psCoordCellToChip(
00401     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00402     const psPlane* in,                 ///< the coordinate within Cell
00403     const psCell* cell                 ///< the Cell in interest
00404 );
00405 
00406 /** Translate a chip coordinate into a FPA coordinate
00407  *
00408  *  @return psPlane*    the resulting FPA coordinate
00409  */
00410 psPlane* psCoordChipToFPA(
00411     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00412     const psPlane* in,                 ///< the coordinate within Chip
00413     const psChip* chip                 ///< the chip in interest
00414 );
00415 
00416 /** Translate a FPA coordinate into a Tangent Plane coordinate
00417  *
00418  *  @return psPlane*    the resulting Tangent Plane coordinate
00419  */
00420 psPlane* psCoordFPAToTP(
00421     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00422     const psPlane* in,                 ///< the coordinate within FPA
00423     double color,                      ///< Color of source
00424     double magnitude,                  ///< Magnitude of source
00425     const psFPA* fpa                   ///< the FPA in interest
00426 );
00427 
00428 /** Translate a Tangent Plane coordinate into a Sky coordinate
00429  *
00430  *  @return psSphere*    the resulting Sky coordinate
00431  */
00432 psSphere* psCoordTPToSky(
00433     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
00434     const psPlane* in,                 ///< the coordinate within Tangent Plane
00435     const psGrommit* grommit           ///< the grommit of the tangent plane
00436 );
00437 
00438 /** Translate a cell coordinate into a FPA coordinate
00439  *
00440  *  @return psPlane*    the resulting FPA coordinate
00441  */
00442 psPlane* psCoordCellToFPA(
00443     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00444     const psPlane* in,                 ///< the coordinate within cell
00445     const psCell* cell                 ///< the cell in interest
00446 );
00447 
00448 /** Translate a cell coordinate into a Sky coordinate
00449  *
00450  *  @return psSphere*    the resulting Sky coordinate
00451  */
00452 psSphere* psCoordCellToSky(
00453     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
00454     const psPlane* in,                 ///< the coordinate within cell
00455     double color,                      ///< Color of source
00456     double magnitude,                  ///< Magnitude of source
00457     const psCell* cell                 ///< the cell in interest
00458 );
00459 
00460 /** Translate a cell coordinate into a Sky coordinate using a 'quick and
00461  *  dirty' method
00462  *
00463  *  @return psSphere*    the resulting Sky coordinate
00464  */
00465 psSphere* psCoordCellToSkyQuick(
00466     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
00467     const psPlane* in,                 ///< the coordinate within cell
00468     const psCell* cell                 ///< the cell in interest
00469 );
00470 
00471 /** Translate a Sky coordinate into a Tangent Plane coordinate
00472  *
00473  *  @return psPlane*    the resulting Tangent Plane coordinate
00474  */
00475 psPlane* psCoordSkyToTP(
00476     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00477     const psSphere* in,                ///< the sky coordinate
00478     const psGrommit* grommit           ///< the grommit
00479 );
00480 
00481 /** Translate a Tangent Plane coordinate into a FPA coordinate
00482  *
00483  *  @return psPlane*    the resulting FPA coordinate
00484  */
00485 psPlane* psCoordTPToFPA(
00486     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00487     const psPlane* in,                 ///< the coordinate within tangent plane
00488     double color,                      ///< Color of source
00489     double magnitude,                  ///< Magnitude of source
00490     const psFPA* fpa                   ///< the FPA of interest
00491 );
00492 
00493 /** Translate a FPA coordinate into a chip coordinate
00494  *
00495  *  @return psPlane*    the resulting chip coordinate
00496  */
00497 psPlane* psCoordFPAToChip(
00498     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00499     const psPlane* in,                 ///< the FPA coordinate
00500     const psChip* chip                 ///< the chip of interest
00501 );
00502 
00503 /** Translate a chip coordinate into a cell coordinate
00504  *
00505  *  @return psPlane*    the resulting cell coordinate
00506  */
00507 psPlane* psCoordChipToCell(
00508     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00509     const psPlane* in,                 ///< the Chip coordinate
00510     const psCell* cell                 ///< the cell of interest
00511 );
00512 
00513 /** Translate a sky coordinate into a cell coordinate
00514  *
00515  *  @return psPlane*    the resulting cell coordinate
00516  */
00517 psPlane* psCoordSkyToCell(
00518     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00519     const psSphere* in,                ///< the Sky coordinate
00520     double color,                      ///< Color of source
00521     double magnitude,                  ///< Magnitude of source
00522     const psCell* cell                 ///< the cell of interest
00523 );
00524 
00525 /** Translate a sky coordinate into a cell coordinate using a 'quick and
00526  *  dirty' method
00527  *
00528  *  @return psPlane*    the resulting cell coordinate
00529  */
00530 psPlane* psCoordSkyToCellQuick(
00531     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00532     const psSphere* in,                ///< the Sky coordinate
00533     const psCell* cell                 ///< the cell of interest
00534 );
00535 
00536 
00537 #endif

Generated on Mon Apr 4 18:24:44 2005 for Pan-STARRS Foundation Library by  doxygen 1.3.9.1