Changeset 20270
- Timestamp:
- Oct 19, 2008, 1:53:56 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroLoadRefstars.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroLoadRefstars.c
r19289 r20270 2 2 # define ELIXIR_MODE 1 3 3 4 // XXX other comment 4 char *psastroSetMagLimit (float *minMag, float *maxRho, pmConfig *config); 5 5 6 6 psArray *psastroLoadRefstars (pmConfig *config) { … … 53 53 PS_ASSERT (outformat, NULL); 54 54 55 char *photcode = psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR.PHOTCODE"); 55 // we have an exposure with a certain filter and exposure time: choose the maximum 56 // reference star density for stars fainter than an equivalent instrumental mag limit 57 float minMag; 58 float maxRho; 59 char *photcode = psastroSetMagLimit (&minMag, &maxRho, config); 56 60 PS_ASSERT (photcode, NULL); 57 58 float MAGmax = psMetadataLookupF32(NULL, recipe, "DVO.GETSTAR.MAG.MAX");59 61 60 62 // issue the following command: … … 86 88 // supply the max magnitude, the output format, and the photcode 87 89 if (strcasecmp (photcode, "NONE")) { 88 psStringAppend (&getstarCommand, " -maglim %f", MAGmax); 89 } 90 if (strcasecmp (photcode, "NONE")) { 91 psStringAppend (&getstarCommand, " -photcode %s", photcode); 90 91 psStringAppend (&getstarCommand, " -photcode %s -minmag %f -max-density %f", photcode, minMag, maxRho); 92 92 } 93 93 psStringAppend (&getstarCommand, " -format %s", outformat); … … 222 222 return refstars; 223 223 } 224 225 # define ESCAPE(MSG) { \ 226 psLogMsg ("psastro", PS_LOG_INFO, MSG); \ 227 goto escape; } 228 229 char *psastroSetMagLimit (float *minMag, float *maxRho, pmConfig *config) { 230 231 bool status; 232 char *photcode; 233 234 // select the current recipe 235 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE); 236 237 // select the input data sources 238 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); 239 if (!input) { 240 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data"); 241 return NULL; 242 } 243 assert (input->fpa); 244 245 *maxRho = psMetadataLookupF32(&status, recipe, "DVO.GETSTAR.MAX.RHO"); 246 if (!status) { 247 psError(PSASTRO_ERR_CONFIG, false, "DVO.GETSTAR.MAX.RHO missing from recipe"); 248 return NULL; 249 } 250 251 // select the filter; default to fixed photcode and mag limit otherwise 252 char *filter = psMetadataLookupStr (&status, input->fpa->concepts, "FPA.FILTERID"); 253 if (!status) ESCAPE ("missing FPA.FILTER in concepts"); 254 255 float exptime = psMetadataLookupF32 (&status, input->fpa->concepts, "FPA.EXPOSURE"); 256 if (!status) ESCAPE ("missing FPA.EXPOSURE in concepts"); 257 258 // we need to select the PHOTCODE.DATA folder that matches our filter 259 psMetadataItem *item = psMetadataLookup (recipe, "PHOTCODE.DATA"); 260 if (!item) ESCAPE ("PHOTCODE.DATA folders missing"); 261 if (item->type != PS_DATA_METADATA_MULTI) ESCAPE ("PHOTCODE.DATA not a multi"); 262 263 float minInst = psMetadataLookupF32(&status, recipe, "DVO.GETSTAR.MIN.MAG.INST"); 264 if (!status) ESCAPE ("missing DVO.GETSTAR.MIN.MAG.INST"); 265 266 // PHOTCODE.DATA is a multi of metadata items 267 psListIterator *iter = psListIteratorAlloc(item->data.list, PS_LIST_HEAD, false); 268 269 psMetadataItem *refItem = NULL; 270 while ((refItem = psListGetAndIncrement (iter))) { 271 if (refItem->type != PS_DATA_METADATA) ESCAPE ("PHOTCODE.DATA entry is not a metadata folder"); 272 273 char *refFilter = psMetadataLookupStr (&status, refItem->data.md, "FILTER"); 274 if (!status) { 275 psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER"); 276 continue; 277 } 278 279 // does this entry match the current filter? 280 if (strcmp (refFilter, filter)) continue; 281 282 psLogMsg ("psastro", PS_LOG_DETAIL, "PHOTCODE.DATA found for filter %s", filter); 283 284 float zeropt = psMetadataLookupF32 (&status, refItem->data.md, "ZEROPT"); 285 if (!status) { 286 psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER"); 287 continue; 288 } 289 photcode = psMetadataLookupStr (&status, refItem->data.md, "PHOTCODE"); 290 if (!status) { 291 psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER"); 292 continue; 293 } 294 295 // convert the minInst to a calibrated minimum magnitude 296 *minMag = minInst + 2.5*log10(exptime) + zeropt; 297 298 psFree (iter); 299 return photcode; 300 } 301 psFree (iter); 302 303 escape: 304 photcode = psMetadataLookupStr(NULL, recipe, "DVO.GETSTAR.PHOTCODE"); 305 PS_ASSERT (photcode, NULL); 306 307 // give up and use fixed value 308 *minMag = psMetadataLookupF32(NULL, recipe, "DVO.GETSTAR.MIN.MAG"); 309 return photcode; 310 }
Note:
See TracChangeset
for help on using the changeset viewer.
