Changeset 17987
- Timestamp:
- Jun 8, 2008, 2:33:32 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAfile.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfile.c
r17911 r17987 21 21 static void pmFPAfileFree(pmFPAfile *file) 22 22 { 23 if (!file) { 23 if (!file) { 24 return; 25 } 26 27 psTrace ("pmFPAfileFree", 5, "freeing %s\n", file->name); 28 psFree (file->fpa); 29 psFree (file->src); 30 psFree (file->readout); 31 psFree (file->names); 32 33 psFree (file->camera); 34 psFree (file->cameraName); 35 psFree (file->format); 36 psFree (file->formatName); 37 psFree (file->name); 38 39 if (file->fits != NULL) { 40 psFitsClose (file->fits); 41 } 42 psFree(file->compression); 43 psFree(file->options); 44 45 psFree (file->filerule); 46 47 psFree (file->filesrc); 48 psFree (file->detrend); 49 50 psFree (file->filename); 51 psFree (file->extname); 52 24 53 return; 25 }26 27 psTrace ("pmFPAfileFree", 5, "freeing %s\n", file->name);28 psFree (file->fpa);29 psFree (file->src);30 psFree (file->readout);31 psFree (file->names);32 33 psFree (file->camera);34 psFree (file->cameraName);35 psFree (file->format);36 psFree (file->formatName);37 psFree (file->name);38 39 if (file->fits != NULL) {40 psFitsClose (file->fits);41 }42 psFree(file->compression);43 psFree(file->options);44 45 psFree (file->filerule);46 47 psFree (file->filesrc);48 psFree (file->detrend);49 50 psFree (file->filename);51 psFree (file->extname);52 53 return;54 54 } 55 55 56 56 pmFPAfile *pmFPAfileAlloc() 57 57 { 58 pmFPAfile *file = psAlloc(sizeof(pmFPAfile));59 psMemSetDeallocator(file, (psFreeFunc) pmFPAfileFree);60 61 file->wrote_phu = false;62 file->readout = NULL;63 file->header = NULL;64 65 file->fileLevel = PM_FPA_LEVEL_NONE;66 file->dataLevel = PM_FPA_LEVEL_NONE;67 file->freeLevel = PM_FPA_LEVEL_NONE;68 file->mosaicLevel = PM_FPA_LEVEL_NONE;69 70 file->type = PM_FPA_FILE_NONE;71 file->mode = PM_FPA_MODE_NONE;72 file->state = PM_FPA_STATE_CLOSED;73 74 file->fpa = NULL;75 file->fits = NULL;76 file->compression = NULL;77 file->options = NULL;78 file->names = psMetadataAlloc();79 80 file->camera = NULL;81 file->cameraName = NULL;82 file->format = NULL;83 file->formatName = NULL;84 file->name = NULL;85 86 file->filerule = NULL;87 88 file->filename = NULL;89 file->extname = NULL;90 91 file->filesrc = NULL;92 file->detrend = NULL;93 94 file->xBin = 1;95 file->yBin = 1;96 file->src = NULL;97 98 file->save = false;99 100 return file;58 pmFPAfile *file = psAlloc(sizeof(pmFPAfile)); 59 psMemSetDeallocator(file, (psFreeFunc) pmFPAfileFree); 60 61 file->wrote_phu = false; 62 file->readout = NULL; 63 file->header = NULL; 64 65 file->fileLevel = PM_FPA_LEVEL_NONE; 66 file->dataLevel = PM_FPA_LEVEL_NONE; 67 file->freeLevel = PM_FPA_LEVEL_NONE; 68 file->mosaicLevel = PM_FPA_LEVEL_NONE; 69 70 file->type = PM_FPA_FILE_NONE; 71 file->mode = PM_FPA_MODE_NONE; 72 file->state = PM_FPA_STATE_CLOSED; 73 74 file->fpa = NULL; 75 file->fits = NULL; 76 file->compression = NULL; 77 file->options = NULL; 78 file->names = psMetadataAlloc(); 79 80 file->camera = NULL; 81 file->cameraName = NULL; 82 file->format = NULL; 83 file->formatName = NULL; 84 file->name = NULL; 85 86 file->filerule = NULL; 87 88 file->filename = NULL; 89 file->extname = NULL; 90 91 file->filesrc = NULL; 92 file->detrend = NULL; 93 94 file->xBin = 1; 95 file->yBin = 1; 96 file->src = NULL; 97 98 file->save = false; 99 100 return file; 101 101 } 102 102 … … 104 104 pmReadout *pmFPAfileThisReadout (psMetadata *files, const pmFPAview *view, const char *name) 105 105 { 106 PS_ASSERT_PTR_NON_NULL(files, false);107 PS_ASSERT_PTR_NON_NULL(view, false);108 PS_ASSERT_PTR_NON_NULL(name, false);109 PS_ASSERT_INT_POSITIVE(strlen(name), false);110 111 bool status;112 113 pmFPAfile *file = psMetadataLookupPtr (&status, files, name);114 if (file == NULL) {115 return NULL;116 }117 118 // internal files have the readout as a separate element:119 if (file->mode == PM_FPA_MODE_INTERNAL) {120 return file->readout;121 }122 123 pmReadout *readout = pmFPAviewThisReadout (view, file->fpa);124 return readout;106 PS_ASSERT_PTR_NON_NULL(files, false); 107 PS_ASSERT_PTR_NON_NULL(view, false); 108 PS_ASSERT_PTR_NON_NULL(name, false); 109 PS_ASSERT_INT_POSITIVE(strlen(name), false); 110 111 bool status; 112 113 pmFPAfile *file = psMetadataLookupPtr (&status, files, name); 114 if (file == NULL) { 115 return NULL; 116 } 117 118 // internal files have the readout as a separate element: 119 if (file->mode == PM_FPA_MODE_INTERNAL) { 120 return file->readout; 121 } 122 123 pmReadout *readout = pmFPAviewThisReadout (view, file->fpa); 124 return readout; 125 125 } 126 126 … … 128 128 pmCell *pmFPAfileThisCell (psMetadata *files, const pmFPAview *view, const char *name) 129 129 { 130 PS_ASSERT_PTR_NON_NULL(files, false);131 PS_ASSERT_PTR_NON_NULL(view, false);132 PS_ASSERT_PTR_NON_NULL(name, false);133 PS_ASSERT_INT_POSITIVE(strlen(name), false);134 135 bool status;136 137 pmFPAfile *file = psMetadataLookupPtr (&status, files, name);138 if (file == NULL) {139 return NULL;140 }141 142 // internal files have the readout as a separate element:143 if (file->mode == PM_FPA_MODE_INTERNAL) {144 return NULL;145 }146 147 pmCell *cell = pmFPAviewThisCell(view, file->fpa);148 return cell;130 PS_ASSERT_PTR_NON_NULL(files, false); 131 PS_ASSERT_PTR_NON_NULL(view, false); 132 PS_ASSERT_PTR_NON_NULL(name, false); 133 PS_ASSERT_INT_POSITIVE(strlen(name), false); 134 135 bool status; 136 137 pmFPAfile *file = psMetadataLookupPtr (&status, files, name); 138 if (file == NULL) { 139 return NULL; 140 } 141 142 // internal files have the readout as a separate element: 143 if (file->mode == PM_FPA_MODE_INTERNAL) { 144 return NULL; 145 } 146 147 pmCell *cell = pmFPAviewThisCell(view, file->fpa); 148 return cell; 149 149 } 150 150 … … 152 152 pmChip *pmFPAfileThisChip (psMetadata *files, const pmFPAview *view, const char *name) 153 153 { 154 PS_ASSERT_PTR_NON_NULL(files, false);155 PS_ASSERT_PTR_NON_NULL(view, false);156 PS_ASSERT_PTR_NON_NULL(name, false);157 PS_ASSERT_INT_POSITIVE(strlen(name), false);158 159 bool status;160 161 pmFPAfile *file = psMetadataLookupPtr (&status, files, name);162 if (file == NULL) {163 return NULL;164 }165 166 // internal files have the readout as a separate element:167 if (file->mode == PM_FPA_MODE_INTERNAL) {168 return NULL;169 }170 171 pmChip *chip = pmFPAviewThisChip (view, file->fpa);172 return chip;154 PS_ASSERT_PTR_NON_NULL(files, false); 155 PS_ASSERT_PTR_NON_NULL(view, false); 156 PS_ASSERT_PTR_NON_NULL(name, false); 157 PS_ASSERT_INT_POSITIVE(strlen(name), false); 158 159 bool status; 160 161 pmFPAfile *file = psMetadataLookupPtr (&status, files, name); 162 if (file == NULL) { 163 return NULL; 164 } 165 166 // internal files have the readout as a separate element: 167 if (file->mode == PM_FPA_MODE_INTERNAL) { 168 return NULL; 169 } 170 171 pmChip *chip = pmFPAviewThisChip (view, file->fpa); 172 return chip; 173 173 } 174 174 175 175 psString pmFPANameFromRule(const char *rule, const pmFPA *fpa, const pmFPAview *view) 176 176 { 177 PS_ASSERT_STRING_NON_EMPTY(rule, NULL); 178 PS_ASSERT_PTR_NON_NULL(view, NULL); 179 180 psString newName = NULL; // New name, to be returned 181 newName = psStringCopy(rule); 182 183 if (strstr (newName, "{FPA.OBS}") != NULL) { 184 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.OBS"); 185 if (name != NULL) { 186 psStringSubstitute(&newName, "fpa", "{FPA.OBS}"); 187 } 188 } 189 if (strstr (newName, "{CHIP.NAME}") != NULL) { 190 pmChip *chip = pmFPAviewThisChip (view, fpa); 191 if (chip != NULL) { 192 char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME"); 193 if (name != NULL) { 194 psStringSubstitute(&newName, name, "{CHIP.NAME}"); 195 } 196 } 197 } 198 if (strstr (newName, "{CHIP.ID}") != NULL) { 199 pmChip *chip = pmFPAviewThisChip (view, fpa); 200 if (chip != NULL) { 201 char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.ID"); 202 if (name != NULL) { 203 psStringSubstitute(&newName, name, "{CHIP.ID}"); 204 } 205 } 206 } 207 if (strstr (newName, "{CHIP.N}") != NULL) { 208 char *name = NULL; 209 if (view->chip < 0) { 210 psStringAppend (&name, "XX"); 211 } else { 212 psStringAppend (&name, "%02d", view->chip); 213 } 214 psStringSubstitute(&newName, name, "{CHIP.N}"); 215 psFree (name); 216 } 217 if (strstr (newName, "{CELL.NAME}") != NULL) { 218 pmCell *cell = pmFPAviewThisCell (view, fpa); 219 if (cell != NULL) { 220 char *name = psMetadataLookupStr (NULL, cell->concepts, "CELL.NAME"); 221 if (name != NULL) { 222 psStringSubstitute(&newName, name, "{CELL.NAME}"); 223 } 224 } 225 } 226 if (strstr (newName, "{CELL.N}") != NULL) { 227 char *name = NULL; 228 if (view->cell < 0) { 229 psStringAppend (&name, "XX"); 230 } else { 231 psStringAppend (&name, "%02d", view->cell); 232 } 233 psStringSubstitute(&newName, name, "{CELL.N}"); 234 } 235 if (strstr (newName, "{EXTNAME}") != NULL) { 236 pmHDU *hdu = pmFPAviewThisHDU (view, fpa); 237 if (hdu->extname && *hdu->extname) { 238 psStringSubstitute(&newName, hdu->extname, "{EXTNAME}"); 239 } 240 } 241 if (strstr (newName, "{FILTER}") != NULL) { 242 if (fpa != NULL) { 243 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTER"); 244 if (name && *name) { 245 psStringSubstitute(&newName, name, "{FILTER}"); 246 } 247 } 248 } 249 if (strstr (newName, "{FILTER.ID}") != NULL) { 250 if (fpa != NULL) { 251 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTERID"); 252 if (name && *name) { 253 psStringSubstitute(&newName, name, "{FILTER.ID}"); 254 } 255 } 256 } 257 if (strstr (newName, "{CAMERA}") != NULL) { 258 if (fpa != NULL) { 259 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT"); 260 if (name && *name) { 261 psStringSubstitute(&newName, name, "{CAMERA}"); 262 } 263 } 264 } 265 if (strstr (newName, "{INSTRUMENT}") != NULL) { 266 if (fpa != NULL) { 267 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT"); 268 if (name && *name) { 269 psStringSubstitute(&newName, name, "{INSTRUMENT}"); 270 } 271 } 272 } 273 if (strstr (newName, "{DETECTOR}") != NULL) { 274 if (fpa != NULL) { 275 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.DETECTOR"); 276 if (name && *name) { 277 psStringSubstitute(&newName, name, "{DETECTOR}"); 278 } 279 } 280 } 281 if (strstr (newName, "{TELESCOPE}") != NULL) { 282 if (fpa != NULL) { 283 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.TELESCOPE"); 284 if (name && *name) { 285 psStringSubstitute(&newName, name, "{TELESCOPE}"); 286 } 287 } 288 } 289 return newName; 177 PS_ASSERT_STRING_NON_EMPTY(rule, NULL); 178 PS_ASSERT_PTR_NON_NULL(view, NULL); 179 PS_ASSERT_PTR_NON_NULL(fpa, NULL); 180 181 psString newName = NULL; // New name, to be returned 182 newName = psStringCopy(rule); 183 184 if (strstr (newName, "{FPA.OBS}") != NULL) { 185 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.OBS"); 186 if (name != NULL) { 187 psStringSubstitute(&newName, name, "{FPA.OBS}"); 188 } 189 } 190 if (strstr (newName, "{FPA.NAME}") != NULL) { 191 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.NAME"); 192 if (name != NULL) { 193 psStringSubstitute(&newName, name, "{FPA.NAME}"); 194 } 195 } 196 if (strstr (newName, "{CHIP.NAME}") != NULL) { 197 pmChip *chip = pmFPAviewThisChip (view, fpa); 198 if (chip != NULL) { 199 char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME"); 200 if (name != NULL) { 201 psStringSubstitute(&newName, name, "{CHIP.NAME}"); 202 } 203 } 204 } 205 if (strstr (newName, "{CHIP.ID}") != NULL) { 206 pmChip *chip = pmFPAviewThisChip (view, fpa); 207 if (chip != NULL) { 208 char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.ID"); 209 if (name != NULL) { 210 psStringSubstitute(&newName, name, "{CHIP.ID}"); 211 } 212 } 213 } 214 if (strstr (newName, "{CHIP.N}") != NULL) { 215 char *name = NULL; 216 if (view->chip < 0) { 217 psStringAppend (&name, "XX"); 218 } else { 219 psStringAppend (&name, "%02d", view->chip); 220 } 221 psStringSubstitute(&newName, name, "{CHIP.N}"); 222 psFree (name); 223 } 224 if (strstr (newName, "{CELL.NAME}") != NULL) { 225 pmCell *cell = pmFPAviewThisCell (view, fpa); 226 if (cell != NULL) { 227 char *name = psMetadataLookupStr (NULL, cell->concepts, "CELL.NAME"); 228 if (name != NULL) { 229 psStringSubstitute(&newName, name, "{CELL.NAME}"); 230 } 231 } 232 } 233 if (strstr (newName, "{CELL.N}") != NULL) { 234 char *name = NULL; 235 if (view->cell < 0) { 236 psStringAppend (&name, "XX"); 237 } else { 238 psStringAppend (&name, "%02d", view->cell); 239 } 240 psStringSubstitute(&newName, name, "{CELL.N}"); 241 } 242 if (strstr (newName, "{EXTNAME}") != NULL) { 243 pmHDU *hdu = pmFPAviewThisHDU (view, fpa); 244 if (hdu->extname && *hdu->extname) { 245 psStringSubstitute(&newName, hdu->extname, "{EXTNAME}"); 246 } 247 } 248 if (strstr (newName, "{FILTER}") != NULL) { 249 if (fpa != NULL) { 250 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTER"); 251 if (name && *name) { 252 psStringSubstitute(&newName, name, "{FILTER}"); 253 } 254 } 255 } 256 if (strstr (newName, "{FILTER.ID}") != NULL) { 257 if (fpa != NULL) { 258 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTERID"); 259 if (name && *name) { 260 psStringSubstitute(&newName, name, "{FILTER.ID}"); 261 } 262 } 263 } 264 if (strstr (newName, "{CAMERA}") != NULL) { 265 if (fpa != NULL) { 266 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT"); 267 if (name && *name) { 268 psStringSubstitute(&newName, name, "{CAMERA}"); 269 } 270 } 271 } 272 if (strstr (newName, "{INSTRUMENT}") != NULL) { 273 if (fpa != NULL) { 274 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT"); 275 if (name && *name) { 276 psStringSubstitute(&newName, name, "{INSTRUMENT}"); 277 } 278 } 279 } 280 if (strstr (newName, "{DETECTOR}") != NULL) { 281 if (fpa != NULL) { 282 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.DETECTOR"); 283 if (name && *name) { 284 psStringSubstitute(&newName, name, "{DETECTOR}"); 285 } 286 } 287 } 288 if (strstr (newName, "{TELESCOPE}") != NULL) { 289 if (fpa != NULL) { 290 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.TELESCOPE"); 291 if (name && *name) { 292 psStringSubstitute(&newName, name, "{TELESCOPE}"); 293 } 294 } 295 } 296 return newName; 290 297 } 291 298 … … 293 300 psString pmFPAfileNameFromRule(const char *rule, const pmFPAfile *file, const pmFPAview *view) 294 301 { 295 PS_ASSERT_PTR_NON_NULL(rule, NULL);296 PS_ASSERT_INT_POSITIVE(strlen(rule), NULL);297 PS_ASSERT_PTR_NON_NULL(file, NULL);298 PS_ASSERT_PTR_NON_NULL(view, NULL);299 300 psString newRule = NULL; // Rule to pass on to pmFPANameFromRule301 newRule = psStringCopy(rule);302 303 if (strstr(newRule, "{OUTPUT}") != NULL) {304 char *name = psMetadataLookupStr(NULL, file->names, "OUTPUT");305 if (name) {306 psStringSubstitute(&newRule, name, "{OUTPUT}");307 }308 }309 310 psString newName = pmFPANameFromRule(newRule, file->fpa, view); // New name, to be returned311 psFree(newRule);312 313 return newName;302 PS_ASSERT_PTR_NON_NULL(rule, NULL); 303 PS_ASSERT_INT_POSITIVE(strlen(rule), NULL); 304 PS_ASSERT_PTR_NON_NULL(file, NULL); 305 PS_ASSERT_PTR_NON_NULL(view, NULL); 306 307 psString newRule = NULL; // Rule to pass on to pmFPANameFromRule 308 newRule = psStringCopy(rule); 309 310 if (strstr(newRule, "{OUTPUT}") != NULL) { 311 char *name = psMetadataLookupStr(NULL, file->names, "OUTPUT"); 312 if (name) { 313 psStringSubstitute(&newRule, name, "{OUTPUT}"); 314 } 315 } 316 317 psString newName = pmFPANameFromRule(newRule, file->fpa, view); // New name, to be returned 318 psFree(newRule); 319 320 return newName; 314 321 } 315 322 … … 318 325 bool pmFPAfileCopyView (pmFPA *out, pmFPA *in, const pmFPAview *view) 319 326 { 320 PS_ASSERT_PTR_NON_NULL(out, false); 321 PS_ASSERT_PTR_NON_NULL(in, false); 322 PS_ASSERT_PTR_NON_NULL(view, false); 323 324 // pmFPAWrite takes care of all PHUs as needed 325 if (view->chip == -1) { 326 pmFPACopy (out, in); 327 return true; 328 } 329 if (view->chip >= in->chips->n) { 330 psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %ld", view->chip, in->chips->n); 327 PS_ASSERT_PTR_NON_NULL(out, false); 328 PS_ASSERT_PTR_NON_NULL(in, false); 329 PS_ASSERT_PTR_NON_NULL(view, false); 330 331 // pmFPAWrite takes care of all PHUs as needed 332 if (view->chip == -1) { 333 pmFPACopy (out, in); 334 return true; 335 } 336 if (view->chip >= in->chips->n) { 337 psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %ld", view->chip, in->chips->n); 338 return false; 339 } 340 pmChip *inChip = in->chips->data[view->chip]; 341 pmChip *outChip = out->chips->data[view->chip]; 342 343 if (view->cell == -1) { 344 pmChipCopy (outChip, inChip); 345 return true; 346 } 347 if (view->cell >= inChip->cells->n) { 348 psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld", 349 view->cell, inChip->cells->n); 350 return false; 351 } 352 pmCell *inCell = inChip->cells->data[view->cell]; 353 pmCell *outCell = outChip->cells->data[view->cell]; 354 355 if (view->readout == -1) { 356 pmCellCopy (outCell, inCell); 357 return true; 358 } 359 psError(PS_ERR_UNKNOWN, true, "Returning false"); 331 360 return false; 332 } 333 pmChip *inChip = in->chips->data[view->chip]; 334 pmChip *outChip = out->chips->data[view->chip]; 335 336 if (view->cell == -1) { 337 pmChipCopy (outChip, inChip); 338 return true; 339 } 340 if (view->cell >= inChip->cells->n) { 341 psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld", 342 view->cell, inChip->cells->n); 343 return false; 344 } 345 pmCell *inCell = inChip->cells->data[view->cell]; 346 pmCell *outCell = outChip->cells->data[view->cell]; 347 348 if (view->readout == -1) { 349 pmCellCopy (outCell, inCell); 350 return true; 351 } 352 psError(PS_ERR_UNKNOWN, true, "Returning false"); 353 return false; 354 355 // XXX add readout / segment equivalents 361 362 // XXX add readout / segment equivalents 356 363 } 357 364 … … 360 367 bool pmFPAfileCopyStructureView (pmFPA *out, const pmFPA *in, int xBin, int yBin, const pmFPAview *view) 361 368 { 362 bool status; 363 PS_ASSERT_PTR_NON_NULL(out, false); 364 PS_ASSERT_PTR_NON_NULL(in, false); 365 PS_ASSERT_PTR_NON_NULL(view, false); 366 367 // XXX this should be smarter (ie, only copy concepts from the current chips) 368 // but such a call is needed, so re-copy stuff rather than no copy 369 pmFPACopyConcepts (out, in); 370 371 // pmFPAWrite takes care of all PHUs as needed 372 if (view->chip == -1) { 373 status = pmFPACopyStructure (out, in, xBin, yBin); 369 bool status; 370 PS_ASSERT_PTR_NON_NULL(out, false); 371 PS_ASSERT_PTR_NON_NULL(in, false); 372 PS_ASSERT_PTR_NON_NULL(view, false); 373 374 // XXX this should be smarter (ie, only copy concepts from the current chips) 375 // but such a call is needed, so re-copy stuff rather than no copy 376 pmFPACopyConcepts (out, in); 377 378 // pmFPAWrite takes care of all PHUs as needed 379 if (view->chip == -1) { 380 status = pmFPACopyStructure (out, in, xBin, yBin); 381 return status; 382 } 383 if (view->chip >= in->chips->n) { 384 psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %ld", view->chip, in->chips->n); 385 return false; 386 } 387 pmChip *inChip = in->chips->data[view->chip]; 388 pmChip *outChip = out->chips->data[view->chip]; 389 390 if (view->cell == -1) { 391 status = pmChipCopyStructure (outChip, inChip, xBin, yBin); 392 return status; 393 } 394 if (view->cell >= inChip->cells->n) { 395 psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld", 396 view->cell, inChip->cells->n); 397 return false; 398 } 399 pmCell *inCell = inChip->cells->data[view->cell]; 400 pmCell *outCell = outChip->cells->data[view->cell]; 401 402 status = pmCellCopyStructure (outCell, inCell, xBin, yBin); 374 403 return status; 375 }376 if (view->chip >= in->chips->n) {377 psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %ld", view->chip, in->chips->n);378 return false;379 }380 pmChip *inChip = in->chips->data[view->chip];381 pmChip *outChip = out->chips->data[view->chip];382 383 if (view->cell == -1) {384 status = pmChipCopyStructure (outChip, inChip, xBin, yBin);385 return status;386 }387 if (view->cell >= inChip->cells->n) {388 psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld",389 view->cell, inChip->cells->n);390 return false;391 }392 pmCell *inCell = inChip->cells->data[view->cell];393 pmCell *outCell = outChip->cells->data[view->cell];394 395 status = pmCellCopyStructure (outCell, inCell, xBin, yBin);396 return status;397 404 } 398 405 399 406 pmFPAfileType pmFPAfileTypeFromString(const char *type) 400 407 { 401 PS_ASSERT_STRING_NON_EMPTY(type, PM_FPA_FILE_NONE);402 403 if (!strcasecmp (type, "SX")) {404 return PM_FPA_FILE_SX;405 }406 if (!strcasecmp (type, "OBJ")) {407 return PM_FPA_FILE_OBJ;408 }409 if (!strcasecmp (type, "CMP")) {410 return PM_FPA_FILE_CMP;411 }412 if (!strcasecmp (type, "CMF")) {413 return PM_FPA_FILE_CMF;414 }415 if (!strcasecmp (type, "RAW")) {416 return PM_FPA_FILE_RAW;417 }418 if (!strcasecmp (type, "IMAGE")) {419 return PM_FPA_FILE_IMAGE;420 }421 if (!strcasecmp (type, "PSF")) {422 return PM_FPA_FILE_PSF;423 }424 if (!strcasecmp (type, "JPEG")) {425 return PM_FPA_FILE_JPEG;426 }427 if (!strcasecmp (type, "KAPA")) {428 return PM_FPA_FILE_KAPA;429 }430 if (!strcasecmp (type, "MASK")) {431 return PM_FPA_FILE_MASK;432 }433 if (!strcasecmp (type, "WEIGHT")) {434 return PM_FPA_FILE_WEIGHT;435 }436 if (!strcasecmp (type, "FRINGE")) {437 return PM_FPA_FILE_FRINGE;438 }439 if (!strcasecmp (type, "DARK")) {440 return PM_FPA_FILE_DARK;441 }442 if (!strcasecmp (type, "HEADER")) {443 return PM_FPA_FILE_HEADER;444 }445 // deprecate this?446 if (!strcasecmp (type, "ASTROM")) {447 return PM_FPA_FILE_ASTROM_MODEL;448 }449 if (!strcasecmp (type, "ASTROM.MODEL")) {450 return PM_FPA_FILE_ASTROM_MODEL;451 }452 if (!strcasecmp (type, "ASTROM.REFSTARS")) {453 return PM_FPA_FILE_ASTROM_REFSTARS;454 }455 456 return PM_FPA_FILE_NONE;408 PS_ASSERT_STRING_NON_EMPTY(type, PM_FPA_FILE_NONE); 409 410 if (!strcasecmp (type, "SX")) { 411 return PM_FPA_FILE_SX; 412 } 413 if (!strcasecmp (type, "OBJ")) { 414 return PM_FPA_FILE_OBJ; 415 } 416 if (!strcasecmp (type, "CMP")) { 417 return PM_FPA_FILE_CMP; 418 } 419 if (!strcasecmp (type, "CMF")) { 420 return PM_FPA_FILE_CMF; 421 } 422 if (!strcasecmp (type, "RAW")) { 423 return PM_FPA_FILE_RAW; 424 } 425 if (!strcasecmp (type, "IMAGE")) { 426 return PM_FPA_FILE_IMAGE; 427 } 428 if (!strcasecmp (type, "PSF")) { 429 return PM_FPA_FILE_PSF; 430 } 431 if (!strcasecmp (type, "JPEG")) { 432 return PM_FPA_FILE_JPEG; 433 } 434 if (!strcasecmp (type, "KAPA")) { 435 return PM_FPA_FILE_KAPA; 436 } 437 if (!strcasecmp (type, "MASK")) { 438 return PM_FPA_FILE_MASK; 439 } 440 if (!strcasecmp (type, "WEIGHT")) { 441 return PM_FPA_FILE_WEIGHT; 442 } 443 if (!strcasecmp (type, "FRINGE")) { 444 return PM_FPA_FILE_FRINGE; 445 } 446 if (!strcasecmp (type, "DARK")) { 447 return PM_FPA_FILE_DARK; 448 } 449 if (!strcasecmp (type, "HEADER")) { 450 return PM_FPA_FILE_HEADER; 451 } 452 // deprecate this? 453 if (!strcasecmp (type, "ASTROM")) { 454 return PM_FPA_FILE_ASTROM_MODEL; 455 } 456 if (!strcasecmp (type, "ASTROM.MODEL")) { 457 return PM_FPA_FILE_ASTROM_MODEL; 458 } 459 if (!strcasecmp (type, "ASTROM.REFSTARS")) { 460 return PM_FPA_FILE_ASTROM_REFSTARS; 461 } 462 463 return PM_FPA_FILE_NONE; 457 464 } 458 465 459 466 const char *pmFPAfileStringFromType(pmFPAfileType type) 460 467 { 461 switch (type) {462 case PM_FPA_FILE_SX:463 return ("SX");464 case PM_FPA_FILE_OBJ:465 return ("OBJ");466 case PM_FPA_FILE_CMP:467 return ("CMP");468 case PM_FPA_FILE_CMF:469 return ("CMF");470 case PM_FPA_FILE_RAW:471 return ("RAW");472 case PM_FPA_FILE_IMAGE:473 return ("IMAGE");474 case PM_FPA_FILE_PSF:475 return ("PSF");476 case PM_FPA_FILE_JPEG:477 return ("JPEG");478 case PM_FPA_FILE_KAPA:479 return ("KAPA");480 case PM_FPA_FILE_MASK:481 return ("MASK");482 case PM_FPA_FILE_WEIGHT:483 return ("WEIGHT");484 case PM_FPA_FILE_FRINGE:485 return ("FRINGE");486 case PM_FPA_FILE_DARK:487 return("DARK");488 case PM_FPA_FILE_HEADER:489 return ("HEADER");490 case PM_FPA_FILE_ASTROM_MODEL:491 return ("ASTROM.MODEL");492 case PM_FPA_FILE_ASTROM_REFSTARS:493 return ("ASTROM.REFSTARS");494 default:495 return ("NONE");496 }497 return ("NONE");468 switch (type) { 469 case PM_FPA_FILE_SX: 470 return ("SX"); 471 case PM_FPA_FILE_OBJ: 472 return ("OBJ"); 473 case PM_FPA_FILE_CMP: 474 return ("CMP"); 475 case PM_FPA_FILE_CMF: 476 return ("CMF"); 477 case PM_FPA_FILE_RAW: 478 return ("RAW"); 479 case PM_FPA_FILE_IMAGE: 480 return ("IMAGE"); 481 case PM_FPA_FILE_PSF: 482 return ("PSF"); 483 case PM_FPA_FILE_JPEG: 484 return ("JPEG"); 485 case PM_FPA_FILE_KAPA: 486 return ("KAPA"); 487 case PM_FPA_FILE_MASK: 488 return ("MASK"); 489 case PM_FPA_FILE_WEIGHT: 490 return ("WEIGHT"); 491 case PM_FPA_FILE_FRINGE: 492 return ("FRINGE"); 493 case PM_FPA_FILE_DARK: 494 return("DARK"); 495 case PM_FPA_FILE_HEADER: 496 return ("HEADER"); 497 case PM_FPA_FILE_ASTROM_MODEL: 498 return ("ASTROM.MODEL"); 499 case PM_FPA_FILE_ASTROM_REFSTARS: 500 return ("ASTROM.REFSTARS"); 501 default: 502 return ("NONE"); 503 } 504 return ("NONE"); 498 505 } 499 506
Note:
See TracChangeset
for help on using the changeset viewer.
