IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 4, 2006, 7:02:16 AM (20 years ago)
Author:
eugene
Message:

substantial updates

File:
1 edited

Legend:

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

    r7154 r7332  
    11# include "psastro.h"
    22
    3 bool psastroMosaicGetRefstars (pmFPA *fpa, psArray *refs, psMetadata *recipe) {
     3bool psastroMosaicGetRefstars (pmConfig *config, psArray *refs) {
    44
     5    bool status;
    56    pmChip *chip = NULL;
    67    pmCell *cell = NULL;
    78    pmReadout *readout = NULL;
     9
     10    // select the current recipe
     11    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, "PSASTRO");
     12    if (!recipe) {
     13        psErrorStackPrint(stderr, "Can't find PSASTRO recipe!\n");
     14        exit(EXIT_FAILURE);
     15    }
     16
     17    // select the input data sources
     18    pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");
     19    if (!input) {
     20        psErrorStackPrint(stderr, "Can't find input data!\n");
     21        exit(EXIT_FAILURE);
     22    }
     23
     24    float fieldExtra = psMetadataLookupS32 (&status, recipe, "PSASTRO.FIELD.EXTRA");
     25    if (!status) fieldExtra = 0.0;
     26
    827    pmFPAview *view = pmFPAviewAlloc (0);
     28    pmFPA *fpa = input->fpa;
    929
    1030    // this loop selects the matched stars for all chips
     
    2242                if (! readout->data_exists) { continue; }
    2343
    24                 // select the raw objects for this readout
    25                 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.OBJECTS");
    26                 if (rawstars == NULL) { continue; }
     44                // read WCS data from the corresponding header
     45                pmHDU *hdu = pmFPAviewThisHDU (view, fpa);
    2746
     47                int Nx = psMetadataLookupS32 (&status, hdu->header, "NAXIS1");
     48                int Ny = psMetadataLookupS32 (&status, hdu->header, "NAXIS2");
     49
     50                float minX = -fieldExtra*Nx;
     51                float maxX = (1+fieldExtra)*Nx;
     52                float minY = -fieldExtra*Ny;
     53                float maxY = (1+fieldExtra)*Ny;
     54               
    2855                // the refstars is a subset within range of this chip
    2956                psArray *refstars = psArrayAlloc (100);
     57
     58                int Nst = 0;
    3059
    3160                // select the reference objects within range of this readout
    3261                // project the reference objects to this chip
    3362                for (int i = 0; i < refs->n; i++) {
    34                     pmAstromObj *ref = refs->data[i];
     63                    pmAstromObj *ref = pmAstromObjCopy(refs->data[i]);
    3564       
    3665                    p_psProject (ref->TP, ref->sky, fpa->projection);
     
    3867                    psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP);
    3968
    40                     // XXX what is the X,Y range of the selected chip?
    41                     // XXX for the moment, force these to be good for Megacam
    42                     if (ref->chip->x <  -10) continue;
    43                     if (ref->chip->x > 2060) continue;
    44                     if (ref->chip->y <  -10) continue;
    45                     if (ref->chip->y > 4610) continue;
     69                    // limit the X,Y range of the refs to the selected chip
     70                    if (ref->chip->x < minX) continue;
     71                    if (ref->chip->x > maxX) continue;
     72                    if (ref->chip->y < minY) continue;
     73                    if (ref->chip->y > maxY) continue;
    4674                   
     75                    if (Nst < 0) {
     76                        fprintf (stderr, "dn: %f,%f <- %f,%f <- %f,%f <- %f,%f\n",
     77                                 ref->chip->x, ref->chip->y,
     78                                 ref->FP->x, ref->FP->y,
     79                                 ref->TP->x, ref->TP->y,
     80                                 ref->sky->r, ref->sky->d);
     81
     82                        psSphere *sk = psSphereAlloc();
     83                        psPlane *fp = psPlaneAlloc();
     84                        psPlane *tp = psPlaneAlloc();
     85
     86                        psPlaneTransformApply (fp, chip->toFPA, ref->chip);
     87                        psPlaneDistortApply (tp, fpa->toTangentPlane, fp, 0.0, 0.0);
     88                        p_psDeproject (sk, tp, fpa->projection);
     89
     90                        fprintf (stderr, "up: %f,%f -> %f,%f -> %f,%f -> %f,%f\n",
     91                                 ref->chip->x, ref->chip->y,
     92                                 fp->x, fp->y,
     93                                 tp->x, tp->y,
     94                                 sk->r, sk->d);
     95                    }
     96                    Nst ++;
     97
    4798                    psArrayAdd (refstars, 100, ref);
    4899                }
     100                psTrace (__func__, 4, "Added %d refstars\n", refstars->n);
     101
    49102                psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS", PS_DATA_ARRAY, "astrometry matches", refstars);
     103
     104                // XXX test point
     105                if (0) {
     106                    pmChip *chip1 = fpa->chips->data[10];
     107                    pmCell *cell1 = chip1->cells->data[0];
     108                    pmReadout *readout1 = cell1->readouts->data[0];
     109                    psArray *refstars1 = psMetadataLookupPtr (NULL, readout1->analysis, "PSASTRO.REFSTARS");
     110                    pmAstromObj *ref1 = refstars1->data[0];
     111                    fprintf (stderr, "test 3: %f %f  %f %f  %f %f\n", ref1->chip->x, ref1->chip->y, ref1->FP->x, ref1->FP->y, ref1->sky->r, ref1->sky->d);
     112                }
     113
     114                psFree (refstars);
    50115            }
    51116        }
    52117    }
     118
     119    psFree (view);
    53120    return true;
    54121}
Note: See TracChangeset for help on using the changeset viewer.