IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26563


Ignore:
Timestamp:
Jan 12, 2010, 12:29:32 PM (16 years ago)
Author:
watersc1
Message:

added preliminary camera and diff stage support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/gpc1_find_images.pl

    r26548 r26563  
    33use DBI;
    44use Getopt::Std;
    5 getopts('hFARCPp:BLMDWIYTvx:n:c:w:s:O:S:N:',\%opt);
     5getopts('hEFARCPp:BLMDWIJVYTvx:n:c:w:s:d:e:O:S:N:',\%opt);
    66#getopt('xncwOS:hARCW',\%opt);
    77unless (exists($opt{O})) {
     
    3434}
    3535
     36# abcdefghijklmnopqrstuvwxyz
     37#used:
     38# ABCDEF     LMNOP RST  W Y
     39#   c    h     n    s  vwx 
    3640if (exists($opt{h})) {
    3741    print "USAGE find_images.pl ... \n";
    3842    print "          -h              This help\n";
    39     print "          -R              Return raw data.\n";
    40     print "          -C              Return chip stage data.\n";
    41     print "          -W              Return warp stage data.\n";
     43    print "          -R              Return Raw data.\n";
     44    print "          -C              Return Chip stage data.\n";
     45    print "          -E              Return camEra stage data.\n";
     46    print "          -W              Return Warp stage data.\n";
     47    print "          -T              Get the sTacks for a given input.\n";
     48    print "          -J              Get the dIff stage data (warps only for now).\n";
    4249    print "          -A              Return not just fits images.\n";
    4350    print "          -F              Convert to real filenames.\n";
     
    4552    print "          -B              Return burntool table.\n";
    4653    print "          -M              Include masks in results.\n";
     54    print "          -L              Return the log files from this stage.\n";
    4755    print "          -D              Return only pre-destreaked images.\n";
    4856    print "          -Y              Yes, I want the raw, even if it's not been processed.\n";
    49     print "          -T              Get the sTacks for a given input.\n";
     57    print "          -V              Return the cmf or smf files.\n";
    5058    print "          -v              Be verbose on output.\n";
    5159    print " \n";
    5260    print "          -x <exp_id>     Specify a exp_id.\n";
    5361    print "          -c <chip_id>    ...\n";
     62    print "          -e <cam_id>     ...\n";
    5463    print "          -w <warp_id>    ...\n";
    5564    print "          -s <stack_id>   ...\n";
     65    print "          -d <diff_id>    ...\n";
    5666    print "          -n <exp_name>   ...\n";
    5767    print " \n";
     
    6676$dbname = 'gpc1';
    6777$dbserver = 'ippdb01';
    68 $dbuser = 'ipp';
    69 $dbpass = 'ipp';
     78$dbuser = 'ippuser';
     79$dbpass = 'ippuser';
    7080$db = DBI->connect("DBI:mysql:database=${dbname};host=${dbserver};" .
    7181                   "mysql_socket=" . DB_SOCKET(),
     
    7585
    7686if ($opt{Y}) {
    77     $sth_base = "SELECT warp_id,warpRun.workdir,chipRun.chip_id,chipRun.workdir,rawExp.exp_name,rawExp.exp_id,rawExp.workdir,rawExp.dateobs,rawExp.pon_time,0,'nostack' from warpRun RIGHT OUTER JOIN fakeRun USING(fake_id) RIGHT OUTER JOIN camRun USING(cam_id) RIGHT OUTER JOIN chipRun USING(chip_id) RIGHT OUTER JOIN rawExp USING (exp_id)";
     87    $sth_base = "SELECT warp_id,warpRun.workdir,chipRun.chip_id,chipRun.workdir,rawExp.exp_name,rawExp.exp_id,rawExp.workdir,rawExp.dateobs,rawExp.pon_time,0,'nostack',camRun.cam_id,camRun.workdir,0,'nodiff' from warpRun RIGHT OUTER JOIN fakeRun USING(fake_id) RIGHT OUTER JOIN camRun USING(cam_id) RIGHT OUTER JOIN chipRun USING(chip_id) RIGHT OUTER JOIN rawExp USING (exp_id)";
    7888}
    7989else {
    80     $sth_base = "SELECT warp_id,warpRun.workdir,chipRun.chip_id,chipRun.workdir,rawExp.exp_name,rawExp.exp_id,rawExp.workdir,rawExp.dateobs,rawExp.pon_time,0,'nostack' from warpRun  JOIN fakeRun USING(fake_id)  JOIN camRun USING(cam_id)  JOIN chipRun USING(chip_id)  JOIN rawExp USING (exp_id)";
     90    $sth_base = "SELECT warp_id,warpRun.workdir,chipRun.chip_id,chipRun.workdir,rawExp.exp_name,rawExp.exp_id,rawExp.workdir,rawExp.dateobs,rawExp.pon_time,0,'nostack',camRun.cam_id,camRun.workdir,0,'nodiff' from warpRun  JOIN fakeRun USING(fake_id)  JOIN camRun USING(cam_id)  JOIN chipRun USING(chip_id)  JOIN rawExp USING (exp_id)";
    8191}
    8292
     
    95105if (exists($opt{w})) {
    96106    push @sth_adds, "warpRun.warp_id = $opt{w}";
     107}
     108if (exists($opt{e})) {
     109    push @sth_adds, "camRun.cam_id = $opt{e}";
    97110}
    98111if (exists($opt{s})||exists($opt{T})) {
     
    107120    $sth_base .= ' JOIN stackInputSkyfile USING (warp_id) JOIN stackSumSkyfile USING (stack_id) JOIN stackRun USING (stack_id)';
    108121#    print "$sth_base\n";
     122}
     123if (exists($opt{J})||(exists($opt{d}))) {
     124    if (exists($opt{d})&&($opt{d} != 0)) {
     125        push @sth_adds, "diffRun.diff_id = $opt{d}";
     126    }
     127    $sth_base =~ s/0,'nodiff'/diffRun.diff_id,diffSkyfile.path_base/;
     128    if (exists($opt{J})) {
     129#       $sth_base .= ' RIGHT OUTER ';
     130    }
     131    $sth_base .= ' JOIN diffInputSkyfile ON (warpRun.warp_id = diffInputSkyfile.warp1 OR warpRun.warp_id = diffInputSkyfile.warp2) JOIN diffRun USING (diff_id) JOIN diffSkyfile USING (diff_id)';
    109132}
    110133if ($#sth_adds != -1) {
     
    124147    ($warp_id, $warp_workdir, $chip_id, $chip_workdir,
    125148     $exp_name, $exp_id, $exp_workdir, $exp_dateobs, $exp_pontime,
    126      $stack_id, $stack_sumfile_uri) = @{ $rr };
     149     $stack_id, $stack_sumfile_uri,
     150     $cam_id, $cam_workdir,
     151     $diff_id, $diff_workdir
     152    ) = @{ $rr };
    127153    if ($stack_id == 0) {
    128154        $stack_sumfile_uri = '';
     
    132158    if (exists($opt{I})) {
    133159        $stack_id = 0; # Ditto.
     160        $cam_id = 0;
     161        $diff_id = 0;
    134162    }
    135163    if (exists($opt{N})) {
     
    231259        close(NLS);
    232260    }
     261    if (exists($opt{E})) {
     262        open(NLS,"neb-ls $cam_workdir/${exp_name}.${exp_id}/ |") || die "can't neb-ls";
     263        while (<NLS>) {
     264            chomp;
     265            if (is_valid_cam($_)) {
     266                push @scan, $_;
     267                $found++;
     268            }
     269        }
     270        close(NLS);
     271    }
    233272    if (exists($opt{W})) {
    234273        open(NLS,"neb-ls $warp_workdir/${exp_name}.${exp_id}/ |") || die "can't neb-ls";
     
    241280        }
    242281    }
     282    if (exists($opt{J})) {
     283        @diff_tmp = split /\//, $diff_workdir;
     284        $diff_prefix = pop(@diff_tmp);
     285        $diff_true_dir = join '/',@diff_tmp;
     286
     287        open(NLS,"neb-ls $diff_true_dir |") || die "can't neb-ls";
     288        while (<NLS>) {
     289            chomp;
     290            if (is_valid_diff($_)) {
     291                push @scan, $_;
     292                $found++;
     293            }
     294        }
     295    }
    243296    if (exists($opt{s})||exists($opt{T})) {
    244297        if (defined($stack_sumfile_uri)) {
     
    354407        }
    355408    }
     409    elsif ($opt{V} && ($key =~ /cmf/)) {
     410        return(1);
     411    }
    356412    elsif ($key !~ /fits/) {
    357413        return(0); # Not a fits
     
    375431}
    376432
     433sub is_valid_cam {
     434    my $key = shift;
     435    if ($key =~ /\.cm\./) {
     436        if ($opt{A}) {
     437            return(1);
     438        }
     439        elsif ($opt{L} && ($key =~ /log/)) {
     440            return(1);
     441        }
     442        elsif ($opt{V} && ($key =~ /smf/)) {
     443            return(1);
     444        }
     445    }
     446    return(0);
     447}
     448
     449sub is_valid_diff {
     450    my $key = shift;
     451    if ($key =~ /$diff_prefix/) {
     452        if ($opt{D} && ($key !~ /SR/)) {
     453            return(0); # Not destreaked when required
     454        }
     455        if (($opt{S} ne '')&&($key !~ /$opt{S}/)) {
     456            return(0); # Not the requested skycell
     457        }
     458        if (($opt{O} ne '')&& !(is_mapped($key,$opt{O}))) {
     459            return(0); # Not the remapped OTA requested
     460        }
     461       
     462        if ($opt{A}) {
     463            return(1); # You asked for all,
     464        }
     465        elsif ($opt{L}) {
     466            if ($key =~ /log/) {
     467                return(1);
     468            }
     469            else {
     470                return(0);
     471            }
     472        }
     473        elsif ($opt{V} && ($key =~ /cmf/)) {
     474            return(1);
     475        }
     476        elsif ($key !~ /fits/) {
     477            return(0); # Not a fits
     478        }
     479        elsif ($key =~ /wt.fits/) {
     480            return(0); # No handler for weight right now.
     481        }
     482        elsif ($key =~ /mask/) {
     483            if ($opt{M}) {
     484                return(1); # Requested mask
     485            }
     486            else {
     487                return(0);
     488            }
     489        }
     490        else {
     491            return(1); # Should be just the warp.
     492        }
     493    }
     494   
     495    return(0);
     496}
    377497sub is_valid_warp {
    378498    my $key = shift;
     
    402522        }
    403523    }
     524    elsif ($opt{V} && ($key =~ /cmf/)) {
     525        return(1);
     526    }
    404527    elsif ($key !~ /fits/) {
    405528        return(0); # Not a fits
     
    421544    return(0);
    422545}
    423        
    424 
    425 
    426    
    427    
Note: See TracChangeset for help on using the changeset viewer.