[yt-svn] commit/yt: ngoldbaum: Merged in jzuhone/yt-3.x/yt-3.0 (pull request #891)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sun May 11 13:13:18 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/788d2640d9f4/
Changeset: 788d2640d9f4
Branch: yt-3.0
User: ngoldbaum
Date: 2014-05-11 22:13:10
Summary: Merged in jzuhone/yt-3.x/yt-3.0 (pull request #891)
Fixing two bugs related to the FITS PRs
Affected #: 6 files
diff -r b19ce8c82e07be0ebc07f8e8943ac56c1bf40a21 -r 788d2640d9f4ba392b0fb20d95a1da3085192355 doc/source/cookbook/fits_radio_cubes.ipynb
--- a/doc/source/cookbook/fits_radio_cubes.ipynb
+++ b/doc/source/cookbook/fits_radio_cubes.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:2f774139560d94508c2c51b70930d46941d9ceef7228655de32a69634f6c6d83"
+ "signature": "sha256:dbc41f6f836cdeb88a549d85e389d6e4e43d163d8c4c267baea8cce0ebdbf441"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -45,7 +45,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "ds = yt.load(\"radio_fits/m33_hi.fits\", nan_mask=0.0)"
+ "ds = yt.load(\"radio_fits/m33_hi.fits\", nan_mask=0.0, z_axis_decomp=True)"
],
"language": "python",
"metadata": {},
@@ -179,6 +179,31 @@
"cell_type": "markdown",
"metadata": {},
"source": [
+ "We can also make a projection of all the emission along the line of sight:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "prj = yt.ProjectionPlot(ds, \"z\", [\"intensity\"], origin=\"native\", proj_style=\"sum\")\n",
+ "prj.show()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Since we're not doing an integration along a path length, we needed to specify `proj_style = \"sum\"`. "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"We can also look at the slices perpendicular to the other axes, which will show us the structure along the velocity axis:"
]
},
diff -r b19ce8c82e07be0ebc07f8e8943ac56c1bf40a21 -r 788d2640d9f4ba392b0fb20d95a1da3085192355 yt/analysis_modules/particle_trajectories/particle_trajectories.py
--- a/yt/analysis_modules/particle_trajectories/particle_trajectories.py
+++ b/yt/analysis_modules/particle_trajectories/particle_trajectories.py
@@ -66,13 +66,13 @@
if isinstance(outputs, DatasetSeries):
self.data_series = outputs
else:
- self.data_series = DatasetSeries.from_filenames(outputs)
+ self.data_series = DatasetSeries(outputs)
self.masks = []
self.sorts = []
self.array_indices = []
self.indices = indices
self.num_indices = len(indices)
- self.num_steps = len(filenames)
+ self.num_steps = len(outputs)
self.times = []
# Default fields
diff -r b19ce8c82e07be0ebc07f8e8943ac56c1bf40a21 -r 788d2640d9f4ba392b0fb20d95a1da3085192355 yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -317,7 +317,7 @@
finfo = self.pf._get_field_info(*field)
mylog.debug("Setting field %s", field)
units = finfo.units
- if self.weight_field is None:
+ if self.weight_field is None and not self._sum_only:
# See _handle_chunk where we mandate cm
if units == '':
input_units = "cm"
@@ -329,7 +329,7 @@
self[field] = YTArray(field_data[fi].ravel(),
input_units=input_units,
registry=self.pf.unit_registry)
- if self.weight_field is None:
+ if self.weight_field is None and not self._sum_only:
u_obj = Unit(units, registry=self.pf.unit_registry)
if u_obj.is_code_unit and input_units != units \
or self.pf.no_cgs_equiv_length:
diff -r b19ce8c82e07be0ebc07f8e8943ac56c1bf40a21 -r 788d2640d9f4ba392b0fb20d95a1da3085192355 yt/frontends/fits/data_structures.py
--- a/yt/frontends/fits/data_structures.py
+++ b/yt/frontends/fits/data_structures.py
@@ -17,6 +17,7 @@
import weakref
import warnings
import re
+import uuid
from yt.config import ytcfg
from yt.funcs import *
@@ -200,37 +201,49 @@
self.parameter_file.field_units[k] = self.parameter_file.field_units[primary_fname]
def _count_grids(self):
- self.num_grids = self.pf.nprocs
+ self.num_grids = self.pf.parameters["nprocs"]
def _parse_index(self):
f = self._handle # shortcut
pf = self.parameter_file # shortcut
# If nprocs > 1, decompose the domain into virtual grids
- if pf.nprocs > 1:
- bbox = np.array([[le,re] for le, re in zip(pf.domain_left_edge,
- pf.domain_right_edge)])
- dims = np.array(pf.domain_dimensions)
- # If we are creating a dataset of lines, only decompose along the position axes
- if len(pf.line_database) > 0:
- dims[pf.vel_axis] = 1
- psize = get_psize(dims, pf.nprocs)
- gle, gre, shapes, slices = decompose_array(dims, psize, bbox)
- self.grid_left_edge = self.pf.arr(gle, "code_length")
- self.grid_right_edge = self.pf.arr(gre, "code_length")
- self.grid_dimensions = np.array([shape for shape in shapes], dtype="int32")
- # If we are creating a dataset of lines, only decompose along the position axes
- if len(pf.line_database) > 0:
- self.grid_left_edge[:,pf.vel_axis] = pf.domain_left_edge[pf.vel_axis]
- self.grid_right_edge[:,pf.vel_axis] = pf.domain_right_edge[pf.vel_axis]
- self.grid_dimensions[:,pf.vel_axis] = pf.domain_dimensions[pf.vel_axis]
-
+ if self.num_grids > 1:
+ if self.pf.z_axis_decomp:
+ dz = (pf.domain_width/pf.domain_dimensions)[2]
+ self.grid_dimensions[:,2] = np.around(float(pf.domain_dimensions[2])/
+ self.num_grids).astype("int")
+ self.grid_dimensions[-1,2] += (pf.domain_dimensions[2] % self.num_grids)
+ self.grid_left_edge[0,2] = pf.domain_left_edge[2]
+ self.grid_left_edge[1:,2] = pf.domain_left_edge[2] + \
+ np.cumsum(self.grid_dimensions[:-1,2])*dz
+ self.grid_right_edge[:,2] = self.grid_left_edge[:,2]+self.grid_dimensions[:,2]*dz
+ self.grid_left_edge[:,:2] = pf.domain_left_edge[:2]
+ self.grid_right_edge[:,:2] = pf.domain_right_edge[:2]
+ self.grid_dimensions[:,:2] = pf.domain_dimensions[:2]
+ else:
+ bbox = np.array([[le,re] for le, re in zip(pf.domain_left_edge,
+ pf.domain_right_edge)])
+ dims = np.array(pf.domain_dimensions)
+ # If we are creating a dataset of lines, only decompose along the position axes
+ if len(pf.line_database) > 0:
+ dims[pf.vel_axis] = 1
+ psize = get_psize(dims, self.num_grids)
+ gle, gre, shapes, slices = decompose_array(dims, psize, bbox)
+ self.grid_left_edge = self.pf.arr(gle, "code_length")
+ self.grid_right_edge = self.pf.arr(gre, "code_length")
+ self.grid_dimensions = np.array([shape for shape in shapes], dtype="int32")
+ # If we are creating a dataset of lines, only decompose along the position axes
+ if len(pf.line_database) > 0:
+ self.grid_left_edge[:,pf.vel_axis] = pf.domain_left_edge[pf.vel_axis]
+ self.grid_right_edge[:,pf.vel_axis] = pf.domain_right_edge[pf.vel_axis]
+ self.grid_dimensions[:,pf.vel_axis] = pf.domain_dimensions[pf.vel_axis]
else:
self.grid_left_edge[0,:] = pf.domain_left_edge
self.grid_right_edge[0,:] = pf.domain_right_edge
self.grid_dimensions[0] = pf.domain_dimensions
- if self.pf.events_data:
+ if pf.events_data:
try:
self.grid_particle_count[:] = pf.primary_header["naxis2"]
except KeyError:
@@ -290,6 +303,7 @@
nprocs = None,
storage_filename = None,
nan_mask = None,
+ z_axis_decomp = False,
line_database = None,
line_width = None,
suppress_astropy_warnings = True,
@@ -297,8 +311,11 @@
if parameters is None:
parameters = {}
+ parameters["nprocs"] = nprocs
self.specified_parameters = parameters
+ self.z_axis_decomp = z_axis_decomp
+
if line_width is not None:
self.line_width = YTQuantity(line_width[0], line_width[1])
self.line_units = line_width[1]
@@ -322,11 +339,15 @@
self.nan_mask = {"all":nan_mask}
elif isinstance(nan_mask, dict):
self.nan_mask = nan_mask
- self.nprocs = nprocs
- self._handle = _astropy.pyfits.open(self.filenames[0],
- memmap=True,
- do_not_scale_image_data=True,
- ignore_blank=True)
+ if isinstance(self.filenames[0], _astropy.pyfits.PrimaryHDU):
+ self._handle = _astropy.pyfits.HDUList(self.filenames[0])
+ fn = "InMemoryFITSImage_%s" % (uuid.uuid4().hex)
+ else:
+ self._handle = _astropy.pyfits.open(self.filenames[0],
+ memmap=True,
+ do_not_scale_image_data=True,
+ ignore_blank=True)
+ fn = self.filenames[0]
self._fits_files = [self._handle]
if self.num_files > 1:
for fits_file in auxiliary_files:
@@ -387,7 +408,7 @@
self.refine_by = 2
- Dataset.__init__(self, filename, dataset_type)
+ Dataset.__init__(self, fn, dataset_type)
self.storage_filename = storage_filename
def _set_code_unit_attributes(self):
@@ -435,8 +456,11 @@
def _parse_parameter_file(self):
- self.unique_identifier = \
- int(os.stat(self.parameter_filename)[stat.ST_CTIME])
+ if self.parameter_filename.startswith("InMemory"):
+ self.unique_identifier = time.time()
+ else:
+ self.unique_identifier = \
+ int(os.stat(self.parameter_filename)[stat.ST_CTIME])
# Determine dimensionality
@@ -472,14 +496,26 @@
self.current_redshift = self.omega_lambda = self.omega_matter = \
self.hubble_constant = self.cosmological_simulation = 0.0
- # If this is a 2D events file, no need to decompose
- if self.events_data: self.nprocs = 1
+ if self.dimensionality == 2 and self.z_axis_decomp:
+ mylog.warning("You asked to decompose along the z-axis, but this is a 2D dataset. " +
+ "Ignoring.")
+ self.z_axis_decomp = False
+
+ if self.events_data: self.specified_parameters["nprocs"] = 1
# If nprocs is None, do some automatic decomposition of the domain
- if self.nprocs is None:
- self.nprocs = np.around(np.prod(self.domain_dimensions) /
- 32**self.dimensionality).astype("int")
- self.nprocs = max(min(self.nprocs, 512), 1)
+ if self.specified_parameters["nprocs"] is None:
+ if len(self.line_database) > 0:
+ dims = 2
+ else:
+ dims = self.dimensionality
+ if self.z_axis_decomp:
+ nprocs = np.around(self.domain_dimensions[2]/8).astype("int")
+ else:
+ nprocs = np.around(np.prod(self.domain_dimensions)/32**dims).astype("int")
+ self.parameters["nprocs"] = max(min(nprocs, 512), 1)
+ else:
+ self.parameters["nprocs"] = self.specified_parameters["nprocs"]
self.reversed = False
diff -r b19ce8c82e07be0ebc07f8e8943ac56c1bf40a21 -r 788d2640d9f4ba392b0fb20d95a1da3085192355 yt/frontends/fits/io.py
--- a/yt/frontends/fits/io.py
+++ b/yt/frontends/fits/io.py
@@ -88,7 +88,7 @@
for chunk in chunks:
for g in chunk.objs:
start = ((g.LeftEdge-self.pf.domain_left_edge)/dx).to_ndarray().astype("int")
- end = ((g.RightEdge-self.pf.domain_left_edge)/dx).to_ndarray().astype("int")
+ end = start + g.ActiveDimensions
if self.line_db is not None and fname in self.line_db:
my_off = self.line_db.get(fname).in_units(self.pf.vel_unit).value
my_off = my_off - 0.5*self.pf.line_width
diff -r b19ce8c82e07be0ebc07f8e8943ac56c1bf40a21 -r 788d2640d9f4ba392b0fb20d95a1da3085192355 yt/geometry/ppv_coordinates.py
--- a/yt/geometry/ppv_coordinates.py
+++ b/yt/geometry/ppv_coordinates.py
@@ -25,8 +25,6 @@
self.axis_name = {}
self.axis_id = {}
- self.x_axis = {}
- self.y_axis = {}
for axis, axis_name in zip([pf.lon_axis, pf.lat_axis, pf.vel_axis],
["Image\ x", "Image\ y", pf.vel_name]):
@@ -42,28 +40,6 @@
self.axis_id[axis] = axis
self.axis_id[axis_name] = axis
- if axis == 0:
- self.x_axis[axis] = 1
- self.x_axis[lower_ax] = 1
- self.x_axis[axis_name] = 1
- self.y_axis[axis] = 2
- self.y_axis[lower_ax] = 2
- self.y_axis[axis_name] = 2
- elif axis == 1:
- self.x_axis[axis] = 2
- self.x_axis[lower_ax] = 2
- self.x_axis[axis_name] = 2
- self.y_axis[axis] = 0
- self.y_axis[lower_ax] = 0
- self.y_axis[axis_name] = 0
- elif axis == 2:
- self.x_axis[axis] = 0
- self.x_axis[lower_ax] = 0
- self.x_axis[axis_name] = 0
- self.y_axis[axis] = 1
- self.y_axis[lower_ax] = 1
- self.y_axis[axis_name] = 1
-
self.default_unit_label = {}
self.default_unit_label[pf.lon_axis] = "pixel"
self.default_unit_label[pf.lat_axis] = "pixel"
@@ -75,3 +51,8 @@
def convert_from_cylindrical(self, coord):
raise NotImplementedError
+ x_axis = { 'x' : 1, 'y' : 0, 'z' : 0,
+ 0 : 1, 1 : 0, 2 : 0}
+
+ y_axis = { 'x' : 2, 'y' : 2, 'z' : 1,
+ 0 : 2, 1 : 2, 2 : 1}
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