Changeset 41510
- Timestamp:
- Mar 3, 2021, 3:05:40 PM (5 years ago)
- Location:
- trunk/pswarp/src
- Files:
-
- 6 edited
-
pswarpCleanup.c (modified) (7 diffs)
-
pswarpDefineLayout.c (modified) (1 diff)
-
pswarpLoop.c (modified) (1 diff)
-
pswarpLoopBackground.c (modified) (7 diffs)
-
pswarpTransformReadout.c (modified) (1 diff)
-
pswarpUpdateMetadata.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarpCleanup.c
r37053 r41510 14 14 // Lists of file rules which we may need to save here 15 15 static char *outputFiles[] = { 16 "PSWARP.OUTPUT",17 "PSWARP.OUTPUT.MASK",18 "PSWARP.OUTPUT.VARIANCE",19 "PSWARP.OUTPUT.BKGMODEL",20 "PSWARP.OUTPUT.SOURCES",21 "PSPHOT.OUTPUT",22 "PSPHOT.RESID",23 "PSPHOT.BACKMDL",24 "PSPHOT.BACKMDL.STDEV",25 "PSPHOT.BACKGND",26 "PSPHOT.BACKSUB",27 "PSPHOT.PSF.SAVE",28 "SOURCE.PLOT.MOMENTS",29 "SOURCE.PLOT.PSFMODEL",30 "SOURCE.PLOT.APRESID",31 NULL16 "PSWARP.OUTPUT", 17 "PSWARP.OUTPUT.MASK", 18 "PSWARP.OUTPUT.VARIANCE", 19 "PSWARP.OUTPUT.BKGMODEL", 20 "PSWARP.OUTPUT.SOURCES", 21 "PSPHOT.OUTPUT", 22 "PSPHOT.RESID", 23 "PSPHOT.BACKMDL", 24 "PSPHOT.BACKMDL.STDEV", 25 "PSPHOT.BACKGND", 26 "PSPHOT.BACKSUB", 27 "PSPHOT.PSF.SAVE", 28 "SOURCE.PLOT.MOMENTS", 29 "SOURCE.PLOT.PSFMODEL", 30 "SOURCE.PLOT.APRESID", 31 NULL 32 32 }; 33 33 … … 53 53 psError(psErrorCodeLast(), false, "Unable to read files."); 54 54 pmFPAfileFreeSetStrict(false); 55 psFree(view); 55 56 goto DONE; 56 57 } … … 63 64 psError(psErrorCodeLast(), false, "Unable to read files."); 64 65 pmFPAfileFreeSetStrict(false); 66 psFree(view); 65 67 goto DONE; 66 68 } … … 73 75 psError(psErrorCodeLast(), false, "Unable to read files."); 74 76 pmFPAfileFreeSetStrict(false); 77 psFree(view); 75 78 goto DONE; 76 79 } … … 79 82 psError(psErrorCodeLast(), false, "Unable to write files."); 80 83 pmFPAfileFreeSetStrict(false); 84 psFree(view); 81 85 goto DONE; 82 86 } … … 85 89 psError(psErrorCodeLast(), false, "Unable to write files."); 86 90 pmFPAfileFreeSetStrict(false); 91 psFree(view); 87 92 goto DONE; 88 93 } … … 116 121 psLibFinalize(); 117 122 123 psMemBlock **memblocks; 124 int Nleaks = psMemCheckLeaks (0, &memblocks, stderr, false); 125 fprintf (stderr, "Found %d leaks at %s\n", Nleaks, "ppImage"); 126 118 127 DONE: 119 128 exitValue = pswarpExitCode(exitValue); -
trunk/pswarp/src/pswarpDefineLayout.c
r35684 r41510 82 82 pswarpBounds *srcBounds = pswarpMakeBounds (input->fpa, frame); 83 83 pswarpBounds *tgtBounds = pswarpMakeBounds (skycell->fpa, frame); 84 85 psFree (frame); 84 86 85 87 // find the output (tgt) chips which overlap the input (src) chips -
trunk/pswarp/src/pswarpLoop.c
r41396 r41510 221 221 } 222 222 } 223 psFree (view); 223 224 return true; 224 225 } -
trunk/pswarp/src/pswarpLoopBackground.c
r40354 r41510 55 55 if (!status) { 56 56 psError(PSWARP_ERR_DATA, true, "number of inputs is not defined (programming error)"); 57 psFree (view); 57 58 return false; 58 59 } … … 90 91 pmFPAviewReset (view); 91 92 92 pmFPAview *view = pmFPAviewAlloc(0);93 if (!pmFPAfileIOChecks(config, view , PM_FPA_BEFORE)) {93 pmFPAview *viewT2 = pmFPAviewAlloc(0); 94 if (!pmFPAfileIOChecks(config, viewT2, PM_FPA_BEFORE)) { 94 95 psError(psErrorCodeLast(), false, "Unable to read files."); 96 psFree (viewT2); 95 97 goto FAIL; 96 98 } 97 99 98 100 pmChip *chip; 99 while ((chip = pmFPAviewNextChip (view , input->fpa, 1)) != NULL) {101 while ((chip = pmFPAviewNextChip (viewT2, input->fpa, 1)) != NULL) { 100 102 if (!chip->process || !chip->file_exists) { continue; } 101 if (!pmFPAfileIOChecks(config, view , PM_FPA_BEFORE)) {103 if (!pmFPAfileIOChecks(config, viewT2, PM_FPA_BEFORE)) { 102 104 psError(psErrorCodeLast(), false, "Unable to read files."); 105 psFree (viewT2); 103 106 goto FAIL; 104 107 } … … 107 110 double xBin = NAN; 108 111 double yBin = NAN; 109 pswarpGetInputScales (&xBin, &yBin, config, view , chip);112 pswarpGetInputScales (&xBin, &yBin, config, viewT2, chip); 110 113 double fluxRatio = xBin * yBin / (float) (xGrid * yGrid); 111 114 112 if (!pswarpModifyChipAstrom (config, view , chip, astrom, bilevelAstrometry, xBin, yBin)) {115 if (!pswarpModifyChipAstrom (config, viewT2, chip, astrom, bilevelAstrometry, xBin, yBin)) { 113 116 psError(psErrorCodeLast(), false, "failed to set BKGMODEL astrometry."); 117 psFree (viewT2); 114 118 goto FAIL; 115 119 } 116 120 117 121 pmCell *cell; 118 while ((cell = pmFPAviewNextCell (view , input->fpa, 1)) != NULL) {119 psTrace ("pswarp", 4, "ACell %d: %x %x %d\n", view ->cell, cell->file_exists, cell->process,psErrorCodeLast());122 while ((cell = pmFPAviewNextCell (viewT2, input->fpa, 1)) != NULL) { 123 psTrace ("pswarp", 4, "ACell %d: %x %x %d\n", viewT2->cell, cell->file_exists, cell->process,psErrorCodeLast()); 120 124 if (!cell->process || !cell->file_exists) { continue; } 121 if (!pmFPAfileIOChecks (config, view , PM_FPA_BEFORE)) {125 if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_BEFORE)) { 122 126 psError(psErrorCodeLast(), false, "Unable to read files."); 127 psFree (viewT2); 123 128 goto FAIL; 124 129 } … … 126 131 // process each of the readouts 127 132 pmReadout *readout; 128 while ((readout = pmFPAviewNextReadout(view , input->fpa, 1)) != NULL) {129 if (!pmFPAfileIOChecks(config, view , PM_FPA_BEFORE)) {133 while ((readout = pmFPAviewNextReadout(viewT2, input->fpa, 1)) != NULL) { 134 if (!pmFPAfileIOChecks(config, viewT2, PM_FPA_BEFORE)) { 130 135 psError(psErrorCodeLast(), false, "Unable to read files."); 136 psFree (viewT2); 131 137 goto FAIL; 132 138 } … … 136 142 137 143 if (astrom != input) { 138 pmReadout *astromRO = pmFPAviewThisReadout(view, astrom->fpa); // Readout for astrometry 139 if ((!refcat)&&(astromRO)) { 140 if ((astromRO->parent->parent->hdu->header)&&(output->fpa->analysis)) { 141 psMetadataItem *refItem = psMetadataLookup(astromRO->parent->parent->hdu->header, "PSREFCAT"); 142 if (refItem) { 143 refcat = psMetadataLookupStr(NULL, astromRO->parent->parent->hdu->header, "PSREFCAT"); 144 psMetadataAddStr(output->fpa->analysis, PS_LIST_TAIL, "REFERENCE_CATALOG", PS_META_REPLACE, 145 "Reference catalog used for calibration.", refcat); 146 } 144 pmReadout *astromRO = pmFPAviewThisReadout(viewT2, astrom->fpa); // Readout for astrometry 145 if ((!refcat)&&(astromRO)) { 146 if ((astromRO->parent->parent->hdu->header)&&(output->fpa->analysis)) { 147 psMetadataItem *refItem = psMetadataLookup(astromRO->parent->parent->hdu->header, "PSREFCAT"); 148 if (refItem) { 149 refcat = psMetadataLookupStr(NULL, astromRO->parent->parent->hdu->header, "PSREFCAT"); 150 psMetadataAddStr(output->fpa->analysis, PS_LIST_TAIL, "REFERENCE_CATALOG", PS_META_REPLACE, 151 "Reference catalog used for calibration.", refcat); 152 } 153 } 147 154 } 148 }149 155 } 150 156 … … 159 165 pswarpTransformToTarget (output->fpa, readout, config, true); 160 166 161 if (!pmFPAfileIOChecks (config, view , PM_FPA_AFTER)) { // Readout167 if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_AFTER)) { // Readout 162 168 psError(psErrorCodeLast(), false, "Unable to close files."); 169 psFree (viewT2); 163 170 goto FAIL; 164 171 } 165 172 } 166 173 167 if (!pmFPAfileIOChecks (config, view , PM_FPA_AFTER)) { // Cell174 if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_AFTER)) { // Cell 168 175 psError(psErrorCodeLast(), false, "Unable to close files."); 176 psFree (viewT2); 169 177 goto FAIL; 170 178 } 171 179 } 172 180 173 if (!pmFPAfileIOChecks (config, view , PM_FPA_AFTER)) { // Chip181 if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_AFTER)) { // Chip 174 182 psError(psErrorCodeLast(), false, "Unable to close files."); 183 psFree (viewT2); 175 184 goto FAIL; 176 185 } 177 186 } 178 187 179 if (!pmFPAfileIOChecks (config, view , PM_FPA_AFTER)) { // FPA188 if (!pmFPAfileIOChecks (config, viewT2, PM_FPA_AFTER)) { // FPA 180 189 psError(psErrorCodeLast(), false, "Unable to close files."); 190 psFree (viewT2); 181 191 goto FAIL; 182 192 } … … 184 194 if (!pswarpUpdateMetadata (output->fpa, skycell->fpa, input->fpa, astrom->fpa, config, false)) { 185 195 psError(psErrorCodeLast(), false, "problem generating statistics."); 196 psFree (viewT2); 186 197 goto FAIL; 187 198 } 199 psFree (viewT2); 188 200 } 189 201 -
trunk/pswarp/src/pswarpTransformReadout.c
r41382 r41510 118 118 psAssert (yGridMax < grid->nYpts, "yGridMax too big\n"); 119 119 120 //fprintf (stderr, "warp %d,%d - %d,%d\n", xGridMin, yGridMin, xGridMax, yGridMax);120 fprintf (stderr, "warp %d,%d - %d,%d\n", xGridMin, yGridMin, xGridMax, yGridMax); 121 121 122 122 // create jobs and supply them to the threads -
trunk/pswarp/src/pswarpUpdateMetadata.c
r40354 r41510 23 23 24 24 if ((output)&&(output->analysis)) { 25 psMetadataItem *refItem = psMetadataLookup(output->analysis, "REFERENCE_CATALOG");26 if (refItem) {27 refcat = psMetadataLookupStr (NULL, output->analysis, "REFERENCE_CATALOG");28 }25 psMetadataItem *refItem = psMetadataLookup(output->analysis, "REFERENCE_CATALOG"); 26 if (refItem) { 27 refcat = psMetadataLookupStr (NULL, output->analysis, "REFERENCE_CATALOG"); 28 } 29 29 } 30 30 pmChip *chip; … … 47 47 pmReadout *readout; 48 48 while ((readout = pmFPAviewNextReadout(view, output, 1)) != NULL) { 49 // skip empty output readouts49 // skip empty output readouts 50 50 if (!readout->data_exists) continue; 51 51 … … 57 57 psArray *covars = psListToArray(covariances); // Array of covariance matrices 58 58 if (covars->n) { 59 psKernel *covar = psImageCovarianceAverage(covars);60 psMetadataRemoveKey(readout->analysis, PSWARP_ANALYSIS_COVARIANCES);59 psKernel *covar = psImageCovarianceAverage(covars); 60 psMetadataRemoveKey(readout->analysis, PSWARP_ANALYSIS_COVARIANCES); 61 61 62 // Correct covariance matrix scale for the mean (square root of the) Jacobian63 double jacobian = psMetadataLookupF64(NULL, readout->analysis, PSWARP_ANALYSIS_JACOBIAN); // Jacobian64 int goodPixels = psMetadataLookupS32(NULL, readout->analysis, PSWARP_ANALYSIS_GOODPIX); // Good pixels65 jacobian /= goodPixels;66 readout->covariance = psImageCovarianceScale(covar, jacobian);67 psFree(covar);62 // Correct covariance matrix scale for the mean (square root of the) Jacobian 63 double jacobian = psMetadataLookupF64(NULL, readout->analysis, PSWARP_ANALYSIS_JACOBIAN); // Jacobian 64 int goodPixels = psMetadataLookupS32(NULL, readout->analysis, PSWARP_ANALYSIS_GOODPIX); // Good pixels 65 jacobian /= goodPixels; 66 readout->covariance = psImageCovarianceScale(covar, jacobian); 67 psFree(covar); 68 68 69 if (readout->variance) {70 psImageCovarianceTransfer(readout->variance, readout->covariance);71 }69 if (readout->variance) { 70 psImageCovarianceTransfer(readout->variance, readout->covariance); 71 } 72 72 73 psFree(covars);73 psFree(covars); 74 74 } 75 75 } … … 94 94 psArray *chipnames = psMetadataLookupPtr(&status, readout->analysis, PSWARP_ANALYSIS_CHIPNAMES); 95 95 for (int i = 0; chipnames && (i < chipnames->n); i++) { 96 psStringAppend (&keyword, "SRC_%04d", i);97 psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", chipnames->data[i]);98 psFree (keyword);96 psStringAppend (&keyword, "SRC_%04d", i); 97 psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", chipnames->data[i]); 98 psFree (keyword); 99 99 } 100 100 … … 102 102 psArray *chipRegions = psMetadataLookupPtr(&status, readout->analysis, PSWARP_ANALYSIS_CHIPREGIONS); 103 103 for (int i = 0; chipRegions && (i < chipRegions->n); i++) { 104 psStringAppend (&keyword, "SEC_%04d", i);105 psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", chipRegions->data[i]);106 psFree (keyword);104 psStringAppend (&keyword, "SEC_%04d", i); 105 psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", chipRegions->data[i]); 106 psFree (keyword); 107 107 } 108 108 … … 110 110 psArray *backmaps = psMetadataLookupPtr(&status, readout->analysis, PSWARP_ANALYSIS_BACKMAPS); // 111 111 for (int i = 0; backmaps && (i < backmaps->n); i++) { 112 psPlaneTransform *map = backmaps->data[i];113 psStringAppend (&keyword, "MPX_%04d", i);114 psStringAppend (&mapstring, "[%8.2f,%8.4f,%8.4f]", map->x->coeff[0][0], map->x->coeff[1][0], map->x->coeff[0][1]);115 psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, "warp to image map", mapstring);116 psFree (keyword);117 psFree (mapstring);118 psStringAppend (&keyword, "MPY_%04d", i);119 psStringAppend (&mapstring, "[%8.2f,%8.4f,%8.4f]", map->y->coeff[0][0], map->y->coeff[1][0], map->y->coeff[0][1]);120 psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, "warp to image map", mapstring);121 psFree (keyword);122 psFree (mapstring);112 psPlaneTransform *map = backmaps->data[i]; 113 psStringAppend (&keyword, "MPX_%04d", i); 114 psStringAppend (&mapstring, "[%8.2f,%8.4f,%8.4f]", map->x->coeff[0][0], map->x->coeff[1][0], map->x->coeff[0][1]); 115 psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, "warp to image map", mapstring); 116 psFree (keyword); 117 psFree (mapstring); 118 psStringAppend (&keyword, "MPY_%04d", i); 119 psStringAppend (&mapstring, "[%8.2f,%8.4f,%8.4f]", map->y->coeff[0][0], map->y->coeff[1][0], map->y->coeff[0][1]); 120 psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, "warp to image map", mapstring); 121 psFree (keyword); 122 psFree (mapstring); 123 123 } 124 124 } … … 164 164 if (!psMetadataCopy(output->concepts, input->concepts)) { 165 165 psError(psErrorCodeLast(), false, "Unable to copy FPA concepts from input to output."); 166 psFree(view); 166 167 return false; 167 168 } … … 174 175 175 176 if (refcat) { 176 if ((output)&&(output->hdu)&&(output->hdu->header)) {177 psMetadataAddStr(output->hdu->header, PS_LIST_TAIL, "PSREFCAT", PS_META_REPLACE,178 "Reference catalog used for calibration", refcat);179 }177 if ((output)&&(output->hdu)&&(output->hdu->header)) { 178 psMetadataAddStr(output->hdu->header, PS_LIST_TAIL, "PSREFCAT", PS_META_REPLACE, 179 "Reference catalog used for calibration", refcat); 180 } 180 181 } 181 182 … … 193 194 } 194 195 196 psFree(view); 195 197 return true; 196 198 }
Note:
See TracChangeset
for help on using the changeset viewer.
