[yt-svn] commit/yt: MatthewTurk: Removing last vestiges of gadget in 2.x.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat Nov 2 08:08:31 PDT 2013


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/8d0535ad7b49/
Changeset:   8d0535ad7b49
Branch:      yt
User:        MatthewTurk
Date:        2013-11-02 16:08:12
Summary:     Removing last vestiges of gadget in 2.x.
Affected #:  8 files

diff -r 4aede64dc503166025f302a8419bcaa19837ccfe -r 8d0535ad7b494511d40304940ca6ee1280f35176 yt/frontends/gadget/__init__.py
--- a/yt/frontends/gadget/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-"""
-API for yt.frontends.gadget
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------

diff -r 4aede64dc503166025f302a8419bcaa19837ccfe -r 8d0535ad7b494511d40304940ca6ee1280f35176 yt/frontends/gadget/api.py
--- a/yt/frontends/gadget/api.py
+++ /dev/null
@@ -1,26 +0,0 @@
-"""
-API for yt.frontends.gadget
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-
-from .data_structures import \
-      GadgetGrid, \
-      GadgetHierarchy, \
-      GadgetStaticOutput
-
-from .fields import \
-      GadgetFieldInfo, \
-      add_gadget_field
-
-from .io import \
-      IOHandlerGadget

