Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OGSTools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
OpenGeoSys Tools
OGSTools
Commits
4018c834
Commit
4018c834
authored
1 year ago
by
Florian Zill
Browse files
Options
Downloads
Patches
Plain Diff
timevalues as np array
parent
353f7740
No related branches found
No related tags found
1 merge request
!117
Probe Functionality
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ogstools/meshlib/mesh_series.py
+6
-6
6 additions, 6 deletions
ogstools/meshlib/mesh_series.py
with
6 additions
and
6 deletions
ogstools/meshlib/mesh_series.py
+
6
−
6
View file @
4018c834
...
...
@@ -215,23 +215,23 @@ class MeshSeries:
return
range
(
len
(
self
.
timevalues
))
@property
def
timevalues
(
self
)
->
list
[
float
]
:
def
timevalues
(
self
)
->
np
.
ndarray
:
"""
Return the timevalues of the timeseries data.
"""
if
self
.
_data_type
==
"
vtu
"
:
return
[
0
]
return
np
.
zeros
(
1
)
if
self
.
_data_type
==
"
pvd
"
:
return
self
.
_pvd_reader
.
time_values
return
np
.
asarray
(
self
.
_pvd_reader
.
time_values
)
# elif self._data_type == "xdmf":
time_values
=
[]
for
collection_i
in
self
.
_xdmf_reader
.
collection
:
for
element
in
collection_i
:
if
element
.
tag
==
"
Time
"
:
time_values
+=
[
float
(
element
.
attrib
[
"
Value
"
])]
return
time_values
return
np
.
asarray
(
time_values
)
def
closest_timestep
(
self
,
timevalue
:
float
)
->
int
:
"""
Return the corresponding timestep from a timevalue.
"""
return
int
(
np
.
argmin
(
np
.
abs
(
np
.
array
(
self
.
timevalues
)
-
timevalue
)))
return
int
(
np
.
argmin
(
np
.
abs
(
self
.
timevalues
-
timevalue
)))
def
closest_timevalue
(
self
,
timevalue
:
float
)
->
float
:
"""
Return the closest timevalue to a timevalue.
"""
...
...
@@ -245,7 +245,7 @@ class MeshSeries:
self
,
timevalue
:
float
,
lazy_eval
:
bool
=
True
)
->
pv
.
UnstructuredGrid
:
"""
Return the temporal interpolated mesh for a given timevalue.
"""
t_vals
=
np
.
array
(
self
.
timevalues
)
t_vals
=
self
.
timevalues
ts1
=
int
(
t_vals
.
searchsorted
(
timevalue
,
"
right
"
)
-
1
)
ts2
=
min
(
ts1
+
1
,
len
(
t_vals
)
-
1
)
if
np
.
isclose
(
timevalue
,
t_vals
[
ts1
]):
...
...
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