[ncl-talk] Can NCL automatically read in an integer variable with scale_factor and add_offset?
Dennis Shea
shea at ucar.edu
Thu May 17 11:26:56 MDT 2018
undef("int2flt_scale")
function int2flt_scale (xi)
begin
xf = xi*xi at scale_factor + xi at add_offset
xf at long_name = xi at long_name
xf at units = xi at units
xf at missing_value = xf at _FillValue
xf at valid_range= tofloat( xi at valid_range)
copy_VarCoords(xi, xf)
return(xf)
end
f = addfile("foo.nc","r")
soil_m = int2flt_scale( f->SOIL_M )
printVarSummary(soil_m)
printMinMax(soil_m, 0)
On Thu, May 17, 2018 at 11:05 AM, Yongxin Zhang <yongxin.fred at gmail.com>
wrote:
> I have a netCDF file, soil_m.nc, that contains only integer variables
> with scale_factor and add_offset, for example, SOIL_M looks like this:
>
> int SOIL_M(time, y, soil_layers_stag, x) ;
>
> SOIL_M:_FillValue = -999900 ;
>
> SOIL_M:missing_value = -999900 ;
>
> SOIL_M:long_name = "volumetric soil moisture" ;
>
> SOIL_M:units = "m3 m-3" ;
>
> SOIL_M:scale_factor = 0.01f ;
>
> SOIL_M:add_offset = 0.f ;
>
> SOIL_M:valid_range = 0, 100 ;
>
> After I opened the data file by issuing "fin=addfile("soil_m.nc","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.
>
> Thanks,
> Yongxin
>
> _______________________________________________
> 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/20180517/7b61d0c3/attachment.html>
More information about the ncl-talk
mailing list