Project

General

Profile

Issues setting time to the netCDF file

Added by chinmay Deval about 8 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


Replies (6)

RE: Issues setting time to the netCDF file - Added by Ralf Mueller about 8 years ago

Hi!

Try the settaxis operator
check the history attribute of my upload for an example

hth
ralf

t.nc.gz (135 KB) t.nc.gz

RE: Issues setting time to the netCDF file - Added by chinmay Deval about 8 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

test.png (101 KB) test.png used settaxis and tried to open the file using ncview to see if the axis is set

RE: Issues setting time to the netCDF file - Added by Ralf Mueller about 8 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 about 8 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 about 8 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 about 8 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

    (1-6/6)