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