IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19506


Ignore:
Timestamp:
Sep 11, 2008, 3:04:49 PM (18 years ago)
Author:
eugene
Message:

various fixes to make the model boresite and rotation consistent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/astrom/pmAstrometryModel.c

    r18601 r19506  
    99 *
    1010 *  @author EAM, IfA
    11  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2008-07-17 22:38:15 $
     11 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2008-09-12 01:04:49 $
    1313 *
    1414 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    250250bool pmAstromModelWriteFP (pmFPAfile *file) {
    251251
    252     bool status;
    253 
    254252    psMetadata *header = psMetadataAlloc();
    255253    psMetadataAddStr(header, PS_LIST_TAIL, "COORD",    PS_META_REPLACE, "name of this layer",   "FOCAL_PLANE");
     
    260258    psArray *model = psArrayAllocEmpty (1);
    261259
    262     // XXX is this or the tpa region correct?
    263     psRegion *region = pmAstromFPAExtent (file->fpa);
    264 
    265     // rotate the toTPA to have 0.0 posangle
    266     float posangle = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.POSANGLE");
    267 
    268     // the to/from TPA transform currently has rotation of posangle; remove it & create the toTPA version
    269     psPlaneTransform *fromTPA = psPlaneTransformRotate (NULL, file->fpa->fromTPA, -posangle);
    270     psPlaneTransform *toTPA   = psPlaneTransformInvert(NULL, fromTPA, *region, 50);
     260    // region over which the fromTPA projection is valid
     261    psRegion *region = pmAstromFPInTP (file->fpa);
     262
     263    psPlaneTransform *toTPA   = file->fpa->toTPA;
    271264
    272265    for (int i = 0; i <= toTPA->x->nX; i++) {
     
    315308    bool status;
    316309
    317     // get the boresite model parameters
     310    // get the boresite model parameters.  these track the position of the boresite
     311    // as a function of the rotator angle
    318312    float Xo = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.X0");
    319313    float Yo = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.Y0");
     
    322316    float To = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.T0");
    323317    float Po = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.P0");
     318
     319    // the PosZero is the offset between the reported and actual POSANGLE values
    324320    float PosZero = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.POS_ZERO");  /// XXX be consistent with degrees v radians
    325321    char *refChip = psMetadataLookupStr (&status, file->fpa->concepts, "FPA.REF.CHIP");
     
    341337    psMetadataAddF32(row,    PS_LIST_TAIL, "MINY",     PS_META_REPLACE, "range", region->y0);
    342338    psMetadataAddF32(row,    PS_LIST_TAIL, "MAXY",     PS_META_REPLACE, "range", region->y1);
    343 
    344     // psMetadataAddF32(row,    PS_LIST_TAIL, "XREF",     PS_META_REPLACE, "", file->fpa->toSky->R  * PS_DEG_RAD);
    345     // psMetadataAddF32(row,    PS_LIST_TAIL, "YREF",     PS_META_REPLACE, "", file->fpa->toSky->D  * PS_DEG_RAD);
    346339
    347340    psMetadataAddF32(row,    PS_LIST_TAIL, "XSCALE",   PS_META_REPLACE, "", file->fpa->toSky->Xs * PS_DEG_RAD);
     
    353346    psMetadataAddF32(row,    PS_LIST_TAIL, "BORE_T0",  PS_META_REPLACE, "boresite parameter", To);
    354347    psMetadataAddF32(row,    PS_LIST_TAIL, "BORE_P0",  PS_META_REPLACE, "boresite parameter", Po);
    355     psMetadataAddF32(row,    PS_LIST_TAIL, "POS_ZERO", PS_META_REPLACE, "boresite parameter", PosZero);
    356     psMetadataAddStr(row,    PS_LIST_TAIL, "REF_CHIP", PS_META_REPLACE, "boresite parameter", refChip);
     348
     349    psMetadataAddF32(row,    PS_LIST_TAIL, "POS_ZERO", PS_META_REPLACE, "POSANGLE offset (degrees)", PosZero);
     350    psMetadataAddStr(row,    PS_LIST_TAIL, "REF_CHIP", PS_META_REPLACE, "reference chip for model", refChip);
    357351
    358352    psArrayAdd (model, 100, row);
     
    454448bool pmAstromModelReadPHU (pmFPAfile *file) {
    455449
    456     fprintf (stderr, "not sure we need to read PHU\n");
     450    // not necessary to read the PHU
    457451    return true;
    458452}
     
    500494    }
    501495
    502     // XXX do I need anything from the header?
     496    // load the header
    503497    psMetadata *header = psFitsReadHeader(NULL, file->fits); // The FITS header
    504498    if (!header) psAbort("cannot read model header");
     
    507501    psArray *model = psFitsReadTable (file->fits);
    508502    if (!model) psAbort("cannot read model");
    509     fprintf (stderr, "read %ld rows from FP\n", model->n);
     503    psLogMsg ("psModules.astrom", 4, "read %ld rows from FP\n", model->n);
    510504
    511505    // parse the model entries
     
    535529        int iy = psMetadataLookupS32(&status, row, "YORDER");  REQUIRE (status, "missing YORDER");
    536530
    537         // XXX do I need to use this or can i rely on the camera concepts?
    538         // minX = psMetadataLookupF32(&status, row, "MINX");
    539         // maxX = psMetadataLookupF32(&status, row, "MAXX");
    540         // minY = psMetadataLookupF32(&status, row, "MINY");
    541         // maxY = psMetadataLookupF32(&status, row, "MAXY");
    542 
    543         // XXX need to include mask values
    544531        chip->toFPA->x->coeff[ix][iy]    = psMetadataLookupF32(&status, row, "POLY_X");
    545532        chip->toFPA->y->coeff[ix][iy]    = psMetadataLookupF32(&status, row, "POLY_Y");
     
    584571    // read the complete model data at one shot
    585572    psArray *model = psFitsReadTable (file->fits);
    586     fprintf (stderr, "read %ld rows from FP\n", model->n);
     573    psLogMsg ("psModules.astrom", 4, "read %ld rows from FP\n", model->n);
    587574
    588575    // parse the model
     
    644631
    645632    psArray *model = psFitsReadTable (file->fits);
    646     fprintf (stderr, "read %ld rows from TP\n", model->n);
     633    psLogMsg ("psModules.astrom", 4, "read %ld rows from TP\n", model->n);
    647634    if (model->n != 1) psAbort("invalid number of rows in TP model (%ld)", model->n);
    648635
     
    679666
    680667    psArray *model = psFitsReadTable (file->fits);
    681     fprintf (stderr, "read %ld rows from SKY\n", model->n);
     668    psLogMsg ("psModules.astrom", 4, "read %ld rows from SKY\n", model->n);
    682669    if (model->n != 1) psAbort("invalid number of rows in SKY model (%ld)", model->n);
    683670
    684671    // XXX not much information of interest in this table...
     672
     673    // generate a template projection for comparisons
     674    psFree (file->fpa->toSky);
     675    file->fpa->toSky = psProjectionAlloc (0.0, 0.0, PS_RAD_DEG/3600.0, PS_RAD_DEG/3600.0, PS_PROJ_DIS);
    685676
    686677    psFree (model);
     
    698689    double DEC = psMetadataLookupF64 (&status, concepts, "FPA.DEC"); REQUIRE (status, "missing FPA.DEC");
    699690    double POS = PM_RAD_DEG * psMetadataLookupF64 (&status, concepts, "FPA.POSANGLE"); REQUIRE (status, "missing FPA.POSANGLE");
    700     // double ROT = psMetadataLookupF64 (&status, concepts, "FPA.ROTANGLE"); REQUIRE (status, "missing FPA.ROTANGLE");
    701691
    702692    // get projection scale; center is supplied
     
    721711
    722712    // apply true posangle = -(POS - POS_ZERO)
     713    psLogMsg ("psModules.astrom", 4, "Position Angle: %f, Model Position Angle Zero Point: %f\n", POS, PosZero);
    723714    psPlaneTransform *fromTPA = psPlaneTransformRotate (NULL, file->fpa->fromTPA, (POS - PosZero));
    724715    psFree (file->fpa->fromTPA);
     
    728719    psFree (file->fpa->toTPA);
    729720    file->fpa->toTPA = psPlaneTransformInvert(NULL, file->fpa->fromTPA, *region, 50);
     721    psFree (region);
    730722
    731723    // current position of the nominal boresite in refChip coordinates
    732724    double X = Xo + RX*cos(POS - To)*cos(Po) + RY*sin(POS - To)*sin(Po);
    733725    double Y = Yo + RY*sin(POS - To)*cos(Po) - RX*cos(POS - To)*sin(Po);
     726    psLogMsg ("psModules.astrom", 4, "Boresite coords on reference chip: %f, %f\n", X, Y);
    734727
    735728    // get reference chip from name
     
    742735    psSphere *boreSky = psSphereAlloc();
    743736
    744     // find the true RA,DEC coord of the mirror of the reported boresite
    745     boreCH->x = -X;
    746     boreCH->y = -Y;
     737    // find the FP coord of the reported boresite location
     738    boreCH->x = X;
     739    boreCH->y = Y;
    747740    psPlaneTransformApply (boreFP, chip->toFPA, boreCH);
     741
     742    // find the true RA,DEC coord of the mirror of the reported boresite FP location
     743    boreFP->x = -boreFP->x;
     744    boreFP->y = -boreFP->y;
    748745    psPlaneTransformApply (boreTP, file->fpa->toTPA, boreFP);
    749746    psDeproject (boreSky, boreTP, file->fpa->toSky);
     
    761758    psFree (boreSky);
    762759
    763     psFree (region);
    764760    return (true);
    765761}
Note: See TracChangeset for help on using the changeset viewer.