I’m using grdinterpolate to find values over a vertical cross section, however it seems like the X axis output units are being given in m? Is there a way to set it to be given in km?
Thank you! I guess I got confused with the part:
If no units are specified we default to great circle distances in km (if geographic).
from the documentation and was trying to find a way to get to it.
Your solution unfortunately is leading me to another error. My GMT is not allowing me to call variables from netCDF files. If I use $mygrid?var for anything it gives me “Named variable does not exist in file”.
Ex: the grid I’m working on, from grdinfo
x_min: 0 x_max: 8012484.78674 x_inc: 111284.510927 name: longitude n_columns: 73
and if I try
gmt grdedit$mygrid?longitude it gives
grdinfo (gmtapi_import_grid): Named variable does not exist in file [v.-80.-15.-5.-15.grd?longitude]
[Session gmt (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session gmt (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
I tested with other netCDF grids and still get the same error…
Yes. GMT has never let anyone access a coordinate array since most of the time there is none, just the scalars min, inc, max. Only grids or cube layers can be accessed.
Perfect, this does the trick for now! Thanks a lot!!
For anyone with a similar problem, here is how I’m getting around:
#run your interpolate options for a cross-section
gmt grdinterpolate $ingrid -G$outgrid -E$lon1/$lat1/$lon2/$lat2 -T$zmin/$zmax/$zinc -fg
#calculate the max crossing distance and convert to kilometers
dmax=$(gmt grdinfo -C -Q $outgrid | awk '{print $3/1000}')
#reset the values in kilometers
gmt grdedit -R0/$dmax/$zmin/$zmax $ingrid