Changeset 5789
- Timestamp:
- Dec 13, 2005, 6:30:21 PM (20 years ago)
- Location:
- trunk/archive/scripts/src/phase2
- Files:
-
- 3 edited
-
pmFPARead.c (modified) (6 diffs)
-
pmFPARead.h (modified) (1 diff)
-
pmFPAWrite.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/scripts/src/phase2/pmFPARead.c
r5786 r5789 219 219 220 220 // Translate a name from the configuration file, containing something like "%a_%d" to a real value 221 psString p_pmFPATranslateName( psString name, // The name to translate222 pmCell *cell // The cell for which to translate221 psString p_pmFPATranslateName(const psString name, // The name to translate 222 const pmCell *cell // The cell for which to translate 223 223 ) 224 224 { … … 338 338 } 339 339 340 // Get filename and extension out of "somefile.fits:ext" 341 psString p_pmFPATranslateFileExt(psString *extName, // Extension name, to be returned 342 const psString name, // The string to be translated and then parsed 343 const pmCell *cell // The cell 344 ) 345 { 346 psString filenameExt = p_pmFPATranslateName(name, cell); 347 const char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn 348 psString filename = NULL; // The filename 349 if (extName && *extName) { 350 psFree(*extName); 351 } 352 if (extName) { 353 *extName = NULL; 354 } 355 356 if (colon) { 357 filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon)); 358 if (strlen(colon) > 1) { 359 if (extName) { 360 *extName = psStringCopy(colon + 1); 361 } 362 } 363 } else { 364 filename = psMemIncrRefCounter(filenameExt); 365 } 366 367 return filename; 368 } 369 340 370 // Read a mask into the FPA 341 371 bool pmFPAReadMask(pmFPA *fpa, // FPA to read into … … 386 416 if (strcasecmp(sourceType, "FILE") == 0) { 387 417 // Source is a file (with optional extension, e.g., "myMaskFile.fits:thisExt" 388 psString filenameExt = p_pmFPATranslateName(name, cell); 389 char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn 390 psString filename = NULL; // The filename 391 psString extname = NULL;// The extenstion name 392 if (colon) { 393 filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon)); 394 if (strlen(colon) > 1) { 395 extname = psStringCopy(colon + 1); 396 } 397 } else { 398 filename = psMemIncrRefCounter(filenameExt); 399 } 418 psString extname = NULL; // Extension name 419 psString filename = p_pmFPATranslateFileExt(&extname, name, cell); // The filename 400 420 401 421 psFree(maskSource); … … 410 430 psFree(filename); 411 431 psFree(extname); 412 psFree(filenameExt);413 432 } else if (strncasecmp(sourceType, "EXT", 3) == 0) { 414 433 // Source is an extension in the original file … … 536 555 if (strcasecmp(sourceType, "FILE") == 0) { 537 556 // Source is a file (with optional extension, e.g., "myWeightFile.fits:thisExt" 538 psString filenameExt = p_pmFPATranslateName(name, cell); 539 char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn 540 psString filename = NULL; // The filename 541 psString extname = NULL;// The extenstion name 542 if (colon) { 543 filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon)); 544 if (strlen(colon) > 1) { 545 extname = psStringCopy(colon + 1); 546 } 547 } else { 548 filename = psMemIncrRefCounter(filenameExt); 549 } 557 psString extname = NULL; // Extension name 558 psString filename = p_pmFPATranslateFileExt(&extname, name, cell); // The filename 550 559 551 560 psFree(weightSource); … … 560 569 psFree(filename); 561 570 psFree(extname); 562 psFree(filenameExt);563 571 } else if (strncasecmp(sourceType, "EXT", 3) == 0) { 564 572 // Source is an extension in the original file -
trunk/archive/scripts/src/phase2/pmFPARead.h
r5583 r5789 4 4 #include "pmFPA.h" 5 5 6 bool pmFPARead(pmFPA *fpa, // FPA to read into7 psFits *fits,// FITS file from which to read8 psMetadata *phu,// Primary header9 psDB *db// Database handle, for concept ingest6 bool pmFPARead(pmFPA *fpa, // FPA to read into 7 psFits *fits, // FITS file from which to read 8 psMetadata *phu, // Primary header 9 psDB *db // Database handle, for concept ingest 10 10 ); 11 11 12 psString p_pmFPATranslateName( psString name, // The name to translate13 pmCell *cell // The cell for which to translate12 psString p_pmFPATranslateName(const psString name, // The name to translate 13 const pmCell *cell // The cell for which to translate 14 14 ); 15 15 16 bool pmFPAReadMask(pmFPA *fpa, // FPA to read into 17 psFits *source // Source FITS file (for the original data) 16 psString p_pmFPATranslateFileExt(psString *extName, // Extension name, to be returned 17 const psString filenameExt, // The string to parse into filename and ext 18 const pmCell *cell // The cell 18 19 ); 19 20 20 bool pmFPAReadWeight(pmFPA *fpa, // FPA to read into 21 psFits *source // Source FITS file (for the original data) 21 bool pmFPAReadMask(pmFPA *fpa, // FPA to read into 22 psFits *source // Source FITS file (for the original data) 23 ); 24 25 bool pmFPAReadWeight(pmFPA *fpa, // FPA to read into 26 psFits *source // Source FITS file (for the original data) 22 27 ); 23 28 -
trunk/archive/scripts/src/phase2/pmFPAWrite.c
r5786 r5789 124 124 if (strcasecmp(sourceType, "FILE") == 0) { 125 125 // Source is a file (with optional extension, e.g., "myMaskFile.fits:thisExt" 126 psString filenameExt = p_pmFPATranslateName(name, cell); 127 char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn 128 psString filename = NULL; // The filename 129 psString extname = NULL;// The extenstion name 130 if (colon) { 131 filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon)); 132 if (strlen(colon) > 1) { 133 extname = psStringCopy(colon + 1); 134 } 135 } else { 136 filename = psMemIncrRefCounter(filenameExt); 137 } 138 126 psString extname = NULL; // Extension name 127 psString filename = p_pmFPATranslateFileExt(&extname, name, cell); // The filename 139 128 psFree(maskDest); 140 129 maskDest = psFitsOpen(filename, "rw"); … … 144 133 psFree(filename); 145 134 psFree(extname); 146 psFree(filenameExt);147 135 } else if (strncasecmp(sourceType, "EXT", 3) == 0) { 148 136 // Source is an extension in the original file … … 227 215 if (strcasecmp(sourceType, "FILE") == 0) { 228 216 // Source is a file (with optional extension, e.g., "myWeightFile.fits:thisExt" 229 psString filenameExt = p_pmFPATranslateName(name, cell); 230 char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn 231 psString filename = NULL; // The filename 232 psString extname = NULL;// The extenstion name 233 if (colon) { 234 filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon)); 235 if (strlen(colon) > 1) { 236 extname = psStringCopy(colon + 1); 237 } 238 } else { 239 filename = psMemIncrRefCounter(filenameExt); 240 } 217 psString extname = NULL; // Extension name 218 psString filename = p_pmFPATranslateFileExt(&extname, name, cell); // The filename 241 219 242 220 psFree(weightDest); … … 247 225 psFree(filename); 248 226 psFree(extname); 249 psFree(filenameExt);250 227 } else if (strncasecmp(sourceType, "EXT", 3) == 0) { 251 228 // Source is an extension in the original file
Note:
See TracChangeset
for help on using the changeset viewer.
