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
c7b75f3e
Commit
c7b75f3e
authored
3 years ago
by
leufen1
Browse files
Options
Downloads
Patches
Plain Diff
filter plots different seasons, filter returns data with missing values now (not squeezed version)
parent
82c4ba1e
No related branches found
No related tags found
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
#67999
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
-14
22 additions, 14 deletions
mlair/helpers/filter.py
with
22 additions
and
14 deletions
mlair/helpers/filter.py
+
22
−
14
View file @
c7b75f3e
...
@@ -230,13 +230,16 @@ class ClimateFIRFilter:
...
@@ -230,13 +230,16 @@ class ClimateFIRFilter:
# create new time axis
# create new time axis
factor
=
1
if
td_type
==
"
D
"
else
24
factor
=
1
if
td_type
==
"
D
"
else
24
start
=
coords
[
time_dim
][
-
1
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
start
=
coords
[
time_dim
][
-
1
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
end
=
coords
[
time_dim
][
-
1
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
+
np
.
timedelta64
(
extend_range
*
factor
,
end
=
coords
[
time_dim
][
-
1
].
values
.
astype
(
"
datetime64[%s]
"
%
td_type
)
+
np
.
timedelta64
(
td_type
)
extend_range
*
factor
+
1
,
td_type
)
new_time_axis
=
np
.
arange
(
start
,
end
).
astype
(
"
datetime64[ns]
"
)
new_time_axis
=
np
.
arange
(
start
,
end
).
astype
(
"
datetime64[ns]
"
)
# 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
(
extend_range
*
factor
-
1
,
td_type
)
extend_range
*
factor
,
td_type
)
# start = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type) - np.timedelta64(
# 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
)})
new_values
.
coords
[
time_dim
]
=
new_time_axis
new_values
.
coords
[
time_dim
]
=
new_time_axis
...
@@ -331,19 +334,24 @@ class ClimateFIRFilter:
...
@@ -331,19 +334,24 @@ class ClimateFIRFilter:
# plot
# plot
if
self
.
plot_path
is
not
None
:
if
self
.
plot_path
is
not
None
:
try
:
for
i
,
time_pos
in
enumerate
([
0.25
,
1.5
,
2.75
,
4
]):
# [0.25, 1.5, 2.75, 4] x 365 days
pos
=
720
*
fs
try
:
filter_example
=
filter_input_data
.
isel
({
time_dim
:
pos
})
pos
=
int
(
time_pos
*
365
*
fs
)
t0
=
filter_example
.
coords
[
time_dim
].
values
filter_example
=
filter_input_data
.
isel
({
time_dim
:
pos
})
t_slice
=
filter_input_data
.
isel
(
t0
=
filter_example
.
coords
[
time_dim
].
values
{
time_dim
:
slice
(
pos
-
int
((
length
-
1
)
/
2
),
pos
+
int
((
length
-
1
)
/
2
)
+
1
)}).
coords
[
t_slice
=
filter_input_data
.
isel
(
time_dim
].
values
{
time_dim
:
slice
(
pos
-
int
((
length
-
1
)
/
2
),
pos
+
int
((
length
-
1
)
/
2
)
+
1
)}).
coords
[
self
.
plot
(
data
,
filter_example
,
var_dim
,
time_dim
,
t_slice
,
t0
,
plot_index
)
time_dim
].
values
except
IndexError
:
self
.
plot
(
data
,
filter_example
,
var_dim
,
time_dim
,
t_slice
,
t0
,
f
"
{
plot_index
}
_
{
i
}
"
)
pass
except
IndexError
:
pass
# select only values at tmp dimension 0 at each point in time
# select only values at tmp dimension 0 at each point in time
return
filt
.
sel
({
new_dim
:
0
},
drop
=
True
),
h
,
apriori
res
=
filt
.
sel
({
new_dim
:
0
},
drop
=
True
)
# create result array with same shape like input data, gabs are filled by nans
res_full
=
xr
.
ones_like
(
data
)
*
np
.
nan
res_full
.
loc
[
res
.
coords
]
=
res
return
res_full
,
h
,
apriori
@staticmethod
@staticmethod
def
_create_tmp_dimension
(
data
):
def
_create_tmp_dimension
(
data
):
...
...
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