<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19328">
<STYLE>
<!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        font-size:10.5pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Verdana;
        color:windowtext;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
/* Page Definitions */
@page Section1
        {size:595.3pt 841.9pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;
        layout-grid:15.6pt;}
div.Section1
        {page:Section1;}
-->
</STYLE>
</HEAD>
<BODY>
<DIV><FONT color=#0000ff size=2 face=Verdana>Thanks a lot, <FONT
color=#000000>Dennis</FONT></FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana>Your and Mary's prompt response to problems
from new learners is extremely helpful.</FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana>Forgive me to rise the question again because I
do not know anything about it. There are too many things I need to learn before
I can use NCL well.</FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana>Thank you again and All my best
wishes!</FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana>Shawn</FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV align=left>
<DIV align=left><FONT size=2 face=Verdana>
<HR style="WIDTH: 122px; HEIGHT: 2px" SIZE=2>
</FONT></DIV>
<DIV><FONT color=#c0c0c0><FONT size=2 face=Verdana>Wen.J.Qu</FONT></DIV>
<DIV><FONT size=2 face=Verdana>2012-10-19</FONT></FONT></DIV></DIV>
<DIV><FONT size=2 face=Verdana>
<HR>
</FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2><STRONG>发件人:</STRONG> Dennis
Shea</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2><STRONG>发送时间:</STRONG>
2012-10-19 08:28:43</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2><STRONG>收件人:</STRONG>
Wen.J.Qu@gmail.com</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2><STRONG>抄送:</STRONG>
ncl-talk</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2><STRONG>主题:</STRONG> Re: [ncl-talk] Why
min/max are different from the actual range?</FONT></FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana>
<DIV>This issue has been discussed many times on ncl-talk.</DIV>
<DIV>See the FAQ and email archives.</DIV>
<DIV>==========</DIV>
<DIV>As indicated, your data are type short.</DIV>
<DIV>They also have a 'scale_factor' and 'add_offset'</DIV>
<DIV> </DIV>
<DIV> Variable: hgt</DIV>
<DIV> Type: short</DIV>
<DIV> </DIV>
<DIV> add_offset : 32066</DIV>
<DIV> scale_factor : 1</DIV>
<DIV> </DIV>
<DIV>These must be unpacked (unscaled) prior to use. The formula is</DIV>
<DIV> </DIV>
<DIV> unpacked_value = packed_value*scale_factor + add_offset</DIV>
<DIV> </DIV>
<DIV>NCL has a function located in contributed.ncl for this.</DIV>
<DIV>It preserves all meta data.</DIV>
<DIV> </DIV>
<DIV> <A
href="http://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml">http://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml</A></DIV>
<DIV> </DIV>
<DIV>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</DIV>
<DIV> </DIV>
<DIV>hgt = short2flt( f- >hgt(:,5,:,:) )</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>On 10/19/12 12:52 AM, Wen.J.Qu wrote:</DIV>
<DIV>> Hi, all</DIV>
<DIV>> When I read a .nc file, printVarSummary shows the 3D variable "hgt" has</DIV>
<DIV>> an actual range of "-527, 32307 "</DIV>
<DIV>> But when I use the line {print("hgt min/max = " + min(hgt) + "/"</DIV>
<DIV>> + max(hgt))} to print the min and max, it shows "hgt min/max =</DIV>
<DIV>> -27627/-26066"</DIV>
<DIV>> Please help me to give some hint about the problem of this code. Is it</DIV>
<DIV>> from my calculation of min and max with the "short" data type? Is it</DIV>
<DIV>> from the wrong setting of the missing value? Or is it from my probably</DIV>
<DIV>> some wrong in reading the .nc file?</DIV>
<DIV>> Thanks a lot in advance.</DIV>
<DIV>> Shawn</DIV>
<DIV>> ##############################################################</DIV>
<DIV>> code</DIV>
<DIV>> ##############################################################</DIV>
<DIV>> fil = systemfunc ("cd " + diri + " ; ls hgt."+YEAR+".nc")</DIV>
<DIV>> f = addfile(diri+fil,"r")</DIV>
<DIV>> ;Debugprint</DIV>
<DIV>> printVarSummary(f)</DIV>
<DIV>> hgt = f- >hgt(:,5,:,:)</DIV>
<DIV>> ;Debugprint</DIV>
<DIV>> printVarSummary(hgt)</DIV>
<DIV>> print("hgt min/max = " + min(hgt) + "/" + max(hgt))</DIV>
<DIV>> ##############################################################</DIV>
<DIV>> ##############################################################</DIV>
<DIV>> print result</DIV>
<DIV>> ##############################################################</DIV>
<DIV>> Variable: hgt</DIV>
<DIV>> Type: short</DIV>
<DIV>> Total Size: 7673760 bytes</DIV>
<DIV>> 3836880 values</DIV>
<DIV>> Number of Dimensions: 3</DIV>
<DIV>> Dimensions and sizes: [time | 365] x [lat | 73] x [lon | 144]</DIV>
<DIV>> Coordinates:</DIV>
<DIV>> time: [17373888..17382624]</DIV>
<DIV>> lat: [90..-90]</DIV>
<DIV>> lon: [ 0..357.5]</DIV>
<DIV>> Number Of Attributes: 19</DIV>
<DIV>> level : 500</DIV>
<DIV>> long_name : mean Daily Geopotential height</DIV>
<DIV>> actual_range : ( -527, 32307 )</DIV>
<DIV>> unpacked_valid_range : ( -700, 35000 )</DIV>
<DIV>> units : m</DIV>
<DIV>> add_offset : 32066</DIV>
<DIV>> scale_factor : 1</DIV>
<DIV>> missing_value : 32766</DIV>
<DIV>> precision : 0</DIV>
<DIV>> least_significant_digit : 0</DIV>
<DIV>> GRIB_id : 7</DIV>
<DIV>> GRIB_name : HGT</DIV>
<DIV>> var_desc : Geopotential height</DIV>
<DIV>> dataset : NCEP Reanalysis Daily Averages</DIV>
<DIV>> level_desc : Multiple levels</DIV>
<DIV>> statistic : Mean</DIV>
<DIV>> parent_stat : Individual Obs</DIV>
<DIV>> valid_range : ( -32766, 2934 )</DIV>
<DIV>> _FillValue : 32766</DIV>
<DIV>> (0) hgt min/max = -27627/-26066</DIV>
<DIV>> ##############################################################</DIV>
<DIV>> ------------------------------------------------------------------------</DIV>
<DIV>> Wen.J.Qu</DIV>
<DIV>> 2012-10-19</DIV>
<DIV>></DIV>
<DIV>></DIV>
<DIV>> _______________________________________________</DIV>
<DIV>> ncl-talk mailing list</DIV>
<DIV>> List instructions, subscriber options, unsubscribe:</DIV>
<DIV>> <A
href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</A></DIV>
<DIV>></DIV></FONT></DIV></BODY></HTML>