<div dir="ltr"><div><div><div><br><br>undef("int2flt_scale")<br>function int2flt_scale (xi)<br></div><div>begin<br></div><div>    xf = xi*xi@scale_factor + xi@add_offset<br></div><div>    xf@long_name = xi@long_name<br></div><div>    xf@units           = xi@units<br></div><div>    xf@missing_value = xf@_FillValue <br></div><div>    xf@valid_range= tofloat( xi@valid_range)<br></div><div>    copy_VarCoords(xi, xf)<br></div><div>    return(xf)<br></div><div><span class="gmail-m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span></div><div>end<br></div><div><br></div> f = addfile("<a href="http://foo.nc">foo.nc</a>","r")<br><br><span class="gmail-m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"> soil_m = int2flt_scale( f->SOIL_M )<br></span></div><span class="gmail-m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"> printVarSummary(soil_m)<br></span></div><span class="gmail-m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"> printMinMax(soil_m, 0)<br></span><div><div><br> <br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 17, 2018 at 11:05 AM, Yongxin Zhang <span dir="ltr"><<a href="mailto:yongxin.fred@gmail.com" target="_blank">yongxin.fred@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I have a netCDF file, <a href="http://soil_m.nc" target="_blank">soil_m.nc</a>, that contains only integer variables with scale_factor and add_offset, for example, SOIL_M looks like this:<div><br></div><div>




<span></span>





<p class="m_-8688641017838019295gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>int SOIL_M(time, y, soil_layers_stag, x) ;</span></p>
<p class="m_-8688641017838019295gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>SOIL_M:_FillValue = -999900 ;</span></p>
<p class="m_-8688641017838019295gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>SOIL_M:missing_value = -999900 ;</span></p>
<p class="m_-8688641017838019295gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>SOIL_M:long_name = "volumetric soil moisture" ;</span></p>
<p class="m_-8688641017838019295gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>SOIL_M:units = "m3 m-3" ;</span></p>
<p class="m_-8688641017838019295gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>SOIL_M:scale_factor = 0.01f ;</span></p>
<p class="m_-8688641017838019295gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>SOIL_M:add_offset = 0.f ;</span></p>
<p class="m_-8688641017838019295gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="m_-8688641017838019295gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span><span class="m_-8688641017838019295gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>SOIL_M:valid_range = 0, 100 ;</span></p>


<br></div><div>After I opened the data file by issuing "fin=addfile("<a href="http://soil_m.nc" target="_blank">soil_m.nc</a>","r")" in ncl and then I did "data1=fin->SOIL_M", "data2=tofloat(fin->SOIL_M)", and "data3=int2flt(fin->SOIL_M)" but in all cases the data range from 0 to 100 instead of 0 to 1 or 0.0 to 1.0. I am just wondering if there is a way that NCL can automatically read in an integer variable with the scale_factor and add_offset applied.</div><div><br></div><div>Thanks,</div><div>Yongxin</div></div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>