[yt-svn] commit/yt: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Tue Sep 25 13:31:28 PDT 2012
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/d3f1fbececb6/
changeset: d3f1fbececb6
branch: yt
user: scopatz
date: 2012-09-25 22:26:05
summary: Added fix for #428
affected #: 1 file
diff -r ae3f6a9e07a18644470391eaa684434ffc14bb8a -r d3f1fbececb63a7db41d46f496791ba41bb88e32 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -853,11 +853,15 @@
return names
def _send_zmq(self):
- from IPython.zmq.pylab.backend_inline import \
- send_figure
+ try:
+ # pre-IPython v0.14
+ from IPython.zmq.pylab.backend_inline import send_figure as display
+ except ImportError:
+ # IPython v0.14+
+ from IPython.core.display import display
for k, v in sorted(self.plots.iteritems()):
canvas = FigureCanvasAgg(v.figure)
- send_figure(v.figure)
+ display(v.figure)
def show(self):
r"""This will send any existing plots to the IPython notebook.
https://bitbucket.org/yt_analysis/yt/changeset/dfe2b9787bc7/
changeset: dfe2b9787bc7
branch: yt
user: scopatz
date: 2012-09-25 22:26:45
summary: merged upstream changes.
affected #: 9 files
diff -r d3f1fbececb63a7db41d46f496791ba41bb88e32 -r dfe2b9787bc7b39b6a82bc904fee5d3967502c37 yt/analysis_modules/level_sets/clump_handling.py
--- a/yt/analysis_modules/level_sets/clump_handling.py
+++ b/yt/analysis_modules/level_sets/clump_handling.py
@@ -133,6 +133,7 @@
else:
exec(operation)
+ if self.children is None: return
for child in self.children:
child.pass_down(operation)
diff -r d3f1fbececb63a7db41d46f496791ba41bb88e32 -r dfe2b9787bc7b39b6a82bc904fee5d3967502c37 yt/frontends/_skeleton/__init__.py
--- /dev/null
+++ b/yt/frontends/_skeleton/__init__.py
@@ -0,0 +1,25 @@
+"""
+API for yt.frontends.skeleton
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: Columbia University
+Homepage: http://yt-project.org/
+License:
+ Copyright (C) 2012 Matthew Turk. 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/>.
+
+"""
diff -r d3f1fbececb63a7db41d46f496791ba41bb88e32 -r dfe2b9787bc7b39b6a82bc904fee5d3967502c37 yt/frontends/_skeleton/api.py
--- /dev/null
+++ b/yt/frontends/_skeleton/api.py
@@ -0,0 +1,37 @@
+"""
+API for yt.frontends._skeleton
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: Columbia University
+Homepage: http://yt-project.org/
+License:
+ Copyright (C) 2012 Matthew Turk. 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 .data_structures import \
+ SkeletonGrid, \
+ SkeletonHierarchy, \
+ SkeletonStaticOutput
+
+from .fields import \
+ SkeletonFieldInfo, \
+ add_flash_field
+
+from .io import \
+ IOHandlerSkeleton
diff -r d3f1fbececb63a7db41d46f496791ba41bb88e32 -r dfe2b9787bc7b39b6a82bc904fee5d3967502c37 yt/frontends/_skeleton/data_structures.py
--- /dev/null
+++ b/yt/frontends/_skeleton/data_structures.py
@@ -0,0 +1,157 @@
+"""
+Skeleton data structures
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: Columbia University
+Homepage: http://yt-project.org/
+License:
+ Copyright (C) 2012 Matthew Turk. 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/>.
+"""
+
+import h5py
+import stat
+import numpy as np
+import weakref
+
+from yt.funcs import *
+from yt.data_objects.grid_patch import \
+ AMRGridPatch
+from yt.data_objects.hierarchy import \
+ AMRHierarchy
+from yt.data_objects.static_output import \
+ StaticOutput
+from yt.utilities.definitions import \
+ mpc_conversion, sec_conversion
+from yt.utilities.io_handler import \
+ io_registry
+from yt.utilities.physical_constants import cm_per_mpc
+from .fields import SkeletonFieldInfo, add_flash_field, KnownSkeletonFields
+from yt.data_objects.field_info_container import \
+ FieldInfoContainer, NullFunc, ValidateDataField, TranslationFunc
+
+class SkeletonGrid(AMRGridPatch):
+ _id_offset = 0
+ #__slots__ = ["_level_id", "stop_index"]
+ def __init__(self, id, hierarchy, level):
+ AMRGridPatch.__init__(self, id, filename = hierarchy.hierarchy_filename,
+ hierarchy = hierarchy)
+ self.Parent = None
+ self.Children = []
+ self.Level = level
+
+ def __repr__(self):
+ return "SkeletonGrid_%04i (%s)" % (self.id, self.ActiveDimensions)
+
+class SkeletonHierarchy(AMRHierarchy):
+
+ grid = SkeletonGrid
+ float_type = np.float64
+
+ def __init__(self, pf, data_style='skeleton'):
+ self.data_style = data_style
+ self.parameter_file = weakref.proxy(pf)
+ # for now, the hierarchy file is the parameter file!
+ self.hierarchy_filename = self.parameter_file.parameter_filename
+ self.directory = os.path.dirname(self.hierarchy_filename)
+ AMRHierarchy.__init__(self, pf, data_style)
+
+ def _initialize_data_storage(self):
+ pass
+
+ def _detect_fields(self):
+ # This needs to set a self.field_list that contains all the available,
+ # on-disk fields.
+ pass
+
+ def _count_grids(self):
+ # This needs to set self.num_grids
+ pass
+
+ def _parse_hierarchy(self):
+ # This needs to fill the following arrays, where N is self.num_grids:
+ # self.grid_left_edge (N, 3) <= float64
+ # self.grid_right_edge (N, 3) <= float64
+ # self.grid_dimensions (N, 3) <= int
+ # self.grid_particle_count (N, 1) <= int
+ # self.grid_levels (N, 1) <= int
+ # self.grids (N, 1) <= grid objects
+ #
+ pass
+
+ def _populate_grid_objects(self):
+ # For each grid, this must call:
+ # grid._prepare_grid()
+ # grid._setup_dx()
+ # This must also set:
+ # grid.Children <= list of child grids
+ # grid.Parent <= parent grid
+ # This is handled by the frontend because often the children must be
+ # identified.
+ pass
+
+class SkeletonStaticOutput(StaticOutput):
+ _hierarchy_class = SkeletonHierarchy
+ _fieldinfo_fallback = SkeletonFieldInfo
+ _fieldinfo_known = KnownSkeletonFields
+ _handle = None
+
+ def __init__(self, filename, data_style='skeleton',
+ storage_filename = None,
+ conversion_override = None):
+
+ if conversion_override is None: conversion_override = {}
+ self._conversion_override = conversion_override
+
+ StaticOutput.__init__(self, filename, data_style)
+ self.storage_filename = storage_filename
+
+ def _set_units(self):
+ # This needs to set up the dictionaries that convert from code units to
+ # CGS. The needed items are listed in the second entry:
+ # self.time_units <= sec_conversion
+ # self.conversion_factors <= mpc_conversion
+ # self.units <= On-disk fields
+ pass
+
+ def _parse_parameter_file(self):
+ # This needs to set up the following items:
+ #
+ # self.unique_identifier
+ # self.parameters <= full of code-specific items of use
+ # self.domain_left_edge <= array of float64
+ # self.domain_right_edge <= array of float64
+ # self.dimensionality <= int
+ # self.domain_dimensions <= array of int64
+ # self.current_time <= simulation time in code units
+ #
+ # We also set up cosmological information. Set these to zero if
+ # non-cosmological.
+ #
+ # self.cosmological_simulation <= int, 0 or 1
+ # self.current_redshift <= float
+ # self.omega_lambda <= float
+ # self.omega_matter <= float
+ # self.hubble_constant <= float
+
+ @classmethod
+ def _is_valid(self, *args, **kwargs):
+ # This accepts a filename or a set of arguments and returns True or
+ # False depending on if the file is of the type requested.
+ return False
+
+
diff -r d3f1fbececb63a7db41d46f496791ba41bb88e32 -r dfe2b9787bc7b39b6a82bc904fee5d3967502c37 yt/frontends/_skeleton/fields.py
--- /dev/null
+++ b/yt/frontends/_skeleton/fields.py
@@ -0,0 +1,102 @@
+"""
+Skeleton-specific fields
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: Columbia University
+Homepage: http://yt-project.org/
+License:
+ Copyright (C) 2012 Matthew Turk. 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 yt.data_objects.field_info_container import \
+ FieldInfoContainer, \
+ NullFunc, \
+ TranslationFunc, \
+ FieldInfo, \
+ ValidateParameter, \
+ ValidateDataField, \
+ ValidateProperty, \
+ ValidateSpatial, \
+ ValidateGridType
+import yt.data_objects.universal_fields
+from yt.utilities.physical_constants import \
+ kboltz
+
+# The first field container is where any fields that exist on disk go, along
+# with their conversion factors, display names, etc.
+
+KnownSkeletonFields = FieldInfoContainer()
+add_skeleton_field = KnownSkeletonFields.add_field
+
+SkeletonFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo)
+add_field = SkeletonFieldInfo.add_field
+
+# Often, we want to translate between fields on disk and fields in yt. This
+# construct shows how to do that. Note that we use TranslationFunc.
+
+translation_dict = {"x-velocity": "velx",
+ "y-velocity": "vely",
+ "z-velocity": "velz",
+ "Density": "dens",
+ "Temperature": "temp",
+ "Pressure" : "pres",
+ "Grav_Potential" : "gpot",
+ "particle_position_x" : "particle_posx",
+ "particle_position_y" : "particle_posy",
+ "particle_position_z" : "particle_posz",
+ "particle_velocity_x" : "particle_velx",
+ "particle_velocity_y" : "particle_vely",
+ "particle_velocity_z" : "particle_velz",
+ "particle_index" : "particle_tag",
+ "Electron_Fraction" : "elec",
+ "HI_Fraction" : "h ",
+ "HD_Fraction" : "hd ",
+ "HeI_Fraction": "hel ",
+ "HeII_Fraction": "hep ",
+ "HeIII_Fraction": "hepp",
+ "HM_Fraction": "hmin",
+ "HII_Fraction": "hp ",
+ "H2I_Fraction": "htwo",
+ "H2II_Fraction": "htwp",
+ "DI_Fraction": "deut",
+ "DII_Fraction": "dplu",
+ "ParticleMass": "particle_mass",
+ "Flame_Fraction": "flam"}
+
+for f,v in translation_dict.items():
+ if v not in KnownSkeletonFields:
+ pfield = v.startswith("particle")
+ add_skeleton_field(v, function=NullFunc, take_log=False,
+ validators = [ValidateDataField(v)],
+ particle_type = pfield)
+ if f.endswith("_Fraction") :
+ dname = "%s\/Fraction" % f.split("_")[0]
+ else :
+ dname = f
+ ff = KnownSkeletonFields[v]
+ pfield = f.startswith("particle")
+ add_field(f, TranslationFunc(v),
+ take_log=KnownSkeletonFields[v].take_log,
+ units = ff._units, display_name=dname,
+ particle_type = pfield)
+
+# Here's an example of adding a new field:
+
+add_skeleton_field("dens", function=NullFunc, take_log=True,
+ convert_function=_get_convert("dens"),
+ units=r"\rm{g}/\rm{cm}^3")
diff -r d3f1fbececb63a7db41d46f496791ba41bb88e32 -r dfe2b9787bc7b39b6a82bc904fee5d3967502c37 yt/frontends/_skeleton/io.py
--- /dev/null
+++ b/yt/frontends/_skeleton/io.py
@@ -0,0 +1,44 @@
+"""
+Skeleton-specific IO functions
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: Columbia University
+Homepage: http://yt-project.org/
+License:
+ Copyright (C) 2012 Matthew Turk. 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/>.
+"""
+
+import numpy as np
+import h5py
+
+from yt.utilities.io_handler import \
+ BaseIOHandler
+
+class IOHandlerSkeleton(BaseIOHandler):
+ _particle_reader = False
+ _data_style = "skeleton"
+
+ def _read_data_set(self, grid, field):
+ # This must return the array, of size/shape grid.ActiveDimensions, that
+ # corresponds to 'field'.
+ pass
+
+ def _read_data_slice(self, grid, field, axis, coord):
+ # If this is not implemented, the IO handler will just slice a
+ # _read_data_set item.
+ pass
diff -r d3f1fbececb63a7db41d46f496791ba41bb88e32 -r dfe2b9787bc7b39b6a82bc904fee5d3967502c37 yt/frontends/_skeleton/setup.py
--- /dev/null
+++ b/yt/frontends/_skeleton/setup.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+import setuptools
+import os
+import sys
+import os.path
+
+
+def configuration(parent_package='', top_path=None):
+ from numpy.distutils.misc_util import Configuration
+ config = Configuration('skeleton', parent_package, top_path)
+ config.make_config_py() # installs __config__.py
+ #config.make_svn_version_py()
+ return config
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