Changeset 34800
- Timestamp:
- Dec 11, 2012, 2:04:31 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 94 edited
- 6 copied
-
. (modified) (1 prop)
-
Nebulous-Server/bin/neb-voladm (modified) (1 diff)
-
Ohana (modified) (1 prop)
-
Ohana/src/libohana/src (modified) (1 prop)
-
Ohana/src/opihi (modified) (1 prop)
-
Ohana/src/opihi/cmd.astro (modified) (1 prop)
-
Ohana/src/opihi/cmd.data (modified) (1 prop)
-
extsrc/gpcsw/gpcsrc/Make.Common (modified) (1 diff)
-
ippMonitor (modified) (1 prop)
-
ippScripts/Build.PL (modified) (1 diff)
-
ippScripts/MANIFEST (modified) (1 diff)
-
ippScripts/scripts/destreak_restore_camera.pl (modified) (1 prop)
-
ippScripts/scripts/detrend_process_imfile.pl (modified) (2 diffs)
-
ippScripts/scripts/ipp_apply_burntool_single.pl (modified) (1 prop)
-
ippScripts/scripts/magic_destreak.pl (modified) (1 prop)
-
ippScripts/scripts/regenerate_background.pl (copied) (copied from branches/czw_branch/20120906/ippScripts/scripts/regenerate_background.pl )
-
ippScripts/scripts/skycell_jpeg.pl (modified) (2 diffs)
-
ippScripts/scripts/stack_skycell.pl (modified) (2 diffs)
-
ippScripts/scripts/warp_skycell.pl (modified) (7 diffs)
-
ippTasks (modified) (1 prop)
-
ippTasks/Makefile.am (modified) (1 diff)
-
ippTasks/bg.regeneration.pro (copied) (copied from branches/czw_branch/20120906/ippTasks/bg.regeneration.pro )
-
ippToPsps (modified) (1 prop)
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/camtool_find_pendingimfile.sql (modified) (1 prop)
-
ippTools/share/chiptool_setimfiletoupdate.sql (modified) (1 prop)
-
ippTools/share/pxadmin_create_tables.sql (modified) (1 prop)
-
ippTools/share/stacktool_inputskyfile.sql (modified) (1 diff)
-
ippTools/share/stacktool_tobkg.sql (copied) (copied from branches/czw_branch/20120906/ippTools/share/stacktool_tobkg.sql )
-
ippTools/share/warptool_towarped.sql (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/magictool.c (modified) (1 prop)
-
ippTools/src/stacktool.c (modified) (4 diffs)
-
ippTools/src/stacktool.h (modified) (1 diff)
-
ippTools/src/stacktoolConfig.c (modified) (3 diffs)
-
ippTools/src/warptool.c (modified) (3 diffs)
-
ippTools/src/warptoolConfig.c (modified) (1 diff)
-
ippconfig (modified) (1 prop)
-
ippconfig/gpc1/pswarp.config (modified) (1 diff)
-
ippconfig/recipes/filerules-mef.mdc (modified) (5 diffs)
-
ippconfig/recipes/filerules-simple.mdc (modified) (5 diffs)
-
ippconfig/recipes/filerules-split.mdc (modified) (5 diffs)
-
ippconfig/recipes/nightly_science.config (modified) (4 diffs)
-
ippconfig/recipes/ppBackground.mdc (modified) (1 diff)
-
ippconfig/recipes/ppStack.config (modified) (1 diff)
-
ippconfig/recipes/ppSub.config (modified) (1 prop)
-
ippconfig/recipes/pswarp.config (modified) (1 diff)
-
ippconfig/recipes/reductionClasses.mdc (modified) (1 prop)
-
ppBackground/src/ppBackground.h (modified) (1 diff)
-
ppBackground/src/ppBackgroundRestore.c (modified) (3 diffs)
-
ppImage/src (modified) (1 prop)
-
ppSkycell/src/ppSkycellCamera.c (modified) (1 diff)
-
ppSkycell/src/ppSkycellLoop.c (modified) (12 diffs)
-
ppStack/src/Makefile.am (modified) (3 diffs)
-
ppStack/src/ppStack.h (modified) (2 diffs)
-
ppStack/src/ppStackArguments.c (modified) (1 diff)
-
ppStack/src/ppStackCamera.c (modified) (4 diffs)
-
ppStack/src/ppStackCleanup.c (modified) (3 diffs)
-
ppStack/src/ppStackCombineAlternate.c (copied) (copied from branches/czw_branch/20120906/ppStack/src/ppStackCombineAlternate.c )
-
ppStack/src/ppStackCombinePrepare.c (modified) (3 diffs)
-
ppStack/src/ppStackFiles.c (modified) (3 diffs)
-
ppStack/src/ppStackLoop.c (modified) (5 diffs)
-
ppStack/src/ppStackLoop.h (modified) (2 diffs)
-
ppStack/src/ppStackMedian.c (copied) (copied from branches/czw_branch/20120906/ppStack/src/ppStackMedian.c )
-
ppStack/src/ppStackMedianLoop.c (copied) (copied from branches/czw_branch/20120906/ppStack/src/ppStackMedianLoop.c )
-
ppStack/src/ppStackOptions.h (modified) (1 diff)
-
ppStack/src/ppStackPrepare.c (modified) (2 diffs)
-
ppStack/src/ppStackReadout.c (modified) (1 diff)
-
ppStack/src/ppStackSetup.c (modified) (2 diffs)
-
ppStack/src/ppStackThread.c (modified) (4 diffs)
-
ppStack/src/ppStackThread.h (modified) (1 diff)
-
ppStack/src/ppStackUpdateHeader.c (modified) (2 diffs)
-
ppViz/src/ppVizPSF/ppVizPSFCamera.c (modified) (2 diffs)
-
ppViz/src/ppVizPSF/ppVizPSFLoop.c (modified) (9 diffs)
-
psLib/src/imageops/psImageInterpolate.c (modified) (7 diffs)
-
psLib/src/imageops/psImageInterpolate.h (modified) (1 diff)
-
psLib/src/imageops/psImagePixelManip.c (modified) (3 diffs)
-
psModules (modified) (1 prop)
-
psModules/src/camera/pmFPABin.c (modified) (4 diffs)
-
psModules/src/camera/pmFPAfileIO.c (modified) (1 diff)
-
psModules/src/detrend/pmDark.c (modified) (3 diffs)
-
psModules/src/imcombine/pmStack.c (modified) (1 diff)
-
psModules/src/imcombine/pmStack.h (modified) (1 diff)
-
psModules/src/objects/Makefile.am (modified) (1 diff)
-
psModules/src/objects/pmFootprintCullPeaks.c (modified) (1 diff)
-
psphot (modified) (1 prop)
-
psphot/src (modified) (1 prop)
-
psphot/src/psphotStackImageLoop.c (modified) (1 prop)
-
pstamp/scripts (modified) (1 prop)
-
psvideophot (modified) (1 prop)
-
pswarp/src/pswarp.c (modified) (2 diffs)
-
pswarp/src/pswarp.h (modified) (2 diffs)
-
pswarp/src/pswarpArguments.c (modified) (4 diffs)
-
pswarp/src/pswarpDefine.c (modified) (3 diffs)
-
pswarp/src/pswarpFileNames.h (modified) (2 diffs)
-
pswarp/src/pswarpLoop.c (modified) (5 diffs)
-
pswarp/src/pswarpParseCamera.c (modified) (2 diffs)
-
pswarp/src/pswarpTransformReadout.c (modified) (6 diffs)
-
pswarp/src/pswarpTransformSources.c (modified) (1 diff)
-
pswarp/src/pswarpTransformTile.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
trunk/Nebulous-Server/bin/neb-voladm
r32615 r34800 68 68 if (defined $allocate and $allocate !~ m/^[01]$/) 69 69 or (defined $available and $available !~ m/^[01]$/) 70 or (defined $xattr and $xattr !~ m/^[012 ]$/);70 or (defined $xattr and $xattr !~ m/^[0123]$/); 71 71 } 72 72 -
trunk/Ohana
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/Ohana (added) merged: 34772,34786
- Property svn:mergeinfo changed
-
trunk/Ohana/src/libohana/src
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/Ohana/src/libohana/src (added) merged: 34772,34786 /trunk/Ohana/src/libohana/src (added) merged: 2-2412
- Property svn:mergeinfo changed
-
trunk/Ohana/src/opihi
-
Property svn:mergeinfo
set to
/branches/eam_branches/ipp-20120905/Ohana/src/opihi merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Ohana/src/opihi/cmd.astro
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/Ohana/src/opihi/cmd.astro (added) merged: 34772,34786
- Property svn:mergeinfo changed
-
trunk/Ohana/src/opihi/cmd.data
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/Ohana/src/opihi/cmd.data (added) merged: 34772,34786
- Property svn:mergeinfo changed
-
trunk/extsrc/gpcsw/gpcsrc/Make.Common
r31150 r34800 156 156 # compilation and -shared applies to the link stage. 157 157 # 158 FCDEBUG = -g -O -fno-automatic158 FCDEBUG = -g -O0 -fno-automatic 159 159 FFWARN = -Wall 160 160 FFLAGS = $(FCDEBUG) $(EXTRA_FFLAGS) $(FFWARN) $(CCDEFS) $(CCINCS) 161 CCDEBUG = -g -O 161 CCDEBUG = -g -O0 162 162 CCSHARE = -fPIC -shared 163 163 CCWARN = -Wall -Wstrict-prototypes # -Wshadow -
trunk/ippMonitor
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippMonitor (added) merged: 34772
- Property svn:mergeinfo changed
-
trunk/ippScripts/Build.PL
r33627 r34800 128 128 scripts/listvideocells.pl 129 129 scripts/skycalibration.pl 130 scripts/regenerate_background.pl 130 131 )], 131 132 dist_abstract => 'Scripts for running the Pan-STARRS IPP', -
trunk/ippScripts/MANIFEST
r31435 r34800 46 46 scripts/skycell_jpeg.pl 47 47 scripts/lap_science.pl 48 scripts/regenerate_background.pl 48 49 t/00_distribution.t -
trunk/ippScripts/scripts/destreak_restore_camera.pl
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippScripts/scripts/destreak_restore_camera.pl (added) merged: 34772
- Property svn:mergeinfo changed
-
trunk/ippScripts/scripts/detrend_process_imfile.pl
r33666 r34800 27 27 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 28 28 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 29 my $nebrepair = can_run('neb-repair') or (warn "Can't find neb-repair" and $missing_tools = 1); 30 29 31 if ($missing_tools) { 30 32 warn("Can't find required tools."); … … 124 126 # Run ppImage 125 127 unless ($no_op) { 128 my $repair_cmd = "$nebrepair $input_uri"; 129 my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose); 130 unless ($repair_success) { 131 &my_die("Unable to attempt repair: $input_uri $repair_error_code", $det_id, $exp_id, $class_id $PS_EXIT_SYS_ERROR); 132 } 133 134 126 135 my $command = "$ppImage -file $input_uri $outroot"; 127 136 $command .= " -recipe PPIMAGE $ppimage_recipe"; -
trunk/ippScripts/scripts/ipp_apply_burntool_single.pl
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippScripts/scripts/ipp_apply_burntool_single.pl merged: 34772,34786
- Property svn:mergeinfo changed
-
trunk/ippScripts/scripts/magic_destreak.pl
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippScripts/scripts/magic_destreak.pl (added) merged: 34772
- Property svn:mergeinfo changed
-
trunk/ippScripts/scripts/skycell_jpeg.pl
r28403 r34800 268 268 269 269 my %tangents = (); 270 271 my %products = ('image' => "PPSTACK.UNCONV", 272 'mask' => "PPSTACK.UNCONV.MASK", 273 'variance' => "PPSTACK.UNCONV.VARIANCE", 274 'exp' => "PPSTACK.UNCONV.EXP", 275 'num' => "PPSTACK.UNCONV.EXPNUM", 276 'bkg' => "PPSTACK.OUTPUT.BKGMODEL" 277 ); 270 278 271 279 foreach my $imfile (@$imfiles) { … … 281 289 282 290 $projection_cell =~ s/^(.*)\..*$/$1/; 283 291 284 292 unless (exists($tangents{$projection_cell})) { 285 293 # Make a temp file and fill, but be sure to save 286 ($tempFile, $tempName) = tempfile("/tmp/skycell.$projection_cell.XXXX", 287 UNLINK => !$save_temps); 288 $tangents{$projection_cell}{FILE} = $tempFile; 289 $tangents{$projection_cell}{NAME} = $tempName; 290 if ($masks) { 291 my ($maskFile, $maskName) = tempfile("/tmp/skycell.$projection_cell.masks.XXXX", 292 UNLINK => !$save_temps); 293 $tangents{$projection_cell}{MFILE} = $maskFile; 294 $tangents{$projection_cell}{MNAME} = $maskName; 295 } 296 } 297 print "$skycell_id $projection_cell\n"; 298 my $file = $ipprc->filename("PPSTACK.OUTPUT", $path_base, $skycell_id); 299 print "$file $state $quality\n"; 300 my $f_fh = $tangents{$projection_cell}{FILE}; 301 print $f_fh "$file\n"; 302 if ($masks) { 303 my $mask = $ipprc->filename("PPSTACK.OUTPUT.MASK", $path_base, $skycell_id); 304 print "$mask\n"; 305 my $m_fh = $tangents{$projection_cell}{MFILE}; 306 print $m_fh "$mask\n"; 294 foreach my $key (keys %products) { 295 ($tempFile, $tempName) = tempfile("/tmp/skycell.$projection_cell.$key.XXXX", 296 UNLINK => !$save_temps); 297 $tangents{$projection_cell}{$key}{FILE} = $tempFile; 298 $tangents{$projection_cell}{$key}{NAME} = $tempName; 299 } 300 } 301 foreach my $key (keys %products) { 302 print "$skycell_id $projection_cell\n"; 303 my $file = $ipprc->filename($products{$key}, $path_base, $skycell_id); 304 print "$file $state $quality\n"; 305 my $f_fh = $tangents{$projection_cell}{$key}{FILE}; 306 print $f_fh "$file\n"; 307 307 } 308 308 } 309 309 foreach my $projection_cell (keys %tangents) { 310 $command = "$ppSkycell -images $tangents{$projection_cell}{NAME}"; 311 if ($masks) { 312 $command .= " -masks $tangents{$projection_cell}{MNAME} "; 313 } 314 $command .= " ${outroot}.${projection_cell} "; 315 print "$command\n"; 316 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 317 unless ($success) { 318 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 319 &my_die("unable to perform ppSkycell: $error_code", $stage_id, $error_code); 320 } 310 ## Loop over results here. 311 # Images 312 # Masks 313 # Variances 314 # Nexptime 315 # Nexp 316 # Backgrounds 317 318 foreach my $key (keys %products) { 319 $command = "$ppSkycell -images $tangents{$projection_cell}{$key}{NAME}"; 320 $command .= " ${outroot}.${projection_cell}.${key} "; 321 if ($key eq 'bkg') { 322 $command .= " -Di BIN1 1 -Di BIN2 1 "; 323 } 324 elsif ($key eq 'image') { 325 $command .= " -masks $tangents{$projection_cell}{mask}{NAME} "; 326 } 327 elsif ($key eq 'mask') { 328 next; # This should be made with the images. 329 } 330 print "$command\n"; 331 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 332 unless ($success) { 333 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 334 &my_die("unable to perform ppSkycell: $error_code", $stage_id, $error_code); 335 } 336 } 337 321 338 # Update database: 322 339 $command = "$stacktool -addsummary -sass_id $stage_id -projection_cell $projection_cell -path_base $outroot"; -
trunk/ippScripts/scripts/stack_skycell.pl
r32562 r34800 229 229 my $sources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $file->{path_base}); # Sources name 230 230 231 my $bkgmodel = $ipprc->filename("PSWARP.OUTPUT.BKGMODEL", $file->{path_base}); 232 231 233 &my_die("Image $image does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $image ); 232 234 &my_die("Mask $mask does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $mask ); … … 240 242 print $listFile "\tPSF\tSTR\t" . $psf . "\n" if $convolve; 241 243 print $listFile "\tSOURCES\tSTR\t" . $sources . "\n"; 244 print $listFile "\tBKGMODEL\tSTR\t" . $bkgmodel . "\n" if $ipprc->file_exists( $bkgmodel ); 242 245 243 246 print $listFile "END\n\n"; -
trunk/ippScripts/scripts/warp_skycell.pl
r33053 r34800 128 128 # Where do we get the astrometry source from? 129 129 my $astromSource; # The astrometry source 130 my $doBackground; # Do we want to make background models? 130 131 { 131 132 my $command = "$ppConfigDump -camera $camera -recipe PSWARP $recipe_pswarp -dump-recipe PSWARP -"; … … 139 140 &my_die("Unable to parse metadata config doc", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR); 140 141 $astromSource = metadataLookupStr($metadata, 'ASTROM.SOURCE'); 142 $doBackground = metadataLookupBool($metadata, 'BACKGROUND.MODEL'); 141 143 } 142 144 … … 168 170 if ($do_stats) { 169 171 $outputStats = prepare_output ("SKYCELL.STATS", $outroot, $skycell_id, 1) if $do_stats; 172 } 173 my $outputBKGs; 174 if ($doBackground) { 175 $outputBKGs = prepare_output ("PSWARP.OUTPUT.BKGMODEL", $outroot, $skycell_id, 1); 170 176 } 171 177 my $configuration; … … 209 215 my ($weightFile, $weightName) = tempfile( "$tempOutRoot.weight.list.XXXX", UNLINK => !$save_temps); 210 216 my ($astromFile, $astromName) = tempfile( "$tempOutRoot.astrom.list.XXXX", UNLINK => !$save_temps); 211 217 my ($bkgFile, $bkgName); 218 if ($doBackground) { 219 ($bkgFile, $bkgName) = tempfile( "$tempOutRoot.bkg.list.XXXX", UNLINK => !$save_temps); 220 } 212 221 my $wrote_astrom = 0; 213 222 foreach my $imfile (@$imfiles) { … … 235 244 print $maskFile "$mask\n"; 236 245 print $weightFile "$weight\n"; 246 my $bkg; 247 if ($doBackground) { 248 $bkg = $ipprc->filename("PSPHOT.BACKMDL", $imfile->{chip_path_base}, $imfile->{class_id}); 249 print $bkgFile "$bkg\n"; 250 } 237 251 238 252 if (!$wrote_astrom) { … … 245 259 close $weightFile; 246 260 close $astromFile; 247 261 if ($doBackground) { 262 close($bkgFile); 263 } 248 264 # We need the recipe to determine if we care whether the PSF is generated or not 249 265 my $recipe; … … 269 285 $command .= " -variancelist $weightName"; 270 286 $command .= " -astromlist $astromName"; 287 $command .= " -bkglist $bkgName" if ($doBackground); 271 288 $command .= " $outroot $skyFile"; 272 289 $command .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE"; -
trunk/ippTasks
- Property svn:mergeinfo set to
-
trunk/ippTasks/Makefile.am
r33030 r34800 45 45 diffphot.pro \ 46 46 lap.pro \ 47 vp.pro 47 vp.pro \ 48 bg.regeneration.pro 48 49 49 50 other_files = \ -
trunk/ippToPsps
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippToPsps (added) merged: 34772,34786
- Property svn:mergeinfo changed
-
trunk/ippTools/share/Makefile.am
r34766 r34800 393 393 stacktool_sassskyfile.sql \ 394 394 stacktool_tosum.sql \ 395 stacktool_tobkg.sql \ 395 396 stacktool_tosummary.sql \ 396 397 stacktool_addsummary.sql \ -
trunk/ippTools/share/camtool_find_pendingimfile.sql
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippTools/share/camtool_find_pendingimfile.sql (added) merged: 34772
- Property svn:mergeinfo changed
-
trunk/ippTools/share/chiptool_setimfiletoupdate.sql
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippTools/share/chiptool_setimfiletoupdate.sql (added) merged: 34772
- Property svn:mergeinfo changed
-
trunk/ippTools/share/pxadmin_create_tables.sql
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippTools/share/pxadmin_create_tables.sql (added) merged: 34772
- Property svn:mergeinfo changed
-
trunk/ippTools/share/stacktool_inputskyfile.sql
r32937 r34800 4 4 rawExp.exp_id, 5 5 rawExp.exp_name, 6 rawExp.exp_time, 6 7 rawExp.object, 7 8 rawExp.dateobs, -
trunk/ippTools/share/warptool_towarped.sql
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippTools/share/warptool_towarped.sql (added) merged: 34772
- Property svn:mergeinfo changed
-
trunk/ippTools/src
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippTools/src (added) merged: 34772,34780,34786
- Property svn:mergeinfo changed
-
trunk/ippTools/src/magictool.c
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippTools/src/magictool.c (added) merged: 34772
- Property svn:mergeinfo changed
-
trunk/ippTools/src/stacktool.c
r34731 r34800 37 37 static bool inputskyfileMode(pxConfig *config); 38 38 static bool tosumMode(pxConfig *config); 39 static bool tobkgMode(pxConfig *config); 39 40 static bool addsumskyfileMode(pxConfig *config); 40 41 static bool sumskyfileMode(pxConfig *config); … … 76 77 MODECASE(STACKTOOL_MODE_INPUTSKYFILE, inputskyfileMode); 77 78 MODECASE(STACKTOOL_MODE_TOSUM, tosumMode); 79 MODECASE(STACKTOOL_MODE_TOBKG, tobkgMode); 78 80 MODECASE(STACKTOOL_MODE_ADDSUMSKYFILE, addsumskyfileMode); 79 81 MODECASE(STACKTOOL_MODE_SUMSKYFILE, sumskyfileMode); … … 952 954 // negative simple so the default is true 953 955 if (!ippdbPrintMetadatas(stdout, output, "stackSumSkyfile", !simple)) { 956 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 957 psFree(output); 958 return false; 959 } 960 } 961 962 psFree(output); 963 964 return true; 965 } 966 967 static bool tobkgMode(pxConfig *config) 968 { 969 PS_ASSERT_PTR_NON_NULL(config, false); 970 971 psMetadata *where = psMetadataAlloc(); 972 PXOPT_COPY_S64(config->args, where, "-stack_id", "stack_id", "=="); 973 pxAddLabelSearchArgs (config, where, "-label", "stackRun.label", "=="); 974 975 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 976 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 977 978 psString query = pxDataGet("stacktool_tobkg.sql"); 979 if (!query) { 980 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 981 return false; 982 } 983 984 psString whereClause = psStringCopy(""); // WHERE conditions to add 985 if (psListLength(where->list)) { 986 psString new = psDBGenerateWhereConditionSQL(where, NULL); 987 psStringAppend(&whereClause, "\nAND %s", new); 988 psFree(new); 989 } 990 psFree(where); 991 992 psStringAppend(&query, "\nORDER by priority DESC, stack_id"); 993 994 // treat limit == 0 as "no limit" 995 if (limit) { 996 psString limitString = psDBGenerateLimitSQL(limit); 997 psStringAppend(&query, " %s", limitString); 998 psFree(limitString); 999 } 1000 1001 if (!p_psDBRunQueryF(config->dbh, query, whereClause)) { 1002 psError(PS_ERR_UNKNOWN, false, "database error"); 1003 psFree(query); 1004 return false; 1005 } 1006 psFree(query); 1007 1008 psArray *output = p_psDBFetchResult(config->dbh); 1009 if (!output) { 1010 psErrorCode err = psErrorCodeLast(); 1011 switch (err) { 1012 case PS_ERR_DB_CLIENT: 1013 psError(PXTOOLS_ERR_SYS, false, "database error"); 1014 case PS_ERR_DB_SERVER: 1015 psError(PXTOOLS_ERR_PROG, false, "database error"); 1016 default: 1017 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1018 } 1019 1020 return false; 1021 } 1022 if (!psArrayLength(output)) { 1023 psTrace("stacktool", PS_LOG_INFO, "no rows found"); 1024 psFree(output); 1025 return true; 1026 } 1027 1028 if (psArrayLength(output)) { 1029 // negative simple so the default is true 1030 if (!ippdbPrintMetadatas(stdout, output, "stackBkgSkyfile", !simple)) { 954 1031 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 955 1032 psFree(output); … … 1681 1758 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 1682 1759 PXOPT_LOOKUP_S16(quality, config->args, "-set_quality", false, false); 1760 PXOPT_LOOKUP_S16(background_model, config->args, "-set_background_model", false, false); 1683 1761 1684 1762 psMetadata *where = psMetadataAlloc(); 1685 1763 PXOPT_COPY_S64(config->args, where, "-stack_id", "stack_id", "=="); 1686 1764 1687 if (!pxSetFaultCode(config->dbh, "stackSumSkyfile", where, fault, quality)) { 1765 if (background_model) { 1766 psMetadata *values = psMetadataAlloc(); 1767 PXOPT_COPY_S16(config->args, values, "-set_background_model", "background_model", "=="); 1768 long rows = psDBUpdateRows(config->dbh,"stackSumSkyfile", where, values); 1769 psFree(values); 1770 if (!rows) { 1771 // This maybe should rollback and error if rows != 1 1772 psError(PS_ERR_UNKNOWN, true, "no rows changed"); 1773 return false; 1774 } 1775 } 1776 else { 1777 if (!pxSetFaultCode(config->dbh, "stackSumSkyfile", where, fault, quality)) { 1688 1778 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 1689 1779 psFree (where); 1690 1780 return false; 1781 } 1691 1782 } 1692 1783 psFree (where); -
trunk/ippTools/src/stacktool.h
r28375 r34800 31 31 STACKTOOL_MODE_INPUTSKYFILE, 32 32 STACKTOOL_MODE_TOSUM, 33 STACKTOOL_MODE_TOBKG, 33 34 STACKTOOL_MODE_ADDSUMSKYFILE, 34 35 STACKTOOL_MODE_SUMSKYFILE, -
trunk/ippTools/src/stacktoolConfig.c
r34731 r34800 150 150 psMetadataAddBool(tosumArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 151 151 152 // -tobkg 153 psMetadata *tobkgArgs = psMetadataAlloc(); 154 psMetadataAddS64(tobkgArgs, PS_LIST_TAIL, "-stack_id", 0, "search by stack ID", 0); 155 psMetadataAddStr(tobkgArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by label", NULL); 156 psMetadataAddU64(tobkgArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 157 psMetadataAddBool(tobkgArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 158 152 159 // -addsumskyfile 153 160 psMetadata *addsumskyfileArgs = psMetadataAlloc(); … … 280 287 psMetadataAddS16(updatesumskyfileArgs, PS_LIST_TAIL, "-fault", 0, "set fault code (required)", 0); 281 288 psMetadataAddS16(updatesumskyfileArgs, PS_LIST_TAIL, "-set_quality", 0, "set quality", 0); 282 289 psMetadataAddS16(updatesumskyfileArgs, PS_LIST_TAIL, "-set_background_model", 0, "set background model", 0); 290 283 291 // -exportrun 284 292 psMetadata *exportrunArgs = psMetadataAlloc(); … … 304 312 PXOPT_ADD_MODE("-inputskyfile", "", STACKTOOL_MODE_INPUTSKYFILE, inputskyfileArgs); 305 313 PXOPT_ADD_MODE("-tosum", "", STACKTOOL_MODE_TOSUM, tosumArgs); 314 PXOPT_ADD_MODE("-tobkg", "", STACKTOOL_MODE_TOBKG, tobkgArgs); 306 315 PXOPT_ADD_MODE("-addsumskyfile", "", STACKTOOL_MODE_ADDSUMSKYFILE, addsumskyfileArgs); 307 316 PXOPT_ADD_MODE("-sumskyfile", "list results of stackRun", STACKTOOL_MODE_SUMSKYFILE, sumskyfileArgs); -
trunk/ippTools/src/warptool.c
r34766 r34800 2059 2059 PXOPT_LOOKUP_S64(magicked, config->args, "-set_magicked", false, false); 2060 2060 PXOPT_LOOKUP_S16(quality, config->args, "-set_quality", false, false); 2061 2061 2062 if (magicked) { 2062 2063 psStringAppend(&set_magicked_skyfile, "\n , warpSkyfile.magicked = %" PRId64, magicked); … … 2065 2066 if (quality) { 2066 2067 psStringAppend(&set_magicked_skyfile, "\n , warpSkyfile.quality = %"PRId16, quality); 2068 } 2069 PXOPT_LOOKUP_S16(background_model, config->args, "-set_background_model", false, false); 2070 if (background_model) { 2071 psStringAppend(&set_magicked_skyfile, "\n , warpSkyfile.background_model = %"PRId16, background_model); 2067 2072 } 2068 2073 } else if (!strcmp(data_state, "cleaned") || !strcmp(data_state, "purged")) { … … 2125 2130 // warp_id, skycell_id, fault are required 2126 2131 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 2127 2128 if (!state) { 2132 PXOPT_LOOKUP_S16(background_model, config->args, "-set_background_model", false, false); 2133 if (background_model) { 2134 // CZW 2012-12-06: I'm unclear why we don't use this form for all updates? 2135 psMetadata *where = psMetadataAlloc(); 2136 psMetadata *values = psMetadataAlloc(); 2137 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); 2138 PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "=="); 2139 PXOPT_COPY_S16(config->args, values, "-set_background_model", "background_model", "=="); 2140 long rows = psDBUpdateRows(config->dbh,"warpSkyfile", where, values); 2141 psFree(values); 2142 psFree(where); 2143 if (!rows) { 2144 // This maybe should rollback and error if rows != 1 2145 psError(PS_ERR_UNKNOWN, true, "no rows changed"); 2146 return false; 2147 } 2148 } 2149 else if (!state) { 2129 2150 psMetadata *where = psMetadataAlloc(); 2130 2151 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); -
trunk/ippTools/src/warptoolConfig.c
r34766 r34800 410 410 psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-set_quality", 0,"new quality value", 0); 411 411 psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-set_state", 0, "set state", 0); 412 412 psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-set_background_model", 0, "set the background_model value", 0); 413 413 // -exportrun 414 414 psMetadata *exportrunArgs = psMetadataAlloc(); -
trunk/ippconfig
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippconfig (added) merged: 34412,34442,34455,34531,34628,34772,34786
- Property svn:mergeinfo changed
-
trunk/ippconfig/gpc1/pswarp.config
r19094 r34800 1 1 ASTROM.SOURCE STR PSASTRO.OUTPUT # Source file rule for astrometry, or NULL 2 BACKGROUND.MODEL BOOL TRUE 3 BKG.XGRID S32 50 4 BKG.YGRID S32 50 -
trunk/ippconfig/recipes/filerules-mef.mdc
r34528 r34800 120 120 PSWARP.SKYCELL INPUT @FILES CHIP IMAGE 121 121 PSWARP.ASTROM INPUT @FILES CHIP CMF 122 PSWARP.BKGMODEL INPUT @FILES CHIP IMAGE 122 123 123 124 ## files used by ppsub … … 138 139 PPSTACK.INPUT.PSF INPUT @FILES CHIP PSF 139 140 PPSTACK.INPUT.SOURCES INPUT @FILES FPA CMF 141 PPSTACK.INPUT.BKGMODEL INPUT @FILES FPA IMAGE 140 142 141 143 ## files used by ppstamp … … 296 298 PSWARP.BIN2 OUTPUT {OUTPUT}.b2.fits IMAGE COMP_IMG FPA TRUE NONE 297 299 PSWARP.CONFIG OUTPUT {OUTPUT}.pswarp.mdc TEXT NONE FPA TRUE NONE 300 PSWARP.OUTPUT.BKGMODEL OUTPUT {OUTPUT}.mdl.fits IMAGE NONE FPA TRUE NONE 298 301 299 302 SKYCELL.STATS OUTPUT {OUTPUT}.stats STATS NONE FPA TRUE NONE … … 342 345 PPSTACK.OUTPUT.JPEG1 OUTPUT {OUTPUT}.b1.jpg JPEG NONE FPA TRUE NONE 343 346 PPSTACK.OUTPUT.JPEG2 OUTPUT {OUTPUT}.b2.jpg JPEG NONE FPA TRUE NONE 347 PPSTACK.OUTPUT.BKGMODEL OUTPUT {OUTPUT}.mdl.fits IMAGE NONE FPA TRUE NONE 348 PPSTACK.OUTPUT.BKGREST OUTPUT {OUTPUT}.bkgrest.fits IMAGE NONE FPA TRUE NONE 344 349 PPSTACK.CONFIG OUTPUT {OUTPUT}.ppStack.mdc TEXT NONE FPA TRUE NONE 345 350 … … 370 375 PPSKYCELL.BIN1 OUTPUT {OUTPUT}.{FILE.INDEX}.b1.fits IMAGE NONE FPA TRUE NONE 371 376 PPSKYCELL.BIN2 OUTPUT {OUTPUT}.{FILE.INDEX}.b2.fits IMAGE NONE FPA TRUE NONE 377 PPSKYCELL.BIN1.MASK OUTPUT {OUTPUT}.{FILE.INDEX}.b1.mk.fits MASK COMP_MASK FPA TRUE NONE 378 PPSKYCELL.BIN2.MASK OUTPUT {OUTPUT}.{FILE.INDEX}.b2.mk.fits MASK COMP_MASK FPA TRUE NONE 372 379 373 380 LOG.IMFILE OUTPUT {OUTPUT}.{CHIP.NAME}.log TEXT NONE CHIP TRUE NONE -
trunk/ippconfig/recipes/filerules-simple.mdc
r34528 r34800 90 90 PSWARP.SKYCELL INPUT @FILES FPA IMAGE 91 91 PSWARP.ASTROM INPUT @FILES FPA CMF 92 PSWARP.BKGMODEL INPUT @FILES CHIP IMAGE 92 93 93 94 ## files used by ppsub … … 108 109 PPSTACK.INPUT.PSF INPUT @FILES CHIP PSF 109 110 PPSTACK.INPUT.SOURCES INPUT @FILES FPA CMF 111 PPSTACK.INPUT.BKGMODEL INPUT @FILES FPA IMAGE 110 112 111 113 ## files used by ppstamp … … 251 253 PSWARP.BIN2 OUTPUT {OUTPUT}.b2.fits IMAGE NONE FPA TRUE NONE 252 254 PSWARP.CONFIG OUTPUT {OUTPUT}.pswarp.mdc TEXT NONE FPA TRUE NONE 255 PSWARP.OUTPUT.BKGMODEL OUTPUT {OUTPUT}.mdl.fits IMAGE NONE FPA TRUE NONE 253 256 254 257 SKYCELL.STATS OUTPUT {OUTPUT}.stats STATS NONE FPA TRUE NONE … … 300 303 PPSTACK.OUTPUT.JPEG1 OUTPUT {OUTPUT}.b1.jpg JPEG NONE FPA TRUE NONE 301 304 PPSTACK.OUTPUT.JPEG2 OUTPUT {OUTPUT}.b2.jpg JPEG NONE FPA TRUE NONE 305 PPSTACK.OUTPUT.BKGMODEL OUTPUT {OUTPUT}.mdl.fits IMAGE NONE FPA TRUE NONE 306 PPSTACK.OUTPUT.BKGREST OUTPUT {OUTPUT}.bkgrest.fits IMAGE NONE FPA TRUE NONE 302 307 PPSTACK.CONFIG OUTPUT {OUTPUT}.ppStack.mdc TEXT NONE FPA TRUE NONE 303 308 … … 327 332 PPSKYCELL.BIN1 OUTPUT {OUTPUT}.{FILE.INDEX}.b1.fits IMAGE NONE FPA TRUE NONE 328 333 PPSKYCELL.BIN2 OUTPUT {OUTPUT}.{FILE.INDEX}.b2.fits IMAGE NONE FPA TRUE NONE 334 PPSKYCELL.BIN1.MASK OUTPUT {OUTPUT}.b1.mk.fits MASK COMP_MASK FPA TRUE NONE 335 PPSKYCELL.BIN2.MASK OUTPUT {OUTPUT}.b2.mk.fits MASK COMP_MASK FPA TRUE NONE 329 336 330 337 LOG.IMFILE OUTPUT {OUTPUT}.imfile.log TEXT NONE FPA TRUE NONE -
trunk/ippconfig/recipes/filerules-split.mdc
r34528 r34800 108 108 PSWARP.SKYCELL INPUT @FILES FPA IMAGE 109 109 PSWARP.ASTROM INPUT @FILES CHIP CMF 110 PSWARP.BKGMODEL INPUT @FILES CHIP IMAGE 110 111 111 112 ## files used by ppsub … … 126 127 PPSTACK.INPUT.PSF INPUT @FILES CHIP PSF 127 128 PPSTACK.INPUT.SOURCES INPUT @FILES FPA CMF 129 PPSTACK.INPUT.BKGMODEL INPUT @FILES FPA IMAGE 128 130 129 131 ## files used by ppstamp … … 278 280 PSWARP.CONFIG OUTPUT {OUTPUT}.pswarp.mdc TEXT NONE FPA TRUE NONE 279 281 PSWARP.OUTPUT.UNCOMPRESSED OUTPUT {OUTPUT}.fits IMAGE NONE FPA TRUE NONE 282 PSWARP.OUTPUT.BKGMODEL OUTPUT {OUTPUT}.mdl.fits IMAGE NONE FPA TRUE NONE 280 283 281 284 SKYCELL.STATS OUTPUT {OUTPUT}.stats STATS NONE FPA TRUE NONE … … 333 336 PPSTACK.OUTPUT.JPEG1 OUTPUT {OUTPUT}.b1.jpg JPEG NONE FPA TRUE NONE 334 337 PPSTACK.OUTPUT.JPEG2 OUTPUT {OUTPUT}.b2.jpg JPEG NONE FPA TRUE NONE 338 PPSTACK.OUTPUT.BKGMODEL OUTPUT {OUTPUT}.mdl.fits IMAGE NONE FPA TRUE NONE 339 PPSTACK.OUTPUT.BKGREST OUTPUT {OUTPUT}.bkgrest.fits IMAGE NONE FPA TRUE NONE 335 340 PPSTACK.CONFIG OUTPUT {OUTPUT}.ppStack.mdc TEXT NONE FPA TRUE NONE 336 341 … … 360 365 PPSKYCELL.JPEG1 OUTPUT {OUTPUT}.0.b1.jpeg JPEG NONE CHIP TRUE NONE 361 366 PPSKYCELL.JPEG2 OUTPUT {OUTPUT}.0.b2.jpeg JPEG NONE CHIP TRUE NONE 362 PPSKYCELL.BIN1 OUTPUT {OUTPUT}.0.b1.fits IMAGE COMP_IMG FPA TRUE NONE 363 PPSKYCELL.BIN2 OUTPUT {OUTPUT}.0.b2.fits IMAGE COMP_IMG FPA TRUE NONE 367 PPSKYCELL.BIN1 OUTPUT {OUTPUT}.b1.fits IMAGE COMP_IMG FPA TRUE NONE 368 PPSKYCELL.BIN2 OUTPUT {OUTPUT}.b2.fits IMAGE COMP_IMG FPA TRUE NONE 369 PPSKYCELL.BIN1.MASK OUTPUT {OUTPUT}.b1.mk.fits MASK COMP_MASK FPA TRUE NONE 370 PPSKYCELL.BIN2.MASK OUTPUT {OUTPUT}.b2.mk.fits MASK COMP_MASK FPA TRUE NONE 364 371 365 372 LOG.IMFILE OUTPUT {OUTPUT}.{CHIP.NAME}.log TEXT NONE CHIP TRUE NONE -
trunk/ippconfig/recipes/nightly_science.config
r34608 r34800 229 229 DIFFABLE BOOL TRUE 230 230 REDUCTION STR SWEETSPOT 231 ADDITIONAL_STACK_LABEL STR ecliptic.rp 231 232 # REDUCTION STR SSTF_4SIG 232 233 # WARP S16 60 … … 240 241 DIFFABLE BOOL TRUE 241 242 REDUCTION STR SWEETSPOT 243 ADDITIONAL_STACK_LABEL STR ecliptic.rp 242 244 # REDUCTION STR SSTF_4SIG 243 245 END … … 250 252 DIFFABLE BOOL TRUE 251 253 REDUCTION STR SWEETSPOT 254 ADDITIONAL_STACK_LABEL STR ecliptic.rp 252 255 # REDUCTION STR SSTF_4SIG 253 256 END … … 260 263 DIFFABLE BOOL TRUE 261 264 REDUCTION STR SWEETSPOT 265 ADDITIONAL_STACK_LABEL STR ecliptic.rp 262 266 # REDUCTION STR SSTF_4SIG 263 267 END -
trunk/ippconfig/recipes/ppBackground.mdc
r28486 r34800 1 1 # Recipe options for ppBackground 2 2 3 BINNING_RECIPE STR PSPHOT 4 BINNING_XNAME STR BACKGROUND.XBIN 5 BINNING_YNAME STR BACKGROUND.YBIN 6 7 DEFAULT METADATA 8 END 9 10 11 STACK METADATA 12 BINNING_RECIPE STR PSWARP 13 BINNING_XNAME STR BKG.XGRID 14 BINNING_YNAME STR BKG.YGRID 15 END 16 3 17 4 18 BACKGROUND METADATA -
trunk/ippconfig/recipes/ppStack.config
r34091 r34800 103 103 STACK.TYPE STR DEEP_STACK 104 104 105 DEFAULT.EXPTIME F32 NAN 106 105 107 # Recipe overrides for STACK 106 108 STACK METADATA -
trunk/ippconfig/recipes/ppSub.config
- Property svn:mergeinfo set to
-
trunk/ippconfig/recipes/pswarp.config
r28442 r34800 19 19 MASKSTAT.ADVISORY U32 0x080 20 20 21 BACKGROUND.MODEL BOOL FALSE # Construct a warped version of the chip stage background 22 BKG.XGRID S32 4 # These need to be tuned 23 BKG.YGRID S32 4 21 24 22 25 # Default recipe for warping -
trunk/ippconfig/recipes/reductionClasses.mdc
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ippconfig/recipes/reductionClasses.mdc (added) merged: 34772,34786 /trunk/ippconfig/recipes/reductionClasses.mdc (added) merged: 2-17522
- Property svn:mergeinfo changed
-
trunk/ppBackground/src/ppBackground.h
r28300 r34800 37 37 ); 38 38 39 /// Determine the binning from the recipe if available. 40 psImageBinning *ppBackgroundBinningByRecipe(const psImage *image, // Image for which to generate a bg model 41 const pmConfig *config, // Configuration 42 psString recipe_name, 43 psString Xbin_name, 44 psString Ybin_name 45 ); 46 47 39 48 /// Restore the background to an image 40 49 bool ppBackgroundRestore( -
trunk/ppBackground/src/ppBackgroundRestore.c
r34298 r34800 5 5 6 6 #include "ppBackground.h" 7 8 psImageBinning *ppBackgroundBinningByRecipe(const psImage *image, // Image for which to generate a bg model 9 const pmConfig *config, // Configuration 10 psString recipe_name, 11 psString Xbin_name, 12 psString Ybin_name 13 ) 14 { 15 bool status = true; 16 17 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, recipe_name); 18 assert (recipe); 19 20 // I have the fine image size, I know the binning factor, determine the ruff image size 21 psImageBinning *binning = psImageBinningAlloc(); 22 binning->nXfine = image->numCols; 23 binning->nYfine = image->numRows; 24 binning->nXbin = psMetadataLookupS32(&status, recipe, Xbin_name); 25 binning->nYbin = psMetadataLookupS32(&status, recipe, Ybin_name); 26 27 psImageBinningSetRuffSize(binning, PS_IMAGE_BINNING_CENTER); 28 psImageBinningSetSkip(binning, image); 29 30 return binning; 31 } 32 33 34 7 35 8 36 bool ppBackgroundRestore(pmChip *chip, const pmChip *background, const pmChip *pattern, … … 27 55 if (background) { 28 56 pmReadout *bgRO = pmFPAviewThisReadout(view, background->parent); // Readout with background 29 psImageBinning *binning = psphotBackgroundBinning(image, config); 57 58 psImageBinning *binning; 59 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPBACKGROUND_RECIPE); // Recipe 60 if (!recipe) { 61 binning = psphotBackgroundBinning(image, config); 62 } 63 else { 64 binning = ppBackgroundBinningByRecipe(image,config, 65 psMetadataLookupStr(NULL,recipe,"BINNING_RECIPE"), 66 psMetadataLookupStr(NULL,recipe,"BINNING_XNAME"), 67 psMetadataLookupStr(NULL,recipe,"BINNING_YNAME")); 68 } 69 70 fprintf(stderr,"%d %d %d %d\n",binning->nXfine,binning->nYfine,binning->nXbin,binning->nYbin); 30 71 if (!binning) { 31 72 psError(psErrorCodeLast(), false, "Unable to find background binning"); … … 49 90 for (int y = 0; y < numRows; y++) { 50 91 for (int x = 0; x < numCols; x++) { 92 if ((y % 250 == 0)&&(x % 250 == 0)) { 93 printf("%d %d %g\n",x,y,bgImage->data.F32[y][x]); 94 } 51 95 image->data.F32[y][x] += bgImage->data.F32[y][x]; 96 52 97 } 53 98 } -
trunk/ppImage/src
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/ppImage/src (added) merged: 34772
- Property svn:mergeinfo changed
-
trunk/ppSkycell/src/ppSkycellCamera.c
r28375 r34800 103 103 return false; 104 104 } 105 if (!pmFPAfileDefineOutput(data->config, NULL, "PPSKYCELL.BIN1")) { 105 pmFPAfile *bin1 = pmFPAfileDefineOutput(data->config, NULL, "PPSKYCELL.BIN1"); 106 if (!bin1) { 106 107 psError(psErrorCodeLast(), false, "Unable to define output."); 107 108 return false; 108 109 } 109 if (!pmFPAfileDefineOutput(data->config, NULL, "PPSKYCELL.BIN2")) { 110 pmFPAfile *bin2 = pmFPAfileDefineOutput(data->config, NULL, "PPSKYCELL.BIN2"); 111 if (!bin2) { 110 112 psError(psErrorCodeLast(), false, "Unable to define output."); 111 113 return false; 114 } 115 if (data->masksName) { 116 pmFPAfile *mask1 = pmFPAfileDefineOutput(data->config, bin1->fpa , "PPSKYCELL.BIN1.MASK"); 117 if (!mask1) { 118 psError(psErrorCodeLast(), false, "Unable to define output."); 119 return false; 120 } 121 mask1->save = true; 122 pmFPAfile *mask2 = pmFPAfileDefineOutput(data->config, bin2->fpa , "PPSKYCELL.BIN2.MASK"); 123 if (!mask2) { 124 psError(psErrorCodeLast(), false, "Unable to define output."); 125 return false; 126 } 127 mask2->save = true; 112 128 } 113 129 -
trunk/ppSkycell/src/ppSkycellLoop.c
r28375 r34800 15 15 ) 16 16 { 17 base->x0 = PS_M IN(base->x0, compare->x0);18 base->x1 = PS_M AX(base->x1, compare->x1);17 base->x0 = PS_MAX(base->x0, compare->x0); 18 base->x1 = PS_MIN(base->x1, compare->x1); 19 19 base->y0 = PS_MIN(base->y0, compare->y0); 20 20 base->y1 = PS_MAX(base->y1, compare->y1); … … 27 27 { 28 28 psPlane *fromCoords = psPlaneAlloc(), *toCoords = psPlaneAlloc(); // Coordinates for transforms 29 psRegion *region = psRegionAlloc( INFINITY, -INFINITY, INFINITY, -INFINITY); // Region for skycell29 psRegion *region = psRegionAlloc(-INFINITY, INFINITY, INFINITY, -INFINITY); // Region for skycell 30 30 31 31 // Limit the region using the nominated point (X,Y) … … 38 38 toCoords->x += wcs->crpix1; \ 39 39 toCoords->y += wcs->crpix2; \ 40 region->x0 = PS_M IN(region->x0, toCoords->x); \41 region->x1 = PS_M AX(region->x1, toCoords->x); \40 region->x0 = PS_MAX(region->x0, toCoords->x); \ 41 region->x1 = PS_MIN(region->x1, toCoords->x); \ 42 42 region->y0 = PS_MIN(region->y0, toCoords->y); \ 43 43 region->y1 = PS_MAX(region->y1, toCoords->y); … … 132 132 psVector *target = psVectorAlloc(data->numInputs, PS_TYPE_S32); // Target for each input 133 133 psArray *imageRegions = psArrayAlloc(data->numInputs); // Region for image 134 134 psArray *regionHDUs = psArrayAlloc(data->numInputs); 135 // Determine which projection cells we have to deal with. 135 136 for (int i = 0; i < data->numInputs; i++) { 136 137 pmFPAfile *file = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.IMAGE", i); // File to examine … … 178 179 target->data.S32[i] = numProj; 179 180 psTrace("ppSkycell", 3, "Image %d uses new projection\n", i); 180 181 psArrayAdd(regionHDUs,1,hdu); 181 182 numProj++; 182 183 } … … 184 185 185 186 pmFPAfileActivate(data->config->files, false, NULL); 186 187 // Loop over projections 187 188 for (int i = 0; i < numProj; i++) { 188 189 psRegion *projRegion = projRegions->data[i]; // Region for skycell projection 189 190 psTrace("ppSkycell", 2, "Projection %d: [%.0f:%.0f,%.0f:%.0f]\n", 190 191 i, projRegion->x0, projRegion->x1, projRegion->y0, projRegion->y1); 191 int xSize = projRegion->x1 -projRegion->x0 + 1; // Size of unbinned image192 int xSize = -projRegion->x1 + projRegion->x0 + 1; // Size of unbinned image 192 193 int ySize = projRegion->y1 - projRegion->y0 + 1; // Size of unbinned image 193 194 // Size of binned image 1 … … 198 199 psImage *image1 = psImageAlloc(numCols1, numRows1, PS_TYPE_F32); // Binned image 199 200 psImage *image2 = psImageAlloc(numCols2, numRows2, PS_TYPE_F32); // Binned image 200 psImageInit(image1, 0);201 psImageInit(image2, 0);202 201 psImageInit(image1,NAN); 202 psImageInit(image2,NAN); 203 203 204 psImage *mask1 = NULL, *mask2 = NULL; // Binned masks 204 205 if (data->masksName) { … … 208 209 psImageInit(mask2, 0xFF); 209 210 } 210 211 pmHDU *projhdu = NULL; 212 int modify_wcs1 = 1; 213 int modify_wcs2 = 1; 214 // Loop over inputs to this projection. 211 215 for (int j = 0; j < data->numInputs; j++) { 212 216 if (target->data.S32[j] != i) { 213 217 continue; 214 218 } 215 216 219 pmFPAfileActivateSingle(data->config->files, true, "PPSKYCELL.IMAGE", j); 217 220 if (data->masksName) { … … 227 230 228 231 pmFPAfile *file = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.IMAGE", j); 232 if (!projhdu) { 233 projhdu = file->fpa->hdu; 234 // psMetadataCopy(projhdu->header,file->fpa->hdu->header); 235 } 236 #if 0 237 else { 238 if ((psMetadataLookupF32(NULL,file->fpa->hdu->header,"CRPIX1") >= 239 psMetadataLookupF32(NULL,projhdu->header,"CRPIX1"))&& 240 (psMetadataLookupF32(NULL,file->fpa->hdu->header,"CRPIX2") >= 241 psMetadataLookupF32(NULL,projhdu->header,"CRPIX1"))) { 242 projhdu = file->fpa->hdu; 243 psMetadataCopy(projhdu->header,file->fpa->hdu->header); 244 } 245 } 246 #endif 247 229 248 pmReadout *inRO = pmFPAviewThisReadout(view, file->fpa); // Readout with input 230 249 psFree(view); 231 250 232 // Flip images; no idea why this has to be done, but apparently it does 233 { 234 psImage *rot = psImageRotate(NULL, inRO->image, M_PI, NAN, PS_INTERPOLATE_BILINEAR); 235 psFree(inRO->image); 236 inRO->image = rot; 237 } 238 if (inRO->mask) { 239 psImage *rot = psImageRotate(NULL, inRO->mask, M_PI, 0, PS_INTERPOLATE_FLAT); 240 psFree(inRO->mask); 241 inRO->mask = rot; 242 } 243 251 // data->maskVal = 0xffff; 244 252 pmReadout *bin1RO = pmReadoutAlloc(NULL), *bin2RO = pmReadoutAlloc(NULL); // Binned readouts 245 253 if (!pmReadoutRebin(bin1RO, inRO, data->maskVal, data->bin1, data->bin1)) { … … 256 264 psRegion *imageRegion = imageRegions->data[j]; // Region for image 257 265 // Offsets for image on skycell 258 int xOffset1 = ( imageRegion->x0 -projRegion->x0) / (float)data->bin1;259 int yOffset1 = ( imageRegion->y0 - projRegion->y0) / (float)data->bin1;266 int xOffset1 = (-imageRegion->x0 + projRegion->x0) / (float)data->bin1; 267 int yOffset1 = (-imageRegion->y1 + projRegion->y1) / (float)data->bin1; 260 268 int xOffset2 = xOffset1 / (float)data->bin2, yOffset2 = yOffset1 / (float)data->bin2; 261 262 269 // XXX Completely neglecting rotations 263 270 // The skycells are divided up neatly with them all having the same orientation 264 psImageOverlaySection(image1, bin1RO->image, xOffset1, yOffset1, "=");265 psImageOverlaySection(image2, bin2RO->image, xOffset2, yOffset2, "=");271 psImageOverlaySection(image1, bin1RO->image, xOffset1, yOffset1, "E"); 272 psImageOverlaySection(image2, bin2RO->image, xOffset2, yOffset2, "E"); 266 273 if (data->masksName) { 267 psImageOverlaySection(mask1, bin1RO->mask, xOffset1, yOffset1, " =");268 psImageOverlaySection(mask2, bin2RO->mask, xOffset2, yOffset2, " =");274 psImageOverlaySection(mask1, bin1RO->mask, xOffset1, yOffset1, "M"); 275 psImageOverlaySection(mask2, bin2RO->mask, xOffset2, yOffset2, "M"); 269 276 } 270 277 … … 287 294 pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN1"); 288 295 pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN2"); 296 if (data->masksName) { 297 pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN1.MASK"); 298 pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN2.MASK"); 299 } 289 300 } 290 301 … … 313 324 314 325 if (data->doFits) { 326 327 pmFPAfile *fits1 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.BIN1", 0); 328 // Copy header from projection root hdu 329 fits1->fpa->hdu = pmHDUAlloc(NULL); 330 fits1->fpa->hdu->header = psMetadataAlloc(); 331 psMetadataCopy(fits1->fpa->hdu->header,projhdu->header); 332 333 // Change wcs here 334 #define WCS_DEBUG 0 335 if (modify_wcs1) { 336 pmAstromWCS *WCS = pmAstromWCSfromHeader(fits1->fpa->hdu->header); 337 double cd1f = 1.0 * data->bin1; 338 double cd2f = 1.0 * data->bin1; 339 #if WCS_DEBUG 340 fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g)\n",data->bin1,data->bin2, 341 cd1f,cd2f,WCS->cdelt1,WCS->cdelt2, 342 WCS->crpix1,WCS->crpix2 343 ); 344 #endif 345 WCS->cdelt1 *= cd1f; 346 WCS->cdelt2 *= cd2f; 347 WCS->crpix1 = WCS->crpix1 / cd1f; 348 WCS->crpix2 = WCS->crpix2 / cd2f; 349 #if WCS_DEBUG 350 fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g) %d %d %d %d\n",data->bin1,data->bin2, 351 cd1f,cd2f,WCS->cdelt1,WCS->cdelt2, 352 WCS->crpix1,WCS->crpix2, 353 WCS->trans->x->nX, WCS->trans->x->nY, 354 WCS->trans->y->nX, WCS->trans->y->nY 355 ); 356 #endif 357 for (int q = 0; q <= WCS->trans->x->nX; q++) { 358 for (int r = 0; r <= WCS->trans->x->nY; r++) { 359 WCS->trans->x->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r); 360 #if WCS_DEBUG 361 fprintf(stderr,"PC: %d %d %g %g\n", 362 q,r,pow(cd1f,q) * pow(cd2f,r), 363 WCS->trans->x->coeff[q][r]); 364 #endif 365 } 366 } 367 for (int q = 0; q <= WCS->trans->y->nX; q++) { 368 for (int r = 0; r <= WCS->trans->y->nY; r++) { 369 WCS->trans->y->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r); 370 #if WCS_DEBUG 371 fprintf(stderr,"PC: %d %d %g %g\n", 372 q,r,pow(cd1f,q) * pow(cd2f,r), 373 WCS->trans->y->coeff[q][r]); 374 #endif 375 } 376 } 377 pmAstromWCStoHeader (fits1->fpa->hdu->header,WCS); 378 WCS = pmAstromWCSfromHeader(fits1->fpa->hdu->header); 379 #if WCS_DEBUG 380 fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g)\n",data->bin1,data->bin2, 381 cd1f,cd2f,WCS->cdelt1,WCS->cdelt2, 382 WCS->crpix1,WCS->crpix2 383 ); 384 #endif 385 modify_wcs1 = 0; 386 } 387 388 389 pmChip *Fchip1 = pmFPAfileThisChip(data->config->files, view, "PPSKYCELL.BIN1"); 390 psMetadataAddS32(Fchip1->concepts,PS_LIST_TAIL,"CHIP.XPARITY", PS_META_REPLACE,"",1); 391 psMetadataAddS32(Fchip1->concepts,PS_LIST_TAIL,"CHIP.YPARITY", PS_META_REPLACE,"",1); 392 315 393 pmCell *Fcell1 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.BIN1"); // Rebinned cell 1 316 pmCell *Fcell2 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.BIN2"); // Rebinned cell 2 317 318 // This is a hack to get a functioning header created so the fits images can be written out. 394 /* // This is a hack to get a functioning header created so the fits images can be written out. */ 319 395 psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.XPARITY", PS_META_REPLACE,"",1); 320 396 psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.YPARITY", PS_META_REPLACE,"",1); 321 397 psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.READDIR", PS_META_REPLACE,"",1); 398 399 pmReadout *Fro1 = pmReadoutAlloc(Fcell1); 400 Fro1->image = image1; 401 Fro1->mask = mask1; 402 Fro1->data_exists = Fcell1->data_exists = Fcell1->parent->data_exists = true; 403 404 fits1->save = true; 405 fits1->fileIndex = i; 406 407 // Do the mask if we need to 408 if (data->masksName) { 409 /* pmFPAfile *Mask1 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.BIN1.MASK", 0); */ 410 /* // Mask1->fpa->hdu = pmHDUAlloc(NULL); */ 411 /* // Mask1->fpa->hdu->header = psMetadataAlloc(); */ 412 /* // psMetadataCopy(Mask1->fpa->hdu->header,fits1->fpa->hdu->header); */ 413 /* pmChip *Mchip1 = pmFPAfileThisChip(data->config->files, view, "PPSKYCELL.BIN1.MASK"); */ 414 /* psMetadataAddS32(Mchip1->concepts,PS_LIST_TAIL,"CHIP.XPARITY", PS_META_REPLACE,"",1); */ 415 /* psMetadataAddS32(Mchip1->concepts,PS_LIST_TAIL,"CHIP.YPARITY", PS_META_REPLACE,"",1); */ 416 417 /* pmCell *Mcell1 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.BIN1.MASK"); // Rebinned cell 1 */ 418 /* /\* // This is a hack to get a functioning header created so the fits images can be written out. *\/ */ 419 /* psMetadataAddS32(Mcell1->concepts,PS_LIST_TAIL,"CELL.XPARITY", PS_META_REPLACE,"",1); */ 420 /* psMetadataAddS32(Mcell1->concepts,PS_LIST_TAIL,"CELL.YPARITY", PS_META_REPLACE,"",1); */ 421 /* psMetadataAddS32(Mcell1->concepts,PS_LIST_TAIL,"CELL.READDIR", PS_META_REPLACE,"",1); */ 422 423 /* pmReadout *Mro1 = pmReadoutAlloc(Mcell1); */ 424 /* Mro1->image = image1; */ 425 /* Mro1->mask = mask1; */ 426 /* Mro1->data_exists = Mcell1->data_exists = Mcell1->parent->data_exists = true; */ 427 428 /* Mask1->save = true; */ 429 /* Mask1->fileIndex = i; */ 430 } 431 432 433 434 // Repeat with second binned image 435 pmFPAfile *fits2 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.BIN2", 0); 436 fits2->fpa->hdu = pmHDUAlloc(NULL); 437 fits2->fpa->hdu->header = psMetadataAlloc(); 438 psMetadataCopy(fits2->fpa->hdu->header,projhdu->header); 439 440 if (modify_wcs2) { 441 pmAstromWCS *WCS = pmAstromWCSfromHeader(fits2->fpa->hdu->header); 442 double cd1f = 1.0 * data->bin2 * data->bin1; 443 double cd2f = 1.0 * data->bin2 * data->bin1; 444 445 WCS->cdelt1 *= cd1f; 446 WCS->cdelt2 *= cd2f; 447 WCS->crpix1 = WCS->crpix1 / cd1f; 448 WCS->crpix2 = WCS->crpix2 / cd2f; 449 450 for (int q = 0; q < WCS->trans->x->nX; q++) { 451 for (int r = 0; r < WCS->trans->x->nY; r++) { 452 WCS->trans->x->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r); 453 } 454 } 455 for (int q = 0; q < WCS->trans->y->nX; q++) { 456 for (int r = 0; r < WCS->trans->y->nY; r++) { 457 WCS->trans->y->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r); 458 } 459 } 460 pmAstromWCStoHeader (fits2->fpa->hdu->header,WCS); 461 modify_wcs2 = 0; 462 } 463 464 pmChip *Fchip2 = pmFPAfileThisChip(data->config->files, view, "PPSKYCELL.BIN2"); 465 psMetadataAddS32(Fchip2->concepts,PS_LIST_TAIL,"CHIP.XPARITY", PS_META_REPLACE,"",1); 466 psMetadataAddS32(Fchip2->concepts,PS_LIST_TAIL,"CHIP.YPARITY", PS_META_REPLACE,"",1); 467 468 469 pmCell *Fcell2 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.BIN2"); // Rebinned cell 2 322 470 psMetadataAddS32(Fcell2->concepts,PS_LIST_TAIL,"CELL.XPARITY", PS_META_REPLACE,"",1); 323 471 psMetadataAddS32(Fcell2->concepts,PS_LIST_TAIL,"CELL.YPARITY", PS_META_REPLACE,"",1); 324 472 psMetadataAddS32(Fcell2->concepts,PS_LIST_TAIL,"CELL.READDIR", PS_META_REPLACE,"",1); 325 326 psMetadataAddS32(Fcell1->parent->concepts,PS_LIST_TAIL,"CHIP.XPARITY", PS_META_REPLACE,"",1); 327 psMetadataAddS32(Fcell1->parent->concepts,PS_LIST_TAIL,"CHIP.YPARITY", PS_META_REPLACE,"",1); 328 psMetadataAddS32(Fcell2->parent->concepts,PS_LIST_TAIL,"CHIP.XPARITY", PS_META_REPLACE,"",1); 329 psMetadataAddS32(Fcell2->parent->concepts,PS_LIST_TAIL,"CHIP.YPARITY", PS_META_REPLACE,"",1); 330 331 pmReadout *Fro1 = pmReadoutAlloc(Fcell1), *Fro2 = pmReadoutAlloc(Fcell2); // Binned readouts 332 333 Fro1->image = image1; 473 474 pmReadout *Fro2 = pmReadoutAlloc(Fcell2); 334 475 Fro2->image = image2; 335 Fro1->mask = mask1;336 476 Fro2->mask = mask2; 337 338 Fro1->data_exists = Fcell1->data_exists = Fcell1->parent->data_exists = true;339 477 Fro2->data_exists = Fcell2->data_exists = Fcell2->parent->data_exists = true; 340 341 pmFPAfile *fits1 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.BIN1", 0); 342 fits1->save = true; 343 fits1->fileIndex = i; 344 pmFPAfile *fits2 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.BIN2", 0); 478 345 479 fits2->save = true; 346 480 fits2->fileIndex = i; 481 482 347 483 } 348 484 -
trunk/ppStack/src/Makefile.am
r30620 r34800 1 bin_PROGRAMS = ppStack 1 bin_PROGRAMS = ppStack ppStackMedian 2 2 3 3 if HAVE_SVNVERSION … … 25 25 ppStack_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS) $(PPSTATS_LIBS) $(PPSTACK_LIBS) 26 26 27 ppStackMedian_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS) 28 ppStackMedian_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS) $(PPSTATS_LIBS) $(PPSTACK_LIBS) 29 27 30 ppStack_SOURCES = \ 28 31 ppStack.c \ … … 43 46 ppStackCombinePrepare.c \ 44 47 ppStackCombineInitial.c \ 48 ppStackCombineAlternate.c \ 49 ppStackReject.c \ 50 ppStackCombineFinal.c \ 51 ppStackCleanup.c \ 52 ppStackPhotometry.c \ 53 ppStackFinish.c \ 54 ppStackTarget.c \ 55 ppStackUpdateHeader.c \ 56 ppStackJPEGs.c \ 57 ppStackStats.c \ 58 ppStackErrorCodes.c 59 60 ppStackMedian_SOURCES = \ 61 ppStackMedian.c \ 62 ppStackArguments.c \ 63 ppStackCamera.c \ 64 ppStackFiles.c \ 65 ppStackMedianLoop.c \ 66 ppStackPSF.c \ 67 ppStackReadout.c \ 68 ppStackVersion.c \ 69 ppStackMatch.c \ 70 ppStackSources.c \ 71 ppStackThread.c \ 72 ppStackOptions.c \ 73 ppStackSetup.c \ 74 ppStackPrepare.c \ 75 ppStackConvolve.c \ 76 ppStackCombinePrepare.c \ 77 ppStackCombineInitial.c \ 78 ppStackCombineAlternate.c \ 45 79 ppStackReject.c \ 46 80 ppStackCombineFinal.c \ -
trunk/ppStack/src/ppStack.h
r34092 r34800 38 38 PPSTACK_FILES_STACK, // Stack files 39 39 PPSTACK_FILES_UNCONV, // Unconvolved stack files 40 PPSTACK_FILES_PHOT // Files for photometry 40 PPSTACK_FILES_PHOT, // Files for photometry 41 PPSTACK_FILES_BKG, // Files for bkg 42 PPSTACK_FILES_MEDIAN_IN, // Files for median only stacks. 43 PPSTACK_FILES_MEDIAN_OUT // Files for median only stacks. 41 44 } ppStackFileList; 42 45 … … 111 114 bool ppStackReadoutFinalThread(psThreadJob *job // Job to process 112 115 ); 116 // Perform median stacking for background 117 bool ppStackCombineBackground(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config); 118 bool ppStackCombineMedian(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config); 113 119 114 120 // Return software version -
trunk/ppStack/src/ppStackArguments.c
r31422 r34800 324 324 } 325 325 326 326 327 psTrace("ppStack", 1, "Done parsing arguments\n"); 327 328 -
trunk/ppStack/src/ppStackCamera.c
r30620 r34800 156 156 psString psf = psMetadataLookupStr(&mdok, input, "PSF"); // Name of PSF 157 157 psString sources = psMetadataLookupStr(&mdok, input, "SOURCES"); // Name of sources 158 158 psString bkgmodel = psMetadataLookupStr(&mdok, input, "BKGMODEL"); // Name of warped background model 159 159 160 pmFPAfile *imageFile = defineFile(config, NULL, "PPSTACK.INPUT", 160 161 image, PM_FPA_FILE_IMAGE); // File for image … … 215 216 } 216 217 218 // Grab bkgmodel information here 219 if (!bkgmodel || strlen(bkgmodel) == 0) { 220 // We have no background models. 221 } 222 else { 223 pmFPAfile *inputBKG = defineFile(config,NULL,"PPSTACK.INPUT.BKGMODEL",bkgmodel, 224 PM_FPA_FILE_IMAGE); 225 if (!inputBKG) { 226 psError(psErrorCodeLast(), false, 227 "Unable to define file from bkgmodel %d (%s)",i,bkgmodel); 228 return(false); 229 } 230 }// End bkgmodel 231 232 233 234 217 235 i++; 218 236 } … … 460 478 jpeg2->save = true; 461 479 480 // Output background 481 pmFPAfile *outBkg = pmFPAfileDefineOutput(config,NULL,"PPSTACK.OUTPUT.BKGMODEL"); 482 if (!outBkg) { 483 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.BKGMODEL")); 484 return(false); 485 } 486 if (outBkg->type != PM_FPA_FILE_IMAGE) { 487 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.BKGMODEL is not of type IMAGE"); 488 return(false); 489 } 490 outBkg->save = true; 491 pmFPAfile *outBkgRest = pmFPAfileDefineOutput(config,NULL,"PPSTACK.OUTPUT.BKGREST"); 492 if (!outBkgRest) { 493 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.BKGREST")); 494 return(false); 495 } 496 if (outBkgRest->type != PM_FPA_FILE_IMAGE) { 497 psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.BKGREST is not of type IMAGE"); 498 return(false); 499 } 500 462 501 // For photometry, we operate on the chip-mosaicked image 463 502 // we create a copy of the mosaicked image for psphot so we can write out a clean image … … 496 535 } 497 536 537 // Define output file here. 538 498 539 return true; 499 540 } -
trunk/ppStack/src/ppStackCleanup.c
r30874 r34800 22 22 options->outRO = NULL; 23 23 24 options->expRO->data_exists = false; 25 options->expRO->parent->data_exists = false; 26 options->expRO->parent->parent->data_exists = false; 27 psFree(options->expRO); 28 options->expRO = NULL; 24 if (options->expRO) { 25 options->expRO->data_exists = false; 26 if (options->expRO->parent) { 27 options->expRO->parent->data_exists = false; 28 options->expRO->parent->parent->data_exists = false; 29 } 30 psFree(options->expRO); 31 options->expRO = NULL; 32 } 29 33 34 if (options->bkgRO) { 35 options->bkgRO->data_exists = false; 36 if (options->bkgRO->parent) { 37 options->bkgRO->parent->data_exists = false; 38 options->bkgRO->parent->parent->data_exists = false; 39 } 40 psFree(options->bkgRO); 41 options->bkgRO = NULL; 42 } 43 30 44 for (int i = 0; i < options->num; i++) { 31 45 pmCellFreeData(options->cells->data[i]); … … 62 76 63 77 bool ppStackCleanup (pmConfig *config, ppStackOptions *options) { 64 65 78 psExit exitValue = ppStackExitCode(PS_EXIT_SUCCESS); // Exit code 66 79 67 80 // Ensure everything closes 68 81 if (config) { … … 72 85 ppStackFileActivation(config, PPSTACK_FILES_UNCONV, true); 73 86 ppStackFileActivation(config, PPSTACK_FILES_PHOT, true); 87 ppStackFileActivation(config, PPSTACK_FILES_MEDIAN_IN, true); 88 ppStackFileActivation(config, PPSTACK_FILES_MEDIAN_OUT, true); 74 89 if (!ppStackFilesIterateUp(config)) { 75 90 psError(psErrorCodeLast(), false, "Unable to close files."); -
trunk/ppStack/src/ppStackCombinePrepare.c
r30620 r34800 1 1 #include "ppStack.h" 2 2 3 bool ppStackCombinePrepare(const char *outName, const char *expName, 3 bool ppStackCombinePrepare(const char *outName, const char *expName, const char *bkgName, 4 4 ppStackFileList files, ppStackThreadData *stack, 5 5 ppStackOptions *options, pmConfig *config) … … 27 27 options->outRO = pmReadoutAlloc(cell); // Output readout 28 28 29 pmCell *expCell = pmFPAfileThisCell(config->files, view, expName); // Exposure cell 30 options->expRO = pmReadoutAlloc(expCell); // Output readout 29 if (expName) { 30 pmCell *expCell = pmFPAfileThisCell(config->files, view, expName); // Exposure cell 31 options->expRO = pmReadoutAlloc(expCell); //Output readout 32 } 33 /* else { */ 34 /* options->expRO = NULL; */ 35 /* } */ 36 pmCell *bkgCell; 37 int bkg_r0,bkg_c0; 38 int bkg_nC,bkg_nR; 39 if (bkgName) { 40 ppStackFileActivationSingle(config, PPSTACK_FILES_BKG, true, 0); 41 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", 0); 42 pmFPAview *view = ppStackFilesIterateDown(config); 43 pmReadout *ro = pmFPAviewThisReadout(view,file->fpa); 44 45 bkg_r0 = ro->image->row0; 46 bkg_c0 = ro->image->col0; 47 bkg_nC = ro->image->numCols; 48 bkg_nR = ro->image->numRows; 49 bkgCell = pmFPAfileThisCell(config->files, view, bkgName); // Bkg cell 50 51 options->bkgRO = pmReadoutAlloc(bkgCell); // BKG readout 52 // if (!pmHDUGenerateForFPA(options->bkgRO->parent->parent->parent)) { 53 options->bkgRO->parent->parent->parent->hdu = pmHDUAlloc(NULL); 54 if (!options->bkgRO->parent->parent->parent->hdu) { 55 fprintf(stderr,"failed to generate a HDU for this thing.\n"); 56 } 57 options->bkgRO->parent->parent->parent->hdu->header = psMetadataCopy(options->bkgRO->parent->parent->parent->hdu->header, 58 ro->parent->parent->parent->hdu->header); 59 60 options->bkgRO->parent->concepts = psMetadataCopy(options->bkgRO->parent->concepts, 61 ro->parent->concepts); 62 options->bkgRO->parent->parent->concepts = psMetadataCopy(options->bkgRO->parent->parent->concepts, 63 ro->parent->parent->concepts); 64 options->bkgRO->parent->parent->parent->concepts = psMetadataCopy(options->bkgRO->parent->parent->parent->concepts, 65 ro->parent->parent->parent->concepts); 66 67 } 68 else { 69 options->bkgRO = NULL; 70 } 31 71 32 72 psFree(view); … … 42 82 } 43 83 44 if (!pmReadoutStackDefineOutput(options->expRO, col0, row0, numCols, numRows, true, true, 0)) { 84 if (expName) { 85 if (!pmReadoutStackDefineOutput(options->expRO, col0, row0, numCols, numRows, true, true, 0)) { 45 86 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to prepare output."); 46 87 return false; 88 } 89 } 90 91 if (bkgName) { 92 if (!pmReadoutStackDefineOutput(options->bkgRO, bkg_c0, bkg_r0, bkg_nC, bkg_nR, false, false, 0)) { 93 psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to prepare output."); 94 return false; 95 } 96 97 98 47 99 } 48 100 -
trunk/ppStack/src/ppStackFiles.c
r31158 r34800 14 14 /// Files required for the convolution 15 15 static char *filesConvolve[] = { "PPSTACK.INPUT", "PPSTACK.INPUT.MASK", "PPSTACK.INPUT.VARIANCE", NULL }; 16 17 /// Files required for the background 18 static char *filesBkg[] = { "PPSTACK.INPUT.BKGMODEL", NULL }; 19 20 /// Files required for median only stacking 21 static char *filesMedianIn[] = { "PPSTACK.INPUT", 22 NULL }; 23 /// Files required for median only stacking 24 static char *filesMedianOut[] = { "PPSTACK.OUTPUT", 25 NULL }; 16 26 17 27 /// Regular (convolved) stack files … … 19 29 "PPSTACK.OUTPUT.EXP", "PPSTACK.OUTPUT.EXPNUM", "PPSTACK.OUTPUT.EXPWT", 20 30 "PPSTACK.OUTPUT.JPEG1", "PPSTACK.OUTPUT.JPEG2", 31 "PPSTACK.OUTPUT.BKGMODEL", 21 32 NULL }; 22 33 /// Unconvolved stack files … … 41 52 case PPSTACK_FILES_UNCONV: return filesUnconv; 42 53 case PPSTACK_FILES_PHOT: return filesPhot; 54 case PPSTACK_FILES_BKG: return filesBkg; 55 case PPSTACK_FILES_MEDIAN_IN: return filesMedianIn; 56 case PPSTACK_FILES_MEDIAN_OUT: return filesMedianOut; 43 57 default: 44 58 psAbort("Unrecognised file list: %x", list); -
trunk/ppStack/src/ppStackLoop.c
r31435 r34800 63 63 64 64 // Prepare for combination 65 if (!ppStackCombinePrepare("PPSTACK.OUTPUT", "PPSTACK.OUTPUT.EXP", PPSTACK_FILES_STACK, stack, options, config)) {65 if (!ppStackCombinePrepare("PPSTACK.OUTPUT", "PPSTACK.OUTPUT.EXP", "PPSTACK.OUTPUT.BKGMODEL", PPSTACK_FILES_STACK, stack, options, config)) { 66 66 psError(psErrorCodeLast(), false, "Unable to prepare for combination."); 67 67 psFree(stack); … … 84 84 pmCellFreeData(options->cells->data[i]); 85 85 } 86 psFree(stack);86 // psFree(stack); 87 87 88 88 // Pixel rejection … … 142 142 } 143 143 144 // Generate median background stack here. 145 if (!ppStackCombineBackground(stack, options, config)) { 146 psError(psErrorCodeLast(), false, "Unable to generate median of background images."); 147 psFree(stack); 148 return false; 149 } 150 ppStackFileActivation(config,PPSTACK_FILES_BKG ,false); 144 151 // Photometry 145 152 psTrace("ppStack", 1, "Photometering stacked image....\n"); … … 171 178 return false; 172 179 } 173 psFree(stack);180 // psFree(stack); 174 181 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS")); 175 182 ppStackMemDump("cleanup"); … … 186 193 187 194 // Prepare for combination 188 if (!ppStackCombinePrepare("PPSTACK.UNCONV", "PPSTACK.UNCONV.EXP", PPSTACK_FILES_UNCONV,195 if (!ppStackCombinePrepare("PPSTACK.UNCONV", "PPSTACK.UNCONV.EXP", NULL, PPSTACK_FILES_UNCONV, 189 196 stack, options, config)) { 190 197 psError(psErrorCodeLast(), false, "Unable to prepare for combination."); -
trunk/ppStack/src/ppStackLoop.h
r30620 r34800 4 4 // Loop over the inputs, doing the combination 5 5 bool ppStackLoop( 6 pmConfig *config, // Configuration 7 ppStackOptions *options // Options for stacking 8 ); 9 // Median only loop. 10 bool ppStackMedianLoop( 6 11 pmConfig *config, // Configuration 7 12 ppStackOptions *options // Options for stacking … … 32 37 const char *outName, // Name of output file 33 38 const char *expName, // Name of exposure file 39 const char *bkgName, // Name of background file 34 40 ppStackFileList files, // Files of interest 35 41 ppStackThreadData *stack, // Stack -
trunk/ppStack/src/ppStackOptions.h
r34093 r34800 48 48 // Rejection 49 49 psArray *rejected; // Rejected pixels 50 // Background 51 pmReadout *bkgRO; // Output background readout 52 psArray *bkgImages; // Input background images 50 53 } ppStackOptions; 51 54 -
trunk/ppStack/src/ppStackPrepare.c
r34095 r34800 132 132 psVectorInit(options->inputMask, 0); 133 133 options->exposures = psVectorAlloc(options->num, PS_TYPE_F32); 134 134 135 psVectorInit(options->exposures, NAN); 135 136 … … 150 151 151 152 options->exposures->data.F32[i] = psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE"); 153 if ((options->exposures->data.F32[i] == 0)|| 154 (!(isfinite(options->exposures->data.F32[i])))){ 155 options->exposures->data.F32[i] = psMetadataLookupF32(NULL,recipe,"DEFAULT.EXPTIME"); 156 } 152 157 options->sumExposure += options->exposures->data.F32[i]; 153 158 -
trunk/ppStack/src/ppStackReadout.c
r30620 r34800 194 194 195 195 196 197 196 bool ppStackReadoutFinal(const pmConfig *config, pmReadout *outRO, pmReadout *expRO, const psArray *readouts, 198 197 const psVector *mask, const psArray *rejected, const psVector *weightings, -
trunk/ppStack/src/ppStackSetup.c
r31158 r34800 89 89 options->origMasks = psArrayAlloc(num); 90 90 options->origVariances = psArrayAlloc(num); 91 options->bkgImages = psArrayAlloc(num); 91 92 pmFPAview *view = pmFPAviewAlloc(0); 93 int nullMasks = 0; 94 int nullVariances = 0; 92 95 for (int i = 0; i < num; i++) { 93 96 { … … 97 100 { 98 101 // We want the convolved mask, since that defines the area that has been tested for outliers 102 if (options->convolve) { 99 103 options->origMasks->data[i] = psMemIncrRefCounter(options->convMasks->data[i]); 104 } 105 else { 106 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.MASK", i); 107 options->origMasks->data[i] = pmFPAfileName(file, view, config); 108 } 109 if (!(options->origMasks->data[i])) { 110 nullMasks++; 111 } 100 112 } 101 113 { 102 114 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.VARIANCE", i); 103 115 options->origVariances->data[i] = pmFPAfileName(file, view, config); 116 if (!(options->origVariances->data[i])) { 117 nullVariances++; 118 } 104 119 } 120 /* { */ 121 /* pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", i); */ 122 /* options->bkgImages->data[i] = pmFPAfileName(file, view, config); */ 123 /* } */ 105 124 } 125 if (nullMasks == num) { 126 psFree(options->origMasks); 127 } 128 if (nullVariances == num) { 129 psFree(options->origVariances); 130 } 131 106 132 psFree(view); 107 133 -
trunk/ppStack/src/ppStackThread.c
r31158 r34800 40 40 psFree(stack->maskFits); 41 41 psFree(stack->varianceFits); 42 psFree(stack->bkgFits); 42 43 return; 43 44 } … … 67 68 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, covariances, NULL); 68 69 } 69 70 70 71 ppStackThreadData *stack = psAlloc(sizeof(ppStackThreadData)); // Thread data, to return 71 72 psMemSetDeallocator(stack, (psFreeFunc)stackThreadDataFree); … … 77 78 stack->maskFits = psArrayAlloc(numInputs); 78 79 stack->varianceFits = psArrayAlloc(numInputs); 80 stack->bkgFits = psArrayAlloc(numInputs); 79 81 for (int i = 0; i < numInputs; i++) { 80 82 if (!cells->data[i]) { … … 95 97 psFree(resolved); \ 96 98 } 97 99 98 100 IMAGE_OPEN(imageNames, stack->imageFits, i); 99 IMAGE_OPEN(maskNames, stack->maskFits, i); 100 IMAGE_OPEN(varianceNames, stack->varianceFits, i); 101 if (maskNames) { 102 IMAGE_OPEN(maskNames, stack->maskFits, i); 103 } 104 if (varianceNames) { 105 IMAGE_OPEN(varianceNames, stack->varianceFits, i); 106 } 101 107 } 102 108 -
trunk/ppStack/src/ppStackThread.h
r31158 r34800 25 25 psArray *maskFits; // FITS file pointers for masks 26 26 psArray *varianceFits; // FITS file pointers for variances 27 psArray *bkgFits; // FITS file pointers for background models 27 28 } ppStackThreadData; 28 29 -
trunk/ppStack/src/ppStackUpdateHeader.c
r31158 r34800 6 6 7 7 pmReadout *outRO = options->outRO; // Output readout 8 pmReadout *expRO = options->expRO; 8 9 9 10 // Propagate WCS 10 11 bool wcsDone = false; // Have we done the WCS? 11 12 for (int i = 0; i < options->num && !wcsDone; i++) { 12 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {13 if ((options->inputMask)&&(options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i])) { 13 14 continue; 14 15 } … … 123 124 snprintf (field, 64, "AIR_%04d", i); 124 125 psMetadataAddF32(hdu->header, PS_LIST_TAIL, field, PS_META_REPLACE, "input image airmass", value); 125 } 126 } 127 128 // Copy information into expRO, because it should be there too. 129 if ((expRO)&&(expRO->parent)) { 130 pmHDU *expROhdu = pmHDUFromCell(expRO->parent); 131 if (!expROhdu->header) { 132 expROhdu->header = psMetadataAlloc(); 133 } 134 expRO->parent->parent->parent->hdu->header = psMetadataCopy(expRO->parent->parent->parent->hdu->header, 135 outRO->parent->parent->parent->hdu->header); 136 137 expRO->parent->concepts = psMetadataCopy(expRO->parent->concepts, 138 outRO->parent->concepts); 139 expRO->parent->parent->concepts = psMetadataCopy(expRO->parent->parent->concepts, 140 outRO->parent->concepts); 141 expRO->parent->parent->parent->concepts = psMetadataCopy(expRO->parent->parent->parent->concepts, 142 outRO->parent->parent->parent->concepts); 143 } 144 126 145 return true; 127 146 } -
trunk/ppViz/src/ppVizPSF/ppVizPSFCamera.c
r26367 r34800 19 19 files->data[0] = psStringCopy(name); 20 20 if (psMetadataLookup(config->arguments, file)) { 21 21 22 psMetadataRemoveKey(config->arguments, file); 22 23 } … … 42 43 fileArguments("SOURCES", data->sourcesName, "Input sources", data->config); 43 44 pmFPAfile *srcs = pmFPAfileBindFromArgs(&status, psf, data->config, 44 "PSPHOT.INPUT.CMF", "SOURCES"); // File 45 "PSPHOT.INPUT.CMF", "SOURCES"); // File 46 fprintf(stderr,"%ld %d\n",(long) srcs, status); 45 47 if (!status || !srcs) { 46 48 psError(PS_ERR_IO, false, "Failed to build file from PSPHOT.INPUT.CMF"); -
trunk/ppViz/src/ppVizPSF/ppVizPSFLoop.c
r27667 r34800 20 20 return NULL; 21 21 } 22 22 fprintf(stderr,"Woo!\n"); 23 23 pmChip *chip; // Chip from FPA 24 24 while ((chip = pmFPAviewNextChip(view, psfFile->fpa, 1))) { … … 56 56 psWarning("More than one readout present for chip %d, cell %d", view->chip, view->cell); 57 57 } 58 58 fprintf(stderr,"Woo!\n"); 59 59 pmReadout *readout; // Readout from cell 60 60 while ((readout = pmFPAviewNextReadout(view, psfFile->fpa, 1))) { 61 fprintf(stderr,"Woo?\n"); 61 62 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 62 63 psError(PS_ERR_UNKNOWN, false, "Error loading data from files."); 63 64 return false; 64 65 } 65 if (!readout->data_exists) { 66 continue; 67 } 68 66 fprintf(stderr,"Woo2?\n"); 69 67 pmPSF *psf = psMetadataLookupPtr(NULL, chip->analysis, "PSPHOT.PSF"); // PSF 70 68 assert(psf); … … 72 70 bool mdok; // Status of MD lookup 73 71 psArray *sources = psMetadataLookupPtr(&mdok, readout->analysis, "PSPHOT.SOURCES"); // Sources 72 73 if (sources && !readout->data_exists) { // This fails if -sources not specified 74 continue; 75 } 76 readout->data_exists = true; 77 fprintf(stderr,"Woo! %ld\n", sources ? sources->n : -1); 78 79 fprintf(stderr,"%d\n",mdok); 74 80 int numCols = 0, numRows = 0; // Size of image 75 81 psVector *xOffset = NULL, *yOffset = NULL; // Offset from source to true position … … 80 86 psLogMsg("ppVizPSF", PS_LOG_INFO, "Generating %dx%d image", numCols, numRows); 81 87 } 82 if (sources ) {88 if (sources && !sources->n) { 83 89 psMemIncrRefCounter(sources); 84 90 psLogMsg("ppVizPSF", PS_LOG_INFO, "Using %ld input sources from CMF file", sources->n); … … 89 95 90 96 if (data->fakeNum > 0 && isfinite(data->fakeMag)) { 97 fprintf(stderr,"Here! fakes\n"); 91 98 long numOld = 0; // Old number of sources 92 99 long numNew = -1; // New number of sources … … 118 125 } 119 126 if (!sources && !data->input) { 127 fprintf(stderr,"Here! default\n"); 120 128 // Generate fake image with only a single realisation of the PSF 121 129 sources = psArrayAlloc(1); … … 151 159 psFree(psf->residuals); 152 160 psf->residuals = NULL; 153 161 fprintf(stderr,"still here"); 154 162 if (sources) { 163 fprintf(stderr,"Here! sources?\n"); 155 164 if (!pmReadoutFakeFromSources(readout, numCols, numRows, sources, 0, xOffset, yOffset, 156 165 psf, data->minFlux, 0, false, true)) { … … 159 168 } 160 169 } else if (data->input) { 170 161 171 psVector *x = data->input->data[0]; // x coordinates 162 172 psVector *y = data->input->data[1]; // y coordinates 163 173 psVector *mag = data->input->data[2]; // Magnitudes 174 fprintf(stderr,"Here! input? %d %d %g %d %ld\n",numCols,numRows,data->minFlux,1,x->n); 164 175 if (!pmReadoutFakeFromVectors(readout, numCols, numRows, x, y, mag, xOffset, yOffset, 165 176 psf, data->minFlux, 0, false, true)) { … … 168 179 } 169 180 } 170 181 171 182 psFree(sources); 172 183 psFree(xOffset); -
trunk/psLib/src/imageops/psImageInterpolate.c
r34365 r34800 31 31 #include "psImageConvolve.h" 32 32 33 # define IS_BILIN_SEPARABLE 033 # define IS_BILIN_SEPARABLE 1 34 34 35 35 #include "psImageInterpolate.h" … … 189 189 switch (mode) { 190 190 case PS_INTERPOLATE_FLAT: 191 case PS_INTERPOLATE_BILINEAR_SIMPLE: 191 192 // Nothing to pre-compute 192 193 break; … … 287 288 # endif 288 289 case PS_INTERPOLATE_BIQUADRATIC: 290 case PS_INTERPOLATE_BILINEAR_SIMPLE: 289 291 // 2D kernel, would cost too much memory to pre-calculate 290 292 break; 293 291 294 default: 292 295 psAbort("Unsupported interpolation mode: %x", mode); … … 937 940 938 941 942 psImageInterpolateStatus interpolateJustWork(double *imageValue, double *varianceValue, 943 psImageMaskType *maskValue, float x, float y, 944 const psImageInterpolation *interp) { 945 float u1,u2; 946 int xl,xh; 947 int yl,yh; 948 const psImage *image = interp->image; // Image to interpolate 949 950 xl = floor(x); 951 if (xl < 0) { xl = 0; } 952 if (xl >= image->numCols) {xl = image->numCols - 1; } 953 xh = xl + 1; 954 if (xh >= image->numCols) {xh = image->numCols - 1; } 955 956 yl = floor(y); 957 if (yl < 0) { yl = 0; } 958 if (yl >= image->numRows) {yl = image->numRows - 1; } 959 yh = yl + 1; 960 if (yh >= image->numRows) {yh = image->numRows - 1; } 961 962 if (imageValue && image) { 963 if (image->data.F32[yl][xl] == image->data.F32[yl][xh]) { 964 u1 = image->data.F32[yl][xh]; 965 } 966 else { 967 u1 = (xh - x) * image->data.F32[yl][xl] + (x - xl) * image->data.F32[yl][xh]; 968 } 969 if (image->data.F32[yh][xl] == image->data.F32[yh][xh]) { 970 u2 = image->data.F32[yh][xh]; 971 } 972 else { 973 u2 = (xh - x) * image->data.F32[yh][xl] + (x - xl) * image->data.F32[yh][xh]; 974 } 975 if (u1 == u2) { 976 *imageValue = u1; 977 } 978 else { 979 *imageValue = (yh - y) * u1 + (y - yl) * u2; 980 } 981 if ((floor(x) >= image->numCols)|| 982 (floor(y) >= image->numRows)) { 983 *imageValue = NAN; 984 } 985 } 986 #if (0) 987 if (*imageValue == 0.0) { 988 fprintf(stderr,"IJK: Zero!: %g %g [%d %d %d %d] %g %g (%g %g %g %g)\n", 989 x,y,xl,xh,yl,yh,u1,u2, 990 image->data.F32[yl][xl],image->data.F32[yl][xh],image->data.F32[yh][xl],image->data.F32[yh][xh] 991 ); 992 } 993 #endif 994 return PS_INTERPOLATE_STATUS_GOOD; 995 } 996 939 997 940 998 psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, … … 969 1027 case PS_INTERPOLATE_BIQUADRATIC: 970 1028 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp); 1029 case PS_INTERPOLATE_BILINEAR_SIMPLE: 1030 return interpolateJustWork(imageValue, varianceValue, maskValue, x, y, interp); 971 1031 case PS_INTERPOLATE_BILINEAR: 972 1032 # if (!IS_BILIN_SEPARABLE) 973 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp);1033 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp); 974 1034 # endif 975 1035 case PS_INTERPOLATE_GAUSS: … … 1019 1079 switch (mode) { 1020 1080 case PS_INTERPOLATE_FLAT: 1081 case PS_INTERPOLATE_BILINEAR_SIMPLE: 1021 1082 // No smearing by design 1022 1083 return 1.0; … … 1083 1144 if (!strcasecmp(name, "FLAT")) return PS_INTERPOLATE_FLAT; 1084 1145 if (!strcasecmp(name, "BILINEAR")) return PS_INTERPOLATE_BILINEAR; 1146 if (!strcasecmp(name, "SIMPLEBILINEAR")) return PS_INTERPOLATE_BILINEAR_SIMPLE; 1085 1147 if (!strcasecmp(name, "BIQUADRATIC")) return PS_INTERPOLATE_BIQUADRATIC; 1086 1148 if (!strcasecmp(name, "GAUSS")) return PS_INTERPOLATE_GAUSS; -
trunk/psLib/src/imageops/psImageInterpolate.h
r21281 r34800 33 33 PS_INTERPOLATE_LANCZOS3, ///< Sinc interpolation with 6x6 pixel kernel 34 34 PS_INTERPOLATE_LANCZOS4, ///< Sinc interpolation with 8x8 pixel kernel 35 PS_INTERPOLATE_BILINEAR_SIMPLE, ///< Simple manual bilinear interpolation 35 36 } psImageInterpolateMode; 36 37 -
trunk/psLib/src/imageops/psImagePixelManip.c
r12953 r34800 216 216 } 217 217 218 218 #define psImageOverlayLoopClean(DATATYPE,OP) { \ 219 for (int row=y0;row<imageRowLimit;row++) { \ 220 ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \ 221 ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-y0]; \ 222 for (int col=x0;col<imageColLimit;col++) { \ 223 if (!isfinite(imageRow[col])) { \ 224 imageRow[col] OP overlayRow[col-x0]; \ 225 } \ 226 else if (!isfinite(overlayRow[col-x0])) { \ 227 imageRow[col] = imageRow[col]; \ 228 } \ 229 else { \ 230 imageRow[col] = overlayRow[col-x0]; \ 231 } \ 232 } \ 233 } \ 234 pixelsOverlaid += (imageRowLimit - y0) * (imageColLimit - x0); \ 235 } 236 237 #define psImageOverlayLoopMask(DATATYPE) { \ 238 for (int row=y0;row<imageRowLimit;row++) { \ 239 ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \ 240 ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-y0]; \ 241 for (int col=x0;col<imageColLimit;col++) { \ 242 if (!isfinite(imageRow[col])) { \ 243 imageRow[col] = overlayRow[col-x0]; \ 244 } \ 245 else if (!isfinite(overlayRow[col-x0])) { \ 246 imageRow[col] = imageRow[col]; \ 247 } \ 248 else { \ 249 imageRow[col] &= overlayRow[col-x0]; \ 250 } \ 251 } \ 252 } \ 253 pixelsOverlaid += (imageRowLimit - y0) * (imageColLimit - x0); \ 254 } 255 256 257 219 258 #define psImageOverlayLoop(DATATYPE,OP) { \ 220 259 for (int row=y0;row<imageRowLimit;row++) { \ 221 260 ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \ 222 261 ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-y0]; \ 223 for (int col=x0;col<imageColLimit;col++) { \224 imageRow[col] OP overlayRow[col-x0]; \225 }\226 } \262 for (int col=x0;col<imageColLimit;col++) { \ 263 imageRow[col] OP overlayRow[col-x0]; \ 264 } \ 265 } \ 227 266 pixelsOverlaid += (imageRowLimit - y0) * (imageColLimit - x0); \ 228 }267 } 229 268 230 269 #define psImageOverlayLoopDivide(DATATYPE,BADVALUE) { \ … … 273 312 psImageOverlayLoop(DATATYPE,*=); \ 274 313 break; \ 314 case 'E': \ 315 psImageOverlayLoopClean(DATATYPE,=); \ 316 break; \ 275 317 case '/': \ 276 318 psImageOverlayLoopDivide(DATATYPE,BADVALUE); \ 277 319 break; \ 278 320 case '=': \ 279 psImageOverlaySetLoop(DATATYPE); \321 psImageOverlaySetLoop(DATATYPE); \ 280 322 break; \ 281 323 default: \ … … 286 328 } \ 287 329 break; 330 #define psImageOverlayCaseInt(DATATYPE,BADVALUE) \ 331 case PS_TYPE_##DATATYPE: \ 332 switch (*op) { \ 333 case '+': \ 334 psImageOverlayLoop(DATATYPE,+=); \ 335 break; \ 336 case '-': \ 337 psImageOverlayLoop(DATATYPE,-=); \ 338 break; \ 339 case '*': \ 340 psImageOverlayLoop(DATATYPE,*=); \ 341 break; \ 342 case 'E': \ 343 psImageOverlayLoopClean(DATATYPE,=); \ 344 break; \ 345 case 'M': \ 346 psImageOverlayLoopMask(DATATYPE); \ 347 break; \ 348 case '/': \ 349 psImageOverlayLoopDivide(DATATYPE,BADVALUE); \ 350 break; \ 351 case '=': \ 352 psImageOverlaySetLoop(DATATYPE); \ 353 break; \ 354 default: \ 355 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 356 _("Specified operation, '%s', is not supported."), \ 357 op); \ 358 return pixelsOverlaid; \ 359 } \ 360 break; 288 361 289 362 switch (type) { 290 psImageOverlayCase (U8, 0);291 psImageOverlayCase (U16,0);292 psImageOverlayCase (U32,0); // Not a requirement293 psImageOverlayCase (U64,0); // Not a requirement294 psImageOverlayCase (S8, 0);295 psImageOverlayCase (S16,0);296 psImageOverlayCase (S32,0); // Not a requirement297 psImageOverlayCase (S64,0); // Not a requirement363 psImageOverlayCaseInt(U8, 0); 364 psImageOverlayCaseInt(U16,0); 365 psImageOverlayCaseInt(U32,0); // Not a requirement 366 psImageOverlayCaseInt(U64,0); // Not a requirement 367 psImageOverlayCaseInt(S8, 0); 368 psImageOverlayCaseInt(S16,0); 369 psImageOverlayCaseInt(S32,0); // Not a requirement 370 psImageOverlayCaseInt(S64,0); // Not a requirement 298 371 psImageOverlayCase(F32,NAN); 299 372 psImageOverlayCase(F64,NAN); -
trunk/psModules
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/psModules (added) merged: 34442,34516,34623,34625-34626,34667,34772
- Property svn:mergeinfo changed
-
trunk/psModules/src/camera/pmFPABin.c
r24906 r34800 43 43 } 44 44 45 int Nbits = (int) (ceil(log(maskVal)/log(2)) + 1); 46 int *bitcounter = malloc(sizeof(int) * Nbits); 47 int pxlcount; 48 45 49 int xLast = numColsIn - 1, yLast = numRowsIn - 1; // Last index 46 50 int yStart = psImageBinningGetFineY(binning, 0); // Starting input y for binning … … 55 59 float sum = 0.0; // Sum of pixels 56 60 int numPix = 0; // Number of pixels 61 62 for (int j = 0; j < Nbits; j++) { // Reset bit counter 63 bitcounter[j] = 0; 64 } 65 pxlcount = 0; 66 57 67 for (int y = yStart; y < yStop; y++) { 58 68 for (int x = xStart; x < xStop; x++) { 69 if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] != 0)) { 70 for (int j = 0; j < Nbits; j++) { 71 psImageMaskType M = (psImageMaskType) pow(2,j); 72 if (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & M) { 73 bitcounter[j]++; 74 } 75 } 76 } 77 59 78 if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) { 60 79 continue; … … 65 84 sum += inImage->data.F32[y][x]; 66 85 numPix++; 86 87 67 88 } 68 89 } 69 90 91 70 92 // Values to set 71 93 float imageValue; … … 79 101 } 80 102 outImage->data.F32[yOut][xOut] = imageValue; 81 outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = maskValue; 103 // outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = maskValue; 104 outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = 0; 105 for (int j = 0; j < Nbits; j++) { 106 if (bitcounter[j] > 0.5 * pxlcount) { 107 outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] |= (int) pow(2,j); 108 } 109 } 82 110 xStart = xStop; 83 111 } -
trunk/psModules/src/camera/pmFPAfileIO.c
r34403 r34800 76 76 while ((item = psMetadataGetAndIncrement (iter)) != NULL) { 77 77 pmFPAfile *file = item->data.V; 78 79 78 switch (place) { 80 79 case PM_FPA_BEFORE: -
trunk/psModules/src/detrend/pmDark.c
r33089 r34800 353 353 354 354 // retrieve the required parameter vectors 355 psArray * values = psMetadataLookupPtr(&mdok, output->analysis, "DARK.VALUES");356 psAssert( values, "values not supplied");355 psArray *in_values = psMetadataLookupPtr(&mdok, output->analysis, "DARK.VALUES"); 356 psAssert(in_values, "values not supplied"); 357 357 psVector *roMask = psMetadataLookupPtr(&mdok, output->analysis, "DARK.RO.MASK"); 358 358 psAssert(roMask, "roMask not supplied"); 359 psVector *orders = psMetadataLookupPtr(&mdok, output->analysis, "DARK.ORDERS"); 360 psAssert(orders, "orders not supplied"); 361 362 psPolynomialMD *poly = psPolynomialMDAlloc(orders); // Polynomial for fitting 359 psVector *max_orders = psMetadataLookupPtr(&mdok, output->analysis, "DARK.ORDERS"); 360 psAssert(max_orders, "orders not supplied"); 361 362 psArray *values_set = psArrayAlloc(max_orders->n); 363 psArray *poly_set = psArrayAlloc(max_orders->n); 364 psVector *logL = psVectorAlloc(max_orders->n,PS_TYPE_F64); 365 366 for (int i = 0; i < max_orders->n; i++) { 367 psVector *orders = psVectorAlloc(i+1,PS_TYPE_U8); 368 for (int j = 0; j < orders->n; j++) { 369 orders->data.U8[j] = max_orders->data.U8[j]; 370 } 371 poly_set->data[i] = psPolynomialMDAlloc(orders); // Polynomial for fitting 372 373 psArray *values = psArrayAlloc(in_values->n); 374 375 for (int j = 0; j < values->n; j++) { 376 psVector *these_values = psVectorAlloc(i+1,PS_TYPE_F32); 377 psVector *input_values = in_values->data[j]; 378 379 for (int k = 0; k < orders->n; k++) { 380 these_values->data.F32[k] = input_values->data.F32[k]; 381 } 382 values->data[j] = these_values; 383 } 384 values_set->data[i] = values; 385 } 363 386 364 387 // retrieve the norm vector, if supplied … … 383 406 } 384 407 385 pmDarkVisualInit(values );408 pmDarkVisualInit(values_set->data[max_orders->n - 1]); 386 409 387 410 pmReadout *outReadout = output->readouts->data[0]; … … 423 446 } 424 447 425 if (!psPolynomialMDClipFit(poly, pixels, NULL, mask, 0xff, values, iter, rej)) { 448 int k_best = 0; 449 for (int k = 0; k < max_orders->n; k++) { 450 psPolynomialMD *poly = poly_set->data[k]; 451 psArray *values = values_set->data[k]; 452 453 if (!psPolynomialMDClipFit(poly, pixels, NULL, mask, 0xff, values, iter, rej)) { 426 454 psErrorClear(); // Nothing we can do about it 427 455 psVectorInit(poly->coeff, NAN); 428 } 429 430 pmDarkVisualPixelFit(pixels, mask); 431 pmDarkVisualPixelModel(poly, values); 432 433 for (int k = 0; k < poly->coeff->n; k++) { 456 } 457 458 pmDarkVisualPixelFit(pixels, mask); 459 pmDarkVisualPixelModel(poly, values); 460 461 // Insert math here to choose optimum model. 462 logL->data.F64[k] = 0.0; 463 psPolynomialMD *polySig = poly_set->data[0]; 464 for (int m = 0; m < poly->deviations->n; m++) { 465 logL->data.F64[k] += pow(poly->deviations->data.F32[m] / polySig->stdevFit,2); 466 /* if ((xOut == 20) && (yOut == 256)) { */ 467 /* psTrace("psModules.detrend",3,"pmDarkCombine DEV: %d %d: input %d models: Norders: %d logL: %g value: %g\n", */ 468 /* xOut,yOut,m,k,logL->data.F64[k],poly->deviations->data.F32[m]); */ 469 /* } */ 470 } 471 if (k > 0) { 472 if ( ( logL->data.F64[k - 1] - logL->data.F64[k] ) > 1) { // Hard coded criterion for a ~5% limit with one degree of freedom 473 k_best = k; 474 } 475 } 476 if ((xOut <= 600) && (yOut <= 600)) { 477 psTrace("psModules.detrend",3,"pmDarkCombine: %d %d: models: Norders: %d logL: %g BestOrders: %d\n", 478 xOut,yOut,k,logL->data.F64[k],k_best); 479 } 480 } 481 if (k_best > 1) { 482 k_best = 1; 483 } 484 /* k_best = 1; */ 485 // Select the polynomial that seems best. 486 psPolynomialMD *poly = poly_set->data[k_best]; 487 488 // for (int k = 0; k < poly->coeff->n; k++) { 489 for (int k = 0; k < max_orders->n + 1; k++) { // There is one more coefficient than is stored here. 434 490 pmReadout *ro = output->readouts->data[k]; // Readout of interest 435 ro->image->data.F32[yOut][xOut] = poly->coeff->data.F64[k]; 491 if (k < poly->coeff->n) { 492 ro->image->data.F32[yOut][xOut] = poly->coeff->data.F64[k]; 493 } 494 else { 495 ro->image->data.F32[yOut][xOut] = 0.0; 496 } 436 497 } 437 498 counts->data.U16[yOut][xOut] = poly->numFit; -
trunk/psModules/src/imcombine/pmStack.c
r34150 r34800 1358 1358 } 1359 1359 1360 bool pmStackSimpleMedianCombine( 1361 pmReadout *combined, 1362 psArray *input) { 1363 int num = input->n; 1364 // int numCols, numRows; 1365 int minInputCols, maxInputCols, minInputRows, maxInputRows; // Smallest and largest values to combine 1366 int xSize, ySize; // Size of the output image 1367 1368 psArray *stack = psArrayAlloc(num); // Stack of readouts 1369 for (int i = 0; i < num; i++) { 1370 // pmStackData *data = input->data[i]; // Stack data for this input 1371 pmReadout *ro = input->data[i]; // data->readout; // Readout of interest 1372 if (!ro) { 1373 continue; 1374 } 1375 stack->data[i] = psMemIncrRefCounter(ro); 1376 } 1377 1378 if (!pmReadoutStackValidate(&minInputCols, &maxInputCols, &minInputRows, &maxInputRows, &xSize, &ySize, 1379 stack)) { 1380 psError(psErrorCodeLast(), false, "Input stack is not valid."); 1381 psFree(stack); 1382 return false; 1383 } 1384 1385 psVector *pixelData = psVectorAlloc(input->n,PS_TYPE_F32); 1386 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); 1387 1388 for (int y = minInputRows; y < maxInputRows; y++) { 1389 for (int x = minInputCols; x < maxInputCols; x++) { 1390 for (int i = 0; i < input->n; i++) { 1391 pmReadout *ro = stack->data[i]; 1392 psImage *image = ro->image; 1393 pixelData->data.F32[i] = image->data.F32[y][x]; 1394 } 1395 if (!psVectorStats(stats,pixelData,NULL,NULL,0)) { 1396 psError(PS_ERR_UNKNOWN, false, "Unable to calculate median"); 1397 psFree(stats); 1398 psFree(pixelData); 1399 psFree(stack); 1400 return(false); 1401 } 1402 combined->image->data.F32[y][x] = stats->robustMedian; 1403 combined->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = 0; 1404 } 1405 } 1406 1407 psFree(stats); 1408 psFree(pixelData); 1409 psFree(stack); 1410 return (true); 1411 } 1412 1360 1413 /// Stack input images 1361 1414 bool pmStackCombine( -
trunk/psModules/src/imcombine/pmStack.h
r27427 r34800 41 41 float addVariance ///< Additional variance when rejecting 42 42 ); 43 /// Stack input images simply 44 bool pmStackSimpleMedianCombine(pmReadout *combined, ///< Combined readout (output) 45 psArray *input ///< Input array of pmStackData 46 ); 43 47 44 48 /// Stack input images -
trunk/psModules/src/objects/Makefile.am
r34403 r34800 111 111 pmSourceOutputs.h \ 112 112 pmSourceIO.h \ 113 pmSourceSatstar.h \ 113 114 pmSourcePlots.h \ 114 115 pmSourceVisual.h \ -
trunk/psModules/src/objects/pmFootprintCullPeaks.c
r34198 r34800 91 91 92 92 // max flux is above threshold for brightest peak 93 pmPeak *maxPeak = fp->peaks->data[0]; 93 pmPeak *maxPeak = NULL; 94 for (int i = 0; i < fp->peaks->n; i++) { 95 pmPeak *testPeak = fp->peaks->data[i]; 96 float this_peak = useSmoothedImage ? testPeak->smoothFlux : testPeak->rawFlux; 97 98 if (isfinite(this_peak)) { 99 maxPeak = fp->peaks->data[i]; 100 break; 101 } 102 } 103 psAssert(maxPeak,"maxPeak was not set in these peaks"); 104 // = fp->peaks->data[0]; 94 105 float maxFlux = useSmoothedImage ? maxPeak->smoothFlux : maxPeak->rawFlux; 95 106 -
trunk/psphot
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/psphot (added) merged: 34772,34786
- Property svn:mergeinfo changed
-
trunk/psphot/src
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/psphot/src (added) merged: 34772,34786 /trunk/psphot/src (added) merged: 2-4113
- Property svn:mergeinfo changed
-
trunk/psphot/src/psphotStackImageLoop.c
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/psphot/src/psphotStackImageLoop.c (added) merged: 34772,34786 /trunk/psphot/src/psphotStackImageLoop.c merged: 2-26885
- Property svn:mergeinfo changed
-
trunk/pstamp/scripts
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/pstamp/scripts (added) merged: 34772
- Property svn:mergeinfo changed
-
trunk/psvideophot
- Property svn:mergeinfo changed
/branches/czw_branch/20120906/psvideophot (added) merged: 34772
- Property svn:mergeinfo changed
-
trunk/pswarp/src/pswarp.c
r27904 r34800 46 46 goto DIE; 47 47 } 48 if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND.MODEL")) { 49 if (!pswarpDefineBackground(config)) { 50 goto DIE; 51 } 52 } 48 53 49 54 // Open the statistics file … … 66 71 if (!pswarpLoop(config, stats)) { 67 72 goto DIE; 73 } 74 if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND.MODEL")) { 75 if (!pswarpLoopBackground(config, stats)) { 76 fprintf(stderr,"Dying!\n"); 77 goto DIE; 78 } 68 79 } 69 80 -
trunk/pswarp/src/pswarp.h
r28043 r34800 62 62 psImage *region; 63 63 64 /** values which are needed to control the background model warping. */ 65 bool background_warping; 66 double offset_x; 67 double offset_y; 68 64 69 /** input values for this tile */ 65 70 int gridX; … … 81 86 bool pswarpParseCamera (pmConfig *config); 82 87 bool pswarpDefine (pmConfig *config); 88 bool pswarpDefineBackground (pmConfig *config); 83 89 bool pswarpLoop (pmConfig *config, psMetadata *stats); 90 bool pswarpLoopBackground (pmConfig *config, psMetadata *stats); 84 91 psExit pswarpExitCode(psExit exitValue); 85 92 bool pswarpTransformReadout (pmReadout *output, pmReadout *input, pmConfig *config); -
trunk/pswarp/src/pswarpArguments.c
r34089 r34800 86 86 pmConfigFileSetsMD (config->arguments, &argc, argv, "MASK", "-mask", "-masklist"); 87 87 pmConfigFileSetsMD (config->arguments, &argc, argv, "VARIANCE", "-variance", "-variancelist"); 88 88 pmConfigFileSetsMD (config->arguments, &argc, argv, "BACKGROUND", "-background", "-bkglist"); 89 89 90 if (argc != 3) { 90 91 usage(); … … 164 165 } 165 166 167 bool doBKG = psMetadataLookupBool(&status,recipe, "BACKGROUND.MODEL"); ///< Generate the warped background model? 168 if (!status) { 169 doBKG = false; 170 psWarning("BACKGROUND.MODEL is not set in the %s recipe -- defaulting to FALSE.", PSWARP_RECIPE); 171 } 172 int bkgXgrid = psMetadataLookupS32(&status,recipe, "BKG.XGRID"); ///< Xsize of background model 173 if (!status) { 174 bkgXgrid = 10; 175 psWarning("BKG.XGRID is not set in the %s recipe -- defaultint to %d.",PSWARP_RECIPE,bkgXgrid); 176 } 177 int bkgYgrid = psMetadataLookupS32(&status,recipe, "BKG.YGRID"); ///< Xsize of background model 178 if (!status) { 179 bkgYgrid = 10; 180 psWarning("BKG.YGRID is not set in the %s recipe -- defaultint to %d.",PSWARP_RECIPE,bkgYgrid); 181 } 182 183 166 184 // Set recipe values in the recipe (since we've possibly altered some) 167 185 psMetadataAddS32(recipe, PS_LIST_TAIL, "GRID.NX", PS_META_REPLACE, … … 176 194 "Fraction of bad flux for a pixel to be marked as poor", poorFrac); 177 195 psMetadataAddBool(recipe, PS_LIST_TAIL, "PSF", PS_META_REPLACE, "Generate a PSF Model?", PSF); 178 196 psMetadataAddBool(recipe, PS_LIST_TAIL, "BACKGROUND.MODEL", PS_META_REPLACE, "Generate the warped background model?", doBKG); 197 psMetadataAddS32(recipe, PS_LIST_TAIL, "BKG.XGRID", PS_META_REPLACE, "Xsize of background model", bkgXgrid); 198 psMetadataAddS32(recipe, PS_LIST_TAIL, "BKG.YGRID", PS_META_REPLACE, "Ysize of background model", bkgYgrid); 199 200 179 201 // Set recipe values in the arguments 180 202 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "GRID.NX", 0, … … 189 211 "Fraction of bad flux for a pixel to be marked as poor", poorFrac); 190 212 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "PSF", PS_META_REPLACE, "Generate a PSF Model?", PSF); 213 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "BACKGROUND.MODEL", PS_META_REPLACE, "Generate the warped background model?", doBKG); 214 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "BKG.XGRID", PS_META_REPLACE, "Xsize of background model", bkgXgrid); 215 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "BKG.YGRID", PS_META_REPLACE, "Ysize of background model", bkgYgrid); 191 216 192 217 psTrace("pswarp", 1, "Done with pswarpArguments...\n"); -
trunk/pswarp/src/pswarpDefine.c
r27989 r34800 41 41 return false; 42 42 } 43 43 44 44 // open the full skycell file; no need to defer different depths. only load the header data 45 45 pmFPAview *view = pmFPAviewAlloc (0); … … 86 86 psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.X0"); 87 87 psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.Y0"); 88 89 88 90 } 89 91 … … 123 125 } 124 126 } 125 127 126 128 view->chip = view->cell = view->readout = -1; 127 129 pmFPAAddSourceFromView(output->fpa, view, output->format); 130 128 131 129 132 psFree (view); 130 133 return true; 131 134 } 135 136 bool pswarpDefineBackground (pmConfig *config) { 137 138 // load the PSWARP recipe 139 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSWARP_RECIPE); 140 if (!recipe) { 141 psError(PSWARP_ERR_CONFIG, true, "Can't find PSWARP recipe!\n"); 142 return false; 143 } 144 145 // select the input data sources 146 pmFPAfile *skycell = psMetadataLookupPtr (NULL, config->files, "PSWARP.SKYCELL"); 147 if (!skycell) { 148 psError(PSWARP_ERR_CONFIG, false, "Can't find skycell data!\n"); 149 return false; 150 } 151 pmFPAfile *output = psMetadataLookupPtr(NULL, config->files, "PSWARP.OUTPUT.BKGMODEL"); 152 if (!output) { 153 psError(PSWARP_ERR_CONFIG, false, "Can't find output data!\n"); 154 return false; 155 } 156 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PSWARP.INPUT"); 157 if (!input) { 158 psError(PSWARP_ERR_CONFIG, false, "Can't find input data!\n"); 159 return false; 160 } 161 162 // open the full skycell file; no need to defer different depths. only load the header data 163 pmFPAview *view = pmFPAviewAlloc (0); 164 pmFPAfileOpen (skycell, view, config); 165 166 // Read header and create target 167 { 168 if (!pmFPAReadHeaderSet(skycell->fpa, skycell->fits, config)) { 169 psError(psErrorCodeLast(), false, "Unable to read headers for skycell."); 170 psFree(view); 171 return false; 172 } 173 view->chip = 0; 174 view->cell = 0; 175 view->readout = 0; 176 pmCell *source = pmFPAfileThisCell(config->files, view, "PSWARP.SKYCELL"); ///< Source cell 177 pmHDU *hdu = pmHDUFromCell(source); ///< HDU for source 178 if (!hdu || !hdu->header) { 179 psError(PM_ERR_PROG, false, "Unable to find header for sky cell."); 180 psFree(view); 181 return false; 182 } 183 int numCols = psMetadataLookupS32(NULL, hdu->header, "NAXIS1"); ///< Number of columns 184 int numRows = psMetadataLookupS32(NULL, hdu->header, "NAXIS2"); ///< Number of rows 185 if ((numCols == 0) || (numRows == 0)) { 186 psError(PSWARP_ERR_DATA, false, "skycell has invalid dimensions %d x %d", numCols, numRows); 187 psFree(view); 188 return false; 189 } 190 191 pmCell *target = pmFPAviewThisCell(view, output->fpa); ///< Target cell 192 pmReadout *readout = pmReadoutAlloc(target); ///< Target readout 193 readout->image = psImageAlloc(numCols / output->xBin, numRows / output->yBin, PS_TYPE_F32); 194 psImageInit(readout->image, NAN); 195 psFree(readout); // Drop reference 196 197 bool status = false; 198 psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XBIN"); 199 psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YBIN"); 200 /* psMetadataAddS32(target->concepts,PS_LIST_TAIL,"CELL.XBIN",PS_META_REPLACE,"",output->xBin); */ 201 /* psMetadataAddS32(target->concepts,PS_LIST_TAIL,"CELL.YBIN",PS_META_REPLACE,"",output->yBin); */ 202 psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XSIZE"); 203 psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YSIZE"); 204 /* psMetadataAddS32(target->concepts,PS_LIST_TAIL,"CELL.XSIZE",PS_META_REPLACE,"",numCols / output->xBin); */ 205 /* psMetadataAddS32(target->concepts,PS_LIST_TAIL,"CELL.YSIZE",PS_META_REPLACE,"",numRows / output->yBin); */ 206 psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XPARITY"); 207 psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YPARITY"); 208 psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.X0"); 209 psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.Y0"); 210 211 212 } 213 214 // XXX this is not a sufficient test 215 view->chip = 0; 216 view->cell = 0; 217 view->readout = -1; 218 pmHDU *phu = pmFPAviewThisPHU(view, skycell->fpa); ///< Skycell PHU 219 pmHDU *hdu = pmFPAviewThisHDU(view, skycell->fpa); ///< Skycell header 220 221 pmAstromWCS *WCS = pmAstromWCSfromHeader(hdu->header); 222 223 double cd1f = 1.0 * output->xBin; 224 double cd2f = 1.0 * output->yBin; 225 226 WCS->crpix1 = WCS->crpix1 / cd1f; 227 WCS->crpix2 = WCS->crpix2 / cd2f; 228 229 WCS->cdelt1 *= cd1f; 230 WCS->cdelt2 *= cd2f; 231 232 WCS->trans->x->coeff[1][0] *= cd1f; 233 WCS->trans->x->coeff[0][1] *= cd2f; 234 WCS->trans->y->coeff[1][0] *= cd1f; 235 WCS->trans->y->coeff[0][1] *= cd2f; 236 237 238 pmAstromWCStoHeader (hdu->header,WCS); 239 240 bool bilevelAstrometry = false; 241 if (phu) { 242 char *ctype = psMetadataLookupStr(NULL, phu->header, "CTYPE1"); 243 if (ctype) { 244 bilevelAstrometry = !strcmp(&ctype[4], "-DIS"); 245 } 246 } 247 248 // We read from the skycell into the output. i.e., the output receives the desired astrometry. 249 pmChip *outputChip = pmFPAviewThisChip(view, output->fpa); ///< Chip in the output 250 if (bilevelAstrometry) { 251 if (!pmAstromReadBilevelMosaic(output->fpa, phu->header)) { 252 psError(psErrorCodeLast(), false, "Unable to read bilevel mosaic astrometry for skycell."); 253 psFree(view); 254 return false; 255 } 256 if (!pmAstromReadBilevelChip(outputChip, hdu->header)) { 257 psError(psErrorCodeLast(), false, "Unable to read bilevel chip astrometry for skycell."); 258 psFree(view); 259 return false; 260 } 261 } else { 262 // we use a default FPA pixel scale of 1.0 263 if (!pmAstromReadWCS(output->fpa, outputChip, hdu->header, 1.0)) { 264 psError(psErrorCodeLast(), false, "Unable to read WCS astrometry for skycell."); 265 psFree(view); 266 return false; 267 } 268 } 269 270 271 view->chip = view->cell = view->readout = -1; 272 pmFPAAddSourceFromView(output->fpa, view, output->format); 273 274 275 psFree (view); 276 return true; 277 } -
trunk/pswarp/src/pswarpFileNames.h
r21368 r34800 12 12 "PSWARP.MASK", 13 13 "PSWARP.VARIANCE", 14 "PSWARP.BKGMODEL", 14 15 NULL 15 16 }; … … 20 21 "PSWARP.OUTPUT.MASK", 21 22 "PSWARP.OUTPUT.VARIANCE", 23 "PSWARP.OUTPUT.BKGMODEL", 22 24 NULL 23 25 }; -
trunk/pswarp/src/pswarpLoop.c
r29928 r34800 179 179 // read WCS data from the corresponding header 180 180 pmHDU *hdu = pmFPAviewThisHDU (view, astrom->fpa); 181 182 181 183 if (bilevelAstrometry) { 182 184 if (!pmAstromReadBilevelChip (chip, hdu->header)) { … … 195 197 } 196 198 } 197 199 198 200 pmCell *cell; 199 201 while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) { … … 227 229 228 230 pswarpTransformReadout(output, readout, config); 229 231 230 232 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 231 233 psError(psErrorCodeLast(), false, "Unable to write files."); … … 255 257 goto DONE; 256 258 } 257 259 258 260 pmCell *outCell = output->parent; ///< Output cell 259 261 pmChip *outChip = outCell->parent; ///< Output chip … … 450 452 return true; 451 453 } 454 455 // Loop over the inputs, warp them to the output skycell and then write out the output. 456 bool pswarpLoopBackground(pmConfig *config, psMetadata *stats) 457 { 458 bool status; 459 bool mdok; // Status of MD lookup 460 const char *skyCamera = psMetadataLookupStr(NULL, config->arguments, 461 "SKYCELL.CAMERA"); // Name of camera for skycell 462 pmConfigCamerasCull(config, skyCamera); 463 pmConfigRecipesCull(config, "PSWARP,PPSTATS,PSPHOT,PSASTRO,MASKS,JPEG"); 464 465 // load the recipe 466 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSWARP_RECIPE); 467 if (!recipe) { 468 psError(PSWARP_ERR_CONFIG, false, "missing recipe %s", PSWARP_RECIPE); 469 return false; 470 } 471 472 if (!pswarpSetMaskBits(config)) { 473 psError(psErrorCodeLast(), false, "failed to set mask bits"); 474 return NULL; 475 } 476 477 // select the input data sources 478 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PSWARP.BKGMODEL"); 479 if (!input) { 480 psError(PSWARP_ERR_CONFIG, true, "Can't find input data!\n"); 481 return false; 482 } 483 484 // use the external astrometry source if supplied 485 pmFPAfile *astrom = psMetadataLookupPtr(NULL, config->files, "PSWARP.ASTROM"); 486 if (!astrom) { 487 astrom = input; 488 } 489 490 if (astrom->camera != input->camera) { 491 psError(PSWARP_ERR_DATA, true, "Input camera and astrometry camera do not match."); 492 return false; 493 } 494 495 // select the output readout 496 pmFPAview *view = pmFPAviewAlloc(0); 497 view->chip = 0; 498 view->cell = 0; 499 view->readout = 0; 500 pmReadout *output = pmFPAfileThisReadout(config->files, view, "PSWARP.OUTPUT.BKGMODEL"); 501 if (!output) { 502 psError(PSWARP_ERR_CONFIG, true, "Can't find output background data!\n"); 503 return false; 504 } 505 psFree (view); 506 // Turn all skycell files on to generate them, and then turn them off for the loop over the input images 507 // the input, which is in a different format. 508 { 509 pswarpFileActivation(config, detectorFiles, false); 510 pswarpFileActivation(config, photFiles, false); 511 pswarpFileActivation(config, independentFiles, false); 512 pswarpFileActivation(config, skycellFiles, true); 513 if (!pswarpIOChecksBefore(config)) { 514 psError(psErrorCodeLast(), false, "Unable to read files."); 515 goto DONE; 516 } 517 pswarpFileActivation(config, skycellFiles, false); 518 } 519 // Read the input astrometry 520 // XXX rather than use the activations here, this should just explicitly loop over the desired filerule 521 { 522 523 pmFPAfileActivate(config->files, true, "PSWARP.ASTROM"); 524 525 pmChip *chip; 526 pmFPAview *view = pmFPAviewAlloc(0); 527 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 528 psError(psErrorCodeLast(), false, "Unable to read files."); 529 goto DONE; 530 } 531 532 while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) { 533 #if 0 534 // This needs to be removed because otherwise it throws an error of duplicate PSPHOT.DETECTIONS. 535 if (!chip->process || !chip->file_exists) { continue; } 536 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 537 psError(psErrorCodeLast(), false, "Unable to read files."); 538 goto DONE; 539 } 540 #endif 541 pmCell *cell; 542 while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) { 543 psTrace ("pswarp", 4, "ACell %d: %x %x %d\n", view->cell, cell->file_exists, cell->process,psErrorCodeLast()); 544 if (!cell->process || !cell->file_exists) { continue; } 545 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE) || 546 !pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { 547 psError(psErrorCodeLast(), false, "Unable to read files."); 548 goto DONE; 549 } 550 } 551 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { 552 psError(psErrorCodeLast(), false, "Unable to write files."); 553 goto DONE; 554 } 555 } 556 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { 557 psError(psErrorCodeLast(), false, "Unable to write files."); 558 goto DONE; 559 } 560 psFree(view); 561 pswarpFileActivation(config, detectorFiles, true); 562 pmFPAfileActivate(config->files, false, "PSWARP.ASTROM"); 563 } 564 565 // Don't care about the skycell anymore --- we've read it, and that's all we need to do. 566 pmFPAfileActivate(config->files, false, "PSWARP.SKYCELL"); 567 view = pmFPAviewAlloc(0); 568 569 // find the FPA phu 570 bool bilevelAstrometry = false; 571 pmHDU *phu = pmFPAviewThisPHU(view, astrom->fpa); 572 573 // pmAstromWCS *WCSF = pmAstromWCSfromHeader(phu->header); 574 575 if (phu) { 576 char *ctype = psMetadataLookupStr(NULL, phu->header, "CTYPE1"); 577 if (ctype) { 578 bilevelAstrometry = !strcmp (&ctype[4], "-DIS"); 579 } 580 } 581 if (bilevelAstrometry) { 582 if (!pmAstromReadBilevelMosaic(input->fpa, phu->header)) { 583 psError(psErrorCodeLast(), false, "Unable to read bilevel mosaic astrometry for input FPA."); 584 psFree(view); 585 psFree(stats); 586 goto DONE; 587 } 588 } 589 590 psList *cells = psListAlloc(NULL); // List of cells, for concepts averaging 591 592 // files associated with the science image 593 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 594 psError(psErrorCodeLast(), false, "Unable to read files."); 595 goto DONE; 596 } 597 pmChip *chip; 598 while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) { 599 psTrace ("pswarp", 4, "DChip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 600 if (!chip->process || !chip->file_exists) { continue; } 601 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 602 psError(psErrorCodeLast(), false, "Unable to read files."); 603 goto DONE; 604 } 605 606 // Pull information from the header of the background files so we can use it to set values. 607 pmHDU *hdu = pmFPAviewThisHDU(view,input->fpa); 608 psMetadata *header = hdu->header; 609 610 int IMAXIS1 = psMetadataLookupS32(NULL,header,"IMNAXIS1"); 611 int IMAXIS2 = psMetadataLookupS32(NULL,header,"IMNAXIS2"); 612 int NAXIS1 = psMetadataLookupS32(NULL,header,"NAXIS1"); 613 int NAXIS2 = psMetadataLookupS32(NULL,header,"NAXIS2"); 614 char *CCDSUM = psMetadataLookupStr(NULL,header,"CCDSUM"); 615 int CCDSUM1 = atoi(strtok(CCDSUM," ")); 616 int CCDSUM2 = atoi(strtok(NULL," ")); 617 618 psMetadataAddF32(config->arguments,PS_LIST_TAIL,"BKG_WARP_XOFFSET", PS_META_REPLACE, 619 "xoffset for background model data", (NAXIS1 * CCDSUM1 - IMAXIS1) / (2.0 * CCDSUM1)); 620 psMetadataAddF32(config->arguments,PS_LIST_TAIL,"BKG_WARP_YOFFSET", PS_META_REPLACE, 621 "yoffset for background model data", (NAXIS2 * CCDSUM2 - IMAXIS2) / (2.0 * CCDSUM2)); 622 psTrace("pswarp",5,"%d %d %d %d %d %d %g %g %d %d", 623 psMetadataLookupS32(NULL,header,"IMNAXIS1"), 624 psMetadataLookupS32(NULL,header,"IMNAXIS2"), 625 psMetadataLookupS32(NULL,header,"NAXIS1"), 626 psMetadataLookupS32(NULL,header,"NAXIS2"), 627 CCDSUM1,CCDSUM2, 628 psMetadataLookupF32(NULL,config->arguments,"BKG_WARP_XOFFSET"), 629 psMetadataLookupF32(NULL,config->arguments,"BKG_WARP_YOFFSET"), 630 psMetadataLookupS32(NULL,config->arguments,"BKG.XGRID"), 631 psMetadataLookupS32(NULL,config->arguments,"BKG.YGRID")); 632 633 634 // read WCS data from the corresponding header 635 hdu = pmFPAviewThisHDU (view, astrom->fpa); 636 637 pmAstromWCS *WCS = pmAstromWCSfromHeader(hdu->header); 638 639 double cd1f = (1.0 * CCDSUM1);// * (1.0 * psMetadataLookupS32(NULL,config->arguments,"BKG.XGRID")); 640 double cd2f = (1.0 * CCDSUM2);// * (1.0 * psMetadataLookupS32(NULL,config->arguments,"BKG.YGRID")); 641 642 WCS->cdelt1 *= cd1f; 643 WCS->cdelt2 *= cd2f; 644 WCS->crpix1 = WCS->crpix1 / cd1f; 645 WCS->crpix2 = WCS->crpix2 / cd2f; 646 647 // WCS->trans->x->nX/nY 648 for (int q = 0; q <= WCS->trans->x->nX; q++) { 649 for (int r = 0; r <= WCS->trans->x->nY; r++) { 650 WCS->trans->x->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r); 651 } 652 } 653 for (int q = 0; q <= WCS->trans->y->nX; q++) { 654 for (int r = 0; r <= WCS->trans->y->nY; r++) { 655 WCS->trans->y->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r); 656 } 657 } 658 pmAstromWCStoHeader (hdu->header,WCS); 659 660 if (bilevelAstrometry) { 661 if (!pmAstromReadBilevelChip (chip, hdu->header)) { 662 psError(psErrorCodeLast(), false, "Unable to read bilevel chip astrometry for input FPA."); 663 psFree(view); 664 psFree(stats); 665 goto DONE; 666 } 667 } else { 668 // we use a default FPA pixel scale of 1.0 669 if (!pmAstromReadWCS (astrom->fpa, chip, hdu->header, 1.0)) { 670 psError(psErrorCodeLast(), false, "Unable to read WCS astrometry for input FPA."); 671 psFree(view); 672 psFree(stats); 673 goto DONE; 674 } 675 } 676 // Modify structure here. 677 678 679 pmCell *cell; 680 while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) { 681 psTrace ("pswarp", 4, "DCell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 682 if (!cell->process || !cell->file_exists) { continue; } 683 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 684 psError(psErrorCodeLast(), false, "Unable to read files."); 685 goto DONE; 686 } 687 688 psListAdd(cells, PS_LIST_TAIL, cell); 689 690 // process each of the readouts 691 pmReadout *readout; 692 while ((readout = pmFPAviewNextReadout(view, input->fpa, 1)) != NULL) { 693 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 694 psError(psErrorCodeLast(), false, "Unable to read files."); 695 goto DONE; 696 } 697 if (!readout->data_exists) { 698 continue; 699 } 700 701 for (int x = 0; x < readout->image->numCols; x++) { 702 for (int y = 0; y < readout->image->numRows; y++) { 703 readout->image->data.F32[y][x] = readout->image->data.F32[y][x] * (cd1f * cd2f) / 704 (psMetadataLookupS32(&mdok,config->arguments,"BKG.XGRID") * 705 psMetadataLookupS32(&mdok,config->arguments,"BKG.YGRID")); 706 } 707 } 708 709 psMetadataAddS32(config->arguments,PS_LIST_TAIL, "INTERPOLATION.MODE", PS_META_REPLACE, "", 8); 710 711 psMetadataAddBool(config->arguments,PS_LIST_TAIL, "BACKGROUND_WARPING", PS_META_REPLACE, "", true); 712 pswarpTransformReadout(output, readout, config); 713 psMetadataAddBool(config->arguments,PS_LIST_TAIL, "BACKGROUND_WARPING", PS_META_REPLACE, "", false); 714 715 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 716 psError(psErrorCodeLast(), false, "Unable to write files."); 717 goto DONE; 718 } 719 } 720 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 721 psError(psErrorCodeLast(), false, "Unable to write files."); 722 goto DONE; 723 } 724 } 725 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 726 psError(psErrorCodeLast(), false, "Unable to write files."); 727 goto DONE; 728 } 729 } 730 if (!output->data_exists) { 731 psWarning("No overlap between input and skycell."); 732 psphotFilesActivate(config, false); 733 psFree(cells); 734 psFree(view); 735 goto DONE; 736 } 737 pmCell *outCell = output->parent; ///< Output cell 738 pmChip *outChip = outCell->parent; ///< Output chip 739 pmFPA *outFPA = outChip->parent; ///< Output FP 740 741 /* if (!pswarpPixelsLit(output, stats, config)) { */ 742 /* psError(psErrorCodeLast(), false, "Unable to calculate pixel regions."); */ 743 /* psFree(cells); */ 744 /* psFree(view); */ 745 /* goto DONE; */ 746 /* } */ 747 psRegion *trimsec = psMetadataLookupPtr(NULL, outCell->concepts, "CELL.TRIMSEC"); ///< Trim section 748 trimsec->x0 = trimsec->x1 = trimsec->y0 = trimsec->y1 = 0; ///< All pixels 749 750 if (!psMetadataCopy(outFPA->concepts, input->fpa->concepts)) { 751 psError(psErrorCodeLast(), false, "Unable to copy FPA concepts from input to output."); 752 psFree(stats); 753 psFree(view); 754 goto DONE; 755 } 756 757 pmHDU *hdu = outFPA->hdu; ///< HDU for the output warped image 758 759 // Copy header from target 760 { 761 pmFPAview *skyView = pmFPAviewAlloc(0); ///< View into skycell 762 skyView->chip = skyView->cell = 0; 763 pmCell *cell = pmFPAfileThisCell(config->files, skyView, "PSWARP.SKYCELL"); // Skycell cell 764 psFree(skyView); 765 pmHDU *skyHDU = pmHDUFromCell(cell); ///< HDU 766 if (!skyHDU) { 767 psError(PSWARP_ERR_DATA, false, "Unable to find skycell HDU."); 768 psFree(view); 769 goto DONE; 770 } 771 hdu->header = psMetadataCopy(hdu->header, skyHDU->header); 772 } 773 pswarpVersionHeader(hdu->header); 774 775 if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) { 776 psError(psErrorCodeLast(), false, "Unable to generate WCS header."); 777 psFree(stats); 778 goto DONE; 779 } 780 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 781 psError(psErrorCodeLast(), false, "Unable to write files."); 782 goto DONE; 783 } 784 // Done with the detector side of things 785 pswarpFileActivation(config, detectorFiles, false); 786 pswarpFileActivation(config, independentFiles, false); 787 788 789 // Add MD5 information for readout 790 const char *chipName = psMetadataLookupStr(NULL, output->parent->parent->concepts, "CHIP.NAME"); 791 const char *cellName = psMetadataLookupStr(NULL, output->parent->concepts, "CELL.NAME"); 792 psString headerName = NULL; ///< Header name for MD5 793 psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, view->readout); 794 psVector *md5 = psImageMD5(output->image); ///< md5 hash 795 psString md5string = psMD5toString(md5); ///< String 796 psFree(md5); 797 psMetadataAddStr(hdu->header, PS_LIST_TAIL, headerName, PS_META_REPLACE, 798 "Image MD5", md5string); 799 psFree(md5string); 800 psFree(headerName); 801 psFree(view); 802 DONE: 803 804 return true; 805 } -
trunk/pswarp/src/pswarpParseCamera.c
r28442 r34800 84 84 } 85 85 86 pmFPAfile *inBackground = defineInputFile(config, NULL, "PSWARP.BKGMODEL", "BACKGROUND", 87 PM_FPA_FILE_IMAGE); 88 if (!inBackground) { 89 psLogMsg("pswarp", PS_LOG_INFO, "No background models supplied"); 90 } 91 86 92 // The input skycell is a required argument: it defines the output image 87 93 // XXX we may need a different skycell structure here … … 134 140 } 135 141 142 if (inBackground && psMetadataLookupBool(&mdok, recipe, "BACKGROUND.MODEL")) { 143 pmFPAfile *outBackground = pmFPAfileDefineSkycell(config, NULL, "PSWARP.OUTPUT.BKGMODEL"); 144 /* pmFPAfile *outBackground = pmFPAfileDefineFromFPA(config,output->fpa, */ 145 /* psMetadataLookupS32(&mdok,recipe,"BKG.XGRID"), */ 146 /* psMetadataLookupS32(&mdok,recipe,"BKG.YGRID"), */ 147 /* "PSWARP.OUTPUT.BKGMODEL"); */ 148 outBackground->xBin = psMetadataLookupS32(&mdok, recipe, "BKG.XGRID"); 149 outBackground->yBin = psMetadataLookupS32(&mdok, recipe, "BKG.YGRID"); 150 151 if (!outBackground) { 152 psError(psErrorCodeLast(), false, "Failed to build FPA from PSWARP.OUTPUT.BKGMODEL"); 153 return false; 154 } 155 outBackground->save = true; 156 } 157 136 158 if (psMetadataLookupBool(&mdok, recipe, "PSF")) { 137 159 // This file, PSPHOT.INPUT, is just used as a carrier; output files (eg, PSPHOT.RESID) are defined by -
trunk/pswarp/src/pswarpTransformReadout.c
r34089 r34800 29 29 psImageInterpolateMode interpolationMode = psMetadataLookupS32(NULL, config->arguments, 30 30 "INTERPOLATION.MODE"); ///< Mode for interp 31 31 32 int numKernels = psMetadataLookupS32(NULL, config->arguments, "INTERPOLATION.NUM"); ///< Number of kernels 32 33 … … 60 61 // output coordinates to input coordinates 61 62 pswarpMapGrid *grid = pswarpMapGridFromImage(input, output, nGridX, nGridY); 62 63 // if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND_WARPING")) { 64 63 65 // XXX optionally modify the grid based on this result and force the maxError < XXX 64 66 double maxError = pswarpMapGridMaxError(grid); // Maximum (positional) error from using grid … … 130 132 args->goodPixels = 0; 131 133 134 if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND_WARPING")) { 135 args->background_warping = true; 136 args->offset_x = psMetadataLookupF32(NULL,config->arguments,"BKG_WARP_XOFFSET"); 137 args->offset_y = psMetadataLookupF32(NULL,config->arguments,"BKG_WARP_YOFFSET"); 138 } 139 140 132 141 // allocate a job 133 142 psThreadJob *job = psThreadJobAlloc ("PSWARP_TRANSFORM_TILE"); … … 171 180 } else { 172 181 pswarpTransformTileArgs *args = job->args->data[0]; 173 // fprintf (stderr, "finished job %d,%d, Nargs: %ld\n", args->gridX, args->gridY, job->args->n);174 182 goodPixels += args->goodPixels; 175 183 xMin = PS_MIN(args->xMin, xMin); … … 183 191 jacobian += args->jacobian * args->goodPixels; 184 192 } 193 194 185 195 } 186 196 psFree(job); … … 201 211 202 212 if (goodPixels > 0 && psMetadataLookupBool(&mdok, recipe, "SOURCES")) { 213 if (!psMetadataLookupBool(NULL,config->arguments,"BACKGROUND_WARPING")) { 203 214 if (!pswarpTransformSources(output, input, config)) { 204 psError(psErrorCodeLast(), false, "Unable to interpolate image.");205 return false;215 psError(psErrorCodeLast(), false, "Unable to interpolate image."); 216 return false; 206 217 } 218 } 207 219 } 208 220 -
trunk/pswarp/src/pswarpTransformSources.c
r32351 r34800 41 41 if (!outDetections) { 42 42 outDetections = pmDetectionsAlloc(); 43 psMetadataAddPtr(output->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_ARRAY, "Warped sources", outDetections);43 psMetadataAddPtr(output->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_ARRAY , "Warped sources", outDetections); 44 44 } 45 45 psArray *outSources = outDetections->allSources; -
trunk/pswarp/src/pswarpTransformTile.c
r29331 r34800 46 46 args->jacobian = NAN; 47 47 48 args->background_warping = false; 49 args->offset_x = 0.0; 50 args->offset_y = 0.0; 51 48 52 return args; 49 53 } … … 83 87 // Iterate over the output image pixels (parent frame) 84 88 long goodPixels = 0; ///< Number of input pixels landing on the output image 89 85 90 for (int y = yMin; y < yMax; y++) { 86 91 for (int x = xMin; x < xMax; x++) { 87 88 92 // Only transform those pixels requested 89 93 if (region && region->data.PS_TYPE_IMAGE_MASK_DATA[y][x]) { 90 94 continue; 91 95 } 92 93 96 // pswarpMapApply converts the output coordinate (x,y) to the input coordinate. 94 97 // both are in the parent frames of the input and output images. 95 98 double xIn, yIn; // Input pixel coordinates 96 99 pswarpMapApply(&xIn, &yIn, map, x + 0.5, y + 0.5); 100 101 // This needs to use a more reliable method to do this offset and limiting 102 // if (args->interp->mode == 8) { 103 if (args->background_warping) { 104 // double xOffset = 177.0 / 400.0; // (modelsize * modelbinning - xsize) / 2.0 105 // double yOffset = 166.0 / 400.0; // (modelsize * modelbinning - ysize) / 2.0 106 xIn += args->offset_x; 107 yIn += args->offset_y; 108 109 if ((xIn > inNumCols - args->offset_x)|| 110 (yIn > inNumRows - args->offset_y)|| 111 (xIn < args->offset_x)|| 112 (yIn < args->offset_y)) { 113 continue; 114 } 115 } 116 97 117 if (xIn < 0 || xIn >= inNumCols || yIn < 0 || yIn >= inNumRows) { 98 118 continue;
Note:
See TracChangeset
for help on using the changeset viewer.
