Issues setting time to the netCDF file
Added by chinmay Deval almost 9 years ago
Hi,
I am trying to write geotiff file to netCDF file. I use gdal_translate to convert tiff to netcdf (the output, "SMOD.*.nc" is attache below). Now this file does not have a time dimension/variable and I want to set date (as in filename) to each file so that eventually I can use cdo mergetime to put multiple such files together. I have already tried using setreftime, setdate, set calendar and settunits without any success (please refer to the attached "srt_*.nc" to see the error I get when trying to open nc file after using setreftime). All my further processing is dependent on being able to set time variable and mergetime the data into a single nc file. I would be really grateful if someone could please guide me with the aforementioned issues.
Best,
Chinmay
SMOD15A2.2001.01.01.mosaic.Lai_1km.nc (27.1 MB) SMOD15A2.2001.01.01.mosaic.Lai_1km.nc | output of tiff to nc using gdal_translate | ||
srt_SMOD15A2.2001.01.01.mosaic.Lai_1km.nc (54.1 MB) srt_SMOD15A2.2001.01.01.mosaic.Lai_1km.nc | output after using cdo setreftime |
Replies (6)
RE: Issues setting time to the netCDF file - Added by Ralf Mueller almost 9 years ago
RE: Issues setting time to the netCDF file - Added by chinmay Deval almost 9 years ago
Dear Ralf,
I tried settaxis operator but when I try to open the file I get an error popup (please see the attached screenshot). This happened also when I tried using all the other operators that I mentioned in previous post. I would really appreciate any help on this front.
Best,
Chinmay
RE: Issues setting time to the netCDF file - Added by Ralf Mueller almost 9 years ago
ncview throws a warning, because your input field is zero at all locations
if you call cdo infov
on you input, you'll that max, mean and min are all zero
RE: Issues setting time to the netCDF file - Added by Jaison-Thomas Ambadan almost 9 years ago
Hi Ralf,
I think the problem is related to CDO handling of the variable Band1, which of type Byte - that's why it's showing zeros as the output of "cdo -info" (My NcView shows correct plot on the original file).
@Chinmay:
you could try using the -ot option in GDAL - use integer type instead of Byte like:
gdal_translate -ot Int16 -of netcdf HDF5:"BLAH-BLAH-BLAH.h5"://WHATEVER myfile.nc
Now CDO operators should work properly.
Cheers,
J
RE: Issues setting time to the netCDF file - Added by chinmay Deval almost 9 years ago
Dear Ralf & Jaison,
Thanks a lot for your prompt replies. Translating data to integer type and then using CDO operators worked just fine.
Best,
Chinmay
RE: Issues setting time to the netCDF file - Added by Uwe Schulzweida almost 9 years ago
Yes, this is a bug with the netCDF data type "byte". This bug will be fixed in the next CDO release!
Cheers,
Uwe