[Yt-svn] yt: 2 new changesets
hg at spacepope.org
hg at spacepope.org
Wed Nov 10 13:58:30 PST 2010
hg Repository: yt
details: yt/rev/870790e1a61e
changeset: 3524:870790e1a61e
user: Matthew Turk <matthewturk at gmail.com>
date:
Wed Nov 10 13:58:11 2010 -0800
description:
Only take the log in no_ghost if it's a to-be-logged field
hg Repository: yt
details: yt/rev/6e9ce30447f6
changeset: 3525:6e9ce30447f6
user: Matthew Turk <matthewturk at gmail.com>
date:
Wed Nov 10 13:58:26 2010 -0800
description:
Merging
diffstat:
yt/analysis_modules/sunrise_export/sunrise_exporter.py | 18 +++++++----
yt/data_objects/grid_patch.py | 6 ++-
yt/frontends/art/data_structures.py | 13 ++++---
yt/frontends/art/fields.py | 28 +++++++++---------
yt/utilities/_amr_utils/fortran_reader.pyx | 5 +--
yt/utilities/amr_kdtree/amr_kdtree.py | 8 ++--
yt/visualization/volume_rendering/camera.py | 2 -
yt/visualization/volume_rendering/grid_partitioner.py | 9 +----
8 files changed, 43 insertions(+), 46 deletions(-)
diffs (276 lines):
diff -r 04eb15b562a5 -r 6e9ce30447f6 yt/analysis_modules/sunrise_export/sunrise_exporter.py
--- a/yt/analysis_modules/sunrise_export/sunrise_exporter.py Wed Nov 10 10:18:14 2010 -0800
+++ b/yt/analysis_modules/sunrise_export/sunrise_exporter.py Wed Nov 10 13:58:26 2010 -0800
@@ -94,6 +94,7 @@
col_list = []
if subregion_bounds == None:
DLE, DRE = pf.domain_left_edge, pf.domain_right_edge
+ DX = pf.domain_dimensions
else:
DLE, DX = zip(*subregion_bounds)
DLE, DX = na.array(DLE), na.array(DX)
@@ -122,9 +123,10 @@
col_list.append(pyfits.Column("mass", format="D", array=current_mass, unit="Msun"))
col_list.append(pyfits.Column("age_m", format="D", array=age))
col_list.append(pyfits.Column("age_l", format="D", array=age))
+ #For particles, Sunrise takes
+ #the dimensionless metallicity, not the mass of the metals
col_list.append(pyfits.Column("metallicity", format="D",
- array=0.02*current_mass*reg["metallicity_fraction"][pi],
- unit="Msun")) # wrong?
+ array=reg["metallicity_fraction"][pi],unit="Msun")) # wrong?
col_list.append(pyfits.Column("L_bol", format="D",
array=na.zeros(particle_mass.size)))
@@ -137,9 +139,11 @@
write_particles = True
def _MetalMass(field, data):
- return data["Metallicity"] * data["CellMassMsun"]
+ return data["Metal_Density"] * data["CellVolume"]
+
def _convMetalMass(data):
- return 1.0
+ return 1.0/1.989e33
+
add_field("MetalMass", function=_MetalMass,
convert_function=_convMetalMass)
@@ -172,8 +176,8 @@
st_table.header.update("hierarch lengthunit", "kpc", comment="Length unit for grid")
for i,a in enumerate('xyz'):
- st_table.header.update("min%s" % a, DLE[i] * pf['kpc'])
- st_table.header.update("max%s" % a, DRE[i] * pf['kpc'])
+ st_table.header.update("min%s" % a, DLE[i] * pf['kpc']/pf.domain_dimensions)
+ st_table.header.update("max%s" % a, DRE[i] * pf['kpc']/pf.domain_dimensions)
st_table.header.update("n%s" % a, DX[i])
st_table.header.update("subdiv%s" % a, 2)
st_table.header.update("subdivtp", "UNIFORM", "Type of grid subdivision")
@@ -222,7 +226,7 @@
col_list = [pyfits.Column("dummy", format="F", array=na.zeros(1, dtype='float32'))]
cols = pyfits.ColDefs(col_list)
md_table = pyfits.new_table(cols)
- md_table.header.update("snaptime", pf.current_time*pf["years"])
+ md_table.header.update("snaptime", pf.current_time*pf['years'])
md_table.name = "YT"
hls = [pyfits.PrimaryHDU(), st_table, mg_table,md_table]
diff -r 04eb15b562a5 -r 6e9ce30447f6 yt/data_objects/grid_patch.py
--- a/yt/data_objects/grid_patch.py Wed Nov 10 10:18:14 2010 -0800
+++ b/yt/data_objects/grid_patch.py Wed Nov 10 13:58:26 2010 -0800
@@ -473,7 +473,8 @@
new_field[1:,1:,:-1] += of
new_field[1:,1:,1:] += of
na.multiply(new_field, 0.125, new_field)
- new_field = na.log10(new_field)
+ if self.pf.field_info[field].take_log:
+ new_field = na.log10(new_field)
new_field[:,:, -1] = 2.0*new_field[:,:,-2] - new_field[:,:,-3]
new_field[:,:, 0] = 2.0*new_field[:,:,1] - new_field[:,:,2]
@@ -483,6 +484,7 @@
new_field[-1,:,:] = 2.0*new_field[-2,:,:] - new_field[-3,:,:]
new_field[0,:,:] = 2.0*new_field[1,:,:] - new_field[2,:,:]
- na.power(10.0,new_field,new_field)
+ if self.pf.field_info[field].take_log:
+ na.power(10.0, new_field, new_field)
return new_field
diff -r 04eb15b562a5 -r 6e9ce30447f6 yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py Wed Nov 10 10:18:14 2010 -0800
+++ b/yt/frontends/art/data_structures.py Wed Nov 10 13:58:26 2010 -0800
@@ -438,10 +438,8 @@
self.rho0*self.v0**2*(aexpn**-5.0)
tr = self.tr
self.conversion_factors["Temperature"] = tr
- self.conversion_factors["Metallicity"] = 1
- self.conversion_factors["MetallicitySNII"] = 1
- self.conversion_factors["MetallicitySNIa"] = 1
-
+ self.conversion_factors["Metal_Density"] = 1
+
# Now our conversion factors
for ax in 'xyz':
# Add on the 1e5 to get to cm/s
@@ -450,6 +448,10 @@
self.time_units['years'] = seconds / (365*3600*24.0)
self.time_units['days'] = seconds / (3600*24.0)
+ #we were already in seconds, go back in to code units
+ self.current_time /= self.t0
+
+
def _parse_parameter_file(self):
# We set our domain to run from 0 .. 1 since we are otherwise
# unconstrained.
@@ -526,7 +528,6 @@
self.max_level = header_vals['max_level']
self.nhydro_vars = 10 #this gets updated later, but we'll default to this
#nchem is nhydrovars-8, so we typically have 2 extra chem species
-
self.hubble_time = 1.0/(self.hubble_constant*100/3.08568025e19)
#self.hubble_time /= 3.168876e7 #Gyr in s
def integrand(x,oml=self.omega_lambda,omb=self.omega_matter):
@@ -535,7 +536,7 @@
integrand_arr = integrand(spacings)
self.current_time = na.trapz(integrand_arr,dx=na.diff(spacings))
self.current_time *= self.hubble_time
-
+
for to_skip in ['tl','dtl','tlold','dtlold','iSO']:
_skip_record(f)
diff -r 04eb15b562a5 -r 6e9ce30447f6 yt/frontends/art/fields.py
--- a/yt/frontends/art/fields.py Wed Nov 10 10:18:14 2010 -0800
+++ b/yt/frontends/art/fields.py Wed Nov 10 13:58:26 2010 -0800
@@ -94,38 +94,38 @@
ARTFieldInfo["Temperature"]._convert_function=_convertTemperature
def _MetallicitySNII(field, data):
- #get the dimensionaless mass fraction
+ #get the dimensionless mass fraction
tr = data["Metal_DensitySNII"] / data["Density"]
tr *= data.pf.conversion_factors["Density"]
return tr
-def _convert_MetallicitySNII(data):
- return data.convert("MetallicitySNII")
add_field("MetallicitySNII", function=_MetallicitySNII, units = r"\mathrm{K}")
ARTFieldInfo["MetallicitySNII"]._units = r"\mathrm{K}"
-ARTFieldInfo["MetallicitySNII"]._convert_function=_convert_MetallicitySNII
def _MetallicitySNIa(field, data):
- #get the dimensionaless mass fraction
+ #get the dimensionless mass fraction
tr = data["Metal_DensitySNIa"] / data["Density"]
tr *= data.pf.conversion_factors["Density"]
return tr
-def _convert_MetallicitySNIa(data):
- return data.convert("MetallicitySNIa")
add_field("MetallicitySNIa", function=_MetallicitySNIa, units = r"\mathrm{K}")
ARTFieldInfo["MetallicitySNIa"]._units = r"\mathrm{K}"
-ARTFieldInfo["MetallicitySNIa"]._convert_function=_convert_MetallicitySNIa
def _Metallicity(field, data):
- #get the dimensionaless mass fraction of the total metals
- tr = data["Metal_Density2"] / data["Density"]
- tr += data["Metal_Density1"] / data["Density"]
+ #get the dimensionless mass fraction of the total metals
+ tr = data["Metal_DensitySNIa"] / data["Density"]
+ tr += data["Metal_DensitySNII"] / data["Density"]
tr *= data.pf.conversion_factors["Density"]
return tr
-def _convert_Metallicity(data):
- return data.convert("Metallicity")
add_field("Metallicity", function=_Metallicity, units = r"\mathrm{K}")
ARTFieldInfo["Metallicity"]._units = r"\mathrm{K}"
-ARTFieldInfo["Metallicity"]._convert_function=_convert_Metallicity
\ No newline at end of file
+
+def _Metal_Density(field,data):
+ return data["Metal_DensitySNII"]+data["Metal_DensitySNIa"]
+def _convert_Metal_Density(data):
+ return data.convert("Metal_Density")
+
+add_field("Metal_Density", function=_Metal_Density, units = r"\mathrm{K}")
+ARTFieldInfo["Metal_Density"]._units = r"\mathrm{K}"
+ARTFieldInfo["Metal_Density"]._convert_function=_convert_Metal_Density
diff -r 04eb15b562a5 -r 6e9ce30447f6 yt/utilities/_amr_utils/fortran_reader.pyx
--- a/yt/utilities/_amr_utils/fortran_reader.pyx Wed Nov 10 10:18:14 2010 -0800
+++ b/yt/utilities/_amr_utils/fortran_reader.pyx Wed Nov 10 13:58:26 2010 -0800
@@ -234,9 +234,6 @@
fread(&new_padding, sizeof(int), 1, f); FIX_LONG(new_padding)
assert(padding[0] == new_padding)
- at cython.cdivision(True)
- at cython.boundscheck(False)
- at cython.wraparound(False)
def read_art_grid(int varindex,
np.ndarray[np.int64_t, ndim=1] start_index,
np.ndarray[np.int32_t, ndim=1] grid_dims,
@@ -253,8 +250,8 @@
cdef np.ndarray[np.int64_t, ndim=1] og_start_index
cdef np.float64_t temp_data
cdef np.int64_t end_index[3]
- cdef int kr_offset, jr_offset, ir_offset
cdef int to_fill = 0
+ cdef ir_offset, jr_offset, kr_offset
# Note that indexing into a cell is:
# (k*2 + j)*2 + i
for i in range(3):
diff -r 04eb15b562a5 -r 6e9ce30447f6 yt/utilities/amr_kdtree/amr_kdtree.py
--- a/yt/utilities/amr_kdtree/amr_kdtree.py Wed Nov 10 10:18:14 2010 -0800
+++ b/yt/utilities/amr_kdtree/amr_kdtree.py Wed Nov 10 13:58:26 2010 -0800
@@ -26,18 +26,18 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import numpy as na
+from mpi4py import MPI
from yt.funcs import *
from yt.visualization.volume_rendering.grid_partitioner import HomogenizedVolume
from yt.utilities.amr_utils import PartitionedGrid
from yt.utilities.performance_counters import yt_counters, time_function
import yt.utilities.parallel_tools.parallel_analysis_interface as PT
-from yt.config import ytcfg
-
from time import time
import h5py
-my_rank = ytcfg.getint("yt", "__parallel_rank")
-nprocs = ytcfg.getint("yt", "__parallel_size")
+comm = MPI.COMM_WORLD
+my_rank = comm.rank
+nprocs = comm.size
def corner_bounds(split_dim, split, current_left = None, current_right = None):
r"""
diff -r 04eb15b562a5 -r 6e9ce30447f6 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py Wed Nov 10 10:18:14 2010 -0800
+++ b/yt/visualization/volume_rendering/camera.py Wed Nov 10 13:58:26 2010 -0800
@@ -194,8 +194,6 @@
else:
volume = HomogenizedVolume(fields, pf = self.pf,
log_fields = log_fields)
- else:
- self.use_kd = isinstance(volume, AMRKDTree)
self.volume = volume
def _setup_normalized_vectors(self, normal_vector, north_vector):
diff -r 04eb15b562a5 -r 6e9ce30447f6 yt/visualization/volume_rendering/grid_partitioner.py
--- a/yt/visualization/volume_rendering/grid_partitioner.py Wed Nov 10 10:18:14 2010 -0800
+++ b/yt/visualization/volume_rendering/grid_partitioner.py Wed Nov 10 13:58:26 2010 -0800
@@ -43,9 +43,8 @@
class HomogenizedVolume(ParallelAnalysisInterface):
bricks = None
def __init__(self, fields = "Density", source = None, pf = None,
- log_fields = None, no_ghost = False):
+ log_fields = None):
# Typically, initialized as hanging off a hierarchy. But, not always.
- self.no_ghost = no_ghost
if pf is not None: self.pf = pf
if source is None: source = self.pf.h.all_data()
self.source = source
@@ -76,8 +75,7 @@
# field.
vcds = []
for field, log_field in zip(self.fields, self.log_fields):
- vcd = grid.get_vertex_centered_data(field, no_ghost = self.no_ghost)
- vcd = vcd.astype("float64")
+ vcd = grid.get_vertex_centered_data(field).astype('float64')
if log_field: vcd = na.log10(vcd)
vcds.append(vcd)
@@ -179,9 +177,6 @@
))
self.bricks = na.array(bricks, dtype='object')
- def reset_cast(self):
- pass
-
class HomogenizedBrickCollection(DistributedObjectCollection):
def __init__(self, source):
# The idea here is that we have two sources -- the global_domain
More information about the yt-svn
mailing list