Changeset 23592
- Timestamp:
- Mar 29, 2009, 4:04:51 PM (17 years ago)
- Location:
- trunk/psastro/src
- Files:
-
- 3 edited
-
psastroExtractAnalysis.c (modified) (1 diff)
-
psastroExtractGhosts.c (modified) (5 diffs)
-
psastroExtractStars.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroExtractAnalysis.c
r23591 r23592 51 51 psFree(refs); 52 52 53 // convert star positions to ghost positions and add to the readout->analysis data 54 psastroExtractGhosts (config); 55 53 56 psastroExtractStars (config); 54 psastroExtractGhosts (config);55 57 return true; 56 58 } -
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; -
trunk/psastro/src/psastroExtractStars.c
r23591 r23592 83 83 return false; 84 84 } 85 85 86 char *filename = NULL; 86 87 psStringAppend (&filename, "%s.st.fits", fileroot); 87 88 88 psFits *outStars = psFitsOpen (filename, "w"); 89 89 if (!outStars) { … … 91 91 return false; 92 92 } 93 psFree (filename); 94 95 filename = NULL; 96 psStringAppend (&filename, "%s.gh.fits", fileroot); 97 psFits *outGhosts = psFitsOpen (filename, "w"); 98 if (!outGhosts) { 99 psError(PS_ERR_IO, false, "error opening file %s\n", filename); 100 return false; 101 } 102 psFree (filename); 93 103 94 104 pmFPAview *view = pmFPAviewAlloc (0); … … 103 113 psMetadataAddF32 (phu, PS_LIST_TAIL, "EXPTIME", 0, "exptime", exptime); 104 114 psMetadataAddF32 (phu, PS_LIST_TAIL, "ZEROPT", 0, "zeropt", zeropt); 115 105 116 psFitsWriteBlank (outStars, phu, NULL); 117 psFitsWriteBlank (outGhosts, phu, NULL); 106 118 psFree (phu); 107 119 … … 145 157 psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y", 0, "focal-plane coordinate", ref->FP->y); 146 158 psMetadataAddF32 (header, PS_LIST_TAIL, "MAG", 0, "magnitude", ref->Mag); 159 160 snprintf (extname, 80, "extname.%05d", nExt); 161 psFitsWriteImage (outStars, header, subraster, 0, extname); 162 nExt ++; 163 164 psFree (header); 165 psFree (subraster); 166 } 167 168 // select the raw objects for this readout (loaded in psastroExtract.c) 169 psArray *ghosts = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.GHOSTS"); 170 if (ghosts == NULL) { continue; } 171 172 // identify the bright stars of interest 173 for (int i = 0; i < ghosts->n; i++) { 174 pmAstromObj *ghost = ghosts->data[i]; 175 176 pmReadout *inReadout = pmFPAviewThisReadout (view, input->fpa); 177 psImage *subraster = psastroExtractStar (inReadout->image, ghost->chip->x, ghost->chip->y, 200.0, 200.0); 178 if (!subraster) continue; 179 180 // generate a (very) basic header: 181 psMetadata *header = psMetadataAlloc (); 182 psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_X", 0, "chip coordinate", ghost->chip->x); 183 psMetadataAddF32 (header, PS_LIST_TAIL, "CHIP_Y", 0, "chip coordinate", ghost->chip->y); 184 psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_X", 0, "focal-plane coordinate", ghost->FP->x); 185 psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y", 0, "focal-plane coordinate", ghost->FP->y); 186 psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_X0", 0, "star focal-plane coordinate", ghost->TP->x); // note : over-loaded value 187 psMetadataAddF32 (header, PS_LIST_TAIL, "FPA_Y0", 0, "star focal-plane coordinate", ghost->TP->y); // note : over-loaded value 188 psMetadataAddF32 (header, PS_LIST_TAIL, "MAG", 0, "magnitude", ghost->Mag); 147 189 148 190 snprintf (extname, 80, "extname.%05d", nExt);
Note:
See TracChangeset
for help on using the changeset viewer.
