Page 1 of 1

NetCDF Error

Posted: Fri Nov 06, 2020 10:56 am
by eccentricaomy
I am currently working with the NetCDF version of the Raven-HYPR model. The model is running successfully with station based forcing data. However, when I am switching in to NetCDF forcing data, it is showing the following error message-

#------------------ Error Message --------------------------
Exiting Gracefully: CForcingGrid::ForcingGridInit: time unit string is not in the format '[days/hours/...] since YYYY-MM-DD HH:MM:SS +0000' !
Error Type: Bad input data
#---------------------------------------------------------------------

Clearly, I didn’t process the forcing data correctly. Here is the bash script that I used to process the NetCDF forcing data from hourly WFDE5-GEM-CaPA reanalysis data-

#$ -S /bin/bash
cdo mulc,3600 basin_rain.nc Temp1.nc
cdo daysum Temp1.nc Temp2.nc
cdo settaxis,1979-01-01,07:00:00,1day Temp2.nc Daily_Avg_Precip.nc

cdo dayavg basin_temperature.nc Daily_Avg_Temperature_K.nc
cdo addc,-273.16 Daily_Avg_Temperature_K.nc Temp3.nc
cdo settaxis,1979-01-01,07:00:00,1day Temp3.nc Daily_Avg_Temperature_C.nc
rm Temp*.nc
echo ======== E N D =============================

What am I doing wrong here? For the convenience-here are some of the important portions of the .rvi and .rvt files-

#------------------- .rvi ---------------------
# Simulation parameters
:StartDate 1990-10-01 07:00:00
:EndDate 2016-10-01 07:00:00
:TimeStep 24:00:00

#------------------- .rvt ---------------------
# Gridded inputs
:GriddedForcing PRECIP
:ForcingType PRECIP
:FileNameNC Daily_Avg_Precip.nc
:VarNameNC pr
:DimNamesNC lon lat time
:RedirectToFile GriddedForcings.txt
:EndGriddedForcing

:GriddedForcing TEMP_AVE
:ForcingType TEMP_AVE
:FileNameNC Daily_Avg_Temperature_C.nc
:VarNameNC tas
:DimNamesNC lon lat time
:RedirectToFile GriddedForcings.txt
:EndGriddedForcing
#Hydrometric Gauges
:RedirectToFile Wood_River_LaflecheObservedFlow.rvt
#-----------------------------------------------------------------------

Re: NetCDF Error

Posted: Fri Nov 06, 2020 2:30 pm
by jrcraig
Hi Kamrul,

You'll need to check the netcdf units for the units attribute of the time axis (you can see this if you open up in panoply or similar). It should be, e.g., "days since 1989-01-01 00:00:00 +0400" or "hours since 1989-01-01 00:00:00 +0000" or "minutes since 1989-01-01 00:00:00" or "seconds since 1989-01-01 00:00:00".

There are some NetCDF time units that raven does not support (i.e., named time zones such as UTC or GMT appended after +0000).

Regards,
James Craig

Re: NetCDF Error

Posted: Sat Nov 07, 2020 9:32 am
by eccentricaomy
Thanks James. I checked the time unit of the files before and after processing. Followings are the metadata for those files-
--------------------------
Before Processing:
--------------------------
dimensions:
time = UNLIMITED; // (341873 currently)
lon = 14;
lat = 6;
variables:
double time(time=341873);
:standard_name = "time";
:long_name = "Time";
:units = "hours since 1979-1-1 07:00:00";
:calendar = "proleptic_gregorian";
:axis = "T";
:_ChunkSizes = 512; // int

float lon(lon=14);
:standard_name = "longitude";
:long_name = "longitude";
:units = "degrees_east";
:axis = "X";

float lat(lat=6);
:standard_name = "latitude";
:long_name = "latitude";
:units = "degrees_north";
:axis = "Y";

float pr(time=341873, lat=6, lon=14);
:units = "kg m-2 s-1";
:_FillValue = 1.0E20f; // float
:missing_value = 1.0E20f; // float
:standard_name = "rainfall_flux";
:long_name = "Rainfall Flux";
:_ChunkSizes = 1, 6, 14; // int


-----------------------
After Processing:
-----------------------
dimensions:
time = UNLIMITED; // (14245 currently)
lon = 14;
lat = 6;
variables:
double time(time=14245);
:standard_name = "time";
:long_name = "Time";
:units = "days since 1979-1-1 07:00:00";
:calendar = "proleptic_gregorian";
:axis = "T";
:_ChunkSizes = 512; // int

float lon(lon=14);
:standard_name = "longitude";
:long_name = "longitude";
:units = "degrees_east";
:axis = "X";

float lat(lat=6);
:standard_name = "latitude";
:long_name = "latitude";
:units = "degrees_north";
:axis = "Y";

float pr(time=14245, lat=6, lon=14);
:standard_name = "daily_rainfall";
:long_name = "daily sum of precipitation mm per day";
:units = "mm d-1";
:_FillValue = -9999.0f; // float
:missing_value = -9999.0f; // float
:_ChunkSizes = 1, 6, 14; // int


I used the following script to process-
#--------------- Script ------------
cdo mulc,3600 basin_rain.nc Temp1.nc
cdo daysum Temp1.nc Temp2.nc
cdo settaxis,1979-01-01,07:00:00,1day Temp2.nc Temp3.nc
cdo setattribute,pr@standard_name="daily_rainfall" Temp3.nc Temp4.nc
cdo setattribute,pr@long_name="daily sum of precipitation mm per day" Temp4.nc Temp5.nc
cdo settunits,days Temp5.nc Temp6.nc
cdo setattribute,pr@units="mm d-1" Temp6.nc Temp7.nc
cdo setmissval,-9999 Temp7.nc Daily_Avg_Precip.nc
#-------------------------------------

I am still getting the same error-
#-------------- Error Message --------------
CForcingGrid::ForcingGridInit: time unit string is not in the format '[days/hours/...] since YYYY-MM-DD HH:MM:SS +0000' !
Error Type: Bad input data
#-----------------------------------------------

I am clueless at this point. What am I doing wrong?

Re: NetCDF Error

Posted: Fri Nov 20, 2020 2:07 pm
by jrcraig
you are close. It says the time units are

hours since 1979-1-1 07:00:00

This needs to be modified to

hours since 1979-01-01 07:00:00

(i.e., yyyy-mm-dd rather than yyyy-m-d)
Which is the CF-compliant time stamp format. Unfortunately I am not sufficiently familiar with cdo scripting to know how to do this, but I know it should be possible!

Re: NetCDF Error

Posted: Mon Nov 23, 2020 10:31 am
by julemai
Hi Kamrul,

sorry for my late reply. You could adjust the time unit formatting with the following NCO command to match the required formatting YYYY-MM-DD.

ncap2 -O -s "time@units=\"days since 1979-01-01 07:00:00\"" old.nc new.nc

Cheers,
Julie

Re: NetCDF Error

Posted: Mon Nov 23, 2020 11:04 am
by eccentricaomy
This works! Thanks.

Re: NetCDF Error

Posted: Mon Nov 23, 2020 12:51 pm
by julemai
Awesome!