NetCDF 2 NetCDF coordinate dimension transfer?

From: Ramon Docto <mondocto2_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 04 2013 - 16:06:23 MDT

Hello List,

I wish to create a new NetCDF file containing a derived variable for Mean
Daily Temperature (mdt) by taking the mean of tmax and tmin variables in an
exsiting NetCDF file.

My script is as follows:

begin

  ipath = "~/data/echam5/daily/"
  fname = "gdd.196101-196512.nc"

  ifile = addfile(ipath + fname, "r")

  tmax = ifile->tmaxscr
  tmin = ifile->tminscr

  system("/bin/rm -f ./test.nc")

  ofile = addfile("test.nc", "c")

  ;; enable record dimension
time

filedimdef(ofile,"time",-1,True)

  ofile->tmax =
tmax

  ofile->tmin =
tmin

  mdt = (tmax + tmin) /
2
  mdt@long_name="Mean Daily
Temperature";

  ofile->mdt =
mdt

end

However, mdt created this way assumes new coordinate dimensions:

netcdf test {
dimensions:
        time = UNLIMITED ; // (1825 currently)
        lat = 51 ;
        lon = 56 ;
        ncl3 = 1825 ;
        ncl4 = 51 ;
        ncl5 = 56 ;
variables:
        short tmax(time, lat, lon) ;
                tmax:long_name = "Maximum screen temperature (K) v3" ;
                tmax:units = "K" ;
                tmax:add_offset = 250.f ;
                tmax:scale_factor = 0.0046875f ;
                tmax:valid_min = -32500 ;
                tmax:valid_max = 32500 ;
                tmax:_FillValue = -32767s ;
                tmax:missing_value = -32767s ;
        float time(time) ;
                time:units = "minutes since 1951-01-01 00:00:00" ;
                time:standard_name = "time" ;
                time:axis = "T" ;
        float lat(lat) ;
                lat:long_name = "latitude" ;
                lat:standard_name = "latitude" ;
                lat:axis = "Y" ;
                lat:units = "degrees_north" ;
        float lon(lon) ;
                lon:long_name = "longitude" ;
                lon:standard_name = "longitude" ;
                lon:axis = "X" ;
                lon:units = "degrees_east" ;
        short tmin(time, lat, lon) ;
                tmin:long_name = "Minimimum screen temperature (K) v3" ;
                tmin:units = "K" ;
                tmin:add_offset = 250.f ;
                tmin:scale_factor = 0.0046875f ;
                tmin:valid_min = -32500 ;
                tmin:valid_max = 32500 ;
                tmin:_FillValue = -32767s ;
                tmin:missing_value = -32767s ;
        int mdt(ncl3, ncl4, ncl5) ;
                mdt:long_name = "Mean Daily Temperature" ;
                mdt:_FillValue = -32767 ;
}

Questions:

A. How do I create derived variables with coordinates matching their inputs?
B. I notice the type of the derived variable (int) is also unmatched to the
inputs (short, with appropriate scale and offset values). How might I
arrange that also?

Thanks in advance,
Ramon

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jun 4 16:06:37 2013

This archive was generated by hypermail 2.1.8 : Tue Jun 11 2013 - 12:03:58 MDT