Commits

drudd  committed 7857d97

Added artio2. Need to link cart:/src/tools/artio directory to
yt/frontends/artio2/artio (useful since artio is under development).

  • Participants
  • Parent commits 847938d

Comments (0)

Files changed (8)

File yt/frontends/artio2/__init__.py

Empty file added.

File yt/frontends/artio2/_artio_reader.pyx

+# warning: this may not be portable
+from libc.stdint cimport int32_t, int64_t
+
+cdef extern from "artio.h" :
+    ctypedef struct artio_file_struct "artio_file_struct" :
+        pass
+    ctypedef artio_file_struct *artio_file "artio_file"
+
+    ctypedef struct artio_context_struct "artio_context_struct" :
+        pass
+    ctypedef artio_context_struct *artio_context "artio_context"
+    cdef artio_context artio_context_global
+
+    cdef int ARTIO_OPEN_HEADER "ARTIO_OPEN_HEADER"
+    cdef int ARTIO_OPEN_GRID "ARTIO_OPEN_GRID"
+    cdef int ARTIO_OPEN_PARTICLES "ARTIO_OPEN_PARTICLES" 
+
+    cdef int ARTIO_SUCCESS "ARTIO_SUCCESS"
+
+    artio_file artio_fileset_open(char *file_prefix, int type, artio_context context )
+    int artio_fileset_close( artio_file handle )
+
+    # parameter functions
+    cdef int artio_parameter_iterate( artio_file handle, char *key, int *type, int *length )
+    cdef int artio_parameter_get_array_length(artio_file handle, char * key, int *length)
+
+    cdef int artio_parameter_get_int(artio_file handle, char * key, int32_t * value)
+    cdef int artio_parameter_get_int_array(artio_file handle, char * key, int length,
+            int32_t *values)
+
+cpdef artio_is_valid( char *file_prefix ) :
+    cdef artio_file handle = artio_fileset_open( file_prefix, 
+                ARTIO_OPEN_HEADER, artio_context_global )
+    if handle == NULL :
+        print "Handle is null"
+        return False;
+    else :
+        artio_fileset_close(handle) 
+    return True

File yt/frontends/artio2/api.py

+from .data_structures import \
+    Artio2StaticOutput
+
+from .io import \
+      IOHandlerArtio2

File yt/frontends/artio2/data_structures.py

+#from _artio_reader import artio_is_valid
+import _artio_reader
+
+from yt.data_objects.static_output import \
+    StaticOutput
+
+class Artio2StaticOutput(StaticOutput):
+    _handle = None
+
+    def __init__(self, filename, data_style='artio2'):
+        if self._handle is not None; return
+        self.fileset_prefix = filename[:-4]
+        self._handle = _artio_reader.artio_open_fileset( prefix, ARTIO_OPEN_HEADER, artio_context_global )
+        StaticOutput.__init__(self, filename, data_style)
+
+    def _parse_parameter_file(self) :
+        self.parameters = _artio_reader.artio_read_parameters( self._handle )
+
+    @classmethod
+    def _is_valid(self, *args, **kwargs) :
+        # a valid artio header file starts with a prefix and ends with .art
+        if not args[0].endswith(".art"): return False
+        return _artio_reader.artio_is_valid(args[0][:-4])
+
+

File yt/frontends/artio2/io.py

+from yt.utilities.io_handler import \
+    BaseIOHandler
+
+class IOHandlerArtio2(BaseIOHandler) :
+    _data_style = "artio2"
+
+    def _read_fluid_selection(self, chunks, selector, fields, size):
+        return

File yt/frontends/artio2/setup.py

+#!/usr/bin/env python
+import setuptools
+import os
+import sys
+import os.path
+from glob import glob
+
+def configuration(parent_package='', top_path=None):
+    from numpy.distutils.misc_util import Configuration
+    config = Configuration('artio2', parent_package, top_path)
+    config.add_extension("_artio_reader",
+        ["yt/frontends/artio2/_artio_reader.pyx"]+
+            glob("yt/frontends/artio2/artio/*.c"),
+        language="c",
+        include_dirs=["yt/frontends/artio2/artio/"],
+        depends=glob("yt/frontends/artio2/artio/*.h") )
+    config.make_config_py()  # installs __config__.py
+    #config.make_svn_version_py()
+    return config

File yt/frontends/setup.py

     config.add_subpackage("nyx")
     config.add_subpackage("orion")
     config.add_subpackage("artio")
+    config.add_subpackage("artio2")
     config.add_subpackage("ramses")
     config.add_subpackage("tiger")
     config.add_subpackage("art")
 from yt.frontends.artio.api import \
     ARTIOStaticOutput, ARTIOFieldInfo, add_artio_field
 
+from yt.frontends.artio2.api import \
+    Artio2StaticOutput
+
 from yt.frontends.ramses.api import \
     RAMSESStaticOutput, RAMSESFieldInfo, add_ramses_field