[ncl-talk] byte2flt

Laura Fowler laura at ucar.edu
Fri Jul 14 17:57:23 MDT 2023


Hello:

I am trying to read Nexrad Reflectivity data from a netCDF file in which
Reflectivity has a "byte" format and is defined as:

radar-data/20120611> ncdump -h 20120611T1900Z.nc

byte Reflectivity(Altitude, Latitude, Longitude) ;

Reflectivity:long_name = "Radar Reflectivity" ;

Reflectivity:units = "dBZ" ;

Reflectivity:scale_factor = 0.5f ;

Reflectivity:add_offset = -33.f ;

Reflectivity:missing_value = 0b ;

A printVarSummary of the dBZ_b variable that points to Reflectivity shows:

Variable: dBZ_b

Type: byte

Total Size: 10064208 bytes

            10064208 values

Number of Dimensions: 3

Dimensions and sizes: [Altitude | 24] x [Latitude | 539] x [Longitude | 778]

Coordinates:

            Altitude: [ 1..24]

            Latitude: [30.94..41.7]

            Longitude: [260.12..275.66]

Number Of Attributes: 6

  long_name : Radar Reflectivity

  units : dBZ

  scale_factor : 0.5

  add_offset : -33

  missing_value : 0

  _FillValue : 0

After reading the section on "Coercion of types", and for now ignoring
scale_factor and add_offset, I simply used the tofloat function to output
the max and min values of dBZ_b. I got:

(0) --- max dBZ_b = 127

(0) --- min dBZ_b = -128


Finally, using scale_factor and add_offset, I used the function byte2flt to
convert dBZ_b to a float and output the max and min value of dBZ_s, or:

dBZ_s = byte2flt(dBZ_b)

(0) --- max dBZ_s = 30.5

(0) --- min dBZ_s = -97

The maximum value of dBZ_s is much lower than I expected (the maximum value
of dBZ_s should actually be 58.5 dBZ, as derived by an IDL script used to
plot the nexrad Reflectivity data for a peer-review publication).


Can somebody help me figure out why I am getting values that are too low
relative to what I am expecting. I also tried to bypass the byte2flt
function and use the scale_factor and add_offset variables (x_float =
x_byte*scale + offset), but to no avail.

If you interested to help me out, my working directory on cheyenne is
/glade/u/home/laura/fromYunYao/radar-data/20120611;
the data file is 20120611T1900Z.nc; the ncl script is read.ncl; and the
main idl script is nexrad.pro.

Many thanks,
Laura

-- 
!-------------------------------------------------------------------------------------------------------------
Laura D. Fowler

Mesoscale and Microscale Meteorology Division (MMM)
National Center for Atmospheric Research
P.O. Box 3000, Boulder CO 80307-3000

e-mail: laura at ucar.edu
phone: 303-497-1628

!-------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20230714/80f437b3/attachment.htm>


More information about the ncl-talk mailing list