IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 21, 2005, 11:03:53 AM (21 years ago)
Author:
eugene
Message:

various cleanups and fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroBuildFPA.c

    r5510 r5560  
    1818    // allocate the structures
    1919
    20     pmFPA *fpa = pmFPAAlloc ();
     20    pmFPA *fpa = pmFPAAlloc (NULL, NULL);
    2121
    22     fpa->chips = psArrayAlloc (Nchips);
     22    psArrayRealloc (fpa->chips, Nchips);
    2323    for (int i = 0; i < Nchips; i++) {
     24        pmChip *chip = pmChipAlloc (fpa);
    2425
    25         pmChip *chip = pmChipAlloc ();
    26         chip->fpa = fpa; // assign parent fpa (view only; don't free)
     26        psArrayRealloc (chip->cells, Ncells);
     27        for (int j = 0; j < Ncells; j++) {
     28            pmCell *cell = pmCellAlloc (chip);
    2729
    28         chip->cells = psArrayAlloc (Ncells);
    29         for (int j = 0; j < Ncells; j++) {
    30 
    31             pmCell *cell = pmCellAlloc ();
    32             cell->chip = chip;      // assign parent chip (view only; don't free)
    33             cell->header = header;  // XXX EAM : extend this function to take more than header
    34 
     30            // XXX EAM : extend this function to take more than one header
     31            cell->header = header;     
    3532            pmCellInterpretWCS (cell, header);
    3633
    37             cell->readouts = psArrayAlloc (Nreadouts);
     34            psArrayRealloc (cell->readouts, Nreadouts);
    3835            for (int k = 0; k < Nreadouts; k++) {
     36                pmReadout *readout = pmReadoutAlloc (cell);
    3937
    40                 pmReadout *readout = pmReadoutAlloc ();
    41                 readout->stars  = stars;   // XXX EAM : need more than one stars...
     38                // XXX EAM : extend this function to take more than one stars...
     39                psMetadataAdd (readout->analysis, PS_LIST_TAIL, "STARS.FULLSET", PS_DATA_ARRAY, "stars from analysis", stars);
    4240
    43                 cells->readouts->data[j] = readout;
     41                // XXX EAM : this information should be in the header...
     42                readout->col0 = readout->row0 = 0;
     43                readout->colBins = readout->rowBins = 1;
     44
     45                cell->readouts->data[j] = readout;
    4446            }
    45             chips->cells->data[j] = cell;
     47            chip->cells->data[j] = cell;
    4648        }
    4749        fpa->chips->data[i] = chip;
     
    5355bool pmCellInterpretWCS (pmCell *cell, psMetadata *header) {
    5456
     57    pmChip *chip;
     58    pmFPA  *fpa;
     59    bool status;
     60    psProjectionType type;
    5561    float crval1, crval2, crpix1, crpix2, cdelt1, cdelt2;
    5662    float pc1_1, pc1_2, pc2_1, pc2_2;
    5763
    5864    // *** interpret header data, convert to crval(i), etc
    59     char *ctype = pmMetadataLookupPtr (&status, header, "CTYPE2");
     65    char *ctype = psMetadataLookupPtr (&status, header, "CTYPE2");
    6066    if (!status) {
    6167        psLogMsg ("psastro", 2, "warning: no WCS metadata in header\n");
     
    8591
    8692        // test the CROTAi varient:
    87         float rotate = psMetadataLookupF32 (&status, header, "CROTA2");
     93        double rotate = psMetadataLookupF32 (&status, header, "CROTA2");
    8894        if (status) {
    89             Lambda = cdelt2 / cdelt1;
     95            double Lambda = cdelt2 / cdelt1;
    9096            pc1_1 =  cos(rotate*RAD_DEG);
    9197            pc1_2 = -sin(rotate*RAD_DEG) * Lambda;
     
    131137
    132138    // XXX EAM : these must already be set
    133     chip = cell->chip;
    134     fpa = chip->fpa;
     139    chip = cell->parent;
     140    fpa  = chip->parent;
    135141
    136142    // set toChip to identity as default
    137     // XXX EAM : psPlaneTransformAlloc uses nTerm not nOrder (bug 581)
    138     // XXX EAM : define these in the config?
    139     // int nX = psMetadataLookupS32 (&status, myHeader, "CHIP.NX");
    140     // int nY = psMetadataLookupS32 (&status, myHeader, "CHIP.NY");
    141     cell->toChip   = psPlaneTransformAlloc (2, 2);
     143    // XXX EAM : can we actually use higher order?
     144    int nX = psMetadataLookupS32 (&status, header, "PSASTRO.CHIP.NX");
     145    if (!status) nX = 1;
     146    int nY = psMetadataLookupS32 (&status, header, "PSASTRO.CHIP.NY");
     147    if (!status) nY = 1;
     148
     149    cell->toChip   = psPlaneTransformAlloc (1, 1);
    142150    cell->toChip->x->coeff[1][0] = 1;
    143151    cell->toChip->x->mask[1][1]  = 1;
     
    152160
    153161    // XXX EAM : psPlaneTransformAlloc uses nTerm not nOrder (bug 581)
    154     chip->toFPA   = psPlaneTransformAlloc (2, 2);
     162    // XXX EAM : I've fixed this in pslib eam_rel8_b2
     163    chip->toFPA   = psPlaneTransformAlloc (1, 1);
    155164   
    156165    chip->toFPA->x->coeff[0][0] = crpix1;
     
    164173    chip->toFPA->y->mask[1][1]  = 1;
    165174
     175    chip->fromFPA = p_psPlaneTransformLinearInvert (chip->toFPA);
     176
    166177    // set toTPA to identity as default
    167178    // XXX EAM : psPlaneDistortAlloc uses nTerm not nOrder (bug 581)
    168179    if (fpa->toTPA == NULL) {
    169         fpa->toTPA   = psPlaneDistortAlloc (2, 2, 1, 1);
     180        fpa->toTPA   = psPlaneDistortAlloc (1, 1, 0, 0);
    170181        fpa->toTPA->x->coeff[1][0][0][0] = 1;
    171182        fpa->toTPA->x->mask[1][1][0][0]  = 1;
     
    173184        fpa->toTPA->y->coeff[0][1][0][0] = 1;
    174185        fpa->toTPA->y->mask[1][1][0][0]  = 1;
     186        fpa->fromTangentPlane = psPlaneDistortInvert (fpa->toTangentPlane);
    175187    } else {
    176188        psLogMsg ("psastro", 2, "warning: fpa distortion already defined\n");
     
    178190
    179191    // center of projection is (0,0) coordinate of TPA
    180     fpa->toSky = psProjectionAlloc (crval1, crval2, cdelt1, cdelt2, type);
     192    fpa->toSky = psProjectionAlloc (crval1*RAD_DEG, crval2*RAD_DEG, cdelt1*RAD_DEG, cdelt2*RAD_DEG, type);
    181193    return true;
    182194}
Note: See TracChangeset for help on using the changeset viewer.