subgrid.py - create a subgrid in an Airviro RES field by interpolation

Usage:

  subgrid.py x0 y0 x1 y1 nx ny [datafile ..]

Examples:

  Create a subgrid with the south-west corner in (0, 0) and the
  north-east corner in (39, 39) containing 40x40 grid points:

     exportres -H -e SUB data.RES | subgrid 0 0 39 39 40 40 > data.fld

  Sum urban and regional BUM concentrations and extract the same
  subgrid as above (using bash process substitution):

     subgrid 0 0 39 39 40 40 \
         <(exportres -H -e P1R bum.RES) \
         <(exportres -H -e P1U bum.RES) \
         > p1t.fld

Positional arguments:
  x0,y0     south-west corner of the subgrid
  x1,y1     north-east corner of the subgrid
  nx,ny     number of cells in the subgrid
  datafile  Airviro field data with a header as produced by exportres;
            if omitted or '-', read from stdin; if multiple datafiles
            are given, sum them up and then interpolate