Changeset 28243 for trunk/ppTranslate/src/ppMopsRead.c
- Timestamp:
- Jun 7, 2010, 9:45:30 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/ppTranslate/src/ppMopsRead.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppTranslate/src/ppMopsRead.c
r28218 r28243 4 4 5 5 #include <stdio.h> 6 #include <string.h> 6 7 #include <pslib.h> 7 8 … … 16 17 psArray *detections = psArrayAlloc(num); // Array of detections, to return 17 18 for (int i = 0; i < num; i++) { 18 psFits *fits = psFitsOpen(inNames->data[i], "r"); // FITS file 19 const char *name = inNames->data[i]; // File name 20 psFits *fits = psFitsOpen(name, "r"); // FITS file 19 21 if (!fits) { 20 22 psError(PS_ERR_IO, false, "Unable to open input %d", i); … … 41 43 continue; 42 44 } 43 ppMopsDetections *det = ppMopsDetectionsAlloc(); 45 ppMopsDetections *det = detections->data[i] = ppMopsDetectionsAlloc(); 46 det->component = psStringNCopy(name, strrchr(name, '.') - name); // Strip off extension 44 47 det->header = header; 45 48 det->num = size; … … 61 64 det->naxis2 = psMetadataLookupS32(NULL, header, "IMNAXIS2"); 62 65 66 det->psfHeader = psFitsReadHeader(NULL, fits); 67 if (!det->psfHeader) { 68 psError(psErrorCodeLast(), false, "Unable to read header %d", i); 69 return false; 70 } 63 71 psMetadata *table = det->table = psFitsReadTableAllColumns(fits); // Table of interest 64 72 if (!table) { … … 66 74 return false; 67 75 } 68 psFitsClose(fits);69 76 70 77 psVector *ra = psMetadataLookupVector(NULL, table, "RA_PSF"); … … 80 87 } 81 88 82 psTrace("ppMops.read", 2, "Read %ld rows from %s\n", det->num, (const char*)inNames->data[i]);89 psTrace("ppMops.read", 2, "Read %ld rows from %s\n", det->num, det->component); 83 90 84 detections->data[i] = det; 91 if (!psFitsMoveExtName(fits, "SkyChip.deteff")) { 92 psWarning("No detection efficiencies included in %s", det->component); 93 psErrorStackPrint(stderr, "No detection efficiencies included in %s", det->component); 94 psErrorClear(); 95 continue; 96 } 97 98 det->deteffHeader = psFitsReadHeader(NULL, fits); 99 if (!det->deteffHeader) { 100 psWarning("Unable to read detection efficiency header in %s", det->component); 101 psErrorClear(); 102 continue; 103 } 104 det->deteffTable = psFitsReadTableAllColumns(fits); 105 if (!det->deteffTable) { 106 psFree(det->deteffHeader); 107 det->deteffHeader = NULL; 108 psWarning("Unable to read detection efficiency table in %s", det->component); 109 psErrorClear(); 110 continue; 111 } 112 psTrace("ppMops.read", 2, "Read detection efficiency from %s\n", det->component); 113 psFitsClose(fits); 85 114 } 86 115
Note:
See TracChangeset
for help on using the changeset viewer.
