Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Tom Rink
python
Commits
c5811173
Commit
c5811173
authored
1 year ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
d7dbd8c1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/aeolus/datasource.py
+12
-6
12 additions, 6 deletions
modules/aeolus/datasource.py
with
12 additions
and
6 deletions
modules/aeolus/datasource.py
+
12
−
6
View file @
c5811173
...
@@ -119,7 +119,7 @@ class Files:
...
@@ -119,7 +119,7 @@ class Files:
def
get_file_containing_time
(
self
,
timestamp
):
def
get_file_containing_time
(
self
,
timestamp
):
"""
"""
:param timestamp: seconds since the epoch
:param timestamp: seconds since the epoch
:return: the file whose time range
(defined as the difference between consecutive file time labels)
contains timestamp.
:return: the file whose time range contains timestamp.
"""
"""
k
=
-
1
k
=
-
1
for
i
in
range
(
self
.
ftimes
.
shape
[
0
]):
for
i
in
range
(
self
.
ftimes
.
shape
[
0
]):
...
@@ -134,7 +134,7 @@ class Files:
...
@@ -134,7 +134,7 @@ class Files:
def
get_file
(
self
,
timestamp
,
window
=
None
):
def
get_file
(
self
,
timestamp
,
window
=
None
):
"""
"""
:param timestamp: seconds since the epoch.
:param timestamp: seconds since the epoch.
:param window: the duration of files in this object. Defaults to the constructor time span.
:param window: the duration
(minutes)
of files in this object. Defaults to the constructor time span.
:return: the file whose duration contains the timestamp.
:return: the file whose duration contains the timestamp.
"""
"""
if
window
is
None
:
if
window
is
None
:
...
@@ -154,15 +154,21 @@ class Files:
...
@@ -154,15 +154,21 @@ class Files:
:param t_lo_minutes: can be negative or positive
:param t_lo_minutes: can be negative or positive
:param t_hi_minutes: can be negative or positive, but must be greater than t_lo_minutes.
:param t_hi_minutes: can be negative or positive, but must be greater than t_lo_minutes.
:return: the file whose time label is within the absolute range (timestamp + t_lo_minutes, timestamp + t_hi_minutes)
:return: the file whose time label is within the absolute range (timestamp + t_lo_minutes, timestamp + t_hi_minutes)
if more than one, return the first occurrence.
"""
"""
if
t_hi_minutes
<=
t_lo_minutes
:
raise
ValueError
(
'
t_hi_minutes must be greater than t_lo_minutes
'
)
t_lo
=
timestamp
+
datetime
.
timedelta
(
minutes
=
t_lo_minutes
).
seconds
t_lo
=
timestamp
+
datetime
.
timedelta
(
minutes
=
t_lo_minutes
).
seconds
t_hi
=
timestamp
+
datetime
.
timedelta
(
minutes
=
t_hi_minutes
).
seconds
t_hi
=
timestamp
+
datetime
.
timedelta
(
minutes
=
t_hi_minutes
).
seconds
midx
=
np
.
where
(
np
.
logical_and
(
self
.
ftimes
[:,
0
]
>=
t_lo
,
self
.
ftimes
[:,
0
]
<
t_hi
))[
0
]
m_idx
=
np
.
where
(
np
.
logical_and
(
self
.
ftimes
[:,
0
]
>=
t_lo
,
self
.
ftimes
[:,
0
]
<
t_hi
))[
0
]
midx
=
midx
[
0
]
# the first occurrence
if
len
(
m_idx
)
>
0
:
m_idx
=
m_idx
[
0
]
# the first occurrence
return
self
.
flist
[
midx
],
self
.
ftimes
[
midx
,
0
],
midx
return
self
.
flist
[
m_idx
],
self
.
ftimes
[
m_idx
,
0
],
m_idx
else
:
return
None
,
None
,
None
def
get_parameters
(
self
):
def
get_parameters
(
self
):
pass
pass
...
...
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