- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/psModules
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psModules merged eligible /branches/eam_branches/stackphot.20100406/psModules 27623-27653 /branches/pap_delete/psModules 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/psModules/src/camera/pmFPAfileDefine.c
r23370 r27840 57 57 return NAN; 58 58 } 59 int value = psMetadataItemParseF32(item); // Value of interst59 float value = psMetadataItemParseF32(item); // Value of interst 60 60 return value; 61 61 } … … 72 72 return NAN; 73 73 } 74 intvalue = psMetadataItemParseF64(item); // Value of interst74 double value = psMetadataItemParseF64(item); // Value of interst 75 75 return value; 76 76 } … … 91 91 psMetadata *data = pmConfigFileRule(config, camera, name); // File rule 92 92 if (!data) { 93 psError( PS_ERR_IO, true, "Can't find file rule %s!", name);93 psError(psErrorCodeLast(), false, "Can't find file rule %s!", name); 94 94 return NULL; 95 95 } … … 105 105 file->type = pmFPAfileTypeFromString(type); 106 106 if (file->type == PM_FPA_FILE_NONE) { 107 psError(P S_ERR_IO, true, "FILE.TYPE is not defined for %s\n", name);107 psError(PM_ERR_CONFIG, true, "FILE.TYPE is not defined for %s\n", name); 108 108 psFree(file); 109 109 return NULL; … … 115 115 file->dataLevel = pmFPALevelFromName(psMetadataLookupStr (&status, data, "DATA.LEVEL")); 116 116 if (file->dataLevel == PM_FPA_LEVEL_NONE) { 117 psError(P S_ERR_IO, true, "DATA.LEVEL is not set for %s\n", name);117 psError(PM_ERR_CONFIG, true, "DATA.LEVEL is not set for %s\n", name); 118 118 psFree(file); 119 119 return NULL; … … 137 137 if (!psMetadataAddPtr(config->files, PS_LIST_TAIL, name, 138 138 PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, "", file)) { 139 psError(P S_ERR_IO, false, "could not add %s to config files", name);139 psError(PM_ERR_CONFIG, false, "could not add %s to config files", name); 140 140 return NULL; 141 141 } … … 167 167 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->system, "CAMERAS"); // Known cameras 168 168 if (!mdok || !cameras) { 169 psError(P S_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");169 psError(PM_ERR_CONFIG, true, "Unable to find CAMERAS in the system configuration.\n"); 170 170 return NULL; 171 171 } 172 172 camera = psMetadataLookupMetadata(&mdok, cameras, cameraName); // Camera configuration of interest 173 173 if (!mdok || !camera) { 174 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find automatically generated " 175 "camera configuration %s in system configuration.\n", cameraName); 174 psError(PM_ERR_CONFIG, true, 175 "Unable to find automatically generated camera configuration %s in system configuration.", 176 cameraName); 176 177 return NULL; 177 178 } … … 184 185 psMetadata *filerule = pmConfigFileRule(config, camera, name); // File rule 185 186 if (!filerule) { 186 psError( PS_ERR_IO, true, "Can't find file rule %s!", name);187 psError(psErrorCodeLast(), false, "Can't find file rule %s!", name); 187 188 return NULL; 188 189 } … … 199 200 file->type = pmFPAfileTypeFromString(type); 200 201 if (file->type == PM_FPA_FILE_NONE) { 201 psError(P S_ERR_IO, true, "FILE.TYPE is not defined for %s\n", name);202 psError(PM_ERR_CONFIG, true, "FILE.TYPE is not defined for %s\n", name); 202 203 psFree(file); 203 204 return NULL; … … 230 231 psMetadata *format = psMetadataLookupMetadata(&status, formats, formatName); // Camera format to use 231 232 if (!format) { 232 psError(P S_ERR_BAD_PARAMETER_VALUE, true, "Unable to find format %s for file %s.\n",233 psError(PM_ERR_CONFIG, true, "Unable to find format %s for file %s.\n", 233 234 formatName, file->name); 234 235 psFree(file); … … 287 288 options->stdevNum = parseOptionFloat(scheme, "STDEV.NUM", source); // Padding to edge 288 289 if (!isfinite(options->stdevNum)) { 289 psError(P S_ERR_BAD_PARAMETER_VALUE, false, "Bad value for STDEV.NUM for %s", source);290 psError(PM_ERR_CONFIG, true, "Bad value for STDEV.NUM for %s", source); 290 291 psFree(source); 291 292 psFree(file); … … 296 297 options->stdevBits = parseOptionInt(scheme, "STDEV.BITS", source, 0); // Bits for stdev 297 298 if (options->stdevBits <= 0) { 298 psError(P S_ERR_BAD_PARAMETER_VALUE, false, "Bad value for STDEV.BITS (%d) for %s",299 psError(PM_ERR_CONFIG, true, "Bad value for STDEV.BITS (%d) for %s", 299 300 options->stdevBits, source); 300 301 psFree(source); … … 310 311 psAbort("Should never get here."); 311 312 } 313 } 314 315 psMetadataItem *fuzz = psMetadataLookup(scheme, "FUZZ"); // Quantisation fuzz? 316 if (fuzz) { 317 if (fuzz->type != PS_TYPE_BOOL) { 318 psWarning("FUZZ in compression scheme %s isn't boolean.", fitsType); 319 goto FITS_OPTIONS_DONE; 320 } 321 options->fuzz = fuzz->data.B; 312 322 } 313 323 … … 337 347 file->fileLevel = pmFPAPHULevel(format); 338 348 if (file->fileLevel == PM_FPA_LEVEL_NONE) { 339 psError(P S_ERR_IO, true, "Unable to determine file level for %s\n", name);349 psError(PM_ERR_CONFIG, true, "Unable to determine file level for %s\n", name); 340 350 psFree(file); 341 351 return NULL; … … 344 354 file->dataLevel = pmFPALevelFromName(psMetadataLookupStr(&status, filerule, "DATA.LEVEL")); 345 355 if (file->dataLevel == PM_FPA_LEVEL_NONE) { 346 psError(P S_ERR_IO, true, "DATA.LEVEL is not set for %s\n", name);356 psError(PM_ERR_CONFIG, true, "DATA.LEVEL is not set for %s\n", name); 347 357 psFree(file); 348 358 return NULL; … … 443 453 psString realName = pmConfigConvertFilename(filenames->data[0], config, false, false); 444 454 if (!realName) { 445 psError( PS_ERR_IO, false, "Failed to convert file name %s", (char *)filenames->data[0]);455 psError(psErrorCodeLast(), false, "Failed to convert file name %s", (char *)filenames->data[0]); 446 456 return NULL; 447 457 } … … 451 461 psFits *fits = psFitsOpen(realName, "r"); // FITS file 452 462 if (!fits) { 453 psError( PS_ERR_IO, false, "Failed to open file %s", realName);463 psError(psErrorCodeLast(), false, "Failed to open file %s", realName); 454 464 psFree(realName); 455 465 return NULL; … … 457 467 phu = psFitsReadHeader (NULL, fits); // Primary header 458 468 if (!phu) { 459 psError( PS_ERR_IO, false, "Failed to read file header %s", realName);469 psError(psErrorCodeLast(), false, "Failed to read file header %s", realName); 460 470 psFree(realName); 461 471 return NULL; 462 472 } 463 psFitsClose(fits); 473 if (!psFitsClose(fits)) { 474 psError(psErrorCodeLast(), false, "Failed to close file %s", realName); 475 psFree(realName); 476 return NULL; 477 } 464 478 465 479 // Determine the current format from the header; determine camera if not specified already. … … 467 481 format = pmConfigCameraFormatFromHeader(&camera, &cameraName, &formatName, config, phu, true); 468 482 if (!format) { 469 psError( PS_ERR_IO, false, "Failed to determine camera format for %s", realName);483 psError(psErrorCodeLast(), false, "Failed to determine camera format for %s", realName); 470 484 psFree(camera); 471 485 psFree(formatName); … … 477 491 fileLevel = pmFPAPHULevel(format); 478 492 if (fileLevel == PM_FPA_LEVEL_NONE) { 479 psError(P S_ERR_IO, true, "Unable to determine file level for %s", realName);493 psError(PM_ERR_CONFIG, true, "Unable to determine file level for %s", realName); 480 494 psFree(camera); 481 495 psFree(formatName); … … 490 504 psFree(camera); 491 505 if (!fpa) { 492 psError( PS_ERR_IO, false, "Failed to construct FPA from %s", realName);506 psError(psErrorCodeLast(), false, "Failed to construct FPA from %s", realName); 493 507 psFree(formatName); 494 508 psFree(realName); … … 504 518 pmFPAfile *file = pmFPAfileDefineInput(config, fpa, cameraName, name); // File, to return 505 519 if (!file) { 506 psError( PS_ERR_IO, false, "File %s not defined", name);520 psError(psErrorCodeLast(), false, "File %s not defined", name); 507 521 psFree(formatName); 508 522 psFree(format); … … 531 545 psString realName = pmConfigConvertFilename(filenames->data[i], config, false, false); 532 546 if (!realName) { 533 psError( PS_ERR_IO, false, "Failed to convert file name %s", (char*)filenames->data[i]);547 psError(psErrorCodeLast(), false, "Failed to convert file name %s", (char*)filenames->data[i]); 534 548 return NULL; 535 549 } 536 550 psFits *fits = psFitsOpen(realName, "r"); // FITS file 537 551 if (!fits) { 538 psError( PS_ERR_IO, false, "Failed to open file %s", realName);552 psError(psErrorCodeLast(), false, "Failed to open file %s", realName); 539 553 psFree(realName); 540 554 return NULL; 541 555 } 542 556 phu = psFitsReadHeader(NULL, fits); 543 psFitsClose(fits); 557 if (!psFitsClose(fits)) { 558 psError(psErrorCodeLast(), false, "Failed to close file %s", realName); 559 psFree(realName); 560 return NULL; 561 } 544 562 if (!phu) { 545 psError( PS_ERR_IO, false, "Failed to read file header %s", realName);563 psError(psErrorCodeLast(), false, "Failed to read file header %s", realName); 546 564 psFree(realName); 547 565 return NULL; … … 552 570 if (i == 0 && file->type == PM_FPA_FILE_MASK) { 553 571 if (!pmConfigMaskReadHeader(config, phu)) { 554 psError( PS_ERR_IO, false, "Error reading mask bits");572 psError(psErrorCodeLast(), false, "Error reading mask bits"); 555 573 psFree(phu); 556 574 return NULL; … … 562 580 bool valid = false; 563 581 if (!pmConfigValidateCameraFormat(&valid, format, phu)) { 564 psError( PS_ERR_UNKNOWN, false, "Error in config scripts\n");582 psError(psErrorCodeLast(), false, "Error in config scripts\n"); 565 583 psFree(phu); 566 584 return NULL; 567 585 } 568 586 if (!valid) { 569 psError( PS_ERR_IO, false, "File %s is not from the required camera",587 psError(psErrorCodeLast(), false, "File %s is not from the required camera", 570 588 (char*)filenames->data[i]); 571 589 psFree(phu); … … 575 593 format = pmConfigCameraFormatFromHeader(NULL, NULL, NULL, config, phu, true); 576 594 if (!format) { 577 psError( PS_ERR_IO, false, "Failed to determine camera format from %s",595 psError(psErrorCodeLast(), false, "Failed to determine camera format from %s", 578 596 (char*)filenames->data[i]); 579 597 psFree(phu); … … 601 619 phu = NULL; 602 620 if (!view) { 603 psError(P S_ERR_IO, false, "Unable to determine source for %s", name);621 psError(PM_ERR_CONFIG, true, "Unable to determine source for %s", name); 604 622 return NULL; 605 623 } … … 633 651 } 634 652 if (filenames->n == 0) { 635 psError(P S_ERR_IO, false, "No files in array in %s in arguments", argname);653 psError(PM_ERR_CONFIG, true, "No files in array in %s in arguments", argname); 636 654 if (success) { 637 655 *success = false; … … 667 685 } 668 686 if (filenames->n == 0) { 669 psError(P S_ERR_IO, false, "No files in array in %s in arguments", argname);687 psError(PM_ERR_CONFIG, true, "No files in array in %s in arguments", argname); 670 688 if (success) { 671 689 *success = false; … … 700 718 } 701 719 if (filenames->n <= entry) { 702 psError(P S_ERR_IO, false, "Insufficient files (%ld) in array in %s in arguments",720 psError(PM_ERR_CONFIG, true, "Insufficient files (%ld) in array in %s in arguments", 703 721 filenames->n, argname); 704 722 if (success) { … … 760 778 } 761 779 if (bind && files->n != bind->n) { 762 psError(P S_ERR_BAD_PARAMETER_VALUE, true,780 psError(PM_ERR_CONFIG, true, 763 781 "Length of filenames (%ld) and bind files (%ld) does not match.", 764 782 files->n, bind->n); … … 774 792 files->data[i] = psMemIncrRefCounter(fpaFileDefineFromArray(config, bindFile, filename, dummy)); 775 793 if (!files->data[i]) { 776 psError( PS_ERR_UNKNOWN, false, "Unable to define file %s %d", filename, i);794 psError(psErrorCodeLast(), false, "Unable to define file %s %d", filename, i); 777 795 psFree(dummy); 778 796 psFree(files); … … 802 820 // a camera config is needed (as source of file rule) 803 821 if (config->camera == NULL) { 804 psError(P S_ERR_IO, true, "camera is not defined");822 psError(PM_ERR_PROG, true, "camera is not defined"); 805 823 return NULL; 806 824 } … … 809 827 pmFPA *fpa = pmFPAConstruct(config->camera, config->cameraName); 810 828 if (!fpa) { 811 psError( PS_ERR_IO, false, "Failed to construct FPA for %s", filename);829 psError(psErrorCodeLast(), false, "Failed to construct FPA for %s", filename); 812 830 return NULL; 813 831 } … … 818 836 psFree (fpa); 819 837 if (!file) { 820 psError( PS_ERR_IO, false, "file %s not defined\n", filename);838 psError(psErrorCodeLast(), false, "file %s not defined\n", filename); 821 839 return NULL; 822 840 } … … 824 842 // image names may not come from file->names 825 843 if (!strcasecmp(file->filerule, "@FILES")) { 826 psError(P S_ERR_IO, true, "supplied filerule uses illegal value @FILES");844 psError(PM_ERR_CONFIG, true, "supplied filerule uses illegal value @FILES"); 827 845 // XXX remove the file from config->files 828 846 return NULL; … … 881 899 // a camera config is needed (as source of file rule) 882 900 if (config->camera == NULL) { 883 psError(P S_ERR_IO, true, "camera is not defined");901 psError(PM_ERR_PROG, true, "camera is not defined"); 884 902 return NULL; 885 903 } … … 895 913 fpa = pmFPAConstruct(config->camera, config->cameraName); 896 914 if (!fpa) { 897 psError( PS_ERR_IO, false, "Failed to construct FPA for %s", filename);915 psError(psErrorCodeLast(), false, "Failed to construct FPA for %s", filename); 898 916 return NULL; 899 917 } … … 902 920 file = pmFPAfileDefineInput (config, fpa, NULL, filename); 903 921 if (!file) { 904 psError( PS_ERR_IO, false, "file %s not defined\n", filename);922 psError(psErrorCodeLast(), false, "file %s not defined\n", filename); 905 923 psFree(fpa); 906 924 return NULL; … … 934 952 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, "PPIMAGE"); 935 953 if (!status) { 936 psError(P S_ERR_UNEXPECTED_NULL, true, "PPIMAGE recipe not found.");954 psError(PM_ERR_CONFIG, true, "PPIMAGE recipe not found."); 937 955 psFree(options); 938 956 psFree(fpa); … … 1012 1030 pmDetrendSelectResults *results = pmDetrendSelect (options, config); 1013 1031 if (!results) { 1014 psError ( PS_ERR_IO, false, "no matching detrend data");1032 psError (psErrorCodeLast(), false, "no matching detrend data"); 1015 1033 return NULL; 1016 1034 } … … 1018 1036 file->fileLevel = pmFPALevelFromName(results->level); 1019 1037 if (file->fileLevel == PM_FPA_LEVEL_NONE) { 1020 psError (P S_ERR_IO, false, "invalid file level for selected detrend data");1038 psError (PM_ERR_CONFIG, false, "invalid file level for selected detrend data"); 1021 1039 return NULL; 1022 1040 } … … 1043 1061 pmFPAfile *file = pmFPAfileDefineOutput (config, fpa, filename); 1044 1062 if (!file) { 1045 psError( PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1063 psError(psErrorCodeLast(), false, "file %s not defined\n", filename); 1046 1064 return NULL; 1047 1065 } … … 1062 1080 pmFPAfile *file = pmFPAfileDefineOutputForFormat(config, NULL, filename, src->cameraName, src->formatName); 1063 1081 if (!file) { 1064 psError( PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1082 psError(psErrorCodeLast(), false, "file %s not defined\n", filename); 1065 1083 return NULL; 1066 1084 } … … 1084 1102 pmFPAfile *file = pmFPAfileDefineOutput (config, NULL, filename); 1085 1103 if (!file) { 1086 psError( PS_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1104 psError(psErrorCodeLast(), false, "file %s not defined\n", filename); 1087 1105 return NULL; 1088 1106 } 1089 1107 if (!file->camera) { 1090 psError(P S_ERR_UNEXPECTED_NULL, false, "file %s does not define a new camera\n", filename);1108 psError(PM_ERR_CONFIG, false, "file %s does not define a new camera\n", filename); 1091 1109 return NULL; 1092 1110 } … … 1127 1145 } 1128 1146 if (!file) { 1129 psError(P S_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1147 psError(PM_ERR_CONFIG, true, "file %s not defined\n", filename); 1130 1148 return NULL; 1131 1149 } … … 1170 1188 } 1171 1189 if (!file) { 1172 psError(P S_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1190 psError(PM_ERR_CONFIG, true, "file %s not defined\n", filename); 1173 1191 return NULL; 1174 1192 } … … 1177 1195 if (src) { 1178 1196 if (!pmConceptsCopyFPA(file->fpa, src, true, false)) { 1179 psError( PS_ERR_UNKNOWN, false, "Unable to copy concepts from source to new FPA");1197 psError(psErrorCodeLast(), false, "Unable to copy concepts from source to new FPA"); 1180 1198 return NULL; 1181 1199 } … … 1221 1239 } 1222 1240 if (!file) { 1223 psError(P S_ERR_UNEXPECTED_NULL, false, "file %s not defined\n", filename);1241 psError(PM_ERR_CONFIG, true, "file %s not defined\n", filename); 1224 1242 return NULL; 1225 1243 } … … 1228 1246 if (src) { 1229 1247 if (!pmConceptsCopyFPA(file->fpa, src, false, false)) { 1230 psError( PS_ERR_UNKNOWN, false, "Unable to copy concepts from source to new FPA");1248 psError(psErrorCodeLast(), false, "Unable to copy concepts from source to new FPA"); 1231 1249 return NULL; 1232 1250 } … … 1253 1271 file->name = psStringCopy (name); 1254 1272 1273 // free a previously existing readout 1274 psFree(file->readout); 1255 1275 file->readout = readout; 1256 psMetadataAddPtr(files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN, "", file); 1276 1277 // allow for multiple entries 1278 // XXX handle replace vs multiple? 1279 psMetadataAddPtr(files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, "", file); 1257 1280 psFree(file); 1258 1281 // we free this copy of file, but 'files' still has a copy … … 1274 1297 } 1275 1298 if (file == NULL) { 1276 psError(P S_ERR_IO, true, "file %s is NULL", name);1299 psError(PM_ERR_CONFIG, true, "file %s is NULL", name); 1277 1300 return false; 1278 1301 } … … 1295 1318 const char *name, // name of internal/external file 1296 1319 const pmFPA *fpa, // use this fpa to generate 1297 const psImageBinning *binning) { 1320 const psImageBinning *binning, 1321 int index) { 1298 1322 pmReadout *readout = NULL; 1299 1323 1300 bool status = true; 1301 pmFPAfile *file = psMetadataLookupPtr(&status, config->files, name); 1324 pmFPAfile *file = pmFPAfileSelectSingle(config->files, name, index); 1302 1325 1303 1326 // if the file does not exist, it is not being used as an I/O file: define an internal version 1304 1327 if (file == NULL) { 1305 readout = pmFPAfileDefineInternal (config->files, name, binning->nXruff, binning->nYruff, PS_TYPE_F32); 1306 return readout; 1328 // XXX currently, we do not guarantee that the defined file lands on entry 'index' 1329 psAssert (binning, "internal files must be supplied a psImageBinning for the output images size"); 1330 readout = pmFPAfileDefineInternal (config->files, name, binning->nXruff, binning->nYruff, PS_TYPE_F32); 1331 return readout; 1307 1332 } 1308 1333
Note:
See TracChangeset
for help on using the changeset viewer.
