[yt-svn] commit/yt: 7 new changesets
Bitbucket
commits-noreply at bitbucket.org
Wed Feb 20 17:54:15 PST 2013
7 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/9ba8af43485c/
changeset: 9ba8af43485c
branch: yt
user: ngoldbaum
date: 2013-02-20 22:18:51
summary: Fixing a bug in PlotWindow.set_width() that broke specifying the
width and unit as separate keyword parameters.
affected #: 1 file
diff -r db1d8020d9fb8484147d65366968b012db4d0b50 -r 9ba8af43485cf0b5213dff26abfcb9c3930f6fb6 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -453,6 +453,9 @@
else:
set_axes_unit = False
+ if isinstance(width, (int, long, float)):
+ width = (width, unit)
+
width = StandardWidth(self._frb.axis, width, None, self.pf)
centerx = (self.xlim[1] + self.xlim[0])/2.
https://bitbucket.org/yt_analysis/yt/commits/d802b5371c6e/
changeset: d802b5371c6e
branch: yt
user: ngoldbaum
date: 2013-02-20 22:20:12
summary: Merged yt_analysis/yt into yt
affected #: 4 files
diff -r 9ba8af43485cf0b5213dff26abfcb9c3930f6fb6 -r d802b5371c6e853c565bee0a6cc11aee055ad04f yt/analysis_modules/halo_finding/rockstar/rockstar.py
--- a/yt/analysis_modules/halo_finding/rockstar/rockstar.py
+++ b/yt/analysis_modules/halo_finding/rockstar/rockstar.py
@@ -164,6 +164,13 @@
If set to ``True``, it will be assumed that there are only dark
matter particles present in the simulation. This can save analysis
time if this is indeed the case. Default: ``False``.
+ hires_dm_mass : float
+ If supplied, use only the highest resolution dark matter
+ particles, with a mass less than (1.1*hires_dm_mass), in units
+ of ParticleMassMsun. This is useful for multi-dm-mass
+ simulations. Note that this will only give sensible results for
+ halos that are not "polluted" by lower resolution
+ particles. Default: ``None``.
Returns
-------
@@ -187,7 +194,8 @@
"""
def __init__(self, ts, num_readers = 1, num_writers = None,
outbase="rockstar_halos", dm_type=1,
- force_res=None, total_particles=None, dm_only=False):
+ force_res=None, total_particles=None, dm_only=False,
+ hires_dm_mass=None):
mylog.warning("The citation for the Rockstar halo finder can be found at")
mylog.warning("http://adsabs.harvard.edu/abs/2013ApJ...762..109B")
ParallelAnalysisInterface.__init__(self)
@@ -217,6 +225,7 @@
self.force_res = force_res
self.total_particles = total_particles
self.dm_only = dm_only
+ self.hires_dm_mass = hires_dm_mass
# Setup pool and workgroups.
self.pool, self.workgroup = self.runner.setup_pool()
p = self._setup_parameters(ts)
@@ -227,28 +236,51 @@
def _setup_parameters(self, ts):
if self.workgroup.name != "readers": return None
tpf = ts[0]
+
def _particle_count(field, data):
- if self.dm_only:
- return np.prod(data["particle_position_x"].shape)
try:
- return (data["particle_type"]==self.dm_type).sum()
+ data["particle_type"]
+ has_particle_type=True
except KeyError:
- return np.prod(data["particle_position_x"].shape)
+ has_particle_type=False
+
+ if (self.dm_only or (not has_particle_type)):
+ if self.hires_dm_mass is None:
+ return np.prod(data["particle_position_x"].shape)
+ else:
+ return (data['ParticleMassMsun'] < self.hires_dm_mass*1.1).sum()
+ elif has_particle_type:
+ if self.hires_dm_mass is None:
+ return (data["particle_type"]==self.dm_type).sum()
+ else:
+ return ( (data["particle_type"]==self.dm_type) &
+ (data['ParticleMassMsun'] < self.hires_dm_mass*1.1) ).sum()
+ else:
+ raise RuntimeError() # should never get here
+
add_field("particle_count", function=_particle_count,
not_in_all=True, particle_type=True)
dd = tpf.h.all_data()
# Get DM particle mass.
all_fields = set(tpf.h.derived_field_list + tpf.h.field_list)
- for g in tpf.h._get_objs("grids"):
- if g.NumberOfParticles == 0: continue
- if self.dm_only:
- iddm = Ellipsis
- elif "particle_type" in all_fields:
- iddm = g["particle_type"] == self.dm_type
- else:
- iddm = Ellipsis
- particle_mass = g['ParticleMassMsun'][iddm][0] / tpf.hubble_constant
- break
+ has_particle_type = ("particle_type" in all_fields)
+
+ if self.hires_dm_mass is None:
+ for g in tpf.h._get_objs("grids"):
+ if g.NumberOfParticles == 0: continue
+
+ if (self.dm_only or (not has_particle_type)):
+ iddm = Ellipsis
+ elif has_particle_type:
+ iddm = g["particle_type"] == self.dm_type
+ else:
+ iddm = Ellipsis # should never get here
+
+ particle_mass = g['ParticleMassMsun'][iddm][0] / tpf.hubble_constant
+ break
+ else:
+ particle_mass = self.hires_dm_mass / tpf.hubble_constant
+
p = {}
if self.total_particles is None:
# Get total_particles in parallel.
@@ -302,6 +334,7 @@
force_res = self.force_res,
particle_mass = float(self.particle_mass),
dm_only = int(self.dm_only),
+ hires_only = (self.hires_dm_mass is not None),
**kwargs)
# Make the directory to store the halo lists in.
if self.comm.rank == 0:
diff -r 9ba8af43485cf0b5213dff26abfcb9c3930f6fb6 -r d802b5371c6e853c565bee0a6cc11aee055ad04f yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
--- a/yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
+++ b/yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
@@ -163,6 +163,7 @@
SCALE_NOW = 1.0/(pf.current_redshift+1.0)
# Now we want to grab data from only a subset of the grids for each reader.
all_fields = set(pf.h.derived_field_list + pf.h.field_list)
+ has_particle_type = ("particle_type" in all_fields)
# First we need to find out how many this reader is going to read in
# if the number of readers > 1.
@@ -170,12 +171,19 @@
local_parts = 0
for g in pf.h._get_objs("grids"):
if g.NumberOfParticles == 0: continue
- if rh.dm_only:
- iddm = Ellipsis
- elif "particle_type" in all_fields:
- iddm = g["particle_type"] == rh.dm_type
+ if (rh.dm_only or (not has_particle_type)):
+ if rh.hires_only:
+ iddm = (g['ParticleMassMsun'] < PARTICLE_MASS*1.1)
+ else:
+ iddm = Ellipsis
+ elif has_particle_type:
+ if rh.hires_only:
+ iddm = ( (g["particle_type"]==rh.dm_type) &
+ (g['ParticleMassMsun'] < PARTICLE_MASS*1.1) )
+ else:
+ iddm = g["particle_type"] == rh.dm_type
else:
- iddm = Ellipsis
+ iddm = Ellipsis # should never get here
arri = g["particle_index"].astype("int64")
arri = arri[iddm] #pick only DM
local_parts += arri.size
@@ -195,12 +203,19 @@
pi = 0
for g in pf.h._get_objs("grids"):
if g.NumberOfParticles == 0: continue
- if rh.dm_only:
- iddm = Ellipsis
- elif "particle_type" in all_fields:
- iddm = g["particle_type"] == rh.dm_type
- else:
- iddm = Ellipsis
+ if (rh.dm_only or (not has_particle_type)):
+ if rh.hires_only:
+ iddm = (g['ParticleMassMsun'] < PARTICLE_MASS*1.1)
+ else:
+ iddm = Ellipsis
+ elif has_particle_type:
+ if rh.hires_only:
+ iddm = ( (g["particle_type"]==rh.dm_type) &
+ (g['ParticleMassMsun'] < PARTICLE_MASS*1.1) )
+ else:
+ iddm = g["particle_type"] == rh.dm_type
+ else:
+ iddm = Ellipsis # should never get here
arri = g["particle_index"].astype("int64")
arri = arri[iddm] #pick only DM
npart = arri.size
@@ -230,6 +245,7 @@
cdef public int dm_type
cdef public int total_particles
cdef public int dm_only
+ cdef public int hires_only
def __cinit__(self, ts):
self.ts = ts
@@ -244,7 +260,7 @@
int writing_port = -1, int block_ratio = 1,
int periodic = 1, force_res=None,
int min_halo_size = 25, outbase = "None",
- int dm_only = 0):
+ int dm_only = 0, int hires_only = False):
global PARALLEL_IO, PARALLEL_IO_SERVER_ADDRESS, PARALLEL_IO_SERVER_PORT
global FILENAME, FILE_FORMAT, NUM_SNAPS, STARTING_SNAP, h0, Ol, Om
global BOX_SIZE, PERIODIC, PARTICLE_MASS, NUM_BLOCKS, NUM_READERS
@@ -276,6 +292,7 @@
TOTAL_PARTICLES = total_particles
self.block_ratio = block_ratio
self.dm_only = dm_only
+ self.hires_only = hires_only
tpf = self.ts[0]
h0 = tpf.hubble_constant
diff -r 9ba8af43485cf0b5213dff26abfcb9c3930f6fb6 -r d802b5371c6e853c565bee0a6cc11aee055ad04f yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -2068,6 +2068,7 @@
source=None, node_name = None, field_cuts = None,
preload_style='level', serialize=True,**kwargs):
AMR2DData.__init__(self, axis, field, pf, node_name = None, **kwargs)
+ self.proj_style = "integrate"
self.weight_field = weight_field
self._field_cuts = field_cuts
self.serialize = serialize
diff -r 9ba8af43485cf0b5213dff26abfcb9c3930f6fb6 -r d802b5371c6e853c565bee0a6cc11aee055ad04f yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -177,9 +177,11 @@
info['label'] = info['label'].replace(' ','\/')
info['label'] = r'$\rm{'+info['label']+r'}$'
+ # Try to determine the units of the data
+ units = None
if self.data_source._type_name in ("slice", "cutting"):
units = info['units']
- elif self.data_source._type_name == "proj":
+ elif self.data_source._type_name in ("proj", "overlap_proj"):
if (self.data_source.weight_field is not None or
self.data_source.proj_style == "mip"):
units = info['units']
https://bitbucket.org/yt_analysis/yt/commits/263fa718f240/
changeset: 263fa718f240
branch: yt
user: ngoldbaum
date: 2013-02-21 02:48:02
summary: Making assert_rel_equal cast to numpy arrays to allow comparing lists or tuples.
affected #: 1 file
diff -r 9ba8af43485cf0b5213dff26abfcb9c3930f6fb6 -r 263fa718f240be763d166566ba5caf5adb4e2ba6 yt/testing.py
--- a/yt/testing.py
+++ b/yt/testing.py
@@ -38,9 +38,9 @@
# Mask out NaNs
a1[np.isnan(a1)] = 1.0
a2[np.isnan(a2)] = 1.0
- elif np.isnan(a1) and np.isnan(a2):
+ elif np.any(np.isnan(a1)) and np.any(np.isnan(a2)):
return True
- return assert_almost_equal(a1/a2, 1.0, decimals, err_msg=err_msg,
+ return assert_almost_equal(np.array(a1)/np.array(a2), 1.0, decimals, err_msg=err_msg,
verbose=verbose)
def amrspace(extent, levels=7, cells=8):
https://bitbucket.org/yt_analysis/yt/commits/608956fd88e1/
changeset: 608956fd88e1
branch: yt
user: ngoldbaum
date: 2013-02-21 02:48:29
summary: Fixing an error that caused (width, width) tuples to be improperly parsed.
affected #: 1 file
diff -r 263fa718f240be763d166566ba5caf5adb4e2ba6 -r 608956fd88e10815bd5414e6f4d32e9c103db830 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -164,8 +164,8 @@
elif iterable(width):
if isinstance(width[1], str):
width = (width, width)
- elif isinstance(width[1], tuple):
- pass
+ elif isinstance(width[1], (long, int, float)):
+ width = ((width[0], '1'), (width[1], '1'))
else:
width = ((width, '1'), (width, '1'))
if depth is not None:
https://bitbucket.org/yt_analysis/yt/commits/c7074d6975cc/
changeset: c7074d6975cc
branch: yt
user: ngoldbaum
date: 2013-02-21 02:48:40
summary: Adding set_width() tests.
affected #: 1 file
Diff not available.
https://bitbucket.org/yt_analysis/yt/commits/e7b647837a13/
changeset: e7b647837a13
branch: yt
user: ngoldbaum
date: 2013-02-21 02:49:22
summary: Merging.
affected #: 4 files
Diff not available.
https://bitbucket.org/yt_analysis/yt/commits/e98c2e518d1e/
changeset: e98c2e518d1e
branch: yt
user: ngoldbaum
date: 2013-02-21 02:52:29
summary: Forgot to yield these two tests.
affected #: 1 file
Diff not available.
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