[ncl-talk] Time, lat and lon information is missing in created file

Mary Haley haley at ucar.edu
Thu May 21 15:13:39 MDT 2015


Amit,

Your code looks correct, so it may be the input data that's the issue.

You should always do a "printVarSummary" on any variables that aren't
producing the expected metadata.

What does the following report:

printVarSummary(tasmax)
printVarSummary(b)

You can try this script as an example:

 infile  = "$NCARG_ROOT/lib/ncarg/data/cdf/uv300.nc"
 outfile = "test.nc"
 f = addfile(infile,"r")
 u = f->U(:,{25:50},{-100:100})
 b = u
 printVarSummary(u)

;---Write to new file
 system(" rm -rf " + outfile)
 ncdf = addfile(outfile,"c")
 filedimdef(ncdf,"time",-1,True)
 ncdf->u = u

;---Close the file
 delete(ncdf)

;---Open new file and read coordinate arrays
  a = addfile (outfile,"r")
  time = a->time
  lat  = a->lat
  lon  = a->lon
  print(time)
  printVarSummary(lat)
  printVarSummary(lon)
  printMinMax(lat,0)
  printMinMax(lon,0)



On Tue, May 19, 2015 at 10:03 AM, amit timilsina <
timilsinaamit87 at huskers.unl.edu> wrote:

>
> Hello all,
>
> I have tried to clip required domain data set and created new .nc file but
> there is not time co-ordinate information. Is there other code need to
> write while creating file??? Here is the code I have used.
>
>
> ncl 0> f =
> addfile("tasmax_Amon_MPI-ESM-LR_decadal1980_r1i1p1_198101-201012.nc","r")
> ncl 1> tasmax =f->tasmax(:,{25:50},{235:285})
> ncl 2> b = tasmax
> ncl 3> ncdf = addfile("tasmax_Amon_MPI-ESM-LR_decadal1980_r1_USA.nc","c")
> ncl 4> filedimdef(ncdf,"time",-1,True)
> ncl 5> ncdf->tasmax = b
>
> I could not have access to any co-rodinates using following codes:
>
> a= addfile ("tasmax_Amon_MPI-ESM-LR_decadal1980_r1_USA.nc","r")
> b=a->time               /*output: there is no time dimension on file a
> c=a->lon                  /*output: there is no lon dimension on file a
> d=a->lat                  /*output: there is no lat demotion on file a
>
>
> Thank you in advance
>
> Regards,
> Amit
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150521/e2056821/attachment.html 


More information about the ncl-talk mailing list