Re: Lost long_names / units

From: Michael Notaro <mnotaro_at_nyahnyahspammersnyahnyah>
Date: Thu, 07 May 2009 08:19:37 -0500

Dennis,

Thanks!

The whole issue is confusing. I same the same file to Guangshan
and we both did an ncdump on the file. For me, AGDD_PERIOD
has a long_name of "K" and for him, nothing, not even quotes.

After I run either program, the long_name changes from "K" to "".

When Guangshan runs either, it goes from nothing to "".

Not sure why you didn't find that also.

Mike

On May 6, 2009, at 5:22 PM, Dennis Shea wrote:

> Mike, .... I know that Dave is looking but
> you stated in an earlier emails: "
>
> 2 things go wrong. Some units are lost (e.g. time_mgr_rst_type)
> and some long_names are lost (AGDD_PERIOD). Also,
> levsoi and string_length, 2 unused attributes, are lost.
> ========
>
>
> I ran the appended script and both "time_mgr_rst_type"
> and "AGDD_PERIOD" have the *same meta data*.
> I used ncdump -h rather than ncl_filedump to remove
> any doubt that it is related to NCL. I am not sure why you
> would be experiencing the issues you describe.
>
> As to why the dimension names/values 'levsoi' and 'string_length'
> are not written to the file, the answer is simple:
>
> out->$names(i)$ = v ; write variable values and meta data
>
> This writes out meta data associated with each *variable*.
> Since 'levsoi' and 'string_length' are *not* associated with any
> of the *variables* being written, they will not appear on the
> output netcdf file. The user must do this.
>
> Note that NCL places variables in a stack. I think it is last-in/
> first-out
> so if you want the exact order then uncomment the lines below.
>
>
> ==================== NCL SCRIPT ====================
> in =addfile("b35.012mons1.clm2.r.2193-01-01-00000.nc","r")
> names = getfilevarnames(in)
> numb = dimsizes(names)
>
> dimNames = getvardims(in) ; "in" if a *file reference* AND
> dimSizes = getfiledimsizes(in) ; it is also a *variable*
> dimUnlim = new( dimsizes(dimNames), "logical", "No_FillValue")
> dimUnlim = False
>
> system("/bin/rm -f newfile.nc") ; remove any pre-existing file
> out=addfile("newfile.nc","c")
>
> ;names = names(::-1) ; NOT needed but if exact
> order ;dimSizes = dimSizes(::-1) ; desired.
> ;dimNames = dimNames(::-1)
> do i=0,numb-1 v = in->$names(i)$
> out->$names(i)$ = v ; write variable values and meta data
> delete(v)
> end do
>
>
>
> Michael Notaro wrote:
>> Dave,
>>
>> Even with this other script, the dimensions levsoi & string_length
>> are
>> lost and some variables lose their units and long_names. Something
>> seems wrong.
>>
>> Mike
>>
>>
>> begin
>> system ("/bin/rm b35.012mons1.clm2.r.
>> 2193-01-01-00000.new.nc") ; remove if exist
>> out = addfile("b35.012mons1.clm2.r.2193-01-01-00000.new.nc","c")
>> in = addfile("b35.012mons1.clm2.r.2193-01-01-00000.nc", "r")
>> vname = getfilevarnames(in)
>>
>> do i=0,dimsizes(vname)-1
>> dims = getfilevardims(in,vname(i))
>> nrank = dimsizes(dims)
>> Vold = in->$vname(i)$ ; read each variable to memory
>> Vnew = Vold
>> copy_VarMeta(Vold,Vnew)
>> out->$vname(i)$ = Vnew
>> delete(Vnew)
>> delete(Vold)
>> delete(dims)
>> delete(nrank)
>> end do
>>
>> end
>>
>>
>>
>> On May 6, 2009, at 3:53 PM, David Brown wrote:
>>
>>
>>> Hi Mike,
>>> This doesn't sound like the correct documented behavior. Can you
>>> supply a test case NetCDF file that will demonstrate the problem
>>> using the sample code below?
>>> Thanks,
>>> -dave
>>>
>>>
>>> On May 6, 2009, at 2:15 PM, Michael Notaro wrote:
>>>
>>>
>>>> If I open a file, retrieve all the variables, and write them
>>>> to a new file, some of the variables lose their long_names and
>>>> units
>>>> in the process, mainly integer variables. Please see below.
>>>> Any idea how to maintain all the variables' info, including
>>>> long_name, dimensions, units, etc?
>>>>
>>>> Mike
>>>>
>>>> a=addfile("originalfile.nc","r")
>>>> .....
>>>> ......
>>>> out=addfile("newfile.nc","c")
>>>> do i=0,numb-1
>>>> v = a->$names(i)$
>>>> out->$names(i)$ = v
>>>> delete(v)
>>>> end do
>>>>
>>>> _______________________________________________
>>>> 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
>>
>
>
> --
> ======================================================
> Dennis J. Shea tel: 303-497-1361 |
> P.O. Box 3000 fax: 303-497-1333 |
> Climate Analysis Section |
> Climate & Global Dynamics Div. |
> National Center for Atmospheric Research |
> Boulder, CO 80307 |
> USA email: shea 'at' ucar.edu |
> ======================================================
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu May 07 2009 - 07:19:37 MDT

This archive was generated by hypermail 2.2.0 : Fri May 08 2009 - 10:05:07 MDT