[gradsusr] create missing day, save as netcdf file, reopen with ctl file

Jennifer Adams jma at cola.iges.org
Wed Dec 3 10:27:21 EST 2014


Hi, David — 
That is a clever data manipulation and use of chsub! I think it is failing because your file with the one time step (20991231) is not identical to the other two in all aspects except the time metadata. Under the hood, GrADS requires that the netcdf varid be the same for all the variables in the templated data files, and it also requires that the number of dimensions is the same for each variable, and that the sizes of the non-T coordinates are also the same. 

You could try this:
1. Do an ncdump -c of the first rcp85 data file
2. Do a full ncdump of your 1-time step file
3. Put the two dump ouputs together in such a way so that you can use ‘ncgen’ to create a new file that will have all the metadata of the rcp85 file, but the grid of values from the data file you created. You will need to alter the time axis value and metadata to make sure it maps to 31dec2099. 
4. use ncgen to create the 4th data file in your set. 

—Jennifer

On Dec 2, 2014, at 4:52 PM, Westberg, David J. <David.J.Westberg at nasa.gov> wrote:

> I'm working with CMIP5 BCC-CSM1-1 historical and rcp85 surface temperature (tas) data, and I'm trying to create a time series from 1976 to 2100.  I'm using open_grads and here is the configuration:
> 
> Config: v2.0.1.oga.1 little-endian readline printim grib2 netcdf hdf4-sds hdf5 opendap-grids,stn athena geotiff shapefile
> Grid Analysis and Display System (GrADS) Version 2.0.1.oga.1
> 
> These are the netcdf files I'm using:
> 
> tas_day_bcc-csm1-1_historical_r1i1p1_18500101-20121230.nc
> tas_day_bcc-csm1-1_rcp85_r1i1p1_20060101-20991230.nc
> tas_day_bcc-csm1-1_rcp85_r1i1p1_21000101-21991231.nc
> 
> This is my ctl file (BCC-CSM1-1_TAS_hist_rcp85.ctl) to link the above files together:
> 
> DSET TAS/tas_day_bcc-csm1-1_%ch.nc
> # below goes from 1850 to 2005, skipping hist 2006-2012
> CHSUB     1 56940 historical_r1i1p1_18500101-20121230.nc
> CHSUB 56941 91250 rcp85_r1i1p1_20060101-20991230.nc
> CHSUB 91251 127750 rcp85_r1i1p1_21000101-21991231.nc
> OPTIONS template
> DTYPE netcdf
> OPTIONS 365_day_calendar
> TDEF time 127750 LINEAR 00z1Jan1850 1440mn
> 
> The second file is missing 20991231 (31 Dec 2099), so I thought I would average 20991230 and 21000101 to replace the missing day (20991231) and save it as a new netcdf file.
> ga-> define newgrid = (tas(t=91249)+tas(t=91251))/2
> ga-> set sdfwrite tas_day_bcc-csm1-1_rcp85_r1i1p1_20991231.nc
> ga-> sdfwrite newgrid
> 
> This is my new ctl file (BCC-CSM1-1_TAS_hist_rcp85_with31dec2099.ctl) to link the above files together:
> 
> DSET TAS/tas_day_bcc-csm1-1_%ch.nc
> # below goes from 1850 to 2005, skipping hist 2006-2012
> CHSUB     1 56940 historical_r1i1p1_18500101-20121230.nc
> CHSUB 56941 91249 rcp85_r1i1p1_20060101-20991230.nc
> CHSUB 91250 91250 rcp85_r1i1p1_20991231.nc
> CHSUB 91251 127750 rcp85_r1i1p1_21000101-21991231.nc
> OPTIONS template
> DTYPE netcdf
> OPTIONS 365_day_calendar
> TDEF time 127750 LINEAR 00z1Jan1850 1440mn
> 
> I use xdfopen on the above ctl file.  Plotting on either side time wise of 00z31Dec2099 works, but I can't get a plot for 00z31Dec2099.
> 
> ga-> set t 91249
> Time values set: 2099:12:30:0 2099:12:30:0 
> ga-> d tas
> Contouring: 245 to 310 interval 5 
> ga-> set t 91251
> Time values set: 2100:1:1:0 2100:1:1:0 
> ga-> d tas      
> Contouring: 245 to 315 interval 5 
> ga-> set t 91250
> Time values set: 2099:12:31:0 2099:12:31:0 
> ga-> d tas      
> NetCDF Error (gancrow, nc_get_vara_double): NetCDF: Variable not found
> Data Request Error:  Error for variable 'tas'
>  Error ocurred at column 1
> DISPLAY error:  Invalid expression 
>  Expression = tas
> ga-> d newgrid  
> Syntax Error:  Invalid Operand 
>  'newgrid' not a variable or function name
>  Error ocurred at column 1
> DISPLAY error:  Invalid expression 
>  Expression = newgrid
> 
> So I tried another method.  I created a ctl file (tas_day_bcc-csm1-1_rcp85_r1i1p1_20991231.ctl; see below) for the tas_day_bcc-csm1-1_rcp85_r1i1p1_20991231.nc file, and added this control file to the main ctl file (BCC-CSM1-1_TAS_hist_rcp85_with31dec2099.ctl).
> 
> [tas_day_bcc-csm1-1_rcp85_r1i1p1_20991231.ctl]
> dset tas_day_bcc-csm1-1_rcp85_r1i1p1_20991231.nc
> dtype netcdf
> options 365_day_calendar
> tdef lat 1 linear 00Z31DEC2099 1440mn
> 
> 
> [BCC-CSM1-1_TAS_hist_rcp85_with31dec2099.ctl]
> DSET TAS/tas_day_bcc-csm1-1_%ch
> # below goes from 1850 to 2005, skipping hist 2006-2012
> CHSUB     1 56940 historical_r1i1p1_18500101-20121230.nc
> CHSUB 56941 91249 rcp85_r1i1p1_20060101-20991230.nc
> CHSUB 91250 91250 rcp85_r1i1p1_20991231.ctl
> CHSUB 91251 127750 rcp85_r1i1p1_21000101-21991231.nc
> OPTIONS template
> DTYPE netcdf
> OPTIONS 365_day_calendar
> TDEF time 127750 LINEAR 00z1Jan1850 1440mn
> 
> This time, I get this:
> 
> ga-> set t 91250                                        
> Time values set: 2099:12:31:0 2099:12:31:0 
> ga-> d tas
> Cannot contour grid - all undefined values 
> 
> Any suggestions???
> 
> David Westberg
> SSAI / NASA Langley Research Center
> david.j.westberg at nasa.gov
> 
> 
> 
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr

--
Jennifer M. Adams
Center for Ocean-Land-Atmosphere Studies (COLA)
111 Research Hall, Mail Stop 2B3
George Mason University
4400 University Drive
Fairfax, VA 22030 





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20141203/5aec4f21/attachment-0001.html 


More information about the gradsusr mailing list