IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 17, 2004, 2:53:17 PM (22 years ago)
Author:
eugene
Message:

extensive re-organization of astrometry, image, object data structures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/include/psAstrom.h

    r247 r251  
    1 #if !defined(PS_ASTROM_H)
    2 #define PS_ASTROM_H
     1# if !defined(PS_ASTROM_H)
     2# define PS_ASTROM_H
    33
    44/** \file psAstrom.h
     
    77 */
    88
     9/** Astrometric solution for an OTA.
     10 * There are five coordinate frames that we need to worry about:
     11 * 1. Cell frame:    x,y in pixels (raw coordinates; lower-left pixel center is 0.5,0.5 TBR)
     12 * 2. Chip frame:    X,Y in pixels
     13 * 3. FPA frame:     P,Q in microns
     14 * 4. Tangent plane: L,M in arcsec (TBR - angles or linear?) from the telescope boresight.
     15 * 5. Sky frame:     R,D in degrees (TBR - radians?)
     16 *
     17 * 1 <--> 2: cell.coords : a 2-D linear transformation : rotation, scaling, offset, (skew)
     18 * 2 <--> 3: chip.coords : a 2-D cubic (max) transform : specifies how the chips are mounted on the focal plane.
     19 * 3 <--> 4: fpa.distort : a 2-D quartic (?) transform : specifies the distortions in the optics
     20 * 4 <--> 5: fpa.SLpars  : SLALib parameters generated based on the telescope, ra, dec, time, etc from exposure info
     21 */
     22
     23/** Information needed (by SLALIB) to convert Apparent to Observed Position */
     24typedef struct {
     25    double latitude;                    ///< geodetic latitude (radians)
     26    double sinLat, cosLat;              ///< sine and cosine of geodetic latitude
     27    double abberationMag;               ///< magnitude of diurnal aberration vector
     28    double height;                      ///< height (HM)
     29    double temperature;                 ///< ambient temperature (TDK)
     30    double pressure;                    ///< pressure (PMB)
     31    double humidity;                    ///< relative humidity (RH)
     32    double wavelength;                  ///< wavelength (WL)
     33    double lapseRate;                   ///< lapse rate (TLR)
     34    double refractA, refractB;          ///< refraction constants A and B (radians)
     35    double longitudeOffset;             ///< longitude + eqn of equinoxes + ``sidereal UT'' (radians)
     36    double siderealTime;                ///< local apparent sidereal time (radians)
     37} psGrommit;
     38
     39/** Exposure information from the telescope */
     40typedef struct {
     41    // Telescope longitude, latitude and height are stored separately, since they don't change with pointing
     42    double ra, dec;                     //!< Telescope boresight
     43    double ha;                          //!< Hour angle
     44    double zd;                          //!< Zenith distance
     45    double az;                          //!< Azimuth
     46    double lst;                         //!< Local Sidereal Time
     47    float mjd;                          //!< MJD of observation
     48    float rotAngle;                     //!< Rotator position angle
     49    float temp;                         //!< Air temperature, for estimating refraction
     50    float pressure;                     //!< Air pressure, for calculating refraction
     51    float humidity;                     //!< Relative humidity, for calculating refraction
     52    float exptime;                      //!< Exposure time
     53    /* Derived quantities */
     54    float posAngle;                     //!< Position angle
     55    float parallactic;                  //!< Parallactic angle
     56    float airmass;                      //!< Airmass, calculated from zenith distance
     57    float pf;                           //!< Parallactic factor
     58    char *cameraName;                   ///< name of camera which provided exposure
     59    char *telescopeName;                ///< name of telescope which provided exposure
     60    psGrommit *grommit;                 //!< Data needed to convert from the sky to the tangent plane
     61} psExposure;
     62
     63/** a Focal plane array: a collection of chips.  Not all chips in a camera need to be listed in an instance of
     64 *  psFPA.
     65 */
     66typedef struct {
     67    int nChips;                         ///< Number of Cells assigned
     68    int nAlloc;                         ///< Number of Cells available
     69    psChip *chips;                      ///< Chips in the Focal Plane Array
     70    psMetaData *md;                     ///< FPA-level metadata
     71    psDistort *TPtoFP;                  ///< Transformation term from
     72    psDistort *FPtoTP;                  ///< Transformation term from
     73    psExposure *exp;                    ///< information about this exposure
     74    psMatrix *dx, *dy;                  //!< Focal Plane fixed pattern residual offsets
     75    psPhotSystem colorPlus, colorMinus; ///< Colour reference
     76    float rmsX, rmsY;                   //!< Dispersion in astrometric solution
     77    float chi2;                         //!< chi^2 of astrometric solution
     78} psFPA;
     79
     80/** a Chip: a collection of cells.  Not all valid cells in a chip need to be listed in an
     81 *  instance of psChip.
     82 */
     83typedef struct {
     84    int nCells;                         ///< Number of Cells assigned
     85    psCell *cells;                      ///< Cells in the Chip
     86    psMetaData *md;                     ///< Chip-level metadata
     87
     88    psCoordXform *chipToFPA;            ///< Transformations from chip coordinates to FPA coordinates
     89    psCoordXform *FPAtoChip;            ///< Transformations from chip coordinates to FPA coordinates
     90
     91    psFPA *parentFPA;                   ///< FPA which contains this chip
     92} psChip;
     93
     94/** a Cell: a collection of pixels.
     95 */
     96typedef struct {
     97    psObjectTable *objects;             ///< objects derived from cell
     98    psImage *image;                     ///< imaging area of cell
     99    psImage *overscan;                  ///< bias region (subimage) of cell
     100    psMetaData *md;                     ///< Cell-level metadata
     101
     102    psCoordXform *cellToChip;           ///< Transformations from cell coordinates to chip coordinates
     103    psCoordXform *cellToFPA;            ///< Transformations from cell coordinates to FPA coordinates
     104
     105    psChip  *parentChip;                ///< chip which contains this cell
     106} psCell;
     107
     108/*** Functions ***********************************************************************/
     109
    9110/***********************************************************************************************************/
    10111
    11 /** Exposure information from the telescope */
    12 typedef struct {
    13     // Telescope longitude, latitude and height are stored separately, since they don't change with pointing
    14     double ra, dec;                     //!< Telescope boresight
    15     double ha;                          //!< Hour angle
    16     double zd;                          //!< Zenith distance
    17     double az;                          //!< Azimuth
    18     double lst;                         //!< Local Sidereal Time
    19     float mjd;                          //!< MJD of observation
    20     float rotAngle;                     //!< Rotator position angle
    21     float temp;                         //!< Air temperature, for estimating refraction
    22     float pressure;                     //!< Air pressure, for calculating refraction
    23     float humidity;                     //!< Relative humidity, for calculating refraction
    24     float exptime;                      //!< Exposure time
    25     /* Derived quantities */
    26     float posAngle;                     //!< Position angle
    27     float parallactic;                  //!< Parallactic angle
    28     float airmass;                      //!< Airmass, calculated from zenith distance
    29     float pf;                           //!< Parallactic factor
    30 } psExposure;
     112/* Calculating and applying astrometric solutions */
     113
     114/** returns Cell in Chip which contains the given point */
     115int
     116psCellInChip (psChip *chip,             ///< chip description
     117              psCoords *coords          ///< coordinate to find
     118              );
     119
     120/** returns the Cell coords for the specified Cell corresponding to the given Chip coords */
     121psCoords
     122psChipCoordsOnCell (psCell *cell,       ///< source cell for coordinate
     123                    psCoords *coords    ///< coordinate of interest
     124                    );
     125
     126/** returns the Cell coords for the specified Cell corresponding to the given Chip coords */
     127psCoords
     128psCellCoordsInChip (psChip *chip,       ///<
     129                    int cell,           ///<
     130                    psCoords *coords    ///<
     131                    );
     132
     133/** returns Chip in FPA which contains the given point */
     134int
     135psChipInFPA (psFPA *fpa,                ///<
     136             psCoords *coords           ///<
     137             );
     138
     139/** returns the Chip coords for the specified Chip corresponding to the given FPA coords */
     140psCoords
     141psFPACoordsOnChip (psChip *chip,        ///<
     142                   psCoords *coords     ///<
     143                   );
     144
     145/** returns the Chip coords for the specified Chip corresponding to the given FPA coords */
     146psCoords
     147psChipCoordsInFPA (psFPA *fpa,          ///<
     148                   int chip,            ///<
     149                   psCoords *coords     ///<
     150                   );
     151
     152/** Convert (RA,Dec) to (cell#,x,y) */
     153psCoords *
     154psSkyToFPA(psFPA *fpa,                  //!< OTA details
     155           psCoords *coords             //!< Position on the sky
     156           );
     157
     158/** Convert (cell#,x,y) to (RA,Dec) */
     159psCoords *
     160psFPAToSky(psFPA *fpa,                  //!< OTA details
     161           psCoords *coords             //!< Position on the sky
     162           );
     163
     164/** Convert (RA,Dec) to (cell#,x,y) */
     165psCoords *
     166psSkyToTP(psExposure *exp,              //!< OTA details
     167          psCoords *coords              //!< Position on the sky
     168          );
     169
     170/** Convert (RA,Dec) to (cell#,x,y) */
     171psCoords *
     172psTPtoSky(psExposure *exp,              //!< OTA details
     173          psCoords *coords              //!< Position on the sky
     174          );
     175
     176/** Get the airmass for a given position and sidereal time */
     177float
     178psGetAirmass(psCoords *coords,          //!< Position on the sky
     179             double siderealTime        //!< Sidereal time
     180             );
     181
     182/** Get the parallactic angle for a given position and sidereal time */
     183float
     184psGetParallactic(psCoords *coords,      //!< Position on the sky
     185                 double siderealTime    //!< Sidereal time
     186                 );
     187
     188/** Estimate atmospheric refraction, along the parallactic */
     189float
     190psGetRefraction(float colour,           //!< Colour of object
     191                psColourRef colourRef,  //!< Colour reference
     192                psExposure *exp         //!< Telescope pointing information, for airmass, temp and pressure
     193                );
     194
     195/** Fit astrometric solution to list of (chip#,x,y) and (RA,Dec) */
     196int
     197psFitAstrom(psOTADescription *restrict ota, //!< Initial guess for coefficients
     198            const psOTAPosArray *restrict detector, //!< Positions on OTA (chip#,x,y)
     199            const psSkyPosArray *restrict sky, //!< Positions on the sky (RA,Dec)
     200            const psExposure *exp       //!< Telescope pointing information, for airmass, parallactic angle
     201                                        //!< which may help set the astrometric solution
     202            );
     203
     204/*** Constructors / Destructors ******************************************************/
    31205
    32206/** Constructor */
    33207psExposure *
    34 psExposureAlloc(double ra, double dec,  //!< Telescope boresight
    35                 double ha,              //!< Hour angle
    36                 double zd,              //!< Zenith distance
    37                 double az,              //!< Azimuth
    38                 double lst,             //!< Local Sidereal Time
    39                 float mjd,              //!< MJD
    40                 float rotAngle,         //!< Rotator position angle
    41                 float temp,             //!< Temperature
    42                 float pressure,         //!< Pressure
    43                 float humidity,         //!< Relative humidity
    44                 float exptime           //!< Exposure time
    45     );
     208psExposureAlloc(double ra, double dec,  //!< Telescope boresight
     209                double ha,              //!< Hour angle
     210                double zd,              //!< Zenith distance
     211                double az,              //!< Azimuth
     212                double lst,             //!< Local Sidereal Time
     213                float mjd,              //!< MJD
     214                float rotAngle,         //!< Rotator position angle
     215                float temp,             //!< Temperature
     216                float pressure,         //!< Pressure
     217                float humidity,         //!< Relative humidity
     218                float exptime           //!< Exposure time
     219                );
    46220
    47221/** Destructor */
    48222void
    49223psExposureFree(psExposure *restrict myExp //!< Object to destroy
    50     );
    51 
    52 
    53 /***********************************************************************************************************/
    54 
    55 /** Cell details: specifies how the cell is mounted on its parent OTA */
    56 typedef struct {
    57     double x, y;                        //!< Position of cell in its OTA.  Specifies the position of the
    58                                         //!< (imaginary) pixel (0,0)
    59     double xErr, yErr;                  //!< Error in position of cell in the OTA.
    60     double rotation;                    //!< Rotation of cell in its OTA.  Specified from +x through +y
    61     int xSize, ySize;                   //!< Number of pixels in x and y
    62     double scale;                       //!< Relative pixel scales, if CCD pitch varies over the OTA. Specify
    63                                         //!< a positive scale for a left-handed coordinate system, negative
    64                                         //!< for right. If NULL, then every chip has identical scale, and
    65                                         //!< system is left-handed.
    66 } psCellDescription;
    67 
    68 /** Constructor */
    69 psCellDescription *
    70 psCellDescriptionAlloc(void);
    71 
    72 /** Destructor */
    73 void
    74 psCellDescriptionFree(psCellDescription *restrict myCell //!< Cell description to destroy
    75     );
    76 
    77 /***********************************************************************************************************/
    78 
    79 /** Array of cell descriptions */
    80 typedef struct {
    81     psType type;                        //!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
    82     int size;                           //!< Total number of elements available
    83     int n;                              //!< Number of elements in use
    84     double *arr;                        //!< The array data
    85 } psCellDescriptionArray;
    86 
    87 /** Constructor */
    88 psCellDescriptionArray *psCellDescriptionArrayAlloc(int s, //!< Total number of elements to make available
    89                                                     int n //!< Number of elements that will be used
    90                                                     );
    91 /** Reallocator */
    92 psCellDescriptionArray *psCellDescriptionArrayRealloc(psCellDescriptionArray *myArray, //!< Array to
    93                                                                                        //!< reallocate
    94                                                       int s //!< Total number of elements to make available
    95                                                       );
    96 /** Destructor */
    97 void psCellDescriptionArrayFree(psCellDescriptionArray *restrict myArray //!< Array to free
    98                                 );
    99 
    100 /***********************************************************************************************************/
    101 
    102 /** OTA details: specifies how the OTA is mounted on the focal plane */
    103 typedef struct {
    104     double x, y;                        //!< Position of OTA on the focal plane.  Specifies the position of
    105                                         //!< the bottom left-hand corner.
    106     double xErr, yErr;                  //!< Error in the position of the OTA.
    107     double rotation;                    //!< Rotation of OTA on the focal plane.  Specified from +x through +y
    108     psCellDescriptionArray *restrict cells; //!< Cell descriptions
    109     struct psOTAAstrom *astrom;         //!< OTA astrometry
    110     psExposure *exp;                    //!< Exposure data
    111 } psOTADescription;
    112 
    113 /** Constructor */
    114 psOTADescription *
    115 psOTADescriptionAlloc(void);
    116 
    117 /** Destructor. */
    118 void
    119 psOTADescriptionFree(psOTADescription *restrict myOTA //!< OTA description to destroy
    120     );
    121 
    122 /***********************************************************************************************************/
    123 
    124 /** Astrometric solution for an OTA.
    125  * There are four coordinate frames that we need to worry about:
    126  * 1. Chip frame: chip# plus x,y in pixels
    127  * 2. Focal plane frame: X,Y in microns
    128  * 3. Tangent plane: xi,eta in arcsec from the telescope boresight.
    129  * 4. Sky frame: RA,Dec
    130  *
    131  * 1 <--> 2: OTA description (parent of this struct) specifies how the chips are mounted on the focal plane.
    132  * 2 <--> 3: The astrometric solution corrects for distortions in the optics so we can go from what the
    133  * telescope sees on the focal plane to what it really should be like (i.e. the tangent plane).
    134  * 3 <--> 4: SLALib converts between the tangent plane and the celestial sphere using a set of numbers one
    135  * must calculate for each tangent point.
    136  *
    137  * Coordinate frames 2 and 3 are generally hidden from the user because all they care about is going between
    138  * frames 1 and 4.
    139  */
    140 typedef struct {
    141     /* Focal plane to and from tangent plane */
    142     psDPolynomial4D *restrict tpToFPX, *restrict tpToFPY; //!< General astrometric solution for tangent plane
    143                                                           //!< to focal plane
    144     psDPolynomial4D *restrict fpToTPXi, *restrict fpToTPEta; //!< General astrometric solution for focal plane
    145                                                              //!< to tangent plane
    146     psMatrix *pattern;                  //!< Fixed pattern distortions for focal plane to tangent plane (simply
    147                                         //!< * -1 for the reverse); MAY NEED TO BE REVISED UPON IMPLEMENTATION
    148     /* Tangent plane to and from the celestial sphere */
    149     psDoubleArray *restrict tp;         //!< Data needed to convert from the sky to the tangent plane and back;
    150                                         //!< produced by and used by SLALib (a.k.a. "Wallace's Grommit")
    151     psColourRef colorRef;               //!< Colour reference
    152     /* Characterisation of the solution */
    153     float rmsX, rmsY;                   //!< Dispersion in astrometric solution
    154     float chi2;                         //!< chi^2 of astrometric solution
    155 } psOTAAstrom;
    156 
    157 /** Constructor */
    158 psOTAAstrom *
    159 psOTAAstromAlloc(const psExposure *exp //!< Telescope pointing, used to initialise the tp data.
    160     );
    161 
    162 /** Destructor */
    163 void
    164 psOTAAstromFree(psOTAAstrom *restrict myAstrom  //!< Object to destroy
    165     );
    166 
    167 /***********************************************************************************************************/
    168 
    169 /* Calculating and applying astrometric solutions */
    170 
    171 /** Convert (RA,Dec) to (cell#,x,y) */
    172 psOTAPos *
    173 psSkyToOTA(const psSkyPos *restrict position, //!< Position on the sky
    174            const psOTADescription *restrict ota //!< OTA details
    175     );
    176 
    177 /** Convert (cell#,x,y) to (RA,Dec) */
    178 psSkyPos *
    179 psOTAToSky(const psOTAPos *restrict position, //!< Position on the detector
    180            const psOTADescription *restrict ota //!< OTA details
    181     );
    182 
    183 /** Fit astrometric solution to list of (chip#,x,y) and (RA,Dec) */
    184 int
    185 psFitAstrom(psOTADescription *restrict ota, //!< Initial guess for coefficients
    186             const psOTAPosArray *restrict detector, //!< Positions on OTA (chip#,x,y)
    187             const psSkyPosArray *restrict sky, //!< Positions on the sky (RA,Dec)
    188             const psExposure *exp       //!< Telescope pointing information, for airmass, parallactic angle
    189                                         //!< which may help set the astrometric solution
    190             );
    191 
    192 /***********************************************************************************************************/
    193 
    194 /* Functions needed for astrometry, and will likely be useful elsewhere */
    195 
    196 /** Get the airmass for a given position and sidereal time */
    197 float
    198 psGetAirmass(const psSkyPos *restrict position, //!< Position on the sky
    199              double siderealTime        //!< Sidereal time
    200              );
    201 
    202 /** Get the parallactic angle for a given position and sidereal time */
    203 float
    204 psGetParallactic(const psSkyPos *restrict position, //!< Position on the sky
    205                  double siderealTime    //!< Sidereal time
    206                  );
    207 
    208 /** Estimate atmospheric refraction, along the parallactic */
    209 float
    210 psGetRefraction(float colour,           //!< Colour of object
    211                 psColourRef colourRef,  //!< Colour reference
    212                 psExposure *exp         //!< Telescope pointing information, for airmass, temp and pressure
    213     );
    214 
    215 /***********************************************************************************************************/
     224               );
    216225
    217226#endif
Note: See TracChangeset for help on using the changeset viewer.