diff -r 4aede64dc503166025f302a8419bcaa19837ccfe -r 8d0535ad7b494511d40304940ca6ee1280f35176 yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ /dev/null
@@ -1,189 +0,0 @@
-"""
-Data structures for Gadget.
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-
-import h5py
-import numpy as np
-from itertools import izip
-
-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 \
-    sec_conversion
-
-from .fields import GadgetFieldInfo, KnownGadgetFields
-from yt.data_objects.field_info_container import \
-    FieldInfoContainer, NullFunc
-
-class GadgetGrid(AMRGridPatch):
-    _id_offset = 0
-    def __init__(self, hierarchy, id, dimensions, start,
-                 level, parent_id, particle_count):
-        AMRGridPatch.__init__(self, id, filename = hierarchy.filename,
-                              hierarchy = hierarchy)
-        self.Parent = [] # Only one parent per grid        
-        self.Children = []
-        self.Level = level
-        self.ActiveDimensions = dimensions.copy()
-        self.NumberOfParticles = particle_count
-        self.start_index = start.copy().astype("int64")
-        self.stop_index = self.start_index + dimensions.copy()
-        self.id = id
-        self._parent_id = parent_id
-        
-        try:
-            padd = '/data/grid_%010i/particles' % id
-            self.particle_types = self.hierarchy._handle[padd].keys()
-        except:
-            self.particle_types =  ()
-        self.filename = hierarchy.filename
-        
-    def __repr__(self):
-        return 'GadgetGrid_%05i'%self.id
-        
-class GadgetHierarchy(AMRHierarchy):
-    grid = GadgetGrid
-
-    def __init__(self, pf, data_style='gadget_hdf5'):
-        self.filename = pf.filename
-        self.directory = os.path.dirname(pf.filename)
-        self.data_style = data_style
-        self._handle = h5py.File(pf.filename)
-        AMRHierarchy.__init__(self, pf, data_style)
-        self._handle.close()
-        self._handle = None
-        
-
-    def _initialize_data_storage(self):
-        pass
-
-    def _detect_fields(self):
-        #this adds all the fields in 
-        #/particle_types/{Gas/Stars/etc.}/{position_x, etc.}
-        self.field_list = []
-        for ptype in self._handle['particle_types'].keys():
-            for field in self._handle['particle_types'+'/'+ptype]:
-                if field not in self.field_list:
-                    self.field_list += field,
-        
-    def _setup_classes(self):
-        dd = self._get_data_reader_dict()
-        AMRHierarchy._setup_classes(self, dd)
-        self.object_types.sort()
-
-    def _count_grids(self):
-        self.num_grids = len(self._handle['/grid_dimensions'])
-        
-    def _parse_hierarchy(self):
-        f = self._handle # shortcut
-        npa = np.array
-        DLE = self.parameter_file.domain_left_edge
-        DRE = self.parameter_file.domain_right_edge
-        DW = (DRE - DLE)
-        
-        self.grid_levels.flat[:] = f['/grid_level'][:].astype("int32")
-        LI = f['/grid_left_index'][:]
-        print LI
-        self.grid_dimensions[:] = f['/grid_dimensions'][:]
-        self.grid_left_edge[:]  = (LI * DW + DLE)
-        dxs = 1.0/(2**(self.grid_levels+1)) * DW
-        self.grid_right_edge[:] = self.grid_left_edge \
-                                + dxs *(1 + self.grid_dimensions)
-        self.grid_particle_count.flat[:] = f['/grid_particle_count'][:].astype("int32")
-        grid_parent_id = f['/grid_parent_id'][:]
-        self.max_level = np.max(self.grid_levels)
-        
-        args = izip(xrange(self.num_grids), self.grid_levels.flat,
-                    grid_parent_id, LI,
-                    self.grid_dimensions, self.grid_particle_count.flat)
-        self.grids = np.empty(len(args), dtype='object')
-        for gi, (j,lvl,p, le, d, n) in enumerate(args):
-            self.grids[gi] = self.grid(self,j,d,le,lvl,p,n)
-        
-    def _populate_grid_objects(self):    
-        for g in self.grids:
-            if g._parent_id >= 0:
-                parent = self.grids[g._parent_id]
-                g.Parent = parent
-                parent.Children.append(g)
-        for g in self.grids:
-            g._prepare_grid()
-            g._setup_dx()
-            
-    def _setup_derived_fields(self):
-        self.derived_field_list = []
-
-class GadgetStaticOutput(StaticOutput):
-    _hierarchy_class = GadgetHierarchy
-    _fieldinfo_fallback = GadgetFieldInfo
-    _fieldinfo_known = KnownGadgetFields
-
-    def __init__(self, filename,storage_filename=None) :
-        self.storage_filename = storage_filename
-        self.filename = filename
-        
-        StaticOutput.__init__(self, filename, 'gadget_infrastructure')
-        self._set_units()
-        
-    def _set_units(self):
-        self.units = {}
-        self.time_units = {}
-        self.time_units['1'] = 1
-        self.units['1'] = 1.0
-        self.units['cm'] = 1.0
-        self.units['unitary'] = 1.0 / \
-            (self.domain_right_edge - self.domain_left_edge).max()
-        for unit in sec_conversion.keys():
-            self.time_units[unit] = 1.0 / sec_conversion[unit]
-
-    def _parse_parameter_file(self):
-        fileh = h5py.File(self.filename)
-        sim_param = fileh['/simulation_parameters'].attrs
-        self.refine_by = sim_param['refine_by']
-        self.dimensionality = sim_param['dimensionality']
-        self.num_ghost_zones = sim_param['num_ghost_zones']
-        self.field_ordering = sim_param['field_ordering']
-        self.domain_dimensions = sim_param['domain_dimensions']
-        self.current_time = sim_param['current_time']
-        self.domain_left_edge = sim_param['domain_left_edge']
-        self.domain_right_edge = sim_param['domain_right_edge']
-        self.unique_identifier = sim_param['unique_identifier']
-        self.cosmological_simulation = sim_param['cosmological_simulation']
-        self.current_redshift = sim_param['current_redshift']
-        self.omega_lambda = sim_param['omega_lambda']
-        self.hubble_constant = sim_param['hubble_constant']
-        fileh.close()
-        
-         
-    @classmethod
-    def _is_valid(self, *args, **kwargs):
-        format = 'Gadget Infrastructure'
-        add1 = 'griddded_data_format'
-        add2 = 'data_software'
-        try:
-            fileh = h5py.File(args[0],'r')
-            if add1 in fileh['/'].items():
-                if add2 in fileh['/'+add1].attrs.keys():
-                    if fileh['/'+add1].attrs[add2] == format:
-                        fileh.close()
-                        return True
-            fileh.close()
-        except:
-            pass
-        return False

diff -r 4aede64dc503166025f302a8419bcaa19837ccfe -r 8d0535ad7b494511d40304940ca6ee1280f35176 yt/frontends/gadget/fields.py
--- a/yt/frontends/gadget/fields.py
+++ /dev/null
@@ -1,123 +0,0 @@
-"""
-Gadget-specific fields
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-
-import numpy as np
-
-from yt.funcs import *
-from yt.data_objects.field_info_container import \
-    FieldInfoContainer, \
-    FieldInfo, \
-    ValidateParameter, \
-    ValidateDataField, \
-    ValidateProperty, \
-    ValidateSpatial, \
-    ValidateGridType
-import yt.data_objects.universal_fields
-
-GadgetFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo)
-add_gadget_field = GadgetFieldInfo.add_field
-
-add_field = add_gadget_field
-
-translation_dict = {"particle_position_x" : "position_x",
-                    "particle_position_y" : "position_y",
-                    "particle_position_z" : "position_z",
-                   }
-
-def _generate_translation(mine, theirs):
-    pfield = mine.startswith("particle")
-    add_field(theirs, function=lambda a, b: b[mine], take_log=True,
-              particle_type = pfield)
-
-for f,v in translation_dict.items():
-    if v not in GadgetFieldInfo:
-        # Note here that it's the yt field that we check for particle nature
-        pfield = f.startswith("particle")
-        add_field(v, function=lambda a,b: None, take_log=False,
-                  validators = [ValidateDataField(v)],
-                  particle_type = pfield)
-    print "Setting up translator from %s to %s" % (v, f)
-    _generate_translation(v, f)
-
-
-#for f,v in translation_dict.items():
-#    add_field(f, function=lambda a,b: None, take_log=True,
-#        validators = [ValidateDataField(v)],
-#        units=r"\rm{cm}")
-#    add_field(v, function=lambda a,b: None, take_log=True,
-#        validators = [ValidateDataField(v)],
-#        units=r"\rm{cm}")
-          
-
-          
-add_field("position_x", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("position_x")],
-          particle_type = True,
-          units=r"\rm{cm}")
-
-add_field("position_y", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("position_y")],
-          particle_type = True,
-          units=r"\rm{cm}")
-
-add_field("position_z", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("position_z")],
-          particle_type = True,
-          units=r"\rm{cm}")
-
-add_field("VEL", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("VEL")],
-          units=r"")
-
-add_field("id", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("ID")],
-          units=r"")
-
-add_field("mass", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("mass")],
-          units=r"\rm{g}")
-def _particle_mass(field, data):
-    return data["mass"]/just_one(data["CellVolume"])
-def _convert_particle_mass(data):
-    return 1.0
-add_field("particle_mass", function=_particle_mass, take_log=True,
-          convert_function=_convert_particle_mass,
-          validators = [ValidateSpatial(0)],
-          units=r"\mathrm{g}\/\mathrm{cm}^{-3}")
-
-add_field("U", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("U")],
-          units=r"")
-
-add_field("NE", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("NE")],
-          units=r"")
-
-add_field("POT", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("POT")],
-          units=r"")
-
-add_field("ACCE", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("ACCE")],
-          units=r"")
-
-add_field("ENDT", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("ENDT")],
-          units=r"")
-
-add_field("TSTP", function=lambda a,b: None, take_log=True,
-          validators = [ValidateDataField("TSTP")],
-          units=r"")
-

