Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
idg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ResearchAndDevelopment
idg
Commits
009945f9
Commit
009945f9
authored
4 years ago
by
Jakob Maljaars
Browse files
Options
Downloads
Patches
Plain Diff
Write to S string in h5parm
parent
9d0c3a4b
No related branches found
No related tags found
1 merge request
!51
Idg cal jakob 1 (rebased)
Pipeline
#8083
passed
4 years ago
Stage: prepare
Stage: build
Stage: integration_and_deploy
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
idg-cal/h5parmwriter.py
+14
-4
14 additions, 4 deletions
idg-cal/h5parmwriter.py
with
14 additions
and
4 deletions
idg-cal/h5parmwriter.py
+
14
−
4
View file @
009945f9
...
...
@@ -163,11 +163,15 @@ class H5ParmWriter:
hdf_location
=
self
.
solution_set
+
"
/
"
+
name
self
.
h5file
[
self
.
solution_set
].
create_group
(
name
)
self
.
h5file
[
hdf_location
].
attrs
[
"
TITLE
"
]
=
str
.
encode
(
type_name
)
self
.
h5file
[
hdf_location
].
attrs
[
"
TITLE
"
]
=
np
.
asarray
(
type_name
,
dtype
=
f
"
<S
{
len
(
type_name
)
}
"
)
self
.
__write_version_stamp
(
self
.
solution_set
+
"
/
"
+
name
)
# Convert axes labels to S-type
axes_labels
=
list
(
axes
.
keys
())
axes_labels
=
"
,
"
.
join
(
axes_labels
).
encode
()
axes_labels
=
np
.
asarray
(
axes_labels
,
dtype
=
f
"
<S
{
len
(
axes_labels
)
}
"
)
axes_shape
=
tuple
(
axes
.
values
())
dtype
=
values
.
dtype
if
values
is
not
None
else
dtype
...
...
@@ -205,7 +209,9 @@ class H5ParmWriter:
self
.
h5file
[
hdf_location
+
"
/weight
"
][:]
=
weights
if
history
is
not
None
:
self
.
h5file
[
hdf_location
+
"
/val
"
].
attrs
[
"
HISTORY000
"
]
=
str
.
encode
(
history
)
self
.
h5file
[
hdf_location
+
"
/val
"
].
attrs
[
"
HISTORY000
"
]
=
np
.
asarray
(
history
,
dtype
=
f
"
<S
{
len
(
history
)
}
"
)
def
fill_solution_table
(
self
,
name
,
values
,
offset
=
None
):
"""
...
...
@@ -359,7 +365,9 @@ class H5ParmWriter:
hdf_location : str
Location where the version stamp will be added.
"""
self
.
h5file
[
hdf_location
].
attrs
[
"
h5parm_version
"
]
=
str
.
encode
(
H5PARM_VERSION
)
self
.
h5file
[
hdf_location
].
attrs
[
"
h5parm_version
"
]
=
np
.
asarray
(
H5PARM_VERSION
,
dtype
=
f
"
<S
{
len
(
H5PARM_VERSION
)
}
"
)
def
__write_attributes
(
self
,
hdf_location
,
attributes
,
overwrite
):
"""
...
...
@@ -384,7 +392,9 @@ class H5ParmWriter:
else
:
if
isinstance
(
value
,
str
):
# Byte encoded string
self
.
h5file
[
hdf_location
].
attrs
[
key
]
=
str
.
encode
(
value
)
self
.
h5file
[
hdf_location
].
attrs
[
key
]
=
np
.
asarray
(
value
,
dtype
=
f
"
<S
{
len
(
value
)
}
"
)
elif
isinstance
(
value
,
np
.
ndarray
)
and
value
.
dtype
.
type
==
np
.
str_
:
# Convert to S string
data_type_h5
=
re
.
sub
(
r
"
[a-zA-Z]
"
,
"
S
"
,
value
.
dtype
.
str
)
...
...
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