IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 14, 2021, 3:30:26 PM (5 years ago)
Author:
eugene
Message:

improved plots, option to restrict to camera-confirmed sources

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/eam/teleff/warpstats.sh

    r41712 r41720  
    11
    2 macro warpstats.glob
     2macro load.warpstats
    33 if ($0 != 2)
    4    echo "USAGE: warpstats (glob)"
     4   echo "USAGE: load.warpstats (glob)"
    55   break
    66 end
    77 
    8  delete -q Rref Dref Xref Yref Q1ref
     8 # accumulate these fields for comparison plots
     9 $FIELDS = Rref Dref Mref
     10
     11 # delete accumulation vectors
     12 delete -q $FIELDS
    913
    1014 list name -glob $1
    1115 for i 0 $name:n
    1216
     17   echo "reading from $name:$i"
    1318   data $name:$i
    1419   read -fits DATA -sizes
     
    2025   calc.warpstats
    2126   if ($i == 0)
    22      set magFound_sum = magFound
    2327     set numTotal_sum = numTotal
    2428     set numPoss_sum  = numPoss
    2529   else
     30     set numTotal_sum = numTotal + numTotal_sum
    2631     set numPoss_sum  = numPoss  + numPoss_sum
    27      set numTotal_sum = numTotal + numTotal_sum
    2832   end
    29    concat RrefSS Rref
    30    concat DrefSS Dref
    31    concat XrefSS Xref
    32    concat YrefSS Yref
    33    concat Q1refSS Q1ref
     33   foreach field $FIELDS
     34     concat $field\_out $field
     35   end
     36
     37   # cleanup by deleting the loaded vectors
     38   delete -q $allfields
    3439 end
    3540   
    36  set magFound = magFound_sum
    3741 set numTotal = numTotal_sum
    38  set fracPoss  = numPoss_sum  / numTotal_sum
     42 set numPoss  = numPoss_sum
     43 delete numTotal_sum numPoss_sum
    3944
    40  plot.warpstats
    41 
    42  # plot.warpsky
     45 set fracPoss  = (numTotal > 0) ? numPoss  / numTotal : zero(numTotal)
    4346end
    4447
    45 macro warpstats.single
    46  if ($0 != 2)
    47    echo "USAGE: warpstats (file)"
    48    break
    49  end
    50  
    51  data $1
    52  read -fits DATA -list-fields -q
    53  list tfields -join allfields
    54  read -fits DATA $allfields
     48# assumes we have loaded values from the stf tables
     49# magBin, numTotal, numFound, numPoss, numGood
     50macro plot.warpstats.fracs
    5551
    56  # assumes data has been loaded
    57  # results in magFound, fracFound, numFound
    58  calc.warpstats
    59 
    60  plot.warpstats
    61 end
    62 
    63 macro plot.warpstats
    6452 clear -s
    6553 resize 1800 1200
    6654 label -fn helvetica 18
     55 $BSTY = -tickpad 0.2 -xpad 3.5 -labelpadx 3.0 -ypad 4.5 -labelpady 4.0 +ypad 4.5 +labelpady 4.0
     56
     57 # plot the detection fractions, using left axis
    6758 section a 0 0 1 1
    68  $BSTY = -tickpad 0.2 -xpad 3.5 -labelpadx 3.0 -ypad 4.5 -labelpady 4.0 +ypad 5.5 +labelpady 5.0
    69  lim magFound -0.02 1.02; box $BSTY -ticks 1110;
    70  plot -x hist magFound fracPoss  -lw 3 -c blue70
    71  label -x mag -y "detectable fraction"
    72  subset tmp = fracPoss where (magFound > 15) && (magFound < 20); vstat -q tmp; $FracBrightPoss = $MEDIAN
     59 lim magBin -0.02 1.02; box $BSTY -ticks 1110;
     60
     61 plot -x hist magBin fracPoss  -lw 3 -c blue70
     62
     63 subset tmp = fracPoss  where (magBin > 15) && (magBin < 20); vstat -q tmp; $FracBrightPoss = $MEDIAN
    7364 line -c blue -lt dot -lw 2 100 $FracBrightPoss to 0 $FracBrightPoss
    74  fprintf "%.1f-pct of sources are unmasked" {100*$FracBrightPoss}
    7565
     66 fprintf "%.1f-pct of bright sources were detectable (unmasked)" {100*$FracBrightPoss}
     67
     68 label -x mag -y "detected fraction"
     69
     70 # plot the total number of detected sources, using the right axis
    7671 section b 0 0 1 1
    77  lim magFound numTotal; box $BSTY -ticks 1011 -labels 0001; plot -x hist magFound numTotal -c grey70 -lw 2
    78  label +y "reference catalog numbers"
     72 lim magBin numTotal; box $BSTY -ticks 1011 -labels 0001
     73
     74 plot -x hist magBin numTotal -c grey80 -lw 2
     75 label +y "detected number"
     76
     77 $Xlegend = 0.02; $dXlegend = 0.03
     78 $Ylegend = 0.95; $dYlegend = 0.02
     79 line -frac $Xlegend $Ylegend to {$Xlegend + $dXlegend} $Ylegend -c blue  -lw 3; textline -frac -justify 5 {$Xlegend + $dXlegend + 0.01} $Ylegend "unmasked source positions (psfqf > 0.85)"; $Ylegend -= $dYlegend
    7980end
    8081
    81 macro plot.warpsky
    82 
    83   dev -n sky
    84   vstat -q Rref; $Ro = $MEDIAN
    85   vstat -q Dref; $Do = $MEDIAN; $PlotRadius = 0.6*($MAX - $MIN)
    86   region -n sky $Ro $Do $PlotRadius
    87   cplot -pt box -sz 0.3 -op 0.1 -c black Rref Dref
    88 
    89   # create t 0 360 0.01
    90   # set dR = 3*dcos(t)/2.0
    91   # set dD = 3*dsin(t)/2.0
    92   # set Dc = $Do + dD
    93   # set Rc = $Ro + dR/dcos(Dc)
    94   # cplot -x line Rc Dc -c blue -lw 2
    95 end
    96 
    97 
     82# relies on the following vectors: Mref_out, Q1ref_out, PSF_QF_out, X_PSF_out
    9883macro calc.warpstats
    9984 $Mmin = 10
     
    10186 $Mdel = 0.25
    10287 
    103  delete -q magFound numTotal numPoss fracPoss
     88 delete -q  magBin numTotal numPoss
    10489 for mag $Mmin $Mmax $Mdel
    105    concat $mag magFound
     90   concat $mag magBin
    10691
    107    # what fraction of the sources were actually detected?
    108    set keepmag = (MrefSS > $mag - 0.5*$Mdel) && (MrefSS <= $mag + 0.5*$Mdel)
    109    subset XinBin = XrefSS if keepmag
    110    concat XinBin[] numTotal
     92   # sources in mag bin
     93   set keepSrc = (Mref_out > $mag - 0.5*$Mdel) && (Mref_out <= $mag + 0.5*$Mdel)
     94   subset tmp = Mref_out if keepSrc
     95   concat tmp[] numTotal
    11196
    11297   # what fraction of the sources could have been detected (mask fraction > 0.85 at position)?
    113    set keepgood = keepmag && (Q1refSS > 0.85)
    114    subset XinBinGood = XrefSS if keepgood
    115    concat {XinBinGood[]/XinBin[]} fracPoss
    116    concat XinBinGood[] numPoss
     98   set keepMsk = keepSrc && (Q1ref_out > 0.85)
     99   subset tmp = Mref_out if keepMsk
     100   concat tmp[] numPoss
    117101 end
     102
     103 delete -q tmp keepSrc keepMsk keepDet
    118104end
    119 
Note: See TracChangeset for help on using the changeset viewer.