IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 12, 2007, 2:25:32 PM (19 years ago)
Author:
Paul Price
Message:

Only read header of template skycell, and create target from that.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarpDefine.c

    r12526 r12826  
    77    psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSWARP_RECIPE);
    88    if (!recipe) {
    9         psError(PSWARP_ERR_CONFIG, true, "Can't find PSWARP recipe!\n");
    10         return false;
     9        psError(PSWARP_ERR_CONFIG, true, "Can't find PSWARP recipe!\n");
     10        return false;
    1111    }
    1212
     
    1414    pmFPAfile *skycell = psMetadataLookupPtr (NULL, config->files, "PSWARP.SKYCELL");
    1515    if (!skycell) {
    16         psError(PSWARP_ERR_CONFIG, true, "Can't find skycell data!\n");
    17         return false;
     16        psError(PSWARP_ERR_CONFIG, true, "Can't find skycell data!\n");
     17        return false;
    1818    }
    1919
    2020    // open the full skycell file; no need to defer different depths. only load the header data
    21     // XXX force fileLevel and view to be chip. is this right?
    22     // skycell->type = PM_FPA_FILE_HEADER;
    23     // skycell->fileLevel = PM_FPA_LEVEL_CHIP;
    2421    pmFPAview *view = pmFPAviewAlloc (0);
    2522    pmFPAfileOpen (skycell, view, config);
    26     pmFPAfileRead (skycell, view, config);
     23
     24    // Read header and create target
     25    {
     26        pmFPAReadHeaderSet(skycell->fpa, skycell->fits, config->database);
     27        view->chip = 0;
     28        view->cell = 0;
     29        view->readout = 0;
     30        pmCell *source = pmFPAfileThisCell(config->files, view, "PSWARP.SKYCELL"); // Source cell
     31        pmHDU *hdu = pmHDUFromCell(source); // HDU for source
     32        if (!hdu || !hdu->header) {
     33            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find header for sky cell.");
     34            return false;
     35        }
     36        int numCols = psMetadataLookupS32(NULL, hdu->header, "NAXIS1"); // Number of columns
     37        int numRows = psMetadataLookupS32(NULL, hdu->header, "NAXIS2"); // Number of rows
     38
     39        pmCell *target = pmFPAfileThisCell(config->files, view, "PSWARP.OUTPUT"); // Target cell
     40        pmReadout *readout = pmReadoutAlloc(target); // Target readout
     41        readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     42        psFree(readout);                // Drop reference
     43
     44        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.XBIN");
     45        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.YBIN");
     46        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.XSIZE");
     47        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.YSIZE");
     48        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.XPARITY");
     49        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.YPARITY");
     50        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.X0");
     51        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.Y0");
     52    }
    2753
    2854    // XXX this is not a sufficient test
     
    3359    bool bilevelAstrometry = false;
    3460    if (phu) {
    35         char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
    36         if (ctype) {
    37             bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
    38         }
     61        char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
     62        if (ctype) {
     63            bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
     64        }
    3965    }
    4066    if (bilevelAstrometry) {
    41         pmAstromReadBilevelMosaic (skycell->fpa, phu->header);
    42         pmAstromReadBilevelChip (chip, hdu->header);
     67        pmAstromReadBilevelMosaic (skycell->fpa, phu->header);
     68        pmAstromReadBilevelChip (chip, hdu->header);
    4369    } else {
    44         // we use a default FPA pixel scale of 1.0
    45         pmAstromReadWCS (skycell->fpa, chip, hdu->header, 1.0);
     70        // we use a default FPA pixel scale of 1.0
     71        pmAstromReadWCS (skycell->fpa, chip, hdu->header, 1.0);
    4672    }
    4773
     
    4975    pmFPAfile *output = psMetadataLookupPtr (NULL, config->files, "PSWARP.OUTPUT");
    5076    if (!output) {
    51         psError(PSWARP_ERR_CONFIG, true, "Can't find output data!\n");
    52         return false;
     77        psError(PSWARP_ERR_CONFIG, true, "Can't find output data!\n");
     78        return false;
    5379    }
    54     // output->fileLevel = PM_FPA_LEVEL_CHIP;
    55 
    56     pmFPAfileCreate(output, view, config);
    57 
    58 # if 0
    59     // XXX This function should only load the skycell headers and create the output based
    60     // on that file.  I'm going to ask paul to look into this
    61     pmFPACopyStructure (output->fpa, skycell->fpa, 1, 1);
    62 
    63     // XXX can I just create the needed readout?
    64     // create the needed readouts
    65     for (int i = 0; i < output->fpa->chips->n; i++) {
    66         pmChip *chip = output->fpa->chips->data[i];
    67         for (int j = 0; j < chip->cells->n; j++) {
    68             pmCell *cell = chip->cells->data[j];
    69             pmReadout *readout;
    70             if (cell->readouts->n == 0) {
    71                 readout = pmReadoutAlloc (cell);
    72             }
    73             bool mdok1 = false;
    74             bool mdok2 = false;
    75             pmHDU *hdu = pmHDUGetLowest (output->fpa, chip, cell);
    76             int Nx = psMetadataLookupS32(&mdok1, hdu->header, "NAXIS1"); // Trim section
    77             int Ny = psMetadataLookupS32(&mdok2, hdu->header, "NAXIS2"); // Trim section
    78             if (!mdok1 || !mdok2) {
    79                 psError(PS_ERR_IO, true, "NAXIS1 or NAXIS2 not set --- unable to create output image.\n");
    80                 return false;
    81             }
    82             readout->image = psImageAlloc (Nx, Ny, PS_TYPE_F32);
    83             psFree (readout);
    84         }
    85     }
    86 # endif
    8780
    8881    psFree (view);
Note: See TracChangeset for help on using the changeset viewer.