[Yt-svn] yt: 3 new changesets
hg at spacepope.org
hg at spacepope.org
Wed Nov 10 14:28:20 PST 2010
hg Repository: yt
details: yt/rev/ea18aa4a61da
changeset: 3528:ea18aa4a61da
user: Sam Skillman <sam.skillman at gmail.com>
date:
Wed Nov 10 15:20:47 2010 -0700
description:
Removing a from amr_kdtree import *, modifying the
amr_kdtree/__init__.py file, and adding move_to, rotate, and rotation
functions to the camera object.
hg Repository: yt
details: yt/rev/a05bac651daf
changeset: 3529:a05bac651daf
user: Sam Skillman <sam.skillman at gmail.com>
date:
Wed Nov 10 15:21:39 2010 -0700
description:
Forgot to add api file.
hg Repository: yt
details: yt/rev/4256464c070b
changeset: 3530:4256464c070b
user: Sam Skillman <sam.skillman at gmail.com>
date:
Wed Nov 10 15:27:01 2010 -0700
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_kdtree/__init__.py | 2 +-
yt/utilities/amr_kdtree/api.py | 28 ++++
yt/visualization/volume_rendering/camera.py | 115 ++++++++++++++++-
7 files changed, 177 insertions(+), 33 deletions(-)
diffs (truncated from 384 to 300 lines):
diff -r 04eb15b562a5 -r 4256464c070b 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 15:27:01 2010 -0700
@@ -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 4256464c070b 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 15:27:01 2010 -0700
@@ -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 4256464c070b 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 15:27:01 2010 -0700
@@ -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 4256464c070b 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 15:27:01 2010 -0700
@@ -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 4256464c070b yt/utilities/amr_kdtree/__init__.py
--- a/yt/utilities/amr_kdtree/__init__.py Wed Nov 10 10:18:14 2010 -0800
+++ b/yt/utilities/amr_kdtree/__init__.py Wed Nov 10 15:27:01 2010 -0700
@@ -1,4 +1,4 @@
"""
Initialize amr_kdtree
"""
-from amr_kdtree import *
+
diff -r 04eb15b562a5 -r 4256464c070b yt/utilities/amr_kdtree/api.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/utilities/amr_kdtree/api.py Wed Nov 10 15:27:01 2010 -0700
@@ -0,0 +1,28 @@
+"""
+API for yt.utilities.amr_kdtree
+
+Authors: Samuel Skillman <samskillman at gmail.com>
+Affiliation: University of Colorado at Boulder
+Wil St. Charles <fallen751 at gmail.com>
+Affiliation: University of Colorado at Boulder
+
+Homepage: http://yt.enzotools.org/
+License:
+ Copyright (C) 2010 Samuel Skillman. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+from amr_kdtree import AMRKDTree
diff -r 04eb15b562a5 -r 4256464c070b 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 15:27:01 2010 -0700
@@ -35,7 +35,7 @@
from yt.data_objects.data_containers import data_object_registry
from yt.utilities.parallel_tools.parallel_analysis_interface import \
ParallelAnalysisInterface
-from yt.utilities.amr_kdtree import *
+from yt.utilities.amr_kdtree.api import AMRKDTree
class Camera(ParallelAnalysisInterface):
def __init__(self, center, normal_vector, width,
@@ -176,6 +176,8 @@
self.steady_north = steady_north
# This seems to be necessary for now. Not sure what goes wrong when not true.
if north_vector is not None: self.steady_north=True
+ self.north_vector = north_vector
+ self.rotation_vector = north_vector
if fields is None: fields = ["Density"]
self.fields = fields
if transfer_function is None:
@@ -206,12 +208,15 @@
t = na.cross(normal_vector, vecs).sum(axis=1)
ax = t.argmax()
north_vector = na.cross(vecs[ax,:], normal_vector).ravel()
+ if self.rotation_vector is None:
+ self.rotation_vector=north_vector
else:
if self.steady_north:
north_vector = north_vector - na.dot(north_vector,normal_vector)*normal_vector
north_vector /= na.sqrt(na.dot(north_vector, north_vector))
east_vector = -na.cross(north_vector, normal_vector).ravel()
east_vector /= na.sqrt(na.dot(east_vector, east_vector))
+ self.normal_vector = normal_vector
self.unit_vectors = [north_vector, east_vector, normal_vector]
self.box_vectors = na.array([self.unit_vectors[0]*self.width[0],
self.unit_vectors[1]*self.width[1],
@@ -261,11 +266,15 @@
The 'up' direction for the plane of rays. If not specific,
calculated automatically.
"""
- if width is None: width = self.width
+ if width is None:
+ width = self.width
if not iterable(width):
width = (width, width, width) # front/back, left/right, top/bottom
self.width = width
- if center is not None: self.center = center
+ if center is not None:
+ self.center = center
+ if north_vector is None:
+ north_vector = self.north_vector
if normal_vector is None:
normal_vector = self.front_center-self.center
self._setup_normalized_vectors(normal_vector, north_vector)
@@ -383,6 +392,106 @@
self.zoom(f)
yield self.snapshot()
+ def move_to(self, final, n_steps, final_width=None):
+ r"""Loop over a look_at
+
+ This will yield `n_steps` snapshots until the current view has been
+ moved to a final center of `final` with a final width of final_width.
+
+ Parameters
+ ----------
+ final : array_like
+ The final center to move to after `n_steps`
+ n_steps : int
+ The number of look_at snapshots to make.
+ final_width: float or array_like, optional
+ Specifies the final width after `n_steps`. Useful for
+ moving and zooming at the same time.
+
+ Examples
+ --------
+
More information about the yt-svn
mailing list