missing values/fill values/masked arrays

When I plot the data with missing values (say the mask is

    > 1.0e20) it obviously screws up the range of the y limits.
    > I've seen other packages which understand a missing_value
    > attribute or a fill_value attribute and leave that
    > section of the curve blank. I was hoping for a behavior
    > similar to Matlab, when the data vector contains NaNs. I
    > see some mention of this in the matplotlib-devel list
    > (J. Whitaker's patch for pcolor) and I see a keyword
    > argument for contourf that seems to address this
    > situation. Is there anything for line plots?

Eric Firing contributes a patch for masked array support for line
plots which is in CVS. I haven't tried this with date plots but there
is every reason to believe it will "just work"

See examples/masked_demo.py in CVS.

Let me know!

JDH

John Hunter wrote:

"Derrick" == Derrick Snowden <Derrick.Snowden@...259...> writes:
           
   > When I plot the data with missing values (say the mask is
   > 1.0e20) it obviously screws up the range of the y limits.
   > I've seen other packages which understand a missing_value
   > attribute or a fill_value attribute and leave that
   > section of the curve blank. I was hoping for a behavior
   > similar to Matlab, when the data vector contains NaNs. I
   > see some mention of this in the matplotlib-devel list
   > (J. Whitaker's patch for pcolor) and I see a keyword
   > argument for contourf that seems to address this
   > situation. Is there anything for line plots?

Eric Firing contributes a patch for masked array support for line
plots which is in CVS. I haven't tried this with date plots but there
is every reason to believe it will "just work"

See examples/masked_demo.py in CVS.

Let me know!

JDH

Some progress on this front...thanks for all your suggestions. I tried to go with John's suggestion as it seems the most complete in the long run. I had some success, and some errors. First the success...

After downloading lines.py from cvs and reinstalling, I ran into an error trying to run the examples/masked_array.py. The error message differed depending on whether I used numarray or numeric. I won't include it here because I got past that point by downloading axes.py and reinstalling.

1. When I tried
python masked_array.py --numarray

I got the following error and no plot...

[snowden@...620... examples]$ python masked_demo.py --numarray
/usr/lib/python2.3/site-packages/matplotlib/__init__.py:636: UserWarning: Bad key "verbose.erro" on line 199 in /home/snowden/.matplotlibrc
  warnings.warn('Bad key "%s" on line %d in %s' % (key, cnt, fname))
loaded rc file /home/snowden/.matplotlibrc
matplotlib version 0.80
verbose.level helpful
interactive is False
platform is linux2
numerix numarray 1.3.1
font search path ['/usr/share/matplotlib']
loaded ttfcache file /home/snowden/.ttffont.cache
matplotlib data path /usr/share/matplotlib
backend GTKAgg version 2.2.0
Traceback (most recent call last):
  File "masked_demo.py", line 19, in ?
    lines = plot(x, y, 'r', x, ym1, 'g', x, ym2, 'bo')
  File "/usr/lib/python2.3/site-packages/matplotlib/pylab.py", line 1899, in plot
    ret = gca().plot(*args, **kwargs)
  File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 2491, in plot
    self.add_line(line)
  File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 732, in add_line
    self.update_datalim_numerix( xdata, ydata )
  File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 717, in update_datalim_numerix
    self.dataLim.update_numerix(x, y, not self.has_data())
ValueError: x and y must be equal length sequences

2. When I tried
python masked_array.py --Numeric

I get a plot, but while the plot is active an error message is periodically scrolling across the terminal screen. (I'm using GTKAgg)

Traceback (most recent call last):
  File "/usr/lib/python2.3/site-packages/matplotlib/backends/backend_gtk.py", line 163, in motion_notify_event
    FigureCanvasBase.motion_notify_event(self, x, y)
  File "/usr/lib/python2.3/site-packages/matplotlib/backend_bases.py", line 743, in motion_notify_event
    func(event)
  File "/usr/lib/python2.3/site-packages/matplotlib/backend_bases.py", line 997, in mouse_move
    s = event.inaxes.format_coord(event.xdata, event.ydata)
  File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 609, in format_coord
    xs = self.format_xdata(x)
  File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 591, in format_xdata
    func = self.xaxis.get_major_formatter().format_data
AttributeError: ScalarFormatter instance has no attribute 'format_data'

I suppose this is successful in that I get a plot to come on the screen but I doubt it's the solution you intended... Any ideas?

This brings me to my last question. Has anyone out there had any problems with the sourceforge cvs? I am unable to log in using the commands that are suggested on the sourceforege site. I am at a government site and am behind a firewall. Before I delve into cvs too deeply, I wondered if firewalls are known to not work well with cvs servers? I have had some difficulties with rsync servers in the past.

Thanks again,
Derrick