Changeset 23592 for trunk/psastro/src/psastroExtractGhosts.c
- Timestamp:
- Mar 29, 2009, 4:04:51 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroExtractGhosts.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroExtractGhosts.c
r23591 r23592 29 29 pmReadout *readout = NULL; 30 30 float zeropt, exptime; 31 char extname[81];32 31 33 psLogMsg ("psastro", PS_LOG_INFO, " extracting bright-star subrasters");32 psLogMsg ("psastro", PS_LOG_INFO, "determine ghost positions"); 34 33 35 34 // select the current recipe … … 53 52 pmFPA *fpa = astrom->fpa; 54 53 55 // select the input data sources56 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.EXTRACT.INPUT");57 if (!input) {58 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data");59 return false;60 }61 62 // only load data from INPUT63 pmFPAfileActivate(config->files, false, NULL);64 pmFPAfileActivate(config->files, true, "PSASTRO.EXTRACT.INPUT");65 66 54 // really error-out here? or just skip? 67 55 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, fpa, recipe)) { … … 75 63 EXTRACT_MAX_MAG += MagOffset; 76 64 77 int nExt = 0;78 79 // open the output file handle: we are just saving a series of extensions to this file80 char *fileroot = psMetadataLookupStr (&status, config->arguments, "OUTPUT");81 if (!fileroot) {82 psLogMsg ("psastro", PS_LOG_INFO, "output filename not supplied");83 return false;84 }85 char *filename = NULL;86 psStringAppend (&filename, "%s.gh.fits", fileroot);87 88 psFits *outStars = psFitsOpen (filename, "w");89 if (!outStars) {90 psError(PS_ERR_IO, false, "error opening file %s\n", filename);91 return false;92 }93 94 65 pmFPAview *view = pmFPAviewAlloc (0); 95 96 // generate a (very) basic header:97 psMetadata *phu = psMetadataAlloc ();98 // select the filter; default to fixed photcode and mag limit otherwise99 char *filter = psMetadataLookupStr (&status, fpa->concepts, "FPA.FILTERID");100 if (!status) ESCAPE("missing FPA.FILTER in concepts");101 102 psMetadataAddStr (phu, PS_LIST_TAIL, "FILTER", 0, "filter", filter);103 psMetadataAddF32 (phu, PS_LIST_TAIL, "EXPTIME", 0, "exptime", exptime);104 psMetadataAddF32 (phu, PS_LIST_TAIL, "ZEROPT", 0, "zeropt", zeropt);105 psFitsWriteBlank (outStars, phu, NULL);106 psFree (phu);107 108 // open/load files as needed109 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE("failed on FPA BEFORE");110 66 111 67 // this loop selects the matched stars for all chips … … 114 70 if (!chip->process || !chip->file_exists) { continue; } 115 71 if (!chip->fromFPA) { continue; } 116 117 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE("failed on Chip BEFORE");118 72 119 73 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { … … 150 104 if (!ghostReadout) continue; 151 105 152 // XXX box size needs to be larger... 153 psImage *subraster = psastroExtractStar (ghostReadout->image, xChip, yChip, 200.0, 200.0); 154 if (!subraster) continue; 106 psArray *ghosts = psMetadataLookupPtr (&status, ghostReadout->analysis, "PSASTRO.GHOSTS"); 107 if (ghosts == NULL) { 108 ghosts = psArrayAllocEmpty (100); 109 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.GHOSTS", PS_DATA_ARRAY, "astrometry matches", ghosts); 110 psFree (ghosts); 111 } 112 113 pmAstromObj *ghost = pmAstromObjAlloc (); 114 ghost->FP->x = xFPA; 115 ghost->FP->y = yFPA; 116 ghost->chip->x = xChip; 117 ghost->chip->y = yChip; 118 ghost->TP->x = ref->FP->x; // XXX this is a bit of sleazy over-loading 119 ghost->TP->y = ref->FP->y; 120 ghost->Mag = ref->Mag; 155 121 156 // generate a (very) basic header: 157 psMetadata *header = psMetadataAlloc (); 158 psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_X", 0, "chip coordinate", ref->chip->x); 159 psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_Y", 0, "chip coordinate", ref->chip->y); 160 psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_X", 0, "focal-plane coordinate", ref->FP->x); 161 psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y", 0, "focal-plane coordinate", ref->FP->y); 162 psMetadataAddF32 (header, PS_LIST_TAIL, "MAG", 0, "magnitude", ref->Mag); 122 psArrayAdd (ghosts, 100, ghost); 123 psFree (ghost); 124 } 125 } 126 } 127 } 163 128 164 snprintf (extname, 80, "extname.%05d", nExt);165 psFitsWriteImage (outStars, header, subraster, 0, extname);166 nExt ++;167 168 psFree (header);169 psFree (subraster);170 }171 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on Readout AFTER");;172 }173 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on Cell AFTER");;174 }175 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on Chip AFTER");;176 }177 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE("failed on FPA AFTER");;178 179 psFitsClose (outStars);180 psFree (filename);181 129 psFree (view); 182 130 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
