Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
toolbox
WindEnergyToolbox
Commits
f3cde157
Commit
f3cde157
authored
8 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
minor improvement of gtsdf
parent
3b1c209c
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
wetb/gtsdf/__init__.py
+7
-3
7 additions, 3 deletions
wetb/gtsdf/__init__.py
wetb/gtsdf/gtsdf.py
+3
-0
3 additions, 0 deletions
wetb/gtsdf/gtsdf.py
wetb/gtsdf/tests/test_gtsdf.py
+20
-5
20 additions, 5 deletions
wetb/gtsdf/tests/test_gtsdf.py
wetb/gtsdf/unix_time.py
+1
-1
1 addition, 1 deletion
wetb/gtsdf/unix_time.py
with
31 additions
and
9 deletions
wetb/gtsdf/__init__.py
+
7
−
3
View file @
f3cde157
...
...
@@ -42,10 +42,14 @@ from .gtsdf import load_pandas
class
Dataset
(
object
):
def
__init__
(
self
,
filename
):
self
.
time
,
self
.
data
,
self
.
info
=
load
(
filename
)
def
__call__
(
self
,
name
):
if
name
==
"
Time
"
:
def
__call__
(
self
,
id
):
if
isinstance
(
id
,
str
):
return
self
(([
'
Time
'
]
+
self
.
info
[
'
attribute_names
'
]).
index
(
id
)
+
1
)
if
id
==
1
:
return
self
.
time
return
self
.
data
[:,
self
.
info
[
'
attribute_names
'
].
index
(
name
)]
else
:
return
self
.
data
[:,
id
-
2
]
__all__
=
sorted
([
m
for
m
in
set
(
dir
())
-
set
(
d
)])
...
...
This diff is collapsed.
Click to expand it.
wetb/gtsdf/gtsdf.py
+
3
−
0
View file @
f3cde157
...
...
@@ -322,6 +322,9 @@ def append_block(filename, data, **kwargs):
dtype
=
kwargs
.
get
(
'
dtype
'
,
np
.
uint16
)
else
:
dtype
=
f
[
block_name_fmt
%
0
][
'
data
'
].
dtype
if
dtype
==
np
.
uint16
:
if
no_observations
<
12
:
# size with float32<1.2*size with uint16
dtype
=
np
.
float32
block
=
f
.
create_group
(
block_name_fmt
%
blocknr
)
if
'
time
'
in
kwargs
:
...
...
This diff is collapsed.
Click to expand it.
wetb/gtsdf/tests/test_gtsdf.py
+
20
−
5
View file @
f3cde157
...
...
@@ -31,7 +31,7 @@ class Test_gsdf(unittest.TestCase):
@classmethod
def
tearDownClass
(
cls
):
super
(
Test_gsdf
,
cls
).
tearDownClass
()
shutil
.
rmtree
(
tmp_path
)
#
shutil.rmtree(tmp_path)
def
test_minimum_requirements
(
self
):
fn
=
tmp_path
+
"
minimum.hdf5
"
...
...
@@ -170,15 +170,27 @@ class Test_gsdf(unittest.TestCase):
def
test_append
(
self
):
fn
=
tmp_path
+
'
append.hdf5
'
d
=
np
.
arange
(
12
,
dtype
=
np
.
float32
).
reshape
(
6
,
2
)
d
=
np
.
arange
(
48
,
dtype
=
np
.
float32
).
reshape
(
24
,
2
)
d
[
2
,
0
]
=
np
.
nan
gtsdf
.
save
(
fn
,
d
)
_
,
data
,
_
=
gtsdf
.
load
(
fn
)
np
.
testing
.
assert_array_almost_equal
(
data
,
d
,
4
)
np
.
testing
.
assert_array_almost_equal
(
data
,
d
,
3
)
gtsdf
.
append_block
(
fn
,
d
)
_
,
data
,
_
=
gtsdf
.
load
(
fn
)
self
.
assertEqual
(
data
.
shape
,
(
12
,
2
))
np
.
testing
.
assert_array_almost_equal
(
data
,
np
.
append
(
d
,
d
,
0
),
4
)
self
.
assertEqual
(
data
.
shape
,
(
48
,
2
))
np
.
testing
.
assert_array_almost_equal
(
data
,
np
.
append
(
d
,
d
,
0
),
3
)
f
=
h5py
.
File
(
fn
)
self
.
assertIn
(
'
gains
'
,
f
[
'
block0001
'
])
f
.
close
()
def
test_append_small_block
(
self
):
fn
=
tmp_path
+
'
append_small_block.hdf5
'
d
=
np
.
arange
(
12
,
dtype
=
np
.
float32
).
reshape
(
2
,
6
)
gtsdf
.
save
(
fn
,
d
)
gtsdf
.
append_block
(
fn
,
d
+
12
)
f
=
h5py
.
File
(
fn
)
self
.
assertNotIn
(
'
gains
'
,
f
[
'
block0001
'
])
f
.
close
()
def
test_nan_float
(
self
):
...
...
@@ -226,6 +238,9 @@ class Test_gsdf(unittest.TestCase):
if
__name__
==
"
__main__
"
:
#import sys;sys.argv = ['', 'Test.testName']
unittest
.
main
()
This diff is collapsed.
Click to expand it.
wetb/gtsdf/unix_time.py
+
1
−
1
View file @
f3cde157
...
...
@@ -34,7 +34,7 @@ def from_unix(sec):
return
datetime
.
utcfromtimestamp
(
0
)
return
datetime
.
utcfromtimestamp
(
sec
)
else
:
sec
=
np
.
array
(
sec
)
sec
=
np
.
array
(
sec
)
.
astype
(
np
.
float
)
ms
=
np
.
atleast_1d
((
sec
*
1000000
%
1000000
).
astype
(
np
.
int
))
sec
=
sec
.
astype
(
np
.
int
)
S
=
np
.
atleast_1d
(
sec
%
60
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment