Changeset 25051
- Timestamp:
- Aug 11, 2009, 3:54:00 PM (17 years ago)
- Location:
- branches/czw_branch/cleanup
- Files:
-
- 100 edited
- 50 copied
-
. (modified) (1 prop)
-
Nebulous-Server/Changes (modified) (1 diff)
-
Nebulous-Server/lib/Nebulous/Server.pm (modified) (3 diffs)
-
Nebulous-Server/lib/Nebulous/Server/Config.pm (modified) (3 diffs)
-
Nebulous-Server/t/05_server_replicate_object.t (modified) (1 diff)
-
Nebulous-Server/t/09_server_delete_instance.t (modified) (1 diff)
-
Nebulous/Changes (modified) (1 diff)
-
Nebulous/MANIFEST (modified) (1 diff)
-
Nebulous/bin/neb-cull (modified) (6 diffs)
-
Nebulous/lib/Nebulous/Client.pm (modified) (8 diffs)
-
Nebulous/nebclient/configure.ac (modified) (1 diff)
-
Nebulous/nebclient/src/nebclient.c (modified) (58 diffs)
-
Nebulous/nebclient/src/nebclient.h (modified) (1 diff)
-
Nebulous/nebclient/tests/tests.c (modified) (1 diff)
-
Nebulous/t/72_neb-cull.t (copied) (copied from trunk/Nebulous/t/72_neb-cull.t )
-
Ohana/src/addstar/Makefile (modified) (2 diffs)
-
Ohana/src/addstar/doc/notes.txt (modified) (1 diff)
-
Ohana/src/addstar/include/2mass.h (modified) (1 diff)
-
Ohana/src/addstar/include/addstar.h (modified) (3 diffs)
-
Ohana/src/addstar/src/ConfigInit.c (modified) (1 diff)
-
Ohana/src/addstar/src/GetZeroPointExposure.c (copied) (copied from trunk/Ohana/src/addstar/src/GetZeroPointExposure.c )
-
Ohana/src/addstar/src/LoadData.c (modified) (1 diff)
-
Ohana/src/addstar/src/ReadImageHeader.c (modified) (4 diffs)
-
Ohana/src/addstar/src/SkyRegionUtils.c (modified) (2 diffs)
-
Ohana/src/addstar/src/args.c (modified) (1 diff)
-
Ohana/src/addstar/src/args_load2mass.c (modified) (2 diffs)
-
Ohana/src/addstar/src/load2mass.c (modified) (3 diffs)
-
Ohana/src/addstar/src/load2mass_as_rawdata.c (modified) (4 diffs)
-
Ohana/src/libdvo/include/dvo.h (modified) (3 diffs)
-
Ohana/src/libdvo/src/dvo_photcode_ops.c (modified) (1 diff)
-
Ohana/src/libdvo/src/skyregion_ops.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/dbExtractMeasures.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/dbFields.c (modified) (1 diff)
-
Ohana/src/opihi/include/dvoshell.h (modified) (1 diff)
-
PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm (modified) (7 diffs)
-
archive/ducttape (copied) (copied from trunk/archive/ducttape )
-
archive/ducttape/fix_compress.c (copied) (copied from trunk/archive/ducttape/fix_compress.c )
-
arclog/arclog.pl (modified) (2 diffs)
-
arclog/arclog_readdb.pl (modified) (5 diffs)
-
catalyst (copied) (copied from trunk/catalyst )
-
catalyst/2007.0-specs (copied) (copied from trunk/catalyst/2007.0-specs )
-
catalyst/2007.0-specs/CVS (copied) (copied from trunk/catalyst/2007.0-specs/CVS )
-
catalyst/2007.0-specs/CVS/Entries (copied) (copied from trunk/catalyst/2007.0-specs/CVS/Entries )
-
catalyst/2007.0-specs/CVS/Repository (copied) (copied from trunk/catalyst/2007.0-specs/CVS/Repository )
-
catalyst/2007.0-specs/CVS/Root (copied) (copied from trunk/catalyst/2007.0-specs/CVS/Root )
-
catalyst/2007.0-specs/installcd-2.6.19.config (copied) (copied from trunk/catalyst/2007.0-specs/installcd-2.6.19.config )
-
catalyst/2007.0-specs/installcd-stage1-minimal.spec (copied) (copied from trunk/catalyst/2007.0-specs/installcd-stage1-minimal.spec )
-
catalyst/2007.0-specs/installcd-stage2-minimal.spec (copied) (copied from trunk/catalyst/2007.0-specs/installcd-stage2-minimal.spec )
-
catalyst/2007.0-specs/portage (copied) (copied from trunk/catalyst/2007.0-specs/portage )
-
catalyst/2007.0-specs/portage/CVS (copied) (copied from trunk/catalyst/2007.0-specs/portage/CVS )
-
catalyst/2007.0-specs/portage/CVS/Entries (copied) (copied from trunk/catalyst/2007.0-specs/portage/CVS/Entries )
-
catalyst/2007.0-specs/portage/CVS/Repository (copied) (copied from trunk/catalyst/2007.0-specs/portage/CVS/Repository )
-
catalyst/2007.0-specs/portage/CVS/Root (copied) (copied from trunk/catalyst/2007.0-specs/portage/CVS/Root )
-
catalyst/2007.0-specs/portage/package.keywords (copied) (copied from trunk/catalyst/2007.0-specs/portage/package.keywords )
-
catalyst/2007.0-specs/stage1.spec (copied) (copied from trunk/catalyst/2007.0-specs/stage1.spec )
-
catalyst/2007.0-specs/stage2.spec (copied) (copied from trunk/catalyst/2007.0-specs/stage2.spec )
-
catalyst/2007.0-specs/stage3.spec (copied) (copied from trunk/catalyst/2007.0-specs/stage3.spec )
-
catalyst/2007.0-specs/stage4.spec (copied) (copied from trunk/catalyst/2007.0-specs/stage4.spec )
-
catalyst/2008.0-specs (copied) (copied from trunk/catalyst/2008.0-specs )
-
catalyst/2008.0-specs/2.6.28-rc7-00105-gfeaf384.conf (copied) (copied from trunk/catalyst/2008.0-specs/2.6.28-rc7-00105-gfeaf384.conf )
-
catalyst/2008.0-specs/hardened (copied) (copied from trunk/catalyst/2008.0-specs/hardened )
-
catalyst/2008.0-specs/hardened/stage1-nomultilib.spec (copied) (copied from trunk/catalyst/2008.0-specs/hardened/stage1-nomultilib.spec )
-
catalyst/2008.0-specs/hardened/stage1.spec (copied) (copied from trunk/catalyst/2008.0-specs/hardened/stage1.spec )
-
catalyst/2008.0-specs/hardened/stage2-nomultilib.spec (copied) (copied from trunk/catalyst/2008.0-specs/hardened/stage2-nomultilib.spec )
-
catalyst/2008.0-specs/hardened/stage2.spec (copied) (copied from trunk/catalyst/2008.0-specs/hardened/stage2.spec )
-
catalyst/2008.0-specs/hardened/stage3-nomultilib.spec (copied) (copied from trunk/catalyst/2008.0-specs/hardened/stage3-nomultilib.spec )
-
catalyst/2008.0-specs/hardened/stage3.spec (copied) (copied from trunk/catalyst/2008.0-specs/hardened/stage3.spec )
-
catalyst/2008.0-specs/installcd-stage1.spec (copied) (copied from trunk/catalyst/2008.0-specs/installcd-stage1.spec )
-
catalyst/2008.0-specs/installcd-stage2-minimal.spec (copied) (copied from trunk/catalyst/2008.0-specs/installcd-stage2-minimal.spec )
-
catalyst/2008.0-specs/livecd-stage1.spec (copied) (copied from trunk/catalyst/2008.0-specs/livecd-stage1.spec )
-
catalyst/2008.0-specs/livecd-stage2.spec (copied) (copied from trunk/catalyst/2008.0-specs/livecd-stage2.spec )
-
catalyst/2008.0-specs/livedvd-stage1.spec (copied) (copied from trunk/catalyst/2008.0-specs/livedvd-stage1.spec )
-
catalyst/2008.0-specs/livedvd-stage2.spec (copied) (copied from trunk/catalyst/2008.0-specs/livedvd-stage2.spec )
-
catalyst/2008.0-specs/stage1.spec (copied) (copied from trunk/catalyst/2008.0-specs/stage1.spec )
-
catalyst/2008.0-specs/stage2-desktop.spec (copied) (copied from trunk/catalyst/2008.0-specs/stage2-desktop.spec )
-
catalyst/2008.0-specs/stage2.spec (copied) (copied from trunk/catalyst/2008.0-specs/stage2.spec )
-
catalyst/2008.0-specs/stage3-desktop.spec (copied) (copied from trunk/catalyst/2008.0-specs/stage3-desktop.spec )
-
catalyst/2008.0-specs/stage3.spec (copied) (copied from trunk/catalyst/2008.0-specs/stage3.spec )
-
catalyst/2008.0-specs/stage4.spec (copied) (copied from trunk/catalyst/2008.0-specs/stage4.spec )
-
console/scripts/console (modified) (3 diffs)
-
console/scripts/console-config (modified) (2 diffs)
-
console/scripts/console-ipp-defaults (modified) (2 diffs)
-
dbconfig/changes.txt (modified) (1 diff)
-
dbconfig/magic.md (modified) (1 diff)
-
dbconfig/pstamp.md (modified) (1 diff)
-
doc/misc/docgen.pl (modified) (3 diffs, 1 prop)
-
extlibs/readline-5.2-p13.tar.gz (copied) (copied from trunk/extlibs/readline-5.2-p13.tar.gz )
-
ippScripts/scripts/magic_destreak.pl (modified) (8 diffs)
-
ippScripts/scripts/magic_destreak_revert.pl (modified) (2 diffs, 1 prop)
-
ippScripts/scripts/publish_file.pl (modified) (1 diff)
-
ippTasks/dist.pro (modified) (1 diff)
-
ippTasks/magic.pro (modified) (6 diffs)
-
ippTasks/pstamp.pro (modified) (3 diffs)
-
ippTasks/survey.pro (modified) (3 diffs)
-
ippTests/tap (copied) (copied from trunk/ippTests/tap )
-
ippTests/tap/mailTestResults.pl (copied) (copied from trunk/ippTests/tap/mailTestResults.pl )
-
ippTests/tap/proveParser.pl (copied) (copied from trunk/ippTests/tap/proveParser.pl )
-
ippTests/tap/tapTest.pl (copied) (copied from trunk/ippTests/tap/tapTest.pl )
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/chiptool_processedimfile.sql (modified) (1 diff)
-
ippTools/share/difftool_definewarpstack_part1.sql (modified) (2 diffs)
-
ippTools/share/magicdstool_definebyquery_camera.sql (modified) (1 diff)
-
ippTools/share/magicdstool_definebyquery_chip.sql (modified) (1 diff)
-
ippTools/share/magicdstool_definebyquery_diff.sql (modified) (3 diffs)
-
ippTools/share/magicdstool_definebyquery_raw.sql (modified) (1 diff)
-
ippTools/share/magicdstool_definebyquery_warp.sql (modified) (1 diff)
-
ippTools/share/magicdstool_todestreak.sql (modified) (8 diffs)
-
ippTools/share/magictool_toprocess_runs.sql (copied) (copied from trunk/ippTools/share/magictool_toprocess_runs.sql )
-
ippTools/share/pstamptool_addjob_otherjob.sql (modified) (1 diff)
-
ippTools/share/pstamptool_addjob_stampjob.sql (modified) (1 diff)
-
ippTools/share/pxadmin_create_tables.sql (modified) (3 diffs)
-
ippTools/share/stacktool_sumskyfile.sql (modified) (1 diff)
-
ippTools/src/difftool.c (modified) (1 diff)
-
ippTools/src/disttool.c (modified) (2 diffs)
-
ippTools/src/magicdstool.c (modified) (4 diffs)
-
ippTools/src/magictool.c (modified) (7 diffs)
-
ippTools/src/magictoolConfig.c (modified) (1 diff)
-
ippTools/src/pstamptool.c (modified) (3 diffs)
-
ippTools/src/pstamptoolConfig.c (modified) (2 diffs)
-
ippTools/src/stacktool.c (modified) (1 diff)
-
ippTools/src/stacktoolConfig.c (modified) (1 diff)
-
ippTools/src/warptool.c (modified) (1 diff)
-
ippTools/src/warptoolConfig.c (modified) (1 diff)
-
ippconfig/vysos5/psastro.config (modified) (3 diffs)
-
magic/remove/src/Line.c (modified) (2 diffs)
-
magic/remove/src/streaksextern.c (modified) (1 diff)
-
magic/remove/src/streaksextern.h (modified) (2 diffs)
-
magic/remove/src/streaksremove.c (modified) (6 diffs)
-
ppMops/src/ppMops.c (modified) (1 diff)
-
ppStack/src/ppStackMatch.c (modified) (4 diffs)
-
psLib/src/fits/psFits.c (modified) (2 diffs)
-
psLib/src/fits/psFitsHeader.c (modified) (6 diffs)
-
psLib/src/fits/psFitsHeader.h (modified) (1 diff)
-
psLib/src/fits/psFitsImage.c (modified) (4 diffs)
-
psLib/src/math/psStats.c (modified) (29 diffs)
-
psModules/src/concepts/pmConcepts.c (modified) (2 diffs)
-
psModules/src/imcombine/pmSubtractionAnalysis.c (modified) (1 diff)
-
psconfig/pschecklibs (modified) (1 diff)
-
psconfig/tagsets/ipp-2.9.libs (modified) (1 diff)
-
psphot/doc/notes.20090523.txt (modified) (2 diffs)
-
pstamp/scripts/pstamp_finish.pl (modified) (3 diffs)
-
pstamp/scripts/pstamp_job_run.pl (modified) (7 diffs)
-
pstamp/scripts/pstamp_parser_run.pl (modified) (2 diffs)
-
pstamp/scripts/pstamp_results_file.pl (modified) (1 diff)
-
pstamp/scripts/pstampparse.pl (modified) (21 diffs)
-
pstamp/src/ppstampArguments.c (modified) (2 diffs)
-
pstamp/src/ppstampParseCamera.c (modified) (2 diffs)
-
pstamp/test/pstamp_req_create (modified) (3 diffs)
-
pswarp/src/pswarpLoop.c (modified) (2 diffs)
-
pswarp/src/pswarpTransformReadout.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/cleanup
- Property svn:mergeinfo changed
/trunk merged: 24940-24950,24953-24971,24973-24977,24986-24989,24993-25017,25019,25021,25023-25024,25026,25029-25031,25036-25049
- Property svn:mergeinfo changed
-
branches/czw_branch/cleanup/Nebulous-Server/Changes
r24951 r25051 36 36 instance and just those that are available 37 37 - add Nebulous::Server->prune_object() API 38 - don't replicate to the volume being implied by the key being replicated! 38 39 39 40 0.16 -
branches/czw_branch/cleanup/Nebulous-Server/lib/Nebulous/Server.pm
r24951 r25051 696 696 $log->debug("entered - @_"); 697 697 698 my ($key, $ vol_name) = validate_pos(@_,698 my ($key, $dest_vol_name) = validate_pos(@_, 699 699 { 700 700 type => SCALAR, … … 726 726 # instance on it. If all avilable volume already have an instance on them 727 727 # then we should throw an error 728 729 # vol_name overrides the key implied volume 730 eval { 731 $key = parse_neb_key($key, $vol_name); 728 # volume names implied as part of the key are *IGNORED* as the source and 729 # *SHOULD NOT* be used as the destination either 730 731 eval { 732 $key = parse_neb_key($key); 732 733 }; 733 734 $log->logdie("$@") if $@; 734 $vol_name = $key->volume;735 735 736 736 my $db = $self->db($key); 737 737 738 if (defined $vol_name 738 # puke if the source volume is bogus, we may want to actually use this as 739 # the instance to be copied later 740 if (defined $key->volume 739 741 and not $self->_is_valid_volume_name($key, $key->volume)) { 740 742 unless ($key->hard_volume) { 741 $log->warn( "$vol_name is not a known volume name" ); 742 $vol_name = undef; 743 $log->warn($key->volume . " not a known volume name"); 743 744 } else { 744 $log->logdie("$vol_name is not a valid volume name"); 745 } 745 $log->logdie("$key is not a valid volume name"); 746 } 747 } 748 # puke if the source volume is bogus, we may want to actually use this as 749 # the instance to be copied later 750 if (defined $dest_vol_name 751 and not $self->_is_valid_volume_name($key, $dest_vol_name)) { 752 $log->logdie($key->volume . " is not a valid volume name"); 746 753 } 747 754 748 755 my ($vol_id, $vol_host, $vol_path, $vol_xattr); 749 if (defined $ vol_name) {756 if (defined $dest_vol_name) { 750 757 ($vol_id, $vol_host, $vol_path, $vol_xattr) 751 = $self->_get_storage_volume($key, $ vol_name);758 = $self->_get_storage_volume($key, $dest_vol_name); 752 759 } else { 753 760 ($vol_id, $vol_host, $vol_path, $vol_xattr) … … 810 817 $db->rollback; 811 818 # handle soft volumes 812 if (defined $ vol_name and not defined $key->hard_volume) {819 if (defined $dest_vol_name and not defined $key->hard_volume) { 813 820 $log->debug("retrying with 'any' volume"); 814 821 return $self->replicate_object($key->path, 'any'); -
branches/czw_branch/cleanup/Nebulous-Server/lib/Nebulous/Server/Config.pm
r24370 r25051 13 13 14 14 use Log::Log4perl qw( :levels ); 15 use Params::Validate qw( validate validate_pos SCALAR ARRAYREF );15 use Params::Validate qw( validate validate_pos SCALAR ARRAYREF UNDEF ); 16 16 17 17 our %LEVELS = ( … … 32 32 dsn => { type => SCALAR }, 33 33 dbuser => { type => SCALAR }, 34 dbpasswd => { type => SCALAR },34 dbpasswd => { type => SCALAR | UNDEF }, 35 35 }; 36 36 … … 48 48 dsn => { type => SCALAR, optional => 1 }, 49 49 dbuser => { type => SCALAR, optional => 1 }, 50 dbpasswd => { type => SCALAR , optional => 1 },50 dbpasswd => { type => SCALAR | UNDEF, optional => 1 }, 51 51 memcached_servers => { type => ARRAYREF, optional => 1 }, 52 52 }; -
branches/czw_branch/cleanup/Nebulous-Server/t/05_server_replicate_object.t
r24372 r25051 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 2 6;10 use Test::More tests => 25; 11 11 12 12 use lib qw( ./t ./lib ); -
branches/czw_branch/cleanup/Nebulous-Server/t/09_server_delete_instance.t
r24637 r25051 58 58 my $key = "foo"; 59 59 my $uri1 = $neb->create_object($key, 'node01'); 60 my $uri2 = $neb->replicate_object($key, 'node 2');60 my $uri2 = $neb->replicate_object($key, 'node02'); 61 61 62 62 # make one of the instances unavailable -
branches/czw_branch/cleanup/Nebulous/Changes
r24951 r25051 8 8 - add Nebulous::Client->prune() method 9 9 - add Nebulous::Client->there_can_be_only_one() method 10 - add neb-cull --one_only flag 10 11 11 12 0.10 -
branches/czw_branch/cleanup/Nebulous/MANIFEST
r24951 r25051 102 102 t/70_neb-ls.t 103 103 t/71_client_there_can_be_only_one.t 104 t/72_neb-cull.t 104 105 t/90_nebclient.t 105 106 t/TEST.PL -
branches/czw_branch/cleanup/Nebulous/bin/neb-cull
r16183 r25051 16 16 use Pod::Usage qw( pod2usage ); 17 17 18 my ($server, $volume );18 my ($server, $volume, $one_only); 19 19 20 20 $server = $ENV{'NEB_SERVER'} unless $server; … … 23 23 'server|s=s' => \$server, 24 24 'volume|v=s' => \$volume, 25 'one_only|o' => \$one_only, 25 26 ) || pod2usage( 2 ); 26 27 … … 40 41 unless defined $neb; 41 42 43 my @cull_args; 44 push @cull_args, $key; 42 45 if (defined $volume) { 43 $neb->cull($key, $volume) 44 or die "failed to replicate Nebulous key: $key"; 46 push @cull_args, $volume; 47 } 48 49 if ($one_only) { 50 my $status = $neb->there_can_be_only_one(@cull_args); 51 if ($status == 0) { 52 die "not enough instances of Nebulous key: $key"; 53 } 54 if (not defined $status or $status < 1) { 55 die "failed to cull Nebulous key: $key - " . $neb->err 56 if defined $neb->err; 57 die "failed to cull Nebulous key: $key"; 58 } 45 59 } else { 46 $neb->cull($key) 47 or die "failed to replicate Nebulous key: $key"; 60 unless (defined $neb->cull(@cull_args)) { 61 die "failed to cull Nebulous key: $key - " . $neb->err; 62 } 48 63 } 49 64 … … 58 73 =head1 SYNOPSIS 59 74 60 neb-cull [--server <URL>] [--volume <volume name>] <key>75 neb-cull [--server <URL>] [--volume <volume name>] [--one_only] <key> 61 76 62 77 =head1 DESCRIPTION … … 77 92 78 93 Symbolic name of the volume to create the new instance on. 94 95 Optional. 96 97 =item * --one_only|-o 98 99 Removes all but one instances of an object. Any inaccessible instances are 100 removed. If C<--volume> is specified, and an instance exists on that volume, 101 all instances but the one on that volume are removed. 79 102 80 103 Optional. … … 110 133 =head1 COPYRIGHT 111 134 112 Copyright (C) 2007-200 8Joshua Hoblitt. All rights reserved.135 Copyright (C) 2007-2009 Joshua Hoblitt. All rights reserved. 113 136 114 137 This program is free software; you can redistribute it and/or modify it under -
branches/czw_branch/cleanup/Nebulous/lib/Nebulous/Client.pm
r24951 r25051 297 297 my $instances = $stats[6]; 298 298 if (defined $instances and $instances < 2) { 299 $ log->debug("can not cull - not enough instances");299 $self->set_err("can not cull - not enough instances"); 300 300 $log->debug("leaving"); 301 301 … … 305 305 $locations = $self->find_instances($key, $vol_name); 306 306 unless (defined $locations) { 307 $ log->debug( "no instances" );307 $self->set_err( "no instances" ); 308 308 $log->debug( "leaving" ); 309 309 … … 313 313 $locations = $self->find_instances($key); 314 314 unless ($locations) { 315 $ log->debug("no instances");315 $self->set_err( "no instances" ); 316 316 $log->debug("leaving"); 317 317 … … 320 320 321 321 if (scalar @{ $locations } < 2) { 322 $ log->debug("can not cull - not enough instances");322 $self->set_err("can not cull - not enough instances"); 323 323 $log->debug("leaving"); 324 324 … … 365 365 if (not defined $self->prune($key)) { 366 366 # use the prune() method to also determine if $key is valid 367 $removed = undef; 368 return; 367 die "invalid key: $key"; 369 368 } 370 369 … … 377 376 if (defined $locations) { 378 377 my $instances = $self->find_instances($key); 378 if (scalar @$instances < 2) { 379 die "not enough instances"; 380 } 379 381 foreach my $victim (@$instances) { 380 382 next if $victim eq $locations->[0]; … … 387 389 # start at one so cull() is called one less time then the # of 388 390 # instances 391 if ($stats->[6] < 2) { 392 die "not enough instances"; 393 } 389 394 for (my $i = 1; $i < $stats->[6]; $i++) { 390 395 $self->cull($key); … … 395 400 }; 396 401 if ($@) { 402 if ($@ =~ qr/invalid key/) { 403 $self->set_err($@); 404 return; 405 } 397 406 $log->logdie($@); 398 407 } -
branches/czw_branch/cleanup/Nebulous/nebclient/configure.ac
r20208 r25051 5 5 AC_PREREQ(2.61) 6 6 7 AC_INIT([nebclient], [0. 08], [jhoblitt@cpan.org])7 AC_INIT([nebclient], [0.17], [jhoblitt@cpan.org]) 8 8 AC_CONFIG_SRCDIR([nebulous.wsdl]) 9 9 -
branches/czw_branch/cleanup/Nebulous/nebclient/src/nebclient.c
r24951 r25051 51 51 static char *nullstrncpy(char *dest, const char *src, size_t n); 52 52 53 53 54 nebServer *nebServerAlloc(const char *endpoint) 54 55 { 55 nebServer *server; 56 57 server = xmalloc(sizeof(nebServer)); 56 nebServer *server = xmalloc(sizeof(nebServer)); 58 57 59 58 if (endpoint) { … … 77 76 } 78 77 78 79 79 void nebServerFree(nebServer *server) 80 80 { … … 92 92 } 93 93 94 94 95 char *nebCreate(nebServer *server, const char *key, const char *volume, char **URI) 95 96 { 97 REQUIRE_SERVER; 98 99 if (!key) { 100 nebSetErr(server, "parameter 'key' may not be NULL"); 101 102 return NULL; 103 } 104 96 105 struct ns1__create_USCOREobjectResponse response; 97 char *filename;98 99 REQUIRE_SERVER;100 101 if (!key) {102 nebSetErr(server, "parameter 'key' may not be NULL");103 104 return NULL;105 }106 107 106 if (soap_call_ns1__create_USCOREobject(server->soap, server->endpoint, NULL, 108 107 (char *)key, (char *)volume, (char **)&response) != SOAP_OK) { … … 117 116 } 118 117 118 char *filename; 119 119 if (!nebParseURI(server, (char *)response.result, &filename)) { 120 120 nebSetErr(server, "can not parse URI"); 121 nebFree(filename); 122 121 123 return NULL; 122 124 } … … 131 133 } 132 134 135 133 136 int nebOpenCreate(nebServer *server, const char *key, const char *volume, char **URI) 134 137 { 135 char *filename;136 int file; 137 138 REQUIRE_SERVER;139 140 if (!key) {141 nebSetErr(server, "parameter 'key' may not be NULL");142 143 return -1;144 }145 146 filename = nebCreate(server, key, volume, URI);147 148 file = open(filename, O_RDWR|O_TRUNC, 0660);138 REQUIRE_SERVER; 139 140 if (!key) { 141 nebSetErr(server, "parameter 'key' may not be NULL"); 142 143 return -1; 144 } 145 146 char *filename = nebCreate(server, key, volume, URI); 147 if (!filename) { 148 return -1; 149 } 150 151 int file = open(filename, O_RDWR|O_TRUNC, 0660); 149 152 if (file == -1) { 150 153 nebSetErr(server, "can not open %s: %s", filename, strerror(errno)); … … 159 162 } 160 163 164 161 165 bool nebReplicate(nebServer *server, const char *key, const char *volume, char **URI) 162 166 { 163 struct ns1__replicate_USCOREobjectResponse response;164 char *filename;165 int sourceFH, destFH;166 167 167 REQUIRE_SERVER; 168 168 … … 177 177 // we don't do this, it's possible that open will find & open the new 178 178 // instance that we're in the process of creating 179 sourceFH = nebOpen(server, (char *)key, NEB_READ);179 int sourceFH = nebOpen(server, (char *)key, NEB_READ); 180 180 if (sourceFH == -1) { 181 181 nebSetErr(server, "can not open key %s", key); 182 nebFree(filename);183 182 184 183 return false; … … 186 185 187 186 // ask the server for a new instance attached to our key 187 struct ns1__replicate_USCOREobjectResponse response; 188 188 if (soap_call_ns1__replicate_USCOREobject(server->soap, server->endpoint, 189 189 NULL, (char *)key, (char *)volume, (char **)&response) != SOAP_OK) { … … 193 193 } 194 194 195 char *filename = NULL; 195 196 if (!nebParseURI(server, (char *)response.result, &filename)) { 196 197 nebSetErr(server, "can not parse URI"); … … 199 200 } 200 201 201 destFH = open(filename, O_RDWR|O_TRUNC, 0660);202 int destFH = open(filename, O_RDWR|O_TRUNC, 0660); 202 203 if (destFH == -1) { 203 204 nebSetErr(server, "can not open %s: %s\n", filename, strerror(errno)); … … 234 235 } 235 236 237 236 238 bool nebCull(nebServer *server, const char *key) 237 239 { 238 nebObjectInstances *locations; 239 240 REQUIRE_SERVER; 241 242 if (!key) { 243 nebSetErr(server, "parameter 'key' may not be NULL"); 244 245 return false; 246 } 247 248 locations = nebFindInstances(server, key, NULL); 240 REQUIRE_SERVER; 241 242 if (!key) { 243 nebSetErr(server, "parameter 'key' may not be NULL"); 244 245 return false; 246 } 247 248 nebObjectInstances *locations = nebFindInstances(server, key, NULL); 249 249 if (!locations || locations->n <= 1) { 250 250 nebSetErr(server, "can not cull - not enough instances"); 251 if (locations) { 252 nebObjectInstancesFree(locations); 253 } 251 254 252 255 return false; … … 264 267 } 265 268 269 266 270 bool nebLock(nebServer *server, const char *key, nebRW flag) 267 271 { 268 time_t endtime; 269 char *type; 270 int response; 271 272 REQUIRE_SERVER; 273 274 if (!key) { 275 nebSetErr(server, "parameter 'key' may not be NULL"); 276 277 return false; 278 } 279 280 type = flag == NEB_READ ? "read" : "write"; 281 282 endtime = time(NULL) + LOCK_TIMEOUT; 272 REQUIRE_SERVER; 273 274 if (!key) { 275 nebSetErr(server, "parameter 'key' may not be NULL"); 276 277 return false; 278 } 279 280 char *type = flag == NEB_READ ? "read" : "write"; 281 282 time_t endtime = time(NULL) + LOCK_TIMEOUT; 283 283 284 284 while (time(NULL) < endtime) { 285 int response; 285 286 if (soap_call_ns1__lock_USCOREobject(server->soap, server->endpoint, 286 287 NULL, (char *)key, type, &response) != SOAP_OK) { … … 302 303 } 303 304 305 304 306 bool nebUnlock(nebServer *server, const char *key, nebRW flag) 305 307 { 306 char *type; 307 int response; 308 309 REQUIRE_SERVER; 310 311 if (!key) { 312 nebSetErr(server, "parameter 'key' may not be NULL"); 313 314 return false; 315 } 316 317 type = flag == NEB_READ ? "read" : "write"; 318 308 REQUIRE_SERVER; 309 310 if (!key) { 311 nebSetErr(server, "parameter 'key' may not be NULL"); 312 313 return false; 314 } 315 316 char *type = flag == NEB_READ ? "read" : "write"; 317 318 int response; 319 319 if (soap_call_ns1__unlock_USCOREobject(server->soap, server->endpoint, 320 320 NULL, (char *)key, type, &response) != SOAP_OK) { … … 466 466 nebObjectInstances *nebFindInstances(nebServer *server, const char *key, const char *volume) 467 467 { 468 REQUIRE_SERVER; 469 470 if (!key) { 471 nebSetErr(server, "parameter 'key' may not be NULL"); 472 473 return NULL; 474 } 475 468 476 struct ns1__find_USCOREinstancesResponse response; 469 int resultElements = 0;470 char **resultArray;471 nebObjectInstances *locations = NULL;472 473 REQUIRE_SERVER;474 475 if (!key) {476 nebSetErr(server, "parameter 'key' may not be NULL");477 478 return NULL;479 }480 481 477 // FIXME is this leaking memory when response goes out of scope? the gsoap 482 478 // manual seems to 'suggest' that this is temporary data that gets cleaed … … 488 484 } 489 485 490 resultElements = response.result->__size; 491 486 int resultElements = response.result->__size; 487 488 nebObjectInstances *locations = NULL; 492 489 if (resultElements) { 493 490 locations = xmalloc(sizeof(nebObjectInstances)); 494 491 locations->n = resultElements; 495 492 496 resultArray= response.result->__ptr;493 char **resultArray = response.result->__ptr; 497 494 498 495 locations->URI = xmalloc(sizeof(char*) * resultElements); … … 508 505 } 509 506 507 510 508 void nebObjectInstancesFree(nebObjectInstances *locations) 511 509 { … … 521 519 } 522 520 521 523 522 char *nebFind(nebServer *server, const char *key) 524 523 { 525 nebObjectInstances *locations;526 char *filename;527 528 524 REQUIRE_SERVER; 529 525 … … 534 530 } 535 531 536 locations = nebFindInstances(server, key, NULL);532 nebObjectInstances *locations = nebFindInstances(server, key, NULL); 537 533 if (!locations) { 538 534 if (!strstr(nebErr(server), "no instances on storage volume")) { … … 548 544 } 549 545 546 char *filename; 550 547 if (!nebParseURI(server, locations->URI[0], &filename)) { 551 548 nebSetErr(server, "can not parse URI"); … … 560 557 } 561 558 559 562 560 int nebOpen(nebServer *server, const char *key, nebRW flag) 563 561 { 564 nebObjectInstances *locations; 565 char *filename; 566 int fh; 567 568 REQUIRE_SERVER; 569 570 if (!key) { 571 nebSetErr(server, "parameter 'key' may not be NULL"); 572 573 return -1; 574 } 575 576 locations = nebFindInstances(server, key, NULL); 562 REQUIRE_SERVER; 563 564 if (!key) { 565 nebSetErr(server, "parameter 'key' may not be NULL"); 566 567 return -1; 568 } 569 570 nebObjectInstances *locations = nebFindInstances(server, key, NULL); 577 571 if (!locations) { 578 572 nebSetErr(server, "no instances found"); … … 581 575 } 582 576 577 char *filename; 583 578 if (!nebParseURI(server, locations->URI[0], &filename)) { 584 579 nebSetErr(server, "can not parse URI"); … … 588 583 } 589 584 585 int fh = 0; 590 586 if (flag == NEB_WRITE) { 591 587 if (locations->n > 1) { … … 613 609 } 614 610 611 615 612 bool nebDelete(nebServer *server, const char *key) 616 613 { 617 nebObjectInstances *locations; 618 619 REQUIRE_SERVER; 620 621 if (!key) { 622 nebSetErr(server, "parameter 'key' may not be NULL"); 623 624 return false; 625 } 626 627 locations = nebFindInstances(server, key, "any"); 614 REQUIRE_SERVER; 615 616 if (!key) { 617 nebSetErr(server, "parameter 'key' may not be NULL"); 618 619 return false; 620 } 621 622 nebObjectInstances *locations = nebFindInstances(server, key, "any"); 628 623 if (!locations) { 629 624 nebSetErr(server, "no instances found"); … … 646 641 } 647 642 643 648 644 bool nebCopy(nebServer *server, const char *key, const char *newKey) 649 645 { 650 int sourceFH;651 int destFH;652 653 646 REQUIRE_SERVER; 654 647 … … 665 658 } 666 659 667 sourceFH = nebOpen(server, (char *)key, NEB_READ);660 int sourceFH = nebOpen(server, (char *)key, NEB_READ); 668 661 if (sourceFH < 0) { 669 662 // propigate nebOpen() error … … 672 665 } 673 666 674 destFH = nebOpenCreate(server, newKey, NULL, NULL);667 int destFH = nebOpenCreate(server, newKey, NULL, NULL); 675 668 if (destFH < 0) { 676 669 // propigate nebCreate() error … … 696 689 } 697 690 691 698 692 bool nebMove(nebServer *server, const char *key, const char *newKey) 699 693 { … … 723 717 } 724 718 719 725 720 bool nebSwap(nebServer *server, const char *key1, const char *key2) 726 721 { 727 struct ns1__create_USCOREobjectResponse response;728 729 722 REQUIRE_SERVER; 730 723 … … 741 734 } 742 735 736 struct ns1__create_USCOREobjectResponse response; 743 737 if (soap_call_ns1__swap_USCOREobjects(server->soap, server->endpoint, 744 738 NULL, (char *)key1, (char *)key2, (char **)&response) != SOAP_OK) { … … 749 743 } 750 744 745 751 746 bool nebDeleteInstance(nebServer *server, const char *key, const char *URI) 752 747 { 753 int response;754 char *filename;755 bool status;756 757 748 REQUIRE_SERVER; 758 749 … … 763 754 } 764 755 756 char *filename; 765 757 if (!nebParseURI(server, URI, &filename)) { 766 758 nebSetErr(server, "can not parse URI"); … … 769 761 } 770 762 763 int response; 771 764 if (soap_call_ns1__delete_USCOREinstance(server->soap, server->endpoint, 772 765 NULL, (char *)key, (char *)URI, &response) != SOAP_OK) { … … 776 769 } 777 770 771 bool status; 778 772 if (response > 0) { 779 773 status = nebNukeFile(server, filename); … … 787 781 } 788 782 783 789 784 nebObjectStat *nebStat(nebServer *server, const char *key) 790 785 { 791 struct ns1__stat_USCOREobjectResponse response;792 nebObjectStat *stat;793 int resultElements = 0;794 char **resultArray = NULL;795 796 786 REQUIRE_SERVER; 797 787 … … 802 792 } 803 793 804 stat = xmalloc(sizeof(nebObjectStat));794 nebObjectStat *stat = xmalloc(sizeof(nebObjectStat)); 805 795 806 796 // FIXME is this leaking memory when response goes out of scope? the gsoap 807 797 // manual seems to 'suggest' that this is temporary data that gets cleaed 808 798 // up on the next soap function call 799 struct ns1__stat_USCOREobjectResponse response; 809 800 if (soap_call_ns1__stat_USCOREobject(server->soap, server->endpoint, 810 801 NULL, (char *)key, &response) != SOAP_OK) { … … 813 804 } 814 805 815 resultElements = response.result->__size;816 resultArray = response.result->__ptr;806 int resultElements = response.result->__size; 807 char **resultArray = response.result->__ptr; 817 808 818 809 if (resultElements != 8) { … … 821 812 } 822 813 823 nullstrncpy(stat->so_id, resultArray[0], 256);824 nullstrncpy(stat->ext_id, resultArray[1], 256);825 nullstrncpy(stat->read_lock, resultArray[2], 256);814 stat->so_id = atol(resultArray[0]); 815 stat->ext_id = atol(resultArray[1]); 816 stat->read_lock = atoi(resultArray[2]); 826 817 nullstrncpy(stat->write_lock, resultArray[3], 256); 827 818 nullstrncpy(stat->epoch, resultArray[4], 256); … … 833 824 } 834 825 826 835 827 void nebObjectStatFree(nebObjectStat *stat) 836 828 { … … 839 831 } 840 832 841 xfree(stat->so_id); 842 xfree(stat->ext_id); 843 xfree(stat->read_lock); 844 xfree(stat->write_lock); 845 xfree(stat->epoch); 846 xfree(stat->mtime); 847 xfree(stat); 833 nebFree(stat); 848 834 } 849 835 … … 895 881 return response; 896 882 } 883 897 884 898 885 int nebThereCanBeOnlyOne(nebServer *server, const char *key, const char *volume) … … 936 923 nebObjectInstancesFree(locations); 937 924 } else { 925 nebObjectInstancesFree(locations); 938 926 // nuke whatever 939 927 nebObjectStat *stat = nebStat(server, key); … … 941 929 return -1; 942 930 } 931 932 int available = stat->available; 933 nebObjectStatFree(stat); 934 943 935 // start at one so cull() is called one less time then the # of 944 936 // instances 945 for (long i = 1; i < stat->available; i++) {937 for (long i = 1; i < available; i++) { 946 938 if (!nebCull(server, key)) { 947 nebObjectStatFree(stat);948 939 return -1; 949 940 } 950 941 removed++; 951 942 } 952 nebObjectStatFree(stat);953 943 } 954 944 … … 962 952 } 963 953 954 964 955 void nebFree(void *ptr) { 956 if (!ptr) { return; } 965 957 xfree(ptr); 966 958 } … … 969 961 static void p_nebSetErr(const char * filename, unsigned long lineno, const char *function, nebServer *server, const char *format, ...) 970 962 { 971 va_list args; 972 size_t err_size; 973 char err_location[ERRBUF_SIZE]; 974 size_t err_location_size; 975 976 err_location_size = snprintf(err_location, ERRBUF_SIZE, "%s:%lu %s() - ", 963 char err_location[ERRBUF_SIZE]; 964 size_t err_location_size = snprintf(err_location, ERRBUF_SIZE, "%s:%lu %s() - ", 977 965 filename, lineno, function); 978 966 … … 987 975 988 976 while (1) { 977 va_list args; 989 978 va_start(args, format); 990 979 // append error string after error location info 991 err_size = vsnprintf(980 size_t err_size = vsnprintf( 992 981 server->err_buf + err_location_size, 993 982 server->err_buf_size - err_location_size, … … 1013 1002 } 1014 1003 1004 1015 1005 static void nebSetServerErr(nebServer *server) 1016 1006 { 1017 const char **code; 1018 const char **string; 1019 1020 REQUIRE_SERVER; 1021 1022 code = soap_faultcode(server->soap); 1023 string = soap_faultstring(server->soap); 1007 REQUIRE_SERVER; 1008 1009 const char **code = soap_faultcode(server->soap); 1010 const char **string = soap_faultstring(server->soap); 1024 1011 1025 1012 nebSetErr(server, "%s - %s", *code, *string); 1026 1013 } 1014 1027 1015 1028 1016 #if NEBCOPYFILE 1029 1017 static off_t nebCopyFile(nebServer *server, const char *source, const char *dest) 1030 1018 { 1031 int sourceFH; 1032 int destFH; 1033 off_t bytesCopied; 1034 1035 REQUIRE_SERVER; 1036 1037 sourceFH = open(source, O_RDONLY); 1019 REQUIRE_SERVER; 1020 1021 int sourceFH = open(source, O_RDONLY); 1038 1022 if (sourceFH == -1) { 1039 1023 nebSetErr(server, "can not open %s: %s", source, strerror(errno)); … … 1042 1026 } 1043 1027 1044 destFH = open(dest, O_WRONLY|O_CREAT|O_CREAT, 0600);1028 int destFH = open(dest, O_WRONLY|O_CREAT|O_CREAT, 0600); 1045 1029 if (destFH == -1) { 1046 1030 nebSetErr(server, "can not open %s: %s", dest, strerror(errno)); … … 1049 1033 } 1050 1034 1051 bytesCopied = nebCopyFilehandle(server, sourceFH, destFH);1035 off_t bytesCopied = nebCopyFilehandle(server, sourceFH, destFH); 1052 1036 if (bytesCopied < 0) { 1053 1037 return -1; … … 1070 1054 #endif 1071 1055 1056 1072 1057 static off_t nebCopyFilehandle(nebServer *server, int sourceFH, int destFH) 1073 1058 { 1074 off_t bytesTotal; 1075 off_t bytesRemaining; 1076 off_t writeSize; 1077 char writeBuf[64 * 1024]; 1059 REQUIRE_SERVER; 1060 1078 1061 struct stat sourceStat; 1079 1080 REQUIRE_SERVER;1081 1082 1062 if(fstat(sourceFH, &sourceStat)) { 1083 1063 nebSetErr(server, "can not stat filehandles: %s", strerror(errno)); … … 1087 1067 1088 1068 // the size of the file to copied 1089 bytesTotal = sourceStat.st_size;1069 off_t bytesTotal = sourceStat.st_size; 1090 1070 1091 1071 /* … … 1095 1075 */ 1096 1076 1097 bytesRemaining = bytesTotal;1077 off_t bytesRemaining = bytesTotal; 1098 1078 1099 1079 while (bytesRemaining) { 1080 off_t writeSize; 1081 char writeBuf[64 * 1024]; 1100 1082 if (bytesRemaining <= sizeof(writeBuf)) { 1101 1083 writeSize = bytesRemaining; … … 1122 1104 } 1123 1105 1106 1124 1107 static size_t nebParseURI(nebServer *server, const char *URI, char **filename) 1125 1108 { 1126 regex_t myregex;1127 regmatch_t mymatch[2];1128 char errbuf[ERRBUF_SIZE];1129 char *pattern = "^file://(.*)$";1130 int status;1131 size_t matchStart, matchEnd;1132 size_t matchLength;1133 size_t filename_size;1134 1135 1109 REQUIRE_SERVER; 1136 1110 … … 1147 1121 } 1148 1122 1149 status = regcomp(&myregex, pattern, REG_EXTENDED); 1123 regex_t myregex; 1124 regmatch_t mymatch[2]; 1125 char *pattern = "^file://(.*)$"; 1126 char errbuf[ERRBUF_SIZE]; 1127 1128 int status = regcomp(&myregex, pattern, REG_EXTENDED); 1150 1129 if (status != 0) { 1151 1130 regerror(status, &myregex, errbuf, ERRBUF_SIZE); … … 1165 1144 regfree(&myregex); 1166 1145 1167 matchStart = (size_t)mymatch[1].rm_so;1168 matchEnd = (size_t)mymatch[1].rm_eo;1169 matchLength = matchEnd - matchStart;1146 size_t matchStart = (size_t)mymatch[1].rm_so; 1147 size_t matchEnd = (size_t)mymatch[1].rm_eo; 1148 size_t matchLength = matchEnd - matchStart; 1170 1149 1171 1150 if (matchStart == -1) { … … 1173 1152 } 1174 1153 1175 filename_size = matchLength + 1;1154 size_t filename_size = matchLength + 1; 1176 1155 *filename = xmalloc(filename_size); 1177 1156 … … 1180 1159 return strlen(*filename); 1181 1160 } 1161 1182 1162 1183 1163 static bool nebNukeFile(nebServer *server, const char *filename) … … 1199 1179 return true; 1200 1180 } 1181 1201 1182 1202 1183 static char *nullstrncpy(char *dest, const char *src, size_t n) { … … 1206 1187 } 1207 1188 1189 if (!dest) { 1190 dest = xmalloc(n + 1); 1191 } 1192 1208 1193 return strncpy(dest, src, n); 1209 1194 } -
branches/czw_branch/cleanup/Nebulous/nebclient/src/nebclient.h
r24951 r25051 38 38 39 39 typedef struct { 40 char so_id[256];///< storage object ID41 char ext_id[256];///< storage object key (name)42 char read_lock[256];///< read lock value40 long so_id; ///< storage object ID 41 long ext_id; ///< storage object key (name) 42 int read_lock; ///< read lock value 43 43 char write_lock[256]; ///< write lock value 44 44 char epoch[256]; ///< creation time stamp -
branches/czw_branch/cleanup/Nebulous/nebclient/tests/tests.c
r24951 r25051 98 98 99 99 char *copies = nebGetXattr(server, key, "user.copies"); 100 neb_ok(server, strcmp(copies, "2") == 0, "get user.copies xattr");100 neb_ok(server, copies != NULL && strcmp(copies, "2") == 0, "get user.copies xattr"); 101 101 char **xattrs = NULL; 102 102 int n_xattrs = nebListXattr(server, key, &xattrs); 103 printf("# %s\n\n", xattrs[0]); 104 neb_ok(server, n_xattrs == 1, "count of xattrs"); 105 neb_ok(server, strcmp(xattrs[0], "user.copies") == 0, "user.copies xattr exists"); 103 neb_ok(server, xattrs != NULL && n_xattrs == 1, "count of xattrs"); 104 neb_ok(server, xattrs != NULL && strcmp(xattrs[0], "user.copies") == 0, "user.copies xattr exists"); 106 105 neb_ok(server, nebRemoveXattr(server, key, "user.copies"), "remove user.copies xattr"); 107 106 -
branches/czw_branch/cleanup/Ohana/src/addstar/Makefile
r21508 r25051 58 58 $(SRC)/greference.$(ARCH).o \ 59 59 $(SRC)/grefstars.$(ARCH).o \ 60 $(SRC)/GetZeroPointExposure.$(ARCH).o \ 60 61 $(SRC)/LoadStars.$(ARCH).o \ 61 62 $(SRC)/LoadHeaders.$(ARCH).o \ … … 199 200 $(SRC)/replace_match.$(ARCH).o \ 200 201 $(SRC)/update_coords.$(ARCH).o \ 202 $(SRC)/SkyRegionUtils.$(ARCH).o \ 201 203 $(SRC)/StarOps.$(ARCH).o \ 202 204 $(SRC)/ConfigInit.$(ARCH).o \ -
branches/czw_branch/cleanup/Ohana/src/addstar/doc/notes.txt
r21508 r25051 1 2 2009.08.02 3 4 ZERO POINTS: addstar currently has a couple of inconsistent ways that it 5 measures or uses image zero points: 6 7 * the standard zero point: data in the database is saved as M_inst + 8 25.0. This value is written to the image header and checked when 9 the image is loaded. This is completely archaic, but removing 10 this concept from the DVO system will require some work and some 11 care. This value is NOT reflected in the image->Mcal values 12 13 * on-the-fly calibration: addstar was used by CFHT skyprobe to 14 measure the sky transparency. This calculation was done by 15 measuring the zero point between the Tycho stars in the database 16 and the stars in the image. Star data is saved in 17 AddToCalibration as they are found (in find_matches, or 18 equivalent). At the end of the match processing, the zero point 19 for the image was calculated with FindCalibration and saved to the 20 image table but NOT the measure table. For skyprobe, the stars 21 are normally not saved to the database -- the Tycho stars are kept 22 in the measure & average tables, and used as the reference for the 23 zero point calculation above. 24 25 For Pan-STARRS, the zero point analysis is performed by psastro 26 before we run addstar. However, there are a few ways we could 27 choose to apply the zero point calculation: 28 29 * use the per-chip zero point reported in the individual chip 30 headers (easy, but fairly wrong) 31 32 * calculate the per-exposure zero point from the chip headers and 33 supply. 34 35 * calculate the per-exposure zero point from the MATCHED_REFS table 36 37 We also need to consider the zero point error. We currently have 38 only dM (poisson error) + dMcal (calibration error). We need to 39 divide dMsys into dMcal (photometry calibration error) and dMap 40 (aperture correction error). 41 42 * zero point options: 43 * NOMINAL : set Mcal = 0.0 44 * CHIP_HEADER : each chip has zero point in header 45 * PHU_HEADER : a single exposure-wide value in the header 46 * CHIP_AVERAGE : determine zero point for exposure from chip zero points 47 * MATCHED_REFS : recalculate from table 1 48 2 49 2009.02.11 -
branches/czw_branch/cleanup/Ohana/src/addstar/include/2mass.h
r17439 r25051 33 33 e_time get2mass_date (char *ptr, int Nbound, int Nmax); 34 34 35 int load2mass_as_rawdata (Sky Table*skytable, char *filename, AddstarClientOptions options);35 int load2mass_as_rawdata (SkyList *skytable, char *filename, AddstarClientOptions options); 36 36 SkyTable *load2mass_acc (char *path, char *accel); 37 37 int get2mass_3star (Stars *star, char *line, int Nmax); -
branches/czw_branch/cleanup/Ohana/src/addstar/include/addstar.h
r24400 r25051 73 73 char TYCHO_DIR[256]; 74 74 char SubpixDatafile[256]; 75 char *USE_NAME; 75 76 char PASSWORD[80]; 76 77 char HOSTNAME[80]; … … 118 119 double FAKE_THETA; // boresite angle for fake images 119 120 121 char ZERO_POINT_OPTION[64]; 122 float ZERO_POINT_OFFSET; 123 120 124 // carries the mosaic into gstars 121 125 … … 187 191 HeaderSet *MatchHeaders PROTO((int **extsize, int *nimage, int mode, Header **headers, int Nheaders)); 188 192 int LoadData PROTO((FILE *f, char *file, Image **images, int *nvalid, Stars **stars, int *Nstars, Header **headers, int *extsize, HeaderSet *headerSets, int NheaderSets)); 193 int GetZeroPointExposure PROTO((Header **headers, HeaderSet *headerSets, int Nimages)); 189 194 190 195 int in_image PROTO((double r, double d, Image *image)); -
branches/czw_branch/cleanup/Ohana/src/addstar/src/ConfigInit.c
r21508 r25051 77 77 if (!ScanConfig (config, "EXTNAME-KEYWORD", "%s", 0, ExtnameKeyword)) { 78 78 strcpy (ExtnameKeyword, "EXTNAME"); 79 } 80 81 // if this config variable is not set, do not set any zero point offset 82 if (!ScanConfig (config, "ZERO_POINT_OPTION", "%s", 0, ZERO_POINT_OPTION)) { 83 strcpy (ZERO_POINT_OPTION, "NOMINAL"); 79 84 } 80 85 -
branches/czw_branch/cleanup/Ohana/src/addstar/src/LoadData.c
r21508 r25051 23 23 24 24 // find image rootname 25 name = filebasename (file); 25 if (USE_NAME) { 26 name = filebasename (USE_NAME); 27 } else { 28 name = filebasename (file); 29 } 30 31 // if zero points are calculated for the full exposure using more than just the matched chip header, 32 // we need to perform that analysis here 33 GetZeroPointExposure (headers, headerSets, Nimages); 26 34 27 35 // now run through the images, interpret the headers and read the stars -
branches/czw_branch/cleanup/Ohana/src/addstar/src/ReadImageHeader.c
r21508 r25051 8 8 double tmp, sec, Cerror, ZeroPt, FWHM_X, FWHM_Y; 9 9 char *c, photname[64], line[80]; 10 PhotCode *photcodeData = NULL; 10 11 11 12 // zero out the entire image structure … … 104 105 return (FALSE); 105 106 } 106 photcode = GetPhotcodeCodebyName (photname);107 if (photcode == 0) {107 photcodeData = GetPhotcodebyName (photname); 108 if (photcodeData == NULL) { 108 109 fprintf (stderr, "photcode %s not found in photcode table\n", photname); 109 110 return (FALSE); 110 111 } 112 photcode = photcodeData[0].code; 111 113 } 112 114 if (photcode == 0) { … … 191 193 } 192 194 195 // XXX this is archaic: we used to set a fixed zero point of 25 to shift data into the range 196 // 0 - 32 so it would fit in an unsigned int. This is also needed because some programs like 197 // sextractor will put in an arbitrary zero point that we need to understand to get back to 198 // instrumental mags. 193 199 gfits_scan (header, "ZERO_PT", "%lf", 1, &ZeroPt); 194 200 if (ZeroPt != GetZeroPoint()) { … … 197 203 } 198 204 205 // if it exists, find the 206 if (!strcasecmp(ZERO_POINT_OPTION, "CHIP_HEADER")) { 207 float ZPT_OBS; 208 if (!photcodeData || !gfits_scan (header, "ZPT_OBS", "%f", 1, &ZPT_OBS)) { 209 fprintf (stderr, "zero point not supplied in header\n"); 210 ZERO_POINT_OFFSET = 0.0; 211 } else { 212 ZERO_POINT_OFFSET = 0.001*photcodeData[0].C - ZPT_OBS; 213 } 214 } 215 199 216 /* secz is in units milli-airmass */ 200 image[0].Mcal = 0.0;217 image[0].Mcal = ZERO_POINT_OFFSET; 201 218 image[0].Xm = NAN_S_SHORT; 202 219 image[0].flags = 0; -
branches/czw_branch/cleanup/Ohana/src/addstar/src/SkyRegionUtils.c
r14401 r25051 11 11 ALLOCATE (subset, SkyList, 1); 12 12 ALLOCATE (subset[0].regions, SkyRegion *, NSUBSET); 13 ALLOCATE (subset[0].filename, char *, NSUBSET); 13 14 subset[0].ownElements = FALSE; // free these elements when freeing the list 14 15 … … 20 21 21 22 subset[0].regions[Nsubset] = input[0].regions[i]; 23 subset[0].filename[Nsubset] = input[0].filename[i]; 22 24 Nsubset ++; 23 CHECK_REALLOCATE (subset[0].regions, SkyRegion *, NSUBSET, Nsubset, 100); 25 if (Nsubset >= NSUBSET) { 26 NSUBSET += 100; 27 REALLOCATE (subset[0].regions, SkyRegion *, NSUBSET); 28 REALLOCATE (subset[0].filename, char *, NSUBSET); 29 } 24 30 subset[0].Nregions = Nsubset; 25 31 } -
branches/czw_branch/cleanup/Ohana/src/addstar/src/args.c
r21508 r25051 46 46 if ((N = get_argument (argc, argv, "-list"))) { 47 47 options.filelist = TRUE; 48 remove_argument (N, &argc, argv); 49 } 50 51 USE_NAME = NULL; 52 if ((N = get_argument (argc, argv, "-use-name"))) { 53 remove_argument (N, &argc, argv); 54 USE_NAME = strcreate (argv[N]); 48 55 remove_argument (N, &argc, argv); 49 56 } -
branches/czw_branch/cleanup/Ohana/src/addstar/src/args_load2mass.c
r18374 r25051 38 38 } 39 39 40 /* only add to existing regions */ 41 options.existing_regions = FALSE; 42 if ((N = get_argument (argc, argv, "-existing-regions"))) { 43 options.existing_regions = TRUE; 44 remove_argument (N, &argc, argv); 45 } 40 46 /* only add to existing objects */ 41 47 options.only_match = FALSE; … … 62 68 options.timeref = 0; 63 69 options.mosaic = FALSE; 64 options.existing_regions = FALSE;65 70 options.skip_missed = FALSE; 66 71 options.closest = FALSE; -
branches/czw_branch/cleanup/Ohana/src/addstar/src/load2mass.c
r7780 r25051 7 7 int i; 8 8 SkyTable *sky, *sky2mass; 9 SkyList *skylist = NULL; 10 SkyList *overlap = NULL; 9 11 AddstarClientOptions options; 10 12 … … 13 15 options = args_load2mass (argc, argv, options); 14 16 17 // load the full sky description table: 15 18 sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE); 16 19 SkyTableSetFilenames (sky, CATDIR, "cpt"); 17 20 21 // generate the subset matching the user-selected region 22 skylist = SkyListByPatch (sky, -1, &UserPatch); 23 24 // if we only match to existing (already populated) regions, limit the select to those regions: 25 if (options.existing_regions) { 26 SkyList *tmp; 27 tmp = SkyListExistingSubset (skylist, CATDIR); 28 SkyListFree (skylist); 29 skylist = tmp; 30 } 31 18 32 path = TWO_MASS_DIR_AS; 19 33 … … 23 37 24 38 for (i = 0; i < sky2mass[0].Nregions; i++) { 39 // check if any of the skylist entries overlap this 2mass catalog: 40 overlap = SkyListByBounds_List (skylist, -1, sky2mass[0].regions[i].Rmin, sky2mass[0].regions[i].Rmax, sky2mass[0].regions[i].Dmin, sky2mass[0].regions[i].Dmax); 41 if (overlap[0].Nregions == 0) { 42 SkyListFree (overlap); 43 continue; 44 } 45 25 46 fprintf (stderr, "loading %s\n", sky2mass[0].filename[i]); 26 load2mass_as_rawdata (sky, sky2mass[0].filename[i], options); 47 load2mass_as_rawdata (overlap, sky2mass[0].filename[i], options); 48 SkyListFree (overlap); 27 49 } 28 50 exit (0); -
branches/czw_branch/cleanup/Ohana/src/addstar/src/load2mass_as_rawdata.c
r21508 r25051 10 10 # define DEBUG 0 11 11 12 int load2mass_as_rawdata (Sky Table*skytable, char *filename, AddstarClientOptions options) {12 int load2mass_as_rawdata (SkyList *skytable, char *filename, AddstarClientOptions options) { 13 13 14 14 int i, j, verbose; … … 109 109 if (tstars[i].D > UserPatch.Dmax) continue; 110 110 111 // identify the relevant catalog 112 skylist = SkyRegionByPoint_List (skytable, -1, tstars[i].R, tstars[i].D); 113 if (skylist[0].Nregions == 0) { 114 SkyListFree (skylist); 115 continue; 116 } 117 region = skylist[0].regions[0]; 118 if (DEBUG) fprintf (stderr, "writing to %s\n", skylist[0].filename[0]); 119 111 120 // collect array of (Stars *) stars in a new output catalog 112 121 Nstars = 0; … … 114 123 ALLOCATE (stars, Stars *, NSTARS); 115 124 116 // identify the relevant catalog 117 skylist = SkyRegionByPoint (skytable, -1, tstars[i].R, tstars[i].D); 118 region = skylist[0].regions[0]; 119 if (DEBUG) fprintf (stderr, "writing to %s\n", skylist[0].filename[0]); 120 125 // loop over stars in this 2mass region that are also in this output region 121 126 for (j = i; j < Ntstars; j++) { 122 127 if (tstars[j].flag) continue; … … 166 171 } 167 172 168 if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f \n", Nstars,173 if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f)\n", Nstars, 169 174 region[0].Rmin, region[0].Rmax, region[0].Dmin, region[0].Dmax); 170 175 -
branches/czw_branch/cleanup/Ohana/src/libdvo/include/dvo.h
r24951 r25051 311 311 float PhotInst (Measure *measure); 312 312 float PhotCat (Measure *measure); 313 float PhotAper (Measure *measure); 313 314 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt); 314 315 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt); … … 441 442 SkyList *SkyListByBounds PROTO((SkyTable *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax)); 442 443 SkyList *SkyListChildrenByBounds PROTO((SkyTable *table, int No, int depth, double Rmin, double Rmax, double Dmin, double Dmax)); 444 443 445 int SkyListMerge PROTO((SkyList **outlist, SkyList *newlist)); 444 446 int SkyListFree PROTO((SkyList *list)); … … 447 449 int SkyTableSetFilenames PROTO((SkyTable *sky, char *path, char *ext)); 448 450 451 SkyList *SkyRegionByPoint_List PROTO((SkyList *inList, int depth, double ra, double dec)); 452 SkyList *SkyListByBounds_List PROTO((SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax)); 453 SkyList *SkyListChildrenByBounds_List PROTO((SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax)); 454 449 455 /* dvo-specific sorting functions */ 450 456 void sortave (Average *ave, int N); -
branches/czw_branch/cleanup/Ohana/src/libdvo/src/dvo_photcode_ops.c
r17253 r25051 249 249 code = &photcodes[0].code[Np]; 250 250 Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 251 252 return (Mcat); 253 } 254 255 float PhotAper (Measure *measure) { 256 257 int Np; 258 float Mcat; 259 PhotCode *code; 260 261 Np = photcodes[0].hashcode[measure[0].photcode]; 262 if (Np == -1) return (NAN); 263 264 if (photcodes[0].code[Np].type == PHOT_REF) { 265 Mcat = measure[0].Map; 266 return (Mcat); 267 } 268 code = &photcodes[0].code[Np]; 269 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 251 270 252 271 return (Mcat); -
branches/czw_branch/cleanup/Ohana/src/libdvo/src/skyregion_ops.c
r24951 r25051 300 300 REALLOCATE (list[0].filename, char *, NNEW); 301 301 } 302 } 303 } 304 305 list[0].Nregions = Nnew; 306 return (list); 307 } 308 309 /* find region which overlaps c at given depth (-1 : populated ) */ 310 SkyList *SkyRegionByPoint_List (SkyList *inList, int depth, double ra, double dec) { 311 312 int i; 313 SkyRegion **region; 314 SkyList *list; 315 316 ALLOCATE (list, SkyList, 1); 317 ALLOCATE (list[0].regions, SkyRegion *, 1); 318 ALLOCATE (list[0].filename, char *, 1); 319 list[0].Nregions = 0; 320 list[0].ownElements = FALSE; // this list is only holding a view to the elements 321 322 region = inList[0].regions; 323 324 for (i = 0; i < inList[0].Nregions; i++) { 325 326 // once we pass our desired depth, quit 327 if ((depth > -1) && (depth < region[i][0].depth)) break; 328 329 // skip tables that do not overlap 330 if (ra < region[i][0].Rmin) continue; 331 if (ra > region[i][0].Rmax) continue; 332 if (dec < region[i][0].Dmin) continue; 333 if (dec > region[i][0].Dmax) continue; 334 335 // skip tables that are not at our depth 336 if ((depth > -1) && (depth > region[i][0].depth)) continue; 337 if ((depth == -1) && (region[i][0].table == FALSE)) continue; 338 339 list[0].regions[0] = region[i]; 340 list[0].filename[0] = inList[0].filename[i]; 341 list[0].Nregions = 1; 342 break; 343 } 344 return (list); 345 } 346 347 SkyList *SkyListByBounds_List (SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax) { 348 349 int i, j, Ns; 350 SkyList *list, *extra; 351 352 Rmin = ohana_normalize_angle (Rmin); 353 Rmax = ohana_normalize_angle (Rmax); 354 355 /* handle 0,360 boundary requests */ 356 /* this is probably wrong: I will get duplicates for all Dec bands... */ 357 if (Rmin > Rmax) { 358 list = SkyListChildrenByBounds_List (table, depth, 0.0, Rmax, Dmin, Dmax); 359 360 extra = SkyListChildrenByBounds_List (table, depth, Rmin, 360.0, Dmin, Dmax); 361 REALLOCATE (list[0].regions, SkyRegion *, list[0].Nregions + extra[0].Nregions); 362 REALLOCATE (list[0].filename, char *, list[0].Nregions + extra[0].Nregions); 363 Ns = list[0].Nregions; 364 for (i = 0; i < extra[0].Nregions; i++) { 365 // search for pre-existing match 366 for (j = 0; j < list[0].Nregions; j++) { 367 if (list[0].regions[j] == extra[0].regions[i]) { 368 goto skip; 369 } 370 } 371 list[0].regions[Ns] = extra[0].regions[i]; 372 list[0].filename[Ns] = extra[0].filename[i]; 373 Ns ++; 374 skip: 375 continue; 376 } 377 list[0].Nregions = Ns; 378 SkyListFree (extra); 379 } else { 380 list = SkyListChildrenByBounds_List (table, depth, Rmin, Rmax, Dmin, Dmax); 381 } 382 383 return (list); 384 } 385 386 SkyList *SkyListChildrenByBounds_List (SkyList *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax) { 387 388 int i, j, Ns, Ne, Nnew, NNEW; 389 int append; 390 SkyList *children; 391 SkyList *list; 392 SkyRegion **region; 393 394 Nnew = 0; 395 NNEW = 50; 396 ALLOCATE (list, SkyList, 1); 397 ALLOCATE (list[0].regions, SkyRegion *, NNEW); 398 ALLOCATE (list[0].filename, char *, NNEW); 399 list[0].ownElements = FALSE; // this list is only holding a view to the elements 400 401 region = table[0].regions; 402 403 // can we assume the skylist is globally sorted by depth? i think so... 404 for (i = 0; i < table[0].Nregions; i++) { 405 406 // once we pass our desired depth, quit 407 if ((depth > -1) && (depth < region[i][0].depth)) break; 408 409 // skip tables that do not overlap 410 if (Rmax <= region[i][0].Rmin) continue; 411 if (Rmin >= region[i][0].Rmax) continue; 412 if (Dmax <= region[i][0].Dmin) continue; 413 if (Dmin >= region[i][0].Dmax) continue; 414 415 // skip tables that are not at our depth 416 if ((depth > -1) && (depth > region[i][0].depth)) continue; 417 if ((depth == -1) && (region[i][0].table == FALSE)) continue; 418 419 list[0].regions[Nnew] = region[i]; 420 list[0].filename[Nnew] = table[0].filename[i]; 421 Nnew ++; 422 if (Nnew >= NNEW) { 423 NNEW += 50; 424 REALLOCATE (list[0].regions, SkyRegion *, NNEW); 425 REALLOCATE (list[0].filename, char *, NNEW); 302 426 } 303 427 } -
branches/czw_branch/cleanup/Ohana/src/opihi/dvo/dbExtractMeasures.c
r21508 r25051 117 117 case MAG_REF: 118 118 value.Flt = PhotRef (equiv, average, secfilt, measure); 119 break; 120 case MAG_APER: 121 value.Flt = PhotAper (measure); 119 122 break; 120 123 case MAG_ERR: -
branches/czw_branch/cleanup/Ohana/src/opihi/dvo/dbFields.c
r21508 r25051 37 37 if (!strcasecmp (string, "ave")) return (MAG_AVE); 38 38 if (!strcasecmp (string, "ref")) return (MAG_REF); 39 if (!strcasecmp (string, "ap")) return (MAG_APER); 40 if (!strcasecmp (string, "aper")) return (MAG_APER); 39 41 if (!strcasecmp (string, "err")) return (MAG_ERR); 40 42 if (!strcasecmp (string, "photflags")) return (MAG_PHOT_FLAGS); -
branches/czw_branch/cleanup/Ohana/src/opihi/include/dvoshell.h
r21508 r25051 27 27 MAG_INST, 28 28 MAG_CAT, 29 MAG_APER, 29 30 MAG_SYS, 30 31 MAG_REL, -
branches/czw_branch/cleanup/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r24951 r25051 232 232 } 233 233 my $out = $image; 234 234 235 # if uri is nil this will get overridded below 236 # (this is for raw stage) 235 237 $out->{image} = $image->{uri}; 236 # $out->{exp_id} = $image->{exp_id}; 237 # $out->{exp_name} = $image->{exp_name}; 238 # $out->{state} = $image->{state}; # state is undef for rawExp, but that's ok 239 # if ($set_class_id) { 240 # $class_id = $image->{class_id}; 241 # $out->{class_id} = $class_id; 242 # } 238 if ($set_class_id) { 239 $class_id = $image->{class_id}; 240 $out->{component} = $class_id; 241 } 243 242 244 243 # find the mask and weight images … … 248 247 $out->{weight} = $ipprc->filename($weight_name, $base, $class_id) if $weight_name; 249 248 } 250 # $out->{camera} = $camera;251 252 249 $out->{astrom} = find_astrometry($ipprc, $image_db, $image, $verbose) if $want_astrom; 253 250 … … 441 438 } 442 439 440 # cache of results of ppConfigDump 441 my %astromSources; 442 my $last_exp_id = 0; 443 my $lastAstromFile; 444 443 445 # find the astrometry file for a given exposure 444 446 # return undef if no completed camRun exists … … 449 451 my $verbose = shift; 450 452 453 my $exp_id = $image->{exp_id}; 454 if (($exp_id eq $last_exp_id) and $lastAstromFile) { 455 # running camtool 60 times is really expensive when the answer is the same 456 return $lastAstromFile; 457 } 458 $last_exp_id = 0; 459 $lastAstromFile = undef; 460 451 461 my $missing_tools; 452 462 my $camtool = can_run("camtool") or (warn "Can't find camtool" and $missing_tools = 1); … … 457 467 } 458 468 459 my $command = "$camtool -dbname $image_db -processedexp -exp_id $ image->{exp_id}";469 my $command = "$camtool -dbname $image_db -processedexp -exp_id $exp_id"; 460 470 # run the tool and parse the output 461 471 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 487 497 my $camRoot = $camdata->{path_base}; 488 498 my $camera = $image->{camera}; 489 my $astromSource ;490 {499 my $astromSource = $astromSources{$camera}; 500 if (!$astromSource) { 491 501 my $command = "$ppConfigDump -camera $camera -dump-recipe PSWARP -"; 492 502 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 499 509 die("Unable to parse metadata config doc"); 500 510 $astromSource = metadataLookupStr($metadata, 'ASTROM.SOURCE'); 511 $astromSources{$camera} = $astromSource; 501 512 } 502 513 503 514 my $astromFile = $ipprc->filename($astromSource, $camRoot); 515 if ($astromFile) { 516 $lastAstromFile = $astromFile; 517 $last_exp_id = $exp_id; 518 } 504 519 505 520 return $astromFile; -
branches/czw_branch/cleanup/arclog/arclog.pl
r24951 r25051 19 19 use Pod::Usage qw( pod2usage ); 20 20 21 my ($ email);21 my ($debug, $email); 22 22 23 23 GetOptions( 24 'email|s=s' => \$email, 24 'debug|d' => \$debug, 25 'email|s=s' => \$email, 25 26 ) || pod2usage( 2 ); 26 27 … … 176 177 = @$rec{qw( host time device event elapse_time errors )}; 177 178 # pack record 178 $query->execute("$host|$time|$device|$event|$elapse_time|$errors") 179 my $rec = "$host|$time|$device|$event|$elapse_time|$errors"; 180 $query->execute($rec) 179 181 or die "database error: $!"; 182 warn "inserting $rec\n" if $debug; 180 183 181 184 # do not print filtered records -
branches/czw_branch/cleanup/arclog/arclog_readdb.pl
r19139 r25051 19 19 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 20 20 21 my $filter_records = 1;21 my $filter_records = 0; 22 22 23 23 my $rcfile = "$ENV{HOME}/.arclogrc"; … … 30 30 die "can not open logdb" unless $dbh; 31 31 32 my $query = $dbh->prepare("SELECT *FROM log")32 my $query = $dbh->prepare("SELECT record, stamp FROM log") 33 33 or die "database error: $!"; 34 34 $query->execute or die "database error: $!"; … … 52 52 @rec{qw( host time device event elapse_time errors )} 53 53 = split(/\|/, $row->[0]); 54 $rec{stamp} = $row->[1]; 54 55 $rec{time} = $strptime->parse_datetime($rec{time}); 55 56 push @records, \%rec; … … 60 61 61 62 RECORDS: foreach my $rec (@records) { 62 my ($host, $ time, $device, $event, $elapse_time, $errors)63 = @$rec{qw( host time device event elapse_time errors )};63 my ($host, $stamp, $time, $device, $event, $elapse_time, $errors) 64 = @$rec{qw( host stamp time device event elapse_time errors )}; 64 65 65 66 # do not print filtered records … … 71 72 72 73 no warnings qw( uninitialized ); 73 print "$ host $time $device $event $elapse_time $errors\n";74 print "$stamp - $host $time $device $event $elapse_time $errors\n"; 74 75 use warnings; 75 76 } -
branches/czw_branch/cleanup/console/scripts/console
r24615 r25051 63 63 =over 4 64 64 65 =item * -- db|-d <db name>65 =item * --user|-u 66 66 67 Name of database (C<namespace>) to write too.67 The C<ssh> username to use when connecting to the console port. 68 68 69 Optional if defined in the F<.nebdiskdrc> file or the appropriate environment 70 variable is set. 71 72 =item * --user|-u <db username> 73 74 Username to authenticate with. 75 76 Optional if defined in the F<.nebdiskdrc> file or the appropriate environment 77 variable is set. 78 79 =item * --pass|-p <db password> 80 81 Password to authenticate with. 82 83 Optional if defined in the F<.nebdiskdrc> file or the appropriate environment 84 variable is set. 85 86 =item * --debug 87 88 This flag prevents the program from "daemonizing" so output can be sent to 89 C<stdout>/C<stderr> and a debugger used on the running process. 90 91 =item * --pidfile <filename> 92 93 Filename to log the running daemon's PID too. 94 95 Optional, if this option is omitted and no value is defined in the 96 F<.nebdiskrc> then no pidfile is created. 97 98 =item * --stop|-s 99 100 Uses the pidfile to kill an already running daemon. 101 102 =item * --restart|-r 103 104 Uses the pidfile to kill an already running daemon and then starts a new 105 instance. 106 107 =item * --verbose|-r 69 =item * --verbose|-v 108 70 109 71 Turns on informational/debugging messages to be sent to the 110 C<stderr>/C<stdout>. This option is probably not very usefully unless combined 111 with C<--debug>. 112 113 =back 114 115 =head1 ENVIRONMENT 116 117 These environment variables may be used in place of the specified command line 118 options. All command line option will override the corresponding environment 119 value. 120 121 =over 4 122 123 =item * C<NEB_DB> 124 125 Equivalent to --db|-d 126 127 =item * C<NEB_USER> 128 129 Equivalent to --user|-u 130 131 =item * C<NEB_PASS> 132 133 Equivalent to --pass|-p 72 C<stderr>/C<stdout>. 134 73 135 74 =back … … 137 76 =head1 RCFILE 138 77 139 This program will attempt to read an C<rcfile> from F<$HOME/.nebdiskrc> and if 140 found will use it's values to override program defaults. Please not that the 141 precedence for values is: command line, rcfile, environment variables. 142 143 The format of the C<rcfile> is in L<YAML> format and uses the following values: 144 145 --- 146 db: nebulous 147 dbpass: '@neb@' 148 dbuser: nebulous 149 mounts: 150 - /mnt 151 - /tmp 152 - /usr 153 pidfile: /var/tmp/nebdiskd 154 poll_interval: 5 155 156 The values C<db>, C<dbpass>, C<dbuser>, and C<pidfile> have the same semantics 157 as their command line and/or environment variable equivalents. 158 159 =over 4 160 161 =item * C<mounts> 162 163 A list of "paths" to C<stat(2)> before mounted volumes are polled. The propose 164 of this option is to attempt to keep "automounted" volumes mounted while this 165 program is running. 166 167 This value may be omitted or left blank. 168 169 =item * C<poll_interval> 170 171 The number of seconds to wait between checks for mounted volumes. 172 173 This value may be omitted or left blank. The default value is C<60>s. 174 175 =back 78 This program will attempt to read an C<rcfile> from F<$HOME/.Consolerc>. 176 79 177 80 =head1 CREDITS … … 209 112 =head1 SEE ALSO 210 113 211 L<Config::YAML> 114 L<Config::YAML>, L<Console>, L<console-config>, L<console-ipp-defaults> 212 115 213 116 =cut -
branches/czw_branch/cleanup/console/scripts/console-config
r24611 r25051 152 152 =head1 RCFILE 153 153 154 This program will attempt to read an C<rcfile> from F<$HOME/.Consolerc> 155 156 The format of the C<rcfile> is in L<YAML> format and uses the following values: 157 158 --- 159 db: nebulous 160 dbpass: '@neb@' 161 dbuser: nebulous 162 mounts: 163 - /mnt 164 - /tmp 165 - /usr 166 pidfile: /var/tmp/nebdiskd 167 poll_interval: 5 168 169 The values C<db>, C<dbpass>, C<dbuser>, and C<pidfile> have the same semantics 170 as their command line and/or environment variable equivalents. 171 172 =over 4 173 174 =item * C<mounts> 175 176 A list of "paths" to C<stat(2)> before mounted volumes are polled. The propose 177 of this option is to attempt to keep "automounted" volumes mounted while this 178 program is running. 179 180 This value may be omitted or left blank. 181 182 =item * C<poll_interval> 183 184 The number of seconds to wait between checks for mounted volumes. 185 186 This value may be omitted or left blank. The default value is C<60>s. 187 188 =back 154 This program will attempt to read an C<rcfile> from F<$HOME/.Consolerc>. 189 155 190 156 =head1 CREDITS … … 222 188 =head1 SEE ALSO 223 189 224 L<Config::YAML> 190 L<Config::YAML>, L<Console>, L<console>, L<console-ipp-defaults> 225 191 226 192 =cut -
branches/czw_branch/cleanup/console/scripts/console-ipp-defaults
r24618 r25051 139 139 =over 4 140 140 141 =item * --verbose|- r141 =item * --verbose|-v 142 142 143 143 Turns on informational/debugging messages to be sent to the … … 180 180 =head1 SEE ALSO 181 181 182 L<Config::YAML>, L<Console> 182 L<Config::YAML>, L<Console>, L<console>, L<console-config> 183 183 184 184 =cut -
branches/czw_branch/cleanup/dbconfig/changes.txt
r24951 r25051 1201 1201 ALTER TABLE distTarget DROP KEY clean; 1202 1202 ALTER TABLE distTarget ADD CONSTRAINT UNIQUE(label, filter, stage, clean); 1203 1204 ALTER TABLE pstampJob DROP COLUMN args; 1205 ALTER TABLE pstampJob DROP COLUMN uri; 1206 ALTER TABLE magicDSRun ADD COLUMN inv_magic_id BIGINT AFTER magic_id; 1207 ALTER TABLE magicDSRun ADD FOREIGN KEY (inv_magic_id) REFERENCES magicRun(magic_id); -
branches/czw_branch/cleanup/dbconfig/magic.md
r24552 r25051 47 47 magic_ds_id S64 0 # Primary Key 48 48 magic_id S64 0 # Primary Key fkey(magic_id) ref magicRun(magic_id) 49 inv_magic_id S64 0 # Primary Key fkey(inverse_magic_id) ref magicRun(magic_id) 49 50 state STR 0 # Key 50 51 stage STR 64 -
branches/czw_branch/cleanup/dbconfig/pstamp.md
r19760 r25051 36 36 jobType STR 16 37 37 fault S32 0 38 uri STR 25539 38 exp_id S64 0 40 39 outputBase STR 255 41 args STR 51142 40 END -
branches/czw_branch/cleanup/doc/misc/docgen.pl
- Property svn:mergeinfo changed
/trunk/doc/misc/docgen.pl merged: 24994
r24951 r25051 4 4 #Run Doxygen and copy the html files produced to alala web server 5 5 #Called daily by cron 6 #Bill Giebink 12/087 6 8 7 use strict; … … 11 10 use File::Copy; 12 11 13 my $srcDir = "/data/ipp003.0/ippTests/src/ipp"; 12 my $srcDir = "/data/ipp002.0/ippDoxygen/ipp"; 13 system `rm -rf /data/ipp002.0/ippDoxygen/ipp`; 14 system `svn co http://svn.pan-starrs.ifa.hawaii.edu/repo/ipp/trunk/ /data/ipp002.0/ippDoxygen/ipp`; 14 15 my $destDir = "/data/alala.0/ippDocs"; 15 16 system `rm -rf $destDir/*`; 16 17 17 18 finddepth(\&wanted, $srcDir); 19 chdir $srcDir; 20 system `/usr/bin/doxygen`; 21 system ("cp -r $srcDir/docs/html/* $destDir"); 18 22 19 23 sub wanted { … … 27 31 my $currDir = $File::Find::dir; 28 32 system ("$currDir/autogen.sh"); 29 system ("doxygen");30 system ("mkdir $destDir/$subDir");31 system ("cp $currDir/docs/html/* $destDir/$subDir");32 33 } 33 34 } - Property svn:mergeinfo changed
-
branches/czw_branch/cleanup/ippScripts/scripts/magic_destreak.pl
r24951 r25051 38 38 39 39 # Parse the command-line arguments 40 my ($magic_ds_id, $camera, $streaks, $ stage, $stage_id, $component, $uri, $path_base, $inverse, $cam_path_base);40 my ($magic_ds_id, $camera, $streaks, $inv_streaks, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base); 41 41 my ($outroot, $recoveryroot); 42 42 my ($replace, $release); … … 47 47 'camera=s' => \$camera, # camera for evaluating file rules 48 48 'streaks=s' => \$streaks, # file containing the list of streaks 49 'inv_streaks=s' => \$inv_streaks,# file containing the list of streaks from the inverse diff 49 50 'stage=s' => \$stage, # raw, chip, warp, or diff 50 51 'stage_id=s' => \$stage_id, # exp_id, chip_id, warp_id, or diff_id … … 52 53 'uri=s' => \$uri, # uri of the input image 53 54 'path_base=s' => \$path_base, # path_base of the input 54 'inverse' => \$inverse, # Inverse subtraction?55 55 'cam_path_base=s'=> \$cam_path_base, # path_base from camera stage (for chip and raw) 56 56 'outroot=s' => \$outroot, # "directory" for temporary images (may be nebulous) … … 94 94 } elsif ($stage ne "camera") { 95 95 &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 96 } 96 } 97 $inv_streaks = undef if defined($inv_streaks) and ($inv_streaks eq "NULL"); 97 98 98 99 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 205 206 206 207 my ($image, $mask, $ch_mask, $weight, $astrom, $sources); 208 209 # if we're destreaking a bothways diff need to combine the 210 # two streaks files 211 my ($allstreaks_fh, $allstreaks_name); 207 212 208 213 if ($stage eq "raw") { … … 234 239 $sources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $path_base); 235 240 } elsif ($stage eq "diff") { 236 my $name = $inverse ? "PPSUB.INVERSE" : "PPSUB.OUTPUT"; # Base name for images 237 $image = $ipprc->filename($name, $path_base); 238 $mask = $ipprc->filename("$name.MASK", $path_base); 239 $weight = $ipprc->filename("$name.VARIANCE", $path_base); 241 $image = $ipprc->filename("PPSUB.OUTPUT", $path_base); 242 $mask = $ipprc->filename("PPSUB.OUTPUT.MASK", $path_base); 243 $weight = $ipprc->filename("PPSUB.OUTPUT.VARIANCE", $path_base); 240 244 $sources = $ipprc->filename("PPSUB.OUTPUT.SOURCES", $path_base); 245 246 if ($inv_streaks) { 247 # create a temporary file containing the contents of the 248 # two streaks files 249 ($allstreaks_fh, $allstreaks_name) = tempfile ("/tmp/all.streaks.XXXX", 250 UNLINK => !$save_temps); 251 252 combine_streaks($allstreaks_fh, $streaks, $inv_streaks); 253 254 # apply the combined streaks to both the forward and inverse diffs 255 $streaks = $allstreaks_name; 256 } 241 257 } 242 258 … … 266 282 } 267 283 } 284 if (($stage eq "diff") and $inv_streaks) { 285 $image = $ipprc->filename("PPSUB.INVERSE", $path_base); 286 $mask = $ipprc->filename("PPSUB.INVERSE.MASK", $path_base); 287 $weight = $ipprc->filename("PPSUB.INVERSE.VARIANCE", $path_base); 288 $sources = $ipprc->filename("PPSUB.INVERSE.SOURCES", $path_base); 289 290 my $command = "$streaksremove -stage $stage -tmproot $tmproot -streaks $streaks -image $image"; 291 292 $command .= " -recovery $recoveryroot" if defined $recoveryroot; 293 $command .= " -mask $mask" if defined $mask; 294 $command .= " -weight $weight" if defined $weight; 295 $command .= " -sources $sources" if defined $sources; 296 $command .= " -replace" if $replace; 297 $command .= " -release" if $release; 298 $command .= " -dbname $dbname" if defined $dbname; 299 unless (defined $no_op) { 300 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 301 run(command => $command, verbose => $verbose); 302 unless ($success) { 303 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 304 &my_die("Unable to perform streaksremove: $error_code", $magic_ds_id, $component, $error_code); 305 } 306 } else { 307 print "skipping command $command\n"; 308 } 309 } 268 310 } else { 269 311 # camera stage. The only work to do is to censor the detections file … … 376 418 } 377 419 420 sub combine_streaks 421 { 422 my $fout = shift; 423 my $fn1 = shift; 424 my $fn2 = shift; 425 426 my ($n1, @streaks1) = read_streaks_file($fn1); 427 my_die("failed to read streaks from $fn1", $magic_ds_id, $component, 428 $PS_EXIT_UNKNOWN_ERROR) if $n1 < 0; 429 430 my ($n2, @streaks2) = read_streaks_file($fn2); 431 my_die("failed to read streaks from $fn2", $magic_ds_id, $component, 432 $PS_EXIT_UNKNOWN_ERROR) if $n2 < 0; 433 434 print $fout $n1 + $n2 . "\n"; 435 436 foreach my $line (@streaks1, @streaks2) { 437 print $fout $line; 438 } 439 440 close $fout 441 or my_die("failed to close combined streaks file", $magic_ds_id, 442 $component, $PS_EXIT_UNKNOWN_ERROR); 443 } 444 445 sub read_streaks_file 446 { 447 my $filename = shift; 448 my $fh; 449 open $fh, "<$filename" or my_die("failed to open $filename", 450 $magic_ds_id, $component, $PS_EXIT_UNKNOWN_ERROR); 451 452 # first line is the number of streaks 453 my $line = <$fh>; 454 chomp $line; 455 my $nstreaks = $line; 456 457 my @streaks; 458 459 foreach $line (<$fh>) { 460 push @streaks, $line; 461 } 462 463 close $fh; 464 465 return ($nstreaks, @streaks); 466 } 467 378 468 379 469 sub my_die -
branches/czw_branch/cleanup/ippScripts/scripts/magic_destreak_revert.pl
- Property svn:mergeinfo changed
/trunk/ippScripts/scripts/magic_destreak_revert.pl merged: 25019,25023-25024
r24951 r25051 180 180 $bsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $backup_path_base); 181 181 } elsif ($stage eq "diff") { 182 my $name = $inverse ? "PPSUB.INVERSE" : "PPSUB.OUTPUT"; # Base name for images182 my $name = "PPSUB.OUTPUT"; 183 183 $image = $ipprc->filename($name, $path_base); 184 184 $mask = $ipprc->filename("$name.MASK", $path_base); 185 185 $weight = $ipprc->filename("$name.VARIANCE", $path_base); 186 $sources = $ipprc->filename(" PPSUB.OUTPUT.SOURCES", $path_base);186 $sources = $ipprc->filename("$name.SOURCES", $path_base); 187 187 $bimage = $ipprc->filename($name, $backup_path_base); 188 188 $bmask = $ipprc->filename("$name.MASK", $backup_path_base); 189 189 $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base); 190 $bsources = $ipprc->filename("PPSUB.OUTPUT.SOURCES", $backup_path_base); 191 } 192 193 if ($image) { 194 revert_file($image, $bimage) or 195 &my_die("failed to restore image file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 196 } 197 198 if ($mask) { 199 if (!revert_file($mask, $bmask)) { 200 if ($stage eq 'chip') { 201 # don't fail if the mask file (from the camera stage) fails to revert. 202 # It probably doesn't exist 203 # XXX: Handle this properly 204 print STDERR "failure to revert mask file, ignored\n"; 205 } else { 206 &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 207 } 208 } 209 } 210 211 if ($ch_mask) { 212 if (!revert_file($ch_mask, $bch_mask)) { 213 &my_die("failed to restore chip mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 214 } 215 } 216 217 218 if ($weight) { 219 revert_file($weight, $bweight) or 220 &my_die("failed to restore variance image", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 221 } 222 223 if ($sources) { 224 revert_file($sources, $bsources) or 225 &my_die("failed to restore sources file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 226 } 227 228 if ($astrom) { 229 revert_file($astrom, $bastrom) or 230 &my_die("failed to restore astrometry file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 190 $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base); 191 } 192 193 revert_files($image, $mask, $weight, $sources, $astrom, $bimage, $bmask, $bweight, $bsources, $bastrom); 194 195 if ($stage eq "diff") { 196 my $name = "PPSUB.INVERSE"; 197 $image = $ipprc->filename($name, $path_base); 198 $mask = $ipprc->filename("$name.MASK", $path_base); 199 $weight = $ipprc->filename("$name.VARIANCE", $path_base); 200 $sources = $ipprc->filename("$name.SOURCES", $path_base); 201 $bimage = $ipprc->filename($name, $backup_path_base); 202 $bmask = $ipprc->filename("$name.MASK", $backup_path_base); 203 $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base); 204 $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base); 205 revert_files($image, $mask, $weight, $sources, undef, $bimage, $bmask, $bweight, $bsources, undef); 231 206 } 232 207 … … 254 229 255 230 ### Pau. 231 232 sub revert_files { 233 my $image = shift; 234 my $mask = shift; 235 my $weight = shift; 236 my $sources = shift; 237 my $astrom = shift; 238 my $bimage = shift; 239 my $bmask = shift; 240 my $bweight = shift; 241 my $bsources = shift; 242 my $bastrom = shift; 243 244 if ($image) { 245 revert_file($image, $bimage) or 246 &my_die("failed to restore image file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 247 } 248 249 if ($mask) { 250 if (!revert_file($mask, $bmask)) { 251 if ($stage eq 'chip') { 252 # don't fail if the mask file (from the camera stage) fails to revert. 253 # It probably doesn't exist 254 # XXX: Handle this properly 255 print STDERR "failure to revert mask file, ignored\n"; 256 } else { 257 &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 258 } 259 } 260 } 261 262 if ($ch_mask) { 263 if (!revert_file($ch_mask, $bch_mask)) { 264 &my_die("failed to restore chip mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 265 } 266 } 267 268 269 if ($weight) { 270 revert_file($weight, $bweight) or 271 &my_die("failed to restore variance image", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 272 } 273 274 if ($sources) { 275 revert_file($sources, $bsources) or 276 &my_die("failed to restore sources file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 277 } 278 279 if ($astrom) { 280 revert_file($astrom, $bastrom) or 281 &my_die("failed to restore astrometry file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 282 } 283 } 256 284 257 285 sub check_keyword - Property svn:mergeinfo changed
-
branches/czw_branch/cleanup/ippScripts/scripts/publish_file.pl
r24707 r25051 134 134 my $file = $ipprc->file_resolve( $files{$comp} ) or 135 135 &my_die("Unable to resolve file $files{$comp}", $pub_id, $PS_EXIT_SYS_ERROR); 136 my_die("Unable to find file $file", $pub_id, $PS_EXIT_ PROG_ERROR) unless $ipprc->file_exists( $file );136 my_die("Unable to find file $file", $pub_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $file ); 137 137 138 138 my $zp = $zp{$comp}; -
branches/czw_branch/cleanup/ippTasks/dist.pro
r24951 r25051 4 4 check.globals 5 5 6 #$LOGSUBDIR = $LOGDIR/dist6 $LOGSUBDIR = $LOGDIR/dist 7 7 mkdir $LOGSUBDIR 8 8 -
branches/czw_branch/cleanup/ippTasks/magic.pro
r24951 r25051 104 104 end 105 105 end 106 macro magic.ds.off 107 task magic.destreak.load 108 active false 109 end 110 task magic.destreak.run 111 active false 112 end 113 end 114 macro magic.ds.on 115 task magic.destreak.load 116 active true 117 end 118 task magic.destreak.run 119 active true 120 end 121 end 122 123 macro magic.ds.status 124 echo magicToDS 125 book listbook magicToDS 126 echo "" 127 echo magicDSToRevert 128 book listbook magicDSToRevert 129 end 130 106 131 107 132 … … 380 405 381 406 periods -poll $LOADPOLL 382 periods -exec $LOADEXEC 383 periods -timeout 20 407 # this query can take a long time 408 periods -exec 10 409 periods -timeout 120 384 410 npending 1 385 411 … … 388 414 389 415 task.exec 390 $run = magicdstool -todestreak -limit 32416 $run = magicdstool -todestreak -limit 120 391 417 if ($DB:n == 0) 392 418 option DEFAULT … … 449 475 book getword magicToDS $pageName camera -var CAMERA 450 476 book getword magicToDS $pageName streaks_uri -var STREAKS 477 book getword magicToDS $pageName inv_streaks_uri -var INV_STREAKS 451 478 book getword magicToDS $pageName stage -var STAGE 452 479 book getword magicToDS $pageName stage_id -var STAGE_ID … … 454 481 book getword magicToDS $pageName uri -var URI 455 482 book getword magicToDS $pageName path_base -var PATH_BASE 456 book getword magicToDS $pageName inverse -var INVERSE457 483 book getword magicToDS $pageName cam_path_base -var CAM_PATH_BASE 458 484 book getword magicToDS $pageName outroot -var OUTROOT … … 473 499 # TODO: do not add recoveryroot or replace if they are null or zero 474 500 475 $run = magic_destreak.pl --magic_ds_id $MAGIC_DS_ID --camera $CAMERA --streaks $STREAKS --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --uri $URI --path_base $PATH_BASE --cam_path_base $CAM_PATH_BASE --outroot $OUTROOT --logfile $logfile --recoveryroot $RECROOT --replace $REPLACE 476 if ("$INVERSE" == "T") 477 # Inverse subtraction 478 $run = $run --inverse 479 end 501 $run = magic_destreak.pl --magic_ds_id $MAGIC_DS_ID --camera $CAMERA --streaks $STREAKS --inv_streaks $INV_STREAKS --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --uri $URI --path_base $PATH_BASE --cam_path_base $CAM_PATH_BASE --outroot $OUTROOT --logfile $logfile --recoveryroot $RECROOT --replace $REPLACE 480 502 481 503 add_standard_args run -
branches/czw_branch/cleanup/ippTasks/pstamp.pro
r24951 r25051 14 14 # example: 15 15 # $PSDBSERVER = -dbserver hostname 16 $PS_DBSERVER = "" 16 if ($?PSDBSERVER == 0) 17 $PS_DBSERVER = "" 18 end 17 19 18 20 macro pstamp.reset … … 363 365 book setword pstampJob $pageName pantaskState RUN 364 366 book getword pstampJob $pageName job_id -var JOB_ID 367 book getword pstampJob $pageName jobType -var JOB_TYPE 368 book getword pstampJob $pageName rownum -var ROWNUM 365 369 book getword pstampJob $pageName dbname -var DBNAME 366 370 book getword pstampJob $pageName outputBase -var OUTPUT_BASE … … 371 375 372 376 373 $run = pstamp_job_run.pl --job_id $JOB_ID -- redirect-output --output_base $OUTPUT_BASE377 $run = pstamp_job_run.pl --job_id $JOB_ID --job_type $JOB_TYPE --rownum $ROWNUM --output_base $OUTPUT_BASE --redirect-output 374 378 add_standard_args run 375 379 -
branches/czw_branch/cleanup/ippTasks/survey.pro
r24951 r25051 4 4 check.globals 5 5 6 list DIFF_WW 7 ThreePi_SouthernRegion.090724 8 end 9 10 $DIFF_WW_CNT = 0 11 12 task diff.check 6 book create SURVEY_DIFF 7 book create SURVEY_MAGIC 8 9 $SURVEY_DIFF_DB = 0 10 $SURVEY_MAGIC_DB = 0 11 12 $SURVEY_EXEC = 120 13 $SURVEY_POLL = 10 14 $SURVEY_TIMEOUT = 600 15 16 17 # user functions to manipulate diff labels 18 macro survey.add.diff 19 if ($0 != 3) 20 echo "USAGE: survey.add.diff (label) (workdir base)" 21 break 22 end 23 book newpage SURVEY_DIFF $1 24 book setword SURVEY_DIFF $1 WORKDIR $2 25 book setword SURVEY_DIFF $1 STATE PENDING 26 end 27 28 macro survey.del.diff 29 if ($0 != 2) 30 echo "USAGE: survey.del.diff (label)" 31 break 32 end 33 book delpage SURVEY_DIFF $1 34 end 35 36 macro survey.show.diff 37 if ($0 != 1) 38 echo "USAGE: survey.show.diff" 39 break 40 end 41 book listbook SURVEY_DIFF 42 end 43 44 # user functions to manipulate magic labels 45 macro survey.add.magic 46 if ($0 != 3) 47 echo "USAGE: survey.add.magic (label) (workdir base)" 48 break 49 end 50 book newpage SURVEY_MAGIC $1 51 book setword SURVEY_MAGIC $1 WORKDIR $2 52 book setword SURVEY_MAGIC $1 STATE PENDING 53 end 54 55 macro survey.del.magic 56 if ($0 != 2) 57 echo "USAGE: survey.del.magic (label)" 58 break 59 end 60 book delpage SURVEY_MAGIC $1 61 end 62 63 macro survey.show.magic 64 if ($0 != 1) 65 echo "USAGE: survey.show.magic" 66 break 67 end 68 book listbook SURVEY_MAGIC 69 end 70 71 72 task survey.diff 13 73 host local 14 74 15 periods -poll 1016 periods -exec 12017 periods -timeout 60075 periods -poll $SURVEY_POLL 76 periods -exec $SURVEY_EXEC 77 periods -timeout $SURVEY_TIMEOUT 18 78 npending 1 19 79 20 stdout $LOGDIR/ diffcheck.log21 stderr $LOGDIR/ diffcheck.log80 stdout $LOGDIR/survey.diff.log 81 stderr $LOGDIR/survey.diff.log 22 82 23 83 # generate diff warp-warp runs 24 84 task.exec 25 if ($DIFF_WW:n == 0) break 26 $run = difftool -dbname gpc1 -definewarpwarp -distance 0.1 -good_frac 0.1 -timediff 3600 27 $run = $run -input_label $DIFF_WW:$DIFF_WW_CNT 28 $run = $run -template_label $DIFF_WW:$DIFF_WW_CNT 29 $run = $run -label $DIFF_WW:$DIFF_WW_CNT 30 $run = $run -workdir neb://@HOST@.0/gpc1/$DIFF_WW:$DIFF_WW_CNT 31 $run = $run -reduction WARPWARP 32 33 $DIFF_WW_CNT ++ 34 if ($DIFF_WW_CNT >= $DIFF_WW:n) 35 echo "reset DIFF_WW_CNT (was $DIFF_WW_CNT)" 36 set DIFF_WW_CNT = 0 37 end 38 85 book npages SURVEY_DIFF -var N 86 if ($N == 0) 87 # echo "No labels for processing" 88 break 89 endif 90 91 book getpage SURVEY_DIFF 0 -var label -key STATE NEW 92 if ("$label" == "NULL") 93 # All labels have been done --- reset 94 # echo "Resetting labels" 95 for i 0 $N 96 book getpage SURVEY_DIFF $i -var label 97 book setword SURVEY_DIFF $label STATE NEW 98 end 99 book getpage SURVEY_DIFF 0 -var label -key STATE NEW 100 101 # Select different database 102 $SURVEY_DIFF_DB ++ 103 if ($SURVEY_DIFF_DB >= $DB:n) 104 $SURVEY_DIFF_DB = 0 105 end 106 end 107 108 book setword SURVEY_DIFF $label STATE DONE 109 book getword SURVEY_DIFF $label WORKDIR -var workdir 110 111 $run = difftool -definewarpwarp -distance 0.1 -good_frac 0.1 -timediff 3600 112 $run = $run -input_label $label 113 $run = $run -template_label $label 114 $run = $run -label $label 115 $run = $run -workdir $workdir/$label/ 116 117 if ($DB:n == 0) 118 option DEFAULT 119 else 120 $run = $run -dbname $DB:$SURVEY_DIFF_DB 121 option $DB:$SURVEY_DIFF_DB 122 end 123 124 # echo $run 39 125 command $run 40 126 end … … 42 128 # success 43 129 task.exit 0 44 echo "checked for new diff runs"130 # echo "Success" 45 131 end 46 132 … … 59 145 end 60 146 end 147 148 149 150 task survey.magic 151 host local 152 153 periods -poll $SURVEY_POLL 154 periods -exec $SURVEY_EXEC 155 periods -timeout $SURVEY_TIMEOUT 156 npending 1 157 158 stdout $LOGDIR/survey.magic.log 159 stderr $LOGDIR/survey.magic.log 160 161 # generate magic warp-warp runs 162 task.exec 163 book npages SURVEY_MAGIC -var N 164 if ($N == 0) 165 # echo "No labels for processing" 166 break 167 endif 168 169 book getpage SURVEY_MAGIC 0 -var label -key STATE NEW 170 if ("$label" == "NULL") 171 # All labels have been done --- reset 172 # echo "Resetting labels" 173 for i 0 $N 174 book getpage SURVEY_MAGIC $i -var label 175 book setword SURVEY_MAGIC $label STATE NEW 176 end 177 book getpage SURVEY_MAGIC 0 -var label -key STATE NEW 178 179 # Select different database 180 $SURVEY_MAGIC_DB ++ 181 if ($SURVEY_MAGIC_DB >= $DB:n) 182 set $SURVEY_MAGIC_DB = 0 183 end 184 end 185 186 book setword SURVEY_MAGIC $label STATE DONE 187 book getword SURVEY_MAGIC $label WORKDIR -var workdir 188 189 $run = magictool -definebyquery -label $label -diff_label $label -workdir $workdir/$label/ 190 191 if ($DB:n == 0) 192 option DEFAULT 193 else 194 $run = $run -dbname $DB:$SURVEY_MAGIC_DB 195 option $DB:$SURVEY_MAGIC_DB 196 end 197 198 # echo $run 199 command $run 200 end 201 202 # success 203 task.exit 0 204 # echo "Success" 205 end 206 207 # locked list 208 task.exit default 209 showcommand failure 210 end 211 212 task.exit crash 213 showcommand crash 214 end 215 216 # operation times out? 217 task.exit timeout 218 showcommand timeout 219 end 220 end 221 -
branches/czw_branch/cleanup/ippTools/share/Makefile.am
r24951 r25051 151 151 magictool_tomask.sql \ 152 152 magictool_toprocess_inputs.sql \ 153 magictool_toprocess_runs.sql \ 153 154 magictool_toprocess_tree.sql \ 154 155 magictool_toskyfilemask.sql \ -
branches/czw_branch/cleanup/ippTools/share/chiptool_processedimfile.sql
r24112 r25051 8 8 chipProcessedImfile.bg_mean_stdev, 9 9 chipProcessedImfile.path_base, 10 chipProcessedImfile.magicked, 10 11 chipRun.state, 11 12 chipRun.workdir, -
branches/czw_branch/cleanup/ippTools/share/difftool_definewarpstack_part1.sql
r24572 r25051 15 15 SELECT DISTINCT 16 16 diffRun.*, 17 warp_id, 17 18 exp_id 18 19 FROM diffRun … … 24 25 JOIN chipRun USING(chip_id) 25 26 WHERE warp1 IS NOT NULL 26 ) AS diffExp USING(exp_id )27 ) AS diffExp USING(exp_id, warp_id) 27 28 WHERE 28 29 warpSkyfile.fault = 0 -
branches/czw_branch/cleanup/ippTools/share/magicdstool_definebyquery_camera.sql
r24951 r25051 6 6 camRun.cam_id, 7 7 magicRun.label, 8 magicRun.workdir 8 magicRun.workdir, 9 CAST(NULL AS SIGNED) AS inv_magic_id, 10 CAST(NULL AS SIGNED) AS inv_exp_id 9 11 FROM magicRun 10 12 JOIN magicMask USING(magic_id) -
branches/czw_branch/cleanup/ippTools/share/magicdstool_definebyquery_chip.sql
r24951 r25051 6 6 camRun.cam_id, 7 7 magicRun.label, 8 magicRun.workdir 8 magicRun.workdir, 9 CAST(NULL AS SIGNED) AS inv_magic_id, 10 CAST(NULL AS SIGNED) AS inv_exp_id 9 11 FROM magicRun 10 12 JOIN magicMask USING(magic_id) -
branches/czw_branch/cleanup/ippTools/share/magicdstool_definebyquery_diff.sql
r24951 r25051 1 SELECT * 2 FROM ( 1 3 SELECT 2 4 magicRun.magic_id, … … 6 8 0 AS cam_id, 7 9 magicRun.label, 8 magicRun.workdir 10 magicRun.workdir, 11 CAST(NULL AS SIGNED) AS inv_magic_id, 12 CAST(NULL AS SIGNED) AS inv_exp_id 9 13 FROM magicRun 10 14 JOIN magicMask USING(magic_id) … … 15 19 AND ( -- rerun HOOK magicdstool sends "\n1 " if rerun else "\n0 " %s 16 20 OR magicDSRun.magic_ds_id IS NULL) 21 AND diffRun.bothways = 0 17 22 AND diffRun.magicked = 0 18 23 AND diffRun.state = 'full' 24 -- WHERE hook %s 25 UNION 26 SELECT 27 forwardRun.magic_id, 28 forwardRun.exp_id, 29 'diff' AS stage, 30 forwardRun.diff_id AS stage_id, 31 0 AS cam_id, 32 forwardRun.label, 33 forwardRun.workdir, 34 inverseRun.magic_id AS inv_magic_id, 35 inverseRun.exp_id AS inv_exp_id 36 FROM ( 37 SELECT 38 magicRun.magic_id, 39 exp_id, 40 diff_id, 41 magicRun.label, 42 magicRun.workdir 43 FROM magicRun 44 JOIN magicMask USING(magic_id) 45 JOIN diffRun USING(diff_id) 46 LEFT JOIN magicDSRun ON magicRun.magic_id = magicDSRun.magic_id 47 AND magicDSRun.stage = 'diff' 48 WHERE magicRun.state = 'full' 49 AND magicRun.inverse = 0 50 AND ( -- rerun HOOK magicdstool sends "\n1 " if rerun else "\n0 " %s 51 OR magicDSRun.magic_ds_id IS NULL) 52 AND diffRun.state = 'full' 53 AND diffRun.bothways 54 AND diffRun.magicked = 0 55 -- WHERE hook %s 56 ) AS forwardRun 57 JOIN ( 58 SELECT 59 magic_id, 60 exp_id, 61 diff_id 62 FROM magicRun 63 JOIN magicMask USING(magic_id) 64 WHERE magicRun.state = 'full' 65 AND magicRun.inverse = 1 66 ) AS inverseRun USING(diff_id) 19 67 68 ) AS Foo -
branches/czw_branch/cleanup/ippTools/share/magicdstool_definebyquery_raw.sql
r24951 r25051 6 6 0 AS cam_id, 7 7 magicRun.label, 8 magicRun.workdir 8 magicRun.workdir, 9 CAST(NULL AS SIGNED) AS inv_magic_id, 10 CAST(NULL AS SIGNED) AS inv_exp_id 9 11 FROM magicRun 10 12 JOIN magicMask USING(magic_id) -
branches/czw_branch/cleanup/ippTools/share/magicdstool_definebyquery_warp.sql
r24951 r25051 6 6 0 AS cam_id, 7 7 magicRun.label, 8 magicRun.workdir 8 magicRun.workdir, 9 CAST(NULL AS SIGNED) AS inv_magic_id, 10 CAST(NULL AS SIGNED) AS inv_exp_id 9 11 FROM magicRun 10 12 JOIN magicMask USING(magic_id) -
branches/czw_branch/cleanup/ippTools/share/magicdstool_todestreak.sql
r24951 r25051 8 8 camera, 9 9 magicMask.uri as streaks_uri, 10 NULL AS inv_streaks_uri, 10 11 stage, 11 12 stage_id, … … 40 41 camera, 41 42 magicMask.uri as streaks_uri, 43 NULL AS inv_streaks_uri, 42 44 stage, 43 45 stage_id, … … 77 79 camera, 78 80 magicMask.uri as streaks_uri, 81 NULL AS inv_streaks_uri, 79 82 stage, 80 83 stage_id, … … 115 118 camera, 116 119 magicMask.uri as streaks_uri, 120 NULL AS inv_streaks_uri, 117 121 stage, 118 122 stage_id, … … 143 147 AND magicDSFile.component IS NULL 144 148 UNION 145 -- diffSkyfiles149 -- regular diffSkyfiles 146 150 SELECT DISTINCT 147 151 magicDSRun.magic_ds_id, … … 151 155 rawExp.camera, 152 156 magicMask.uri as streaks_uri, 157 NULL AS inv_streaks_uri, 153 158 stage, 154 159 magicRun.diff_id as stage_id, … … 167 172 JOIN magicDSRun USING(magic_id) 168 173 JOIN magicInputSkyfile USING(magic_id) 174 JOIN diffRun USING(diff_id) 169 175 JOIN diffSkyfile 170 176 ON magicRun.diff_id = diffSkyfile.diff_id … … 176 182 magicDSRun.state = 'new' 177 183 AND magicDSRun.stage = 'diff' 184 AND diffRun.bothways = 0 178 185 AND diffSkyfile.fault = 0 179 186 AND diffSkyfile.quality = 0 180 187 AND magicDSFile.component IS NULL 188 -- bothways diffSkyfiles 189 UNION 190 SELECT DISTINCT 191 magicDSRun.magic_ds_id, 192 magicRun.magic_id, 193 magicRun.exp_id, 194 magicDSRun.label, 195 rawExp.camera, 196 magicMask.uri as streaks_uri, 197 (SELECT uri from magicMask where magic_id = inv_magic_id) AS inv_streaks_uri, 198 stage, 199 magicRun.diff_id as stage_id, 200 diffSkyfile.skycell_id as component, 201 NULL AS uri, 202 diffSkyfile.path_base, 203 magicRun.inverse, 204 NULL as cam_path_base, 205 outroot, 206 recoveryroot, 207 re_place, 208 remove 209 FROM rawExp 210 JOIN magicRun USING (exp_id) 211 JOIN magicMask USING (magic_id) 212 JOIN magicDSRun USING(magic_id) 213 JOIN magicInputSkyfile USING(magic_id) 214 JOIN diffRun USING(diff_id) 215 JOIN diffSkyfile 216 ON magicRun.diff_id = diffSkyfile.diff_id 217 AND magicInputSkyfile.node = diffSkyfile.skycell_id 218 LEFT JOIN magicDSFile 219 ON magicDSRun.magic_ds_id = magicDSFile.magic_ds_id 220 AND magicDSFile.component = diffSkyfile.skycell_id 221 WHERE 222 magicDSRun.state = 'new' 223 AND magicDSRun.stage = 'diff' 224 AND diffRun.bothways 225 AND diffSkyfile.fault = 0 226 AND diffSkyfile.quality = 0 227 AND magicDSFile.component IS NULL 181 228 ) as Foo -
branches/czw_branch/cleanup/ippTools/share/pstamptool_addjob_otherjob.sql
r19219 r25051 1 1 INSERT INTO pstampJob 2 (req_id, rownum, state, jobType, uri,exp_id, outputBase, fault)3 VALUES( %lld, '%s', '%s', '%s', '%s',%lld, '%s', %s)2 (req_id, rownum, state, jobType, exp_id, outputBase, fault) 3 VALUES( %lld, '%s', '%s', '%s', %lld, '%s', %s) -
branches/czw_branch/cleanup/ippTools/share/pstamptool_addjob_stampjob.sql
r19219 r25051 1 1 INSERT INTO pstampJob 2 (req_id, rownum, state, jobType, uri, exp_id, outputBase, fault, args)3 VALUES( %lld, '%s', '%s', '%s', '%s', %lld, '%s', %s, '%s')2 (req_id, rownum, state, jobType, exp_id, outputBase, fault) 3 VALUES( %lld, '%s', '%s', '%s', %lld, '%s', %s) -
branches/czw_branch/cleanup/ippTools/share/pxadmin_create_tables.sql
r24951 r25051 1071 1071 magic_ds_id BIGINT AUTO_INCREMENT, 1072 1072 magic_id BIGINT, 1073 inv_magic_id BIGINT, 1073 1074 state VARCHAR(64), 1074 1075 stage VARCHAR(64), … … 1086 1087 KEY(label), 1087 1088 FOREIGN KEY(magic_id) REFERENCES magicRun(magic_id) 1089 FOREIGN KEY(inv_magic_id) REFERENCES magicRun(magic_id) 1088 1090 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1089 1091 … … 1203 1205 jobType VARCHAR(16), 1204 1206 fault SMALLINT, 1205 uri VARCHAR(255),1206 1207 exp_id BIGINT, 1207 1208 outputBase VARCHAR(255), 1208 args VARCHAR(511),1209 1209 PRIMARY KEY(job_id, req_id), 1210 1210 KEY(job_id), -
branches/czw_branch/cleanup/ippTools/share/stacktool_sumskyfile.sql
r24124 r25051 2 2 stackSumSkyfile.*, 3 3 stackRun.state, 4 stackRun.tess_id, 4 5 stackRun.skycell_id, 6 stackRun.filter, 5 7 stackRun.workdir, 8 stackRun.label, 6 9 (SELECT rawExp.camera FROM 7 10 stackInputSkyfile -
branches/czw_branch/cleanup/ippTools/src/difftool.c
r24951 r25051 582 582 PXOPT_COPY_STR(config->args, where, "-skycell_id", "diffInputSkyfile.skycell_id", "=="); 583 583 PXOPT_COPY_S64(config->args, where, "-diff_skyfile_id", "diffInputSkyfile.diff_skyfile_id", "=="); 584 PXOPT_COPY_STR(config->args, where, "-tess_id", "diff Skyfile.tess_id", "==");584 PXOPT_COPY_STR(config->args, where, "-tess_id", "diffRun.tess_id", "=="); 585 585 PXOPT_COPY_S16(config->args, where, "-fault", "diffSkyfile.fault", "=="); 586 586 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); -
branches/czw_branch/cleanup/ippTools/src/disttool.c
r24951 r25051 384 384 psStringAppend(&outroot, "%s/%s/%s", workdir, run_tag, stage); 385 385 386 if (set_label == NULL) { 387 set_label = target_label; 386 psString new_label; 387 if (set_label != NULL) { 388 new_label = set_label; 389 } else { 390 new_label = target_label; 388 391 } 389 392 distRunRow *row = distRunRowAlloc( … … 392 395 stage, 393 396 stage_id, 394 set_label,397 new_label, 395 398 outroot, 396 399 clean, -
branches/czw_branch/cleanup/ippTools/src/magicdstool.c
r24951 r25051 160 160 return false; 161 161 } 162 163 if (psListLength(where->list)) { 164 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 165 psStringAppend(&query, "\n AND %s", whereClause); 166 psFree(whereClause); 167 } 168 psFree(where); 169 170 // treat limit == 0 as "no limit" 171 if (limit) { 172 psString limitString = psDBGenerateLimitSQL(limit); 173 psStringAppend(&query, " %s", limitString); 174 psFree(limitString); 175 } 176 177 if (!p_psDBRunQueryF(config->dbh, query, rerun ? "\n1 " : "\n0 ")) { 178 psError(PS_ERR_UNKNOWN, false, "database error"); 179 psFree(query); 180 return false; 162 char *rerun_flag = rerun ? "\n1 " : "\n0" ; 163 164 if (stageNum != IPP_STAGE_DIFF) { 165 if (psListLength(where->list)) { 166 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 167 psStringAppend(&query, "\nAND %s", whereClause); 168 psFree(whereClause); 169 } 170 psFree(where); 171 172 // treat limit == 0 as "no limit" 173 if (limit) { 174 psString limitString = psDBGenerateLimitSQL(limit); 175 psStringAppend(&query, " %s", limitString); 176 psFree(limitString); 177 } 178 if (!p_psDBRunQueryF(config->dbh, query, rerun_flag)) { 179 psError(PS_ERR_UNKNOWN, false, "database error"); 180 psFree(query); 181 return false; 182 } 183 } else { 184 // diff stage query has two types bothways and !bothways 185 // so we need to send the rerun flag and the where data twice 186 psString whereString = psStringCopy(""); 187 if (psListLength(where->list)) { 188 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 189 psStringAppend(&whereString, "\nAND %s", whereClause); 190 psFree(whereClause); 191 } 192 psFree(where); 193 194 // treat limit == 0 as "no limit" 195 if (limit) { 196 psString limitString = psDBGenerateLimitSQL(limit); 197 psStringAppend(&query, " %s", limitString); 198 psFree(limitString); 199 } 200 201 if (!p_psDBRunQueryF(config->dbh, query, rerun_flag, whereString, rerun_flag, whereString)) { 202 psError(PS_ERR_UNKNOWN, false, "database error"); 203 psFree(whereString); 204 psFree(query); 205 return false; 206 } 207 psFree(whereString); 181 208 } 182 209 psFree(query); … … 215 242 psS64 exp_id = psMetadataLookupS64(NULL, row, "exp_id"); 216 243 psS64 magic_id = psMetadataLookupS64(NULL, row, "magic_id"); 244 psS64 inv_magic_id = psMetadataLookupS64(NULL, row, "inv_magic_id"); 217 245 psS64 cam_id = psMetadataLookupS64(NULL, row, "cam_id"); 218 246 psString magicRunLabel = psMetadataLookupStr(NULL, row, "label"); … … 232 260 0, // magic_ds_id 233 261 magic_id, 262 inv_magic_id, 234 263 "new", 235 264 stage, … … 309 338 0, // ID 310 339 magic_id, 340 0, // inv_magic_id 311 341 "new", // state 312 342 stage, -
branches/czw_branch/cleanup/ippTools/src/magictool.c
r24951 r25051 582 582 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 583 583 PXOPT_COPY_S16(config->args, where, "-fault", "fault", "=="); 584 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 584 585 585 586 psString query = psStringCopy("UPDATE magicRun SET fault = 0, state = 'new' WHERE fault != 0"); … … 803 804 // treat limit == 0 as "no limit" 804 805 if (limit) { 805 psString limitString = psDBGenerateLimitSQL(limit); 806 // cut limit in half 807 // hack to prevent pending leaf nodes from blocking branch nodes 808 psString limitString = psDBGenerateLimitSQL((limit + 1) / 2); 806 809 psStringAppend(&query, " %s", limitString); 807 810 psFree(limitString); … … 849 852 850 853 // look for tree nodes that need to be processed 851 // XXX: This gets all nodes from all magicRuns that are in 'new'state 852 // That doens't seem particularly efficient 853 query = pxDataGet("magictool_toprocess_tree.sql"); 854 query = pxDataGet("magictool_toprocess_runs.sql"); 854 855 if (!query) { 855 856 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); … … 857 858 } 858 859 860 { 861 psString limitString = psDBGenerateLimitSQL( 100 ); 862 psStringAppend(&query, " %s", limitString); 863 psFree(limitString); 864 } 859 865 860 866 if (!p_psDBRunQueryF(config->dbh, query, whereString ? whereString : "")) { … … 867 873 psFree(query); 868 874 869 psArray *magic Tree= p_psDBFetchResult(config->dbh);870 if (!magic Tree) {875 psArray *magicRuns = p_psDBFetchResult(config->dbh); 876 if (!magicRuns) { 871 877 psErrorCode err = psErrorCodeLast(); 872 878 switch (err) { … … 881 887 return false; 882 888 } 883 if (!psArrayLength(magic Tree)) {889 if (!psArrayLength(magicRuns)) { 884 890 psTrace("magictool", PS_LOG_INFO, "no rows found"); 885 psFree(magic Tree);891 psFree(magicRuns); 886 892 return true; 887 893 } 888 894 889 // entries are ordered by magic_id 890 long index = 0; 891 while (index < psArrayLength(magicTree)) { 892 bool status; 895 query = pxDataGet("magictool_toprocess_tree.sql"); 896 if (!query) { 897 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 898 return false; 899 } 900 901 for (psS64 index = 0; index < psArrayLength(magicRuns); index++) { 893 902 if (limit && (psArrayLength(output) >= limit)) { 894 903 break; 895 904 } 896 psS64 current_magic_id = psMetadataLookupS64(&status, magicTree->data[index], "magic_id"); 905 bool status; 906 psS64 magic_id = psMetadataLookupS64(&status, magicRuns->data[index], "magic_id"); 897 907 if (!status) { 898 908 psAbort("failed to lookup value for magic_id column"); 899 909 } 900 901 // find the end of this block 902 long first = index; 903 long last = index; 904 for (long i = index + 1; i < psArrayLength(magicTree); i++) { 905 psS64 magic_id = psMetadataLookupS64(&status, magicTree->data[i], "magic_id"); 906 if (!status) { 907 psAbort("failed to lookup value for magic_id column"); 910 911 whereString = NULL; 912 psStringAppend(&whereString, "\nAND (magic_id = %" PRId64 ")", magic_id); 913 if (!p_psDBRunQueryF(config->dbh, query, whereString )) { 914 psError(PS_ERR_UNKNOWN, false, "database error"); 915 psFree(whereString); 916 psFree(query); 917 return false; 918 } 919 psFree(whereString); 920 psArray *magicTree = p_psDBFetchResult(config->dbh); 921 if (!magicTree) { 922 psErrorCode err = psErrorCodeLast(); 923 switch (err) { 924 case PS_ERR_DB_CLIENT: 925 psError(PXTOOLS_ERR_SYS, false, "database error"); 926 case PS_ERR_DB_SERVER: 927 psError(PXTOOLS_ERR_PROG, false, "database error"); 928 default: 929 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 908 930 } 909 if (magic_id != current_magic_id) { 910 break; 911 } 912 last = i; 913 } 914 915 index = last + 1; 916 917 psHash *forest = psHashAlloc(last - first + 1); 931 932 return false; 933 } 934 psS64 length = psArrayLength(magicTree); 935 if (!length) { 936 psTrace("magictool", PS_LOG_INFO, "no rows found for magic_id %" PRId64, magic_id); 937 psFree(magicTree); 938 continue; 939 } 940 941 psHash *forest = psHashAlloc(length); 918 942 919 943 // convert the array of metadata into a pxTree structure 920 for (long i = first; i <= last; i++) {944 for (long i = 0; i < length; i++) { 921 945 bool status; 922 946 psString node = psMetadataLookupStr(&status, magicTree->data[i], "node"); … … 943 967 pxTreeCrawl(root, findReadyNodes, output); 944 968 psFree(root); 945 946 } 947 psFree(magicTree); 969 psFree(magicTree); 970 } 948 971 949 972 if (psArrayLength(output)) { -
branches/czw_branch/cleanup/ippTools/src/magictoolConfig.c
r24951 r25051 108 108 psMetadataAddS64(reverttreeArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magictool ID", 0); 109 109 psMetadataAddS16(reverttreeArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0); 110 psMetadataAddStr(reverttreeArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 110 111 111 112 // -inputs -
branches/czw_branch/cleanup/ippTools/src/pstamptool.c
r24951 r25051 500 500 PS_ASSERT_PTR_NON_NULL(config, false); 501 501 502 PXOPT_LOOKUP_S64(uri, config->args, "-uri", true, false);503 502 PXOPT_LOOKUP_S64(req_id, config->args, "-req_id", true, false); 504 503 PXOPT_LOOKUP_STR(rownum, config->args, "-rownum", true, false); 505 504 PXOPT_LOOKUP_STR(job_type, config->args, "-job_type", false, false); 506 505 PXOPT_LOOKUP_STR(outputBase, config->args, "-outputBase", true, false); 507 PXOPT_LOOKUP_STR(argString, config->args, "-args", false, false);508 506 PXOPT_LOOKUP_STR(stateString, config->args, "-state", false, false); 509 507 PXOPT_LOOKUP_STR(fault, config->args, "-fault", false, false); … … 519 517 return false; 520 518 } 521 522 if (stampJob && !argString) {523 psError(PS_ERR_UNKNOWN, true, "-args is required for stamp job");524 return false;525 }526 527 519 if (stampJob) { 528 520 query = pxDataGet("pstamptool_addjob_stampjob.sql"); … … 535 527 } 536 528 537 if (!p_psDBRunQueryF(config->dbh, query, req_id, rownum, stateString, job_type, uri, exp_id, outputBase, fault, argString)) {529 if (!p_psDBRunQueryF(config->dbh, query, req_id, rownum, stateString, job_type, exp_id, outputBase, fault)) { 538 530 psError(PS_ERR_UNKNOWN, false, "database error"); 539 531 return false; -
branches/czw_branch/cleanup/ippTools/src/pstamptoolConfig.c
r20151 r25051 100 100 // -addjob 101 101 psMetadata *addjobArgs = psMetadataAlloc(); 102 psMetadataAddStr(addjobArgs, PS_LIST_TAIL, "-uri", 0, "define job file uri", NULL);103 102 psMetadataAddS64(addjobArgs, PS_LIST_TAIL, "-req_id", 0, "define job req_id", 0); 104 103 psMetadataAddStr(addjobArgs, PS_LIST_TAIL, "-rownum", 0, "define job rownum", NULL); 105 104 psMetadataAddStr(addjobArgs, PS_LIST_TAIL, "-job_type", 0, "define job job_type", "stamp"); 106 105 psMetadataAddStr(addjobArgs, PS_LIST_TAIL, "-outputBase", 0, "define job outputBase", NULL); 107 psMetadataAddStr(addjobArgs, PS_LIST_TAIL, "-args", 0, "define job args", NULL);108 106 psMetadataAddStr(addjobArgs, PS_LIST_TAIL, "-state", 0, "new state", "run"); 109 107 psMetadataAddS64(addjobArgs, PS_LIST_TAIL, "-exp_id", 0, "exposure id", 0); … … 128 126 psMetadataAddS64(updatejobArgs, PS_LIST_TAIL, "-job_id", 0, "req_id for which to change state", 0); 129 127 psMetadataAddStr(updatejobArgs, PS_LIST_TAIL, "-state", 0, "new state", NULL); 130 // psMetadataAddStr(updatejobArgs, PS_LIST_TAIL, "-result", 0, "new result", NULL);131 128 psMetadataAddStr(updatejobArgs, PS_LIST_TAIL, "-fault", 0, "new result", NULL); 132 129 -
branches/czw_branch/cleanup/ippTools/src/stacktool.c
r24951 r25051 857 857 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 858 858 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 859 PXOPT_COPY_STR(config->args, where, "-tess_id", "stackRun.tess_id", "=="); 860 PXOPT_COPY_STR(config->args, where, "-skycell_id", "stackRun.skycell_id", "=="); 859 861 860 862 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); -
branches/czw_branch/cleanup/ippTools/src/stacktoolConfig.c
r24951 r25051 159 159 psMetadataAddS64(sumskyfileArgs, PS_LIST_TAIL, "-stack_id", 0, "search by stack ID", 0); 160 160 psMetadataAddS64(sumskyfileArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warp ID", 0); 161 psMetadataAddStr(sumskyfileArgs, PS_LIST_TAIL, "-tess_id", 0, "search by tess ID", 0); 162 psMetadataAddStr(sumskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "search by skycell ID", 0); 161 163 psMetadataAddS64(sumskyfileArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure ID", 0); 162 164 psMetadataAddStr(sumskyfileArgs, PS_LIST_TAIL, "-exp_name", 0, "search by exposure name", NULL); -
branches/czw_branch/cleanup/ippTools/src/warptool.c
r24951 r25051 1192 1192 PXOPT_COPY_S64(config->args, where, "-warp_id", "warpSkyfile.warp_id", "=="); 1193 1193 PXOPT_COPY_STR(config->args, where, "-skycell_id", "warpSkyfile.skycell_id", "=="); 1194 PXOPT_COPY_S64(config->args, where, "-warp_skyfile_id", "warpImfile.warp_skyfile_id", "=="); 1195 PXOPT_COPY_STR(config->args, where, "-skycell_id", "warpSkyfile.skycell_id", "=="); 1194 1196 PXOPT_COPY_STR(config->args, where, "-tess_id", "warpSkyfile.tess_id", "=="); 1195 1197 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); -
branches/czw_branch/cleanup/ippTools/src/warptoolConfig.c
r24951 r25051 208 208 // -warped 209 209 psMetadata *warpedArgs = psMetadataAlloc(); 210 psMetadataAddS64(warpedArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warptool ID", 0); 211 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-skycell_id", 0, "define skycell ID", NULL); 212 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-tess_id", 0, "define tessellation ID", NULL); 213 psMetadataAddS64(warpedArgs, PS_LIST_TAIL, "-exp_id", 0, "define exposure tag", 0); 214 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-exp_name", 0, "define exposure tag", 0); 215 psMetadataAddS64(warpedArgs, PS_LIST_TAIL, "-fake_id", 0, "define phase 3 version of exposure tag", 0); 210 psMetadataAddS64(warpedArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warptool ID", 0); 211 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-skycell_id", 0, "search by skycell ID", NULL); 212 psMetadataAddS64(warpedArgs, PS_LIST_TAIL, "-warp_skyfile_id", 0, "search by skyfile ID", 0); 213 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-tess_id", 0, "search by tessellation ID", NULL); 214 psMetadataAddS64(warpedArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure tag", 0); 215 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-exp_name", 0, "search by exposure tag", 0); 216 psMetadataAddS64(warpedArgs, PS_LIST_TAIL, "-fake_id", 0, "search by phase 3 version of exposure tag", 0); 216 217 psMetadataAddU64(warpedArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 217 psMetadataAddBool(warpedArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);218 psMetadataAddBool(warpedArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 218 219 219 220 // -revertwarped -
branches/czw_branch/cleanup/ippconfig/vysos5/psastro.config
r21502 r25051 12 12 PSASTRO.GRID.NSTAR.MAX S32 800 # max stars accepted for fitting 13 13 14 PSASTRO.MAX.NRAW S32 500 # max stars accepted for fitting (0 for all)14 PSASTRO.MAX.NRAW S32 1000 # max stars accepted for fitting (0 for all) 15 15 PSASTRO.MAX.NREF S32 2000 # max stars accepted for fitting (0 for all) 16 16 … … 26 26 # PSASTRO.GRID.MAX.ANGLE F32 360.0 27 27 # PSASTRO.GRID.DEL.ANGLE F32 1.0 28 PSASTRO.GRID.MIN.ANGLE F32 -10.0 # start angle (degrees)28 PSASTRO.GRID.MIN.ANGLE F32 +6.0 # start angle (degrees) 29 29 PSASTRO.GRID.MAX.ANGLE F32 +10.0 30 PSASTRO.GRID.DEL.ANGLE F32 2.530 PSASTRO.GRID.DEL.ANGLE F32 1.0 31 31 32 32 # 33 PSASTRO.GRID.MIN.SCALE F32 0.9 034 PSASTRO.GRID.MAX.SCALE F32 1. 1035 PSASTRO.GRID.DEL.SCALE F32 0.0 2533 PSASTRO.GRID.MIN.SCALE F32 0.99 34 PSASTRO.GRID.MAX.SCALE F32 1.01 35 PSASTRO.GRID.DEL.SCALE F32 0.01 36 36 37 37 # single-chip radius match in pixels … … 71 71 DVO.GETSTAR.PHOTCODE STR r 72 72 73 PHOTCODE.DATA MULTI 74 PHOTCODE.DATA METADATA 75 FILTER STR r 76 ZEROPT F32 19.0 77 PHOTCODE STR r_SYNTH 78 GHOST_MAX_MAG F32 -20.0 79 END 80 PHOTCODE.DATA METADATA 81 FILTER STR g 82 ZEROPT F32 15.0 83 PHOTCODE STR g_SYNTH 84 GHOST_MAX_MAG F32 -20.0 85 END 86 73 87 PSASTRO.PLOT.REF.MAG.MIN F32 +5.0 74 88 PSASTRO.PLOT.REF.MAG.MAX F32 +12.0 75 89 90 # PSASTRO.MATCH.LUMFUNC BOOL TRUE 91 76 92 # DVO.GETSTAR.MAG.MAX F32 20.0 77 93 # XXX need to be able to limit the density! -
branches/czw_branch/cleanup/magic/remove/src/Line.c
r24382 r25051 444 444 if (y >= 0 && y < numRows) 445 445 { 446 pixel = psAlloc (sizeof(PixelPos)); 447 pixel->x = (unsigned int) x; 448 pixel->y = (unsigned int) y; 449 psArrayAdd (pixels, 1024, pixel); 450 psFree (pixel); 446 psImageSet(pixels, x, y, 1); 451 447 } 452 448 } … … 494 490 if (x >=0 && x < numCols) 495 491 { 496 pixel = psAlloc (sizeof(PixelPos)); 497 pixel->x = (unsigned int) x; 498 pixel->y = (unsigned int) y; 499 psArrayAdd (pixels, 1024, pixel); 500 psFree (pixel); 492 psImageSet(pixels, x, y, 1); 501 493 } 502 494 } -
branches/czw_branch/cleanup/magic/remove/src/streaksextern.c
r24382 r25051 34 34 int i; 35 35 Line line; 36 StreakPixels *pixels = psArrayAllocEmpty (1024); 36 StreakPixels *pixels = psImageAlloc(numCols, numRows, PS_TYPE_U8); 37 psImageInit(pixels, 0); 37 38 int streaksOnComponent = 0; 38 39 -
branches/czw_branch/cleanup/magic/remove/src/streaksextern.h
r20308 r25051 4 4 /** psLib includes */ 5 5 6 #include "ps Array.h"6 #include "psImage.h" 7 7 8 8 /** streakremove includes */ … … 36 36 /** For now, use psArray to define a list of PixelPos pointers */ 37 37 38 typedef ps ArrayStreakPixels;38 typedef psImage StreakPixels; 39 39 40 40 /** Create a list of pixel positions from a Streaks pointer list -
branches/czw_branch/cleanup/magic/remove/src/streaksremove.c
r24951 r25051 13 13 static bool readAndCopyToOutput(streakFiles *sf, bool exciseAll); 14 14 static void exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue); 15 static bool warpedPixel(streakFiles *sfiles, PixelPos *cellCoord);15 static bool warpedPixel(streakFiles *sfiles, int x, int y); 16 16 static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue); 17 17 static void writeImages(streakFiles *sf, bool exciseImageCube); … … 146 146 } 147 147 148 totalStreakPixels += psArrayLength(pixels);149 148 150 149 psTimerStart("REMOVE_STREAKS"); 151 150 152 // for each pixel covered by the streak153 for (int i = 0; i < psArrayLength (pixels); ++i) {154 PixelPos *pixelPos = psArrayGet (pixels, i);155 156 // if this pixel was not part of the warp, skip because it has already been157 // excised (unless we weren't asked to check) 158 if (!checkNonWarpedPixels || warpedPixel(sfiles, pixelPos)) {159 160 excisePixel(sfiles, pixelPos->x, pixelPos->y, true, maskStreak);161 162 } else {163 // This pixel was not included in any warp and has thus already excised164 // by exciseNonWarpedPixels151 for (int y=0 ; y < sfiles->inImage->numRows; y++) { 152 for (int x = 0; x < sfiles->inImage->numCols; x++) { 153 if (psImageGet(pixels, x, y)) { 154 ++totalStreakPixels; 155 if (!checkNonWarpedPixels || warpedPixel(sfiles, x, y)) { 156 157 excisePixel(sfiles, x, y, true, maskStreak); 158 159 } else { 160 // This pixel was not included in any warp and has thus already excised 161 // by exciseNonWarpedPixels 162 } 163 } 165 164 } 166 165 } … … 178 177 exciseImageCube = true; 179 178 } 180 psArrayElementsFree (pixels);181 179 psFree(pixels); 182 180 } … … 756 754 757 755 static bool 758 warpedPixel(streakFiles *sfiles, PixelPos *cellCoord)756 warpedPixel(streakFiles *sfiles, int x, int y) 759 757 { 760 758 PixelPos chipCoord; … … 767 765 // we clip so that the streak calculation code doesn't have to 768 766 // clipping here insures that we don't touch the overscan regions 769 if (( cellCoord->x < 0) || (cellCoord->x >= sfiles->inImage->numCols) ||770 ( cellCoord->y < 0) || (cellCoord->y >= sfiles->inImage->numRows)) {767 if ((x < 0) || (x >= sfiles->inImage->numCols) || 768 (y < 0) || (y >= sfiles->inImage->numRows)) { 771 769 return false; 772 770 } 773 771 774 cellToChipInt(&chipCoord.x, &chipCoord.y, sfiles->astrom, cellCoord->x, cellCoord->y);772 cellToChipInt(&chipCoord.x, &chipCoord.y, sfiles->astrom, x, y); 775 773 776 774 if (chipCoord.x < 0 || chipCoord.x >= sfiles->warpedPixels->numCols) { … … 839 837 } 840 838 841 printf("Censored %d sources\n", numCensored);842 843 839 // get rid of unused elements (don't know if this is necessary) 844 840 psArrayRealloc(outTable, j); 845 841 846 842 addDestreakKeyword(in->header); 847 if (! psFitsWriteTable(out->fits, in->header, outTable, extname)) { 848 psError(PS_ERR_IO, false, "failed to write table to %s", out->resolved_name); 849 streaksExit("", PS_EXIT_DATA_ERROR); 843 if (psArrayLength(outTable) > 0) { 844 printf("Censored %d sources\n", numCensored); 845 if (! psFitsWriteTable(out->fits, in->header, outTable, extname)) { 846 psError(PS_ERR_IO, false, "failed to write table to %s", out->resolved_name); 847 streaksExit("", PS_EXIT_DATA_ERROR); 848 } 849 } else { 850 printf("Censored ALL %d sources\n", numCensored); 851 if (! psFitsWriteTableEmpty(out->fits, in->header, inTable->data[0], extname)) { 852 psError(PS_ERR_IO, false, "failed to write empty table to %s", out->resolved_name); 853 streaksExit("", PS_EXIT_DATA_ERROR); 854 } 850 855 } 851 856 -
branches/czw_branch/cleanup/ppMops/src/ppMops.c
r24706 r25051 139 139 psMetadataAddF64(outHeader, PS_LIST_TAIL, "TEL_ALT", 0, "Telescope altitude", alt); 140 140 psMetadataAddF64(outHeader, PS_LIST_TAIL, "TEL_AZ", 0, "Telescope azimuth", az); 141 psMetadataAdd F64(outHeader, PS_LIST_TAIL, "DIFFIMID", 0, "Difference image identifier", imageid);142 psMetadataAdd F64(outHeader, PS_LIST_TAIL, "FPA_ID", 0, "Exposure identifier", fpaid);141 psMetadataAddS32(outHeader, PS_LIST_TAIL, "DIFFIMID", 0, "Difference image identifier", imageid); 142 psMetadataAddS32(outHeader, PS_LIST_TAIL, "FPA_ID", 0, "Exposure identifier", fpaid); 143 143 psMetadataAddStr(outHeader, PS_LIST_TAIL, "OBSCODE", 0, "IAU Observatory code", OBSERVATORY_CODE); 144 144 psMetadataAddF32(outHeader, PS_LIST_TAIL, "STARPSF", 0, "Stellar PSF (arcsec)", psf); -
branches/czw_branch/cleanup/ppStack/src/ppStackMatch.c
r24951 r25051 222 222 } 223 223 psFitsClose(fits); 224 225 // Add in variance factor226 pmSubtractionKernels *kernels = psMetadataLookupPtr(NULL, conv->analysis,227 PM_SUBTRACTION_ANALYSIS_KERNEL); // Kernels228 float vf = pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false); // Variance factor229 psMetadataItem *vfItem = psMetadataLookup(readout->parent->concepts, "CELL.VARFACTOR");230 if (!isfinite(vf)) {231 vf = 1.0;232 }233 if (isfinite(vfItem->data.F32)) {234 vfItem->data.F32 *= vf;235 } else {236 vfItem->data.F32 = vf;237 }238 224 239 225 if (!readImage(&readout->image, options->imageNames->data[index], config) || … … 413 399 } 414 400 415 // Set the variance factor416 psMetadataItem *vfItem = psMetadataLookup(readout->parent->concepts, "CELL.VARFACTOR");417 float vf = psMetadataLookupF32(NULL, conv->analysis, PM_SUBTRACTION_ANALYSIS_VARFACTOR_1);418 if (!isfinite(vf)) {419 vf = 1.0;420 }421 if (isfinite(vfItem->data.F32)) {422 vfItem->data.F32 *= vf;423 } else {424 vfItem->data.F32 = vf;425 }426 427 401 // Replace original images with convolved 428 402 psFree(readout->image); … … 512 486 psBinaryOp(readout->variance, readout->variance, "*", psScalarAlloc(PS_SQR(norm), PS_TYPE_F32)); 513 487 } 514 488 515 489 // Ensure the background value is zero 516 490 psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for background … … 521 495 } else { 522 496 if (!psMetadataLookupBool(NULL, config->arguments, "PPSTACK.SKIP.BG.SUB")) { 523 psLogMsg("ppStack", PS_LOG_INFO, "Correcting convolved image background by %lf (+/- %lf)",524 psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), psStatsGetValue(bg, PS_STAT_ROBUST_STDEV));525 (void)psBinaryOp(readout->image, readout->image, "-",526 psScalarAlloc(psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), PS_TYPE_F32));497 psLogMsg("ppStack", PS_LOG_INFO, "Correcting convolved image background by %lf (+/- %lf)", 498 psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), psStatsGetValue(bg, PS_STAT_ROBUST_STDEV)); 499 (void)psBinaryOp(readout->image, readout->image, "-", 500 psScalarAlloc(psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), PS_TYPE_F32)); 527 501 } 528 502 } 529 503 530 504 531 505 // Measure the variance level for the weighting -
branches/czw_branch/cleanup/psLib/src/fits/psFits.c
r24285 r25051 150 150 char errorBuf[MAX_STRING_LENGTH], *errorMsg; 151 151 #if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) 152 errorMsg = strerror_r(thisErrno, errorBuf, MAX_STRING_LENGTH);153 #else154 152 strerror_r(thisErrno, errorBuf, MAX_STRING_LENGTH); 155 153 errorMsg = errorBuf; 154 #else 155 errorMsg = strerror_r(thisErrno, errorBuf, MAX_STRING_LENGTH); 156 156 #endif 157 157 psError(PS_ERR_IO, true, "Directory (%s) for requested file is not accessible: %s", … … 209 209 char errorBuf[64], *errorMsg; 210 210 # if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) 211 errorMsg = strerror_r (errno, errorBuf, 64);212 # else213 211 strerror_r (errno, errorBuf, 64); 214 212 errorMsg = errorBuf; 213 # else 214 errorMsg = strerror_r (errno, errorBuf, 64); 215 215 # endif 216 psError (PS_ERR_IO, true, "Failed to delete a previously-existing file: %s", errorMsg); 217 fprintf (stderr, "errno: %d, %s, %s : %lx, %lx\n", thisErrno, errorMsg, errorBuf, (long int) errorMsg, (long int) errorBuf); 216 psError(PS_ERR_IO, true, "Failed to delete a previously-existing file (%s), error %d: %s", 217 name, thisErrno, errorMsg); 218 //fprintf(stderr, "errno: %d, %s, %s : %lx, %lx\n", thisErrno, errorMsg, errorBuf, (long int) errorMsg, (long int) errorBuf); 218 219 return NULL; 219 220 } -
branches/czw_branch/cleanup/psLib/src/fits/psFitsHeader.c
r23376 r25051 147 147 return keyword; 148 148 } 149 150 149 151 150 bool psFitsCheckCompressedImagePHU(const psFits *fits, psMetadata *header) … … 497 496 static bool fitsWriteHeader(psFits *fits, // The FITS file handle 498 497 const psMetadata *output, // Metadata that is to be output into the FITS file 499 bool keyStarts // Write out the key starts? 498 bool keyStarts, // Write out the key starts? 499 bool phuImage // Are we writing a PHU image? 500 500 ) 501 501 { 502 502 int status = 0; // Status of cfitsio calls 503 int extnum = psFitsGetExtNum(fits); // Number of extension 503 504 bool simple = true; // If SIMPLE is T, then the file should conform to the FITS standard 504 505 psFitsCompressionType compress = psFitsCompressionGetType(fits); // Compression type 505 if (psFitsGetExtNum(fits) == 0) { 506 if (extnum == 0) { 507 506 508 // We allow the user to write SIMPLE, but it must be boolean 507 509 psMetadataItem *simpleItem = psMetadataLookup(output, "SIMPLE"); // SIMPLE in the header … … 526 528 bool compressing = ((!fits->options || fits->options->conventions.compression) && 527 529 compress != PS_FITS_COMPRESS_NONE) ? true : false; // Are we compressing? 528 529 530 if (compressing) { 530 531 psMetadataItem *simpleItem = psMetadataLookup(output, "SIMPLE"); // SIMPLE in the header … … 538 539 } 539 540 } 540 // int value = simple; // Temporary holder for boolean 541 // fits_update_key(fits->fd, TLOGICAL, "ZSIMPLE", &value, 542 // "Uncompressed file's conformance to FITS standard", &status); 541 if (simple && phuImage && extnum == 1) { 542 // ZSIMPLE is required for decompression with funpack, etc. For funpack to work, ZSIMPLE needs to 543 // go early in the FITS header (otherwise we get "Extension doesn't start with SIMPLE or XTENSION 544 // keyword."). We put it after ZIMAGE by reading ZIMAGE (which sets the insertion pointer) and 545 // then inserting ZSIMPLE. 546 char comment[FLEN_CARD]; // Comment for ZIMAGE; unused 547 int value; // Value for ZIMAGE; unused 548 fits_read_key(fits->fd, TLOGICAL, "ZIMAGE", &value, comment, &status); 549 fits_insert_key_log(fits->fd, "ZSIMPLE", simple, "Uncompressed file's conforms to FITS", &status); 550 } 543 551 } 544 552 … … 699 707 PS_ASSERT_METADATA_NON_NULL(output, false); 700 708 701 return fitsWriteHeader(fits, output, true); 709 return fitsWriteHeader(fits, output, true, false); 710 } 711 712 bool psFitsWriteHeaderImage(psFits *fits, 713 const psMetadata *output, 714 bool phuImage 715 ) 716 { 717 PS_ASSERT_FITS_NON_NULL(fits, false); 718 PS_ASSERT_FITS_WRITABLE(fits, false); 719 PS_ASSERT_METADATA_NON_NULL(output, false); 720 721 return fitsWriteHeader(fits, output, true, phuImage); 702 722 } 703 723 … … 733 753 } 734 754 735 if (output && !fitsWriteHeader(fits, output, false )) {755 if (output && !fitsWriteHeader(fits, output, false, false)) { 736 756 psError(PS_ERR_IO, false, "Unable to write FITS header.\n"); 737 757 return false; -
branches/czw_branch/cleanup/psLib/src/fits/psFitsHeader.h
r22729 r25051 66 66 ); 67 67 68 /** Write a header for an image 69 * Principal difference with psFitsWriteHeader is this allows writing ZSIMPLE for uncompressing a single image 70 */ 71 bool psFitsWriteHeaderImage( 72 psFits *fits, ///< FITS file 73 const psMetadata *output, ///< Header to output 74 bool phuImage ///< Is this image supposed to be in the PHU? 75 ); 76 77 68 78 /** Writes a "blank" --- a header only, with no image or table. 69 79 * -
branches/czw_branch/cleanup/psLib/src/fits/psFitsImage.c
r24951 r25051 616 616 } 617 617 618 bool createPHU = false; // Are we creating a PHU? 619 618 620 // Create the image HDU 619 621 int hdus = psFitsGetSize(fits); // Number of HDUs in file … … 621 623 // We're creating the first image 622 624 fits_create_img(fits->fd, bitPix, naxis, naxes, &status); 625 createPHU = true; 623 626 } else { 624 627 if (!after) { … … 627 630 // Set status to signal fits_insert_img to insert a new primary HDU 628 631 status = PREPEND_PRIMARY; 632 createPHU = true; 629 633 } else { 630 634 // Move back one to perform an insert after the previous HDU … … 641 645 642 646 // write the header, if any. 643 if (header && !psFitsWriteHeader (fits, header)) {647 if (header && !psFitsWriteHeaderImage(fits, header, createPHU)) { 644 648 psError(PS_ERR_IO, false, "Unable to write FITS header.\n"); 645 649 success = false; -
branches/czw_branch/cleanup/psLib/src/math/psStats.c
r24951 r25051 129 129 130 130 # define COUNT_WARNING(LIMIT, INTERVAL, ...) { \ 131 static int nCalls = 1; \132 if (nCalls < LIMIT) { \133 psWarning(__VA_ARGS__); \134 } \135 if (!(nCalls % INTERVAL)) { \136 psWarning(__VA_ARGS__); \131 static int nCalls = 1; \ 132 if (nCalls < LIMIT) { \ 133 psWarning(__VA_ARGS__); \ 134 } \ 135 if (!(nCalls % INTERVAL)) { \ 136 psWarning(__VA_ARGS__); \ 137 137 psWarning("(warning raised %d times)", nCalls); \ 138 } \139 nCalls ++; \138 } \ 139 nCalls ++; \ 140 140 } 141 141 142 142 143 143 /*****************************************************************************/ … … 217 217 for (long i = 0; i < numData; i++) { 218 218 // Check if the data is with the specified range 219 if (!isfinite(data[i])) 220 continue;219 if (!isfinite(data[i])) 220 continue; 221 221 if (useRange && (data[i] < stats->min)) 222 222 continue; … … 242 242 243 243 if (!isnan(mean)) { 244 stats->results |= PS_STAT_SAMPLE_MEAN;244 stats->results |= PS_STAT_SAMPLE_MEAN; 245 245 } 246 246 return true; … … 278 278 for (long i = 0; i < num; i++) { 279 279 // Check if the data is with the specified range 280 if (!isfinite(vector[i])) 281 continue;280 if (!isfinite(vector[i])) 281 continue; 282 282 if (useRange && (vector[i] < stats->min)) 283 283 continue; … … 329 329 // into the temporary vectors. 330 330 for (long i = 0; i < inVector->n; i++) { 331 if (!isfinite(input[i])) 332 continue;331 if (!isfinite(input[i])) 332 continue; 333 333 if (useRange && (input[i] < stats->min)) 334 334 continue; … … 353 353 // Sort the temporary vector. 354 354 if (!psVectorSort(outVector, outVector)) { // Sort in-place (since it's a copy, it's OK) 355 // an error in psVectorSort is a serious error355 // an error in psVectorSort is a serious error 356 356 psError(PS_ERR_UNEXPECTED_NULL, false, _("Failed to sort input data.")); 357 357 stats->sampleUQ = NAN; … … 407 407 // If the mean is NAN, then generate a warning and set the stdev to NAN. 408 408 if (isnan(stats->sampleMean)) { 409 COUNT_WARNING(10, 100, "WARNING: vectorSampleStdev(): sample mean is NAN. Setting stats->sampleStdev = NAN.");409 COUNT_WARNING(10, 100, "WARNING: vectorSampleStdev(): sample mean is NAN. Setting stats->sampleStdev = NAN."); 410 410 stats->sampleStdev = NAN; 411 411 return true; … … 425 425 for (long i = 0; i < myVector->n; i++) { 426 426 // Check if the data is with the specified range 427 if (!isfinite(data[i])) 428 continue;427 if (!isfinite(data[i])) 428 continue; 429 429 if (useRange && (data[i] < stats->min)) { 430 430 continue; … … 502 502 for (long i = 0; i < myVector->n; i++) { 503 503 // Check if the data is with the specified range 504 if (!isfinite(data[i])) 505 continue;504 if (!isfinite(data[i])) 505 continue; 506 506 if (useRange && (data[i] < stats->min)) { 507 507 continue; … … 771 771 stats->robustLQ = min; 772 772 stats->robustN50 = numValid; 773 // XXX this is sort of an invalid / out-of-bounds result: to set or not to set these bits:773 // XXX this is sort of an invalid / out-of-bounds result: to set or not to set these bits: 774 774 stats->results |= PS_STAT_ROBUST_MEDIAN; 775 775 stats->results |= PS_STAT_ROBUST_STDEV; … … 801 801 // XXXXX we need to consider this step if errors -> variance 802 802 if (!psVectorHistogram(histogram, myVector, errors, mask, maskVal)) { 803 // if psVectorHistogram returns false, we have a programming error803 // if psVectorHistogram returns false, we have a programming error 804 804 psError(PS_ERR_UNKNOWN, false, "Unable to generate histogram for robust statistics.\n"); 805 psFree(histogram);806 psFree(cumulative);807 psFree(statsMinMax);808 psFree(mask);809 810 return false;805 psFree(histogram); 806 psFree(cumulative); 807 psFree(statsMinMax); 808 psFree(mask); 809 810 return false; 811 811 } 812 812 if (psTraceGetLevel("psLib.math") >= 8) { … … 838 838 839 839 // ADD step 3: Interpolate to the exact 50% position in bin units 840 stats->robustMedian = fitQuadraticSearchForYThenReturnBin(cumulative->bounds, cumulative->nums, binMedian, totalDataPoints/2.0);841 // float robustBin = fitQuadraticSearchForYThenReturnXusingValues(cumulative->bounds, cumulative->nums, binMedian, totalDataPoints/2.0);842 // fprintf (stderr, "robustBin : %f vs %f\n", robustBin, stats->robustMedian);843 844 // convert bin to bin value: this is the robust histogram median.840 stats->robustMedian = fitQuadraticSearchForYThenReturnBin(cumulative->bounds, cumulative->nums, binMedian, totalDataPoints/2.0); 841 // float robustBin = fitQuadraticSearchForYThenReturnXusingValues(cumulative->bounds, cumulative->nums, binMedian, totalDataPoints/2.0); 842 // fprintf (stderr, "robustBin : %f vs %f\n", robustBin, stats->robustMedian); 843 844 // convert bin to bin value: this is the robust histogram median. 845 845 if (isnan(stats->robustMedian)) { 846 846 COUNT_WARNING(10, 100, "Failed to fit a quadratic and calculate the 50-percent position.\n"); … … 1054 1054 if (!vectorRobustStats(myVector, errors, mask, maskVal, stats)) { 1055 1055 psError(PS_ERR_UNKNOWN, false, "failure to measure robust stats\n"); 1056 return false;1057 }1056 return false; 1057 } 1058 1058 } 1059 1059 … … 1107 1107 psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers) 1108 1108 if (!psVectorHistogram(histogram, myVector, errors, mask, maskVal)) { 1109 // if psVectorHistogram returns false, we have a programming error1109 // if psVectorHistogram returns false, we have a programming error 1110 1110 psError(PS_ERR_UNKNOWN, false, "Unable to generate histogram for fitted statistics.\n"); 1111 1111 psFree(histogram); … … 1172 1172 PS_VECTOR_PRINT_F32(y); 1173 1173 } 1174 1175 // psMinimizeLMChi2 can return false for bad data as well as for serious failures1174 1175 // psMinimizeLMChi2 can return false for bad data as well as for serious failures 1176 1176 if (!psMinimizeLMChi2(minimizer, NULL, params, NULL, x, y, NULL, minimizeLMChi2Gauss1D)) { 1177 1177 psError(PS_ERR_UNKNOWN, false, "Failed to fit a gaussian to the robust histogram.\n"); … … 1235 1235 if (!vectorRobustStats(myVector, errors, mask, maskVal, stats)) { 1236 1236 psError(PS_ERR_UNKNOWN, false, "failure to measure robust stats\n"); 1237 return false;1238 }1237 return false; 1238 } 1239 1239 } 1240 1240 … … 1355 1355 // psVectorInit (fitMask, 0); 1356 1356 1357 // XXX not sure if these should result in errors or not...1357 // XXX not sure if these should result in errors or not... 1358 1358 if (!psVectorFitPolynomial1D (poly, NULL, 0, y, NULL, x)) { 1359 1359 psError(PS_ERR_UNKNOWN, false, "Failed to fit a gaussian to the robust histogram.\n"); … … 1432 1432 if (!vectorRobustStats(myVector, errors, mask, maskVal, stats)) { 1433 1433 psError(PS_ERR_UNKNOWN, false, "failure to measure robust stats\n"); 1434 return false;1435 }1434 return false; 1435 } 1436 1436 } 1437 1437 … … 1729 1729 if (!vectorRobustStats(myVector, errors, mask, maskVal, stats)) { 1730 1730 psError(PS_ERR_UNKNOWN, false, "failure to measure robust stats\n"); 1731 return false;1732 }1731 return false; 1732 } 1733 1733 } 1734 1734 … … 1766 1766 COUNT_WARNING(10, 100, "Failed to calculate the min/max of the input vector.\n"); 1767 1767 psFree(statsMinMax); 1768 goto escape;1768 goto escape; 1769 1769 } 1770 1770 … … 1774 1774 stats->fittedMean = min; 1775 1775 stats->fittedStdev = 0.0; 1776 stats->results |= PS_STAT_FITTED_MEAN_V4;1777 stats->results |= PS_STAT_FITTED_STDEV_V4;1776 stats->results |= PS_STAT_FITTED_MEAN_V4; 1777 stats->results |= PS_STAT_FITTED_STDEV_V4; 1778 1778 return true; 1779 1779 } … … 1793 1793 psFree(histogram); 1794 1794 psFree(statsMinMax); 1795 goto escape;1795 goto escape; 1796 1796 } 1797 1797 if (psTraceGetLevel("psLib.math") >= 8) { … … 1825 1825 COUNT_WARNING(10, 100, "Failed to calculate the min/max of the input vector.\n"); 1826 1826 psFree(statsMinMax); 1827 goto escape;1827 goto escape; 1828 1828 } 1829 1829 … … 1886 1886 1887 1887 // fit 2nd order polynomial to ln(y) = -(x-xo)^2/2sigma^2 1888 // XXX this fit may fail with an error for an ill-conditioned matrix (bad data)1889 // we probably should be able to handle the data errors gracefully1888 // XXX this fit may fail with an error for an ill-conditioned matrix (bad data) 1889 // we probably should be able to handle the data errors gracefully 1890 1890 psPolynomial1D *poly = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, 2); 1891 1891 bool status = psVectorFitPolynomial1D (poly, NULL, 0, y, NULL, x); … … 1898 1898 psFree(histogram); 1899 1899 psFree(statsMinMax); 1900 goto escape;1900 goto escape; 1901 1901 } 1902 1902 … … 1917 1917 1918 1918 COUNT_WARNING(10, 100, "fit did not converge\n"); 1919 goto escape;1919 goto escape; 1920 1920 } 1921 1921 … … 1987 1987 psFree(histogram); 1988 1988 psFree(statsMinMax); 1989 goto escape;1989 goto escape; 1990 1990 } 1991 1991 … … 2898 2898 *****************************************************************************/ 2899 2899 static psF32 fitQuadraticSearchForYThenReturnBin(const psVector *xVec, 2900 psVector *yVec,2901 psS32 binNum,2902 psF32 yVal2900 psVector *yVec, 2901 psS32 binNum, 2902 psF32 yVal 2903 2903 ) 2904 2904 { … … 2982 2982 } 2983 2983 2984 // I believe that mathematically the fitted bin position must be between binNum - 1 and binNum + 12985 assert (binValue >= binNum - 1);2986 assert (binValue <= binNum + 1);2987 2988 int fitBin = binValue;2989 float dX = xVec->data.F32[fitBin+1] - xVec->data.F32[fitBin];2990 float dY = binValue - fitBin;2991 tmpFloat = xVec->data.F32[fitBin] + dY * dX;2984 // I believe that mathematically the fitted bin position must be between binNum - 1 and binNum + 1 2985 assert (binValue >= binNum - 1); 2986 assert (binValue <= binNum + 1); 2987 2988 int fitBin = binValue; 2989 float dX = xVec->data.F32[fitBin+1] - xVec->data.F32[fitBin]; 2990 float dY = binValue - fitBin; 2991 tmpFloat = xVec->data.F32[fitBin] + dY * dX; 2992 2992 } else { 2993 2993 // These are special cases where the bin is at the beginning or end of the vector. 2994 2994 if (binNum == 0) { 2995 2995 // We have two points only at the beginning of the vectors x and y. 2996 // X = (dX/dY)(Y - Yo) + Xo 2997 float dX = xVec->data.F32[1] - xVec->data.F32[0]; 2998 float dY = yVec->data.F32[1] - yVec->data.F32[0]; 2999 tmpFloat = (yVal - yVec->data.F32[0]) * (dX / dY) + xVec->data.F32[0]; 2996 // X = (dX/dY)(Y - Yo) + Xo 2997 float dX = xVec->data.F32[1] - xVec->data.F32[0]; 2998 float dY = yVec->data.F32[1] - yVec->data.F32[0]; 2999 if (dY == 0.0) { 3000 tmpFloat = xVec->data.F32[0]; 3001 } else { 3002 tmpFloat = (yVal - yVec->data.F32[0]) * (dX / dY) + xVec->data.F32[0]; 3003 } 3000 3004 } else if (binNum == (xVec->n - 1)) { 3001 3005 // We have two points only at the end of the vectors x and y. 3002 // X = (dX/dY)(Y - Yo) + Xo 3003 float dX = xVec->data.F32[binNum] - xVec->data.F32[binNum-1]; 3004 float dY = yVec->data.F32[binNum] - yVec->data.F32[binNum-1]; 3005 tmpFloat = (yVal - yVec->data.F32[binNum-1]) * (dX / dY) + xVec->data.F32[binNum-1]; 3006 } 3006 // X = (dX/dY)(Y - Yo) + Xo 3007 float dX = xVec->data.F32[binNum] - xVec->data.F32[binNum-1]; 3008 float dY = yVec->data.F32[binNum] - yVec->data.F32[binNum-1]; 3009 if (dY == 0.0) { 3010 tmpFloat = xVec->data.F32[binNum-1]; 3011 } else { 3012 tmpFloat = (yVal - yVec->data.F32[binNum-1]) * (dX / dY) + xVec->data.F32[binNum-1]; 3013 } 3014 } 3007 3015 } 3008 3016 -
branches/czw_branch/cleanup/psModules/src/concepts/pmConcepts.c
r24951 r25051 377 377 conceptRegisterS32("CELL.XWINDOW", "Start of cell window (pixels)",p_pmConceptParse_Positions,p_pmConceptFormat_Positions, NULL, true, PM_FPA_LEVEL_CELL); 378 378 conceptRegisterS32("CELL.YWINDOW", "Start of cell window (pixels)",p_pmConceptParse_Positions,p_pmConceptFormat_Positions, NULL, true, PM_FPA_LEVEL_CELL); 379 conceptRegisterF32("CELL.VARFACTOR", "Variance factor for conversion from large to small scales", NULL, NULL, NULL, true, PM_FPA_LEVEL_CELL);380 379 381 380 // CELL.TRIMSEC … … 485 484 concept[length - 1] = '\0'; 486 485 487 // special variants:488 if (!strcmp(concept, "FPA.DATE")) {489 psTime *fpaTime = psMetadataLookupPtr(NULL, fpa->concepts, "FPA.TIME");490 if (!fpaTime) {491 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Missing concept FPA.TIME needed for FPA.DATE");492 psFree(string);493 return NULL;494 }495 psString dateTimeString = psTimeToISO(fpaTime); // String representation496 psList *dateTime = psStringSplit(dateTimeString, "T", true);497 psFree(dateTimeString);498 psString dateString = psMemIncrRefCounter(psListGet(dateTime, PS_LIST_HEAD)); // The date string499 psFree (dateTime);500 501 if (!psStringSubstitute(&string, dateString, "{FPA.DATE}")) {502 psError(PS_ERR_UNKNOWN, false, "Unable to replace concept %s", concept);503 psFree(string); 504 psFree(dateString);505 return NULL; 506 }507 psFree (dateString);508 continue;509 }486 // special variants: 487 if (!strcmp(concept, "FPA.DATE")) { 488 psTime *fpaTime = psMetadataLookupPtr(NULL, fpa->concepts, "FPA.TIME"); 489 if (!fpaTime) { 490 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Missing concept FPA.TIME needed for FPA.DATE"); 491 psFree(string); 492 return NULL; 493 } 494 psString dateTimeString = psTimeToISO(fpaTime); // String representation 495 psList *dateTime = psStringSplit(dateTimeString, "T", true); 496 psFree(dateTimeString); 497 psString dateString = psMemIncrRefCounter(psListGet(dateTime, PS_LIST_HEAD)); // The date string 498 psFree (dateTime); 499 500 if (!psStringSubstitute(&string, dateString, "{FPA.DATE}")) { 501 psError(PS_ERR_UNKNOWN, false, "Unable to replace concept %s", concept); 502 psFree(string); 503 psFree(dateString); 504 return NULL; 505 } 506 psFree (dateString); 507 continue; 508 } 510 509 511 510 psTrace("psModules.concepts", 7, "Interpolating concept %s", concept); -
branches/czw_branch/cleanup/psModules/src/imcombine/pmSubtractionAnalysis.c
r23780 r25051 129 129 130 130 131 // Set the variance factors132 float vf1 = 1.0, vf2 = 1.0; // Variance factors for each image133 switch (kernels->mode) {134 case PM_SUBTRACTION_MODE_1:135 vf1 = pmSubtractionVarianceFactor(kernels, 0.5, 0.5, false);136 break;137 case PM_SUBTRACTION_MODE_2:138 vf2 = pmSubtractionVarianceFactor(kernels, 0.5, 0.5, false);139 break;140 case PM_SUBTRACTION_MODE_DUAL:141 vf1 = pmSubtractionVarianceFactor(kernels, 0.5, 0.5, false);142 vf2 = pmSubtractionVarianceFactor(kernels, 0.5, 0.5, true);143 break;144 default:145 psAbort("Invalid subtraction mode: %x", kernels->mode);146 }147 148 // Weight by the area149 if (region) {150 float norm = (region->x1 - region->x0 + 1) * (region->y1 - region->y0 + 1) / (numCols * numRows);151 vf1 *= norm;152 vf2 *= norm;153 }154 155 // Update the variance factor156 #define UPDATE_VARFACTOR(VF, ANALYSIS) { \157 psMetadataItem *vfItem = psMetadataLookup(analysis, ANALYSIS); \158 if (vfItem) { \159 psAssert(vfItem->type == PS_TYPE_F32, "Should be the type we said."); \160 vfItem->data.F32 += VF; \161 } else { \162 psMetadataAddF32(analysis, PS_LIST_TAIL, ANALYSIS, 0, "Variance factor weighted by the area", VF); \163 } \164 }165 166 UPDATE_VARFACTOR(vf1, PM_SUBTRACTION_ANALYSIS_VARFACTOR_1);167 UPDATE_VARFACTOR(vf2, PM_SUBTRACTION_ANALYSIS_VARFACTOR_2);168 169 131 // Kernel shape 170 132 { -
branches/czw_branch/cleanup/psconfig/pschecklibs
r24068 r25051 100 100 # search for, and drop, existing libdir entry in libpath? 101 101 unshift @libpath, $libdir; 102 103 # XXX a temporary hack for libreadline (this failed... needed to modify libreadline/support/shobj-conf 104 # $shlib_libs = $ENV{'SHLIB_LIBS'}; 105 # unless ($shlib_libs =~ m|-lncurses|) { 106 # $shlib_libs .= " -lncurses"; 107 # } 108 # $ENV{'SHLIB_LIBS'} = $shlib_libs; 102 109 103 110 # add the path defined by PATH -
branches/czw_branch/cleanup/psconfig/tagsets/ipp-2.9.libs
r24399 r25051 29 29 lib libpthread NONE NONE NONE NONE N NONE NONE NONE 30 30 lib libncurses curses,termcap NONE ncurses-5.6.tar.gz ncurses-5.6 N NONE NONE NONE 31 lib libreadline NONE NONE readline-5.2-p1 2.tar.gz readline-5.2-p12Y NONE NONE NONE31 lib libreadline NONE NONE readline-5.2-p13.tar.gz readline-5.2-p13 Y NONE NONE NONE 32 32 lib libz NONE NONE zlib-1.2.3.tar.gz zlib-1.2.3 N --shared NONE NONE 33 33 lib libpng NONE NONE libpng-1.2.15.tar.gz libpng-1.2.15 N NONE NONE NONE -
branches/czw_branch/cleanup/psphot/doc/notes.20090523.txt
r24583 r25051 1 1 2 20090 523 : extended source analysis -- further development2 20090725 : extended source radial profiles 3 3 4 issues to address:4 I need to fix the Petrosian and similar code. There are several issues: 5 5 6 * quality of moments used for initial psf selection 7 - what is the behavior of moments with Gaussian windowing as function of S/N & size? 8 - can we choose a sigma value that will give reliable moments for an expected range of seeing? 6 1) correct implementation of the actual Petrosian radius / Petrosian flux measurement: 9 7 10 * moments for galaxy model guesses 11 - trade-off between Gaussian windowing, tophat windowing, and S/N windowing in footprint area 8 R_p : Given F(R) : F(0) / F(R_p) = 0.9 ?? (something like this...) 12 9 13 initial dev work:10 Actually implemented by calculating the average surface brightness in annullii: 14 11 15 * add Gaussian windowing, S/N windowing, (tophat windowing) and options to select 12 R_p : Given F(R) -> define f(R) = \sum_{R-dR}^{R+dR}F(R) / 4\pi R dR 13 R_p : f(dR) / F(R_p) = P_ratio 16 14 17 * check visualization of moments 15 2) need to construct a clean, normalized radial profile to make this measurement 16 17 * generate radial profiles for each of N annular wedges 18 * find R_50 : f(0) / f(R_50) = 0.5 19 $ fit the ellipse of R_50 to Rmaj sin(T) + Rmin cos(T) 20 21 22 cos(a+b) = cos(a) cos(b) - sin(a) sin(b) 23 sin(a+b) = cos(a) sin(b) + cos(b) sin(a) 24 25 cos(theta+To) = cos(theta) cos(To) - sin(theta) sin(To) 26 sin(theta+To) = cos(theta) sin(To) + sin(theta) cos(To) 27 28 R_x = R_maj cos(theta + theta_o) = R_maj cos(theta) cos(theta_o) - Rmaj sin(theta) sin(theta_o) 29 R_y = R_min sin(theta + theta_o) = R_min cos(theta) sin(theta_o) + Rmin sin(theta) cos(theta_o) 30 31 R_X = R_x cos(phi) - R_y sin(phi) 32 R_Y = R_x sin(phi) + R_y cos(phi) 33 34 R_X = R_maj cos(phi) cos(theta + To) - R_min sin(phi) sin(theta + To) 35 R_Y = R_maj sin(phi) cos(theta + To) + R_min cos(phi) sin(theta + To) 36 37 R_X = (R_maj cos(phi) cos (To) - R_min sin(phi) sin(To)) cos(theta) - (Rmaj cos(phi) sin(To) + Rmin sin(phi) cos(To)) sin(theta) 38 R_Y = (R_maj sin(phi) cos (To) + R_min cos(phi) sin(To)) cos(theta) - (Rmaj cos(phi) sin(To) + Rmin sin(phi) cos(To)) sin(theta) 39 40 41 R_X = Ax cos(theta) + Bx sin(theta) 42 R_Y = Ay cos(theta) + By sin(theta) 43 44 Ax = \sum (R_X * cos(theta)) 45 Bx = \sum (R_X * sin(theta)) 46 Ay = \sum (R_Y * cos(theta)) 47 By = \sum (R_Y * sin(theta)) 48 49 R_maj = sqrt(Ax^2 + Ay^2) 50 R_min = sqrt(Bx^2 + By^2) 51 52 phi = atan2(Bx + By, Ax + Ay) 53 54 *** get rest of math from my notebook... 55 56 18 57 19 58 20090525 : some clarity of issues: … … 40 79 41 80 * QGAUSS with see 81 82 20090523 : extended source analysis -- further development 83 84 issues to address: 85 86 * quality of moments used for initial psf selection 87 - what is the behavior of moments with Gaussian windowing as function of S/N & size? 88 - can we choose a sigma value that will give reliable moments for an expected range of seeing? 89 90 * moments for galaxy model guesses 91 - trade-off between Gaussian windowing, tophat windowing, and S/N windowing in footprint area 92 93 initial dev work: 94 95 * add Gaussian windowing, S/N windowing, (tophat windowing) and options to select 96 97 * check visualization of moments 98 -
branches/czw_branch/cleanup/pstamp/scripts/pstamp_finish.pl
r24951 r25051 173 173 } 174 174 175 my $exp_info; 176 my $last_exp_id = -1; 175 177 foreach my $job (@jobs) { 176 178 my $job_id = $job->{job_id}; … … 181 183 182 184 my ($row, $req_info, $project) = get_request_info($rows, $rownum); 183 my $proj_hash = resolve_project($ipprc, $project, $dbname); 185 186 my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver); 184 187 my $image_db = $proj_hash->{dbname}; 185 186 # get the metadata for the exposure (if any i.e. stack) 187 # returns an appropriate string if !$exp_id 188 my $exp_info = get_exposure_info($image_db, $exp_id); 188 if (!$image_db) { 189 carp("failed to find imagedb for project: $project"); 190 stop_request($req_id, $PS_EXIT_CONFIG_ERROR); 191 } 192 193 if ($exp_id ne $last_exp_id) { 194 # get the metadata for the exposure (if any i.e. stack) 195 # returns an appropriate string if !$exp_id 196 $exp_info = get_exposure_info($image_db, $exp_id); 197 $last_exp_id = $exp_id; 198 } 189 199 190 200 if (($job_type eq "stamp") || ($job_type eq "get_image")) { … … 292 302 # Create a results file module and provide a list of the names (we have the data in the columns) 293 303 my $rowinfo = "$row->{PROJECT}|$row->{JOB_TYPE}|$row->{REQ_TYPE}|$row->{IMG_TYPE}|"; 294 $rowinfo .= "$row->{ID}|$row->{ CLASS_ID}|$row->{OPTION_MASK}|$row->{MJD_MIN}|$row->{MJD_MAX}|";304 $rowinfo .= "$row->{ID}|$row->{TESS_ID}|$row->{COMPONENT}|$row->{OPTION_MASK}|$row->{MJD_MIN}|$row->{MJD_MAX}|"; 295 305 $rowinfo .= "$row->{REQFILT}|$row->{COORD_MASK}|$row->{CENTER_X}|$row->{CENTER_Y}|"; 296 306 $rowinfo .= "$row->{WIDTH}|$row->{HEIGHT}"; -
branches/czw_branch/cleanup/pstamp/scripts/pstamp_job_run.pl
r24951 r25051 14 14 use Digest::MD5::File qw( file_md5_hex ); 15 15 use PS::IPP::PStamp::RequestFile qw( :standard ); 16 17 my $verbose; 18 my $dbname;19 my $dbserver;20 my $job_id;21 my $redirect_output; 22 my $output_base;23 24 my $host = hostname();25 16 use IPC::Cmd 0.36 qw( can_run run ); 17 18 use PS::IPP::Metadata::Config; 19 #use PS::IPP::Metadata::Stats; 20 #use PS::IPP::Metadata::List qw( parse_md_list ); 21 22 use PS::IPP::Config qw( :standard ); 23 24 my ($job_id, $redirect_output, $outputBase, $rownum, $jobType); 25 my ($verbose, $dbname, $dbserver, $no_update); 26 26 27 27 GetOptions( 28 28 'job_id=s' => \$job_id, 29 'output_base=s' => \$output_base, 30 'redirect-output' => \$redirect_output, 29 'job_type=s' => \$jobType, 30 'rownum=s' => \$rownum, 31 'output_base=s' => \$outputBase, 32 'redirect-output' => \$redirect_output, 31 33 'dbname=s' => \$dbname, 32 34 'dbserver=s' => \$dbserver, 33 35 'verbose' => \$verbose, 36 'no-update' => \$no_update, 34 37 ); 35 38 36 39 40 my $host = hostname(); 37 41 if ($verbose) { 38 42 print "\n\n"; … … 41 45 42 46 die "job_id is required" if !$job_id; 43 die "output_base is required" if !$output_base; 44 45 use IPC::Cmd 0.36 qw( can_run run ); 46 47 use PS::IPP::Metadata::Config; 48 use PS::IPP::Metadata::Stats; 49 use PS::IPP::Metadata::List qw( parse_md_list ); 50 51 use PS::IPP::Config qw($PS_EXIT_SUCCESS 52 $PS_EXIT_UNKNOWN_ERROR 53 $PS_EXIT_SYS_ERROR 54 $PS_EXIT_CONFIG_ERROR 55 $PS_EXIT_PROG_ERROR 56 $PS_EXIT_DATA_ERROR 57 $PS_EXIT_TIMEOUT_ERROR 58 metadataLookupStr 59 metadataLookupBool 60 caturi 61 ); 47 48 my_die( "job_type is required", $job_id, $PS_EXIT_PROG_ERROR) if !$jobType; 49 my_die("rownum is required", $job_id, $PS_EXIT_PROG_ERROR) if !$rownum; 50 my_die("output_base is required", $job_id, $PS_EXIT_PROG_ERROR) if !$outputBase; 51 52 62 53 my $ipprc = PS::IPP::Config->new(); # IPP Configuration 63 64 54 if ($redirect_output) { 65 my $logDest = "$output_base.log"; 66 $ipprc->redirect_output($logDest); 67 } 55 my $logDest = "$outputBase.log"; 56 $ipprc->redirect_output($logDest) 57 or my_die ("unable to redirect output to $logDest", $job_id, $PS_EXIT_UNKNOWN_ERROR); 58 } 59 68 60 69 61 if (!$dbserver) { … … 78 70 79 71 if ($missing_tools) { 80 warn("Can't find required tools."); 81 exit ($PS_EXIT_CONFIG_ERROR); 72 my_die("Can't find required tools", $job_id, $PS_EXIT_CONFIG_ERROR); 82 73 } 83 74 84 75 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 85 76 86 my $psjob; 87 #Look up the uri for the given job 88 { 89 my $command = "$pstamptool -pendingjob -job_id $job_id"; 77 my $jobStatus; 78 if ($jobType eq "stamp") { 79 my $argslist = "$outputBase.args"; 80 open ARGSLIST, "<$argslist" or my_die("failed to open argslist file $argslist", $job_id, $PS_EXIT_UNKNOWN_ERROR); 81 my $argString = <ARGSLIST>; 82 close ARGSLIST; 83 chomp $argString; 84 85 # XXX: should we do any other sanity checking? 86 my_die("arglist file $argslist is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString; 87 88 my $command = "$ppstamp $outputBase $argString"; 90 89 $command .= " -dbname $dbname" if $dbname; 91 90 $command .= " -dbserver $dbserver" if $dbserver; 92 91 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 93 92 run(command => $command, verbose => $verbose); 94 unless ($success) {95 die("Unable to perform pstamptool -pendingjob: $error_code");96 }97 98 if (@$stdout_buf == 0) {99 print STDERR "pending pstamp job id $job_id not found\n";100 exit 0;101 }102 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or103 die("Unable to parse metdata config doc");104 105 my $jobs = parse_md_list($metadata);106 my $num = @$jobs;107 die "unexpected number of jobs $num found for job: $job_id" if $num > 1;108 109 $psjob = $jobs->[0];110 }111 112 if (!$psjob) {113 print STDERR "postage stamp job $job_id not found\n";114 exit 1;115 }116 117 my $rownum = $psjob->{rownum};118 my $uri = $psjob->{uri};119 my $outputBase = $psjob->{outputBase};120 my $argString = $psjob->{args};121 my $jobType = $psjob->{jobType};122 123 my $jobStatus;124 if ($jobType eq "stamp") {125 my $command = "$ppstamp -file $uri $outputBase $argString";126 $command .= " -dbname $dbname" if $dbname;127 $command .= " -dbserver $dbserver" if $dbserver;128 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =129 run(command => $command, verbose => $verbose);130 93 131 94 if ($success) { 132 # XXX shouldn't need to do this, review schema`133 95 my $dir = dirname($outputBase); 134 96 135 97 my $reglist = "$dir/reglist$job_id"; 136 98 137 open F, ">$reglist" or die "can't open $reglist for output"; 138 139 # figure out what output images we should expect 140 141 # Note: we are assuming the contents of the filerules here. 142 my @extensions = ( "fits", "mk.fits", "wt.fits"); 143 144 # we always require an image 99 open F, ">$reglist" or my_die( "can't open $reglist for output", $job_id, $PS_EXIT_UNKNOWN_ERROR); 100 101 # Figure out what output images were produced 102 103 # Note: we are assuming the contents of the PSTAMP filerules here. 104 my %extensions = ( $PSTAMP_SELECT_IMAGE => "fits", 105 $PSTAMP_SELECT_MASK => "mk.fits", 106 $PSTAMP_SELECT_WEIGHT => "wt.fits"); 107 108 # we always create a stamp of the image 145 109 my $output_mask = $PSTAMP_SELECT_IMAGE; 146 110 147 # we search the argString for -mask and - weight.111 # we search the argString for -mask and -variance. 148 112 # searching the arg string allows us to avoid adding a column in pstampJob 149 # XXX yeah but does this make us susceptible to user input fouling us up? 150 # For example, what if somebody sets the output base to file-mask-weight 151 # TODO: clean this up 152 $output_mask |= $PSTAMP_SELECT_MASK if ($argString =~ /-mask/); 153 $output_mask |= $PSTAMP_SELECT_WEIGHT if ($argString =~ /-weight/); 154 155 # XXX we're getting a bit intimate with the bit field definitions here. 156 # do better use a hash 157 158 my $m = 1; 159 foreach my $extension (@extensions) { 160 my $do_this_one = $m & $output_mask; 161 $m = $m << 1; 113 $output_mask |= $PSTAMP_SELECT_MASK if ($argString =~ /-mask/); 114 $output_mask |= $PSTAMP_SELECT_WEIGHT if ($argString =~ /-variance/); 115 116 foreach my $key (keys (%extensions)) { 117 my $do_this_one = $key & $output_mask; 118 162 119 next if (! $do_this_one); 120 121 my $extension = $extensions{$key}; 163 122 164 123 my $basename = basename($outputBase); … … 175 134 } else { 176 135 $jobStatus = $error_code >> 8; 177 print STDERR "ppstamp failed with error code: $jobStatus\n";136 my_die( "ppstamp failed with error code: $jobStatus", $job_id, $jobStatus); 178 137 } 179 138 } elsif ($jobType eq "get_image") { 139 my_die( "get_image jobs not working right now", $job_id, $PS_EXIT_CONFIG_ERROR); 140 141 my $uri = ""; 180 142 my $command = "$pstamp_get_image_job --job_id $job_id --uri $uri --out_dir $outputBase --rownum $rownum"; 181 143 $command .= " --dbname $dbname" if $dbname; … … 188 150 } else { 189 151 $jobStatus = $error_code >> 8; 190 print STDERR "ppstamp failed with error code: $jobStatus\n";152 my_die( "pstamp_get_image_job failed with error code: $jobStatus", $job_id, $jobStatus); 191 153 } 192 154 } elsif ($jobType eq "detect_query") { 193 die("multiple detect_query jobs not supported yet");155 my_die("detect_query jobs not supported yet", $job_id,$PS_EXIT_CONFIG_ERROR); 194 156 } else { 195 die("unknown jobType $jobType found");196 } 197 198 # stop the job and set the result value157 my_die("unknown jobType $jobType found", $job_id, $PS_EXIT_PROG_ERROR); 158 } 159 160 # mark the job stopped in the database 199 161 { 200 my $command = "$pstamptool -updatejob -job_id $job_id -state stop -fault $jobStatus";162 my $command = "$pstamptool -updatejob -job_id $job_id -state stop"; 201 163 $command .= " -dbname $dbname" if $dbname; 202 164 $command .= " -dbserver $dbserver" if $dbserver; 203 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 204 run(command => $command, verbose => $verbose); 205 unless ($success) { 206 die("Unable to perform $command: $error_code"); 207 } 208 } 209 210 exit $jobStatus; 165 if (!$no_update) { 166 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 167 run(command => $command, verbose => $verbose); 168 unless ($success) { 169 die("Unable to perform $command: $error_code"); 170 } 171 } else { 172 print STDERR "skipping command: $command\n" 173 } 174 } 175 176 exit 0; 211 177 212 178 # create a string to be passed as input to dsreg when registering this file in a fileset … … 219 185 if (-e $path) { 220 186 my @finfo = stat($path); 221 die "failed to stat $path" unless (@finfo); # XXX clean up187 my_die("failed to stat $path", $job_id, $PS_EXIT_UNKNOWN_ERROR) unless (@finfo); 222 188 my $bytes = $finfo[7]; 223 189 my $md5sum = file_md5_hex($path); … … 225 191 return "$filename|$bytes|$md5sum|$filetype|"; 226 192 } else { 227 die "$filename not found at $path"; 228 } 229 } 193 my_die("$filename not found at $path", $job_id, $PS_EXIT_UNKNOWN_ERROR); 194 } 195 } 196 197 sub my_die 198 { 199 my $msg = shift; # Warning message on die 200 my $job_id = shift; # job identifier 201 my $exit_code = shift; # Exit code to add 202 203 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 204 205 carp($msg); 206 if (defined $job_id and not $no_update) { 207 my $command = "$pstamptool -updatejob"; 208 $command .= " -job_id $job_id"; 209 $command .= " -fault $exit_code"; 210 $command .= " -dbname $dbname" if defined $dbname; 211 $command .= " -dbserver $dbserver" if defined $dbserver; 212 system($command); 213 } 214 exit $exit_code; 215 } 216 -
branches/czw_branch/cleanup/pstamp/scripts/pstamp_parser_run.pl
r24951 r25051 13 13 use Getopt::Long qw( GetOptions ); 14 14 use File::Basename qw( basename dirname); 15 use POSIX qw( strftime ); 15 16 16 17 my $req_id; … … 74 75 } 75 76 76 # workdir is where we download request files to and place any error output from the parser77 # workdir is where all of the files generated for this request are placed 77 78 # NOTE: this location needs to be kept in sync with the web interface ( request.php ) 78 my $workdir = "$pstamp_workdir/$req_id"; 79 79 my $datestr = strftime "%Y%m%d", gmtime; 80 my $datedir = "$pstamp_workdir/$datestr"; 81 if (! -e $datedir ) { 82 mkdir $datedir or die "failed to create working directory $datedir for request id $req_id"; 83 } 84 85 my $workdir = "$datedir/$req_id"; 80 86 if (! -e $workdir ) { 81 87 mkdir $workdir or die "failed to create working directory $workdir for request id $req_id"; -
branches/czw_branch/cleanup/pstamp/scripts/pstamp_results_file.pl
r21196 r25051 88 88 { name => 'IMG_TYPE', type => '16A', writetype => TSTRING }, 89 89 { name => 'ID', type => '16A', writetype => TSTRING }, 90 { name => 'CLASS_ID', type => '16A', writetype => TSTRING }, 90 { name => 'TESS_ID', type => '64A', writetype => TSTRING }, 91 { name => 'COMPONENT', type => '64A', writetype => TSTRING }, 91 92 92 93 # output parameters -
branches/czw_branch/cleanup/pstamp/scripts/pstampparse.pl
r24951 r25051 133 133 # XXX: TODO: sanity check all parameters 134 134 135 # XXX: TODO: We shouldn't just die in this loop.135 # XXX: TODO: We shouldn't really just die in this loop. 136 136 # If we encounter an error for a particular row 137 137 # add a job with the proper fault code. If there is a db or config error we should probably just … … 146 146 $stage = $row->{IMG_TYPE}; 147 147 my $id = $row->{ID}; 148 my $class_id = $row->{CLASS_ID};149 148 my $component = $row->{COMPONENT}; 149 150 150 my $filter = $row->{REQFILT}; 151 151 my $mjd_min = $row->{MJD_MIN}; 152 152 my $mjd_max = $row->{MJD_MAX}; 153 153 154 my $option_mask= $row->{OPTION_MASK}; 154 155 155 die " region of interest is required to make postage stamps"156 die "valid region of interest is required to make postage stamps" 156 157 if (($job_type eq "stamp") and ! validROI($row)); 157 158 158 159 my $skycenter = $row->{skycenter} = ! ($row->{COORD_MASK} & $PSTAMP_CENTER_IN_PIXELS); 159 $class_id = "" if (defined($class_id) and ($class_id eq "null" or $class_id eq "all"));160 160 $component = "" if (defined($component) and ($component eq "null" or $component eq "all")); 161 161 … … 163 163 164 164 165 # note: resolve_project remembers the last project returned so avoids running166 # pstamptool every time165 # note: resolve_project avoids running pstamptool every time by remembering the 166 # last project resolved 167 167 my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver); 168 168 die "project $project not found\n" unless $proj_hash; … … 176 176 if (@rowList) { 177 177 my $firstRow = $rowList[0]; 178 # XXX: the collecting might work with !$skycenter but I need to think about it 178 179 if ($skycenter and same_images_of_interest($row, $firstRow)) { 179 180 push @rowList, $row; … … 181 182 next; 182 183 } else { 183 # Processthe jobs for this set of rows184 $num_jobs += makeJobs($mode, $stage, $need_magic, \@rowList, $imageList);184 # queue the jobs for this set of rows 185 $num_jobs += queueJobs($mode, \@rowList, $imageList); 185 186 @rowList = (); 186 187 } … … 195 196 # request specification. An array reference is returned 196 197 my ($x, $y); 197 $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $c lass_id, $skycenter,198 $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $component, $skycenter, 198 199 $x, $y, $mjd_min, $mjd_max, $filter, $verbose); 199 200 } … … 203 204 next; 204 205 } 206 $row->{need_magic} = $need_magic; 205 207 push @rowList, $row; 206 208 } 207 209 208 210 if (@rowList) { 209 $num_jobs += makeJobs($mode, $stage, $need_magic, \@rowList, $imageList);211 $num_jobs += queueJobs($mode, \@rowList, $imageList); 210 212 } 211 213 … … 223 225 224 226 225 sub makeJobsForRow227 sub queueJobsForRow 226 228 { 227 229 my $row = shift; 230 my $stage = shift; 228 231 my $imageList = shift; 229 232 my $have_skycells = shift; … … 234 237 foreach my $image (@$imageList) { 235 238 my $component; 236 my $class_id; # get rid of this use componet237 239 if ($have_skycells) { 238 240 $component = $image->{skycell_id}; 239 241 } else { 240 242 $component = $image->{class_id}; 241 $class_id = $component;242 243 } 243 244 … … 249 250 my $roi_string; 250 251 251 # XXX we're depending on other code to insure valid values for roi components 252 # this is checked in and ppstamp but I should check here so that we don't get that far, 253 # but not today 252 # note values were insured to be numbers in validROI() 254 253 my $x = $row->{CENTER_X}; 255 254 my $y = $row->{CENTER_Y}; … … 270 269 } 271 270 272 my $ uri= $image->{image};271 my $imagefile = $image->{image}; 273 272 if (($stage ne "stack") and ($need_magic and !$image->{magicked})) { 274 print STDERR "skippping non-magicked image $uri\n" if $verbose; 273 # XXX: should we add a faulted job so the client can know what happened? 274 print STDERR "skippping non-magicked image $imagefile\n" if $verbose; 275 275 next; 276 276 } … … 278 278 279 279 my $args = $roi_string ? $roi_string : ""; 280 $args .= " -class_id $class_id" if $class_id; 280 if ($stage eq "raw" or $stage eq "chip") { 281 $args .= " -class_id $component" if $component; 282 } 281 283 282 284 $job_num++; 283 284 my $output_base = "$out_dir/${rownum}_${job_num}";285 285 286 286 # add astrometry file for raw and chip images if one is available … … 289 289 } 290 290 291 $args .= " -file $imagefile"; 292 291 293 if (($row->{OPTION_MASK} & $PSTAMP_SELECT_MASK) && $image->{mask} ) { 292 294 $args .= " -mask $image->{mask}"; 293 295 } 294 296 if (($row->{OPTION_MASK} & $PSTAMP_SELECT_WEIGHT) and $image->{weight} ) { 295 $args .= " -weight $image->{weight}"; 296 } 297 $args .= " -variance $image->{weight}"; 298 } 299 300 my $output_base = "$out_dir/${rownum}_${job_num}"; 301 my $argslist = "${output_base}.args"; 302 303 # copy the argument list to a file 304 open ARGSLIST, ">$argslist" or die "failed to open $argslist"; 305 print ARGSLIST "$args\n"; 306 close ARGSLIST or die "failed to close $argslist"; 297 307 298 308 # XXX: TODO: here is where we need to check whether or not the source inputs still exist … … 302 312 303 313 $num_jobs++; 304 my $command = "$pstamptool -addjob -req_id $req_id -job_type $row->{JOB_TYPE}" 305 . " -uri $uri -outputBase $output_base -args '$args' -rownum $rownum" 306 . " -state $newState"; 314 my $command = "$pstamptool -addjob -req_id $req_id -job_type $row->{JOB_TYPE}" 315 . " -outputBase $output_base -rownum $rownum -state $newState"; 307 316 $command .= " -exp_id $exp_id" if $exp_id; 308 317 $command .= " -dbname $dbname" if $dbname; … … 313 322 # this is sort of like the mode -noupdate that some other tools support 314 323 print "$command\n"; 315 } els e{324 } elsif (!$no_update) { 316 325 # mode eq "queue_job" 317 326 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 324 333 die "failed to queue job for request $req_id"; 325 334 } 335 } else { 336 print "skipping command: $command\n"; 326 337 } 327 338 } … … 329 340 } 330 341 331 sub makeJobs342 sub queueJobs 332 343 { 333 344 my $mode = shift; 334 my $stage = shift;335 my $need_magic = shift;336 345 my $rowList = shift; 337 346 my $imageList = shift; 338 347 339 348 my $firstRow = $rowList[0]; 349 my $stage = $firstRow->{IMG_TYPE}; 340 350 my $job_type = $firstRow->{JOB_TYPE}; 351 my $need_magic = $firstRow->{need_magic}; 341 352 342 353 my $num_jobs = 0; … … 381 392 my $astrom = $thisRun->[0]->{astrom}; 382 393 die "no astrometry file found" if !$astrom; 383 $command .= " -astrom $astrom"; 394 my $astrom_resolved = $ipprc->file_resolve($astrom); 395 $command .= " -astrom $astrom_resolved"; 384 396 } 385 397 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 404 416 } 405 417 406 407 # XXX TODO: for raw and chip level images and class_id "null" if there are multiple images408 # use -list instead of -file409 418 foreach my $row (@$rowList) { 410 $num_jobs += makeJobsForRow($row, $thisRun, $have_skycells, $need_magic);419 $num_jobs += queueJobsForRow($row, $stage, $thisRun, $have_skycells, $need_magic); 411 420 } 412 421 } … … 451 460 452 461 my $image = shift @$imageList; 462 $image->{stage} = $stage; 453 463 push @runList, $image; 454 464 $last_run_id = $run_id; … … 461 471 my $r2 = shift; 462 472 463 return 0 if ($r1->{project} ne $r2->{project}); 464 return 0 if ($r1->{job_type} ne $r2->{job_type}); 465 return 0 if ($r1->{req_type} ne $r2->{req_type}); 466 return 0 if ($r1->{img_type} ne $r2->{img_type}); 467 return 0 if ($r1->{id} ne $r2->{id}); 468 # XXX: turn this on when we change the request file format to change class_id into component 469 # return false if ($r1->{component} ne $r2->{component}); 473 return 0 if ($r1->{PROJECT} ne $r2->{PROJECT}); 474 return 0 if ($r1->{JOB_TYPE} ne $r2->{JOB_TYPE}); 475 return 0 if ($r1->{REQ_TYPE} ne $r2->{REQ_TYPE}); 476 return 0 if ($r1->{IMG_TYPE} ne $r2->{IMG_TYPE}); 477 return 0 if ($r1->{ID} ne $r2->{ID}); 478 479 if (defined($r1->{COMPONENT})) { 480 return 0 if !defined $r2->{COMPONENT} or ($r1->{COMPONENT} ne $r2->{COMPONENT}); 481 } elsif (defined($r2->{COMPONENT})) { 482 return 0; 483 } 470 484 471 485 return 1; 472 486 } 473 487 488 sub validNumber 489 { 490 my $val = shift; 491 492 return $val =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/; 493 } 494 474 495 sub validROI 475 496 { 476 497 my $row = shift; 477 return 0 if ! defined $row->{CENTER_X};478 return 0 if ! defined $row->{CENTER_Y};479 return 0 if ! defined $row->{WIDTH};480 return 0 if ! defined $row->{HEIGHT};498 return 0 if !validNumber($row->{CENTER_X}); 499 return 0 if !validNumber($row->{CENTER_Y}); 500 return 0 if !validNumber($row->{WIDTH}); 501 return 0 if !validNumber($row->{HEIGHT}); 481 502 482 503 return 1; -
branches/czw_branch/cleanup/pstamp/src/ppstampArguments.c
r18980 r25051 22 22 fprintf(stderr, "Optional arguments:\n"); 23 23 fprintf(stderr, " [-class_id class_id] selects class_id (only used with -pixcenter)\n"); 24 fprintf(stderr, " [-astrom astrom.cmp] : provide an alternative astrometry calibration\n");25 fprintf(stderr, " [-mask mk_image] : mask image\n");26 fprintf(stderr, " [- weight wt_image] : weightimage\n");24 fprintf(stderr, " [-astrom astrom.cmp] : provide an alternative astrometry calibration\n"); 25 fprintf(stderr, " [-mask mk_image] : mask image\n"); 26 fprintf(stderr, " [-variance var_image] : variance image\n"); 27 27 fprintf(stderr, "\n"); 28 28 … … 81 81 pmConfigFileSetsMD(config->arguments, &argc, argv, "ASTROM", "-astrom", "-astromlist"); 82 82 pmConfigFileSetsMD(config->arguments, &argc, argv, "MASK", "-mask", "-masklist"); 83 pmConfigFileSetsMD(config->arguments, &argc, argv, " WEIGHT", "-weight", "-weightlist");83 pmConfigFileSetsMD(config->arguments, &argc, argv, "VARIANCE", "-variance", "-variancelist"); 84 84 85 85 // the input file is a required argument; if not found, we will exit -
branches/czw_branch/cleanup/pstamp/src/ppstampParseCamera.c
r20148 r25051 18 18 } 19 19 if (doWeight) { 20 pmFPAfile *outWeight = pmFPAfileDefineSkycell(config, output->fpa, "PPSTAMP.OUTPUT. WEIGHT");20 pmFPAfile *outWeight = pmFPAfileDefineSkycell(config, output->fpa, "PPSTAMP.OUTPUT.VARIANCE"); 21 21 outWeight->save = true; 22 22 } … … 54 54 } 55 55 bool doWeight = false; 56 pmFPAfile *weight = pmFPAfileBindFromArgs (&status, input, config, "PPSTAMP.INPUT. WEIGHT", "WEIGHT");56 pmFPAfile *weight = pmFPAfileBindFromArgs (&status, input, config, "PPSTAMP.INPUT.VARIANCE", "VARIANCE"); 57 57 if (!status) { 58 psError(PS_ERR_IO, false, "Failed to build FPA from PPSTAMP.INPUT. WEIGHT");58 psError(PS_ERR_IO, false, "Failed to build FPA from PPSTAMP.INPUT.VARIANCE"); 59 59 return false; 60 60 } -
branches/czw_branch/cleanup/pstamp/test/pstamp_req_create
r20257 r25051 26 26 27 27 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 28 pod2usage( -msg => "Required options: --input --output ",29 -exitval => 3) unless defined $input and defined $output;28 pod2usage( -msg => "Required options: --input --output | --req_name", 29 -exitval => 3) unless defined $input and (defined $output or defined $req_name); 30 30 31 31 # The header kewords … … 55 55 { name => 'IMG_TYPE', type => '16A', writetype => TSTRING }, 56 56 { name => 'ID', type => '16A', writetype => TSTRING }, 57 { name => 'CLASS_ID', type => '16A', writetype => TSTRING }, 57 { name => 'TESS_ID', type => '64A', writetype => TSTRING }, 58 { name => 'COMPONENT', type => '64A', writetype => TSTRING }, 58 59 59 60 … … 95 96 if ($req_name) { 96 97 $header->[0]->{value} = $req_name; 97 } 98 } else { 99 $req_name = $header->[0]->{value}; 100 } 101 102 die "no request name defined" unless defined $req_name; 103 104 $output = $req_name . ".fits" if !$output; 98 105 99 106 my $status = make_fits_table($output, EXTNAME, $numRows, \@colData, $columns, $header); -
branches/czw_branch/cleanup/pswarp/src/pswarpLoop.c
r24491 r25051 315 315 316 316 317 // Set variance factor318 {319 bool mdok; // Status of MD lookup320 float varFactor = psMetadataLookupF32(&mdok, output->analysis, PSWARP_ANALYSIS_VARFACTOR);321 long goodPix = psMetadataLookupS64(&mdok, output->analysis, PSWARP_ANALYSIS_GOODPIX);322 varFactor /= goodPix;323 324 psMetadataItem *vfItem = psMetadataLookup(outCell->concepts, "CELL.VARFACTOR"); ///< Item to update325 psAssert(vfItem && vfItem->type == PS_TYPE_F32, "Concept should be as specified.");326 if (!isfinite(vfItem->data.F32)) {327 vfItem->data.F32 = varFactor;328 } else {329 vfItem->data.F32 *= varFactor;330 }331 }332 333 317 // Set covariance matrix for output 334 318 { … … 406 390 pmFPAview *view = pmFPAviewAlloc(0); ///< View into skycell 407 391 view->chip = view->cell = view->readout = 0; 408 409 // Need to adjust the weight --- the main operation in psphotReadoutFindPSF is not determining the410 // signficance of sources, but looking at the significance of individual pixels.411 // We can adjust the weight directly since this is a deep copy412 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa);413 float vf = psMetadataLookupF32(NULL, photRO->parent->concepts, "CELL.VARFACTOR"); // Variance factor414 psBinaryOp(photRO->variance, photRO->variance, "*", psScalarAlloc(vf, PS_TYPE_F32));415 392 416 393 // grab the sources of interest from the storage location (pmFPAfile PSPHOT.INPUT.CMF) -
branches/czw_branch/cleanup/pswarp/src/pswarpTransformReadout.c
r24494 r25051 178 178 psTrace("pswarp.transform", 1, "No overlap\n"); 179 179 } 180 181 // Store the variance factor and number of good pixels182 if (goodPixels > 0) {183 // Variance factor: large factor --> small scale184 float varFactor = psImageInterpolateVarianceFactor(input->image->numCols / 2.0 + input->image->col0,185 input->image->numRows / 2.0 + input->image->row0,186 interp->mode);187 psMetadataItem *vfItem = psMetadataLookup(output->analysis, PSWARP_ANALYSIS_VARFACTOR);188 if (vfItem) {189 psMetadataItem *goodpixItem = psMetadataLookup(output->analysis, PSWARP_ANALYSIS_GOODPIX);190 psAssert(goodpixItem, "It should be where we left it!");191 psAssert(vfItem->type == PS_TYPE_F32 && goodpixItem->type == PS_TYPE_S64,192 "Should be the type we said.");193 194 vfItem->data.F32 += varFactor * goodPixels;195 goodpixItem->data.S64 += goodPixels;196 } else {197 psMetadataAddF32(output->analysis, PS_LIST_TAIL, PSWARP_ANALYSIS_VARFACTOR, 0,198 "Variance factor weighted by the good pixels", varFactor * goodPixels);199 psMetadataAddS64(output->analysis, PS_LIST_TAIL, PSWARP_ANALYSIS_GOODPIX, 0,200 "Number of good pixels", goodPixels);201 }202 }203 180 psFree(interp); 204 181
Note:
See TracChangeset
for help on using the changeset viewer.
