Skip to content

Commit

Permalink
Merge branch 'giumas-add_namespace' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jreadey committed Oct 6, 2015
2 parents 6d80cf2 + e9f2c46 commit 8f4039f
Show file tree
Hide file tree
Showing 61 changed files with 260 additions and 388 deletions.
4 changes: 2 additions & 2 deletions HDFCompass.py
Expand Up @@ -10,5 +10,5 @@
# request a copy from help@hdfgroup.org. #
##############################################################################

import compass_viewer
compass_viewer.run()
from hdf_compass import compass_viewer
compass_viewer.run()
2 changes: 1 addition & 1 deletion HDFCompass.spec
Expand Up @@ -43,4 +43,4 @@ exe = EXE(pyz,
debug=False,
strip=None,
upx=False,
console=False , icon='compass.ico')
console=False, icon='compass.ico')
8 changes: 0 additions & 8 deletions filesystem_model/test.py

This file was deleted.

8 changes: 0 additions & 8 deletions hdf5_model/test.py

This file was deleted.

9 changes: 9 additions & 0 deletions hdf_compass/__init__.py
@@ -0,0 +1,9 @@
"""
HDFCompass Namespace
"""
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
35 changes: 14 additions & 21 deletions array_model/__init__.py → hdf_compass/array_model/__init__.py
Expand Up @@ -14,34 +14,30 @@
Testing model for array types.
"""

import os
import os.path as op
import numpy as np

import compass_model
from hdf_compass import compass_model

import numpy as np

DT_CMP = np.dtype([('a','i'),('b','f')])
DT_CMP = np.dtype([('a', 'i'), ('b', 'f')])

DATA = {'a_0d': np.array(1),
'a_1d': np.arange(10),
'a_2d': np.arange(10*10).reshape((10,10)),
'a_3d': np.arange(10*10*10).reshape((10,10,10)),
'a_4d': np.arange(10*10*10*10).reshape((10,10,10,10)),
'cmp_0d': np.array((1,2), dtype=DT_CMP),
'a_2d': np.arange(10 * 10).reshape((10, 10)),
'a_3d': np.arange(10 * 10 * 10).reshape((10, 10, 10)),
'a_4d': np.arange(10 * 10 * 10 * 10).reshape((10, 10, 10, 10)),
'cmp_0d': np.array((1, 2), dtype=DT_CMP),
'cmp_1d': np.ones((10,), dtype=DT_CMP),
'cmp_2d': np.ones((10,10), dtype=DT_CMP),
'cmp_3d': np.ones((10,10,10),dtype=DT_CMP),
'cmp_4d': np.ones((10,10,10,10),dtype=DT_CMP),
'cmp_2d': np.ones((10, 10), dtype=DT_CMP),
'cmp_3d': np.ones((10, 10, 10), dtype=DT_CMP),
'cmp_4d': np.ones((10, 10, 10, 10), dtype=DT_CMP),
's_0d': np.array("Hello"),
's_1d': np.array(("Hello",)),
'v_0d': np.array('\x01', dtype='|V1'),
'nonsquare': np.arange(5*10).reshape((5,10)),
'nonsquare': np.arange(5 * 10).reshape((5, 10)),
}

class ArrayStore(compass_model.Store):

class ArrayStore(compass_model.Store):
"""
A "data store" represented by the file system.
Expand All @@ -66,7 +62,7 @@ def root(self):
@property
def valid(self):
return True

@staticmethod
def canhandle(url):
if url == "array://localhost":
Expand All @@ -86,7 +82,6 @@ def getparent(self, key):


class ArrayContainer(compass_model.Container):

"""
Represents a directory in the filesystem.
"""
Expand Down Expand Up @@ -131,7 +126,6 @@ def __getitem__(self, idx):


class Array(compass_model.Array):

"""
An N-D array
"""
Expand Down Expand Up @@ -176,7 +170,6 @@ def __getitem__(self, args):


class ArrayKV(compass_model.KeyValue):

classkind = "Array Key/Value Attrs"

@staticmethod
Expand All @@ -186,7 +179,7 @@ def canhandle(store, key):
def __init__(self, store, key):
self._store = store
self._key = key
self.data = {'a': np.array((1,2)), 'b': np.array("Hello"), 'c': np.array('\x01', dtype='|V1')}
self.data = {'a': np.array((1, 2)), 'b': np.array("Hello"), 'c': np.array('\x01', dtype='|V1')}

@property
def key(self):
Expand Down Expand Up @@ -216,4 +209,4 @@ def __getitem__(self, args):
ArrayStore.push(ArrayContainer)
ArrayStore.push(Array)

compass_model.push(ArrayStore)
compass_model.push(ArrayStore)
26 changes: 13 additions & 13 deletions asc_model/__init__.py → hdf_compass/asc_model/__init__.py
Expand Up @@ -20,14 +20,14 @@

import sys
import os.path as op
import numpy as np
import linecache

import compass_model
import numpy as np

from hdf_compass import compass_model

class AsciiGrid(compass_model.Store):

class AsciiGrid(compass_model.Store):
"""
A "data store" represented by an ascii grid file.
"""
Expand Down Expand Up @@ -82,8 +82,8 @@ def getFilePath(self):
prefixLen = len('file://')
return self._url[prefixLen:]

class ASCFile(compass_model.Array):

class ASCFile(compass_model.Array):
"""
Represents a .asc grid file.
"""
Expand Down Expand Up @@ -122,7 +122,7 @@ def description(self):

@property
def shape(self):
return (self._nrows, self._ncols)
return self._nrows, self._ncols

@property
def dtype(self):
Expand All @@ -135,7 +135,6 @@ def __getitem__(self, args):


class Attributes(compass_model.KeyValue):

classkind = "Attributes of ASC Grid File"

@staticmethod
Expand All @@ -149,17 +148,17 @@ def __init__(self, store, key):
self._key = key
filePath = self._store.getFilePath()
self.data = {'NODATA Value': float(linecache.getline(filePath, 6).lstrip("NODATA_value")),
'cellsize': float(linecache.getline(filePath, 5).lstrip("cellsize")),
'yllcorner': float(linecache.getline(filePath, 4).lstrip("yllcorner")),
'xllcorner': float(linecache.getline(filePath, 3).lstrip("xllcorner"))}
'cellsize': float(linecache.getline(filePath, 5).lstrip("cellsize")),
'yllcorner': float(linecache.getline(filePath, 4).lstrip("yllcorner")),
'xllcorner': float(linecache.getline(filePath, 3).lstrip("xllcorner"))}

@property
def key(self):
return self._key

@property
def store(self):
self._store
return self._store

@property
def displayname(self):
Expand All @@ -168,7 +167,7 @@ def displayname(self):
@property
def description(self):
return self.displayname

def close(self):
self._valid = False

Expand All @@ -179,7 +178,8 @@ def keys(self):
def __getitem__(self, args):
return self.data[args]

AsciiGrid.push(Attributes) # attribute data
AsciiGrid.push(ASCFile) # array

AsciiGrid.push(Attributes) # attribute data
AsciiGrid.push(ASCFile) # array

compass_model.push(AsciiGrid)

0 comments on commit 8f4039f

Please sign in to comment.