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

pmAstrometry.h

Go to the documentation of this file.
00001 /** @file  pmAstrometry.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.1.1.1 $ $Name:  $
00011 *  @date $Date: 2005/10/14 00:29:27 $
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 #if HAVE_CONFIG_H
00019 #include <config.h>
00020 #endif
00021 #include "pslib.h"
00022 #include "psDB.h"
00023 
00024 /// @addtogroup AstroImage
00025 /// @{
00026 
00027 /** Focal plane data structure
00028  * 
00029  *  A focal plane consists of one or more chips (according to the number of
00030  *  pieces of contiguous silicon). It contains metadata containers for the
00031  *  concepts and analysis, a link to the parent, and pointers to the FITS header,
00032  *  if that corresponds to this level (the FPA may be the PHU, but will not ever
00033  *  contain pixels). For astrometry, it contains a transformation from the focal
00034  *  plane to the tangent plane and the fixed pattern residuals. It is expected
00035  *  that the transformation will consist of two 4D polynomials (i.e. a function
00036  *  of two coordinates in position, the magnitude of the object, and the color of
00037  *  the object) in order to correct for optical distortions and the effects of
00038  *  the atmosphere; hence we think that it is prudent to include a reverse
00039  *  transformation which will be derived from numerically inverting the forward
00040  *  transformation.
00041  *  
00042  */
00043 typedef struct
00044 {
00045     // Astrometric transformations
00046     psPlaneDistort* fromTangentPlane;   ///< Transformation from tangent plane to focal plane
00047     psPlaneDistort* toTangentPlane;     ///< Transformation from focal plane to tangent plane
00048     psProjection *projection;           ///< Projection from tangent plane to sky
00049     // Information
00050     psMetadata *concepts;               ///< Cache for PS concepts
00051     psMetadata *analysis;               ///< FPA-level analysis metadata
00052     const psMetadata *camera;           ///< Camera configuration
00053     psArray *chips;                     ///< The chips
00054     // FITS data
00055     psMetadata *header;                 ///< The FITS header, if it corresponds to this level
00056     psDB *db;                           ///< Database handle
00057 }
00058 pmFPA;
00059 
00060 /** Chip data structure
00061  *  
00062  *  A chip consists of one or more cells (according to the number of amplifiers
00063  *  on the device). The chip contains metadata containers for the concepts and
00064  *  analysis, a link to the parent, and pointers to the pointers to the various
00065  *  FITS data, if that corresponds to this level. For astrometry, in addition to
00066  *  the rough positioning information, it contains a coordinate transform from
00067  *  the chip to the focal plane. It is expected that this transform will consist
00068  *  of two second-order 2D polynomials; hence we think that it is prudent to
00069  *  include a reverse transformation which will be derived from numerically
00070  *  inverting the forward transformation. A boolean indicates whether the chip is
00071  *  of interest, allowing it to be excluded from analysis.
00072  *  
00073  */
00074 typedef struct
00075 {
00076     // Offset specifying position on focal plane
00077     int col0;                           ///< Offset from the left of FPA.
00078     int row0;                           ///< Offset from the bottom of FPA.
00079     // Astrometric transformations
00080     psPlaneTransform* toFPA;            ///< Transformation from chip to FPA coordinates
00081     psPlaneTransform* fromFPA;          ///< Transformation from FPA to chip coordinates
00082     // Information
00083     psMetadata *concepts;               ///< Cache for PS concepts
00084     psMetadata *analysis;               ///< Chip-level analysis metadata
00085     psArray *cells;                     ///< The cells (referred to by name)
00086     pmFPA *parent;                      ///< Parent FPA
00087     bool valid;                         ///< Do we bother about reading and working with this chip?
00088     // FITS data
00089     const char *extname;                ///< Extension name, if it corresponds to this level
00090     psArray *pixels;                    ///< The pixel data, if it corresponds to this level
00091     psMetadata *header;                 ///< The FITS header, if it corresponds to this level
00092 }
00093 pmChip;
00094 
00095 /** Cell data structure
00096  *
00097  *  A cell consists of one or more readouts.  It also contains a pointer to the
00098  *  cell's metadata, and its parent chip.  On the astrometry side, it also
00099  *  contains coordinate transforms from the cell to chip, from the cell to
00100  *  focal-plane, as well as a "quick and dirty" tranform from the cell to
00101  *  sky coordinates.
00102  *
00103  */
00104 typedef struct
00105 {
00106     // Offset specifying position on chip
00107     int col0;                           ///< Offset from the left of chip.
00108     int row0;                           ///< Offset from the bottom of chip.
00109     // Astrometric transformations
00110     psPlaneTransform* toChip;           ///< Transformations from cell to chip coordinates
00111     psPlaneTransform* toFPA;            ///< Transformations from cell to FPA coordinates
00112     psPlaneTransform* toSky;            ///< Transformations from cell to sky coordinates
00113     // Information
00114     psMetadata *concepts;               ///< Cache for PS concepts
00115     psMetadata *analysis;               ///< Cell-level analysis metadata
00116     psArray *readouts;                  ///< The readouts (referred to by number)
00117     pmChip *parent;                     ///< Parent chip
00118     bool valid;                         ///< Do we bother about reading and working with this cell?
00119     // FITS data
00120     const char *extname;                ///< Extension name, if it corresponds to this level
00121     psArray *pixels;                    ///< The pixel data, if it corresponds to this level
00122     psMetadata *header;                 ///< The FITS header, if it corresponds to this level
00123 }
00124 pmCell;
00125 
00126 /** Readout data structure.
00127  *
00128  *  A readout is the result of a single read of a cell (or a portion thereof).
00129  *  It contains the offset from the lower-left corner of the chip, in the case
00130  *  that the CCD was windowed, as well as the binning factors and parity (if the
00131  *  binning value is negative, then the parity is reversed). It also contains the
00132  *  pixel data, metadata containers for the concepts and analysis, and a link to
00133  *  the parent.
00134  *
00135  */
00136 typedef struct
00137 {
00138     // Position on the cell
00139     int col0;                           ///< Offset from the left of chip.
00140     int row0;                           ///< Offset from the bottom of chip.
00141     int colBins;                        ///< Amount of binning in x-dimension
00142     int rowBins;                        ///< Amount of binning in y-dimension
00143     // Information
00144     psImage *image;                     ///< Imaging area of readout
00145     // XXX: The following mask was removed from the pmReadout struct in recent SDRS
00146     // versions.  However, I'm keeping it here since al ot of modules still require
00147     // it.
00148     psImage *mask;                      ///< Mask of input image
00149     psMetadata *analysis;               ///< Readout-level analysis metadata
00150     psMetadata *concepts;               ///< Cache for PS Concepts
00151     pmCell *parent;                     ///< Parent cell
00152 }
00153 pmReadout;
00154 
00155 
00156 /** Allocates a pmReadout
00157  *
00158  *  The constructor shall make an empty pmReadout. If the parent cell is not
00159  *  NULL, the parent link is made and the readout shall be placed in the
00160  *  parents array of readouts. The metadata containers shall be allocated. All
00161  *  other pointers in the structure shall be initialized to NULL.
00162  *
00163  *  @return pmReadout*    newly allocated pmReadout with all internal pointers set to NULL
00164  */
00165 pmReadout *pmReadoutAlloc(
00166     pmCell *cell                        ///< Parent cell
00167 );
00168 
00169 /** Allocates a pmCell
00170  *
00171  *  The constructor shall make an empty pmCell. If the parent chip is not NULL,
00172  *  the parent link is made and the cell shall be placed in the parents array of
00173  *  cells. The readouts array shall be allocated with a zero size, and the
00174  *  metadata containers constructed. All other pointers in the structure shall be
00175  *  initialized to NULL.
00176  *
00177  *  @return pmCell*    newly allocated pmCell
00178  */
00179 pmCell *pmCellAlloc(
00180     pmChip *chip                        ///< Parent chip
00181 );
00182 
00183 /** Allocates a pmChip
00184  * 
00185  *  The constructor shall make an empty pmChip. If the parent fpa is not NULL,
00186  *  the parent link is made and the chip shall be placed in the parent's array
00187  *  of chips. The cells array shall be allocated with a zero size, and the
00188  *  metadata containers constructed. All other pointers in the structure shall be
00189  *  initialized to NULL.
00190  *
00191  *  @return pmChip*    newly allocated pmChip
00192  */
00193 pmChip *pmChipAlloc(pmFPA *fpa);
00194 
00195 /** Allocates a pmFPA
00196  * 
00197  *  The constructor shall make an empty pmFPA. The chips array shall be
00198  *  allocated with a zero size, the camera and db pointers set to the values
00199  *  provided, and the concepts metadata constructed. All other pointers in the
00200  *  structure shall be initialized to NULL.
00201  * 
00202  */
00203 pmFPA *pmFPAAlloc(
00204     const psMetadata *camera,           ///< Camera configuration
00205     psDB *db                            ///< Database handle
00206 );
00207 
00208 
00209 /** Verify parent links.
00210  * 
00211  *  This function checks the validity of the parent links in the FPA hierarchy.
00212  *  If a parent link is not set (or not set correctly), it is corrected, and the
00213  *  function shall return false. If all the parent pointers were correct, the
00214  *  function shall return true.
00215  * 
00216  */
00217 bool pmFPACheckParents(
00218     pmFPA *fpa
00219 );
00220 
00221 
00222 
00223 /** FUNC DESC
00224  * 
00225  * 
00226  * 
00227  * 
00228  */
00229 
00230 
00231 
00232 /*****************************************************************************
00233     Old Stuff
00234  *****************************************************************************/
00235 
00236 
00237 
00238 /** Find cooresponding cell for given FPA coordinate
00239  *
00240  *  @return pmCell*    the cell cooresponding to the coord in FPA
00241  */
00242 pmCell* pmCellInFPA(
00243     const psPlane* coord,              ///< the coordinate in FPA plane
00244     const pmFPA* FPA                   ///< the FPA to search for the cell
00245 );
00246 
00247 
00248 /** Find cooresponding chip for given FPA coordinate
00249  *
00250  *  @return pmChip*    the chip cooresponding to coord
00251  */
00252 pmChip* pmChipInFPA(
00253     const psPlane* coord,              ///< the coordinate in FPA plane
00254     const pmFPA* FPA                   ///< the FPA to search for the cell
00255 );
00256 
00257 
00258 /** Find cooresponding cell for given Chip coordinate
00259  *
00260  *  @return pmCell*    the cell cooresponding to coord
00261  */
00262 pmCell* pmCellInChip(
00263     const psPlane* coord,              ///< the coordinate in Chip plane
00264     const pmChip* chip                 ///< the chip to search for the cell
00265 );
00266 
00267 
00268 /** Translate a cell coordinate into a chip coordinate
00269  *
00270  *  @return psPlane*    the resulting chip coordinate
00271  */
00272 psPlane* psCoordCellToChip(
00273     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00274     const psPlane* in,                 ///< the coordinate within Cell
00275     const pmCell* cell                 ///< the Cell in interest
00276 );
00277 
00278 
00279 /** Translate a chip coordinate into a FPA coordinate
00280  *
00281  *  @return psPlane*    the resulting FPA coordinate
00282  */
00283 psPlane* psCoordChipToFPA(
00284     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00285     const psPlane* in,                 ///< the coordinate within Chip
00286     const pmChip* chip                 ///< the chip in interest
00287 );
00288 
00289 
00290 /** Translate a FPA coordinate into a Tangent Plane coordinate
00291  *
00292  *  @return psPlane*    the resulting Tangent Plane coordinate
00293  */
00294 psPlane* psCoordFPAToTP(
00295     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00296     const psPlane* in,                 ///< the coordinate within FPA
00297     double color,                      ///< Color of source
00298     double magnitude,                  ///< Magnitude of source
00299     const pmFPA* fpa                   ///< the FPA in interest
00300 );
00301 
00302 
00303 /** Translate a Tangent Plane coordinate into a Sky coordinate
00304  *
00305  *  @return psSphere*    the resulting Sky coordinate
00306  */
00307 psSphere* psCoordTPToSky(
00308     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
00309     const psPlane* in,                ///< the coordinate within Tangent Plane
00310     const psProjection *projection
00311 );
00312 
00313 /** Translate a cell coordinate into a FPA coordinate
00314  *
00315  *  @return psPlane*    the resulting FPA coordinate
00316  */
00317 psPlane* psCoordCellToFPA(
00318     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00319     const psPlane* in,                 ///< the coordinate within cell
00320     const pmCell* cell                 ///< the cell in interest
00321 );
00322 
00323 
00324 /** Translate a cell coordinate into a Sky coordinate
00325  *
00326  *  @return psSphere*    the resulting Sky coordinate
00327  */
00328 psSphere* psCoordCellToSky(
00329     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
00330     const psPlane* in,                 ///< the coordinate within cell
00331     double color,                      ///< Color of source
00332     double magnitude,                  ///< Magnitude of source
00333     const pmCell* cell                 ///< the cell in interest
00334 );
00335 
00336 
00337 /** Translate a cell coordinate into a Sky coordinate using a 'quick and
00338  *  dirty' method
00339  *
00340  *  @return psSphere*    the resulting Sky coordinate
00341  */
00342 psSphere* psCoordCellToSkyQuick(
00343     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
00344     const psPlane* in,                 ///< the coordinate within cell
00345     const pmCell* cell                 ///< the cell in interest
00346 );
00347 
00348 
00349 /** Translate a Sky coordinate into a Tangent Plane coordinate
00350  *
00351  *  @return psPlane*    the resulting Tangent Plane coordinate
00352  */
00353 psPlane* psCoordSkyToTP(
00354     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00355     const psSphere* in,                ///< the sky coordinate
00356     const psProjection *projection
00357 );
00358 
00359 /** Translate a Tangent Plane coordinate into a FPA coordinate
00360  *
00361  *  @return psPlane*    the resulting FPA coordinate
00362  */
00363 psPlane* psCoordTPToFPA(
00364     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00365     const psPlane* in,                 ///< the coordinate within tangent plane
00366     double color,                      ///< Color of source
00367     double magnitude,                  ///< Magnitude of source
00368     const pmFPA* fpa                   ///< the FPA of interest
00369 );
00370 
00371 
00372 /** Translate a FPA coordinate into a chip coordinate
00373  *
00374  *  @return psPlane*    the resulting chip coordinate
00375  */
00376 psPlane* psCoordFPAToChip(
00377     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00378     const psPlane* in,                 ///< the FPA coordinate
00379     const pmChip* chip                 ///< the chip of interest
00380 );
00381 
00382 
00383 /** Translate a chip coordinate into a cell coordinate
00384  *
00385  *  @return psPlane*    the resulting cell coordinate
00386  */
00387 psPlane* psCoordChipToCell(
00388     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00389     const psPlane* in,                 ///< the Chip coordinate
00390     const pmCell* cell                 ///< the cell of interest
00391 );
00392 
00393 
00394 /** Translate a sky coordinate into a cell coordinate
00395  *
00396  *  @return psPlane*    the resulting cell coordinate
00397  */
00398 psPlane* psCoordSkyToCell(
00399     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00400     const psSphere* in,                ///< the Sky coordinate
00401     float color,                       ///< Color of source
00402     float magnitude,                   ///< Magnitude of source
00403     const pmCell* cell                 ///< the cell of interest
00404 );
00405 
00406 
00407 /** Translate a sky coordinate into a cell coordinate using a 'quick and
00408  *  dirty' method
00409  *
00410  *  @return psPlane*    the resulting cell coordinate
00411  */
00412 psPlane* psCoordSkyToCellQuick(
00413     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00414     const psSphere* in,                ///< the Sky coordinate
00415     const pmCell* cell                 ///< the cell of interest
00416 );
00417 
00418 
00419 psMetadataItem *pmCellGetConcept(pmCell *cell, const char *concept);
00420 psMetadataItem *pmChipGetConcept(pmChip *chip, const char *concept);
00421 psMetadataItem *pmFPAGetConcept(pmFPA *fpa, const char *concept);
00422 
00423 /**
00424  * 
00425  *  We next specify a series of specific functions for concept lookups. These
00426  *  will generally be what the user utilises, so the goal is to provide a simple
00427  *  interface providing a single type back, so the user doesnt have to go to the
00428  *  trouble of checking types, etc. These functions should employ the above three
00429  *  general lookup functions and deal with the result appropriately.
00430  *
00431  */
00432 float pmFPAGetAirmass(pmFPA *fpa); // FPA.AIRMASS
00433 psString pmFPAGetFilter(pmFPA *fpa); // FPA.FILTER
00434 float pmFPAGetPosAngle(pmFPA *fpa); // FPA.POSANGLE
00435 double pmFPAGetRA(pmFPA *fpa); // FPA.RA
00436 double pmFPAGetDec(pmFPA *fpa); // FPA.DEC
00437 psString pmFPAGetRADecSys(pmFPA *fpa); // FPA.RADECSYS
00438 psString pmFPAGetName(pmFPA *fpa); // FPA.NAME
00439 psString pmChipGetName(pmChip *chip); // CHIP.NAME
00440 psString pmCellGetName(pmCell *cell); // CELL.NAME
00441 psTime *pmCellGetTime(pmCell *cell); // CELL.TIME
00442 psList *pmCellGetBiasSec(pmCell *cell); // CELL.BIASSEC
00443 psRegion pmCellGetTrimSec(pmCell *cell); // CELL.TRIMSEC
00444 float pmCellGetGain(pmCell *cell); // CELL.GAIN
00445 float pmCellGetReadNoise(pmCell *cell); // CELL.READNOISE
00446 float pmCellGetSaturation(pmCell *cell); // CELL.SATURATION
00447 float pmCellGetBad(pmCell *cell); // CELL.BAD
00448 psPixelCoord pmCellGetBin(pmCell *cell); // CELL.BIN
00449 psPixelCoord pmCellGetParity(pmCell *cell); // CELL.PARITY
00450 float pmReadoutGetExposure(pmReadout *readout); // READOUT.EXPOSURE
00451 float pmReadoutGetDarkTime(pmReadout *readout); // READOUT.DARKTIME
00452 
00453 
00454 
00455 #endif // #ifndef PS_ASTROMETRY_H

Generated on Thu Oct 13 14:29:27 2005 for Pan-STARRS Module Library by  doxygen 1.4.2