Revision: 6807
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6807&view=rev
Author: jswhit
Date: 2009-01-19 15:08:56 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
update to version 1.0.8
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py 2009-01-18
00:12:15 UTC (rev 6806)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py 2009-01-19
15:08:56 UTC (rev 6807)
@@ -77,7 +77,8 @@
from operator import mul
from mmap import mmap, ACCESS_READ
-from numpy import fromstring, ndarray, dtype, empty, array, asarray, squeeze,
zeros, ma
+from numpy import fromstring, ndarray, dtype, empty, array, asarray, squeeze,\
+ zeros, ma
from numpy import little_endian as LITTLE_ENDIAN
@@ -127,9 +128,11 @@
attribute of the ``netcdf_file`` object.
"""
- def __init__(self, filename, mode='r', mmap=True, maskandscale=False):
+ def __init__(self, filename, mode='r', mmap=True, version=1,\
+ maskandscale=False):
self.filename = filename
self.use_mmap = mmap
+ self.version_byte = version
self._maskandscale = maskandscale
assert mode in 'rw', "Mode must be either 'r' or 'w'."
@@ -180,7 +183,8 @@
if size > 1: dtype_ += str(size)
data = empty(shape_, dtype=dtype_)
- self.variables[name] = netcdf_variable(data, typecode, shape,
dimensions, maskandscale=self._maskandscale)
+ self.variables[name] = netcdf_variable(data, typecode, shape,\
+ dimensions, maskandscale=self._maskandscale)
return self.variables[name]
def flush(self):
@@ -190,10 +194,8 @@
def _write(self):
self.fp.write('CDF')
+ self.fp.write(array(self.version_byte, '>b').tostring())
- self.__dict__['version_byte'] = 1
- self.fp.write(array(1, '>b').tostring())
-
# Write headers and data.
self._write_numrecs()
self._write_dim_array()
@@ -347,7 +349,8 @@
def _read(self):
# Check magic bytes and version
- assert self.fp.read(3) == 'CDF', "Error: %s is not a valid NetCDF 3
file" % self.filename
+ magic = self.fp.read(3)
+ assert magic == 'CDF', "Error: %s is not a valid NetCDF 3 file" %
self.filename
self.__dict__['version_byte'] = fromstring(self.fp.read(1), '>b')[0]
# Read file headers and set data.
@@ -360,7 +363,8 @@
self.__dict__['_recs'] = self._unpack_int()
def _read_dim_array(self):
- assert self.fp.read(4) in [ZERO, NC_DIMENSION]
+ header = self.fp.read(4)
+ assert header in [ZERO, NC_DIMENSION]
count = self._unpack_int()
for dim in range(count):
@@ -374,7 +378,8 @@
self.__setattr__(k, v)
def _read_att_array(self):
- assert self.fp.read(4) in [ZERO, NC_ATTRIBUTE]
+ header = self.fp.read(4)
+ assert header in [ZERO, NC_ATTRIBUTE]
count = self._unpack_int()
attributes = {}
@@ -384,7 +389,8 @@
return attributes
def _read_var_array(self):
- assert self.fp.read(4) in [ZERO, NC_VARIABLE]
+ header = self.fp.read(4)
+ assert header in [ZERO, NC_VARIABLE]
begin = 0
dtypes = {'names': [], 'formats': []}
@@ -423,7 +429,8 @@
# Add variable.
self.variables[name] = netcdf_variable(
- data, typecode, shape, dimensions, attributes,
maskandscale=self._maskandscale)
+ data, typecode, shape, dimensions, attributes,
+ maskandscale=self._maskandscale)
if rec_vars:
# Remove padding when only one record variable.
@@ -544,7 +551,8 @@
attribute of the ``netcdf_variable`` object.
"""
- def __init__(self, data, typecode, shape, dimensions, attributes=None,
maskandscale=False):
+ def __init__(self, data, typecode, shape, dimensions, attributes=None,\
+ maskandscale=False):
self.data = data
self._typecode = typecode
self._shape = shape
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins