Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
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
Container registry
Model registry
Operate
Environments
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
esde
machine-learning
MLAir
Commits
939f1980
Commit
939f1980
authored
3 years ago
by
leufen1
Browse files
Options
Downloads
Patches
Plain Diff
more loggings
parent
754e61f0
Branches
Branches containing commit
Tags
Tags containing commit
5 merge requests
!319
add all changes of dev into release v1.4.0 branch
,
!318
Resolve "release v1.4.0"
,
!317
enabled window_lead_time=1
,
!295
Resolve "data handler FIR filter"
,
!259
Draft: Resolve "WRF-Datahandler should inherit from SingleStationDatahandler"
Pipeline
#68027
passed
3 years ago
Stage: test
Stage: docs
Stage: pages
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mlair/helpers/filter.py
+22
-3
22 additions, 3 deletions
mlair/helpers/filter.py
with
22 additions
and
3 deletions
mlair/helpers/filter.py
+
22
−
3
View file @
939f1980
...
@@ -212,20 +212,36 @@ class ClimateFIRFilter:
...
@@ -212,20 +212,36 @@ class ClimateFIRFilter:
# apriori starts after data
# apriori starts after data
if
dates
[
0
]
<
apriori
.
coords
[
time_dim
].
values
[
0
]:
if
dates
[
0
]
<
apriori
.
coords
[
time_dim
].
values
[
0
]:
logging
.
info
(
f
"
{
data
.
coords
[
'
Stations
'
].
values
[
0
]
}
: apriori starts after data
"
)
# add difference in full years
# add difference in full years
date_diff
=
abs
(
dates
[
0
]
-
apriori
.
coords
[
time_dim
].
values
[
0
]).
astype
(
"
timedelta64[D]
"
)
date_diff
=
abs
(
dates
[
0
]
-
apriori
.
coords
[
time_dim
].
values
[
0
]).
astype
(
"
timedelta64[D]
"
)
extend_range
=
np
.
ceil
(
date_diff
/
(
np
.
timedelta64
(
1
,
"
D
"
)
*
365
)).
astype
(
int
)
*
365
extend_range
=
np
.
ceil
(
date_diff
/
(
np
.
timedelta64
(
1
,
"
D
"
)
*
365
)).
astype
(
int
)
*
365
coords
=
apriori
.
coords
coords
=
apriori
.
coords
# create new time axis
# create new time axis
start
=
coords
[
time_dim
][
0
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
-
np
.
timedelta64
(
extend_range
,
"
D
"
)
# start = coords[time_dim][0].values.astype("datetime64[%s]" % td_type) - np.timedelta64(extend_range, "D")
# end = coords[time_dim][0].values.astype("datetime64[%s]" % td_type)
# new_time_axis = np.arange(start, end).astype("datetime64[ns]")
factor
=
1
if
td_type
==
"
D
"
else
24
start
=
coords
[
time_dim
][
0
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
-
np
.
timedelta64
(
extend_range
*
factor
+
1
,
td_type
)
end
=
coords
[
time_dim
][
0
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
end
=
coords
[
time_dim
][
0
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
new_time_axis
=
np
.
arange
(
start
,
end
).
astype
(
"
datetime64[ns]
"
)
new_time_axis
=
np
.
arange
(
start
,
end
).
astype
(
"
datetime64[ns]
"
)
logging
.
info
(
f
"
{
data
.
coords
[
'
Stations
'
].
values
[
0
]
}
: shape of new_time_axis =
{
new_time_axis
.
shape
}
"
)
# extract old values to use with new axis
# extract old values to use with new axis
start
=
coords
[
time_dim
][
0
].
values
.
astype
(
"
datetime64[D]
"
)
# start = coords[time_dim][0].values.astype("datetime64[D]")
end
=
coords
[
time_dim
][
0
].
values
.
astype
(
"
datetime64[D]
"
)
+
np
.
timedelta64
(
extend_range
-
1
,
"
D
"
)
# end = coords[time_dim][0].values.astype("datetime64[D]") + np.timedelta64(extend_range - 1, "D")
# new_values = apriori.sel({time_dim: slice(start, end)})
# new_values.coords[time_dim] = new_time_axis
start
=
coords
[
time_dim
][
0
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
end
=
coords
[
time_dim
][
0
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
+
np
.
timedelta64
(
extend_range
*
factor
-
1
,
td_type
)
new_values
=
apriori
.
sel
({
time_dim
:
slice
(
start
,
end
)})
new_values
=
apriori
.
sel
({
time_dim
:
slice
(
start
,
end
)})
logging
.
info
(
f
"
{
data
.
coords
[
'
Stations
'
].
values
[
0
]
}
: shape of new_values =
{
new_values
.
shape
}
"
)
new_values
.
coords
[
time_dim
]
=
new_time_axis
new_values
.
coords
[
time_dim
]
=
new_time_axis
# add new values to apriori
# add new values to apriori
...
@@ -233,6 +249,7 @@ class ClimateFIRFilter:
...
@@ -233,6 +249,7 @@ class ClimateFIRFilter:
# apriori ends before data
# apriori ends before data
if
dates
[
-
1
]
+
np
.
timedelta64
(
365
,
"
D
"
)
>
apriori
.
coords
[
time_dim
].
values
[
-
1
]:
if
dates
[
-
1
]
+
np
.
timedelta64
(
365
,
"
D
"
)
>
apriori
.
coords
[
time_dim
].
values
[
-
1
]:
logging
.
info
(
f
"
{
data
.
coords
[
'
Stations
'
].
values
[
0
]
}
: apriori ends before data
"
)
# add difference in full years + 1 year (because apriori is used as future estimate)
# add difference in full years + 1 year (because apriori is used as future estimate)
date_diff
=
abs
(
dates
[
-
1
]
-
apriori
.
coords
[
time_dim
].
values
[
-
1
]).
astype
(
"
timedelta64[D]
"
)
date_diff
=
abs
(
dates
[
-
1
]
-
apriori
.
coords
[
time_dim
].
values
[
-
1
]).
astype
(
"
timedelta64[D]
"
)
extend_range
=
np
.
ceil
(
date_diff
/
(
np
.
timedelta64
(
1
,
"
D
"
)
*
365
)).
astype
(
int
)
*
365
+
365
extend_range
=
np
.
ceil
(
date_diff
/
(
np
.
timedelta64
(
1
,
"
D
"
)
*
365
)).
astype
(
int
)
*
365
+
365
...
@@ -245,6 +262,7 @@ class ClimateFIRFilter:
...
@@ -245,6 +262,7 @@ class ClimateFIRFilter:
extend_range
*
factor
+
1
,
extend_range
*
factor
+
1
,
td_type
)
td_type
)
new_time_axis
=
np
.
arange
(
start
,
end
).
astype
(
"
datetime64[ns]
"
)
new_time_axis
=
np
.
arange
(
start
,
end
).
astype
(
"
datetime64[ns]
"
)
logging
.
info
(
f
"
{
data
.
coords
[
'
Stations
'
].
values
[
0
]
}
: shape of new_time_axis =
{
new_time_axis
.
shape
}
"
)
# extract old values to use with new axis
# extract old values to use with new axis
start
=
coords
[
time_dim
][
-
1
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
-
np
.
timedelta64
(
start
=
coords
[
time_dim
][
-
1
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
-
np
.
timedelta64
(
...
@@ -253,6 +271,7 @@ class ClimateFIRFilter:
...
@@ -253,6 +271,7 @@ class ClimateFIRFilter:
# extend_range * factor, td_type)
# extend_range * factor, td_type)
end
=
coords
[
time_dim
][
-
1
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
end
=
coords
[
time_dim
][
-
1
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
new_values
=
apriori
.
sel
({
time_dim
:
slice
(
start
,
end
)})
new_values
=
apriori
.
sel
({
time_dim
:
slice
(
start
,
end
)})
logging
.
info
(
f
"
{
data
.
coords
[
'
Stations
'
].
values
[
0
]
}
: shape of new_values =
{
new_values
.
shape
}
"
)
new_values
.
coords
[
time_dim
]
=
new_time_axis
new_values
.
coords
[
time_dim
]
=
new_time_axis
# add new values to apriori
# add new values to apriori
...
...
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