Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
I
idg
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
8
Merge Requests
8
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ResearchAndDevelopment
idg
Commits
009945f9
Commit
009945f9
authored
Jan 18, 2021
by
Jakob Maljaars
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Write to S string in h5parm
parent
9d0c3a4b
Pipeline
#8083
passed with stages
in 24 minutes and 29 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
idg-cal/h5parmwriter.py
idg-cal/h5parmwriter.py
+14
-4
No files found.
idg-cal/h5parmwriter.py
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment