Re: file dimensions

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue, 5 May 2009 13:11:56 -0600

Hi Mike,

If you have the code:

a=addfile("b35.012mons1.clm2.r.2193-01-01-00000.nc","r")
dims = getvardims(a)

then "dims" should contain the names of all the dimensions that are
defined in the file, whether they are used in a variable or not.
  -dave

On May 5, 2009, at 1:08 PM, Michael Notaro wrote:

> Dave,
>
> But levsoi is not a dimension of any of the variables
> on the file. It is an unused attribute.
>
> Perhaps I don't need it anyhow for the model.
>
> Mike
>
> On May 5, 2009, at 2:03 PM, David Brown wrote:
>
>> Hi Mike,
>> You can use getvardims to retrieve the dimension names from a file
>> variable and
>> getfiledimsizes to get the sizes of each dimension. See example 2
>> of the getvardims doc.
>> -dave
>>
>> On May 5, 2009, at 12:38 PM, Michael Notaro wrote:
>>
>>> I am trying to open a CLM restart file, retrieve its contents,
>>> and write it again to a new identical file (later I will be
>>> modifying
>>> a couple of the variables).
>>>
>>> I tried the approach below. It creates a nearly identical file.
>>> However, the levsoi and string_length dimensions (which
>>> are unused by any variable) are lost.
>>>
>>> I'm not sure if the model needs those to be present. Assuming
>>> it does, how can I retrieve those dimensions from the first
>>> file and pass them to the new file?
>>>
>>> Thanks, Mike
>>>
>>>
>>> a=addfile("b35.012mons1.clm2.r.2193-01-01-00000.nc","r")
>>> system("rm b35.012mons1.clm2.r.2193-01-01-00000.new.nc")
>>> out=addfile("b35.012mons1.clm2.r.2193-01-01-00000.new.nc","c")
>>> names=getfilevarnames(a)
>>> numb=dimsizes(names)
>>> do i=0,numb-1
>>> v = a->$names(i)$
>>> out->$names(i)$ = v
>>> delete(v)
>>> end do
>>>
>>>
>>> From ncdump...
>>>
>>> dimensions:
>>> gridcell = 5674 ;
>>> landunit = 6080 ;
>>> column = 6080 ;
>>> pft = 41900 ;
>>> levsoi = 10 ;
>>> levlak = 10 ;
>>> levsno = 5 ;
>>> levtot = 15 ;
>>> numrad = 2 ;
>>> rtmlon = 720 ;
>>> rtmlat = 360 ;
>>> string_length = 64 ;
>>> etc...
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue May 05 2009 - 13:11:56 MDT

This archive was generated by hypermail 2.2.0 : Wed May 06 2009 - 16:48:59 MDT