[yt-svn] commit/yt: 10 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sat Jun 25 17:17:53 PDT 2016
10 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/657c07606909/
Changeset: 657c07606909
Branch: yt
User: 0x414A
Date: 2016-06-20 17:33:51+00:00
Summary: Put metadata extraction code into its own module
Affected #: 1 file
diff -r 88532ec0be1dac57a7c5bc2a7e6f4f22e39162a1 -r 657c07606909b5af2edd67b0406fed0b367940f5 yt/utilities/metadata.py
--- /dev/null
+++ b/yt/utilities/metadata.py
@@ -0,0 +1,32 @@
+from yt.convenience import load
+from yt.utilities.parameter_file_storage import \
+ output_type_registry
+from yt.utilities.exceptions import \
+ YTOutputNotIdentified
+
+DEFAULT_ATTRS = ("dimensionality", "refine_by", "domain_dimensions",
+ "current_time", "domain_left_edge", "domain_right_edge",
+ "unique_identifier", "current_redshift",
+ "cosmological_simulation", "omega_matter", "omega_lambda",
+ "hubble_constant", "dataset_type")
+
+
+def get_metadata(path, full_output=False, attrs=DEFAULT_ATTRS):
+ ds = load(path)
+ metadata = {'filename': path}
+ for a in attrs:
+ v = getattr(ds, a, None)
+ if v is None:
+ continue
+ if hasattr(v, "tolist"):
+ v = v.tolist()
+ metadata[a] = v
+ if full_output:
+ params = {}
+ for p, v in ds.parameters.items():
+ if hasattr(v, "tolist"):
+ v = v.tolist()
+ params[p] = v
+ metadata['params'] = params
+ ds.close()
+ return metadata
https://bitbucket.org/yt_analysis/yt/commits/a500a9098b1c/
Changeset: a500a9098b1c
Branch: yt
User: 0x414A
Date: 2016-06-20 17:37:38+00:00
Summary: Use metadata code
Affected #: 1 file
diff -r 657c07606909b5af2edd67b0406fed0b367940f5 -r a500a9098b1ce4ddb4fbc769cf852b32fbaf3b9f yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -43,6 +43,7 @@
from yt.visualization.plot_window import \
SlicePlot, \
ProjectionPlot
+from yt.utilities.metadata import get_metadata
from yt.utilities.exceptions import \
YTOutputNotIdentified
@@ -1150,11 +1151,6 @@
def __call__(self, args):
from yt.utilities.parameter_file_storage import \
output_type_registry
- attrs = ("dimensionality", "refine_by", "domain_dimensions",
- "current_time", "domain_left_edge", "domain_right_edge",
- "unique_identifier", "current_redshift",
- "cosmological_simulation", "omega_matter", "omega_lambda",
- "hubble_constant", "dataset_type")
candidates = []
for base, dirs, files in os.walk(".", followlinks=True):
print("(% 10i candidates) Examining %s" % (len(candidates), base))
@@ -1173,26 +1169,10 @@
for i, c in enumerate(sorted(candidates)):
print("(% 10i/% 10i) Evaluating %s" % (i, len(candidates), c))
try:
- ds = load(c)
+ record = get_metadata(c)
except YTOutputNotIdentified:
continue
- record = {'filename': c}
- for a in attrs:
- v = getattr(ds, a, None)
- if v is None:
- continue
- if hasattr(v, "tolist"):
- v = v.tolist()
- record[a] = v
- if args.full_output:
- params = {}
- for p, v in ds.parameters.items():
- if hasattr(v, "tolist"):
- v = v.tolist()
- params[p] = v
- record['params'] = params
records.append(record)
- ds.close()
with open(args.output, "w") as f:
json.dump(records, f, indent=4)
print("Identified %s records output to %s" % (
https://bitbucket.org/yt_analysis/yt/commits/1aec3591d446/
Changeset: 1aec3591d446
Branch: yt
User: 0x414A
Date: 2016-06-20 17:43:57+00:00
Summary: Specify option to retrieve full output
Affected #: 1 file
diff -r a500a9098b1ce4ddb4fbc769cf852b32fbaf3b9f -r 1aec3591d446376be415f97423bc5c30e3223dba yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -1169,7 +1169,7 @@
for i, c in enumerate(sorted(candidates)):
print("(% 10i/% 10i) Evaluating %s" % (i, len(candidates), c))
try:
- record = get_metadata(c)
+ record = get_metadata(c, args.full_output)
except YTOutputNotIdentified:
continue
records.append(record)
https://bitbucket.org/yt_analysis/yt/commits/8b907b75530d/
Changeset: 8b907b75530d
Branch: yt
User: 0x414A
Date: 2016-06-21 16:02:32+00:00
Summary: Remove unused import
Affected #: 1 file
diff -r 1aec3591d446376be415f97423bc5c30e3223dba -r 8b907b75530d5f5ab67806cf8b5ac0c9244ad86d yt/utilities/metadata.py
--- a/yt/utilities/metadata.py
+++ b/yt/utilities/metadata.py
@@ -1,6 +1,4 @@
from yt.convenience import load
-from yt.utilities.parameter_file_storage import \
- output_type_registry
from yt.utilities.exceptions import \
YTOutputNotIdentified
https://bitbucket.org/yt_analysis/yt/commits/9f2207f01bf5/
Changeset: 9f2207f01bf5
Branch: yt
User: 0x414A
Date: 2016-06-21 17:59:04+00:00
Summary: Remove unused imports (at flake8's beckoning)
Affected #: 1 file
diff -r 8b907b75530d5f5ab67806cf8b5ac0c9244ad86d -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 yt/utilities/metadata.py
--- a/yt/utilities/metadata.py
+++ b/yt/utilities/metadata.py
@@ -1,6 +1,4 @@
from yt.convenience import load
-from yt.utilities.exceptions import \
- YTOutputNotIdentified
DEFAULT_ATTRS = ("dimensionality", "refine_by", "domain_dimensions",
"current_time", "domain_left_edge", "domain_right_edge",
https://bitbucket.org/yt_analysis/yt/commits/4f07f691a811/
Changeset: 4f07f691a811
Branch: yt
User: 0x414A
Date: 2016-06-22 17:35:30+00:00
Summary: Merge upstream
Affected #: 14 files
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d setup.cfg
--- a/setup.cfg
+++ b/setup.cfg
@@ -14,6 +14,6 @@
# unused import errors
# autogenerated __config__.py files
# vendored libraries
-exclude = */api.py,*/__init__.py,*/__config__.py,yt/visualization/_mpl_imports.py,yt/utilities/lodgeit.py,yt/utilities/lru_cache.py,yt/utilities/poster/*,yt/extern/*,yt/mods.py
+exclude = doc,benchmarks,*/api.py,*/__init__.py,*/__config__.py,yt/visualization/_mpl_imports.py,yt/utilities/lodgeit.py,yt/utilities/lru_cache.py,yt/utilities/poster/*,yt/extern/*,yt/mods.py
max-line-length=999
ignore = E111,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E201,E202,E211,E221,E222,E227,E228,E241,E301,E203,E225,E226,E231,E251,E261,E262,E265,E266,E302,E303,E402,E502,E701,E703,E731,W291,W292,W293,W391,W503
\ No newline at end of file
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d setup.py
--- a/setup.py
+++ b/setup.py
@@ -216,9 +216,6 @@
depends=glob.glob("yt/frontends/artio/artio_headers/*.c")),
Extension("yt.utilities.spatial._distance_wrap",
glob.glob("yt/utilities/spatial/src/*.c")),
- Extension("yt.visualization._MPL",
- ["yt/visualization/_MPL.c"],
- libraries=std_libs),
]
# EMBREE
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d tests/tests.yaml
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -14,7 +14,7 @@
local_fits_000:
- yt/frontends/fits/tests/test_outputs.py
- local_flash_001:
+ local_flash_002:
- yt/frontends/flash/tests/test_outputs.py
local_gadget_000:
@@ -39,7 +39,7 @@
local_owls_000:
- yt/frontends/owls/tests/test_outputs.py
- local_pw_000:
+ local_pw_001:
- yt/visualization/tests/test_plotwindow.py:test_attributes
- yt/visualization/tests/test_plotwindow.py:test_attributes_wt
- yt/visualization/tests/test_profile_plots.py:test_phase_plot_attributes
@@ -47,7 +47,7 @@
- yt/visualization/tests/test_particle_plot.py:test_particle_projection_filter
- yt/visualization/tests/test_particle_plot.py:test_particle_phase_answers
- local_tipsy_000:
+ local_tipsy_001:
- yt/frontends/tipsy/tests/test_outputs.py
local_varia_001:
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d yt/data_objects/tests/test_covering_grid.py
--- a/yt/data_objects/tests/test_covering_grid.py
+++ b/yt/data_objects/tests/test_covering_grid.py
@@ -1,7 +1,10 @@
import numpy as np
+from yt import \
+ load
from yt.frontends.stream.data_structures import load_particles
from yt.testing import \
+ requires_file, \
fake_random_ds, \
assert_equal, \
assert_almost_equal
@@ -120,3 +123,11 @@
ag = ds.arbitrary_grid([0.0, 0.0, 0.0], [1.0, 1.0, 1.0],
2**ref_level * ds.domain_dimensions)
yield assert_almost_equal, cg["density"], ag["density"]
+
+output_00080 = "output_00080/info_00080.txt"
+ at requires_file(output_00080)
+def test_octree_cg():
+ ds = load(output_00080)
+ cgrid = ds.covering_grid(0, left_edge=ds.domain_left_edge, dims=ds.domain_dimensions)
+ density_field = cgrid["density"]
+ assert_equal((density_field == 0.0).sum(), 0)
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d yt/geometry/coordinates/cartesian_coordinates.py
--- a/yt/geometry/coordinates/cartesian_coordinates.py
+++ b/yt/geometry/coordinates/cartesian_coordinates.py
@@ -23,9 +23,9 @@
cylindrical_to_cartesian
from yt.funcs import mylog
from yt.utilities.lib.pixelization_routines import \
- pixelize_element_mesh, pixelize_off_axis_cartesian
+ pixelize_element_mesh, pixelize_off_axis_cartesian, \
+ pixelize_cartesian
from yt.data_objects.unstructured_mesh import SemiStructuredMesh
-import yt.visualization._MPL as _MPL
class CartesianCoordinateHandler(CoordinateHandler):
@@ -128,7 +128,7 @@
period[1] = self.period[self.y_axis[dim]]
if hasattr(period, 'in_units'):
period = period.in_units("code_length").d
- buff = _MPL.Pixelize(data_source['px'], data_source['py'],
+ buff = pixelize_cartesian(data_source['px'], data_source['py'],
data_source['pdx'], data_source['pdy'],
data_source[field], size[0], size[1],
bounds, int(antialias),
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d yt/geometry/coordinates/cylindrical_coordinates.py
--- a/yt/geometry/coordinates/cylindrical_coordinates.py
+++ b/yt/geometry/coordinates/cylindrical_coordinates.py
@@ -21,9 +21,8 @@
_get_coord_fields, \
cylindrical_to_cartesian, \
cartesian_to_cylindrical
-import yt.visualization._MPL as _MPL
from yt.utilities.lib.pixelization_routines import \
- pixelize_cylinder
+ pixelize_cartesian, pixelize_cylinder
#
# Cylindrical fields
#
@@ -114,11 +113,11 @@
period[1] = self.period[self.y_axis[dim]]
if hasattr(period, 'in_units'):
period = period.in_units("code_length").d
- buff = _MPL.Pixelize(data_source['px'], data_source['py'],
- data_source['pdx'], data_source['pdy'],
- data_source[field], size[0], size[1],
- bounds, int(antialias),
- period, int(periodic)).transpose()
+ buff = pixelize_cartesian(data_source['px'], data_source['py'],
+ data_source['pdx'], data_source['pdy'],
+ data_source[field], size[0], size[1],
+ bounds, int(antialias),
+ period, int(periodic)).transpose()
return buff
def _cyl_pixelize(self, data_source, field, bounds, size, antialias):
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d yt/geometry/particle_deposit.pyx
--- a/yt/geometry/particle_deposit.pyx
+++ b/yt/geometry/particle_deposit.pyx
@@ -329,6 +329,11 @@
cdef np.float64_t[:,:,:,:] field
cdef public object ofield
def initialize(self):
+ if not all(_ > 1 for _ in self.nvals):
+ from yt.utilities.exceptions import YTBoundsDefinitionError
+ raise YTBoundsDefinitionError(
+ "CIC requires minimum of 2 zones in all dimensions",
+ self.nvals)
self.field = append_axes(
np.zeros(self.nvals, dtype="float64", order='F'), 4)
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -239,7 +239,9 @@
spos[2] = pos[2] - sdds[2]/2.0
for k in range(2):
ch = NULL
- if root.children != NULL:
+ # We only supply a child if we are actually going to
+ # look at the next level.
+ if root.children != NULL and next_level == 1:
ch = root.children[cind(i, j, k)]
if iter == 1 and next_level == 1 and ch != NULL:
# Note that visitor.pos is always going to be the
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d yt/geometry/tests/test_particle_deposit.py
--- /dev/null
+++ b/yt/geometry/tests/test_particle_deposit.py
@@ -0,0 +1,14 @@
+from yt.utilities.exceptions import \
+ YTBoundsDefinitionError
+
+from yt.testing import \
+ fake_random_ds
+from numpy.testing import \
+ assert_raises
+
+def test_cic_deposit():
+ ds = fake_random_ds(64, nprocs = 8, particles=64**3)
+ my_reg = ds.arbitrary_grid(ds.domain_left_edge, ds.domain_right_edge,
+ dims=[1, 800, 800])
+ f = ("deposit", "all_cic")
+ assert_raises(YTBoundsDefinitionError, my_reg.__getitem__, f)
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -568,3 +568,14 @@
v = "This operation is not supported for data of geometry %s; " % self.this
v += "It supports data of geometries %s" % (self.supported,)
return v
+
+class YTBoundsDefinitionError(YTException):
+ def __init__(self, message, bounds):
+ self.bounds = bounds
+ self.message = message
+
+ def __str__(self):
+ v = "This operation has encountered a bounds error: "
+ v += self.message
+ v += " Specified bounds are %s" % self.bounds
+ return v
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d yt/utilities/lib/pixelization_routines.pyx
--- a/yt/utilities/lib/pixelization_routines.pyx
+++ b/yt/utilities/lib/pixelization_routines.pyx
@@ -191,6 +191,14 @@
overlap1 = ((fmin(rxpx, xsp+dxsp)
- fmax(lxpx, (xsp-dxsp)))*ipx_dx)
if overlap1 < 0.0: continue
+ # This next line is not commented out because
+ # it's an oddity; we actually want to skip
+ # depositing if the overlap is zero, and that's
+ # how it used to work when we were more
+ # conservative about the iteration indices.
+ # This will reduce artifacts if we ever move to
+ # compositing instead of replacing bitmaps.
+ if overlap1 * overlap2 == 0.0: continue
my_array[j,i] += (dsp * overlap1) * overlap2
else:
my_array[j,i] = dsp
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d yt/visualization/_MPL.c
--- a/yt/visualization/_MPL.c
+++ /dev/null
@@ -1,491 +0,0 @@
-/*******************************************************************************
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-*******************************************************************************/
-//
-// _MPL
-// A module for making static-resolution arrays representing
-// AMR data.
-//
-
-#include "Python.h"
-
-#include <stdio.h>
-#include <math.h>
-#include <signal.h>
-#include <ctype.h>
-
-#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
-#include "numpy/ndarrayobject.h"
-
-#define min(X,Y) ((X) < (Y) ? (X) : (Y))
-#define max(X,Y) ((X) > (Y) ? (X) : (Y))
-
-static PyObject *_pixelizeError;
-
-char _pixelizeDocstring[] =
-"Returns a static-resolution pixelized version of AMR data.\n\n"
-"@parameter xp: ndarray of x centers\n"
-"@Parameter yp: ndarray of y centers\n"
-"@parameter dxp: ndarray of x half-widths\n"
-"@parameter dyp: ndarray of y half-widths\n"
-"@parameter dp: ndarray of data\n"
-"@parameter rows: number of pixel rows\n"
-"@parameter cols: number of pixel columns\n"
-"@parameter bounds: (x_min, x_max, y_min, y_max)";
-
-static PyObject* Py_Pixelize(PyObject *obj, PyObject *args) {
-
- PyObject *xp, *yp, *dxp, *dyp, *dp;
- PyArrayObject *x, *y, *dx, *dy, *d;
- unsigned int rows, cols;
- int antialias = 1;
- double x_min, x_max, y_min, y_max;
- double period_x, period_y;
- int check_period = 1, nx;
- int i, j, p, xi, yi;
- double lc, lr, rc, rr;
- double lypx, rypx, lxpx, rxpx, overlap1, overlap2;
- npy_float64 oxsp, oysp, xsp, ysp, dxsp, dysp, dsp;
- int xiter[2], yiter[2];
- double xiterv[2], yiterv[2];
- npy_intp dims[2];
- PyArrayObject *my_array;
- double width, height, px_dx, px_dy, ipx_dx, ipx_dy;
- PyObject *return_value;
-
- xp = yp = dxp = dyp = dp = NULL;
- x = y = dx = dy = d = NULL;
-
- period_x = period_y = 0;
-
- if (!PyArg_ParseTuple(args, "OOOOOII(dddd)|i(dd)i",
- &xp, &yp, &dxp, &dyp, &dp, &cols, &rows,
- &x_min, &x_max, &y_min, &y_max,
- &antialias, &period_x, &period_y, &check_period))
- return PyErr_Format(_pixelizeError, "Pixelize: Invalid Parameters.");
-
- width = x_max - x_min;
- height = y_max - y_min;
- px_dx = width / ((double) rows);
- px_dy = height / ((double) cols);
- ipx_dx = 1.0 / px_dx;
- ipx_dy = 1.0 / px_dy;
-
- // Check we have something to output to
- if (rows == 0 || cols ==0)
- PyErr_Format( _pixelizeError, "Cannot scale to zero size.");
-
- // Get numeric arrays
- x = (PyArrayObject *) PyArray_FromAny(xp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if (x == NULL) {
- PyErr_Format( _pixelizeError, "x is of incorrect type (wanted 1D float)");
- goto _fail;
- }
-
- y = (PyArrayObject *) PyArray_FromAny(yp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((y == NULL) || (PyArray_SIZE(y) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "y is of incorrect type (wanted 1D float)");
- goto _fail;
- }
-
- d = (PyArrayObject *) PyArray_FromAny(dp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((d == NULL) || (PyArray_SIZE(d) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "data is of incorrect type (wanted 1D float)");
- goto _fail;
- }
-
- dx = (PyArrayObject *) PyArray_FromAny(dxp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((dx == NULL) || (PyArray_SIZE(dx) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "dx is of incorrect type (wanted 1D float)");
- goto _fail;
- }
- dy = (PyArrayObject *) PyArray_FromAny(dyp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((dy == NULL) || (PyArray_SIZE(dy) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "dy is of incorrect type (wanted 1D float)");
- goto _fail;
- }
-
- // Check dimensions match
- nx = PyArray_DIMS(x)[0];
-
- // Calculate the pointer arrays to map input x to output x
-
- dims[0] = rows;
- dims[1] = cols;
- my_array =
- (PyArrayObject *) PyArray_SimpleNewFromDescr(2, dims,
- PyArray_DescrFromType(NPY_FLOAT64));
- //npy_float64 *gridded = (npy_float64 *) my_array->data;
-
- xiter[0] = yiter[0] = 0;
- xiterv[0] = yiterv[0] = 0.0;
-
- Py_BEGIN_ALLOW_THREADS
- for(i=0;i<rows;i++)for(j=0;j<cols;j++)
- *(npy_float64*) PyArray_GETPTR2(my_array, i, j) = 0.0;
- for(p=0;p<nx;p++)
- {
- // these are cell-centered
- oxsp = *((npy_float64 *)PyArray_GETPTR1(x, p));
- oysp = *((npy_float64 *)PyArray_GETPTR1(y, p));
- // half-width
- dxsp = *((npy_float64 *)PyArray_GETPTR1(dx, p));
- dysp = *((npy_float64 *)PyArray_GETPTR1(dy, p));
- dsp = *((npy_float64 *)PyArray_GETPTR1(d, p));
- xiter[1] = yiter[1] = 999;
- if(check_period == 1) {
- if (oxsp - dxsp < x_min) {xiter[1] = +1; xiterv[1] = period_x;}
- else if (oxsp + dxsp > x_max) {xiter[1] = -1; xiterv[1] = -period_x;}
- if (oysp - dysp < y_min) {yiter[1] = +1; yiterv[1] = period_y;}
- else if (oysp + dysp > y_max) {yiter[1] = -1; yiterv[1] = -period_y;}
- }
- overlap1 = overlap2 = 1.0;
- for(xi = 0; xi < 2; xi++) {
- if(xiter[xi] == 999)continue;
- xsp = oxsp + xiterv[xi];
- if((xsp+dxsp<x_min) || (xsp-dxsp>x_max)) continue;
- for(yi = 0; yi < 2; yi++) {
- if(yiter[yi] == 999)continue;
- ysp = oysp + yiterv[yi];
- if((ysp+dysp<y_min) || (ysp-dysp>y_max)) continue;
- lc = max(((xsp-dxsp-x_min)*ipx_dx),0);
- lr = max(((ysp-dysp-y_min)*ipx_dy),0);
- rc = min(((xsp+dxsp-x_min)*ipx_dx), rows);
- rr = min(((ysp+dysp-y_min)*ipx_dy), cols);
- for (i=lr;i<rr;i++) {
- lypx = px_dy * i + y_min;
- rypx = px_dy * (i+1) + y_min;
- if (antialias == 1) {
- overlap2 = ((min(rypx, ysp+dysp) - max(lypx, (ysp-dysp)))*ipx_dy);
- }
- if (overlap2 < 0.0) continue;
- for (j=lc;j<rc;j++) {
- lxpx = px_dx * j + x_min;
- rxpx = px_dx * (j+1) + x_min;
- if (antialias == 1) {
- overlap1 = ((min(rxpx, xsp+dxsp) - max(lxpx, (xsp-dxsp)))*ipx_dx);
- }
- if (overlap1 < 0.0) continue;
- if (antialias == 1)
- *(npy_float64*) PyArray_GETPTR2(my_array, j, i) +=
- (dsp*overlap1)*overlap2;
- else *(npy_float64*) PyArray_GETPTR2(my_array, j, i) = dsp;
- }
- }
- }
- }
- }
- Py_END_ALLOW_THREADS
-
- // Attatch output buffer to output buffer
-
- Py_DECREF(x);
- Py_DECREF(y);
- Py_DECREF(d);
- Py_DECREF(dx);
- Py_DECREF(dy);
-
- return_value = Py_BuildValue("N", my_array);
-
- return return_value;
-
- _fail:
-
- if(x!=NULL)Py_XDECREF(x);
- if(y!=NULL)Py_XDECREF(y);
- if(d!=NULL)Py_XDECREF(d);
- if(dx!=NULL)Py_XDECREF(dx);
- if(dy!=NULL)Py_XDECREF(dy);
- return NULL;
-
-}
-
-static PyObject* Py_CPixelize(PyObject *obj, PyObject *args) {
-
- PyObject *xp, *yp, *zp, *pxp, *pyp,
- *dxp, *dyp, *dzp, *dp,
- *centerp, *inv_matp, *indicesp;
- PyArrayObject *x, *y, *z, *px, *py, *d,
- *dx, *dy, *dz, *center, *inv_mat, *indices;
- unsigned int rows, cols;
- double px_min, px_max, py_min, py_max;
- double width, height;
- long double px_dx, px_dy;
- int i, j, p, nx;
- int lc, lr, rc, rr;
- long double md, cxpx, cypx;
- long double cx, cy, cz;
- npy_float64 *centers;
- npy_intp *dims;
-
- PyArrayObject *my_array;
- npy_float64 *gridded;
- npy_float64 *mask;
-
- int pp;
-
- npy_float64 inv_mats[3][3];
-
- npy_float64 xsp;
- npy_float64 ysp;
- npy_float64 zsp;
- npy_float64 pxsp;
- npy_float64 pysp;
- npy_float64 dxsp;
- npy_float64 dysp;
- npy_float64 dzsp;
- npy_float64 dsp;
-
- PyObject *return_value;
-
- xp = yp = zp = pxp = pyp = dxp = dyp = dzp = dp = NULL;
- centerp = inv_matp = indicesp = NULL;
-
- x = y = z = px = py = dx = dy = dz = d = NULL;
- center = inv_mat = indices = NULL;
-
- if (!PyArg_ParseTuple(args, "OOOOOOOOOOOOII(dddd)",
- &xp, &yp, &zp, &pxp, &pyp, &dxp, &dyp, &dzp, ¢erp, &inv_matp,
- &indicesp, &dp, &cols, &rows, &px_min, &px_max, &py_min, &py_max))
- return PyErr_Format(_pixelizeError, "CPixelize: Invalid Parameters.");
-
- width = px_max - px_min;
- height = py_max - py_min;
- px_dx = width / ((double) rows);
- px_dy = height / ((double) cols);
-
- // Check we have something to output to
- if (rows == 0 || cols ==0)
- PyErr_Format( _pixelizeError, "Cannot scale to zero size.");
-
- // Get numeric arrays
- x = (PyArrayObject *) PyArray_FromAny(xp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if (x == NULL) {
- PyErr_Format( _pixelizeError, "x is of incorrect type (wanted 1D float)");
- goto _fail;
- }
-
- y = (PyArrayObject *) PyArray_FromAny(yp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((y == NULL) || (PyArray_SIZE(y) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "y is of incorrect type (wanted 1D float)");
- goto _fail;
- }
-
- z = (PyArrayObject *) PyArray_FromAny(zp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((z == NULL) || (PyArray_SIZE(y) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "z is of incorrect type (wanted 1D float)");
- goto _fail;
- }
-
- px = (PyArrayObject *) PyArray_FromAny(pxp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((px == NULL) || (PyArray_SIZE(y) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "px is of incorrect type (wanted 1D float)");
- goto _fail;
- }
-
- py = (PyArrayObject *) PyArray_FromAny(pyp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((py == NULL) || (PyArray_SIZE(y) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "py is of incorrect type (wanted 1D float)");
- goto _fail;
- }
-
- d = (PyArrayObject *) PyArray_FromAny(dp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((d == NULL) || (PyArray_SIZE(d) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "data is of incorrect type (wanted 1D float)");
- goto _fail;
- }
-
- dx = (PyArrayObject *) PyArray_FromAny(dxp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((dx == NULL) || (PyArray_SIZE(dx) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "dx is of incorrect type (wanted 1D float)");
- goto _fail;
- }
- dy = (PyArrayObject *) PyArray_FromAny(dyp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((dy == NULL) || (PyArray_SIZE(dy) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "dy is of incorrect type (wanted 1D float)");
- goto _fail;
- }
- dz = (PyArrayObject *) PyArray_FromAny(dzp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, 0, NULL);
- if ((dz == NULL) || (PyArray_SIZE(dz) != PyArray_SIZE(x))) {
- PyErr_Format( _pixelizeError, "dz is of incorrect type (wanted 1D float)");
- goto _fail;
- }
- center = (PyArrayObject *) PyArray_FromAny(centerp,
- PyArray_DescrFromType(NPY_FLOAT64), 1, 1, NPY_ARRAY_C_CONTIGUOUS, NULL);
- if ((dz == NULL) || (PyArray_SIZE(center) != 3)) {
- PyErr_Format( _pixelizeError, "Center must have three points");
- goto _fail;
- }
- inv_mat = (PyArrayObject *) PyArray_FromAny(inv_matp,
- PyArray_DescrFromType(NPY_FLOAT64), 2, 2, 0, NULL);
- if ((inv_mat == NULL) || (PyArray_SIZE(inv_mat) != 9)) {
- PyErr_Format( _pixelizeError, "inv_mat must be three by three");
- goto _fail;
- }
- indices = (PyArrayObject *) PyArray_FromAny(indicesp,
- PyArray_DescrFromType(NPY_INT64), 1, 1, 0, NULL);
- if ((indices == NULL) || (PyArray_SIZE(indices) != PyArray_SIZE(dx))) {
- PyErr_Format( _pixelizeError, "indices must be same length as dx");
- goto _fail;
- }
-
- // Check dimensions match
- nx = PyArray_DIMS(x)[0];
-
- // Calculate the pointer arrays to map input x to output x
-
- centers = (npy_float64 *) PyArray_GETPTR1(center,0);
-
- dims[0] = rows;
- dims[1] = cols;
- my_array =
- (PyArrayObject *) PyArray_SimpleNewFromDescr(2, dims,
- PyArray_DescrFromType(NPY_FLOAT64));
- gridded = (npy_float64 *) PyArray_DATA(my_array);
- mask = malloc(sizeof(npy_float64)*rows*cols);
-
- for(i=0;i<3;i++)for(j=0;j<3;j++)
- inv_mats[i][j]=*(npy_float64*)PyArray_GETPTR2(inv_mat,i,j);
-
- for(p=0;p<cols*rows;p++)gridded[p]=mask[p]=0.0;
- for(pp=0; pp<nx; pp++)
- {
- p = *((npy_int64 *) PyArray_GETPTR1(indices, pp));
- xsp = *((npy_float64 *) PyArray_GETPTR1(x, p));
- ysp = *((npy_float64 *) PyArray_GETPTR1(y, p));
- zsp = *((npy_float64 *) PyArray_GETPTR1(z, p));
- pxsp = *((npy_float64 *) PyArray_GETPTR1(px, p));
- pysp = *((npy_float64 *) PyArray_GETPTR1(py, p));
- dxsp = *((npy_float64 *) PyArray_GETPTR1(dx, p));
- dysp = *((npy_float64 *) PyArray_GETPTR1(dy, p));
- dzsp = *((npy_float64 *) PyArray_GETPTR1(dz, p));
- dsp = *((npy_float64 *) PyArray_GETPTR1(d, p)); // We check this above
- // Any point we want to plot is at most this far from the center
- md = 2.0*sqrtl(dxsp*dxsp + dysp*dysp + dzsp*dzsp);
- if(((pxsp+md<px_min) ||
- (pxsp-md>px_max)) ||
- ((pysp+md<py_min) ||
- (pysp-md>py_max))) continue;
- lc = max(floorl((pxsp-md-px_min)/px_dx),0);
- lr = max(floorl((pysp-md-py_min)/px_dy),0);
- rc = min(ceill((pxsp+md-px_min)/px_dx),rows);
- rr = min(ceill((pysp+md-py_min)/px_dy),cols);
- for (i=lr;i<rr;i++) {
- cypx = px_dy * (i+0.5) + py_min;
- for (j=lc;j<rc;j++) {
- cxpx = px_dx * (j+0.5) + px_min;
- cx = inv_mats[0][0]*cxpx + inv_mats[0][1]*cypx + centers[0];
- cy = inv_mats[1][0]*cxpx + inv_mats[1][1]*cypx + centers[1];
- cz = inv_mats[2][0]*cxpx + inv_mats[2][1]*cypx + centers[2];
- if( (fabs(xsp-cx)*0.95>dxsp) ||
- (fabs(ysp-cy)*0.95>dysp) ||
- (fabs(zsp-cz)*0.95>dzsp)) continue;
- mask[j*cols+i] += 1;
- gridded[j*cols+i] += dsp;
- }
- }
- }
- for(p=0;p<cols*rows;p++)gridded[p]=gridded[p]/mask[p];
-
- // Attatch output buffer to output buffer
-
- Py_DECREF(x);
- Py_DECREF(y);
- Py_DECREF(z);
- Py_DECREF(px);
- Py_DECREF(py);
- Py_DECREF(d);
- Py_DECREF(dx);
- Py_DECREF(dy);
- Py_DECREF(dz);
- Py_DECREF(center);
- Py_DECREF(indices);
- Py_DECREF(inv_mat);
- free(mask);
-
- return_value = Py_BuildValue("N", my_array);
-
- return return_value;
-
- _fail:
-
- Py_XDECREF(x);
- Py_XDECREF(y);
- Py_XDECREF(z);
- Py_XDECREF(px);
- Py_XDECREF(py);
- Py_XDECREF(d);
- Py_XDECREF(dx);
- Py_XDECREF(dy);
- Py_XDECREF(dz);
- Py_XDECREF(center);
- Py_XDECREF(indices);
- Py_XDECREF(inv_mat);
-
- return NULL;
-
-}
-
-static PyMethodDef __MPLMethods[] = {
- {"Pixelize", Py_Pixelize, METH_VARARGS, _pixelizeDocstring},
- {"CPixelize", Py_CPixelize, METH_VARARGS, NULL},
- {NULL, NULL} /* Sentinel */
-};
-
-/* platform independent*/
-#ifdef MS_WIN32
-__declspec(dllexport)
-#endif
-
-
-PyMODINIT_FUNC
-#if PY_MAJOR_VERSION >= 3
-#define _RETVAL m
-PyInit__MPL(void)
-#else
-#define _RETVAL
-init_MPL(void)
-#endif
-{
- PyObject *m, *d;
-#if PY_MAJOR_VERSION >= 3
- static struct PyModuleDef moduledef = {
- PyModuleDef_HEAD_INIT,
- "_MPL", /* m_name */
- "Pixelization routines\n",
- /* m_doc */
- -1, /* m_size */
- __MPLMethods, /* m_methods */
- NULL, /* m_reload */
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL, /* m_free */
- };
- m = PyModule_Create(&moduledef);
-#else
- m = Py_InitModule("_MPL", __MPLMethods);
-#endif
- d = PyModule_GetDict(m);
- _pixelizeError = PyErr_NewException("_MPL.error", NULL, NULL);
- PyDict_SetItemString(d, "error", _pixelizeError);
- import_array();
- return _RETVAL;
-}
diff -r 9f2207f01bf5a9d9ebd6dcfadf8ae003b9579472 -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -41,8 +41,6 @@
from yt.utilities.exceptions import \
YTDataTypeUnsupported
-from . import _MPL
-
callback_registry = {}
def _verify_geometry(func):
@@ -397,24 +395,18 @@
if self.bv_y != 0.0:
# Workaround for 0.0 without units
fv_y -= self.bv_y
- pixX = _MPL.Pixelize(plot.data['px'],
- plot.data['py'],
- plot.data['pdx'],
- plot.data['pdy'],
- fv_x,
- int(nx), int(ny),
- (x0, x1, y0, y1), 0, # bounds, antialias
- (period_x, period_y), periodic,
- ).transpose()
- pixY = _MPL.Pixelize(plot.data['px'],
- plot.data['py'],
- plot.data['pdx'],
- plot.data['pdy'],
- fv_y,
- int(nx), int(ny),
- (x0, x1, y0, y1), 0, # bounds, antialias
- (period_x, period_y), periodic,
- ).transpose()
+ pixX = pixelize_cartesian(plot.data['px'], plot.data['py'],
+ plot.data['pdx'], plot.data['pdy'],
+ fv_x, int(nx), int(ny),
+ (x0, x1, y0, y1), 0, # bounds, antialias
+ (period_x, period_y), periodic,
+ ).transpose()
+ pixY = pixelize_cartesian(plot.data['px'], plot.data['py'],
+ plot.data['pdx'], plot.data['pdy'],
+ fv_y, int(nx), int(ny),
+ (x0, x1, y0, y1), 0, # bounds, antialias
+ (period_x, period_y), periodic,
+ ).transpose()
X,Y = np.meshgrid(np.linspace(xx0,xx1,nx,endpoint=True),
np.linspace(yy0,yy1,ny,endpoint=True))
if self.normalize:
@@ -710,28 +702,22 @@
plot._axes.hold(True)
nx = plot.image._A.shape[0] / self.factor
ny = plot.image._A.shape[1] / self.factor
- pixX = _MPL.Pixelize(plot.data['px'],
- plot.data['py'],
- plot.data['pdx'],
- plot.data['pdy'],
- plot.data[self.field_x],
- int(nx), int(ny),
- (x0, x1, y0, y1),).transpose()
- pixY = _MPL.Pixelize(plot.data['px'],
- plot.data['py'],
- plot.data['pdx'],
- plot.data['pdy'],
- plot.data[self.field_y],
- int(nx), int(ny),
- (x0, x1, y0, y1),).transpose()
+ pixX = pixelize_cartesian(plot.data['px'], plot.data['py'],
+ plot.data['pdx'], plot.data['pdy'],
+ plot.data[self.field_x],
+ int(nx), int(ny),
+ (x0, x1, y0, y1),).transpose()
+ pixY = pixelize_cartesian(plot.data['px'], plot.data['py'],
+ plot.data['pdx'], plot.data['pdy'],
+ plot.data[self.field_y],
+ int(nx), int(ny),
+ (x0, x1, y0, y1),).transpose()
if self.field_color:
- self.field_color = _MPL.Pixelize(plot.data['px'],
- plot.data['py'],
- plot.data['pdx'],
- plot.data['pdy'],
- plot.data[self.field_color],
- int(nx), int(ny),
- (x0, x1, y0, y1),).transpose()
+ self.field_color = pixelize_cartesian(
+ plot.data['px'], plot.data['py'],
+ plot.data['pdx'], plot.data['pdy'],
+ plot.data[self.field_color], int(nx), int(ny),
+ (x0, x1, y0, y1),).transpose()
X,Y = (np.linspace(xx0,xx1,nx,endpoint=True),
np.linspace(yy0,yy1,ny,endpoint=True))
@@ -948,7 +934,7 @@
xf_copy = clump[xf].copy().in_units("code_length")
yf_copy = clump[yf].copy().in_units("code_length")
- temp = _MPL.Pixelize(xf_copy, yf_copy,
+ temp = pixelize_cartesian(xf_copy, yf_copy,
clump[dxf].in_units("code_length")/2.0,
clump[dyf].in_units("code_length")/2.0,
clump[dxf].d*0.0+i+1, # inits inside Pixelize
https://bitbucket.org/yt_analysis/yt/commits/3f4c0a11e108/
Changeset: 3f4c0a11e108
Branch: yt
User: 0x414A
Date: 2016-06-22 18:26:09+00:00
Summary: Add basic Dockerfile and requirements, using continuum official Python3 anaconda image
Affected #: 2 files
diff -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d -r 3f4c0a11e1084fa2a2f8b58373ec7e31adddfac4 doc/Dockerfile
--- /dev/null
+++ b/doc/Dockerfile
@@ -0,0 +1,12 @@
+FROM continuumio/anaconda3:latest
+
+ENV SRC_HOME /usr/src/app
+
+RUN mkdir -p $SRC_HOME
+WORKDIR $SRC_HOME
+
+COPY requirements.txt $SRC_HOME
+
+RUN conda install --file=requirements.txt
+
+ADD . $SRC_HOME
diff -r 4f07f691a811be777cc737a0f22fb2b4ea6fbe4d -r 3f4c0a11e1084fa2a2f8b58373ec7e31adddfac4 doc/requirements.txt
--- /dev/null
+++ b/doc/requirements.txt
@@ -0,0 +1,13 @@
+alabaster==0.7.8
+Babel==2.3.3
+docutils==0.12
+imagesize==0.7.1
+Jinja2==2.8
+MarkupSafe==0.23
+numpydoc==0.5.0
+Pygments==2.1.3
+pytz==2016.4
+six==1.10.0
+snowballstemmer==1.2.1
+Sphinx==1.4.1
+sphinx-bootstrap-theme==0.4.8
https://bitbucket.org/yt_analysis/yt/commits/947d7b0383ce/
Changeset: 947d7b0383ce
Branch: yt
User: 0x414A
Date: 2016-06-22 18:32:06+00:00
Summary: Updated requirements
Affected #: 1 file
diff -r 3f4c0a11e1084fa2a2f8b58373ec7e31adddfac4 -r 947d7b0383cebf3e8a3ff56622d3964841c5da81 doc/requirements.txt
--- a/doc/requirements.txt
+++ b/doc/requirements.txt
@@ -10,4 +10,3 @@
six==1.10.0
snowballstemmer==1.2.1
Sphinx==1.4.1
-sphinx-bootstrap-theme==0.4.8
https://bitbucket.org/yt_analysis/yt/commits/f73da34441c8/
Changeset: f73da34441c8
Branch: yt
User: 0x414A
Date: 2016-06-22 18:49:55+00:00
Summary: Remove files from other commit
Affected #: 2 files
diff -r 947d7b0383cebf3e8a3ff56622d3964841c5da81 -r f73da34441c82ffc49be9e075fd82cbb7c21c4f9 doc/Dockerfile
--- a/doc/Dockerfile
+++ /dev/null
@@ -1,12 +0,0 @@
-FROM continuumio/anaconda3:latest
-
-ENV SRC_HOME /usr/src/app
-
-RUN mkdir -p $SRC_HOME
-WORKDIR $SRC_HOME
-
-COPY requirements.txt $SRC_HOME
-
-RUN conda install --file=requirements.txt
-
-ADD . $SRC_HOME
diff -r 947d7b0383cebf3e8a3ff56622d3964841c5da81 -r f73da34441c82ffc49be9e075fd82cbb7c21c4f9 doc/requirements.txt
--- a/doc/requirements.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-alabaster==0.7.8
-Babel==2.3.3
-docutils==0.12
-imagesize==0.7.1
-Jinja2==2.8
-MarkupSafe==0.23
-numpydoc==0.5.0
-Pygments==2.1.3
-pytz==2016.4
-six==1.10.0
-snowballstemmer==1.2.1
-Sphinx==1.4.1
https://bitbucket.org/yt_analysis/yt/commits/d48c4a143f6e/
Changeset: d48c4a143f6e
Branch: yt
User: xarthisius
Date: 2016-06-26 00:17:40+00:00
Summary: Merged in 0x414A/yt (pull request #2246)
Move extraction code from YTSearchCmd to its own utility module
Affected #: 2 files
diff -r 9e8c28db275b8ccd25279e218b1f063ed2f2aec9 -r d48c4a143f6e3c69c9a1016725d8328f8ea3af53 yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -43,6 +43,7 @@
from yt.visualization.plot_window import \
SlicePlot, \
ProjectionPlot
+from yt.utilities.metadata import get_metadata
from yt.utilities.exceptions import \
YTOutputNotIdentified
@@ -1150,11 +1151,6 @@
def __call__(self, args):
from yt.utilities.parameter_file_storage import \
output_type_registry
- attrs = ("dimensionality", "refine_by", "domain_dimensions",
- "current_time", "domain_left_edge", "domain_right_edge",
- "unique_identifier", "current_redshift",
- "cosmological_simulation", "omega_matter", "omega_lambda",
- "hubble_constant", "dataset_type")
candidates = []
for base, dirs, files in os.walk(".", followlinks=True):
print("(% 10i candidates) Examining %s" % (len(candidates), base))
@@ -1173,26 +1169,10 @@
for i, c in enumerate(sorted(candidates)):
print("(% 10i/% 10i) Evaluating %s" % (i, len(candidates), c))
try:
- ds = load(c)
+ record = get_metadata(c, args.full_output)
except YTOutputNotIdentified:
continue
- record = {'filename': c}
- for a in attrs:
- v = getattr(ds, a, None)
- if v is None:
- continue
- if hasattr(v, "tolist"):
- v = v.tolist()
- record[a] = v
- if args.full_output:
- params = {}
- for p, v in ds.parameters.items():
- if hasattr(v, "tolist"):
- v = v.tolist()
- params[p] = v
- record['params'] = params
records.append(record)
- ds.close()
with open(args.output, "w") as f:
json.dump(records, f, indent=4)
print("Identified %s records output to %s" % (
diff -r 9e8c28db275b8ccd25279e218b1f063ed2f2aec9 -r d48c4a143f6e3c69c9a1016725d8328f8ea3af53 yt/utilities/metadata.py
--- /dev/null
+++ b/yt/utilities/metadata.py
@@ -0,0 +1,28 @@
+from yt.convenience import load
+
+DEFAULT_ATTRS = ("dimensionality", "refine_by", "domain_dimensions",
+ "current_time", "domain_left_edge", "domain_right_edge",
+ "unique_identifier", "current_redshift",
+ "cosmological_simulation", "omega_matter", "omega_lambda",
+ "hubble_constant", "dataset_type")
+
+
+def get_metadata(path, full_output=False, attrs=DEFAULT_ATTRS):
+ ds = load(path)
+ metadata = {'filename': path}
+ for a in attrs:
+ v = getattr(ds, a, None)
+ if v is None:
+ continue
+ if hasattr(v, "tolist"):
+ v = v.tolist()
+ metadata[a] = v
+ if full_output:
+ params = {}
+ for p, v in ds.parameters.items():
+ if hasattr(v, "tolist"):
+ v = v.tolist()
+ params[p] = v
+ metadata['params'] = params
+ ds.close()
+ return metadata
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list