| | 1 | |
| | 2 | {{{ |
| | 3 | #!/usr/bin/env perl |
| | 4 | |
| | 5 | use strict; |
| | 6 | use warnings; |
| | 7 | |
| | 8 | # program that uses STILTS to add colums to a PSPS query from ForcedMeanObjectView |
| | 9 | |
| | 10 | # usage: enhance.pl input [output] |
| | 11 | # If output is blank the results go to stdout in text format. |
| | 12 | |
| | 13 | my $verbose; |
| | 14 | |
| | 15 | my $in = shift; |
| | 16 | my $out = shift; |
| | 17 | |
| | 18 | die "need input file!\n" unless $in; |
| | 19 | |
| | 20 | my $ofmt = 'fits'; |
| | 21 | if (!$out) { |
| | 22 | $ofmt = 'text'; |
| | 23 | $out = '-'; |
| | 24 | } |
| | 25 | |
| | 26 | |
| | 27 | # Set this to the location of the stilts jar file on your system |
| | 28 | # This is where I put it on my Mac. |
| | 29 | my $HOME = $ENV{HOME}; |
| | 30 | my $stilts = "java -jar ${HOME}/tools/stilts.jar"; |
| | 31 | |
| | 32 | |
| | 33 | # If you want a subset of columns output build the list here and uncomment the keepcols command |
| | 34 | # below |
| | 35 | #my $keeplist = "\"objID gFPSFMag\""; |
| | 36 | |
| | 37 | # Get rid of these distracting columns at the beginning of the list |
| | 38 | my $dellist = '"objName uniquePspsOBid"'; |
| | 39 | |
| | 40 | # build the stilts command. We have to be careful about quoting here. |
| | 41 | # In particular that all of the arguments to the cmd= argument are within a single ' ' sequence |
| | 42 | # This way it gets passed to the shell as one word |
| | 43 | # cmd='the list of filter commands that have spaces in them' |
| | 44 | |
| | 45 | my $command = "$stilts tpipe in=$in out=$out ofmt=$ofmt" |
| | 46 | . " cmd='" |
| | 47 | . "delcols $dellist;" |
| | 48 | # . "addcol -after objID extended qualityFlag&1;" |
| | 49 | . "addcol -before ippObjID gFPSFMag 8.9-2.5*log10(gFPSFFlux);" |
| | 50 | . "addcol -before ippObjID gFKronMag 8.9-2.5*log10(gFKronFlux);" |
| | 51 | . "addcol -before ippObjID rFPSFMag 8.9-2.5*log10(rFPSFFlux);" |
| | 52 | . "addcol -before ippObjID rFKronMag 8.9-2.5*log10(rFKronFlux);" |
| | 53 | . "addcol -before ippObjID iFPSFMag 8.9-2.5*log10(iFPSFFlux);" |
| | 54 | . "addcol -before ippObjID iFKronMag 8.9-2.5*log10(iFKronFlux);" |
| | 55 | . "addcol -before ippObjID zFPSFMag 8.9-2.5*log10(zFPSFFlux);" |
| | 56 | . "addcol -before ippObjID zFKronMag 8.9-2.5*log10(zFKronFlux);" |
| | 57 | . "addcol -before ippObjID yFPSFMag 8.9-2.5*log10(yFPSFFlux);" |
| | 58 | . "addcol -before ippObjID yFKronMag 8.9-2.5*log10(yFKronFlux);" |
| | 59 | # . "keepcols $keeplist;" |
| | 60 | . "'" |
| | 61 | ; |
| | 62 | |
| | 63 | print "$command\n" if $verbose; |
| | 64 | |
| | 65 | my $rc = system "$command"; |
| | 66 | if ($rc) { |
| | 67 | my $status = $rc >> 8; |
| | 68 | die "failed $status $rc\n"; |
| | 69 | } |
| | 70 | |
| | 71 | }}} |