[Yt-svn] yt: 2 new changesets
hg at spacepope.org
hg at spacepope.org
Mon Sep 13 21:29:17 PDT 2010
hg Repository: yt
details: yt/rev/7ef2c5d79e9f
changeset: 3398:7ef2c5d79e9f
user: Matthew Turk <matthewturk at gmail.com>
date:
Sun Sep 12 23:15:57 2010 -0700
description:
Adding function dapload to load projections from a DAP server.
For more information, see
http://www.opendap.org/
http://pydap.org/2.x/
hg Repository: yt
details: yt/rev/d448849e70a4
changeset: 3399:d448849e70a4
user: Matthew Turk <matthewturk at gmail.com>
date:
Mon Sep 13 21:29:07 2010 -0700
description:
Merging
diffstat:
yt/convenience.py | 75 +++++++++++++++++++++++++++++++++++++
yt/visualization/plot_types.py | 2 +-
2 files changed, 76 insertions(+), 1 deletions(-)
diffs (94 lines):
diff -r 5459185dfb49 -r d448849e70a4 yt/convenience.py
--- a/yt/convenience.py Sat Sep 11 02:10:23 2010 -0700
+++ b/yt/convenience.py Mon Sep 13 21:29:07 2010 -0700
@@ -105,3 +105,78 @@
proj.axis = axis
proj.pf = pf
return proj
+
+def _chunk(arrlike, chunksize = 800000):
+ total_size = arrlike.shape[0]
+ pbar = get_pbar("Transferring %s " % (arrlike.name), total_size)
+ start = 0; end = 0
+ bits = []
+ while start < total_size:
+ bits.append(arrlike[start:start+chunksize])
+ pbar.update(start)
+ start += chunksize
+ pbar.finish()
+ return na.concatenate(bits)
+
+def dapload(p, axis, weight_field = None):
+ r"""Load a projection dataset from a DAP server.
+
+ If you have projections stored externally on a DAP server, this function
+ can load them (transferring in chunks to avoid overloading) locally and
+ display them.
+
+ Parameters
+ ----------
+ p : string
+ URL for the dataset on the DAP server
+ axis : int
+ The axis of projection to load (0, 1, 2)
+ weight_field : string
+ The weight_field used in the projection
+
+ Returns
+ -------
+ projmock : ProjMock
+ This is a mockup of a projection that mostly fills the API. It can be
+ used with `yt.visualization.image_panner.api.VariableMeshPanner`
+ objects.
+
+ See Also
+ --------
+ http://www.opendap.org/ and http://pydap.org/2.x/ . (Note that HDF5 is not
+ supported on PyDAP 3.x servers.)
+
+ Examples
+ --------
+
+ >>> p = "http://datasets-r-us.org/output_0013.h5"
+ >>> proj = dapload(p, 0, "Density")
+ >>> vmp = VariableMeshPanner(proj, (512, 512), "Density", ImageSaver(0))
+ >>> vmp.zoom(1.0)
+ """
+ class PFMock(dict):
+ domain_left_edge = na.zeros(3, dtype='float64')
+ domain_right_edge = na.ones(3, dtype='float64')
+ pf = PFMock()
+ class ProjMock(dict):
+ pass
+ import dap.client
+ f = dap.client.open(p)
+ b = f["Projections"]["%s" % (axis)]
+ wf = "weight_field_%s" % weight_field
+ if wf not in b: raise KeyError(wf)
+ fields = []
+ for k in b:
+ if k.name.startswith("weight_field"): continue
+ if k.name.endswith("_%s" % weight_field):
+ fields.append(k.name)
+ proj = ProjMock()
+ for f in ["px","py","pdx","pdy"]:
+ proj[f] = _chunk(b[f])
+ for f in fields:
+ new_name = f[:-(len(str(weight_field)) + 1)]
+ proj[new_name] = _chunk(b[f])
+ proj.axis = axis
+ proj.pf = pf
+ return proj
+
diff -r 5459185dfb49 -r d448849e70a4 yt/visualization/plot_types.py
--- a/yt/visualization/plot_types.py Sat Sep 11 02:10:23 2010 -0700
+++ b/yt/visualization/plot_types.py Mon Sep 13 21:29:07 2010 -0700
@@ -216,7 +216,7 @@
self.colorbar.locator = self._old_locator
if hasattr(self,'_old_formatter'):
self.colorbar.formatter = self._old_formatter
- self.norm.autoscale(na.array([zmin,zmax], dype='float64'))
+ self.norm.autoscale(na.array([zmin,zmax], dtype='float64'))
self.image.changed()
if self.colorbar is not None:
mpl_notify(self.image, self.colorbar)
More information about the yt-svn
mailing list