[yt-svn] commit/yt-3.0: 4 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sat Jul 27 12:31:40 PDT 2013
4 new commits in yt-3.0:
https://bitbucket.org/yt_analysis/yt-3.0/commits/564d6b10c024/
Changeset: 564d6b10c024
Branch: yt-3.0
User: ngoldbaum
Date: 2013-07-26 22:53:57
Summary: Initial work on tipsy frontend improvements.
Affected #: 2 files
diff -r 1129fc0779d1c70eb8393017bf70acd97afff0a4 -r 564d6b10c0247d777113781502cf52e6f32f25d2 .hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -12,13 +12,16 @@
yt/frontends/sph/smoothing_kernel.c
yt/geometry/fake_octree.c
yt/geometry/oct_container.c
+yt/geometry/oct_visitors.c
yt/geometry/particle_deposit.c
+yt/geometry/particle_oct_container.c
yt/geometry/selection_routines.c
yt/utilities/amr_utils.c
yt/utilities/kdtree/forthonf2c.h
yt/utilities/libconfig_wrapper.c
yt/utilities/spatial/ckdtree.c
yt/utilities/lib/alt_ray_tracers.c
+yt/utilities/lib/amr_kdtools.c
yt/utilities/lib/CICDeposit.c
yt/utilities/lib/ContourFinding.c
yt/utilities/lib/DepthFirstOctree.c
diff -r 1129fc0779d1c70eb8393017bf70acd97afff0a4 -r 564d6b10c0247d777113781502cf52e6f32f25d2 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -357,13 +357,14 @@
domain_left_edge = None,
domain_right_edge = None,
unit_base = None,
- cosmology_parameters = None):
+ cosmology_parameters = None,
+ parameter_file = None):
self.endian = endian
self.storage_filename = None
if domain_left_edge is None:
- domain_left_edge = np.zeros(3, "float64") - 0.5
+ domain_left_edge = np.zeros(3, "float64") - 1.0
if domain_right_edge is None:
- domain_right_edge = np.zeros(3, "float64") + 0.5
+ domain_right_edge = np.zeros(3, "float64") + 1.0
self.domain_left_edge = np.array(domain_left_edge, dtype="float64")
self.domain_right_edge = np.array(domain_right_edge, dtype="float64")
@@ -375,6 +376,7 @@
self._unit_base = unit_base or {}
self._cosmology_parameters = cosmology_parameters
+ self._param_file = parameter_file
super(TipsyStaticOutput, self).__init__(filename, data_style)
def __repr__(self):
@@ -382,8 +384,8 @@
def _parse_parameter_file(self):
- # The entries in this header are capitalized and named to match Table 4
- # in the GADGET-2 user guide.
+ # Parsing the header of the tipsy file, from this we obtain
+ # the snapshot time and particle counts.
f = open(self.parameter_filename, "rb")
hh = self.endian + "".join(["%s" % (b) for a,b in self._header_spec])
@@ -398,6 +400,25 @@
int(os.stat(self.parameter_filename)[stat.ST_CTIME])
# Set standard values
+ # Read in parameter file, if available.
+ if self._param_file == None:
+ pfn = glob.glob(os.path.dirname+'*.param')
+ assert len(fn) < 2, \
+ "More than one param file is in the data directory"
+ if pfn == []:
+ pfn = None
+ else:
+ pfn = self._param_file
+
+ # modified version of pf read from enzo frontend
+ lines = open(pfn).readlines()
+ for line in (l.strip() for l in lines):
+ # skip comment lines
+ if line.strip().startswith('#'):
+ pass
+ param, vals = (i.strip() for i in line.splot('=',1))
+ import pdb; pdb.set_trace()
+
# This may not be correct.
self.current_time = hvals["time"]
@@ -432,8 +453,12 @@
cosmo = Cosmology(self.hubble_constant * 100.0,
self.omega_matter, self.omega_lambda)
length_unit = DW * self.units['cm'] # Get it in proper cm
- density_unit = cosmo.CriticalDensity(self.current_redshift)
- mass_unit = density_unit * length_unit**3
+ if self.current_redshift:
+ density_unit = cosmo.CriticalDensity(self.current_redshift)
+ mass_unit = density_unit * length_unit**3
+ else:
+ mass_unit = mass_sun_cgs
+ density_unit = mass_unit / length_unit**3
time_unit = 1.0 / np.sqrt(G*density_unit)
velocity_unit = length_unit / time_unit
self.conversion_factors["velocity"] = velocity_unit
https://bitbucket.org/yt_analysis/yt-3.0/commits/db268d5164b2/
Changeset: db268d5164b2
Branch: yt-3.0
User: ngoldbaum
Date: 2013-07-27 06:28:18
Summary: Can read in tipsy parameters from a param file. Support for non-comoving cosmologies.
Affected #: 1 file
diff -r 564d6b10c0247d777113781502cf52e6f32f25d2 -r db268d5164b24b33a3a1485e621420dc4325ecca yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -28,6 +28,7 @@
import stat
import weakref
import struct
+import glob
from itertools import izip
from yt.utilities.fortran_utils import read_record
@@ -46,6 +47,7 @@
G, \
gravitational_constant_cgs, \
km_per_pc, \
+ cm_per_kpc, \
mass_sun_cgs
from yt.utilities.cosmology import Cosmology
from .fields import \
@@ -107,11 +109,12 @@
mpch = {}
mpch.update(mpc_conversion)
unit_base = self._unit_base or {}
- for unit in mpc_conversion:
- mpch['%sh' % unit] = mpch[unit] * self.hubble_constant
- mpch['%shcm' % unit] = (mpch["%sh" % unit] /
- (1 + self.current_redshift))
- mpch['%scm' % unit] = mpch[unit] / (1 + self.current_redshift)
+ if self.cosmological_simulation:
+ for unit in mpc_conversion:
+ mpch['%sh' % unit] = mpch[unit] * self.hubble_constant
+ mpch['%shcm' % unit] = (mpch["%sh" % unit] /
+ (1 + self.current_redshift))
+ mpch['%scm' % unit] = mpch[unit] / (1 + self.current_redshift)
# ud == unit destination
# ur == unit registry
for ud, ur in [(self.units, mpch), (self.time_units, sec_conversion)]:
@@ -362,9 +365,9 @@
self.endian = endian
self.storage_filename = None
if domain_left_edge is None:
- domain_left_edge = np.zeros(3, "float64") - 1.0
+ domain_left_edge = np.zeros(3, "float64") - 0.5
if domain_right_edge is None:
- domain_right_edge = np.zeros(3, "float64") + 1.0
+ domain_right_edge = np.zeros(3, "float64") + 0.5
self.domain_left_edge = np.array(domain_left_edge, dtype="float64")
self.domain_right_edge = np.array(domain_right_edge, dtype="float64")
@@ -402,45 +405,55 @@
# Read in parameter file, if available.
if self._param_file == None:
- pfn = glob.glob(os.path.dirname+'*.param')
- assert len(fn) < 2, \
+ pfn = glob.glob(os.path.dirname(self.parameter_filename)+'/*.param')
+ assert len(pfn) < 2, \
"More than one param file is in the data directory"
if pfn == []:
pfn = None
+ else:
+ pfn = pfn[0]
else:
pfn = self._param_file
- # modified version of pf read from enzo frontend
lines = open(pfn).readlines()
for line in (l.strip() for l in lines):
# skip comment lines
if line.strip().startswith('#'):
- pass
- param, vals = (i.strip() for i in line.splot('=',1))
- import pdb; pdb.set_trace()
+ continue
+ param, val = (i.strip() for i in line.split('=',1))
+ if param.startswith('n') or param.startswith('i'):
+ val = long(val)
+ elif param.startswith('d'):
+ val = float(val)
+ elif param.startswith('b'):
+ val = bool(float(val))
+ self.parameters[param] = val
- # This may not be correct.
+ for key in hvals:
+ self.parameters[key] = hvals[key]
+
self.current_time = hvals["time"]
+ self.domain_dimensions = np.ones(3, "int32") * 2
+ if self.parameters.get('bPeriodic', True):
+ self.periodicity = (True, True, True)
+ else:
+ self.periodicity = (False, False, False)
- # NOTE: These are now set in the main initializer.
- #self.domain_left_edge = np.zeros(3, "float64") - 0.5
- #self.domain_right_edge = np.ones(3, "float64") + 0.5
- self.domain_dimensions = np.ones(3, "int32") * 2
- self.periodicity = (True, True, True)
-
- self.cosmological_simulation = 1
-
- cosm = self._cosmology_parameters or {}
- dcosm = dict(current_redshift = 0.0,
- omega_lambda = 0.0,
- omega_matter = 0.0,
- hubble_constant = 1.0)
- for param in ['current_redshift', 'omega_lambda',
- 'omega_matter', 'hubble_constant']:
- pval = cosm.get(param, dcosm[param])
- setattr(self, param, pval)
-
- self.parameters = hvals
+ if self.parameters.get('bComove', True):
+ self.cosmological_simulation = 1
+ cosm = self._cosmology_parameters or {}
+ dcosm = dict(current_redshift = 0.0,
+ omega_lambda = 0.0,
+ omega_matter = 0.0,
+ hubble_constant = 1.0)
+ for param in ['current_redshift', 'omega_lambda',
+ 'omega_matter', 'hubble_constant']:
+ pval = cosm.get(param, dcosm[param])
+ setattr(self, param, pval)
+ else:
+ self.cosmological_simulation = 0.0
+ kpc_unit = self.parameters.get('dKpcUnit', 1.0)
+ self._unit_base['cm'] = 1.0 / (kpc_unit * cm_per_kpc)
self.filename_template = self.parameter_filename
self.file_count = 1
@@ -449,15 +462,16 @@
def _set_units(self):
super(TipsyStaticOutput, self)._set_units()
- DW = (self.domain_right_edge - self.domain_left_edge).max()
- cosmo = Cosmology(self.hubble_constant * 100.0,
- self.omega_matter, self.omega_lambda)
- length_unit = DW * self.units['cm'] # Get it in proper cm
- if self.current_redshift:
+ if self.cosmological_simulation:
+ DW = (self.domain_right_edge - self.domain_left_edge).max()
+ cosmo = Cosmology(self.hubble_constant * 100.0,
+ self.omega_matter, self.omega_lambda)
+ length_unit = DW * self.units['cm'] # Get it in proper cm
density_unit = cosmo.CriticalDensity(self.current_redshift)
mass_unit = density_unit * length_unit**3
else:
- mass_unit = mass_sun_cgs
+ mass_unit = self.parameters.get('dMsolUnit', 1.0) * mass_sun_cgs
+ length_unit = self.parameters.get('dKpcUnit', 1.0) * cm_per_kpc
density_unit = mass_unit / length_unit**3
time_unit = 1.0 / np.sqrt(G*density_unit)
velocity_unit = length_unit / time_unit
https://bitbucket.org/yt_analysis/yt-3.0/commits/1cd2c9b1e6ba/
Changeset: 1cd2c9b1e6ba
Branch: yt-3.0
User: ngoldbaum
Date: 2013-07-27 06:33:48
Summary: Only try loading a parameter file if one is available.
Affected #: 1 file
diff -r db268d5164b24b33a3a1485e621420dc4325ecca -r 1cd2c9b1e6ba373bea18f9a8ba3d83a5dd787198 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -415,19 +415,20 @@
else:
pfn = self._param_file
- lines = open(pfn).readlines()
- for line in (l.strip() for l in lines):
- # skip comment lines
- if line.strip().startswith('#'):
- continue
- param, val = (i.strip() for i in line.split('=',1))
- if param.startswith('n') or param.startswith('i'):
- val = long(val)
- elif param.startswith('d'):
- val = float(val)
- elif param.startswith('b'):
- val = bool(float(val))
- self.parameters[param] = val
+ if pfn is not None:
+ lines = open(pfn).readlines()
+ for line in (l.strip() for l in lines):
+ # skip comment lines
+ if line.strip().startswith('#'):
+ continue
+ param, val = (i.strip() for i in line.split('=',1))
+ if param.startswith('n') or param.startswith('i'):
+ val = long(val)
+ elif param.startswith('d'):
+ val = float(val)
+ elif param.startswith('b'):
+ val = bool(float(val))
+ self.parameters[param] = val
for key in hvals:
self.parameters[key] = hvals[key]
https://bitbucket.org/yt_analysis/yt-3.0/commits/2e2648a8c3a3/
Changeset: 2e2648a8c3a3
Branch: yt-3.0
User: ngoldbaum
Date: 2013-07-27 08:25:38
Summary: Addressing style comments, cleaning up.
Affected #: 1 file
diff -r 1cd2c9b1e6ba373bea18f9a8ba3d83a5dd787198 -r 2e2648a8c3a3d1a75ff5456ef321577081adb31b yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -394,18 +394,20 @@
hh = self.endian + "".join(["%s" % (b) for a,b in self._header_spec])
hvals = dict([(a, c) for (a, b), c in zip(self._header_spec,
struct.unpack(hh, f.read(struct.calcsize(hh))))])
+ self.parameters.update(hvals)
self._header_offset = f.tell()
+ # These are always true, for now.
self.dimensionality = 3
self.refine_by = 2
self.parameters["HydroMethod"] = "sph"
+
self.unique_identifier = \
int(os.stat(self.parameter_filename)[stat.ST_CTIME])
- # Set standard values
# Read in parameter file, if available.
- if self._param_file == None:
- pfn = glob.glob(os.path.dirname(self.parameter_filename)+'/*.param')
+ if self._param_file is None:
+ pfn = glob.glob(os.path.join(self.directory, "*.param"))
assert len(pfn) < 2, \
"More than one param file is in the data directory"
if pfn == []:
@@ -416,11 +418,12 @@
pfn = self._param_file
if pfn is not None:
- lines = open(pfn).readlines()
- for line in (l.strip() for l in lines):
- # skip comment lines
- if line.strip().startswith('#'):
+ for line in (l.strip() for l in open(pfn)):
+ # skip comment lines and blank lines
+ l = line.strip()
+ if l.startswith('#') or l == '':
continue
+ # parse parameters according to tipsy parameter type
param, val = (i.strip() for i in line.split('=',1))
if param.startswith('n') or param.startswith('i'):
val = long(val)
@@ -430,9 +433,6 @@
val = bool(float(val))
self.parameters[param] = val
- for key in hvals:
- self.parameters[key] = hvals[key]
-
self.current_time = hvals["time"]
self.domain_dimensions = np.ones(3, "int32") * 2
if self.parameters.get('bPeriodic', True):
Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/
--
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