#!/bin/csh -f if ($#argv < 1) then echo echo " Usage: makeFracGrid.com xyzfile" echo " example " echo " makeFracGrid.com ship_ratio_world.xyz" exit 1 endif set infile = $1 set range = -R0/360/-72/72 set displayInc = -I0.25/0.2 set filterInc = -I0.1 set clipLimit = 0.16 rm -f criticalCount.grd criticalCount.xyz rm -f criticalFraction.grd filteredCriticalCount.grd rm -f totalCount.grd filteredTotalCount.grd clippedFilteredTotalCount.grd rm -f tmp.grd # pull out critical ratios, i.e. slope/critical > 1.0 awk '{if ($3 > 1.00) print $1,$2,$3}' < $infile > criticalCount.xyz # count number of pings per node. # # Note the -An and the use of a smaller -I than the display -I # # The key thought is we really want count of ratio>1 at each node, # not the value of ratio at node! xyz2grd -An -V -N0 $range $filterInc $infile -GtotalCount.grd xyz2grd -An -V -N0 $range $filterInc criticalCount.xyz -GcriticalCount.grd # filter the count to smooth out artificats and just because... grdfilter $range $filterInc -V -D3 -Fg60 totalCount.grd -GfilteredTotalCount.grd grdfilter $range $filterInc -V -D3 -Fg60 criticalCount.grd -GfilteredCriticalCount.grd # Clip filtered count to NaN if less than clipLimit. # # this grdmath says # if input < limit place on stack a 0 else 1, # replace any 0 with Nan, # now we have either a 1 or NAN on stack # a MUL with original data gives input data # except with clipped locations replaced by NAN grdmath filteredTotalCount.grd DUP $clipLimit GT 0 NAN MUL = clippedFilteredTotalCount.grd # Calculate ratio of filtered critical and total count grdmath filteredCriticalCount.grd clippedFilteredTotalCount.grd DIV = criticalFraction.grd # surface, grid and filter at display grid size. grd2xyz criticalFraction.grd -V -L -S > criticalFraction.xyz surface criticalFraction.xyz $range $displayInc -V -L -Ll0.0 -Lu1.0 -T.25 -Gtmp.grd chmod a+rw * grdfilter tmp.grd $range $displayInc -V -D3 -Fm60 -Gfrac.grd exit rm -f criticalCount.grd criticalCount.xyz rm -f criticalFraction.grd filteredCriticalCount.grd rm -f totalCount.grd filteredTotalCount.grd clippedFilteredTotalCount.grd rm -f tmp.grd