Changeset 12826
- Timestamp:
- Apr 12, 2007, 2:25:32 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/pswarp/src/pswarpDefine.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarpDefine.c
r12526 r12826 7 7 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSWARP_RECIPE); 8 8 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; 11 11 } 12 12 … … 14 14 pmFPAfile *skycell = psMetadataLookupPtr (NULL, config->files, "PSWARP.SKYCELL"); 15 15 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; 18 18 } 19 19 20 20 // 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;24 21 pmFPAview *view = pmFPAviewAlloc (0); 25 22 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 } 27 53 28 54 // XXX this is not a sufficient test … … 33 59 bool bilevelAstrometry = false; 34 60 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 } 39 65 } 40 66 if (bilevelAstrometry) { 41 pmAstromReadBilevelMosaic (skycell->fpa, phu->header);42 pmAstromReadBilevelChip (chip, hdu->header); 67 pmAstromReadBilevelMosaic (skycell->fpa, phu->header); 68 pmAstromReadBilevelChip (chip, hdu->header); 43 69 } else { 44 // we use a default FPA pixel scale of 1.045 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); 46 72 } 47 73 … … 49 75 pmFPAfile *output = psMetadataLookupPtr (NULL, config->files, "PSWARP.OUTPUT"); 50 76 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; 53 79 } 54 // output->fileLevel = PM_FPA_LEVEL_CHIP;55 56 pmFPAfileCreate(output, view, config);57 58 # if 059 // XXX This function should only load the skycell headers and create the output based60 // on that file. I'm going to ask paul to look into this61 pmFPACopyStructure (output->fpa, skycell->fpa, 1, 1);62 63 // XXX can I just create the needed readout?64 // create the needed readouts65 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 section77 int Ny = psMetadataLookupS32(&mdok2, hdu->header, "NAXIS2"); // Trim section78 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 # endif87 80 88 81 psFree (view);
Note:
See TracChangeset
for help on using the changeset viewer.
