[ncl-talk] netcdf TFLAG dimension
Alan Brammer
abrammer at albany.edu
Fri Sep 18 10:17:37 MDT 2015
That's where a full ncl_filedump would be useful.
That would answer whether VAR is a dimension in each variable? Is it just
an attribute in each variable?
Just send the full output of ncl_filedump of the new and old netcdfs,
people will probably have a better idea as to the real question then.
On 18 Sep 2015 12:14 p.m., "Luo, Chao" <chao.luo at eas.gatech.edu> wrote:
> Hi Alan,
>
> This method does change global attribute VAR to 2, but dosen't change
> dimension variable VAR to 2. I want to change dimension variable VAR from
> 40 to 2.
>
> Thanks,
>
> Chao
>
> ------------------------------
> *From: *"Alan Brammer" <abrammer at albany.edu>
> *To: *"Chao Luo" <chao.luo at eas.gatech.edu>
> *Cc: *"Dennis Shea" <shea at ucar.edu>, "ncl-talk Talk" <ncl-talk at ucar.edu>
> *Sent: *Friday, September 18, 2015 7:13:15 AM
> *Subject: *Re: [ncl-talk] netcdf TFLAG dimension
>
> A full ncl_filedump would be clearer.
>
> Though maybe it's because you're blindly copying the global attributes.
>
> do i=0,dimsizes(global_attnames)-1
> print("Attribute " + global_attnames(i) + " = " + fin@$global_attnames(i)$)
> ;; check what you're copying over.
> if(global_attnames(i).eq."VAR")
> ncdf@$global_attnames(i)$ = 2 ;; Manually edit the global
> attribute you're concerned about.
> else
> ncdf@$global_attnames(i)$ = fin@$global_attnames(i)$ ;-- write
> globalattribute to new netcdf file
> end if
> end do
>
> or just after the loop reset the attribute to whatever you fancy.
>
> ncdf at VAR = 2
>
>
> Alan.
>
> On Thu, Sep 17, 2015 at 6:43 PM, Luo, Chao <chao.luo at eas.gatech.edu>
> wrote:
>
>> Hi, here is what I did.
>>
>> ---------------------------
>>
>> begin
>>
>> fin = addfile(METCRO2D_148x112_20110701,"r")
>> ncdf = addfile(out.nc,"c")
>>
>>
>> global_attnames = getvaratts(fin) ;-- retrieve the global attributes from
>> input file
>> do i=0,dimsizes(global_attnames)-1
>> ncdf@$global_attnames(i)$ = fin@$global_attnames(i)$ ;-- write
>> globalattribute to new netcdf file
>> end do
>>
>> names = getfilevarnames(fin); extract all variable names
>>
>> ;do i = 0, dimsizes(names)-1
>> do i = 0, 1 ; write out two variable
>> ncdf->$names(i)$ = fin->$names(i)$
>> end do
>>
>> end
>>
>> --------------------------
>>
>> But the dimensions of output netcdf file (out.nc) still are:
>>
>> dimensions:
>> TSTEP = UNLIMITED ; // (25 currently)
>> DATE-TIME = 2 ;
>> LAY = 1 ;
>> VAR = 40 ;
>> ROW = 112 ;
>> COL = 148 ;
>>
>> The dimensions of output file should be:
>>
>> dimensions:
>> TSTEP = UNLIMITED ; // (25 currently)
>> DATE-TIME = 2 ;
>> LAY = 1 ;
>> VAR = 2 ;
>> ROW = 112 ;
>> COL = 148 ;
>>
>> I don't know how to change VAR = 40 to VAR = 2 in output file.
>>
>> Thanks very much,
>>
>> Chao
>>
>>
>>
>>
>> ----- Original Message -----
>> From: "Dennis Shea" <shea at ucar.edu>
>> To: "Chao Luo" <chao.luo at eas.gatech.edu>
>> Cc: "ncl-talk Talk" <ncl-talk at ucar.edu>
>> Sent: Thursday, September 17, 2015 1:33:44 PM
>> Subject: Re: [ncl-talk] netcdf TFLAG dimension
>>
>> The description provides no information that can be used to help
>> diagnose the problem, Try again
>>
>> On Wed, Sep 16, 2015 at 1:29 PM, Luo, Chao <chao.luo at eas.gatech.edu>
>> wrote:
>> > Hi,
>> >
>> > I extracted couple variables from a netcdf file (with 40 variables) and
>> > write out to a new netcdf file with dimension and TFLAG information.
>> But the
>> > new file's still has dimension: VAR =40, which is same as the original
>> > netcdf file. The VAR should be equal to 2 (VAR=2) in new netcdf file. I
>> > don't know how to change it by NCL.
>> > Very appreciate any help and suggestions.
>> >
>> > Chao
>> >
>> > _______________________________________________
>> > ncl-talk mailing list
>> > ncl-talk at ucar.edu
>> > List instructions, subscriber options, unsubscribe:
>> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>> >
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> 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/20150918/c6ceed04/attachment.html
More information about the ncl-talk
mailing list