IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39012


Ignore:
Timestamp:
Oct 30, 2015, 8:50:00 AM (11 years ago)
Author:
bills
Message:

after joining everything up, add "delta columns"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/bills/comparestackdetections

    r39006 r39012  
    6868}
    6969
    70 #
    71 my @joined;
     70
     71my $outfile;
     72my $input = $in;
    7273for (my $i=1; $i<=5; $i++) {
    7374    my $cmf = $cmfs[$i];
     
    8485
    8586    my $stackColumn = $filter . "stackImageID";
    86     my $idColumn = $filter . "ippDetectID";
    87     my $outfile = $filter . "_matched" . basename($cmf);
    88     $command = "$stilts tmatch2 in1=$in'#StackObjectAttributes' in2=$ippjoined matcher=2d out=$outfile ofmt=fits"
     87    my $idColumn    = $filter . "ippDetectID";
     88    $outfile = $filter . "_matched" . basename($cmf);
     89
     90    $command = "$stilts tmatch2 in1=$input'#StackObjectAttributes' in2=$ippjoined matcher=2d out=$outfile ofmt=fits"
    8991        . " values1='$stackColumn $idColumn' values2='STACK_ID IPP_IDET' params=.01 join=$joinType"
    9092        . " fixcols=all suffix1='' suffix2=_$filter ocmd='tablename StackObjectAttributes'";
    91     $in = $outfile;
    9293    runcommand($command);
    93 }
     94
     95    if (!$save_temps) {
     96        unlink $ippjoined;
     97        if ($input ne $in) {
     98            unlink $input;
     99        }
     100    }
     101    # input for next round of matches is the output from this one
     102    $input = $outfile;
     103}
     104
     105my $list = getStackColumns();
     106my $cmd = "'";
     107# add x_zpFactor columns
     108for (my $i = 1; $i<=5; $i++) {
     109    next if $cmfs[$i] eq 'none';
     110    my $filter = $filters[$i];
     111    my $zp = $filter . "zp";
     112    $cmd .= "addcol -after $zp ${filter}zpFactor 3630.78*pow(10,-0.4*$zp);";
     113}
     114foreach my $line (@$list) {
     115    my ($col, $ipp, $conversion) = split ' ', $line;
     116    next if !$ipp;
     117    $conversion = "" unless $conversion;
     118    my $equation = "$ipp$conversion";
     119    $equation = "$col-$equation";
     120    my $dcol = "d_$col";
     121    $cmd .= "addcol -after $col $dcol $equation;";
     122}
     123$cmd .= "'";
     124
     125$command = "$stilts tpipe in=$outfile out=$out cmd=$cmd";
     126
     127runcommand($command);
     128unlink($outfile) unless $save_temps;
    94129
    95130exit 0;
    96 
    97 my $matched = "m." . basename($out);
    98 
    99 # $commmand = "$stilts tmatch2 fixcols=dups suffix1=
    100 my $ippjoined;
    101 runcommand("matchIppToPsps $in $ippjoined $matched");
    102 
    103 if (!$save_temps) {
    104     unlink $ippjoined;
    105 }
    106 
    107 # runcommand("adddeltacolumns $matched $out");
    108 
    109 exit 0;
    110 
    111131
    112132sub runcommand {
     
    119139    }
    120140}
     141
     142# list of columns from stackObjectAttributes table
     143sub getStackColumns {
     144    my $filters = shift;
     145    my $cmfs = shift;
     146
     147    # format of the list is "psps column"   "ipp column"    "equation to convert ipp value to psps value"
     148    # If equation is blank the psps column is the same as the ipp column
     149    # columns which begin in x_ have a different value for each of the 5 filters
     150    # similarly ipp columns that end in _x have the name col_$filter
     151
     152    my $list = <<END_OF_LIST;
     153# Note x_zpFactor = 3630.78*pow(10, -0.4*x_zp)
     154
     155objID
     156uniquePspsSTid
     157ippObjID
     158randomStackObjID
     159stackDetectRowID
     160primaryDetection
     161bestDetection
     162
     163x_ippDetectID     IPP_IDET
     164x_stackDetectID
     165x_stackImageID    STACK_ID
     166x_xPos            X_PSF
     167x_yPos            Y_PSF
     168x_xPosErr         X_PSF_SIG
     169x_yPosErr         Y_PSF_SIG
     170x_psfMajorFWHM    PSF_FWHM_MAJ            *abs(PLTSCALE_x)
     171x_psfMinorFWHM    PSF_FWHM_MIN            *abs(PLTSCALE_x)
     172x_psfTheta        PSF_THETA
     173x_psfCore         PSF_CORE
     174x_psfLikelihood                                                 # actually psfLikelihood(EXT_NSIGMA). We assume the formula is ok.
     175x_psfQf           PSF_QF
     176x_psfQfPerfect    PSF_QF_PERFECT
     177x_psfChiSq        PSF_CHISQ
     178x_momentXX        MOMENTS_XX            *PLTSCALE_x*PLTSCALE_x
     179x_momentXY        MOMENTS_XY            *PLTSCALE_x*PLTSCALE_x
     180x_momentYY        MOMENTS_YY            *PLTSCALE_x*PLTSCALE_x
     181x_momentR1        MOMENTS_R1            *abs(PLTSCALE_x)
     182x_momentRH        MOMENTS_RH            *sqrt(abs(PLTSCALE_x))
     183
     184x_psfFlux         PSF_INST_FLUX         *x_zpFactor/x_expTime
     185x_psfFluxErr      PSF_INST_FLUX_SIG     *x_zpFactor/x_expTime
     186
     187x_apFlux          AP_FLUX               *x_zpFactor/x_expTime
     188x_apFluxErr       AP_FLUX_SIG           *x_zpFactor/x_expTime
     189x_apFillFac       AP_NPIX               /(3.14159265359*pow(AP_MAG_RADIUS_x-0.5,2))
     190x_apRadius        AP_MAG_RADIUS         *abs(PLTSCALE_x)
     191x_KronFlux        KRON_FLUX             *x_zpFactor/x_expTime
     192x_KronFluxErr     KRON_FLUX_ERR         *x_zpFactor/x_expTime
     193x_KronRad         MOMENTS_R1            *2.5*abs(PLTSCALE_x)
     194x_expTime
     195x_ExtNSigma       EXT_NSIGMA
     196x_sky             SKY                   /PLTSCALE_x/PLTSCALE_x*x_zpFactor/x_expTime
     197x_skyErr          SKY_SIGMA             /PLTSCALE_x/PLTSCALE_x*x_zpFactor/x_expTime
     198x_zp
     199x_PlateScale      PLTSCALE
     200END_OF_LIST
     201
     202    my @lines = split "\n", $list;
     203
     204    my @output;
     205    foreach my $l (@lines) {
     206        # skip comment lines and empty lines
     207        next if $l =~ '^#';
     208        next if !$l;
     209        # strip off trailing comment
     210        my ($data, $comment) = split '#', $l;
     211        my ($column, $ippColumn, $equation) = split " ", $data;
     212
     213        $ippColumn = "" unless $ippColumn;
     214        $equation  = "" unless $equation;
     215        if ($column =~ '^x_') {
     216            for (my $i=1; $i<=5; $i++) {
     217                my $c = $cmfs[$i];
     218                next if $c eq 'none';
     219                my $f = $filters[$i];
     220                my $newCol = $f . substr($column, 2);
     221                my $newIpp = "";
     222                if ($ippColumn) {
     223                    $newIpp = $ippColumn . "_$f";
     224                }
     225                my $newEquation = $equation;
     226                $newEquation =~ s/_x/_$f/g;
     227                $newEquation =~ s/x_/$f/g;
     228                my $newline = sprintf "%s\t%s\t%s", $newCol, $newIpp, $newEquation;
     229                # print "$newline\n";
     230                push @output, $newline;
     231            }
     232        } else {
     233            # print "$l\n";
     234            push @output, $l;
     235        }
     236       
     237    }
     238
     239    return \@output;
     240}
     241
Note: See TracChangeset for help on using the changeset viewer.