Imagine that you have a file example.nc
, that has wind data defined in 90N, 90S, 180E, 180W region. Is there anyway I could in linux, with a simple nc-type command
If you are on Linux or macOS, you can do this easily using nctoolkit (https://nctoolkit.readthedocs.io/en/latest/) on Python.
import nctoolkit as nc
nc.options(lazy = True)
data = nc.open_data("example.nc")
data.clip(lon = [25, 50], lat = [30, 40])
data.write_nc("output.nc")
Under the hood, nctoolkit uses CDO. So the above is the equivalent of the CDO approach mentioned above:
cdo sellonlatbox,lon1,lon2,lat1,lat2 infile.nc outfile.nc