<p dir="ltr">That's where a full ncl_filedump would be useful. <br>
That would answer whether VAR is a dimension in each variable? Is it just an attribute in each variable? <br>
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. <br>
<br>
</p>
<div class="gmail_quote">On 18 Sep 2015 12:14 p.m., "Luo, Chao" <<a href="mailto:chao.luo@eas.gatech.edu">chao.luo@eas.gatech.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:#000000">Hi Alan,<div><br></div><div>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.</div><div><br></div><div>Thanks,</div><div><br></div><div>Chao <br><br><hr><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>From: </b>"Alan Brammer" <<a href="mailto:abrammer@albany.edu" target="_blank">abrammer@albany.edu</a>><br><b>To: </b>"Chao Luo" <<a href="mailto:chao.luo@eas.gatech.edu" target="_blank">chao.luo@eas.gatech.edu</a>><br><b>Cc: </b>"Dennis Shea" <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>>, "ncl-talk Talk" <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>><br><b>Sent: </b>Friday, September 18, 2015 7:13:15 AM<br><b>Subject: </b>Re: [ncl-talk] netcdf TFLAG dimension<br><br><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">A full ncl_filedump would be clearer. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Though maybe it's because you're blindly copying the global attributes. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">do i=0,dimsizes(global_attnames)-</span><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">1</span></div><div class="gmail_default"><font color="#000000"> print("Attribute " + </font><span style="font-family:verdana,sans-serif">global_attnames</span><font color="#000000">(i) + " = " + fin@$</font><span style="font-family:verdana,sans-serif">global_attnames</span><font color="#000000">(i)$) ;; check what you're copying over. </font><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"> if(global_attnames(i).eq."VAR") </div><div class="gmail_default"><span style="color:rgb(0,0,0);font-size:13px"> ncdf@$global_attnames(i)$ = 2 ;; Manually edit the global attribute you're concerned about. </span></div><div class="gmail_default"><font color="#000000"> else<br></font><span style="font-family:arial,sans-serif;color:rgb(0,0,0);font-size:13px"> ncdf@$global_attnames(i)$ = fin@$global_attnames(i)$ ;-- write globalattribute to new netcdf file</span><br style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;color:rgb(0,0,0);font-size:13px"> end if</span></div><div class="gmail_default"><span style="font-family:arial,sans-serif;color:rgb(0,0,0);font-size:13px">end do</span><br></div><div class="gmail_default"><br></div><div class="gmail_default"><font color="#000000">or just after the loop reset the attribute to whatever you fancy. </font></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-size:13px"><br></span></div><div class="gmail_default"><span style="color:rgb(0,0,0);font-size:13px">ncdf@VAR = 2</span><br></div><div class="gmail_default"><span style="font-family:arial,sans-serif;color:rgb(0,0,0);font-size:13px"><br></span></div><div class="gmail_default"><span style="font-family:arial,sans-serif;color:rgb(0,0,0);font-size:13px"><br></span></div><div class="gmail_default"><span style="font-family:arial,sans-serif;color:rgb(0,0,0);font-size:13px">Alan. </span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 17, 2015 at 6:43 PM, Luo, Chao <span dir="ltr"><<a href="mailto:chao.luo@eas.gatech.edu" target="_blank">chao.luo@eas.gatech.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, here is what I did.<br>
<br>
---------------------------<br>
<br>
begin<br>
<br>
fin = addfile(METCRO2D_148x112_20110701,"r")<br>
ncdf = addfile(<a href="http://out.nc" rel="noreferrer" target="_blank">out.nc</a>,"c")<br>
<br>
<br>
global_attnames = getvaratts(fin) ;-- retrieve the global attributes from input file<br>
do i=0,dimsizes(global_attnames)-1<br>
ncdf@$global_attnames(i)$ = fin@$global_attnames(i)$ ;-- write globalattribute to new netcdf file<br>
end do<br>
<br>
names = getfilevarnames(fin); extract all variable names<br>
<br>
;do i = 0, dimsizes(names)-1<br>
do i = 0, 1 ; write out two variable<br>
ncdf->$names(i)$ = fin->$names(i)$<br>
end do<br>
<br>
end<br>
<br>
--------------------------<br>
<br>
But the dimensions of output netcdf file (<a href="http://out.nc" rel="noreferrer" target="_blank">out.nc</a>) still are:<br>
<br>
dimensions:<br>
TSTEP = UNLIMITED ; // (25 currently)<br>
DATE-TIME = 2 ;<br>
LAY = 1 ;<br>
VAR = 40 ;<br>
ROW = 112 ;<br>
COL = 148 ;<br>
<br>
The dimensions of output file should be:<br>
<br>
dimensions:<br>
TSTEP = UNLIMITED ; // (25 currently)<br>
DATE-TIME = 2 ;<br>
LAY = 1 ;<br>
VAR = 2 ;<br>
ROW = 112 ;<br>
COL = 148 ;<br>
<br>
I don't know how to change VAR = 40 to VAR = 2 in output file.<br>
<br>
Thanks very much,<br>
<br>
Chao<br>
<div><div><br>
<br>
<br>
<br>
----- Original Message -----<br>
From: "Dennis Shea" <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>><br>
To: "Chao Luo" <<a href="mailto:chao.luo@eas.gatech.edu" target="_blank">chao.luo@eas.gatech.edu</a>><br>
Cc: "ncl-talk Talk" <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>><br>
Sent: Thursday, September 17, 2015 1:33:44 PM<br>
Subject: Re: [ncl-talk] netcdf TFLAG dimension<br>
<br>
The description provides no information that can be used to help<br>
diagnose the problem, Try again<br>
<br>
On Wed, Sep 16, 2015 at 1:29 PM, Luo, Chao <<a href="mailto:chao.luo@eas.gatech.edu" target="_blank">chao.luo@eas.gatech.edu</a>> wrote:<br>
> Hi,<br>
><br>
> I extracted couple variables from a netcdf file (with 40 variables) and<br>
> write out to a new netcdf file with dimension and TFLAG information. But the<br>
> new file's still has dimension: VAR =40, which is same as the original<br>
> netcdf file. The VAR should be equal to 2 (VAR=2) in new netcdf file. I<br>
> don't know how to change it by NCL.<br>
> Very appreciate any help and suggestions.<br>
><br>
> Chao<br>
><br>
> _______________________________________________<br>
> ncl-talk mailing list<br>
> <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
> List instructions, subscriber options, unsubscribe:<br>
> <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
><br>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</div></div></blockquote></div><br></div>
</div><br></div></div></div></blockquote></div>