<div dir="ltr"><div><div><div>I have not looked carefully at your code.<br></div><div><br>[1] The &#39;tofloat&#39; function does *NOT* preserve meta data. The contributed function &#39;dble2flt&#39; does preserve meta data.<br></div>     <br><br>[2]<br><br><span style="font-size:16px;background-color:transparent">7   files = systemfunc(&quot;sh sortname.sh&quot;)
<br>     8       setfileoption(&quot;nc&quot;,&quot;Format&quot;,&quot;LargeFile&quot;)
<br>     9       fallvars = addfiles(files,&quot;r&quot;)
<br>    10     ListSetType(fallvars,&quot;cat&quot;)
<br>    11     runoff   = fallvars[:]-&gt;runoff
</span><br><br></div><div>After line 11:<br><br></div>  printVarSummary(runoff)                   ; &lt;=== please look at this<br></div><div>                                                            ; it should have all meta data<br></div><div><br></div><div>FYI: NCL does not care if latitude/longitude/time are double<br><br></div><div>  printVarSummary(runoff&amp;latitude)    ; double with meta data (eg: units)<br></div><div>  printVarSummary(runoff&amp;longitude) ; double<br>  printVarSummary(runoff&amp;time)         ; double<br><br></div><div>  LAT = runoff&amp;latitude      ; save double<br></div><div>  delete( runoff&amp;latitude )   ; delete double values in coordinate array but not dimension name<br></div><div>  runoff&amp;latitude = dble2flt(LAT)<br><br></div><div>  print(runoff&amp;latitude)  ; &lt;== should be type float<br><br></div><div>Do similar things with longitude and time<br></div><div> <br></div><div>                                       <br></div><div>  <br><br></div><div><br></div>To change the double to float, you do not need to do all the steps you <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 22, 2014 at 4:09 AM, <a href="mailto:dyjbean@gmail.com">dyjbean@gmail.com</a> <span dir="ltr">&lt;<a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
<table style="padding:10px;background-color:transparent" background="cid:_Foxmail.1@36b61ecc-955c-3d1e-646c-7dbafd62b1ce" border="0" cellpadding="0" cellspacing="0" height="100%" width="99.99%">
<tbody><tr>
<td style="width:100%;height:100%" valign="top">
<div>
<div><span></span><br></div>
<div><span style="font-size:16px;background-color:rgba(0,0,0,0)">i&#39;m processing merra-land daily production, the variable latitude and longitude are both double.
<br>the below  is my code :
<br>
<br>+++++++++++++++++++++++++++++++++++++++++++++++++++
<br>     1  load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;
<br>     2  load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot;
<br>     3  load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;
<br>     4  load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl&quot;
<br>     5
<br>     6  begin
<br>     7     files = systemfunc(&quot;sh sortname.sh&quot;)
<br>     8     setfileoption(&quot;nc&quot;,&quot;Format&quot;,&quot;LargeFile&quot;)
<br>     9     fallvars = addfiles(files,&quot;r&quot;)
<br>    10     ListSetType(fallvars,&quot;cat&quot;)
<br>    11     runoff   = fallvars[:]-&gt;runoff
<br>    12     slat = fallvars[:]-&gt;latitude(0:360)
<br>    13     slon = fallvars[:]-&gt;longitude(0:539)
<br>    14
<br>    15     dims=dimsizes(runoff)
<br>    16
<br>    17     lat=new((/dims(1)/),float,&quot;No_FillValue&quot;)
<br>    18     lon=new((/dims(2)/),float,&quot;No_FillValue&quot;)
<br>    19     time=new((/dims(0)/),integer,&quot;No_FillValue&quot;)
<br>    20     srunoff=new((/dims(2),dims(1),dims(0)/),float,runoff@_FillValue)
<br>    21
<br>    22     lon!0=&quot;lon&quot;
<br>    23     lon@long_name=&quot;longitude&quot;
<br>    24     lon@units=&quot;degrees-east&quot;
<br>    25     lon=tofloat(slon)
<br>    26     print(slon(0)+&quot; &quot;+slon(539))
<br>    27     print(lon(0)+&quot; &quot;+lon(539))
<br>    28
<br>    29     lat!0=&quot;lat&quot;
<br>    30     lat@long_name=&quot;latitude&quot;
<br>    31     lat@units=&quot;degrees-north&quot;
<br>    32     lat=tofloat(slat)
<br>    33
<br>    34     time!0=&quot;time&quot;
<br>    35     time@long_name=&quot;time&quot;
<br>    36     time@units=&quot;days since 1980-1-1 0&quot;
<br>    37     time=yyyymm_time(1980,2013,&quot;integer&quot;)
<br>    38
<br>    39     srunoff!0=&quot;lon&quot;
<br>    40     srunoff!1=&quot;lat&quot;
<br>    41     srunoff!2=&quot;time&quot;
<br>    42     srunoff&amp;lon=lon
<br>    43     srunoff&amp;lat=lat
<br>    44     srunoff&amp;time=(/time/)
<br>    45     srunoff@units = &quot;kg.m-2.s-1&quot;
<br>    46     srunoff@long_name = &quot;Overland runoff&quot;
<br>    47     ;srunoff=(/runoff(longitude|:,latitude|:,time|:)/)
<br>    48     do i=0,dims(0)-1
<br>    49         do j=0,dims(1)-1
<br>    50            do k=0,dims(2)-1
<br>    51                srunoff(k,j,i)=(/runoff(i,j,k)/)
<br>    52            end do
<br>    53         end do
<br>    54    end do
<br>    55
<br>    56     printVarSummary(runoff)
<br>    57     printVarSummary(srunoff)
<br>    58  end
<br>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
<br>in the line 25,32,37, if i change them with the following fashion:
<br>
<br>lon&amp;lon=tofloat(slon)
<br>lat&amp;lat=tofloat(slat)
<br>time&amp;time=yyyymm_time(1980,2013,&quot;integer&quot;)
<br>
<br>then, the wrong result will generate from line 26 and 27,
<br>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<br>
<br>(0)     -180 179.3333282470703
<br>(0)     -254807 0
<br>
<br>......
<br>
<br>Variable: srunoff
<br>Type: float
<br>Total Size: 318142080 bytes
<br>            79535520 values
<br>Number of Dimensions: 3
<br>Dimensions and sizes:   [lon | 540] x [lat | 361] x [time | 408]
<br>Coordinates:
<br>            lon: [-180..179.3333]
<br>            lat: [-90..90]
<br>            time: [-931605192..0]
<br>Number Of Attributes: 3
<br>  long_name :   Overland runoff
<br>  units :       kg.m-2.s-1
<br>  _FillValue :  1e+15
<br>
<br>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<br><br>if i change them with direct assignment, like the line 25,32,37,the right result will appear
<br>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<br>(0)     -180 179.3333282470703
<br>(0)     -180 179.333
<br>
<br>
<br>Variable: srunoff
<br>Type: float
<br>Total Size: 318142080 bytes
<br>            79535520 values
<br>Number of Dimensions: 3
<br>Dimensions and sizes:   [lon | 540] x [lat | 361] x [time | 408]
<br>Coordinates:
<br>            lon: [-180..179.3333]
<br>            lat: [-90..90]
<br>            time: [198001..201312]
<br>Number Of Attributes: 3
<br>  long_name :   Overland runoff
<br>  units :       kg.m-2.s-1
<br>  _FillValue :  1e+15
<br> 
<br>++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<br>
<br>i want to know why the &quot;lon&amp;lon, lat&amp;lat, time&amp;time&quot; style gave wrong results?
<br>
<br>thanks</span></div><hr style="width:210px;min-height:1px" align="left" color="#b5c4df" size="1"><span class="HOEnZb"><font color="#888888">
<div><span><div style="FONT-FAMILY:verdana;FONT-SIZE:10pt">
<div><a href="mailto:dyjbean@gmail.com" target="_blank">dyjbean@gmail.com</a></div></div></span></div>
<div></div></font></span></div>
</td>
</tr>
</tbody></table>
</div><br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>