#!/bin/bash

inc=`grdinfo santabarbF_bath.grd | grep x_inc | awk '{print $7}'`
echo "inc   : $inc"

xmin=-120.15
xmax=-120.05
ymin=34.33333333
ymax=34.4

deltax=`python -c "print $xmax - $xmin"`
deltay=`python -c "print $ymax - $ymin"`

echo "deltas: $deltax $deltay"

xcells=`python -c "import math;print math.floor($deltax / $inc)"`
ycells=`python -c "import math;print math.floor($deltay / $inc)"`

echo "cells : $xcells $ycells"

new_xmax=`python -c "print $xmin + $inc * $xcells + $inc / 2."`
new_ymax=`python -c "print $ymin + $inc * $ycells + $inc / 2."`

echo "-R$xmin/$new_xmax/$ymin/$new_ymax"

python -c "print ($new_xmax-$xmin), ($xcells*$inc)"
python -c "print ($new_ymax-$ymin), ($ycells*$inc)"
