OpenMatriX 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Debian-HOWTO.md +56 -0
- data/README.md +17 -4
- data/lib/OpenMatriX.rb +40 -21
- data/lib/OpenMatriX/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dec622f6548b7b7b28e605b4a68651c8499c3b39
|
4
|
+
data.tar.gz: 5efe8eb3fbdd801edb26879d2f8eb7bcae826dab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f6686191e9c169d315731161ff537f0481aac9229fd1426be5f9f514becca37d0575c05d96cc79a3901a42289df7292a997e8cd85e08c5a86984725f4d02c85
|
7
|
+
data.tar.gz: 07e97957246ec2f10d1bc3cca6ce81003d9fd0ed0532feab326a28e8986cc30b747aba10197c36edd87e20db1c685cd2e43518a51eac3fe812602a1baf87bd40
|
data/Debian-HOWTO.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Debian Installation and Use Howto
|
2
|
+
|
3
|
+
This how-to MAY be applicable to other linux distros. This was written while making stuff work
|
4
|
+
on a Debian Jessie virtual machine that was upgraded from Debian Wheezy.
|
5
|
+
|
6
|
+
# Prep
|
7
|
+
|
8
|
+
First off, remove the included hdf5 distro. You need 1.8.15, Jessie stable comes
|
9
|
+
with 1.8.13. And make sure you have 64 bit Debian. THIS WILL NOT WORK WITH A
|
10
|
+
32 BIT OPERATING SYSTEM.
|
11
|
+
|
12
|
+
```
|
13
|
+
sudo apt-get remove libhdf5-dev
|
14
|
+
```
|
15
|
+
|
16
|
+
Download the source for hdf5 ans szip from hdf5's webpage and un-tar it, compile, test, and install it:
|
17
|
+
```
|
18
|
+
wget http://www.hdfgroup.org/ftp/lib-external/szip/2.1/src/szip-2.1.tar.gz
|
19
|
+
gunzip szip-2.1.tar.gz
|
20
|
+
tar -xf szip-2.1.tar
|
21
|
+
rm szip-2.1.tar
|
22
|
+
cd szip-2.1
|
23
|
+
./configure --prefix=/usr/local/hdf5
|
24
|
+
make
|
25
|
+
sudo make install
|
26
|
+
|
27
|
+
wget http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.15-patch1.tar
|
28
|
+
tar -xf hdf5-1.8.15-patch1.tar
|
29
|
+
rm hdf5-1.8.15-patch1.tar
|
30
|
+
cd hdf5-1.8.15-patch1
|
31
|
+
./configure --prefix=/usr/local/hdf5 --enable-cxx --with-szlib=/usr/local/hdf5/lib
|
32
|
+
make
|
33
|
+
make check
|
34
|
+
sudo make install
|
35
|
+
sudo make check-install
|
36
|
+
```
|
37
|
+
|
38
|
+
At this time, there should be necessary .so files in /usr/local/hdf5/lib. You need these in the linker
|
39
|
+
path. To add them:
|
40
|
+
```
|
41
|
+
cd /etc/ld.so.conf.d
|
42
|
+
sudo touch hdf5.conf
|
43
|
+
```
|
44
|
+
Add (only) the line /usr/local/hdf5/lib to hdf5.conf (use whatever editor you like).
|
45
|
+
Then, reload the linker:
|
46
|
+
```
|
47
|
+
sudo ldconfig
|
48
|
+
```
|
49
|
+
|
50
|
+
# Landing
|
51
|
+
|
52
|
+
Install Ruby and Rails:
|
53
|
+
```
|
54
|
+
sudo apt-get install ruby
|
55
|
+
sudo apt-get install rubygems
|
56
|
+
gem install rails
|
data/README.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# OpenMatriX
|
2
2
|
|
3
|
-
OpenMatriX is a Ruby Gem to read
|
3
|
+
OpenMatriX is a Ruby Gem to read [Open Matrix files](https://sites.google.com/site/openmodeldata/). This was built for use on the web and to eventually have APIs that can return values from a matrix.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
Windows: This has only been tested on Windows 7-64 bit.
|
8
|
+
|
9
|
+
Linux: a 64-bit version is REQUIRED. This has been tested on a 32-bit Debian VM
|
10
|
+
and it would not work due to addressing issues, however it DOES work on a 64-bit
|
11
|
+
Debian VM.
|
4
12
|
|
5
13
|
## Installation
|
6
14
|
|
@@ -22,25 +30,30 @@ Or install it yourself as:
|
|
22
30
|
|
23
31
|
```ruby
|
24
32
|
# Open file
|
25
|
-
# OMX::OMXFile.new(filename)
|
33
|
+
# file_obj = OMX::OMXFile.new(filename)
|
26
34
|
file = OMX::OMXFile.new('filename.omx')
|
27
35
|
|
28
36
|
# Get the attributes from the file
|
37
|
+
# att_obj = OMX::OMXAttr(file_obj)
|
29
38
|
at = OMX::OMXAttr.new(file)
|
30
39
|
puts "Version: #{at.getVersion()}"
|
31
40
|
puts "Zones: #{at.getZones()}"
|
32
41
|
|
33
42
|
# Get the tables from the file
|
43
|
+
# table_obj = OMX::OMXTables.new(file_obj)
|
34
44
|
t = OMX::OMXTables.new(file)
|
35
45
|
puts "Tables: #{t.getNTables()}"
|
36
46
|
puts "Table Names: #{t.getTableNames()}"
|
37
47
|
|
38
48
|
# Get data from the file
|
39
|
-
# OMX::OMXData.new(
|
49
|
+
# data_object = OMX::OMXData.new(file_obj,"Tablename", number_of_zones)
|
40
50
|
tt = OMX::OMXData.new(file,"DIST",at.getZones())
|
41
|
-
puts tt.
|
51
|
+
puts tt.getI(zone) # Returns array of all J from zone
|
52
|
+
puts tt.getJ(zone) # Returns array of all I to zone
|
53
|
+
puts tt.getIJ(i,j) # Returns value at i,j
|
42
54
|
|
43
55
|
# Close the file
|
56
|
+
# file_obj.close()
|
44
57
|
file.close()
|
45
58
|
```
|
46
59
|
|
data/lib/OpenMatriX.rb
CHANGED
@@ -113,6 +113,8 @@ module OMX
|
|
113
113
|
ffi_lib H5Library.library_path
|
114
114
|
attach_function :group_open, :H5Fopen, [H5Types.hid_t, :string, H5Types.hid_t], H5Types.hid_t
|
115
115
|
attach_function :get_type, :H5Iget_type, [H5Types.hid_t], H5Types.hid_t
|
116
|
+
attach_variable :h5P_CLS_GROUP_ACCESS_ID, :H5P_CLS_GROUP_ACCESS_ID_g, :int
|
117
|
+
attach_variable :h5P_CLS_LINK_ACCESS_ID_g, :H5P_CLS_LINK_ACCESS_ID_g, :int
|
116
118
|
#
|
117
119
|
# Object for wrapping an OMX file. Basic usage:
|
118
120
|
# file = OMX::OMXFile.new('filename.omx')
|
@@ -217,46 +219,63 @@ module OMX
|
|
217
219
|
extend FFI::Library
|
218
220
|
ffi_lib H5Library.library_path
|
219
221
|
|
222
|
+
class H5GInfoT < FFI::Struct
|
223
|
+
layout :storType, :int,
|
224
|
+
:nLinks, H5Types.hsize_t,
|
225
|
+
:maxCOrder, :int,
|
226
|
+
:mounted, H5Types.hbool_t
|
227
|
+
end
|
228
|
+
|
229
|
+
def cast_to_H5GInfoT pointer
|
230
|
+
H5GInfoT.new pointer
|
231
|
+
end
|
232
|
+
|
233
|
+
class H5_index < FFI::Struct
|
234
|
+
layout :idxUnk, :int,
|
235
|
+
:idxName, :string,
|
236
|
+
:idxOrder, :int,
|
237
|
+
:nIdx, :int
|
238
|
+
end
|
239
|
+
|
240
|
+
def cast_to_H5_index pointer
|
241
|
+
H5_index.new pointer
|
242
|
+
end
|
243
|
+
|
220
244
|
#hid_t H5Dopen( hid_t loc_id, const char *name )
|
221
|
-
attach_function :gOpen, :
|
245
|
+
attach_function :gOpen, :H5Gopen2, [H5Types.hid_t, :string, H5Types.hid_t], H5Types.hid_t
|
222
246
|
|
223
|
-
#herr_t
|
224
|
-
attach_function :nTables, :
|
247
|
+
#herr_t H5Gget_info( hid_t group_id, H5G_info_t *group_info )
|
248
|
+
attach_function :nTables, :H5Gget_info, [H5Types.hid_t, H5GInfoT], H5Types.herr_t
|
225
249
|
|
226
|
-
#ssize_t
|
227
|
-
attach_function :
|
250
|
+
#ssize_t H5Lget_name_by_idx( hid_t loc_id, const char *group_name, H5_index_t index_field, H5_iter_order_t order, hsize_t n, char *name, size_t size, hid_t lapl_id )
|
251
|
+
attach_function :tNames2, :H5Lget_name_by_idx, [H5Types.hid_t, :string, :int, :int, :int, :pointer, :int, :int ], :int
|
228
252
|
|
229
253
|
def initialize(file)
|
230
254
|
@id = file.id
|
231
|
-
@gId = gOpen(@id, "data")
|
255
|
+
@gId = gOpen(@id, "data",0)
|
232
256
|
end
|
233
257
|
|
234
258
|
# A function to return the number of matrix tables. Returns an integer value
|
235
259
|
# of the number of tables in the matrix
|
236
260
|
def getNTables()
|
237
|
-
|
238
|
-
|
239
|
-
return(
|
240
|
-
end
|
241
|
-
|
242
|
-
# A function to get the table info... kind of a useless function for now
|
243
|
-
# TODO: Can this be removed?
|
244
|
-
def getTableInfo()
|
245
|
-
sb = Statbuf.new
|
246
|
-
oi = tInfo(@id, "data", 0, sb)
|
247
|
-
puts sb[:nlink]
|
248
|
-
return(oi)
|
261
|
+
h5gi = cast_to_H5GInfoT(FFI::MemoryPointer.new :char, H5GInfoT.size)
|
262
|
+
op = nTables(@gId,h5gi)
|
263
|
+
return(h5gi[:nLinks])
|
249
264
|
end
|
250
265
|
|
251
266
|
# A function to get the table names. Returns a string array of table names.
|
252
267
|
def getTableNames()
|
253
268
|
nT = self.getNTables()-1
|
269
|
+
gName = FFI::MemoryPointer.new(:string)
|
270
|
+
|
271
|
+
pl = createpl(OMX::h5P_CLS_LINK_ACCESS_ID_g)
|
254
272
|
|
273
|
+
# Note from okiAndrew: this seems seriously kludgy, but it works.
|
255
274
|
tN ||= []
|
256
275
|
for t in 0..nT
|
257
|
-
|
258
|
-
|
259
|
-
tN <<
|
276
|
+
tn2o = tNames2(@gId, ".", 0, t, 0, gName, 20, pl)
|
277
|
+
#puts "gName = #{gName.read_string()}"
|
278
|
+
tN << gName.read_string()
|
260
279
|
end
|
261
280
|
return(tN)
|
262
281
|
end
|
data/lib/OpenMatriX/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: OpenMatriX
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Rohne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
92
|
- ".travis.yml"
|
93
|
+
- Debian-HOWTO.md
|
93
94
|
- Gemfile
|
94
95
|
- LICENSE.md
|
95
96
|
- OpenMatriX.gemspec
|
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
version: '0'
|
120
121
|
requirements: []
|
121
122
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.4.8
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
126
|
summary: Open Matrix support for Ruby
|