Changeset 19005 for trunk/psModules/src/camera/pmFPAfile.c
- Timestamp:
- Aug 11, 2008, 11:11:41 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAfile.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfile.c
r17987 r19005 22 22 { 23 23 if (!file) { 24 return;24 return; 25 25 } 26 26 … … 38 38 39 39 if (file->fits != NULL) { 40 psFitsClose (file->fits);40 psFitsClose (file->fits); 41 41 } 42 42 psFree(file->compression); … … 113 113 pmFPAfile *file = psMetadataLookupPtr (&status, files, name); 114 114 if (file == NULL) { 115 return NULL;115 return NULL; 116 116 } 117 117 118 118 // internal files have the readout as a separate element: 119 119 if (file->mode == PM_FPA_MODE_INTERNAL) { 120 return file->readout;120 return file->readout; 121 121 } 122 122 … … 137 137 pmFPAfile *file = psMetadataLookupPtr (&status, files, name); 138 138 if (file == NULL) { 139 return NULL;139 return NULL; 140 140 } 141 141 142 142 // internal files have the readout as a separate element: 143 143 if (file->mode == PM_FPA_MODE_INTERNAL) { 144 return NULL;144 return NULL; 145 145 } 146 146 … … 161 161 pmFPAfile *file = psMetadataLookupPtr (&status, files, name); 162 162 if (file == NULL) { 163 return NULL;163 return NULL; 164 164 } 165 165 166 166 // internal files have the readout as a separate element: 167 167 if (file->mode == PM_FPA_MODE_INTERNAL) { 168 return NULL;168 return NULL; 169 169 } 170 170 … … 183 183 184 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 }185 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.OBS"); 186 if (name != NULL) { 187 psStringSubstitute(&newName, name, "{FPA.OBS}"); 188 } 189 189 } 190 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 }191 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.NAME"); 192 if (name != NULL) { 193 psStringSubstitute(&newName, name, "{FPA.NAME}"); 194 } 195 195 } 196 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 }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 204 } 205 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 }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 213 } 214 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); 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, "{CHIP.NUM}") != NULL) { 225 char *name = NULL; 226 if (view->chip < 0) { 227 psStringAppend (&name, "XX"); 228 } else { 229 psStringAppend (&name, "%d", view->chip); 230 } 231 psStringSubstitute(&newName, name, "{CHIP.NUM}"); 232 psFree (name); 223 233 } 224 234 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 }235 pmCell *cell = pmFPAviewThisCell (view, fpa); 236 if (cell != NULL) { 237 char *name = psMetadataLookupStr (NULL, cell->concepts, "CELL.NAME"); 238 if (name != NULL) { 239 psStringSubstitute(&newName, name, "{CELL.NAME}"); 240 } 241 } 232 242 } 233 243 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}"); 244 char *name = NULL; 245 if (view->cell < 0) { 246 psStringAppend (&name, "XX"); 247 } else { 248 psStringAppend (&name, "%02d", view->cell); 249 } 250 psStringSubstitute(&newName, name, "{CELL.N}"); 251 } 252 if (strstr (newName, "{CELL.NUM}") != NULL) { 253 char *name = NULL; 254 if (view->cell < 0) { 255 psStringAppend (&name, "XX"); 256 } else { 257 psStringAppend (&name, "%d", view->cell); 258 } 259 psStringSubstitute(&newName, name, "{CELL.NUM}"); 241 260 } 242 261 if (strstr (newName, "{EXTNAME}") != NULL) { 243 pmHDU *hdu = pmFPAviewThisHDU (view, fpa);244 if (hdu->extname && *hdu->extname) {245 psStringSubstitute(&newName, hdu->extname, "{EXTNAME}");246 }262 pmHDU *hdu = pmFPAviewThisHDU (view, fpa); 263 if (hdu->extname && *hdu->extname) { 264 psStringSubstitute(&newName, hdu->extname, "{EXTNAME}"); 265 } 247 266 } 248 267 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 }268 if (fpa != NULL) { 269 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTER"); 270 if (name && *name) { 271 psStringSubstitute(&newName, name, "{FILTER}"); 272 } 273 } 255 274 } 256 275 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 }276 if (fpa != NULL) { 277 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTERID"); 278 if (name && *name) { 279 psStringSubstitute(&newName, name, "{FILTER.ID}"); 280 } 281 } 263 282 } 264 283 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 }284 if (fpa != NULL) { 285 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT"); 286 if (name && *name) { 287 psStringSubstitute(&newName, name, "{CAMERA}"); 288 } 289 } 271 290 } 272 291 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 }292 if (fpa != NULL) { 293 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT"); 294 if (name && *name) { 295 psStringSubstitute(&newName, name, "{INSTRUMENT}"); 296 } 297 } 279 298 } 280 299 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 }300 if (fpa != NULL) { 301 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.DETECTOR"); 302 if (name && *name) { 303 psStringSubstitute(&newName, name, "{DETECTOR}"); 304 } 305 } 287 306 } 288 307 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 }308 if (fpa != NULL) { 309 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.TELESCOPE"); 310 if (name && *name) { 311 psStringSubstitute(&newName, name, "{TELESCOPE}"); 312 } 313 } 295 314 } 296 315 return newName; … … 309 328 310 329 if (strstr(newRule, "{OUTPUT}") != NULL) { 311 char *name = psMetadataLookupStr(NULL, file->names, "OUTPUT");312 if (name) {313 psStringSubstitute(&newRule, name, "{OUTPUT}");314 }330 char *name = psMetadataLookupStr(NULL, file->names, "OUTPUT"); 331 if (name) { 332 psStringSubstitute(&newRule, name, "{OUTPUT}"); 333 } 315 334 } 316 335 … … 331 350 // pmFPAWrite takes care of all PHUs as needed 332 351 if (view->chip == -1) { 333 pmFPACopy (out, in);334 return true;352 pmFPACopy (out, in); 353 return true; 335 354 } 336 355 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;356 psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %ld", view->chip, in->chips->n); 357 return false; 339 358 } 340 359 pmChip *inChip = in->chips->data[view->chip]; … … 342 361 343 362 if (view->cell == -1) { 344 pmChipCopy (outChip, inChip);345 return true;363 pmChipCopy (outChip, inChip); 364 return true; 346 365 } 347 366 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;367 psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld", 368 view->cell, inChip->cells->n); 369 return false; 351 370 } 352 371 pmCell *inCell = inChip->cells->data[view->cell]; … … 354 373 355 374 if (view->readout == -1) { 356 pmCellCopy (outCell, inCell);357 return true;375 pmCellCopy (outCell, inCell); 376 return true; 358 377 } 359 378 psError(PS_ERR_UNKNOWN, true, "Returning false"); … … 378 397 // pmFPAWrite takes care of all PHUs as needed 379 398 if (view->chip == -1) { 380 status = pmFPACopyStructure (out, in, xBin, yBin);381 return status;399 status = pmFPACopyStructure (out, in, xBin, yBin); 400 return status; 382 401 } 383 402 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;403 psError(PS_ERR_IO, true, "Requested chip == %d >= in->chips->n == %ld", view->chip, in->chips->n); 404 return false; 386 405 } 387 406 pmChip *inChip = in->chips->data[view->chip]; … … 389 408 390 409 if (view->cell == -1) { 391 status = pmChipCopyStructure (outChip, inChip, xBin, yBin);392 return status;410 status = pmChipCopyStructure (outChip, inChip, xBin, yBin); 411 return status; 393 412 } 394 413 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;414 psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld", 415 view->cell, inChip->cells->n); 416 return false; 398 417 } 399 418 pmCell *inCell = inChip->cells->data[view->cell]; … … 409 428 410 429 if (!strcasecmp (type, "SX")) { 411 return PM_FPA_FILE_SX;430 return PM_FPA_FILE_SX; 412 431 } 413 432 if (!strcasecmp (type, "OBJ")) { 414 return PM_FPA_FILE_OBJ;433 return PM_FPA_FILE_OBJ; 415 434 } 416 435 if (!strcasecmp (type, "CMP")) { 417 return PM_FPA_FILE_CMP;436 return PM_FPA_FILE_CMP; 418 437 } 419 438 if (!strcasecmp (type, "CMF")) { 420 return PM_FPA_FILE_CMF;439 return PM_FPA_FILE_CMF; 421 440 } 422 441 if (!strcasecmp (type, "RAW")) { 423 return PM_FPA_FILE_RAW;442 return PM_FPA_FILE_RAW; 424 443 } 425 444 if (!strcasecmp (type, "IMAGE")) { 426 return PM_FPA_FILE_IMAGE;445 return PM_FPA_FILE_IMAGE; 427 446 } 428 447 if (!strcasecmp (type, "PSF")) { 429 return PM_FPA_FILE_PSF;448 return PM_FPA_FILE_PSF; 430 449 } 431 450 if (!strcasecmp (type, "JPEG")) { 432 return PM_FPA_FILE_JPEG;451 return PM_FPA_FILE_JPEG; 433 452 } 434 453 if (!strcasecmp (type, "KAPA")) { 435 return PM_FPA_FILE_KAPA;454 return PM_FPA_FILE_KAPA; 436 455 } 437 456 if (!strcasecmp (type, "MASK")) { 438 return PM_FPA_FILE_MASK;457 return PM_FPA_FILE_MASK; 439 458 } 440 459 if (!strcasecmp (type, "WEIGHT")) { 441 return PM_FPA_FILE_WEIGHT;460 return PM_FPA_FILE_WEIGHT; 442 461 } 443 462 if (!strcasecmp (type, "FRINGE")) { 444 return PM_FPA_FILE_FRINGE;463 return PM_FPA_FILE_FRINGE; 445 464 } 446 465 if (!strcasecmp (type, "DARK")) { 447 return PM_FPA_FILE_DARK;466 return PM_FPA_FILE_DARK; 448 467 } 449 468 if (!strcasecmp (type, "HEADER")) { 450 return PM_FPA_FILE_HEADER;469 return PM_FPA_FILE_HEADER; 451 470 } 452 471 // deprecate this? 453 472 if (!strcasecmp (type, "ASTROM")) { 454 return PM_FPA_FILE_ASTROM_MODEL;473 return PM_FPA_FILE_ASTROM_MODEL; 455 474 } 456 475 if (!strcasecmp (type, "ASTROM.MODEL")) { 457 return PM_FPA_FILE_ASTROM_MODEL;476 return PM_FPA_FILE_ASTROM_MODEL; 458 477 } 459 478 if (!strcasecmp (type, "ASTROM.REFSTARS")) { 460 return PM_FPA_FILE_ASTROM_REFSTARS;479 return PM_FPA_FILE_ASTROM_REFSTARS; 461 480 } 462 481 … … 468 487 switch (type) { 469 488 case PM_FPA_FILE_SX: 470 return ("SX");489 return ("SX"); 471 490 case PM_FPA_FILE_OBJ: 472 return ("OBJ");491 return ("OBJ"); 473 492 case PM_FPA_FILE_CMP: 474 return ("CMP");493 return ("CMP"); 475 494 case PM_FPA_FILE_CMF: 476 return ("CMF");495 return ("CMF"); 477 496 case PM_FPA_FILE_RAW: 478 return ("RAW");497 return ("RAW"); 479 498 case PM_FPA_FILE_IMAGE: 480 return ("IMAGE");499 return ("IMAGE"); 481 500 case PM_FPA_FILE_PSF: 482 return ("PSF");501 return ("PSF"); 483 502 case PM_FPA_FILE_JPEG: 484 return ("JPEG");503 return ("JPEG"); 485 504 case PM_FPA_FILE_KAPA: 486 return ("KAPA");505 return ("KAPA"); 487 506 case PM_FPA_FILE_MASK: 488 return ("MASK");507 return ("MASK"); 489 508 case PM_FPA_FILE_WEIGHT: 490 return ("WEIGHT");509 return ("WEIGHT"); 491 510 case PM_FPA_FILE_FRINGE: 492 return ("FRINGE");511 return ("FRINGE"); 493 512 case PM_FPA_FILE_DARK: 494 return("DARK");513 return("DARK"); 495 514 case PM_FPA_FILE_HEADER: 496 return ("HEADER");515 return ("HEADER"); 497 516 case PM_FPA_FILE_ASTROM_MODEL: 498 return ("ASTROM.MODEL");517 return ("ASTROM.MODEL"); 499 518 case PM_FPA_FILE_ASTROM_REFSTARS: 500 return ("ASTROM.REFSTARS");519 return ("ASTROM.REFSTARS"); 501 520 default: 502 return ("NONE");521 return ("NONE"); 503 522 } 504 523 return ("NONE");
Note:
See TracChangeset
for help on using the changeset viewer.
