- Timestamp:
- May 7, 2013, 12:01:01 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130419/pswarp/src/pswarpDefineLayout.c
r35512 r35527 14 14 bool pswarpDefineLayout (pmConfig *config) { 15 15 16 // place input astrometry transformations in 'input' 17 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PSWARP.INPUT"); 18 if (!input) { 19 psError(PSWARP_ERR_CONFIG, false, "Can't find input data!\n"); 20 return false; 21 } 22 // input astrometry may be embedded in 'input' or supplied separately 23 pmFPAfile *astrom = psMetadataLookupPtr(NULL, config->files, "PSWARP.ASTROM"); 24 if (!astrom) { 25 astrom = input; 26 } 27 if (!pswarpLoadAstrometry (input, astrom, config)) { 28 psError(PSWARP_ERR_CONFIG, false, "problem loading input astrometry\n"); 29 return false; 30 } 31 32 pmFPAfile *output = psMetadataLookupPtr(NULL, config->files, "PSWARP.OUTPUT"); 16 bool status = false; 17 18 pmFPAfile *output = psMetadataLookupPtr(&status, config->files, "PSWARP.OUTPUT"); 33 19 if (!output) { 34 20 psError(PSWARP_ERR_CONFIG, false, "Can't find output data!\n"); … … 36 22 } 37 23 // select the input data sources 38 pmFPAfile *skycell = psMetadataLookupPtr ( NULL, config->files, "PSWARP.SKYCELL");24 pmFPAfile *skycell = psMetadataLookupPtr (&status, config->files, "PSWARP.SKYCELL"); 39 25 if (!skycell) { 40 26 psError(PSWARP_ERR_CONFIG, false, "Can't find skycell data!\n"); … … 46 32 } 47 33 48 // given the input data, determine which output elements should be generated 49 // and generate the appropriate images 50 51 // find the R,D center for the skycell, use for common projection 52 psProjection *frame = pswarpLocalFrame (skycell->fpa); 53 54 // generate Lmin,max, Mmin,max for both datasets 55 pswarpBounds *srcBounds = pswarpMakeBounds (input->fpa, frame); 56 pswarpBounds *tgtBounds = pswarpMakeBounds (skycell->fpa, frame); 57 58 // find the output (tgt) chips which overlap the input (src) chips 59 pswarpFindOverlap (input->fpa, output->fpa, srcBounds, tgtBounds); 34 // chips are not processed unless we have determined they overlap the inputs 35 pmFPAExcludeChips (output->fpa); 36 37 int nInputs = psMetadataLookupS32(&status, config->arguments, "NUM_INPUTS"); 38 if (!status) { 39 psError(PSWARP_ERR_DATA, true, "number of inputs is not defined (programming error)"); 40 return false; 41 } 42 43 for (int i = 0; i < nInputs; i++) { 44 // place input astrometry transformations in 'input' 45 pmFPAfile *input = pmFPAfileSelectSingle(config->files, "PSWARP.INPUT", i); 46 if (!input) { 47 psError(PSWARP_ERR_CONFIG, false, "Can't find input data!\n"); 48 return false; 49 } 50 51 // input astrometry may be embedded in 'input' or supplied separately 52 pmFPAfile *astrom = pmFPAfileSelectSingle(config->files, "PSWARP.ASTROM", i); 53 if (!astrom) { 54 astrom = input; 55 } 56 if (!pswarpLoadAstrometry (input, astrom, config)) { 57 psError(PSWARP_ERR_CONFIG, false, "problem loading input astrometry\n"); 58 return false; 59 } 60 61 // given the input data, determine which output elements should be generated 62 // and generate the appropriate images 63 64 // find the R,D center for the skycell, use for common projection 65 psProjection *frame = pswarpLocalFrame (skycell->fpa); 66 67 // generate Lmin,max, Mmin,max for both datasets 68 pswarpBounds *srcBounds = pswarpMakeBounds (input->fpa, frame); 69 pswarpBounds *tgtBounds = pswarpMakeBounds (skycell->fpa, frame); 70 71 // find the output (tgt) chips which overlap the input (src) chips 72 pswarpFindOverlap (input->fpa, output->fpa, srcBounds, tgtBounds); 73 psFree (srcBounds); 74 psFree (tgtBounds); 75 } 60 76 61 77 // The loop below generates the output pixels. XXX Should this be deferred until we … … 86 102 return false; 87 103 } 88 int numCols = psMetadataLookupS32( NULL, hdu->header, "NAXIS1"); ///< Number of columns89 int numRows = psMetadataLookupS32( NULL, hdu->header, "NAXIS2"); ///< Number of rows104 int numCols = psMetadataLookupS32(&status, hdu->header, "NAXIS1"); ///< Number of columns 105 int numRows = psMetadataLookupS32(&status, hdu->header, "NAXIS2"); ///< Number of rows 90 106 if ((numCols == 0) || (numRows == 0)) { 91 107 psError(PSWARP_ERR_DATA, false, "skycell has invalid dimensions %d x %d", numCols, numRows); … … 97 113 pmReadout *readout = pmReadoutAlloc(cell); ///< output readout 98 114 readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32); 115 99 116 psImageInit(readout->image, NAN); 100 117 psFree(readout); // Drop reference … … 129 146 # include "pswarpFileNames.h" 130 147 148 static int Nout = 0; 149 131 150 // XX function for tests 132 151 bool pswarpDumpOutput (pmConfig *config) { … … 144 163 pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT"); 145 164 165 pmFPAview *view = pmFPAviewAlloc(0); 166 146 167 pmChip *chip; 147 pmFPAview *view = pmFPAviewAlloc(0);148 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {149 psError(psErrorCodeLast(), false, "Unable to read files.");150 goto DONE;151 }152 168 while ((chip = pmFPAviewNextChip (view, output->fpa, 1)) != NULL) { 153 169 psTrace ("pswarp", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 154 170 if (!chip->process || !chip->file_exists) { continue; } 155 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 156 psError(psErrorCodeLast(), false, "Unable to read files."); 157 goto DONE; 158 } 171 159 172 pmCell *cell; 160 173 while ((cell = pmFPAviewNextCell (view, output->fpa, 1)) != NULL) { 161 174 psTrace ("pswarp", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 162 175 if (!cell->process || !cell->file_exists) { continue; } 163 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE) || 164 !pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { 165 psError(psErrorCodeLast(), false, "Unable to read files."); 166 goto DONE; 176 177 // process each of the readouts 178 pmReadout *readout; 179 while ((readout = pmFPAviewNextReadout(view, output->fpa, 1)) != NULL) { 180 if (!readout->data_exists) { 181 continue; 182 } 183 184 char name[64]; 185 snprintf (name, 64, "dumpwarp.%02d.fits", Nout); 186 Nout ++; 187 188 psphotSaveImage (NULL, readout->image, name); 167 189 } 168 190 }
Note:
See TracChangeset
for help on using the changeset viewer.
