You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(12) |
Sep
(12) |
Oct
(56) |
Nov
(65) |
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(59) |
Feb
(78) |
Mar
(153) |
Apr
(205) |
May
(184) |
Jun
(123) |
Jul
(171) |
Aug
(156) |
Sep
(190) |
Oct
(120) |
Nov
(154) |
Dec
(223) |
2005 |
Jan
(184) |
Feb
(267) |
Mar
(214) |
Apr
(286) |
May
(320) |
Jun
(299) |
Jul
(348) |
Aug
(283) |
Sep
(355) |
Oct
(293) |
Nov
(232) |
Dec
(203) |
2006 |
Jan
(352) |
Feb
(358) |
Mar
(403) |
Apr
(313) |
May
(165) |
Jun
(281) |
Jul
(316) |
Aug
(228) |
Sep
(279) |
Oct
(243) |
Nov
(315) |
Dec
(345) |
2007 |
Jan
(260) |
Feb
(323) |
Mar
(340) |
Apr
(319) |
May
(290) |
Jun
(296) |
Jul
(221) |
Aug
(292) |
Sep
(242) |
Oct
(248) |
Nov
(242) |
Dec
(332) |
2008 |
Jan
(312) |
Feb
(359) |
Mar
(454) |
Apr
(287) |
May
(340) |
Jun
(450) |
Jul
(403) |
Aug
(324) |
Sep
(349) |
Oct
(385) |
Nov
(363) |
Dec
(437) |
2009 |
Jan
(500) |
Feb
(301) |
Mar
(409) |
Apr
(486) |
May
(545) |
Jun
(391) |
Jul
(518) |
Aug
(497) |
Sep
(492) |
Oct
(429) |
Nov
(357) |
Dec
(310) |
2010 |
Jan
(371) |
Feb
(657) |
Mar
(519) |
Apr
(432) |
May
(312) |
Jun
(416) |
Jul
(477) |
Aug
(386) |
Sep
(419) |
Oct
(435) |
Nov
(320) |
Dec
(202) |
2011 |
Jan
(321) |
Feb
(413) |
Mar
(299) |
Apr
(215) |
May
(284) |
Jun
(203) |
Jul
(207) |
Aug
(314) |
Sep
(321) |
Oct
(259) |
Nov
(347) |
Dec
(209) |
2012 |
Jan
(322) |
Feb
(414) |
Mar
(377) |
Apr
(179) |
May
(173) |
Jun
(234) |
Jul
(295) |
Aug
(239) |
Sep
(276) |
Oct
(355) |
Nov
(144) |
Dec
(108) |
2013 |
Jan
(170) |
Feb
(89) |
Mar
(204) |
Apr
(133) |
May
(142) |
Jun
(89) |
Jul
(160) |
Aug
(180) |
Sep
(69) |
Oct
(136) |
Nov
(83) |
Dec
(32) |
2014 |
Jan
(71) |
Feb
(90) |
Mar
(161) |
Apr
(117) |
May
(78) |
Jun
(94) |
Jul
(60) |
Aug
(83) |
Sep
(102) |
Oct
(132) |
Nov
(154) |
Dec
(96) |
2015 |
Jan
(45) |
Feb
(138) |
Mar
(176) |
Apr
(132) |
May
(119) |
Jun
(124) |
Jul
(77) |
Aug
(31) |
Sep
(34) |
Oct
(22) |
Nov
(23) |
Dec
(9) |
2016 |
Jan
(26) |
Feb
(17) |
Mar
(10) |
Apr
(8) |
May
(4) |
Jun
(8) |
Jul
(6) |
Aug
(5) |
Sep
(9) |
Oct
(4) |
Nov
|
Dec
|
2017 |
Jan
(5) |
Feb
(7) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(3) |
Jul
(6) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
1
(16) |
2
(31) |
3
(17) |
4
(18) |
5
(7) |
6
(5) |
7
(16) |
8
(9) |
9
(19) |
10
(18) |
11
(17) |
12
(7) |
13
(6) |
14
(15) |
15
(16) |
16
(15) |
17
(19) |
18
(27) |
19
(10) |
20
(5) |
21
(5) |
22
(19) |
23
(7) |
24
(11) |
25
(19) |
26
(1) |
27
(36) |
28
(37) |
29
(28) |
30
(36) |
|
|
|
Arthur M. Greene wrote: > Thanks much. I am able to replicate your results using netcdf4. > > FYI, I don't believe the xml file is a CDAT creation; rather, it is > probably written using CMOR (http://www2-pcmdi.llnl.gov/cmor), which > was used to standardize the IPCC model output files, presumably so > they could be accessed by a variety of applications via OpenDAP. Hmmmm... > > At any rate, I can access the remote data object with netcdf4, but no > luck retrieving either data or a time index. > > In [94]: datobj = ncf(fname) > In [95]: timedata = datobj.variables['time'] > In [97]: taxvals = timedata[1070:1090] > In [99]: print taxvals > [ 32559.5 32590. 32620.5 32651. 32681.5 32712.5 32743. 32773.5 > 32804. 32834.5 32865.5 32895. 32924.5 32955. 32985.5 33016. > 33046.5 33077.5 33108. 33138.5] > In [100]: print > date2index(date0,timedata.units,timedata.calendar,select='nearest') Arthur: That's because the timedata variable has no attributes (no calendar or units), and the date2index function looks for these attributes. That's weird though, since that dataset is supposed to be CF compliant. I wonder if openDAP is not handling that xml file correctly. -Jeff > --------------------------------------------------------------------------- > > AttributeError Traceback (most recent call > last) > > /home/amg/work/nhmm/<ipython console> in <module>() > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so > in netCDF4.Variable.__getattr__ (netCDF4.c:13593)() > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so > in netCDF4._get_att (netCDF4.c:1806)() > > AttributeError: NetCDF: Attribute not found > > > In [96]: print datobj.variables['tas'].shape > (1680, 90, 144) > In [101]: testdat = datobj.variables['tas'][0,:,:] > --------------------------------------------------------------------------- > > RuntimeError Traceback (most recent call > last) > > /home/amg/work/nhmm/<ipython console> in <module>() > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so > in netCDF4.Variable.__getitem__ (netCDF4.c:14286)() > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so > in netCDF4.Variable._get (netCDF4.c:18945)() > > RuntimeError: NetCDF: Variable has no data in DAP request > > -------------------------- > > Well, at least the error messages are different... > > Thanks again for all the assistance. It would be useful to access the > IPCC output with OpenDap at some point. > > Best, > > Arthur > > > Jeff Whitaker wrote: >> Arthur M. Greene wrote: >>> Thanks much for the quick response. I updated both matplotlib and >>> basemap (now at 0.99.5) via svn and noticed the new netcdftime.py. >>> First, from within site-packages/mpl_toolkits/basemap, >>> >>> $ grep date2index *.py >>> __init__.py::func:`date2index`: compute a time variable index >>> corresponding to a date. >>> __init__.py:def date2index(dates, nctime, >>> calendar='proleptic_gregorian'): >>> __init__.py: return netcdftime.date2index(dates, nctime, >>> calendar=None) >>> netcdftime.py:def date2index(dates, nctime, calendar=None, >>> select='exact'): >>> netcdftime.py: date2index(dates, nctime, calendar=None, >>> select='exact') >>> >>> so there seems to be some disagreement between __init__.py and >>> netcdftime.py concerning the presence of the "select" argument. When I >>> call date2index with the "select" keyword arg I get >>> >>> In [24]: ix0 = >>> date2index(date0,timedata,timedata.calendar,select='nearest') >>> --------------------------------------------------------------------------- >>> >>> TypeError Traceback (most recent >>> call last) >>> >>> /home/amg/work/nhmm/<ipython console> in <module>() >>> >>> TypeError: date2index() got an unexpected keyword argument 'select' >> >> Arthur: I forgot to update the wrapper function in __init__.py - >> that's fixed now if you do an svn update. Concerning your other >> problems below, using your test case exposed a couple of other bugs, >> but it still doesn't work. The basic problem is that the date2index >> function was designed to work with netCDF4 variable objects >> (http://code.google.com/p/netcdf4-python), and the netcdf >> file/variable objects that are produced by pupynere/pydap (the pure >> python netcdf /dap reader included in basemap) don't quite behave the >> same way. Using netCDF4, I can get your gfdl_test.nc case to work with >> >> > cat testdate2index.py >> >> #from mpl_toolkits.basemap import date2index,num2date,NetCDFFile as ncf >> from netCDF4 import Dataset as ncf >> from netCDF4 import date2index, num2date >> from mpl_toolkits import basemap >> fname0 = 'http://esgcet.llnl.gov/dap/' >> fname1 =\ >> 'ipcc4/20c3m/gfdl_cm2_1/pcmdi.ipcc4.gfdl_cm2_1.20c3m.run1.atm.mo.xml' >> fname = fname0+fname1 >> #fname = 'gfdl_test.nc' >> print fname >> datobj = ncf(fname) >> print datobj.variables['tas'].shape >> timedata = datobj.variables['time'] >> from datetime import datetime as dt >> date0 = dt(1951,1,16,12,0,0) >> print num2date(timedata[:],timedata.units,calendar=timedata.calendar) >> print date0 >> nt0 = date2index(date0,timedata,select='nearest') >> print nt0 >> print \ >> timedata[nt0],num2date(timedata[nt0],timedata.units,calendar=timedata.calendar) >> >> >> > python testdate2index.py >> >> gfdl_test.nc >> (13, 31, 29) >> [1950年08月16日 12:00:00 1950年09月16日 00:00:00 1950年10月16日 12:00:00 >> 1950年11月16日 00:00:00 1950年12月16日 12:00:00 1951年01月16日 12:00:00 >> 1951年02月15日 00:00:00 1951年03月16日 12:00:00 1951年04月16日 00:00:00 >> 1951年05月16日 12:00:00 1951年06月16日 00:00:00 1951年07月16日 12:00:00 >> 1951年08月16日 12:00:00] >> 1951年01月16日 12:00:00 >> 5 >> [ 32865.5] [1951年01月16日 12:00:00] >> >> >> Your original example doesn't work because the URL is not an opendap >> server, it's some kind of CDAT xml file that presumably only CDAT >> understands. >> >> We will see if we can fix the date2index function included in basemap >> (if not I will remove it), but for now I recommend using >> netcdf4-python. It's really a much more robust and feature-rich >> solution for netcdf reading and writing. >> -Jeff >> >> >> >> >>> >>> ----------------------- >>> >>> This detail aside, I am still having difficulty with date2index, but >>> annoyingly, I seem to get different error messages with different >>> datasets. I'll illustrate two here, starting with the one I >>> initially posted about. (See note below regarding this data.) >>> >>> In [3]: from mpl_toolkits.basemap import >>> date2index,num2date,NetCDFFile as ncf >>> In [10]: from mpl_toolkits import basemap >>> In [11]: print basemap.__version__ >>> 0.99.5 >>> In [24]: fname0 = 'http://esgcet.llnl.gov/dap/' >>> In [25]: fname1 = >>> 'ipcc4/20c3m/gfdl_cm2_1/pcmdi.ipcc4.gfdl_cm2_1.20c3m.run1.atm.mo.xml' >>> In [26]: fname = fname0+fname1 >>> In [28]: datobj = ncf(fname) >>> In [33]: datobj.variables['tas'].shape >>> Out[33]: (1680, 90, 144) >>> In [34]: timedata = datobj.variables['time'] >>> In [35]: from datetime import datetime as dt >>> In [36]: date0 = dt(1951,1,16,12,0,0) >>> In [37]: print date0 >>> 1951年01月16日 12:00:00 >>> In [38]: nt0 = date2index(date0,timedata) >>> --------------------------------------------------------------------------- >>> >>> ClientError Traceback (most recent >>> call last) >>> >>> /home/amg/work/nhmm/<ipython console> in <module>() >>> >>> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc >>> in date2index(dates, nctime, calendar) >>> 3931 Returns an index or a sequence of indices. >>> 3932 """ >>> -> 3933 return netcdftime.date2index(dates, nctime, calendar=None) >>> 3934 >>> 3935 def maskoceans(lonsin,latsin,datain,inlands=False): >>> >>> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >>> in date2index(dates, nctime, calendar, select) >>> 1006 # If the times do not correspond, then it means that the >>> times >>> 1007 # are not increasing uniformly and we try the bisection >>> method. >>> -> 1008 if not _check_index(index, dates, nctime, calendar): >>> 1009 >>> 1010 # Use the bisection method. Assumes the dates are >>> ordered. >>> >>> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >>> in _check_index(indices, dates, nctime, calendar) >>> 959 return False >>> 960 >>> --> 961 t = nctime[indices] >>> 962 return numpy.all( num2date(t, nctime.units, calendar) == >>> dates) >>> 963 >>> >>> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdf.pyc >>> in __getitem__(self, index) >>> 65 >>> 66 def __getitem__(self, index): >>> ---> 67 datout = squeeze(self._var.__getitem__(index)) >>> 68 # automatically >>> 69 # - remove singleton dimensions >>> >>> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/dtypes.pyc >>> in __getitem__(self, key) >>> 409 def __getitem__(self, key): >>> 410 # Return data from the array. >>> --> 411 return self.data[key] >>> 412 >>> 413 def __setitem__(self, key, item): >>> >>> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/proxy.pyc >>> in __getitem__(self, index) >>> 112 >>> 113 # Fetch data. >>> --> 114 resp, data = openurl(url, self.cache, self.username, >>> self.password) >>> 115 >>> 116 # First lines are ASCII information that end with >>> 'Data:\n'. >>> >>> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/util/http.pyc >>> in openurl(url, cache, username, password) >>> 19 m = re.search('code = (?P<code>\d+);\s*message = >>> "(?P<msg>.*)"', data, re.DOTALL | re.MULTILINE) >>> 20 msg = 'Server error %(code)s: "%(msg)s"' % >>> m.groupdict() >>> ---> 21 raise ClientError(msg) >>> 22 >>> 23 return resp, data >>> >>> ClientError: 'Server error 0: "invalid literal for int(): [1113"' >>> >>> ----------------------------- >>> >>> Note that this is a different error than previously reported. Also, >>> the correct time index is still 1080: >>> >>> In [40]: taxvals = datobj.variables['time'][:] >>> >>> In [41]: num2date(taxvals[1080],timedata.units,timedata.calendar) >>> Out[41]: 1951年01月16日 12:00:00 >>> >>> ----------------------------- >>> >>> This dataset, generated by one of the IPCC models, is >>> password-protected, but could be a good target for decoding, since >>> it is typical of a large class of climate models, that generate a >>> lot of analytical activity. To get a password (they're free) one >>> must register. Info is here: >>> http://www-pcmdi.llnl.gov/ipcc/info_for_analysts.php. Follow "How to >>> access..." then "Register to download output." Once you get a userid >>> and password they can be inserted in the NetCDFFile call, voila. >>> Note that there is a new iteration of IPCC coming down the pike; new >>> model files to become widely available starting in 2010. >>> >>> ------------------------------ >>> >>> The underlying data is available via ftp. I fetched it and extracted >>> a small slab, which is available at >>> http://iri.columbia.edu/~amg/test/gfdl_test.nc. The CDAT package can >>> digest this file; first time step is plotted here: >>> http://iri.columbia.edu/~amg/test/gfdl_test_time0.png. The dates can >>> also be read by this package, and run from Aug 1950 to Aug 1951, >>> inclusive (13 mos). So the file does not seem to be garbage. >>> >>> In [16]: datobj = ncf('gfdl_test.nc') >>> In [17]: timedata = datobj.variables['time'] >>> In [18]: date0 = dt(1951,1,16,12,0,0) >>> In [19]: nt0 = date2index(date0,timedata) >>> --------------------------------------------------------------------------- >>> >>> TypeError Traceback (most recent >>> call last) >>> >>> /home/amg/work/nhmm/<ipython console> in <module>() >>> >>> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc >>> in date2index(dates, nctime, calendar) >>> 3931 Returns an index or a sequence of indices. >>> 3932 """ >>> -> 3933 return netcdftime.date2index(dates, nctime, calendar=None) >>> 3934 >>> 3935 def maskoceans(lonsin,latsin,datain,inlands=False): >>> >>> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >>> in date2index(dates, nctime, calendar, select) >>> 1011 import bisect >>> 1012 >>> -> 1013 index = numpy.array([bisect.bisect_left(nctime, n) >>> for n in num], int) >>> 1014 >>> 1015 nomatch = num2date(nctime[index], nctime.units) != >>> dates >>> >>> TypeError: object of type 'netcdf_variable' has no len() >>> >>> Investigating the time axis, >>> >>> In [20]: taxvals = timedata[:] >>> >>> In [21]: taxvals >>> Out[21]: array([ 32712.5, 32743. , 32773.5, 32804. , 32834.5, >>> 32865.5, 32895. , 32924.5, 32955. , 32985.5, 33016. , 33046.5, >>> 33077.5]) >>> >>> In [22]: num2date(taxvals,timedata.units,timedata.calendar) >>> Out[22]: array([1950年08月16日 12:00:00, 1950年09月16日 00:00:00, 1950年10月16日 >>> 12:00:00, >>> 1950年11月16日 00:00:00, 1950年12月16日 12:00:00, 1951年01月16日 12:00:00, >>> 1951年02月15日 00:00:00, 1951年03月16日 12:00:00, 1951年04月16日 00:00:00, >>> 1951年05月16日 12:00:00, 1951年06月16日 00:00:00, 1951年07月16日 12:00:00, >>> 1951年08月16日 12:00:00], dtype=object) >>> >>> Which agrees with what CDAT sees. >>> >>> ------------------------- >>> >>> I think this is enough for now. I also had problems opening data >>> files whose time units were like "months since xxxx-xx-xx," since >>> the "months" unit does not seem to be supported. ("years since..." >>> could also be useful in some cases.) But maybe one or two things at >>> a time is enough! >>> >>> Thanks for any assistance/advice! >>> >>> Best, >>> >>> Arthur >>> >>> >>> Jeff Whitaker wrote: >>>> David Huard wrote: >>>>> Arthur, >>>>> >>>>> I wrote the date2index function and I think what you are seeing is >>>>> a bug that I fixed a couple of months ago. By using the latest >>>>> version of netcdf4-python, not only should this bug disappear, but >>>>> you'll also find that date2index now supports different selection >>>>> methods: 'exact', 'before', 'after', 'nearest', that should help >>>>> with your use case. >>>>> >>>>> If this does not fix the problem you are seeing, I'd appreciate >>>>> having a copy of the file and code to reproduce the problem and >>>>> find a solution. >>>>> >>>>> HTH, >>>>> >>>>> David Huard >>>> >>>> Arthur: I've just updated basemap svn with David's latest version >>>> of date2index, so another option is to update basemap from svn. >>>> Or, even simpler, just drop the attached netcdftime.py file in >>>> lib/mpl_toolkits/basemap (replacing the old one) and run python >>>> setup.py install. >>>> >>>> -Jeff >>>>> >>>>> >>>>> >>>>> On Mon, Sep 7, 2009 at 9:27 AM, Arthur M. Greene >>>>> <am...@ir... <mailto:am...@ir...>> wrote: >>>>> >>>>> Hi All, >>>>> >>>>> The problem is not with fetching the data slice itself, but >>>>> finding the >>>>> correct indices to specify, particularly with the time >>>>> dimension. The >>>>> below examples refer to a remote dataset that I can open and >>>>> slice >>>>> using >>>>> indices, as in >>>>> >>>>> slice = remoteobj.variables['tas'][:120,20:40,30:50]. >>>>> >>>>> However, I have problems when trying to use the syntax in >>>>> plotsst.py or >>>>> pnganim.py (from the examples) to find time indices: >>>>> >>>>> In [107]: from datetime import datetime as dt >>>>> In [108]: date0 = dt(1951,1,1,0) >>>>> In [110]: print date0 >>>>> 1951年01月01日 00:00:00 >>>>> >>>>> In [125]: timedata = remoteobj.variables['time'] >>>>> In [126]: nt0 = date2index(date0,timedata) >>>>> >>>>> --------------------------------------------------------------------------- >>>>> >>>>> AssertionError Traceback (most recent >>>>> call last) >>>>> >>>>> /home/amg/work/nhmm/<ipython console> in <module>() >>>>> >>>>> >>>>> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc >>>>> >>>>> >>>>> in date2index(dates, nctime, calendar) >>>>> 3924 Returns an index or a sequence of indices. >>>>> 3925 """ >>>>> -> 3926 return netcdftime.date2index(dates, nctime, >>>>> calendar=None) >>>>> 3927 >>>>> 3928 def maskoceans(lonsin,latsin,datain,inlands=False): >>>>> >>>>> >>>>> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >>>>> >>>>> >>>>> in date2index(dates, nctime, calendar) >>>>> 986 >>>>> 987 # Perform check again. >>>>> --> 988 _check_index(index, dates, nctime, calendar) >>>>> 989 >>>>> 990 # convert numpy scalars or single element arrays >>>>> to python >>>>> ints. >>>>> >>>>> >>>>> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >>>>> >>>>> >>>>> in _check_index(indices, dates, nctime, calendar) >>>>> 941 for n,i in enumerate(indices): >>>>> 942 t[n] = nctime[i] >>>>> --> 943 assert numpy.all( num2date(t, nctime.units, calendar) >>>>> == dates) >>>>> 944 >>>>> 945 >>>>> >>>>> AssertionError: >>>>> >>>>> --------------------------------------------------------- >>>>> >>>>> It turns out that date0 corresponds best to index 1080: >>>>> >>>>> In [139]: remoteobj.variables['time'][1080] >>>>> Out[139]: 32865.5 >>>>> >>>>> In [141]: num2date(32865.5,timedata.units,timedata.calendar) >>>>> Out[141]: 1951年01月16日 12:00:00 >>>>> >>>>> This isn't the _exact_ date and time I had specified, but >>>>> >>>>> In [142]: date0 = dt(1951,01,16,12,00,00) >>>>> In [143]: print date0 >>>>> 1951年01月16日 12:00:00 >>>>> >>>>> In [144]: date2index(date0,timedata,timedata.calendar) >>>>> >>>>> produces the same AssertionError. Where is the problem? >>>>> >>>>> What I would _like_ to do is to issue a simple call using >>>>> coordinates >>>>> rather than the indices, of the form: >>>>> >>>>> slice = variable[date0:date1,[plev],lat0:lat1,lon0:lon1], >>>>> >>>>> or similar, preferably without writing a whole module just to >>>>> find the >>>>> correct indices. I need to fetch similar slices from a group of >>>>> models, >>>>> having time axes that may each be defined slightly differently -- >>>>> different calendars, time point set at a different day of the >>>>> month, >>>>> etc. (It's monthly data and I'm specifying only monthly >>>>> bounds, even >>>>> though the calendar may be defined as "days since 1860...") I >>>>> need to >>>>> automate the process so I get back the correct slab regardless. >>>>> >>>>> Suggestions appreciated! >>>>> >>>>> Thx, >>>>> >>>>> Arthur >>>>> >>>>> >>>>> *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* >>>>> Arthur M. Greene, Ph.D. >>>>> The International Research Institute for Climate and Society >>>>> (IRI) >>>>> The Earth Institute, Columbia University, Lamont Campus >>>>> >>>>> amg at iri dot columbia dot edu | http://iri.columbia.edu >>>>> *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> >>>>> Let Crystal Reports handle the reporting - Free Crystal Reports >>>>> 2008 30-Day >>>>> trial. Simplify your report design, integration and deployment - >>>>> and focus on >>>>> what you do best, core application coding. Discover what's new >>>>> with >>>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>>>> _______________________________________________ >>>>> Matplotlib-users mailing list >>>>> Mat...@li... >>>>> <mailto:Mat...@li...> >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>> >>>>> >>>>> ------------------------------------------------------------------------ >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> >>>>> Let Crystal Reports handle the reporting - Free Crystal Reports >>>>> 2008 30-Day trial. Simplify your report design, integration and >>>>> deployment - and focus on what you do best, core application >>>>> coding. Discover what's new with Crystal Reports now. >>>>> http://p.sf.net/sfu/bobj-july >>>>> ------------------------------------------------------------------------ >>>>> >>>>> >>>>> _______________________________________________ >>>>> Matplotlib-users mailing list >>>>> Mat...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>> >>> >> >> > -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
Thanks much. I am able to replicate your results using netcdf4. FYI, I don't believe the xml file is a CDAT creation; rather, it is probably written using CMOR (http://www2-pcmdi.llnl.gov/cmor), which was used to standardize the IPCC model output files, presumably so they could be accessed by a variety of applications via OpenDAP. Hmmmm... At any rate, I can access the remote data object with netcdf4, but no luck retrieving either data or a time index. In [94]: datobj = ncf(fname) In [95]: timedata = datobj.variables['time'] In [97]: taxvals = timedata[1070:1090] In [99]: print taxvals [ 32559.5 32590. 32620.5 32651. 32681.5 32712.5 32743. 32773.5 32804. 32834.5 32865.5 32895. 32924.5 32955. 32985.5 33016. 33046.5 33077.5 33108. 33138.5] In [100]: print date2index(date0,timedata.units,timedata.calendar,select='nearest') --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /home/amg/work/nhmm/<ipython console> in <module>() /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so in netCDF4.Variable.__getattr__ (netCDF4.c:13593)() /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so in netCDF4._get_att (netCDF4.c:1806)() AttributeError: NetCDF: Attribute not found In [96]: print datobj.variables['tas'].shape (1680, 90, 144) In [101]: testdat = datobj.variables['tas'][0,:,:] --------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) /home/amg/work/nhmm/<ipython console> in <module>() /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so in netCDF4.Variable.__getitem__ (netCDF4.c:14286)() /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/netCDF4.so in netCDF4.Variable._get (netCDF4.c:18945)() RuntimeError: NetCDF: Variable has no data in DAP request -------------------------- Well, at least the error messages are different... Thanks again for all the assistance. It would be useful to access the IPCC output with OpenDap at some point. Best, Arthur Jeff Whitaker wrote: > Arthur M. Greene wrote: >> Thanks much for the quick response. I updated both matplotlib and >> basemap (now at 0.99.5) via svn and noticed the new netcdftime.py. >> First, from within site-packages/mpl_toolkits/basemap, >> >> $ grep date2index *.py >> __init__.py::func:`date2index`: compute a time variable index >> corresponding to a date. >> __init__.py:def date2index(dates, nctime, >> calendar='proleptic_gregorian'): >> __init__.py: return netcdftime.date2index(dates, nctime, >> calendar=None) >> netcdftime.py:def date2index(dates, nctime, calendar=None, >> select='exact'): >> netcdftime.py: date2index(dates, nctime, calendar=None, >> select='exact') >> >> so there seems to be some disagreement between __init__.py and >> netcdftime.py concerning the presence of the "select" argument. When I >> call date2index with the "select" keyword arg I get >> >> In [24]: ix0 = >> date2index(date0,timedata,timedata.calendar,select='nearest') >> --------------------------------------------------------------------------- >> >> TypeError Traceback (most recent call >> last) >> >> /home/amg/work/nhmm/<ipython console> in <module>() >> >> TypeError: date2index() got an unexpected keyword argument 'select' > > Arthur: I forgot to update the wrapper function in __init__.py - that's > fixed now if you do an svn update. Concerning your other problems > below, using your test case exposed a couple of other bugs, but it still > doesn't work. The basic problem is that the date2index function was > designed to work with netCDF4 variable objects > (http://code.google.com/p/netcdf4-python), and the netcdf file/variable > objects that are produced by pupynere/pydap (the pure python netcdf /dap > reader included in basemap) don't quite behave the same way. Using > netCDF4, I can get your gfdl_test.nc case to work with > > > cat testdate2index.py > > #from mpl_toolkits.basemap import date2index,num2date,NetCDFFile as ncf > from netCDF4 import Dataset as ncf > from netCDF4 import date2index, num2date > from mpl_toolkits import basemap > fname0 = 'http://esgcet.llnl.gov/dap/' > fname1 =\ > 'ipcc4/20c3m/gfdl_cm2_1/pcmdi.ipcc4.gfdl_cm2_1.20c3m.run1.atm.mo.xml' > fname = fname0+fname1 > #fname = 'gfdl_test.nc' > print fname > datobj = ncf(fname) > print datobj.variables['tas'].shape > timedata = datobj.variables['time'] > from datetime import datetime as dt > date0 = dt(1951,1,16,12,0,0) > print num2date(timedata[:],timedata.units,calendar=timedata.calendar) > print date0 > nt0 = date2index(date0,timedata,select='nearest') > print nt0 > print \ > timedata[nt0],num2date(timedata[nt0],timedata.units,calendar=timedata.calendar) > > > > python testdate2index.py > > gfdl_test.nc > (13, 31, 29) > [1950年08月16日 12:00:00 1950年09月16日 00:00:00 1950年10月16日 12:00:00 > 1950年11月16日 00:00:00 1950年12月16日 12:00:00 1951年01月16日 12:00:00 > 1951年02月15日 00:00:00 1951年03月16日 12:00:00 1951年04月16日 00:00:00 > 1951年05月16日 12:00:00 1951年06月16日 00:00:00 1951年07月16日 12:00:00 > 1951年08月16日 12:00:00] > 1951年01月16日 12:00:00 > 5 > [ 32865.5] [1951年01月16日 12:00:00] > > > Your original example doesn't work because the URL is not an opendap > server, it's some kind of CDAT xml file that presumably only CDAT > understands. > > We will see if we can fix the date2index function included in basemap > (if not I will remove it), but for now I recommend using > netcdf4-python. It's really a much more robust and feature-rich > solution for netcdf reading and writing. > -Jeff > > > > >> >> ----------------------- >> >> This detail aside, I am still having difficulty with date2index, but >> annoyingly, I seem to get different error messages with different >> datasets. I'll illustrate two here, starting with the one I initially >> posted about. (See note below regarding this data.) >> >> In [3]: from mpl_toolkits.basemap import >> date2index,num2date,NetCDFFile as ncf >> In [10]: from mpl_toolkits import basemap >> In [11]: print basemap.__version__ >> 0.99.5 >> In [24]: fname0 = 'http://esgcet.llnl.gov/dap/' >> In [25]: fname1 = >> 'ipcc4/20c3m/gfdl_cm2_1/pcmdi.ipcc4.gfdl_cm2_1.20c3m.run1.atm.mo.xml' >> In [26]: fname = fname0+fname1 >> In [28]: datobj = ncf(fname) >> In [33]: datobj.variables['tas'].shape >> Out[33]: (1680, 90, 144) >> In [34]: timedata = datobj.variables['time'] >> In [35]: from datetime import datetime as dt >> In [36]: date0 = dt(1951,1,16,12,0,0) >> In [37]: print date0 >> 1951年01月16日 12:00:00 >> In [38]: nt0 = date2index(date0,timedata) >> --------------------------------------------------------------------------- >> >> ClientError Traceback (most recent call >> last) >> >> /home/amg/work/nhmm/<ipython console> in <module>() >> >> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc >> in date2index(dates, nctime, calendar) >> 3931 Returns an index or a sequence of indices. >> 3932 """ >> -> 3933 return netcdftime.date2index(dates, nctime, calendar=None) >> 3934 >> 3935 def maskoceans(lonsin,latsin,datain,inlands=False): >> >> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >> in date2index(dates, nctime, calendar, select) >> 1006 # If the times do not correspond, then it means that the >> times >> 1007 # are not increasing uniformly and we try the bisection >> method. >> -> 1008 if not _check_index(index, dates, nctime, calendar): >> 1009 >> 1010 # Use the bisection method. Assumes the dates are >> ordered. >> >> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >> in _check_index(indices, dates, nctime, calendar) >> 959 return False >> 960 >> --> 961 t = nctime[indices] >> 962 return numpy.all( num2date(t, nctime.units, calendar) == >> dates) >> 963 >> >> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdf.pyc >> in __getitem__(self, index) >> 65 >> 66 def __getitem__(self, index): >> ---> 67 datout = squeeze(self._var.__getitem__(index)) >> 68 # automatically >> 69 # - remove singleton dimensions >> >> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/dtypes.pyc >> in __getitem__(self, key) >> 409 def __getitem__(self, key): >> 410 # Return data from the array. >> --> 411 return self.data[key] >> 412 >> 413 def __setitem__(self, key, item): >> >> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/proxy.pyc >> in __getitem__(self, index) >> 112 >> 113 # Fetch data. >> --> 114 resp, data = openurl(url, self.cache, self.username, >> self.password) >> 115 >> 116 # First lines are ASCII information that end with >> 'Data:\n'. >> >> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/util/http.pyc >> in openurl(url, cache, username, password) >> 19 m = re.search('code = (?P<code>\d+);\s*message = >> "(?P<msg>.*)"', data, re.DOTALL | re.MULTILINE) >> 20 msg = 'Server error %(code)s: "%(msg)s"' % m.groupdict() >> ---> 21 raise ClientError(msg) >> 22 >> 23 return resp, data >> >> ClientError: 'Server error 0: "invalid literal for int(): [1113"' >> >> ----------------------------- >> >> Note that this is a different error than previously reported. Also, >> the correct time index is still 1080: >> >> In [40]: taxvals = datobj.variables['time'][:] >> >> In [41]: num2date(taxvals[1080],timedata.units,timedata.calendar) >> Out[41]: 1951年01月16日 12:00:00 >> >> ----------------------------- >> >> This dataset, generated by one of the IPCC models, is >> password-protected, but could be a good target for decoding, since it >> is typical of a large class of climate models, that generate a lot of >> analytical activity. To get a password (they're free) one must >> register. Info is here: >> http://www-pcmdi.llnl.gov/ipcc/info_for_analysts.php. Follow "How to >> access..." then "Register to download output." Once you get a userid >> and password they can be inserted in the NetCDFFile call, voila. Note >> that there is a new iteration of IPCC coming down the pike; new model >> files to become widely available starting in 2010. >> >> ------------------------------ >> >> The underlying data is available via ftp. I fetched it and extracted a >> small slab, which is available at >> http://iri.columbia.edu/~amg/test/gfdl_test.nc. The CDAT package can >> digest this file; first time step is plotted here: >> http://iri.columbia.edu/~amg/test/gfdl_test_time0.png. The dates can >> also be read by this package, and run from Aug 1950 to Aug 1951, >> inclusive (13 mos). So the file does not seem to be garbage. >> >> In [16]: datobj = ncf('gfdl_test.nc') >> In [17]: timedata = datobj.variables['time'] >> In [18]: date0 = dt(1951,1,16,12,0,0) >> In [19]: nt0 = date2index(date0,timedata) >> --------------------------------------------------------------------------- >> >> TypeError Traceback (most recent call >> last) >> >> /home/amg/work/nhmm/<ipython console> in <module>() >> >> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc >> in date2index(dates, nctime, calendar) >> 3931 Returns an index or a sequence of indices. >> 3932 """ >> -> 3933 return netcdftime.date2index(dates, nctime, calendar=None) >> 3934 >> 3935 def maskoceans(lonsin,latsin,datain,inlands=False): >> >> /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >> in date2index(dates, nctime, calendar, select) >> 1011 import bisect >> 1012 >> -> 1013 index = numpy.array([bisect.bisect_left(nctime, n) for >> n in num], int) >> 1014 >> 1015 nomatch = num2date(nctime[index], nctime.units) != dates >> >> TypeError: object of type 'netcdf_variable' has no len() >> >> Investigating the time axis, >> >> In [20]: taxvals = timedata[:] >> >> In [21]: taxvals >> Out[21]: array([ 32712.5, 32743. , 32773.5, 32804. , 32834.5, >> 32865.5, 32895. , 32924.5, 32955. , 32985.5, 33016. , 33046.5, >> 33077.5]) >> >> In [22]: num2date(taxvals,timedata.units,timedata.calendar) >> Out[22]: array([1950年08月16日 12:00:00, 1950年09月16日 00:00:00, 1950年10月16日 >> 12:00:00, >> 1950年11月16日 00:00:00, 1950年12月16日 12:00:00, 1951年01月16日 12:00:00, >> 1951年02月15日 00:00:00, 1951年03月16日 12:00:00, 1951年04月16日 00:00:00, >> 1951年05月16日 12:00:00, 1951年06月16日 00:00:00, 1951年07月16日 12:00:00, >> 1951年08月16日 12:00:00], dtype=object) >> >> Which agrees with what CDAT sees. >> >> ------------------------- >> >> I think this is enough for now. I also had problems opening data files >> whose time units were like "months since xxxx-xx-xx," since the >> "months" unit does not seem to be supported. ("years since..." could >> also be useful in some cases.) But maybe one or two things at a time >> is enough! >> >> Thanks for any assistance/advice! >> >> Best, >> >> Arthur >> >> >> Jeff Whitaker wrote: >>> David Huard wrote: >>>> Arthur, >>>> >>>> I wrote the date2index function and I think what you are seeing is a >>>> bug that I fixed a couple of months ago. By using the latest version >>>> of netcdf4-python, not only should this bug disappear, but you'll >>>> also find that date2index now supports different selection methods: >>>> 'exact', 'before', 'after', 'nearest', that should help with your >>>> use case. >>>> >>>> If this does not fix the problem you are seeing, I'd appreciate >>>> having a copy of the file and code to reproduce the problem and find >>>> a solution. >>>> >>>> HTH, >>>> >>>> David Huard >>> >>> Arthur: I've just updated basemap svn with David's latest version of >>> date2index, so another option is to update basemap from svn. Or, >>> even simpler, just drop the attached netcdftime.py file in >>> lib/mpl_toolkits/basemap (replacing the old one) and run python >>> setup.py install. >>> >>> -Jeff >>>> >>>> >>>> >>>> On Mon, Sep 7, 2009 at 9:27 AM, Arthur M. Greene >>>> <am...@ir... <mailto:am...@ir...>> wrote: >>>> >>>> Hi All, >>>> >>>> The problem is not with fetching the data slice itself, but >>>> finding the >>>> correct indices to specify, particularly with the time >>>> dimension. The >>>> below examples refer to a remote dataset that I can open and slice >>>> using >>>> indices, as in >>>> >>>> slice = remoteobj.variables['tas'][:120,20:40,30:50]. >>>> >>>> However, I have problems when trying to use the syntax in >>>> plotsst.py or >>>> pnganim.py (from the examples) to find time indices: >>>> >>>> In [107]: from datetime import datetime as dt >>>> In [108]: date0 = dt(1951,1,1,0) >>>> In [110]: print date0 >>>> 1951年01月01日 00:00:00 >>>> >>>> In [125]: timedata = remoteobj.variables['time'] >>>> In [126]: nt0 = date2index(date0,timedata) >>>> >>>> --------------------------------------------------------------------------- >>>> >>>> AssertionError Traceback (most recent >>>> call last) >>>> >>>> /home/amg/work/nhmm/<ipython console> in <module>() >>>> >>>> >>>> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc >>>> >>>> >>>> in date2index(dates, nctime, calendar) >>>> 3924 Returns an index or a sequence of indices. >>>> 3925 """ >>>> -> 3926 return netcdftime.date2index(dates, nctime, >>>> calendar=None) >>>> 3927 >>>> 3928 def maskoceans(lonsin,latsin,datain,inlands=False): >>>> >>>> >>>> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >>>> >>>> >>>> in date2index(dates, nctime, calendar) >>>> 986 >>>> 987 # Perform check again. >>>> --> 988 _check_index(index, dates, nctime, calendar) >>>> 989 >>>> 990 # convert numpy scalars or single element arrays to >>>> python >>>> ints. >>>> >>>> >>>> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >>>> >>>> >>>> in _check_index(indices, dates, nctime, calendar) >>>> 941 for n,i in enumerate(indices): >>>> 942 t[n] = nctime[i] >>>> --> 943 assert numpy.all( num2date(t, nctime.units, calendar) >>>> == dates) >>>> 944 >>>> 945 >>>> >>>> AssertionError: >>>> >>>> --------------------------------------------------------- >>>> >>>> It turns out that date0 corresponds best to index 1080: >>>> >>>> In [139]: remoteobj.variables['time'][1080] >>>> Out[139]: 32865.5 >>>> >>>> In [141]: num2date(32865.5,timedata.units,timedata.calendar) >>>> Out[141]: 1951年01月16日 12:00:00 >>>> >>>> This isn't the _exact_ date and time I had specified, but >>>> >>>> In [142]: date0 = dt(1951,01,16,12,00,00) >>>> In [143]: print date0 >>>> 1951年01月16日 12:00:00 >>>> >>>> In [144]: date2index(date0,timedata,timedata.calendar) >>>> >>>> produces the same AssertionError. Where is the problem? >>>> >>>> What I would _like_ to do is to issue a simple call using >>>> coordinates >>>> rather than the indices, of the form: >>>> >>>> slice = variable[date0:date1,[plev],lat0:lat1,lon0:lon1], >>>> >>>> or similar, preferably without writing a whole module just to >>>> find the >>>> correct indices. I need to fetch similar slices from a group of >>>> models, >>>> having time axes that may each be defined slightly differently -- >>>> different calendars, time point set at a different day of the >>>> month, >>>> etc. (It's monthly data and I'm specifying only monthly bounds, >>>> even >>>> though the calendar may be defined as "days since 1860...") I >>>> need to >>>> automate the process so I get back the correct slab regardless. >>>> >>>> Suggestions appreciated! >>>> >>>> Thx, >>>> >>>> Arthur >>>> >>>> >>>> *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* >>>> Arthur M. Greene, Ph.D. >>>> The International Research Institute for Climate and Society (IRI) >>>> The Earth Institute, Columbia University, Lamont Campus >>>> >>>> amg at iri dot columbia dot edu | http://iri.columbia.edu >>>> *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> >>>> Let Crystal Reports handle the reporting - Free Crystal Reports >>>> 2008 30-Day >>>> trial. Simplify your report design, integration and deployment - >>>> and focus on >>>> what you do best, core application coding. Discover what's new with >>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>>> _______________________________________________ >>>> Matplotlib-users mailing list >>>> Mat...@li... >>>> <mailto:Mat...@li...> >>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>> >>>> >>>> ------------------------------------------------------------------------ >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> >>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >>>> 30-Day trial. Simplify your report design, integration and >>>> deployment - and focus on what you do best, core application coding. >>>> Discover what's new with Crystal Reports now. >>>> http://p.sf.net/sfu/bobj-july >>>> ------------------------------------------------------------------------ >>>> >>>> >>>> _______________________________________________ >>>> Matplotlib-users mailing list >>>> Mat...@li... >>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>> >> > > -- *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* Arthur M. Greene, Ph.D. The International Research Institute for Climate and Society The Earth Institute, Columbia University, Lamont Campus Monell Building, 61 Route 9W, Palisades, NY 10964-8000 USA amg at iri dot columbia dot edu | http://iri.columbia.edu *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*
I'm not seeing that, but I'm running Sphinx 0.6.3. It also looks like the kind of thing where removing the build directory may help. Mike Nils Wagner wrote: > Hi all, > > python make.py html failed with > > /home/nwagner/svn/matplotlib/doc/faq/environment_variables_faq.rst:: > WARNING: document isn't included in any toctree > /home/nwagner/svn/matplotlib/doc/mpl_toolkits/axes_grid/index.rst:: > WARNING: document isn't included in any toctree > /home/nwagner/svn/matplotlib/doc/mpl_toolkits/mplot3d/index.rst:: > WARNING: document isn't included in any toctree > /home/nwagner/svn/matplotlib/doc/users/arraydata.rst:: > WARNING: document isn't included in any toctree > /home/nwagner/svn/matplotlib/doc/users/plotting.rst:: > WARNING: document isn't included in any toctree > done > preparing documents... done > Exception occurred while building, starting debugger: > Traceback (most recent call last): > File > "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/cmdline.py", > line 172, in main > app.build(all_files, filenames) > File > "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/application.py", > line 129, in build > self.builder.build_update() > File > "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/builders/__init__.py", > line 255, in build_update > 'out of date' % len(to_build)) > File > "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/builders/__init__.py", > line 310,in build > self.write(docnames, list(updated_docnames), method) > File > "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/builders/__init__.py", > line 349,in write > self.write_doc(docname, doctree) > File > "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/builders/html.py", > line 349, in write_doc > ctx = self.get_doc_context(docname, body, metatags) > File > "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/builders/html.py", > line 319, in get_doc_context > toc = > self.render_partial(self.env.get_toc_for(docname))['fragment'] > File > "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/environment.py", > line 921, in get_toc_for > toc = self.tocs[docname].deepcopy() > KeyError: 'users/annotations' > >> /home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/environment.py(921)get_toc_for() >> > -> toc = self.tocs[docname].deepcopy() > (Pdb) > > I am using > > >>>> matplotlib.__version__ >>>> > '1.0.svn' > > Python 2.6 (r26:66714, Feb 3 2009, 20:49:49) > [GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2 > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA
Hi all, python make.py html failed with /home/nwagner/svn/matplotlib/doc/faq/environment_variables_faq.rst:: WARNING: document isn't included in any toctree /home/nwagner/svn/matplotlib/doc/mpl_toolkits/axes_grid/index.rst:: WARNING: document isn't included in any toctree /home/nwagner/svn/matplotlib/doc/mpl_toolkits/mplot3d/index.rst:: WARNING: document isn't included in any toctree /home/nwagner/svn/matplotlib/doc/users/arraydata.rst:: WARNING: document isn't included in any toctree /home/nwagner/svn/matplotlib/doc/users/plotting.rst:: WARNING: document isn't included in any toctree done preparing documents... done Exception occurred while building, starting debugger: Traceback (most recent call last): File "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/cmdline.py", line 172, in main app.build(all_files, filenames) File "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/application.py", line 129, in build self.builder.build_update() File "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/builders/__init__.py", line 255, in build_update 'out of date' % len(to_build)) File "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/builders/__init__.py", line 310,in build self.write(docnames, list(updated_docnames), method) File "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/builders/__init__.py", line 349,in write self.write_doc(docname, doctree) File "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/builders/html.py", line 349, in write_doc ctx = self.get_doc_context(docname, body, metatags) File "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/builders/html.py", line 319, in get_doc_context toc = self.render_partial(self.env.get_toc_for(docname))['fragment'] File "/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/environment.py", line 921, in get_toc_for toc = self.tocs[docname].deepcopy() KeyError: 'users/annotations' > /home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/environment.py(921)get_toc_for() -> toc = self.tocs[docname].deepcopy() (Pdb) I am using >>> matplotlib.__version__ '1.0.svn' Python 2.6 (r26:66714, Feb 3 2009, 20:49:49) [GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
> From: Michael Droettboom [mailto:md...@st...] > Sent: Wednesday, September 09, 2009 08:17 > > This change has gone into effect (for me at least on a Liux > box). Can anyone test Windows and Mac and report back? On Windows 7RC, Firefox 3.5.2 and IE 8.0 see matplotlib-0.99.0.win32-py2.6.exe.
Hi, is it enough to overwrite the axesgrid.py file in my matplotlib 0.99 installation with the file from svn? I tried that, but i see no effects. Are there anywhere precompiled matplotlib releases for 1.0_win32_pre? Andreas Jae-Joon Lee schrieb: > On Tue, Sep 8, 2009 at 11:51 AM, Yann > Goudard<mat...@al...> wrote: > >> Hi, >> >> I have the same behaviour with LocatableAxes. HostAxes, ParasiteAxes and >> LocatableAxes depend on 'mpl_toolkits.axes_grid.axislines.Axes'. It must >> be the matter origin. >> > > Yes, and this was because I forgot to implement some necessary methods. > This is now fixed in the svn trunk. So if you can,please give it a try. > > >> This another example should draw a grid but does not: >> >> import wx >> from wx import Frame >> from matplotlib.backends.backend_wxagg import FigureFrameWxAgg, >> FigureCanvasWxAgg >> from matplotlib.figure import Figure >> from mpl_toolkits.axes_grid.axes_divider import LocatableAxes >> >> fig = Figure((1, 1), 50) >> axes = LocatableAxes(fig, [0, 0, 1, 1]) >> # axes.toggle_axisline(False) >> axes.grid(True) >> fig.add_axes(axes) >> >> app = wx.PySimpleApp() >> my_viewer = FigureFrameWxAgg(-1, fig) >> my_viewer.Show() >> app.MainLoop() >> >> If you uncomment axes.toggle_axisline(False), it works cause it uses >> normal 'matplolib.axes.Axes' behaviour. It is not a matter for common >> use but if you need 'AxesZero', this trick does not work. >> > > What the toggle_axisline does is simply to make the xaxis and yaxis > (which are responsible for drawing ticks, ticklabels, etc in the > mainline mpl) visible again, and make axis["bottom"] and etc > invisible. > One workaround is to make xaxis and yaxis visible but pnly to draw the > gridlines. Something like below. > > ax.toggle_axisline(True) > ax.grid(True) > ax.gridlines.set_visible(False) # this is just to make the code not to > draw gridlines twice in future release of mpl. > ax.xaxis.set_visible(True) > ax.yaxis.set_visible(True) > for t in ax.xaxis.majorTicks + ax.yaxis.majorTicks: > t.gridOn = True > t.tick1On = False > t.tick2On = False > t.label1On = False > t.label2On = False > > Let me know if this does not work, or there is a case that this cannot be used. > Regards, > > -JJ > > > >> Yann >> >> >> On 09/07/2009 10:37 PM, Andreas Fromm wrote: >> >>> thanks Sebastian, >>> >>> you are right, your code works here too. But i don't get it work in my >>> multi y-axes plot from the matplotlib examples >>> (http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes.html). >>> Even with linear plots, i get no gridlines. >>> >>> Any idea, whats wrong here? >>> >>> minimal code example: >>> ####################### >>> import matplotlib.pyplot as plt >>> from mpl_toolkits.axes_grid.parasite_axes import HostAxes, ParasiteAxes >>> >>> fig = plt.figure(1) >>> fig.clf() >>> #plt.grid(True) >>> host = HostAxes(fig, [0.15, 0.1, 0.65, 0.8]) >>> fig.add_axes(host) >>> >>> host.plot([0, 10, 100], [0, 10, 100], label='host') >>> >>> host.grid(True) #? >>> host.yaxis.grid(True) #? >>> >>> host.yaxis.set_scale('log') #? >>> >>> plt.draw() >>> plt.show() >>> ####################### >>> >>> Greets, >>> Andreas >>> >>> >>> Sebastian Busch schrieb: >>> >>> >>>> from matplotlib.pyplot import * >>>> >>>> plot([1,10,100],[1,10,100]) >>>> grid() >>>> >>>> yscale('log') >>>> xscale('log') >>>> >>>> works here. >>>> >>>> best, >>>> sebastian. >>>> >>>> >>>> >>> ------------------------------------------------------------------------------ >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day >>> trial. Simplify your report design, integration and deployment - and focus on >>> what you do best, core application coding. Discover what's new with >>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day >> trial. Simplify your report design, integration and deployment - and focus on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
Arthur M. Greene wrote: > Thanks much for the quick response. I updated both matplotlib and > basemap (now at 0.99.5) via svn and noticed the new netcdftime.py. > First, from within site-packages/mpl_toolkits/basemap, > > $ grep date2index *.py > __init__.py::func:`date2index`: compute a time variable index > corresponding to a date. > __init__.py:def date2index(dates, nctime, > calendar='proleptic_gregorian'): > __init__.py: return netcdftime.date2index(dates, nctime, > calendar=None) > netcdftime.py:def date2index(dates, nctime, calendar=None, > select='exact'): > netcdftime.py: date2index(dates, nctime, calendar=None, > select='exact') > > so there seems to be some disagreement between __init__.py and > netcdftime.py concerning the presence of the "select" argument. When I > call date2index with the "select" keyword arg I get > > In [24]: ix0 = > date2index(date0,timedata,timedata.calendar,select='nearest') > --------------------------------------------------------------------------- > > TypeError Traceback (most recent call > last) > > /home/amg/work/nhmm/<ipython console> in <module>() > > TypeError: date2index() got an unexpected keyword argument 'select' Arthur: I forgot to update the wrapper function in __init__.py - that's fixed now if you do an svn update. Concerning your other problems below, using your test case exposed a couple of other bugs, but it still doesn't work. The basic problem is that the date2index function was designed to work with netCDF4 variable objects (http://code.google.com/p/netcdf4-python), and the netcdf file/variable objects that are produced by pupynere/pydap (the pure python netcdf /dap reader included in basemap) don't quite behave the same way. Using netCDF4, I can get your gfdl_test.nc case to work with > cat testdate2index.py #from mpl_toolkits.basemap import date2index,num2date,NetCDFFile as ncf from netCDF4 import Dataset as ncf from netCDF4 import date2index, num2date from mpl_toolkits import basemap fname0 = 'http://esgcet.llnl.gov/dap/' fname1 =\ 'ipcc4/20c3m/gfdl_cm2_1/pcmdi.ipcc4.gfdl_cm2_1.20c3m.run1.atm.mo.xml' fname = fname0+fname1 #fname = 'gfdl_test.nc' print fname datobj = ncf(fname) print datobj.variables['tas'].shape timedata = datobj.variables['time'] from datetime import datetime as dt date0 = dt(1951,1,16,12,0,0) print num2date(timedata[:],timedata.units,calendar=timedata.calendar) print date0 nt0 = date2index(date0,timedata,select='nearest') print nt0 print \ timedata[nt0],num2date(timedata[nt0],timedata.units,calendar=timedata.calendar) > python testdate2index.py gfdl_test.nc (13, 31, 29) [1950年08月16日 12:00:00 1950年09月16日 00:00:00 1950年10月16日 12:00:00 1950年11月16日 00:00:00 1950年12月16日 12:00:00 1951年01月16日 12:00:00 1951年02月15日 00:00:00 1951年03月16日 12:00:00 1951年04月16日 00:00:00 1951年05月16日 12:00:00 1951年06月16日 00:00:00 1951年07月16日 12:00:00 1951年08月16日 12:00:00] 1951年01月16日 12:00:00 5 [ 32865.5] [1951年01月16日 12:00:00] Your original example doesn't work because the URL is not an opendap server, it's some kind of CDAT xml file that presumably only CDAT understands. We will see if we can fix the date2index function included in basemap (if not I will remove it), but for now I recommend using netcdf4-python. It's really a much more robust and feature-rich solution for netcdf reading and writing. -Jeff > > ----------------------- > > This detail aside, I am still having difficulty with date2index, but > annoyingly, I seem to get different error messages with different > datasets. I'll illustrate two here, starting with the one I initially > posted about. (See note below regarding this data.) > > In [3]: from mpl_toolkits.basemap import > date2index,num2date,NetCDFFile as ncf > In [10]: from mpl_toolkits import basemap > In [11]: print basemap.__version__ > 0.99.5 > In [24]: fname0 = 'http://esgcet.llnl.gov/dap/' > In [25]: fname1 = > 'ipcc4/20c3m/gfdl_cm2_1/pcmdi.ipcc4.gfdl_cm2_1.20c3m.run1.atm.mo.xml' > In [26]: fname = fname0+fname1 > In [28]: datobj = ncf(fname) > In [33]: datobj.variables['tas'].shape > Out[33]: (1680, 90, 144) > In [34]: timedata = datobj.variables['time'] > In [35]: from datetime import datetime as dt > In [36]: date0 = dt(1951,1,16,12,0,0) > In [37]: print date0 > 1951年01月16日 12:00:00 > In [38]: nt0 = date2index(date0,timedata) > --------------------------------------------------------------------------- > > ClientError Traceback (most recent call > last) > > /home/amg/work/nhmm/<ipython console> in <module>() > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc > in date2index(dates, nctime, calendar) > 3931 Returns an index or a sequence of indices. > 3932 """ > -> 3933 return netcdftime.date2index(dates, nctime, calendar=None) > 3934 > 3935 def maskoceans(lonsin,latsin,datain,inlands=False): > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc > in date2index(dates, nctime, calendar, select) > 1006 # If the times do not correspond, then it means that the > times > 1007 # are not increasing uniformly and we try the bisection > method. > -> 1008 if not _check_index(index, dates, nctime, calendar): > 1009 > 1010 # Use the bisection method. Assumes the dates are > ordered. > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc > in _check_index(indices, dates, nctime, calendar) > 959 return False > 960 > --> 961 t = nctime[indices] > 962 return numpy.all( num2date(t, nctime.units, calendar) == > dates) > 963 > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdf.pyc > in __getitem__(self, index) > 65 > 66 def __getitem__(self, index): > ---> 67 datout = squeeze(self._var.__getitem__(index)) > 68 # automatically > 69 # - remove singleton dimensions > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/dtypes.pyc > in __getitem__(self, key) > 409 def __getitem__(self, key): > 410 # Return data from the array. > --> 411 return self.data[key] > 412 > 413 def __setitem__(self, key, item): > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/proxy.pyc > in __getitem__(self, index) > 112 > 113 # Fetch data. > --> 114 resp, data = openurl(url, self.cache, self.username, > self.password) > 115 > 116 # First lines are ASCII information that end with > 'Data:\n'. > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/util/http.pyc > in openurl(url, cache, username, password) > 19 m = re.search('code = (?P<code>\d+);\s*message = > "(?P<msg>.*)"', data, re.DOTALL | re.MULTILINE) > 20 msg = 'Server error %(code)s: "%(msg)s"' % m.groupdict() > ---> 21 raise ClientError(msg) > 22 > 23 return resp, data > > ClientError: 'Server error 0: "invalid literal for int(): [1113"' > > ----------------------------- > > Note that this is a different error than previously reported. Also, > the correct time index is still 1080: > > In [40]: taxvals = datobj.variables['time'][:] > > In [41]: num2date(taxvals[1080],timedata.units,timedata.calendar) > Out[41]: 1951年01月16日 12:00:00 > > ----------------------------- > > This dataset, generated by one of the IPCC models, is > password-protected, but could be a good target for decoding, since it > is typical of a large class of climate models, that generate a lot of > analytical activity. To get a password (they're free) one must > register. Info is here: > http://www-pcmdi.llnl.gov/ipcc/info_for_analysts.php. Follow "How to > access..." then "Register to download output." Once you get a userid > and password they can be inserted in the NetCDFFile call, voila. Note > that there is a new iteration of IPCC coming down the pike; new model > files to become widely available starting in 2010. > > ------------------------------ > > The underlying data is available via ftp. I fetched it and extracted a > small slab, which is available at > http://iri.columbia.edu/~amg/test/gfdl_test.nc. The CDAT package can > digest this file; first time step is plotted here: > http://iri.columbia.edu/~amg/test/gfdl_test_time0.png. The dates can > also be read by this package, and run from Aug 1950 to Aug 1951, > inclusive (13 mos). So the file does not seem to be garbage. > > In [16]: datobj = ncf('gfdl_test.nc') > In [17]: timedata = datobj.variables['time'] > In [18]: date0 = dt(1951,1,16,12,0,0) > In [19]: nt0 = date2index(date0,timedata) > --------------------------------------------------------------------------- > > TypeError Traceback (most recent call > last) > > /home/amg/work/nhmm/<ipython console> in <module>() > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc > in date2index(dates, nctime, calendar) > 3931 Returns an index or a sequence of indices. > 3932 """ > -> 3933 return netcdftime.date2index(dates, nctime, calendar=None) > 3934 > 3935 def maskoceans(lonsin,latsin,datain,inlands=False): > > /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc > in date2index(dates, nctime, calendar, select) > 1011 import bisect > 1012 > -> 1013 index = numpy.array([bisect.bisect_left(nctime, n) for > n in num], int) > 1014 > 1015 nomatch = num2date(nctime[index], nctime.units) != dates > > TypeError: object of type 'netcdf_variable' has no len() > > Investigating the time axis, > > In [20]: taxvals = timedata[:] > > In [21]: taxvals > Out[21]: array([ 32712.5, 32743. , 32773.5, 32804. , 32834.5, > 32865.5, 32895. , 32924.5, 32955. , 32985.5, 33016. , 33046.5, > 33077.5]) > > In [22]: num2date(taxvals,timedata.units,timedata.calendar) > Out[22]: array([1950年08月16日 12:00:00, 1950年09月16日 00:00:00, 1950年10月16日 > 12:00:00, > 1950年11月16日 00:00:00, 1950年12月16日 12:00:00, 1951年01月16日 12:00:00, > 1951年02月15日 00:00:00, 1951年03月16日 12:00:00, 1951年04月16日 00:00:00, > 1951年05月16日 12:00:00, 1951年06月16日 00:00:00, 1951年07月16日 12:00:00, > 1951年08月16日 12:00:00], dtype=object) > > Which agrees with what CDAT sees. > > ------------------------- > > I think this is enough for now. I also had problems opening data files > whose time units were like "months since xxxx-xx-xx," since the > "months" unit does not seem to be supported. ("years since..." could > also be useful in some cases.) But maybe one or two things at a time > is enough! > > Thanks for any assistance/advice! > > Best, > > Arthur > > > Jeff Whitaker wrote: >> David Huard wrote: >>> Arthur, >>> >>> I wrote the date2index function and I think what you are seeing is a >>> bug that I fixed a couple of months ago. By using the latest version >>> of netcdf4-python, not only should this bug disappear, but you'll >>> also find that date2index now supports different selection methods: >>> 'exact', 'before', 'after', 'nearest', that should help with your >>> use case. >>> >>> If this does not fix the problem you are seeing, I'd appreciate >>> having a copy of the file and code to reproduce the problem and find >>> a solution. >>> >>> HTH, >>> >>> David Huard >> >> Arthur: I've just updated basemap svn with David's latest version of >> date2index, so another option is to update basemap from svn. Or, >> even simpler, just drop the attached netcdftime.py file in >> lib/mpl_toolkits/basemap (replacing the old one) and run python >> setup.py install. >> >> -Jeff >>> >>> >>> >>> On Mon, Sep 7, 2009 at 9:27 AM, Arthur M. Greene >>> <am...@ir... <mailto:am...@ir...>> wrote: >>> >>> Hi All, >>> >>> The problem is not with fetching the data slice itself, but >>> finding the >>> correct indices to specify, particularly with the time >>> dimension. The >>> below examples refer to a remote dataset that I can open and slice >>> using >>> indices, as in >>> >>> slice = remoteobj.variables['tas'][:120,20:40,30:50]. >>> >>> However, I have problems when trying to use the syntax in >>> plotsst.py or >>> pnganim.py (from the examples) to find time indices: >>> >>> In [107]: from datetime import datetime as dt >>> In [108]: date0 = dt(1951,1,1,0) >>> In [110]: print date0 >>> 1951年01月01日 00:00:00 >>> >>> In [125]: timedata = remoteobj.variables['time'] >>> In [126]: nt0 = date2index(date0,timedata) >>> >>> --------------------------------------------------------------------------- >>> >>> AssertionError Traceback (most recent >>> call last) >>> >>> /home/amg/work/nhmm/<ipython console> in <module>() >>> >>> >>> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc >>> >>> >>> in date2index(dates, nctime, calendar) >>> 3924 Returns an index or a sequence of indices. >>> 3925 """ >>> -> 3926 return netcdftime.date2index(dates, nctime, >>> calendar=None) >>> 3927 >>> 3928 def maskoceans(lonsin,latsin,datain,inlands=False): >>> >>> >>> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >>> >>> >>> in date2index(dates, nctime, calendar) >>> 986 >>> 987 # Perform check again. >>> --> 988 _check_index(index, dates, nctime, calendar) >>> 989 >>> 990 # convert numpy scalars or single element arrays to >>> python >>> ints. >>> >>> >>> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >>> >>> >>> in _check_index(indices, dates, nctime, calendar) >>> 941 for n,i in enumerate(indices): >>> 942 t[n] = nctime[i] >>> --> 943 assert numpy.all( num2date(t, nctime.units, calendar) >>> == dates) >>> 944 >>> 945 >>> >>> AssertionError: >>> >>> --------------------------------------------------------- >>> >>> It turns out that date0 corresponds best to index 1080: >>> >>> In [139]: remoteobj.variables['time'][1080] >>> Out[139]: 32865.5 >>> >>> In [141]: num2date(32865.5,timedata.units,timedata.calendar) >>> Out[141]: 1951年01月16日 12:00:00 >>> >>> This isn't the _exact_ date and time I had specified, but >>> >>> In [142]: date0 = dt(1951,01,16,12,00,00) >>> In [143]: print date0 >>> 1951年01月16日 12:00:00 >>> >>> In [144]: date2index(date0,timedata,timedata.calendar) >>> >>> produces the same AssertionError. Where is the problem? >>> >>> What I would _like_ to do is to issue a simple call using >>> coordinates >>> rather than the indices, of the form: >>> >>> slice = variable[date0:date1,[plev],lat0:lat1,lon0:lon1], >>> >>> or similar, preferably without writing a whole module just to >>> find the >>> correct indices. I need to fetch similar slices from a group of >>> models, >>> having time axes that may each be defined slightly differently -- >>> different calendars, time point set at a different day of the >>> month, >>> etc. (It's monthly data and I'm specifying only monthly bounds, >>> even >>> though the calendar may be defined as "days since 1860...") I >>> need to >>> automate the process so I get back the correct slab regardless. >>> >>> Suggestions appreciated! >>> >>> Thx, >>> >>> Arthur >>> >>> >>> *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* >>> Arthur M. Greene, Ph.D. >>> The International Research Institute for Climate and Society (IRI) >>> The Earth Institute, Columbia University, Lamont Campus >>> >>> amg at iri dot columbia dot edu | http://iri.columbia.edu >>> *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> >>> Let Crystal Reports handle the reporting - Free Crystal Reports >>> 2008 30-Day >>> trial. Simplify your report design, integration and deployment - >>> and focus on >>> what you do best, core application coding. Discover what's new with >>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> <mailto:Mat...@li...> >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >>> ------------------------------------------------------------------------ >>> >>> >>> ------------------------------------------------------------------------------ >>> >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >>> 30-Day trial. Simplify your report design, integration and >>> deployment - and focus on what you do best, core application coding. >>> Discover what's new with Crystal Reports now. >>> http://p.sf.net/sfu/bobj-july >>> ------------------------------------------------------------------------ >>> >>> >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> > -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
Thanks much for the quick response. I updated both matplotlib and basemap (now at 0.99.5) via svn and noticed the new netcdftime.py. First, from within site-packages/mpl_toolkits/basemap, $ grep date2index *.py __init__.py::func:`date2index`: compute a time variable index corresponding to a date. __init__.py:def date2index(dates, nctime, calendar='proleptic_gregorian'): __init__.py: return netcdftime.date2index(dates, nctime, calendar=None) netcdftime.py:def date2index(dates, nctime, calendar=None, select='exact'): netcdftime.py: date2index(dates, nctime, calendar=None, select='exact') so there seems to be some disagreement between __init__.py and netcdftime.py concerning the presence of the "select" argument. When I call date2index with the "select" keyword arg I get In [24]: ix0 = date2index(date0,timedata,timedata.calendar,select='nearest') --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/amg/work/nhmm/<ipython console> in <module>() TypeError: date2index() got an unexpected keyword argument 'select' ----------------------- This detail aside, I am still having difficulty with date2index, but annoyingly, I seem to get different error messages with different datasets. I'll illustrate two here, starting with the one I initially posted about. (See note below regarding this data.) In [3]: from mpl_toolkits.basemap import date2index,num2date,NetCDFFile as ncf In [10]: from mpl_toolkits import basemap In [11]: print basemap.__version__ 0.99.5 In [24]: fname0 = 'http://esgcet.llnl.gov/dap/' In [25]: fname1 = 'ipcc4/20c3m/gfdl_cm2_1/pcmdi.ipcc4.gfdl_cm2_1.20c3m.run1.atm.mo.xml' In [26]: fname = fname0+fname1 In [28]: datobj = ncf(fname) In [33]: datobj.variables['tas'].shape Out[33]: (1680, 90, 144) In [34]: timedata = datobj.variables['time'] In [35]: from datetime import datetime as dt In [36]: date0 = dt(1951,1,16,12,0,0) In [37]: print date0 1951年01月16日 12:00:00 In [38]: nt0 = date2index(date0,timedata) --------------------------------------------------------------------------- ClientError Traceback (most recent call last) /home/amg/work/nhmm/<ipython console> in <module>() /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc in date2index(dates, nctime, calendar) 3931 Returns an index or a sequence of indices. 3932 """ -> 3933 return netcdftime.date2index(dates, nctime, calendar=None) 3934 3935 def maskoceans(lonsin,latsin,datain,inlands=False): /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc in date2index(dates, nctime, calendar, select) 1006 # If the times do not correspond, then it means that the times 1007 # are not increasing uniformly and we try the bisection method. -> 1008 if not _check_index(index, dates, nctime, calendar): 1009 1010 # Use the bisection method. Assumes the dates are ordered. /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc in _check_index(indices, dates, nctime, calendar) 959 return False 960 --> 961 t = nctime[indices] 962 return numpy.all( num2date(t, nctime.units, calendar) == dates) 963 /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdf.pyc in __getitem__(self, index) 65 66 def __getitem__(self, index): ---> 67 datout = squeeze(self._var.__getitem__(index)) 68 # automatically 69 # - remove singleton dimensions /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/dtypes.pyc in __getitem__(self, key) 409 def __getitem__(self, key): 410 # Return data from the array. --> 411 return self.data[key] 412 413 def __setitem__(self, key, item): /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/proxy.pyc in __getitem__(self, index) 112 113 # Fetch data. --> 114 resp, data = openurl(url, self.cache, self.username, self.password) 115 116 # First lines are ASCII information that end with 'Data:\n'. /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/dap/util/http.pyc in openurl(url, cache, username, password) 19 m = re.search('code = (?P<code>\d+);\s*message = "(?P<msg>.*)"', data, re.DOTALL | re.MULTILINE) 20 msg = 'Server error %(code)s: "%(msg)s"' % m.groupdict() ---> 21 raise ClientError(msg) 22 23 return resp, data ClientError: 'Server error 0: "invalid literal for int(): [1113"' ----------------------------- Note that this is a different error than previously reported. Also, the correct time index is still 1080: In [40]: taxvals = datobj.variables['time'][:] In [41]: num2date(taxvals[1080],timedata.units,timedata.calendar) Out[41]: 1951年01月16日 12:00:00 ----------------------------- This dataset, generated by one of the IPCC models, is password-protected, but could be a good target for decoding, since it is typical of a large class of climate models, that generate a lot of analytical activity. To get a password (they're free) one must register. Info is here: http://www-pcmdi.llnl.gov/ipcc/info_for_analysts.php. Follow "How to access..." then "Register to download output." Once you get a userid and password they can be inserted in the NetCDFFile call, voila. Note that there is a new iteration of IPCC coming down the pike; new model files to become widely available starting in 2010. ------------------------------ The underlying data is available via ftp. I fetched it and extracted a small slab, which is available at http://iri.columbia.edu/~amg/test/gfdl_test.nc. The CDAT package can digest this file; first time step is plotted here: http://iri.columbia.edu/~amg/test/gfdl_test_time0.png. The dates can also be read by this package, and run from Aug 1950 to Aug 1951, inclusive (13 mos). So the file does not seem to be garbage. In [16]: datobj = ncf('gfdl_test.nc') In [17]: timedata = datobj.variables['time'] In [18]: date0 = dt(1951,1,16,12,0,0) In [19]: nt0 = date2index(date0,timedata) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/amg/work/nhmm/<ipython console> in <module>() /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc in date2index(dates, nctime, calendar) 3931 Returns an index or a sequence of indices. 3932 """ -> 3933 return netcdftime.date2index(dates, nctime, calendar=None) 3934 3935 def maskoceans(lonsin,latsin,datain,inlands=False): /home/amg/usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc in date2index(dates, nctime, calendar, select) 1011 import bisect 1012 -> 1013 index = numpy.array([bisect.bisect_left(nctime, n) for n in num], int) 1014 1015 nomatch = num2date(nctime[index], nctime.units) != dates TypeError: object of type 'netcdf_variable' has no len() Investigating the time axis, In [20]: taxvals = timedata[:] In [21]: taxvals Out[21]: array([ 32712.5, 32743. , 32773.5, 32804. , 32834.5, 32865.5, 32895. , 32924.5, 32955. , 32985.5, 33016. , 33046.5, 33077.5]) In [22]: num2date(taxvals,timedata.units,timedata.calendar) Out[22]: array([1950年08月16日 12:00:00, 1950年09月16日 00:00:00, 1950年10月16日 12:00:00, 1950年11月16日 00:00:00, 1950年12月16日 12:00:00, 1951年01月16日 12:00:00, 1951年02月15日 00:00:00, 1951年03月16日 12:00:00, 1951年04月16日 00:00:00, 1951年05月16日 12:00:00, 1951年06月16日 00:00:00, 1951年07月16日 12:00:00, 1951年08月16日 12:00:00], dtype=object) Which agrees with what CDAT sees. ------------------------- I think this is enough for now. I also had problems opening data files whose time units were like "months since xxxx-xx-xx," since the "months" unit does not seem to be supported. ("years since..." could also be useful in some cases.) But maybe one or two things at a time is enough! Thanks for any assistance/advice! Best, Arthur Jeff Whitaker wrote: > David Huard wrote: >> Arthur, >> >> I wrote the date2index function and I think what you are seeing is a >> bug that I fixed a couple of months ago. By using the latest version >> of netcdf4-python, not only should this bug disappear, but you'll also >> find that date2index now supports different selection methods: >> 'exact', 'before', 'after', 'nearest', that should help with your use >> case. >> >> If this does not fix the problem you are seeing, I'd appreciate having >> a copy of the file and code to reproduce the problem and find a solution. >> >> HTH, >> >> David Huard > > Arthur: I've just updated basemap svn with David's latest version of > date2index, so another option is to update basemap from svn. Or, even > simpler, just drop the attached netcdftime.py file in > lib/mpl_toolkits/basemap (replacing the old one) and run python setup.py > install. > > -Jeff >> >> >> >> On Mon, Sep 7, 2009 at 9:27 AM, Arthur M. Greene <am...@ir... >> <mailto:am...@ir...>> wrote: >> >> Hi All, >> >> The problem is not with fetching the data slice itself, but >> finding the >> correct indices to specify, particularly with the time dimension. The >> below examples refer to a remote dataset that I can open and slice >> using >> indices, as in >> >> slice = remoteobj.variables['tas'][:120,20:40,30:50]. >> >> However, I have problems when trying to use the syntax in >> plotsst.py or >> pnganim.py (from the examples) to find time indices: >> >> In [107]: from datetime import datetime as dt >> In [108]: date0 = dt(1951,1,1,0) >> In [110]: print date0 >> 1951年01月01日 00:00:00 >> >> In [125]: timedata = remoteobj.variables['time'] >> In [126]: nt0 = date2index(date0,timedata) >> >> --------------------------------------------------------------------------- >> >> AssertionError Traceback (most recent >> call last) >> >> /home/amg/work/nhmm/<ipython console> in <module>() >> >> >> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc >> >> >> in date2index(dates, nctime, calendar) >> 3924 Returns an index or a sequence of indices. >> 3925 """ >> -> 3926 return netcdftime.date2index(dates, nctime, >> calendar=None) >> 3927 >> 3928 def maskoceans(lonsin,latsin,datain,inlands=False): >> >> >> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >> >> >> in date2index(dates, nctime, calendar) >> 986 >> 987 # Perform check again. >> --> 988 _check_index(index, dates, nctime, calendar) >> 989 >> 990 # convert numpy scalars or single element arrays to >> python >> ints. >> >> >> /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc >> >> >> in _check_index(indices, dates, nctime, calendar) >> 941 for n,i in enumerate(indices): >> 942 t[n] = nctime[i] >> --> 943 assert numpy.all( num2date(t, nctime.units, calendar) >> == dates) >> 944 >> 945 >> >> AssertionError: >> >> --------------------------------------------------------- >> >> It turns out that date0 corresponds best to index 1080: >> >> In [139]: remoteobj.variables['time'][1080] >> Out[139]: 32865.5 >> >> In [141]: num2date(32865.5,timedata.units,timedata.calendar) >> Out[141]: 1951年01月16日 12:00:00 >> >> This isn't the _exact_ date and time I had specified, but >> >> In [142]: date0 = dt(1951,01,16,12,00,00) >> In [143]: print date0 >> 1951年01月16日 12:00:00 >> >> In [144]: date2index(date0,timedata,timedata.calendar) >> >> produces the same AssertionError. Where is the problem? >> >> What I would _like_ to do is to issue a simple call using coordinates >> rather than the indices, of the form: >> >> slice = variable[date0:date1,[plev],lat0:lat1,lon0:lon1], >> >> or similar, preferably without writing a whole module just to find >> the >> correct indices. I need to fetch similar slices from a group of >> models, >> having time axes that may each be defined slightly differently -- >> different calendars, time point set at a different day of the month, >> etc. (It's monthly data and I'm specifying only monthly bounds, even >> though the calendar may be defined as "days since 1860...") I need to >> automate the process so I get back the correct slab regardless. >> >> Suggestions appreciated! >> >> Thx, >> >> Arthur >> >> >> *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* >> Arthur M. Greene, Ph.D. >> The International Research Institute for Climate and Society (IRI) >> The Earth Institute, Columbia University, Lamont Campus >> >> amg at iri dot columbia dot edu | http://iri.columbia.edu >> *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* >> >> >> >> ------------------------------------------------------------------------------ >> >> Let Crystal Reports handle the reporting - Free Crystal Reports >> 2008 30-Day >> trial. Simplify your report design, integration and deployment - >> and focus on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> <mailto:Mat...@li...> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> ------------------------------------------------------------------------ >> >> ------------------------------------------------------------------------------ >> >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day trial. Simplify your report design, integration and deployment >> - and focus on what you do best, core application coding. Discover >> what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> -- *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* Arthur M. Greene, Ph.D. The International Research Institute for Climate and Society (IRI) The Earth Institute, Columbia University, Lamont Campus Monell Building, 61 Route 9W, Palisades, NY 10964-8000 USA Tel: 845-680-4436 | Fax: 845-680-4865 am...@ir... | http://iri.columbia.edu *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*
On Wed, Sep 9, 2009 at 4:30 AM, Yann<ya...@al...> wrote: > I can not try your revision but I will do it as soon as it is released. > Nervertheless I try your snippet with an AxesZero. I get the gridlines > and the axis but the first was over the second. It is not what I expected. You can rearrange the order of artists by setting the zorder. > As far as I am concerned, I can wait until matplotlib next release. Just to clarify, the patch will be included in the 1.0 release, not the maintenance release of 0.99 version. Regards, -JJ > > Thanks, > > Yann > > On 09/08/2009 08:13 PM, Jae-Joon Lee wrote: >> On Tue, Sep 8, 2009 at 11:51 AM, Yann >> Goudard<mat...@al...> wrote: >> >>> Hi, >>> >>> I have the same behaviour with LocatableAxes. HostAxes, ParasiteAxes and >>> LocatableAxes depend on 'mpl_toolkits.axes_grid.axislines.Axes'. It must >>> be the matter origin. >>> >> Yes, and this was because I forgot to implement some necessary methods. >> This is now fixed in the svn trunk. So if you can,please give it a try. >> >> >>> This another example should draw a grid but does not: >>> >>> import wx >>> from wx import Frame >>> from matplotlib.backends.backend_wxagg import FigureFrameWxAgg, >>> FigureCanvasWxAgg >>> from matplotlib.figure import Figure >>> from mpl_toolkits.axes_grid.axes_divider import LocatableAxes >>> >>> fig = Figure((1, 1), 50) >>> axes = LocatableAxes(fig, [0, 0, 1, 1]) >>> # axes.toggle_axisline(False) >>> axes.grid(True) >>> fig.add_axes(axes) >>> >>> app = wx.PySimpleApp() >>> my_viewer = FigureFrameWxAgg(-1, fig) >>> my_viewer.Show() >>> app.MainLoop() >>> >>> If you uncomment axes.toggle_axisline(False), it works cause it uses >>> normal 'matplolib.axes.Axes' behaviour. It is not a matter for common >>> use but if you need 'AxesZero', this trick does not work. >>> >> What the toggle_axisline does is simply to make the xaxis and yaxis >> (which are responsible for drawing ticks, ticklabels, etc in the >> mainline mpl) visible again, and make axis["bottom"] and etc >> invisible. >> One workaround is to make xaxis and yaxis visible but pnly to draw the >> gridlines. Something like below. >> >> ax.toggle_axisline(True) >> ax.grid(True) >> ax.gridlines.set_visible(False) # this is just to make the code not to >> draw gridlines twice in future release of mpl. >> ax.xaxis.set_visible(True) >> ax.yaxis.set_visible(True) >> for t in ax.xaxis.majorTicks + ax.yaxis.majorTicks: >> t.gridOn = True >> t.tick1On = False >> t.tick2On = False >> t.label1On = False >> t.label2On = False >> >> Let me know if this does not work, or there is a case that this cannot be used. >> Regards, >> >> -JJ >> >> >> >>> Yann >>> >>> >>> On 09/07/2009 10:37 PM, Andreas Fromm wrote: >>> >>>> thanks Sebastian, >>>> >>>> you are right, your code works here too. But i don't get it work in my >>>> multi y-axes plot from the matplotlib examples >>>> (http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes.html). >>>> Even with linear plots, i get no gridlines. >>>> >>>> Any idea, whats wrong here? >>>> >>>> minimal code example: >>>> ####################### >>>> import matplotlib.pyplot as plt >>>> from mpl_toolkits.axes_grid.parasite_axes import HostAxes, ParasiteAxes >>>> >>>> fig = plt.figure(1) >>>> fig.clf() >>>> #plt.grid(True) >>>> host = HostAxes(fig, [0.15, 0.1, 0.65, 0.8]) >>>> fig.add_axes(host) >>>> >>>> host.plot([0, 10, 100], [0, 10, 100], label='host') >>>> >>>> host.grid(True) #? >>>> host.yaxis.grid(True) #? >>>> >>>> host.yaxis.set_scale('log') #? >>>> >>>> plt.draw() >>>> plt.show() >>>> ####################### >>>> >>>> Greets, >>>> Andreas >>>> >>>> >>>> Sebastian Busch schrieb: >>>> >>>> >>>>> from matplotlib.pyplot import * >>>>> >>>>> plot([1,10,100],[1,10,100]) >>>>> grid() >>>>> >>>>> yscale('log') >>>>> xscale('log') >>>>> >>>>> works here. >>>>> >>>>> best, >>>>> sebastian. >>>>> >>>>> >>>>> >>>> ------------------------------------------------------------------------------ >>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day >>>> trial. Simplify your report design, integration and deployment - and focus on >>>> what you do best, core application coding. Discover what's new with >>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>>> _______________________________________________ >>>> Matplotlib-users mailing list >>>> Mat...@li... >>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>> >>>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day >>> trial. Simplify your report design, integration and deployment - and focus on >>> what you do best, core application coding. Discover what's new with >>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
Hi, I think I found a bug, but I am not sure if it's in the doc or in a method name. In the doc, there is reference to a method *suptitle* in class mpl.figure.Figure. The name sounds strange, but the method exists and works. The example given, though, makes reference to *subtitle*, so either the example or the method name are wrong. Here's the link to the doc: http://matplotlib.sourceforge.net/api/figure_api.html?highlight=legend#matplotlib.figure.Figure.suptitle jorge
"Werner F. Bruhin" <wer...@fr...> writes: >> I am getting errors "TypeError: unsupported operand type(s) for +=: >> 'NoneType' and 'str'" in mlab.pyo after py2exe'd my application. I think this has been fixed on the trunk for good, by changing all docstring modifications to use decorators (defined in docstring.py) that check for nonexistent docstrings. The changes are perhaps too big to apply on the 0.99 branch. >> I changed it to: >> if psd.__doc__ is not None: >> psd.__doc__ = psd.__doc__ % kwdocd >> else: >> psd.__doc__ = "" >> >> Above is a bit of a hack, if someone can suggest how to correct this in >> a way which would get accepted as a patch I would search all modules >> correct them. I think either this or something like psd.__doc__ = psd.__doc__ and (psd.__doc__ % kwdocd) should be acceptable as a bugfix. -- Jouni K. Seppänen http://www.iki.fi/jks
Michael Droettboom <md...@st...> writes: > This change has gone into effect (for me at least on a Liux box). Can > anyone test Windows and Mac and report back? Using Firefox 3.5.2 on Mac OS X 10.5, the green download link points to matplotlib-0.99.0-py2.6-macosx10.5.dmg, and when I change my user agent header to Internet Explorer, to matplotlib-0.99.0.win32-py2.6.exe. -- Jouni K. Seppänen http://www.iki.fi/jks
Werner F. Bruhin wrote: > I have run into a bit of problem using 0.99 and py2exe. > > I am getting errors "TypeError: unsupported operand type(s) for +=: > 'NoneType' and 'str'" in mlab.pyo after py2exe'd my application. > > This is caused by this type of code, as one normally uses the optimize > option with py2exe which means that the docs are stripped from the .pyo > files. > "psd.__doc__ = psd.__doc__ % kwdocd" > > I changed it to: > if psd.__doc__ is not None: > psd.__doc__ = psd.__doc__ % kwdocd > else: > psd.__doc__ = "" > > Above is a bit of a hack, if someone can suggest how to correct this in > a way which would get accepted as a patch I would search all modules > correct them. > Maybe a nicer solution would be: if __debug__: psd.__doc__ = psd.__doc__ % kwdocd Also that would mean that above is not run when running Python as "python -O script.py or python -OO script.py where the first solution means that with -O the it would still be executed. Werner
This change has gone into effect (for me at least on a Liux box). Can anyone test Windows and Mac and report back? Cheers, Mike Michael Droettboom wrote: > I just went in and changed the default file downloads back to correct > values, but alas, it appears to have no effect. There is some hints in > the (many) related SF bugs that there may be a delay associated with > these settings, so I will check back again at the end of the day. > > Mike > > On 09/04/2009 05:46 AM, Fabrice Silva wrote: > >> Le jeudi 03 septembre 2009 à 20:16 -0500, John Hunter a écrit : >> >> >>> On Thu, Sep 3, 2009 at 8:04 PM, Alan G Isaac<ala...@gm...> wrote: >>> >>> >>>> The default download from the Matplotlib page >>>> link to http://sourceforge.net/projects/matplotlib/ >>>> which once again highlights basemap. (I think >>>> this was fixed at one point.) >>>> >>>> >>> I'm not seeng this, nor am I seeing basemap settings in the File >>> Manager which would trigger this. Of course, the default download is >>> platform specific, which may be why I am not seeing this, so please >>> give us as much info as possible about your platform (mainly the OS) >>> >>> When I click on the green download button at >>> http://sourceforge.net/projects/matplotlib using mac OSX 10.5, I get >>> redirected to the mpl 0.99 OSX download:: >>> >>> https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99/matplotlib-0.99.0-py2.5-macosx10.5.dmg/download >>> >>> >> Strangely, the green button points to >> http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99/matplotlib-0.99.0-py2.5-macosx-10.3-i386.egg/download >> when I browse on a linux (debian) machine with epiphany (which uses >> gecko, the firefox engine). Why macosx ? >> >> >> > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA
I have run into a bit of problem using 0.99 and py2exe. I am getting errors "TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'" in mlab.pyo after py2exe'd my application. This is caused by this type of code, as one normally uses the optimize option with py2exe which means that the docs are stripped from the .pyo files. "psd.__doc__ = psd.__doc__ % kwdocd" I changed it to: if psd.__doc__ is not None: psd.__doc__ = psd.__doc__ % kwdocd else: psd.__doc__ = "" Above is a bit of a hack, if someone can suggest how to correct this in a way which would get accepted as a patch I would search all modules correct them. Werner
Hi Giuseppe you can load your datafile with pylab... see my little function which i'm using import pylab as pl def readXY(filename): x,y,z = pl.load(filename, unpack=True) return x,y,z (X, Y, Z) = readXY("datafile.dat") after that you have your values in the arrays X;Y;Z kind regards Giuseppe Aprea wrote: > Hi list, > > I have some files with data stored in columns: > > x1 y1 z1 > x2 y2 z2 > x3 y3 z3 > x4 y4 z4 > x5 y5 z5 > ....... > > and I need to make a contour plot of this data using matplotlib. The > problem is that contour plot functions usually handle a different kind > of input: > > X=[[x1,x2,x3,x4,x5,x6], > [x1,x2,x3,x4,x5,x6], > [x1,x2,x3,x4,x5,x6],... > > Y=[[y1,y1,y1,y1,y1,y1], > [y2,y2,y2,y2,y2,y2], > [y3,y3,y3,y3,y3,y3],..... > > Z=[[z1,z2,z3,z4,z5,z6], > [z7,z8,zz9,z10,z11,z12],.... > > I usually load data using 3 lists: x, y and z; I wonder if there is > any function which is able to take these 3 lists and return the right > input for matplotlib functions. > > cheers > > giuseppe > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Hi list, I have some files with data stored in columns: x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4 x5 y5 z5 ....... and I need to make a contour plot of this data using matplotlib. The problem is that contour plot functions usually handle a different kind of input: X=[[x1,x2,x3,x4,x5,x6], [x1,x2,x3,x4,x5,x6], [x1,x2,x3,x4,x5,x6],... Y=[[y1,y1,y1,y1,y1,y1], [y2,y2,y2,y2,y2,y2], [y3,y3,y3,y3,y3,y3],..... Z=[[z1,z2,z3,z4,z5,z6], [z7,z8,zz9,z10,z11,z12],.... I usually load data using 3 lists: x, y and z; I wonder if there is any function which is able to take these 3 lists and return the right input for matplotlib functions. cheers giuseppe
I can not try your revision but I will do it as soon as it is released. Nervertheless I try your snippet with an AxesZero. I get the gridlines and the axis but the first was over the second. It is not what I expected. As far as I am concerned, I can wait until matplotlib next release. Thanks, Yann On 09/08/2009 08:13 PM, Jae-Joon Lee wrote: > On Tue, Sep 8, 2009 at 11:51 AM, Yann > Goudard<mat...@al...> wrote: > >> Hi, >> >> I have the same behaviour with LocatableAxes. HostAxes, ParasiteAxes and >> LocatableAxes depend on 'mpl_toolkits.axes_grid.axislines.Axes'. It must >> be the matter origin. >> > Yes, and this was because I forgot to implement some necessary methods. > This is now fixed in the svn trunk. So if you can,please give it a try. > > >> This another example should draw a grid but does not: >> >> import wx >> from wx import Frame >> from matplotlib.backends.backend_wxagg import FigureFrameWxAgg, >> FigureCanvasWxAgg >> from matplotlib.figure import Figure >> from mpl_toolkits.axes_grid.axes_divider import LocatableAxes >> >> fig = Figure((1, 1), 50) >> axes = LocatableAxes(fig, [0, 0, 1, 1]) >> # axes.toggle_axisline(False) >> axes.grid(True) >> fig.add_axes(axes) >> >> app = wx.PySimpleApp() >> my_viewer = FigureFrameWxAgg(-1, fig) >> my_viewer.Show() >> app.MainLoop() >> >> If you uncomment axes.toggle_axisline(False), it works cause it uses >> normal 'matplolib.axes.Axes' behaviour. It is not a matter for common >> use but if you need 'AxesZero', this trick does not work. >> > What the toggle_axisline does is simply to make the xaxis and yaxis > (which are responsible for drawing ticks, ticklabels, etc in the > mainline mpl) visible again, and make axis["bottom"] and etc > invisible. > One workaround is to make xaxis and yaxis visible but pnly to draw the > gridlines. Something like below. > > ax.toggle_axisline(True) > ax.grid(True) > ax.gridlines.set_visible(False) # this is just to make the code not to > draw gridlines twice in future release of mpl. > ax.xaxis.set_visible(True) > ax.yaxis.set_visible(True) > for t in ax.xaxis.majorTicks + ax.yaxis.majorTicks: > t.gridOn = True > t.tick1On = False > t.tick2On = False > t.label1On = False > t.label2On = False > > Let me know if this does not work, or there is a case that this cannot be used. > Regards, > > -JJ > > > >> Yann >> >> >> On 09/07/2009 10:37 PM, Andreas Fromm wrote: >> >>> thanks Sebastian, >>> >>> you are right, your code works here too. But i don't get it work in my >>> multi y-axes plot from the matplotlib examples >>> (http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes.html). >>> Even with linear plots, i get no gridlines. >>> >>> Any idea, whats wrong here? >>> >>> minimal code example: >>> ####################### >>> import matplotlib.pyplot as plt >>> from mpl_toolkits.axes_grid.parasite_axes import HostAxes, ParasiteAxes >>> >>> fig = plt.figure(1) >>> fig.clf() >>> #plt.grid(True) >>> host = HostAxes(fig, [0.15, 0.1, 0.65, 0.8]) >>> fig.add_axes(host) >>> >>> host.plot([0, 10, 100], [0, 10, 100], label='host') >>> >>> host.grid(True) #? >>> host.yaxis.grid(True) #? >>> >>> host.yaxis.set_scale('log') #? >>> >>> plt.draw() >>> plt.show() >>> ####################### >>> >>> Greets, >>> Andreas >>> >>> >>> Sebastian Busch schrieb: >>> >>> >>>> from matplotlib.pyplot import * >>>> >>>> plot([1,10,100],[1,10,100]) >>>> grid() >>>> >>>> yscale('log') >>>> xscale('log') >>>> >>>> works here. >>>> >>>> best, >>>> sebastian. >>>> >>>> >>>> >>> ------------------------------------------------------------------------------ >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day >>> trial. Simplify your report design, integration and deployment - and focus on >>> what you do best, core application coding. Discover what's new with >>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >> >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day >> trial. Simplify your report design, integration and deployment - and focus on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >>
On 9/8/2009 1:39 PM, Watson, Nathaniel wrote: > I am running Windows Vista 64-bit and have installed matplotlib from > http://sourceforge.net/projects/matplotlib/ via the "Download Now!". What is the name of the file you downloaded? Alan Isaac