diff -r 4aede64dc503166025f302a8419bcaa19837ccfe -r 8d0535ad7b494511d40304940ca6ee1280f35176 yt/frontends/gadget/io.py
--- a/yt/frontends/gadget/io.py
+++ /dev/null
@@ -1,45 +0,0 @@
-"""
-Gadget-specific data-file handling function
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-
-import h5py
-import numpy as np
-
-from yt.utilities.io_handler import \
-    BaseIOHandler
-
-class IOHandlerGadget(BaseIOHandler):
-    _data_style = 'gadget_infrastructure'
-    def _read_data(self, grid, field):
-        data = []
-        fh = h5py.File(grid.filename,mode='r')
-        for ptype in grid.particle_types:
-            address = '/data/grid_%010i/particles/%s/%s' % (grid.id, ptype, field)
-            data.append(fh[address][:])
-        if len(data) > 0:
-            data = np.concatenate(data)
-        fh.close()
-        return np.array(data)
-    def _read_field_names(self,grid): 
-        adr = grid.Address
-        fh = h5py.File(grid.filename,mode='r')
-        rets = cPickle.loads(fh['/root'].attrs['fieldnames'])
-        fh.close()
-        return rets
-
-    def _read_data_slice(self,grid, field, axis, coord):
-        #how would we implement axis here?
-        dat = self._read_data(grid,field)
-        return dat[coord]
-

diff -r 4aede64dc503166025f302a8419bcaa19837ccfe -r 8d0535ad7b494511d40304940ca6ee1280f35176 yt/frontends/gadget/setup.py
--- a/yt/frontends/gadget/setup.py
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/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('gadget', 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