Changeset 30447
- Timestamp:
- Jan 31, 2011, 2:52:18 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20101205
- Files:
-
- 10 edited
-
Nebulous/bin/neb-cull (modified) (5 diffs)
-
PS-IPP-Config/lib/PS/IPP/Config.pm (modified) (1 diff)
-
magic/remove/src/streaksVersion.c (modified) (1 diff)
-
magic/remove/src/streakscompare.c (modified) (1 diff)
-
magic/remove/src/streaksio.c (modified) (19 diffs)
-
magic/remove/src/streaksio.h (modified) (3 diffs)
-
magic/remove/src/streaksrelease.c (modified) (1 diff)
-
magic/remove/src/streaksremove.c (modified) (9 diffs)
-
magic/remove/src/streaksremove.h (modified) (1 diff)
-
magic/remove/src/streaksreplace.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101205/Nebulous/bin/neb-cull
r25121 r30447 17 17 18 18 my ($min_copies, $server, $volume, $one_only); 19 19 my ($soft_volume); 20 20 $server = $ENV{'NEB_SERVER'} unless $server; 21 21 … … 25 25 'volume|v=s' => \$volume, 26 26 'one_only|o' => \$one_only, 27 'soft_volume' => \$soft_volume, 27 28 ) || pod2usage( 2 ); 28 29 … … 42 43 unless defined $neb; 43 44 45 if ($volume) { 46 unless (($soft_volume)) { 47 $volume = '~' . $volume; 48 } 49 } 50 44 51 $volume ||= "any"; 45 52 $min_copies ||= 2; … … 48 55 push @cull_args, $key; 49 56 push @cull_args, $volume; 57 58 # print "$key $volume\n"; 59 # print "@cull_args\n"; 60 50 61 51 62 if ($one_only) { … … 95 106 96 107 Symbolic name of the volume to create the new instance on. 108 109 Optional. 110 111 =item * --soft_volume 112 113 Treat the specified volume name as soft, and allow an instance to be culled 114 from another volume if the specified volume does not have an instance. 97 115 98 116 Optional. -
branches/eam_branches/ipp-20101205/PS-IPP-Config/lib/PS/IPP/Config.pm
r30103 r30447 1048 1048 } 1049 1049 1050 sub magic_filename 1051 { 1052 my $file = shift; 1053 my $prefix = shift; 1054 my $dirname = dirname($file); 1055 my $base = basename($file); 1056 1057 return "$dirname/$prefix$base"; 1058 } 1059 1060 sub destreaked_filename 1061 { 1062 my $self = shift; 1063 my $file = shift; 1064 1065 return magic_filename($file, "SR_"); 1066 } 1067 sub recovery_filename 1068 { 1069 my $self = shift; 1070 my $file = shift; 1071 1072 return magic_filename($file, "REC_"); 1073 } 1074 1050 1075 # Return an EXTNAME From the EXTNAME.RULE table in the camera configuration 1051 1076 sub extname_rule -
branches/eam_branches/ipp-20101205/magic/remove/src/streaksVersion.c
r28043 r30447 58 58 psString source = streaksSource(); // Software source 59 59 60 psMetadataAddStr(header, PS_LIST_TAIL, "STREAK_V", 0, NULL, source);60 psMetadataAddStr(header, PS_LIST_TAIL, "STREAK_V", PS_META_REPLACE, NULL, source); 61 61 62 62 psStringPrepend(&version, "%s version: ", streaksProgram); -
branches/eam_branches/ipp-20101205/magic/remove/src/streakscompare.c
r26477 r30447 18 18 ippStage stage = psMetadataLookupS32(&status, config->arguments, "STAGE"); 19 19 20 sFile *file1 = sFileOpen(config, stage, "INPUT1", NULL, true );21 sFile *file2 = sFileOpen(config, stage, "INPUT2", NULL, true );20 sFile *file1 = sFileOpen(config, stage, "INPUT1", NULL, true, false); 21 sFile *file2 = sFileOpen(config, stage, "INPUT2", NULL, true, false); 22 22 23 23 int ncomponents; -
branches/eam_branches/ipp-20101205/magic/remove/src/streaksio.c
r29392 r30447 42 42 sf->class_id = psMetadataLookupStr(&status, config->arguments, "CLASS_ID"); 43 43 44 sf->inImage = sFileOpen(config, stage, "INPUT", NULL, true );44 sf->inImage = sFileOpen(config, stage, "INPUT", NULL, true, false); 45 45 sf->nHDU = sf->inImage->nHDU; 46 46 … … 48 48 // The names of the temporary and recovery files are taken from the input 49 49 char *inputBasename = basename(sf->inImage->name); 50 sf->outImage = sFileOpen(config, stage, "OUTPUT", inputBasename, true );50 sf->outImage = sFileOpen(config, stage, "OUTPUT", inputBasename, true, true); 51 51 52 52 if (remove) { 53 53 // XXX: the recovery file should be required if stage is raw and the replace flag is set 54 54 // that is if the input raw image is to be destroyed 55 sf->recImage = sFileOpen(config, stage, "RECOVERY", inputBasename, false );56 } else { 57 sf->recImage = sFileOpen(config, stage, "RECOVERY.IMAGE", NULL, true );58 } 59 60 sf->inMask = sFileOpen(config, stage, "INPUT.MASK", NULL, false );55 sf->recImage = sFileOpen(config, stage, "RECOVERY", inputBasename, false, false); 56 } else { 57 sf->recImage = sFileOpen(config, stage, "RECOVERY.IMAGE", NULL, true, false); 58 } 59 60 sf->inMask = sFileOpen(config, stage, "INPUT.MASK", NULL, false, false); 61 61 if (sf->inMask && (sf->stage != IPP_STAGE_RAW)) { 62 62 inputBasename = basename(sf->inMask->name); 63 sf->outMask = sFileOpen(config, stage, "OUTPUT", inputBasename, true );63 sf->outMask = sFileOpen(config, stage, "OUTPUT", inputBasename, true, true); 64 64 if (remove) { 65 sf->recMask = sFileOpen(config, stage, "RECOVERY", inputBasename, false );65 sf->recMask = sFileOpen(config, stage, "RECOVERY", inputBasename, false, false); 66 66 } else { 67 sf->recMask = sFileOpen(config, stage, "RECOVERY.MASK", NULL, true );67 sf->recMask = sFileOpen(config, stage, "RECOVERY.MASK", NULL, true, false); 68 68 } 69 69 } … … 73 73 // If it doesn't exist, we didn't have a camera mask 74 74 if (remove && sf->inMask && (stage == IPP_STAGE_CHIP)) { 75 sf->inChMask = sFileOpen(config, stage, "INPUT.CHMASK", NULL, false );75 sf->inChMask = sFileOpen(config, stage, "INPUT.CHMASK", NULL, false, false); 76 76 if (sf->inChMask) { 77 77 inputBasename = basename(sf->inChMask->name); 78 sf->outChMask = sFileOpen(config, stage, "OUTPUT", inputBasename, true );79 sf->recChMask = sFileOpen(config, stage, "RECOVERY", inputBasename, false );80 } 81 } 82 83 sf->inWeight = sFileOpen(config, stage, "INPUT.WEIGHT", NULL, false );78 sf->outChMask = sFileOpen(config, stage, "OUTPUT", inputBasename, true, true); 79 sf->recChMask = sFileOpen(config, stage, "RECOVERY", inputBasename, false, false); 80 } 81 } 82 83 sf->inWeight = sFileOpen(config, stage, "INPUT.WEIGHT", NULL, false, false); 84 84 if (sf->inWeight) { 85 85 inputBasename = basename(sf->inWeight->name); 86 sf->outWeight = sFileOpen(config, stage, "OUTPUT", inputBasename, true );86 sf->outWeight = sFileOpen(config, stage, "OUTPUT", inputBasename, true, true); 87 87 if (remove) { 88 sf->recWeight = sFileOpen(config, stage, "RECOVERY", inputBasename, false );88 sf->recWeight = sFileOpen(config, stage, "RECOVERY", inputBasename, false, false); 89 89 } else { 90 sf->recWeight = sFileOpen(config, stage, "RECOVERY.WEIGHT", NULL, true );90 sf->recWeight = sFileOpen(config, stage, "RECOVERY.WEIGHT", NULL, true, false); 91 91 } 92 92 } 93 93 if (remove) { 94 sf->inSources = sFileOpen(config, stage, "SOURCES", NULL, false );94 sf->inSources = sFileOpen(config, stage, "SOURCES", NULL, false, false); 95 95 if (sf->inSources) { 96 96 inputBasename = basename(sf->inSources->name); 97 sf->outSources = sFileOpen(config, stage, "OUTPUT", inputBasename, true );97 sf->outSources = sFileOpen(config, stage, "OUTPUT", inputBasename, true, true); 98 98 } 99 99 } … … 121 121 sf->transparentStreaks = psMetadataLookupF64(&status, config->arguments, "TRANSPARENT_STREAKS"); 122 122 123 sf->stats = psMetadataAlloc();124 psString statsFileName= psMetadataLookupStr(&status, config->arguments, "STATS");125 if (statsFileName) {126 sf->statsFile = fopen(statsFileName, "w");127 if (!sf->statsFile) {128 psError(PS_ERR_IO, true, "failed to open stats file %s", statsFileName);129 streaksExit("", PS_EXIT_CONFIG_ERROR);130 }131 }132 133 123 return sf; 134 124 } … … 138 128 { 139 129 freeImages(sf); 130 psFree(sf->stats); 140 131 psFree(sf->diffedPixels); 141 132 psFree(sf->tiles); … … 221 212 222 213 static psString 223 resolveFilename(pmConfig *config, sFile *sfile, bool create )214 resolveFilename(pmConfig *config, sFile *sfile, bool create, bool checkIfDestreaked) 224 215 { 225 216 sfile->inNebulous = IN_NEBULOUS(sfile->name); … … 232 223 // instance. It will get created below in pmConfigConvertFilename 233 224 if ((sfile->resolved_name = nebFind(server, sfile->name)) != NULL) { 234 if ( !nebFileIsDestreaked(sfile)) {225 if (checkIfDestreaked && !nebFileIsDestreaked(sfile)) { 235 226 psError(PS_ERR_IO, false, "attempting to delete file that has not been destreaked %s", sfile->name); 236 227 return NULL; … … 247 238 248 239 sFile *sFileOpen(pmConfig *config, ippStage stage, psString fileSelect, 249 psString outputFilename, bool required )240 psString outputFilename, bool required, bool checkIfDestreaked) 250 241 { 251 242 bool status; … … 322 313 // and the file is to be opened for writing 323 314 if (outputFilename) { 315 sfile->write = true; 324 316 psStringAppend(&sfile->name, "%s%s", name, outputFilename); 325 sfile->resolved_name = resolveFilename(config, sfile, true );317 sfile->resolved_name = resolveFilename(config, sfile, true, checkIfDestreaked); 326 318 if (!sfile->resolved_name) { 327 319 psError(PS_ERR_IO, false, "Failed to resolve filename for %s", sfile->name); … … 335 327 } else { 336 328 sfile->name = psStringCopy(name); 337 sfile->resolved_name = resolveFilename(config, sfile, false );329 sfile->resolved_name = resolveFilename(config, sfile, false, false); 338 330 if (!sfile->resolved_name) { 339 331 psError(PS_ERR_IO, false, "Failed to resolve name for %s", sfile->name); … … 402 394 403 395 void 404 addDestreakKeyword(psMetadata *header )396 addDestreakKeyword(psMetadata *header, bool value) 405 397 { 406 398 psMetadataAddBool(header, PS_LIST_TAIL, "PSDESTRK", PS_META_REPLACE, 407 "Have streaks been removed from image?", true);399 "Have streaks been removed from image?", value); 408 400 } 409 401 … … 416 408 417 409 void 418 copyPHU(streakFiles *sfiles, bool remove )410 copyPHU(streakFiles *sfiles, bool remove, bool destreak) 419 411 { 420 412 psAssert(sfiles->stage == IPP_STAGE_RAW, "copyPHU should only be used for raw stage"); … … 433 425 434 426 // add keyword indicating that streaks have been removed 435 addDestreakKeyword(imageHeader );427 addDestreakKeyword(imageHeader, destreak); 436 428 437 429 if (!psFitsWriteBlank(sfiles->outImage->fits, imageHeader, NULL)) { … … 463 455 } 464 456 // add keyword indicating that streaks have been removed 465 addDestreakKeyword(maskHeader );457 addDestreakKeyword(maskHeader, destreak); 466 458 if (!psFitsWriteBlank(sfiles->outMask->fits, maskHeader, NULL)) { 467 459 psError(PS_ERR_IO, false, "failed to write primary header to %s", … … 493 485 494 486 // add keyword indicating that streaks have been removed 495 addDestreakKeyword(weightHeader );487 addDestreakKeyword(weightHeader, destreak); 496 488 if (!psFitsWriteBlank(sfiles->outWeight->fits, weightHeader, NULL)) { 497 489 psError(PS_ERR_IO, false, "failed to write primary header to %s", … … 683 675 psVector *tiles) 684 676 { 685 if (!sfile ) {677 if (!sfile || !sfile->write) { 686 678 return; 687 679 } … … 861 853 streaksExit("", PS_EXIT_DATA_ERROR); 862 854 } 855 sfile->fits = NULL; 863 856 psFree(sfile->header); 864 857 sfile->header = NULL; … … 1198 1191 weight->data.F32[y][x] = NAN; 1199 1192 } 1193 } else if (weightType == PS_TYPE_F64) { 1194 double weightVal = weight->data.F64[y][x]; 1195 if (!isnan(weightVal)) { 1196 ++nandWeights; 1197 weight->data.F64[y][x] = NAN; 1198 } 1200 1199 } else if(weightType == PS_TYPE_S16) { 1201 1200 double weightVal = weight->data.S16[y][x]; … … 1249 1248 psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 32767); 1250 1249 } else if (in->image->type.type == PS_TYPE_F32) { 1250 in->exciseValue = NAN; 1251 } else if (in->image->type.type == PS_TYPE_F64) { 1251 1252 in->exciseValue = NAN; 1252 1253 } else { -
branches/eam_branches/ipp-20101205/magic/remove/src/streaksio.h
r26408 r30447 5 5 6 6 sFile *sFileOpen(pmConfig *config, ippStage stage, psString fileSelect, 7 psString outputFilename, bool required );7 psString outputFilename, bool required, bool checkIfDestreaked); 8 8 9 9 void closeImages(streakFiles *sfiles); … … 12 12 13 13 void readImage(sFile *sfile, int extnum, ippStage stage, bool isMask); 14 void copyPHU(streakFiles *sfiles, bool remove );14 void copyPHU(streakFiles *sfiles, bool remove, bool destreaked); 15 15 void copyTable(sFile *out, sFile *in, int extnum); 16 16 void copyFitsOptions(sFile *out, sFile *rec, sFile *in, psVector *tiles); … … 24 24 void readImageFrom_pmFile(streakFiles *sf); 25 25 26 void addDestreakKeyword(psMetadata * );26 void addDestreakKeyword(psMetadata *, bool value); 27 27 void addRecoveryKeyword(psMetadata *); 28 28 -
branches/eam_branches/ipp-20101205/magic/remove/src/streaksrelease.c
r27468 r30447 24 24 if (sfiles->stage == IPP_STAGE_RAW) { 25 25 // copy PHU to output files 26 copyPHU(sfiles, true);26 copyPHU(sfiles, false, true); 27 27 28 28 // advance to the first image extension -
branches/eam_branches/ipp-20101205/magic/remove/src/streaksremove.c
r29806 r30447 93 93 // Raw files have a phu and multiple extensions, one per chip 94 94 // Since this is a raw file, copy it's PHU to output files 95 copyPHU(sfiles, true );95 copyPHU(sfiles, true, true); 96 96 97 97 // advance to the first image extension … … 275 275 psLogMsg("streaksremove", PS_LOG_INFO, "time to run streaksremove: %f\n", total_time); 276 276 277 if (sfiles->statsFile) { 278 const char *statsMDC = psMetadataConfigFormat(sfiles->stats); 279 if (!statsMDC || strlen(statsMDC) == 0) { 280 psError(PS_ERR_IO, false, "Unable to get statistics MDC file.\n"); 281 } else { 282 fprintf(sfiles->statsFile, "%s", statsMDC); 283 psFree(statsMDC); 284 fclose(sfiles->statsFile); 285 sfiles->statsFile = NULL; 286 psFree(sfiles->stats); 287 sfiles->stats = NULL; 288 } 289 } 277 psString statsFileName= psMetadataLookupStr(&status, config->arguments, "STATS"); 278 279 if (statsFileName) { 280 // Write out 281 psString resolved = pmConfigConvertFilename(statsFileName, config, true, true); // Resolved filename 282 if (!resolved) { 283 psError(psErrorCodeLast(), false, "Unable to resolve statistics file name"); 284 return false; 285 } 286 if (!psMetadataConfigWrite(sfiles->stats, resolved, NULL)) { 287 psError(psErrorCodeLast(), false, "Unable to serialize stats metadata.\n"); 288 psFree(resolved); 289 return false; 290 } 291 psFree(resolved); 292 } 293 290 294 // all done. Clean up to look for memory leaks. 291 295 … … 613 617 addRecoveryKeyword(sf->recImage->header); 614 618 } 615 addDestreakKeyword(sf->outImage->header );619 addDestreakKeyword(sf->outImage->header, true); 616 620 617 621 if (!SFILE_IS_IMAGE(sf->inImage)) { … … 639 643 addRecoveryKeyword(sf->recMask->header); 640 644 } 641 addDestreakKeyword(sf->outMask->header );645 addDestreakKeyword(sf->outMask->header, true); 642 646 // Note: we don't excise the mask pixels even if exciseAll is true. 643 647 setupImageRefs(sf->outMask, sf->recMask, sf->inMask, sf->extnum, false); … … 671 675 addRecoveryKeyword(sf->recWeight->header); 672 676 } 673 addDestreakKeyword(sf->outWeight->header );677 addDestreakKeyword(sf->outWeight->header, true); 674 678 setupImageRefs(sf->outWeight, sf->recWeight, sf->inWeight, sf->extnum, exciseAll); 675 679 … … 767 771 } 768 772 } 769 } else {773 } else if (sfiles->inImage->image->type.type == PS_TYPE_F32) { 770 774 float imageValue = sfiles->inImage->image->data.F32[y][x]; 771 775 if (sfiles->recImage && !isExciseValue(imageValue, sfiles->inImage->exciseValue) ) { … … 783 787 } 784 788 } 789 } else { 790 // We could handle F64 but I don't think we ever get them. 791 // Should catch this earlier 792 psError(PS_ERR_IO, true, "unexpected image type %x found", sfiles->inImage->image->type.type ); 793 streaksExit("", PS_EXIT_PROG_ERROR); 785 794 } 786 795 787 796 if (sfiles->outWeight) { 788 if (sfiles->recWeight) {789 sfiles->recWeight->image->data.F32[y][x] = sfiles->inWeight->image->data.F32[y][x];790 }791 797 // Assume that weight images are always a floating point type 792 sfiles->outWeight->image->data.F32[y][x] = NAN; 798 if (sfiles->inWeight->image->type.type == PS_TYPE_F32) { 799 if (sfiles->recWeight) { 800 sfiles->recWeight->image->data.F32[y][x] = sfiles->inWeight->image->data.F32[y][x]; 801 } 802 sfiles->outWeight->image->data.F32[y][x] = NAN; 803 } else if (sfiles->inWeight->image->type.type == PS_TYPE_F64) { 804 if (sfiles->recWeight) { 805 sfiles->recWeight->image->data.F64[y][x] = sfiles->inWeight->image->data.F64[y][x]; 806 } 807 sfiles->outWeight->image->data.F64[y][x] = NAN; 808 } else { 809 // Should catch this earlier 810 psError(PS_ERR_IO, true, "unexpected weight image type %x found", sfiles->inWeight->image->type.type ); 811 streaksExit("", PS_EXIT_PROG_ERROR); 812 } 793 813 } 794 814 if (sfiles->outMask) { … … 912 932 streaksExit("", PS_EXIT_DATA_ERROR); 913 933 } 914 addDestreakKeyword(header );934 addDestreakKeyword(header, true); 915 935 916 936 if (!psFitsWriteBlank(out->fits, header, extname)) { … … 973 993 psArrayRealloc(outTable, j); 974 994 975 addDestreakKeyword(header );995 addDestreakKeyword(header, true); 976 996 if (psArrayLength(outTable) > 0) { 977 997 printf("Censored %d sources\n", numCensored); -
branches/eam_branches/ipp-20101205/magic/remove/src/streaksremove.h
r27752 r30447 18 18 psString name; 19 19 bool inNebulous; 20 bool write; 20 21 psFits *fits; 21 22 int nHDU; -
branches/eam_branches/ipp-20101205/magic/remove/src/streaksreplace.c
r26477 r30447 36 36 if (sfiles->stage == IPP_STAGE_RAW) { 37 37 // copy PHU to output files 38 copyPHU(sfiles, false );38 copyPHU(sfiles, false, false); 39 39 40 40 // advance to the first image extension … … 296 296 297 297 sf->outImage->header = (psMetadata*) psMemIncrRefCounter(sf->inImage->header); 298 addDestreakKeyword(sf->outImage->header, false); 298 299 299 300 if (!SFILE_IS_IMAGE(sf->inImage)) { … … 317 318 readImage(sf->recMask, sf->extnum, sf->stage, true); 318 319 sf->outMask->header = (psMetadata*) psMemIncrRefCounter(sf->inMask->header); 320 321 addDestreakKeyword(sf->outMask->header, false); 319 322 320 323 // XXX: TODO … … 329 332 330 333 sf->outWeight->header = (psMetadata*) psMemIncrRefCounter(sf->inWeight->header); 334 addDestreakKeyword(sf->outWeight->header, false); 331 335 setupImageRefs(sf->outMask, NULL, sf->inMask, sf->extnum, false); 332 336
Note:
See TracChangeset
for help on using the changeset viewer.
