I have a couple hundred NetCDF files that I want to process through a geospatial analysis tool, however the tool requires the depth variable to be a double, and it is currently a float. I have found the below article
convert all the variables and dimensions from int/float to double in netcdf file
But when trying to run:
ncap2 -s 'depth=double(depth)' C:\Users\***\input.nc C:\Users\***\output.nc
a temporary file is created that has the header information for the netcdf but never completes processing, and also indicates that the depth field is still a float. Additionally, this does not address processing multiple files.
I have 0 experience with CDO and have found the nco sourgeforce info not to be obvious, my only other coding experience has been with Python.
You can also convert all variables to double precision using cdo:
cdo -b 64 copy input.nc output.nc
If you want to specify floating point type then it is
cdo -b f64 copy input.nc output.nc
Note this converts all variables from float to double, I'm not sure if with CDO you can only change one specific field as is the case with nco.
The command you tried works well for me on all recent versions of NCO, though I do not have access to a Windows machine. Please try on Linux or MacOS if you have access, or make a bug report. For multiple file put the command in a loop over the files as shown in many examples such as this one. Ironically, I added a double->float conversion routine to ncpdq
last year because a majority of people want to save space, not consume it. I will place adding a float->double in ncpdq
on the TODO list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With