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.4.2.1 $ $Name: rel9_1 $
00011 *  @date $Date: 2005/12/12 21:52:17 $
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 // XXX: Is this correct?  Must determine what p_pmHDU is.
00028 // XXX: Create the p_pmHDU alloc/free.
00029 typedef struct
00030 {
00031     const char *extname;                // Extension name, if it corresponds to this level
00032     psArray *pixels;                    // The pixel data, if it corresponds to this level
00033     psMetadata *header;                 // The FITS header, if it corresponds to this level
00034 }
00035 p_pmHDU;
00036 
00037 /** Focal plane data structure
00038  * 
00039  *  A focal plane consists of one or more chips (according to the number of
00040  *  pieces of contiguous silicon). It contains metadata containers for the
00041  *  concepts and analysis, a link to the parent, and pointers to the FITS header,
00042  *  if that corresponds to this level (the FPA may be the PHU, but will not ever
00043  *  contain pixels). For astrometry, it contains a transformation from the focal
00044  *  plane to the tangent plane and the fixed pattern residuals. It is expected
00045  *  that the transformation will consist of two 4D polynomials (i.e. a function
00046  *  of two coordinates in position, the magnitude of the object, and the color of
00047  *  the object) in order to correct for optical distortions and the effects of
00048  *  the atmosphere; hence we think that it is prudent to include a reverse
00049  *  transformation which will be derived from numerically inverting the forward
00050  *  transformation.
00051  *  
00052  */
00053 typedef struct
00054 {
00055     // Astrometric transformations
00056     psPlaneDistort* fromTangentPlane;   ///< Transformation from tangent plane to focal plane
00057     psPlaneDistort* toTangentPlane;     ///< Transformation from focal plane to tangent plane
00058     psProjection *projection;           ///< Projection from tangent plane to sky
00059     // Information
00060     psMetadata *concepts;               ///< Cache for PS concepts
00061     psMetadata *analysis;               ///< FPA-level analysis metadata
00062     const psMetadata *camera;           ///< Camera configuration
00063     psArray *chips;                     ///< The chips
00064     p_pmHDU *private;                   ///< FITS data
00065     psMetadata *phu;                    ///< Primary Header
00066 }
00067 pmFPA;
00068 
00069 /** Chip data structure
00070  *  
00071  *  A chip consists of one or more cells (according to the number of amplifiers
00072  *  on the device). The chip contains metadata containers for the concepts and
00073  *  analysis, a link to the parent, and pointers to the pointers to the various
00074  *  FITS data, if that corresponds to this level. For astrometry, in addition to
00075  *  the rough positioning information, it contains a coordinate transform from
00076  *  the chip to the focal plane. It is expected that this transform will consist
00077  *  of two second-order 2D polynomials; hence we think that it is prudent to
00078  *  include a reverse transformation which will be derived from numerically
00079  *  inverting the forward transformation. A boolean indicates whether the chip is
00080  *  of interest, allowing it to be excluded from analysis.
00081  *  
00082  */
00083 typedef struct
00084 {
00085     // Offset specifying position on focal plane
00086     int col0;                           ///< Offset from the left of FPA.
00087     int row0;                           ///< Offset from the bottom of FPA.
00088     // Astrometric transformations
00089     psPlaneTransform* toFPA;            ///< Transformation from chip to FPA coordinates
00090     psPlaneTransform* fromFPA;          ///< Transformation from FPA to chip coordinates
00091     // Information
00092     psMetadata *concepts;               ///< Cache for PS concepts
00093     psMetadata *analysis;               ///< Chip-level analysis metadata
00094     psArray *cells;                     ///< The cells (referred to by name)
00095     pmFPA *parent;                      ///< Parent FPA
00096     bool valid;                         ///< Do we bother about reading and working with this chip?
00097     p_pmHDU *private;                   ///< FITS data
00098 }
00099 pmChip;
00100 
00101 /** Cell data structure
00102  *
00103  *  A cell consists of one or more readouts.  It also contains a pointer to the
00104  *  cell's metadata, and its parent chip.  On the astrometry side, it also
00105  *  contains coordinate transforms from the cell to chip, from the cell to
00106  *  focal-plane, as well as a "quick and dirty" tranform from the cell to
00107  *  sky coordinates.
00108  *
00109  */
00110 typedef struct
00111 {
00112     // Offset specifying position on chip
00113     int col0;                           ///< Offset from the left of chip.
00114     int row0;                           ///< Offset from the bottom of chip.
00115     // Astrometric transformations
00116     psPlaneTransform* toChip;           ///< Transformations from cell to chip coordinates
00117     psPlaneTransform* toFPA;            ///< Transformations from cell to FPA coordinates
00118     psPlaneTransform* toSky;            ///< Transformations from cell to sky coordinates
00119     // Information
00120     psMetadata *concepts;               ///< Cache for PS concepts
00121     psMetadata *camera;                 ///< Camera Info
00122     psMetadata *analysis;               ///< Cell-level analysis metadata
00123     psArray *readouts;                  ///< The readouts (referred to by number)
00124     pmChip *parent;                     ///< Parent chip
00125     bool valid;                         ///< Do we bother about reading and working with this cell?
00126     p_pmHDU *private;                   ///< FITS data
00127 }
00128 pmCell;
00129 
00130 /** Readout data structure.
00131  *
00132  *  A readout is the result of a single read of a cell (or a portion thereof).
00133  *  It contains the offset from the lower-left corner of the chip, in the case
00134  *  that the CCD was windowed, as well as the binning factors and parity (if the
00135  *  binning value is negative, then the parity is reversed). It also contains the
00136  *  pixel data, metadata containers for the concepts and analysis, and a link to
00137  *  the parent.
00138  *
00139  */
00140 typedef struct
00141 {
00142     // Position on the cell
00143     int col0;                           ///< Offset from the left of chip.
00144     int row0;                           ///< Offset from the bottom of chip.
00145     int colBins;                        ///< Amount of binning in x-dimension
00146     int rowBins;                        ///< Amount of binning in y-dimension
00147     // Information
00148     psImage *image;                     ///< Imaging area of readout
00149     psImage *mask;                      ///< Mask of input image
00150     psImage *weight;                    ///< Weight of input image
00151     psList *bias;                       ///< List of bias section (sub-)images
00152     psMetadata *analysis;               ///< Readout-level analysis metadata
00153     pmCell *parent;                     ///< Parent cell
00154 }
00155 pmReadout;
00156 
00157 
00158 /** Allocates a pmReadout
00159  *
00160  *  The constructor shall make an empty pmReadout. If the parent cell is not
00161  *  NULL, the parent link is made and the readout shall be placed in the
00162  *  parents array of readouts. The metadata containers shall be allocated. All
00163  *  other pointers in the structure shall be initialized to NULL.
00164  *
00165  *  @return pmReadout*    newly allocated pmReadout with all internal pointers set to NULL
00166  */
00167 pmReadout *pmReadoutAlloc(
00168     pmCell *cell                        ///< Parent cell
00169 );
00170 
00171 /** Allocates a pmCell
00172  *
00173  *  The constructor shall make an empty pmCell. If the parent chip is not NULL,
00174  *  the parent link is made and the cell shall be placed in the parents array of
00175  *  cells. The readouts array shall be allocated with a zero size, and the
00176  *  metadata containers constructed. All other pointers in the structure shall be
00177  *  initialized to NULL.
00178  *
00179  *  @return pmCell*    newly allocated pmCell
00180  */
00181 pmCell *pmCellAlloc(
00182     pmChip *chip,                        ///< Parent chip
00183     psMetadata *cameradata,
00184     psString name
00185 );
00186 
00187 /** Allocates a pmChip
00188  * 
00189  *  The constructor shall make an empty pmChip. If the parent fpa is not NULL,
00190  *  the parent link is made and the chip shall be placed in the parent's array
00191  *  of chips. The cells array shall be allocated with a zero size, and the
00192  *  metadata containers constructed. All other pointers in the structure shall be
00193  *  initialized to NULL.
00194  *
00195  *  @return pmChip*    newly allocated pmChip
00196  */
00197 pmChip *pmChipAlloc(
00198     pmFPA *fpa,
00199     psString name
00200 
00201 );
00202 
00203 /** Allocates a pmFPA
00204  * 
00205  *  The constructor shall make an empty pmFPA. The chips array shall be
00206  *  allocated with a zero size, the camera and db pointers set to the values
00207  *  provided, and the concepts metadata constructed. All other pointers in the
00208  *  structure shall be initialized to NULL.
00209  * 
00210  */
00211 pmFPA *pmFPAAlloc(
00212     const psMetadata *camera            ///< Camera configuration
00213 );
00214 
00215 
00216 /** Verify parent links.
00217  * 
00218  *  This function checks the validity of the parent links in the FPA hierarchy.
00219  *  If a parent link is not set (or not set correctly), it is corrected, and the
00220  *  function shall return false. If all the parent pointers were correct, the
00221  *  function shall return true.
00222  * 
00223  */
00224 bool pmFPACheckParents(
00225     pmFPA *fpa
00226 );
00227 
00228 
00229 
00230 /** FUNC DESC
00231  * 
00232  * 
00233  * 
00234  * 
00235  */
00236 
00237 
00238 
00239 /*****************************************************************************
00240     Old Stuff
00241  *****************************************************************************/
00242 
00243 
00244 
00245 /** Find cooresponding cell for given FPA coordinate
00246  *
00247  *  @return pmCell*    the cell cooresponding to the coord in FPA
00248  */
00249 pmCell* pmCellInFPA(
00250     const psPlane* coord,              ///< the coordinate in FPA plane
00251     const pmFPA* FPA                   ///< the FPA to search for the cell
00252 );
00253 
00254 
00255 /** Find cooresponding chip for given FPA coordinate
00256  *
00257  *  @return pmChip*    the chip cooresponding to coord
00258  */
00259 pmChip* pmChipInFPA(
00260     const psPlane* coord,              ///< the coordinate in FPA plane
00261     const pmFPA* FPA                   ///< the FPA to search for the cell
00262 );
00263 
00264 
00265 /** Find cooresponding cell for given Chip coordinate
00266  *
00267  *  @return pmCell*    the cell cooresponding to coord
00268  */
00269 pmCell* pmCellInChip(
00270     const psPlane* coord,              ///< the coordinate in Chip plane
00271     const pmChip* chip                 ///< the chip to search for the cell
00272 );
00273 
00274 
00275 /** Translate a cell coordinate into a chip coordinate
00276  *
00277  *  @return psPlane*    the resulting chip coordinate
00278  */
00279 psPlane* pmCoordCellToChip(
00280     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00281     const psPlane* in,                 ///< the coordinate within Cell
00282     const pmCell* cell                 ///< the Cell in interest
00283 );
00284 
00285 
00286 /** Translate a chip coordinate into a FPA coordinate
00287  *
00288  *  @return psPlane*    the resulting FPA coordinate
00289  */
00290 psPlane* pmCoordChipToFPA(
00291     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00292     const psPlane* in,                 ///< the coordinate within Chip
00293     const pmChip* chip                 ///< the chip in interest
00294 );
00295 
00296 
00297 /** Translate a FPA coordinate into a Tangent Plane coordinate
00298  *
00299  *  @return psPlane*    the resulting Tangent Plane coordinate
00300  */
00301 psPlane* pmCoordFPAToTP(
00302     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00303     const psPlane* in,                 ///< the coordinate within FPA
00304     double color,                      ///< Color of source
00305     double magnitude,                  ///< Magnitude of source
00306     const pmFPA* fpa                   ///< the FPA in interest
00307 );
00308 
00309 
00310 /** Translate a Tangent Plane coordinate into a Sky coordinate
00311  *
00312  *  @return psSphere*    the resulting Sky coordinate
00313  */
00314 psSphere* pmCoordTPToSky(
00315     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
00316     const psPlane* in,                ///< the coordinate within Tangent Plane
00317     const psProjection *projection
00318 );
00319 
00320 /** Translate a cell coordinate into a FPA coordinate
00321  *
00322  *  @return psPlane*    the resulting FPA coordinate
00323  */
00324 psPlane* pmCoordCellToFPA(
00325     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00326     const psPlane* in,                 ///< the coordinate within cell
00327     const pmCell* cell                 ///< the cell in interest
00328 );
00329 
00330 
00331 /** Translate a cell coordinate into a Sky coordinate
00332  *
00333  *  @return psSphere*    the resulting Sky coordinate
00334  */
00335 psSphere* pmCoordCellToSky(
00336     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
00337     const psPlane* in,                 ///< the coordinate within cell
00338     double color,                      ///< Color of source
00339     double magnitude,                  ///< Magnitude of source
00340     const pmCell* cell                 ///< the cell in interest
00341 );
00342 
00343 
00344 /** Translate a cell coordinate into a Sky coordinate using a 'quick and
00345  *  dirty' method
00346  *
00347  *  @return psSphere*    the resulting Sky coordinate
00348  */
00349 psSphere* pmCoordCellToSkyQuick(
00350     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
00351     const psPlane* in,                 ///< the coordinate within cell
00352     const pmCell* cell                 ///< the cell in interest
00353 );
00354 
00355 
00356 /** Translate a Sky coordinate into a Tangent Plane coordinate
00357  *
00358  *  @return psPlane*    the resulting Tangent Plane coordinate
00359  */
00360 psPlane* pmCoordSkyToTP(
00361     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00362     const psSphere* in,                ///< the sky coordinate
00363     const psProjection *projection
00364 );
00365 
00366 /** Translate a Tangent Plane coordinate into a FPA coordinate
00367  *
00368  *  @return psPlane*    the resulting FPA coordinate
00369  */
00370 psPlane* pmCoordTPToFPA(
00371     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00372     const psPlane* in,                 ///< the coordinate within tangent plane
00373     double color,                      ///< Color of source
00374     double magnitude,                  ///< Magnitude of source
00375     const pmFPA* fpa                   ///< the FPA of interest
00376 );
00377 
00378 
00379 /** Translate a FPA coordinate into a chip coordinate
00380  *
00381  *  @return psPlane*    the resulting chip coordinate
00382  */
00383 psPlane* pmCoordFPAToChip(
00384     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00385     const psPlane* in,                 ///< the FPA coordinate
00386     const pmChip* chip                 ///< the chip of interest
00387 );
00388 
00389 
00390 /** Translate a chip coordinate into a cell coordinate
00391  *
00392  *  @return psPlane*    the resulting cell coordinate
00393  */
00394 psPlane* pmCoordChipToCell(
00395     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00396     const psPlane* in,                 ///< the Chip coordinate
00397     const pmCell* cell                 ///< the cell of interest
00398 );
00399 
00400 
00401 /** Translate a sky coordinate into a cell coordinate
00402  *
00403  *  @return psPlane*    the resulting cell coordinate
00404  */
00405 psPlane* pmCoordSkyToCell(
00406     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00407     const psSphere* in,                ///< the Sky coordinate
00408     float color,                       ///< Color of source
00409     float magnitude,                   ///< Magnitude of source
00410     const pmCell* cell                 ///< the cell of interest
00411 );
00412 
00413 
00414 /** Translate a sky coordinate into a cell coordinate using a 'quick and
00415  *  dirty' method
00416  *
00417  *  @return psPlane*    the resulting cell coordinate
00418  */
00419 psPlane* pmCoordSkyToCellQuick(
00420     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
00421     const psSphere* in,                ///< the Sky coordinate
00422     const pmCell* cell                 ///< the cell of interest
00423 );
00424 
00425 /**
00426  * 
00427  * pmFPASelectChip shall set valid to true for the specified chip number
00428  * (chipNum), and all other chips shall have valid set to false. In the event
00429  * that the specified chip number does not exist within the fpa, the function
00430  * shall return false.
00431  *  
00432  */
00433 bool pmFPASelectChip(
00434     pmFPA *fpa,
00435     int chipNum
00436 );
00437 
00438 /**
00439  * 
00440  * pmFPAExcludeChip shall set valid to false only for the specified chip
00441  * number (chipNum). In the event that the specified chip number does not exist
00442  * within the fpa, the function shall generate a warning, and perform no action.
00443  * The function shall return the number of chips within the fpa that have valid
00444  * set to true.
00445  *  
00446  */
00447 int pmFPAExcludeChip(
00448     pmFPA *fpa,
00449     int chipNum
00450 );
00451 
00452 
00453 #endif // #ifndef PS_ASTROMETRY_H
00454 

Generated on Tue Dec 13 13:38:22 2005 for Pan-STARRS Module Library by  doxygen 1.4.5