Time series

From GRASS-Wiki
Jump to navigation Jump to search

Time stamps

Common legends for many raster maps

The general idea is to:

  • Calculate the overall min/max covering all maps with "r.info -r"
  • Create a full-scale color table with "r.colors rules=" on the first map
  • Copy that color table to other maps in the series with "r.colors rast="
  • Draw legend to color table extent with "d.legend range=min,max"

Example using Pathfinder SST data:

MAP_PATTERN='*.s0451pfv50-sst*degC.q4'

# find overall min/max
ALL_MIN=999999
ALL_MAX=-999999

for MAP in `g.mlist rast pattern=$MAP_PATTERN` ; do
  eval `r.info -r $MAP`
  ALL_MAX=`echo "$max $ALL_MAX" | awk '{if ($1 > $2) print $1;  else print $2}'`
  ALL_MIN=`echo "$min $ALL_MIN" | awk '{if ($1 < $2) print $1; else print $2}'`
done

echo "all_min=$ALL_MIN   all_max=$ALL_MAX"
ONETHIRD=`echo $ALL_MIN $ALL_MAX | awk '{print ($2 - $1)/3.0 + $1}'`
TWOTHIRD=`echo $ALL_MIN $ALL_MAX | awk '{print 2*($2 - $1)/3.0 + $1}'` 

# create full-scale color table for first map
FIRST_MAP=`g.mlist rast pattern=$MAP_PATTERN | head -n 1`

r.colors $FIRST_MAP color=rules << EOF
 $ALL_MIN blue
 $ONETHIRD cyan
 $TWOTHIRD yellow
 $ALL_MAX red
EOF

# apply color table to all other maps 
for MAP in `g.mlist rast pattern=$MAP_PATTERN` ; do
   r.colors $MAP rast=$FIRST_MAP
done

# draw
for MAP in `g.mlist rast pattern=$MAP_PATTERN` ; do
   d.rast -o $MAP
   d.legend $MAP range=$ALL_MIN,$ALL_MAX
done


  • For ps.map use the colortable instruction's "range" parameter.

Animation

Development