- Timestamp:
- Jan 13, 2024, 8:15:12 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20230313/psphot/src/psphotDefineFiles.c
r36375 r42582 1 1 # include "psphotInternal.h" 2 pmConfig *pmConfigMakeTemp (pmConfig *config); 2 3 3 4 bool psphotINpsphotStack = false; … … 143 144 } 144 145 146 // Use a temporary config for the source files, keeping the main user, site, 147 // system, files, arguments entries. This allows the sources to be from a 148 // different camera than the input image. NOTE: there is no check that these two 149 // images match in terms of size, pixel scale, etc. That is up to the user. 150 // The temporary config structure has PSCAMERA entries removed from the SKYCELL rules 151 // to allow forced photometry between cameras. 152 153 pmConfig *srcconfig = pmConfigMakeTemp(config); 154 145 155 if (psMetadataLookupPtr(NULL, config->arguments, "SRC")) { 146 if (!pmFPAfileDefineFromArgs (&status, config, "PSPHOT.INPUT.CMF", "SRC")) {156 if (!pmFPAfileDefineFromArgs (&status, srcconfig, "PSPHOT.INPUT.CMF", "SRC")) { 147 157 psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.INPUT.CMF"); 148 158 return status; … … 151 161 152 162 if (psMetadataLookupPtr(NULL, config->arguments, "FORCE")) { 153 if (!pmFPAfileDefineFromArgs (&status, config, "PSPHOT.INPUT.CFF", "FORCE")) {163 if (!pmFPAfileDefineFromArgs (&status, srcconfig, "PSPHOT.INPUT.CFF", "FORCE")) { 154 164 psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.INPUT.CFF"); 155 165 return status; … … 160 170 // XXX cannot use pmFPAfileDefineFromArgs: this is explicitly a FITS-based I/O function 161 171 // supply the attach the 162 if (!psphotLoadSRCTEXT(input->fpa, config)) {172 if (!psphotLoadSRCTEXT(input->fpa, srcconfig)) { 163 173 psError(PSPHOT_ERR_CONFIG, false, "Failed to load PSPHOT.INPUT.TEXT"); 164 174 return status; … … 167 177 168 178 if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) { 169 pmFPAfileBindFromArgs(&status, input, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");179 pmFPAfileBindFromArgs(&status, input, srcconfig, "PSPHOT.PSF.LOAD", "PSPHOT.PSF"); 170 180 if (!status) { 171 181 psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.PSF.LOAD"); … … 173 183 } 174 184 } 185 186 psFree (srcconfig); 175 187 176 188 // XXX add in example PSF image thumbnails … … 214 226 return rule; 215 227 } 228 229 pmConfig *pmConfigMakeTemp (pmConfig *config) { 230 pmConfig *altconfig = pmConfigAlloc(); 231 232 // these are NULL on pmConfigAlloc 233 altconfig->user = psMemIncrRefCounter(config->user); // inherit from primary camera 234 altconfig->site = psMemIncrRefCounter(config->site); // inherit from primary camera 235 236 psFree (altconfig->system); 237 altconfig->system = psMetadataCopy(NULL, config->system); // container for camera-specific recipe values (to be dropped) 238 239 psFree (altconfig->files); 240 altconfig->files = psMemIncrRefCounter(config->files); // inherit from primary camera 241 242 psFree (altconfig->arguments); 243 altconfig->arguments = psMemIncrRefCounter(config->arguments); // inherit from primary camera 244 245 psFree (altconfig->recipes); 246 altconfig->recipes = psMetadataCopy(NULL, config->recipes); // container for camera-specific recipe values (to be dropped) 247 248 // remove PSCAMERA entries from *-SKYCELL cameras. This allows skycell images from 249 // one camera to match those of another camera. XXX Make this optional to force 250 // matching cameras if desired? 251 bool mdok = false; 252 psMetadata *cameras = psMetadataLookupMetadata(&mdok, altconfig->system, "CAMERAS"); 253 psAssert(cameras, "missing cameras in system config info"); 254 255 // iterate over the cameras and find ones with names like _*-SKYCELLS 256 // psMetadataIterator *camerasIter = psMetadataIteratorAlloc(cameras, PS_LIST_HEAD, "^_.+-SKYCELL$"); 257 psMetadataIterator *camerasIter = psMetadataIteratorAlloc(cameras, PS_LIST_HEAD, NULL); 258 psAssert(camerasIter, "unable to generate iterator?"); 259 260 psMetadataItem *camerasItem = NULL; // Item from the metadata 261 while ((camerasItem = psMetadataGetAndIncrement(camerasIter))) { 262 psAssert(camerasItem->type == PS_DATA_METADATA, "camerasItem has invalid type"); 263 264 char *name = camerasItem->name; 265 psAssert (name, "NULL name for item"); 266 267 int nameLen = strlen(name); 268 if (name[0] != '_') continue; 269 if (nameLen <= 9) continue; 270 char *p = &name[nameLen - 8]; 271 if (strcmp(p, "-SKYCELL")) continue; 272 273 // remove PSCAMERA entries from *-SKYCELL cameras 274 psMetadata *formats = psMetadataLookupMetadata(&mdok, camerasItem->data.md, "FORMATS"); // List of formats 275 psAssert (formats, "missing FORMATS in camera.config "); 276 277 psMetadata *format = psMetadataLookupMetadata(&mdok, formats, "SKYCELL"); // one true format for skycells 278 psAssert (format, "missing SKYCELL metaformat for -SKYCELL entry "); 279 280 psMetadata *rule = psMetadataLookupMetadata(&mdok, format, "RULE"); // one true format for skycells 281 psAssert (rule, "missing RULE in SKYCELL metaformat for -SKYCELL entry "); 282 283 psString pscamera = psMetadataLookupStr(&mdok, rule, "PSCAMERA"); // one true format for skycells 284 if (!pscamera) continue; // already removed, or never supplied 285 286 psMetadataRemoveKey (rule, "PSCAMERA"); // allow any camera skycell to match 287 } 288 psFree (camerasIter); 289 290 return (altconfig); 291 } 292
Note:
See TracChangeset
for help on using the changeset viewer.
