SF.net SVN: matplotlib:[6827] branches/v0_98_5_maint
Revision: 6827
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6827&view=rev
Author: mdboom
Date: 2009-01-26 14:32:42 + (Mon, 26 Jan 2009)
Log Message:
---
Make curves and NaNs play nice together
Modified Paths:
--
branches/v0_98_5_maint/CHANGELOG
branches/v0_98_5_maint/lib/matplotlib/patches.py
branches/v0_98_5_maint/lib/matplotlib/path.py
branches/v0_98_5_maint/src/agg_py_path_iterator.h
Modified: branches/v0_98_5_maint/CHANGELOG
===
--- branches/v0_98_5_maint/CHANGELOG2009-01-25 14:38:48 UTC (rev 6826)
+++ branches/v0_98_5_maint/CHANGELOG2009-01-26 14:32:42 UTC (rev 6827)
@@ -1,3 +1,5 @@
+2009-01-26 Make curves and NaNs play nice together - MGD
+
2009-01-19 Fix bug in quiver argument handling. - EF
2009-01-19 Fix bug in backend_gtk: don't delete nonexistent toolbar. - EF
Modified: branches/v0_98_5_maint/lib/matplotlib/patches.py
===
--- branches/v0_98_5_maint/lib/matplotlib/patches.py2009-01-25 14:38:48 UTC
(rev 6826)
+++ branches/v0_98_5_maint/lib/matplotlib/patches.py2009-01-26 14:32:42 UTC
(rev 6827)
@@ -298,8 +298,7 @@
tpath = transform.transform_path_non_affine(path)
affine = transform.get_affine()
-if not np.isnan(tpath.vertices).any():
-renderer.draw_path(gc, tpath, affine, rgbFace)
+renderer.draw_path(gc, tpath, affine, rgbFace)
#renderer.close_group('patch')
Modified: branches/v0_98_5_maint/lib/matplotlib/path.py
===
--- branches/v0_98_5_maint/lib/matplotlib/path.py 2009-01-25 14:38:48 UTC
(rev 6826)
+++ branches/v0_98_5_maint/lib/matplotlib/path.py 2009-01-26 14:32:42 UTC
(rev 6827)
@@ -214,7 +214,8 @@
if not isfinite(curr_vertices).all():
was_nan = True
elif was_nan:
-yield curr_vertices[-2:], MOVETO
+yield curr_vertices[:2], MOVETO
+yield curr_vertices, code
was_nan = False
else:
yield curr_vertices, code
Modified: branches/v0_98_5_maint/src/agg_py_path_iterator.h
===
--- branches/v0_98_5_maint/src/agg_py_path_iterator.h 2009-01-25 14:38:48 UTC
(rev 6826)
+++ branches/v0_98_5_maint/src/agg_py_path_iterator.h 2009-01-26 14:32:42 UTC
(rev 6827)
@@ -15,7 +15,10 @@
PyArrayObject* m_codes;
size_t m_iterator;
size_t m_total_vertices;
+size_t m_ok;
bool m_should_simplify;
+static const unsigned char num_extra_points_map[16];
+static const unsigned code_map[];
public:
PathIterator(const Py::Object& path_obj) :
@@ -41,6 +44,7 @@
throw Py::ValueError("Invalid codes array.");
if (PyArray_DIM(m_codes, 0) != PyArray_DIM(m_vertices, 0))
throw Py::ValueError("Codes array is wrong length");
+m_ok = 0;
}
m_should_simplify = should_simplify_obj.isTrue();
@@ -53,8 +57,6 @@
Py_XDECREF(m_codes);
}
-static const unsigned code_map[];
-
private:
inline void vertex(const unsigned idx, double* x, double* y)
{
@@ -82,20 +84,86 @@
if (m_iterator >= m_total_vertices) return agg::path_cmd_stop;
unsigned code = vertex_with_code(m_iterator++, x, y);
-if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y))
-{
-do
+if (!m_codes) {
+// This is the fast path for when we know we have no curves
+if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y))
{
-if (m_iterator < m_total_vertices)
+do
{
-vertex(m_iterator++, x, y);
+if (m_iterator < m_total_vertices)
+{
+vertex(m_iterator++, x, y);
+}
+else
+{
+return agg::path_cmd_stop;
+}
+} while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
+return agg::path_cmd_move_to;
+}
+}
+else
+{
+// This is the slow method for when there might be curves.
+
+/* If m_ok is 0, we look ahead to see if the next curve
+ segment has any NaNs. If it does, we skip the whole
+ thing and return a move_to to the first point of the
+ next curve segment. This move_to may include NaNs,
+ which is ok, since in that case, it will always be
+ followed by another non-NaN move_to before any other
+ curves are actually drawn. If the current curve
+
SF.net SVN: matplotlib:[6828] trunk/matplotlib
Revision: 6828
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6828&view=rev
Author: mdboom
Date: 2009-01-26 14:40:09 + (Mon, 26 Jan 2009)
Log Message:
---
Merged revisions 6827 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_98_5_maint
r6827 | mdboom | 2009-01-26 09:32:42 -0500 (Mon, 26 Jan 2009) | 2 lines
Make curves and NaNs play nice together
Modified Paths:
--
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/patches.py
trunk/matplotlib/lib/matplotlib/path.py
trunk/matplotlib/src/agg_py_path_iterator.h
Property Changed:
trunk/matplotlib/
trunk/matplotlib/doc/pyplots/README
trunk/matplotlib/doc/sphinxext/gen_gallery.py
trunk/matplotlib/doc/sphinxext/gen_rst.py
Property changes on: trunk/matplotlib
___
Modified: svnmerge-integrated
- /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6822
+ /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6827
Modified: svn:mergeinfo
- /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822
+ /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827
Modified: trunk/matplotlib/CHANGELOG
===
--- trunk/matplotlib/CHANGELOG 2009-01-26 14:32:42 UTC (rev 6827)
+++ trunk/matplotlib/CHANGELOG 2009-01-26 14:40:09 UTC (rev 6828)
@@ -1,3 +1,5 @@
+2009-01-26 Make curves and NaNs play nice together - MGD
+
2009-01-21 Changed the defaults of acorr and xcorr to use
usevlines=True, maxlags=10 and normed=True since these are
the best defaults
Property changes on: trunk/matplotlib/doc/pyplots/README
___
Modified: svn:mergeinfo
-
/branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822
+
/branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827
Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py
___
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822
+ /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827
Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py
___
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822
+ /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===
--- trunk/matplotlib/lib/matplotlib/patches.py 2009-01-26 14:32:42 UTC (rev
6827)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2009-01-26 14:40:09 UTC (rev
6828)
@@ -299,8 +299,7 @@
tpath = transform.transform_path_non_affine(path)
affine = transform.get_affine()
-if not np.isnan(tpath.vertices).any():
-renderer.draw_path(gc, tpath, affine, rgbFace)
+renderer.draw_path(gc, tpath, affine, rgbFace)
renderer.close_group('patch')
Modified: trunk/matplotlib/lib/matplotlib/path.py
===
--- trunk/matplotlib/lib/matplotlib/path.py 2009-01-26 14:32:42 UTC (rev
6827)
+++ trunk/matplotlib/lib/matplotlib/path.py 2009-01-26 14:40:09 UTC (rev
6828)
@@ -213,7 +213,8 @@
if not isfinite(curr_vertices).all():
was_nan = True
elif was_nan:
-yield curr_vertices[-2:], MOVETO
+yield curr_vertices[:2], MOVETO
+yield curr_vertices, code
was_nan = False
else:
yield curr_vertices, code
SF.net SVN: matplotlib:[6829] trunk/matplotlib
Revision: 6829
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6829&view=rev
Author: leejjoon
Date: 2009-01-26 16:39:14 + (Mon, 26 Jan 2009)
Log Message:
---
Improved tight bbox option of the savefig
Modified Paths:
--
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/figure.py
Modified: trunk/matplotlib/CHANGELOG
===
--- trunk/matplotlib/CHANGELOG 2009-01-26 14:40:09 UTC (rev 6828)
+++ trunk/matplotlib/CHANGELOG 2009-01-26 16:39:14 UTC (rev 6829)
@@ -1,3 +1,5 @@
+2009-01-26 Improved tight bbox option of the savefig. - JJL
+
2009-01-26 Make curves and NaNs play nice together - MGD
2009-01-21 Changed the defaults of acorr and xcorr to use
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-01-26 14:40:09 UTC (rev
6828)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-01-26 16:39:14 UTC (rev
6829)
@@ -7377,6 +7377,40 @@
integer=True))
return im
+
+def get_tightbbox(self, renderer):
+"""
+return the tight bounding box of the axes.
+The dimension of the Bbox in canvas coordinate.
+"""
+
+artists = []
+bb = []
+
+artists.append(self)
+
+if self.title.get_visible():
+artists.append(self.title)
+
+if self.xaxis.get_visible():
+artists.append(self.xaxis.label)
+bbx1, bbx2 = self.xaxis.get_ticklabel_extents(renderer)
+bb.extend([bbx1, bbx2])
+if self.yaxis.get_visible():
+artists.append(self.yaxis.label)
+bby1, bby2 = self.yaxis.get_ticklabel_extents(renderer)
+bb.extend([bby1, bby2])
+
+
+bb.extend([c.get_window_extent(renderer) for c in artists])
+
+_bbox = mtransforms.Bbox.union([b for b in bb if b.width!=0 or
b.height!=0])
+
+return _bbox
+
+
+
+
class SubplotBase:
"""
Base class for subplots, which are :class:`Axes` instances with
@@ -7514,6 +7548,8 @@
for label in self.get_yticklabels():
label.set_visible(firstcol)
+
+
_subplot_classes = {}
def subplot_class_factory(axes_class=None):
# This makes a new class that inherits from SubclassBase and the
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===
--- trunk/matplotlib/lib/matplotlib/backend_bases.py2009-01-26 14:40:09 UTC
(rev 6828)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py2009-01-26 16:39:14 UTC
(rev 6829)
@@ -1479,7 +1479,25 @@
origBboxInches = fig.bbox_inches
_boxout = fig.transFigure._boxout
+asp_list = []
+locator_list = []
+for ax in fig.axes:
+pos = ax.get_position(original=False).frozen()
+locator_list.append(ax.get_axes_locator())
+asp_list.append(ax.get_aspect())
+
+def _l(a, r, pos=pos): return pos
+ax.set_axes_locator(_l)
+ax.set_aspect("auto")
+
+
+
def restore_bbox():
+
+for ax, asp, loc in zip(fig.axes, asp_list, locator_list):
+ax.set_aspect(asp)
+ax.set_axes_locator(loc)
+
fig.bbox = origBbox
fig.bbox_inches = origBboxInches
fig.transFigure._boxout = _boxout
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===
--- trunk/matplotlib/lib/matplotlib/figure.py 2009-01-26 14:40:09 UTC (rev
6828)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2009-01-26 16:39:14 UTC (rev
6829)
@@ -,23 +,11 @@
ticklabels. Needs improvement.
"""
-artists = []
bb = []
for ax in self.axes:
+if ax.get_visible():
+bb.append(ax.get_tightbbox(renderer))
-artists.append(ax.xaxis.label)
-artists.append(ax.yaxis.label)
-artists.append(ax.title)
-artists.append(ax)
-
-bbx1, bbx2 = ax.xaxis.get_ticklabel_extents(renderer)
-bby1, bby2 = ax.yaxis.get_ticklabel_extents(renderer)
-bb.extend([bbx1, bbx2, bby1, bby2])
-
-
-bb.extend([c.get_window_extent(renderer) for c in artists \
- if c.get_visible()])
-
_bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0])
bbox_inches = TransformedBbox(_bbox,
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
--
This SF.net email is sponsored by:
SourcForge
SF.net SVN: matplotlib:[6830] trunk/toolkits/basemap/lib/mpl_toolkits/ basemap
Revision: 6830
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6830&view=rev
Author: jswhit
Date: 2009-01-26 19:48:04 + (Mon, 26 Jan 2009)
Log Message:
---
update netcdftime to version 0.7, add date2index function.
Modified Paths:
--
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26
16:39:14 UTC (rev 6829)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26
19:48:04 UTC (rev 6830)
@@ -17,6 +17,8 @@
:func:`num2date`: convert from a numeric time value to a datetime object.
:func:`date2num`: convert from a datetime object to a numeric time value.
+
+:func:`date2index`: compute a time variable index corresponding to a date.
"""
from matplotlib import __version__ as _matplotlib_version
from matplotlib.cbook import is_scalar, dedent
@@ -3941,6 +3943,42 @@
cdftime = netcdftime.utime(units,calendar=calendar)
return cdftime.date2num(dates)
+def date2index(dates, nctime, calendar=None):
+"""
+Return indices of a netCDF time variable corresponding to the given dates.
+
+.. tabularcolumns:: |l|L|
+
+==
+ArgumentsDescription
+==
+datesA datetime object or a sequence of datetime objects.
+ The datetime objects should not include a
+ time-zone offset.
+nctime A netCDF time variable object. The nctime object
+ must have a ``units`` attribute.
+==
+
+.. tabularcolumns:: |l|L|
+
+==
+Keywords Description
+==
+calendar describes the calendar used in the time
+ calculations. All the values currently defined in
+ the CF metadata convention
+ (http://cf-pcmdi.llnl.gov/documents/cf-conventions/)
+ are supported.
+ Valid calendars ``standard``, ``gregorian``,
+ ``proleptic_gregorian``, ``noleap``, ``365_day``,
+ ``julian``, ``all_leap``, ``366_day``.
+ Default is ``proleptic_gregorian``.
+==
+
+Returns an index or a sequence of indices.
+"""
+return netcdftime.date2index(dates, nctime, calendar=None)
+
def maskoceans(lonsin,latsin,datain,inlands=False):
"""
mask data (``datain``), defined on a grid with latitudes ``latsin``
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py
===
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py
2009-01-26 16:39:14 UTC (rev 6829)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py
2009-01-26 19:48:04 UTC (rev 6830)
@@ -1,14 +1,13 @@
"""
Performs conversions of netCDF time coordinate data to/from datetime objects.
"""
-import math, re, time
-import numpy as np
+import math, numpy, re, time
from datetime import datetime as real_datetime
_units = ['days','hours','minutes','seconds','day','hour','minute','second']
_calendars =
['standard','gregorian','proleptic_gregorian','noleap','julian','all_leap','365_day','366_day','360_day']
-__version__ = '0.6'
+__version__ = '0.7'
class datetime:
"""
@@ -467,8 +466,8 @@
The B{C{calendar}} keyword describes the calendar used in the time
calculations.
All the values currently defined in the U{CF metadata convention
-} are
-accepted. The default is C{'standard'}, which corresponds to the mixed
+}
+are accepted. The default is C{'standard'}, which corresponds to the mixed
Gregorian/Julian calendar used by the C{udunits library}. Valid calendars
are:
@@ -534,8 +533,7 @@
C{'standard'} or C{'gregorian'} calendars. An exception will be raised if you
pass
a 'datetime-like' object in that range to the C{L{date2num}} class method.
-Words of Wisdom from the British MetOffice concerning reference dates
-U{http://www.metoffice.com/research/hadleycentre/models/GDT/ch26.html}:
+Words of Wisdom from the British MetOffice concerning reference dates:
"udunits implements the mixed Gregorian/Julian calendar system, as
followed in Engl
SF.net SVN: matplotlib:[6831] trunk/toolkits/basemap/examples/plotsst.py
Revision: 6831
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6831&view=rev
Author: jswhit
Date: 2009-01-26 19:48:47 + (Mon, 26 Jan 2009)
Log Message:
---
update URL, use new date2index function.
Modified Paths:
--
trunk/toolkits/basemap/examples/plotsst.py
Modified: trunk/toolkits/basemap/examples/plotsst.py
===
--- trunk/toolkits/basemap/examples/plotsst.py 2009-01-26 19:48:04 UTC (rev
6830)
+++ trunk/toolkits/basemap/examples/plotsst.py 2009-01-26 19:48:47 UTC (rev
6831)
@@ -1,26 +1,30 @@
-from mpl_toolkits.basemap import Basemap, NetCDFFile
+from mpl_toolkits.basemap import Basemap, NetCDFFile, date2index, num2date
import numpy as np
import matplotlib.pyplot as plt
-import sys
+import sys, datetime
# read in sea-surface temperature and ice data
# can be a local file, a URL for a remote opendap dataset,
-# or (if PyNIO is installed) a GRIB or HDF file.
if len(sys.argv) == 1:
date = '20071215'
else:
date = sys.argv[1]
-if date[0:4] > '2005':
-ncfile =
NetCDFFile('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst/'+date[0:4]+'/AVHRR/sst4-navy-eot.'+date+'.nc')
-else:
-ncfile =
NetCDFFile('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst/'+date[0:4]+'/AVHRR/sst4-path-eot.'+date+'.nc')
+# convert datestring to datetime object.
+date = datetime.datetime(int(date[0:4]),int(date[4:6]),int(date[6:8]))
+print date
+# open dataset.
+dataset =
NetCDFFile('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst/totalAagg')
+# find index of desired time.
+time = dataset.variables['time']
+nt = date2index(date, time)
+print num2date(time[nt],time.units)
# read sst. Will automatically create a masked array using
# missing_value variable attribute.
-sst = ncfile.variables['sst'][:]
+sst = dataset.variables['sst'][nt]
# read ice.
-ice = ncfile.variables['ice'][:]
+ice = dataset.variables['ice'][nt]
# read lats and lons (representing centers of grid boxes).
-lats = ncfile.variables['lat'][:]
-lons = ncfile.variables['lon'][:]
+lats = dataset.variables['lat'][:]
+lons = dataset.variables['lon'][:]
# shift lats, lons so values represent edges of grid boxes
# (as pcolor expects).
delon = lons[1]-lons[0]
@@ -34,7 +38,6 @@
# create Basemap instance for mollweide projection.
# coastlines not used, so resolution set to None to skip
# continent processing (this speeds things up a bit)
-#m = Basemap(projection='ortho',lon_0=-110,lat_0=20,resolution=None)
m = Basemap(projection='moll',lon_0=lons.mean(),lat_0=0,resolution=None)
# compute map projection coordinates of grid.
x, y = m(*np.meshgrid(lons, lats))
@@ -42,7 +45,7 @@
# color background of map projection region.
# missing values over land will show up this color.
m.drawmapboundary(fill_color='0.3')
-# plot ice, then with pcolor
+# plot sst, then ice with pcolor
im1 = m.pcolor(x,y,sst,shading='flat',cmap=plt.cm.jet)
im2 = m.pcolor(x,y,ice,shading='flat',cmap=plt.cm.gist_gray)
# draw parallels and meridians, but don't bother labelling them.
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[6832] trunk/toolkits/basemap/examples/fcstmaps.py
Revision: 6832
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6832&view=rev
Author: jswhit
Date: 2009-01-26 19:51:34 + (Mon, 26 Jan 2009)
Log Message:
---
update URL
Modified Paths:
--
trunk/toolkits/basemap/examples/fcstmaps.py
Modified: trunk/toolkits/basemap/examples/fcstmaps.py
===
--- trunk/toolkits/basemap/examples/fcstmaps.py 2009-01-26 19:48:47 UTC (rev
6831)
+++ trunk/toolkits/basemap/examples/fcstmaps.py 2009-01-26 19:51:34 UTC (rev
6832)
@@ -15,7 +15,7 @@
MMDD = datetime.datetime.today().strftime('%Y%m%d')
# set OpenDAP server URL.
-URLbase="http://nomad3.ncep.noaa.gov:9090/dods/mrf/mrf";
+URLbase="http://nomad1.ncep.noaa.gov:9090/dods/mrf/mrf";
URL=URLbase+MMDD+'/mrf'+MMDD
print URL+'\n'
try:
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[6833] trunk/toolkits/basemap
Revision: 6833 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6833&view=rev Author: jswhit Date: 2009-01-26 20:01:58 + (Mon, 26 Jan 2009) Log Message: --- fix URL in fcstmaps.py example, update Changelog. Modified Paths: -- trunk/toolkits/basemap/Changelog trunk/toolkits/basemap/examples/pnganim.py Modified: trunk/toolkits/basemap/Changelog === --- trunk/toolkits/basemap/Changelog2009-01-26 19:51:34 UTC (rev 6832) +++ trunk/toolkits/basemap/Changelog2009-01-26 20:01:58 UTC (rev 6833) @@ -1,4 +1,5 @@ version 0.99.4 (not yet released) + * added date2index function. * added 'maskoceans' function. * update pupynere to version 1.0.8 (supports writing large files). * added more informative error message in readshapefile when Modified: trunk/toolkits/basemap/examples/pnganim.py === --- trunk/toolkits/basemap/examples/pnganim.py 2009-01-26 19:51:34 UTC (rev 6832) +++ trunk/toolkits/basemap/examples/pnganim.py 2009-01-26 20:01:58 UTC (rev 6833) @@ -20,24 +20,15 @@ raise ValueError,'dates must be in same year' # set OpenDAP server URL. -URLbase="http://nomad3.ncep.noaa.gov:9090/dods/reanalyses/reanalysis-2/6hr/pgb/"; -URL=URLbase+'pres' -URLu=URLbase+'wind' -URLv=URLbase+'wind' +URL="http://nomad1.ncep.noaa.gov:9090/dods/reanalyses/reanalysis-2/6hr/pgb/pgb"; print URL -print URLu -print URLv try: data = NetCDFFile(URL) -datau = NetCDFFile(URLu) -datav = NetCDFFile(URLv) except: raise IOError, 'opendap server not providing the requested data' # read lats,lons,times. print data.variables.keys() -print datau.variables.keys() -print datav.variables.keys() latitudes = data.variables['lat'][:] longitudes = data.variables['lon'][:].tolist() times = data.variables['time'] @@ -55,8 +46,8 @@ raise ValueError,'date2 must be greater than date1' # get sea level pressure and 10-m wind data. slpdata = data.variables['presmsl'] -udata = datau.variables['ugrdprs'] -vdata = datau.variables['vgrdprs'] +udata = data.variables['ugrdprs'] +vdata = data.variables['vgrdprs'] # mult slp by 0.01 to put in units of millibars. slpin = 0.01*slpdata[ntime1:ntime2+1,:,:] uin = udata[ntime1:ntime2+1,0,:,:] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[6834] trunk/toolkits/basemap/examples
Revision: 6834
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6834&view=rev
Author: jswhit
Date: 2009-01-26 20:27:17 + (Mon, 26 Jan 2009)
Log Message:
---
specify calendar
Modified Paths:
--
trunk/toolkits/basemap/examples/plotsst.py
trunk/toolkits/basemap/examples/pnganim.py
Modified: trunk/toolkits/basemap/examples/plotsst.py
===
--- trunk/toolkits/basemap/examples/plotsst.py 2009-01-26 20:01:58 UTC (rev
6833)
+++ trunk/toolkits/basemap/examples/plotsst.py 2009-01-26 20:27:17 UTC (rev
6834)
@@ -15,8 +15,8 @@
dataset =
NetCDFFile('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst/totalAagg')
# find index of desired time.
time = dataset.variables['time']
-nt = date2index(date, time)
-print num2date(time[nt],time.units)
+nt = date2index(date, time, calendar='standard')
+print num2date(time[nt],time.units, calendar='standard')
# read sst. Will automatically create a masked array using
# missing_value variable attribute.
sst = dataset.variables['sst'][nt]
Modified: trunk/toolkits/basemap/examples/pnganim.py
===
--- trunk/toolkits/basemap/examples/pnganim.py 2009-01-26 20:01:58 UTC (rev
6833)
+++ trunk/toolkits/basemap/examples/pnganim.py 2009-01-26 20:27:17 UTC (rev
6834)
@@ -9,15 +9,13 @@
import matplotlib.mlab as mlab
import numpy.ma as ma
import datetime, sys, time, subprocess
-from mpl_toolkits.basemap import Basemap, shiftgrid, NetCDFFile, num2date
+from mpl_toolkits.basemap import Basemap, shiftgrid, NetCDFFile, date2index,
num2date
# times for March 1993 'storm of the century'
-MMDDHH1 = '1993031000'
-MMDDHH2 = '1993031700'
+date1 = datetime.datetime(1993,3,10,0)
+date2 = datetime.datetime(1993,3,17,0)
+print date1, date2
- = MMDDHH1[0:4]
-if != MMDDHH2[0:4]:
-raise ValueError,'dates must be in same year'
# set OpenDAP server URL.
URL="http://nomad1.ncep.noaa.gov:9090/dods/reanalyses/reanalysis-2/6hr/pgb/pgb";
@@ -32,18 +30,10 @@
latitudes = data.variables['lat'][:]
longitudes = data.variables['lon'][:].tolist()
times = data.variables['time']
-# convert numeric time values to datetime objects.
-fdates = num2date(times[:],units=times.units,calendar='standard')
-# put times in MMDDHH format.
-dates = [fdate.strftime('%Y%m%d%H') for fdate in fdates]
-if MMDDHH1 not in dates or MMDDHH2 not in dates:
-raise ValueError, 'date1 or date2 not a valid date (must be in form
MMDDHH, where HH is 00,06,12 or 18)'
-# find indices bounding desired times.
-ntime1 = dates.index(MMDDHH1)
-ntime2 = dates.index(MMDDHH2)
+ntime1 = date2index(date1,times,calendar='standard')
+ntime2 = date2index(date2,times,calendar='standard')
print 'ntime1,ntime2:',ntime1,ntime2
-if ntime1 >= ntime2:
-raise ValueError,'date2 must be greater than date1'
+print num2date(times[ntime1],times.units,calendar='standard'),
num2date(times[ntime2],times.units,calendar='standard')
# get sea level pressure and 10-m wind data.
slpdata = data.variables['presmsl']
udata = data.variables['ugrdprs']
@@ -52,7 +42,7 @@
slpin = 0.01*slpdata[ntime1:ntime2+1,:,:]
uin = udata[ntime1:ntime2+1,0,:,:]
vin = vdata[ntime1:ntime2+1,0,:,:]
-datelabels = dates[ntime1:ntime2+1]
+dates = num2date(times[ntime1:ntime2+1], times.units, calendar='standard')
# add cyclic points
slp = np.zeros((slpin.shape[0],slpin.shape[1],slpin.shape[2]+1),np.float64)
slp[:,:,0:-1] = slpin; slp[:,:,-1] = slpin[:,:,0]
@@ -68,13 +58,12 @@
print uin.min(), uin.max()
print vin.min(), vin.max()
print 'dates'
-print datelabels
+print dates
# make orthographic basemaplt.
m = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)
plt.ion() # interactive mode on.
uin = udata[ntime1:ntime2+1,0,:,:]
vin = vdata[ntime1:ntime2+1,0,:,:]
-datelabels = dates[ntime1:ntime2+1]
# make orthographic basemaplt.
m = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)
plt.ion() # interactive mode on.
@@ -94,7 +83,7 @@
l, b, w, h = pos.bounds
# loop over times, make contour plots, draw coastlines,
# parallels, meridians and title.
-for nt,date in enumerate(datelabels[1:]):
+for nt,date in enumerate(dates):
CS =
m.contour(x,y,slp[nt,:,:],clevs,linewidths=0.5,colors='k',animated=True)
CS = m.contourf(x,y,slp[nt,:,:],clevs,cmap=plt.cm.RdBu_r,animated=True)
# plot wind vectors on lat/lon grid.
@@ -117,7 +106,7 @@
m.drawcoastlines(linewidth=1.5)
m.drawparallels(parallels)
m.drawmeridians(meridians)
-plt.title('SLP and Wind Vectors '+date)
+plt.title('SLP and Wind Vectors '+str(date))
if nt == 0: # plot colorbar on a separate axes (only for first frame)
cax = plt.axes([l+w-0.05, b, 0.03, h]) # setup colorbar axes
fig.colorbar(CS,drawedges=True, cax=cax) # draw colorbar
This was sent by the SourceForge.net collaborative development platf
SF.net SVN: matplotlib:[6835] trunk/toolkits/basemap/lib/mpl_toolkits/ basemap/__init__.py
Revision: 6835 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6835&view=rev Author: jswhit Date: 2009-01-26 20:27:50 + (Mon, 26 Jan 2009) Log Message: --- make default calendar proleptic_gregorian for date2index (to be consistent with num2date and date2num) Modified Paths: -- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py === --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 20:27:17 UTC (rev 6834) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 20:27:50 UTC (rev 6835) @@ -3943,7 +3943,7 @@ cdftime = netcdftime.utime(units,calendar=calendar) return cdftime.date2num(dates) -def date2index(dates, nctime, calendar=None): +def date2index(dates, nctime, calendar='proleptic_gregorian'): """ Return indices of a netCDF time variable corresponding to the given dates. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[6836] trunk/toolkits/basemap/lib/mpl_toolkits/ basemap/netcdftime.py
Revision: 6836 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6836&view=rev Author: jswhit Date: 2009-01-26 22:49:01 + (Mon, 26 Jan 2009) Log Message: --- bugfixes for date2index Modified Paths: -- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py === --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py 2009-01-26 20:27:50 UTC (rev 6835) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py 2009-01-26 22:49:01 UTC (rev 6836) @@ -7,7 +7,7 @@ _units = ['days','hours','minutes','seconds','day','hour','minute','second'] _calendars = ['standard','gregorian','proleptic_gregorian','noleap','julian','all_leap','365_day','366_day','360_day'] -__version__ = '0.7' +__version__ = '0.7.1' class datetime: """ @@ -975,22 +975,29 @@ index[:] = (num-t0)/dt # convert numpy scalars or single element arrays to python ints. -if not len(index.shape) or index.shape == (1,): -index = index.item() +index = _toscalar(index) # Checking that the index really corresponds to the given date. _check_index(index, dates, nctime, calendar) except AssertionError: + +index = numpy.empty(numpy.alen(dates), int) + # If check fails, use brute force method. index[:] = numpy.digitize(num, nctime[:]) - 1 # convert numpy scalars or single element arrays to python ints. -if not len(index.shape) or index.shape == (1,): -index = index.item() +index = _toscalar(index) # Perform check again. _check_index(index, dates, nctime, calendar) return index + +def _toscalar(a): +if a.shape in [(),(1,)]: +return a.item() +else: +return a This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[6837] trunk/toolkits/basemap/lib/mpl_toolkits/ basemap/__init__.py
Revision: 6837 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6837&view=rev Author: jswhit Date: 2009-01-26 22:54:38 + (Mon, 26 Jan 2009) Log Message: --- update date2index docstring. Modified Paths: -- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py === --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 22:49:01 UTC (rev 6836) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 22:54:38 UTC (rev 6837) @@ -3973,6 +3973,9 @@ ``proleptic_gregorian``, ``noleap``, ``365_day``, ``julian``, ``all_leap``, ``366_day``. Default is ``proleptic_gregorian``. + If ``calendar=None``, will use ``calendar`` attribute + of ``nctime`` object, and if that attribute does + not exist calendar is set to ``standard``. == Returns an index or a sequence of indices. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[6838] trunk/toolkits/basemap/Changelog
Revision: 6838 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6838&view=rev Author: jswhit Date: 2009-01-26 22:56:11 + (Mon, 26 Jan 2009) Log Message: --- updated netcdftime to 0.7.1 Modified Paths: -- trunk/toolkits/basemap/Changelog Modified: trunk/toolkits/basemap/Changelog === --- trunk/toolkits/basemap/Changelog2009-01-26 22:54:38 UTC (rev 6837) +++ trunk/toolkits/basemap/Changelog2009-01-26 22:56:11 UTC (rev 6838) @@ -1,6 +1,6 @@ version 0.99.4 (not yet released) - * added date2index function. - * added 'maskoceans' function. + * added date2index function, updated netcdftime to 0.7.1. + * added maskoceans function. * update pupynere to version 1.0.8 (supports writing large files). * added more informative error message in readshapefile when one of the shapefile components can't be found. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[6839] trunk/toolkits/basemap/lib/mpl_toolkits/ basemap/__init__.py
Revision: 6839 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6839&view=rev Author: jswhit Date: 2009-01-26 23:02:46 + (Mon, 26 Jan 2009) Log Message: --- remove some extra whitespace Modified Paths: -- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py === --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 22:56:11 UTC (rev 6838) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 23:02:46 UTC (rev 6839) @@ -3582,7 +3582,7 @@ .. tabularcolumns:: |l|L| == -Arguments Description +ArgumentsDescription == datain a rank-2 array with 1st dimension corresponding to y, 2nd dimension x. @@ -3595,7 +3595,7 @@ .. tabularcolumns:: |l|L| == -Keywords Description +Keywords Description == checkbounds If True, values of xout and yout are checked to see that they lie within the range specified by xin @@ -3714,7 +3714,7 @@ .. tabularcolumns:: |l|L| == -Arguments Description +ArgumentsDescription == lon0 starting longitude for shifted grid (ending longitude if start=False). lon0 must be on @@ -3726,7 +3726,7 @@ .. tabularcolumns:: |l|L| == -Keywords Description +Keywords Description == startif True, lon0 represents the starting longitude of the new grid. if False, lon0 is the ending @@ -3858,7 +3858,7 @@ .. tabularcolumns:: |l|L| == -Keywords Description +Keywords Description == unitsa string of the form ' since ' describing the units and @@ -3917,7 +3917,7 @@ .. tabularcolumns:: |l|L| == -Keywords Description +Keywords Description == unitsa string of the form ' since ' describing the units and @@ -3962,7 +3962,7 @@ .. tabularcolumns:: |l|L| == -Keywords Description +Keywords Description == calendar describes the calendar used in the time calculations. All the values currently defined in @@ -3990,7 +3990,7 @@ .. tabularcolumns:: |l|L| == -Arguments Description +ArgumentsDescription == lonsin, latsin rank-2 arrays containing longitudes and latitudes of grid. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
