I use nco
linux-command line for cuting my '.nc' files. Normally use lat
and lon
of my specific area like below:
ncks -d lat,17.52,30.98 -d lon,-98.52,-78.02 img.nc -O cut.nc
I need to make a loop for a daily cut of 365 files (all year). I am going to do it with Python, but I really want to know if anyone knows a way to do it with the nco package.
Thanks.
NCO solution
just do a loop in bash using wildcards * - e.g. if your files are called img20170101.nc etc then:
the %??? removes ".nc" from the filename
CDO solution By the way, as an alternative you can also use CDO to cut areas:
Python solution Finally, I have recently discover a fantastic new python package PYGEODE that allows you to open netcdf files easily, make time or spatial averages (correctly!) and cut out lat-lon boxes and print on maps. find it here:
https://github.com/pygeode/pygeode