Problem writing masked array to netcdf

From: Daniel Gilmore <daniel.gilmore_at_nyahnyahspammersnyahnyah>
Date: Fri Mar 23 2012 - 08:06:42 MDT

Good morning.

(I originally wrote this and it ended up mixed in with another thread, so
I'm breaking it out into its own message. Sorry about the mix up.)

I'm having an issue writing masked data to a netcdf file. I've read this
section <http://www.pyngl.ucar.edu/bugs.shtml#get_assign_value> and applied
the work-around to my code. The code to read and write the data looks like
this:

    v = self.grib2fh.variables[grib2var]
    mv = v[:].data
    self.ncfh.variables[cdfvar].assign_value(mv)

...where grib2var is the grib2 variable name and cdfvar the corresponding
cf-compliant variable name.

When I read the value from the grib2 file, the data retrieved appears
correct, but when I write to and then retrieve the data from the netcdf
file, the data is all fill values and none of the data looks like it was
written. I'm including the arrays for both below.

Any thoughts?

--------------------------------------------------------------

(Pdb) self.grib2fh.variables[grib2var][:].data[0][186]
array([ 1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
          - - - repeated missing value data omitted for bevity - - -
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 2.84769989e+02,
         2.84540009e+02, 2.84299988e+02, 2.89919983e+02,
         2.90049988e+02, 2.90209991e+02, 2.90389984e+02,
         2.90579987e+02, 2.90769989e+02, 2.92559998e+02,
         2.92540009e+02, 2.92479980e+02, 2.91359985e+02,
         2.91429993e+02, 2.91440002e+02, 2.91399994e+02,
         2.91279999e+02, 2.87149994e+02, 2.86579987e+02,
         2.86059998e+02, 2.85669983e+02, 2.85399994e+02,
         2.85299988e+02, 2.85320007e+02, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20], dtype=float32)
(Pdb) self.ncfh.variables[cdfvar][:].data[0][186]
array([ 1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
          - - - repeated missing value data omitted for brevity - - -
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20, 1.00000002e+20,
         1.00000002e+20, 1.00000002e+20], dtype=float32)

-- 
-- 
Daniel Gilmore (AceInfo Solutions)
PGB/MDL/OST/NWS/NOAA
Office #: SSMC2-10357
Phone: 301.713.0224 x101
Cell: 703.232.9603

_______________________________________________
pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Fri Mar 23 08:06:51 2012

This archive was generated by hypermail 2.1.8 : Wed Apr 11 2012 - 14:41:42 MDT