Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KI-WaVo
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Landesamt für Umwelt
KI-WaVo
Commits
cb2bc705
Commit
cb2bc705
authored
6 months ago
by
Michel Spils
Browse files
Options
Downloads
Patches
Plain Diff
zrxp export function
parent
227b8a23
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
configs/db_new.yaml
+3
-0
3 additions, 0 deletions
configs/db_new.yaml
src/predict_database.py
+3
-2
3 additions, 2 deletions
src/predict_database.py
src/utils/db_tools.py
+24
-0
24 additions, 0 deletions
src/utils/db_tools.py
with
30 additions
and
2 deletions
configs/db_new.yaml
+
3
−
0
View file @
cb2bc705
...
...
@@ -2,12 +2,15 @@ main_config:
max_missing
:
120
db_params
:
user
:
c##mspils
#Passwort ist für eine lokale Datenbank ohne verbindung zum internet. Kann ruhig online stehen.
password
:
cobalt_deviancy
dsn
:
localhost/XE
# Auch als Liste möglich
zrxp_folder
:
../data/dwd_ens_zrpx/
sensor_folder
:
../data/db_in/
zrxp_out_folder
:
../data/zrxp_out/
#If True exports the forecasts if successful to zrxp
export_zrxp
:
True
#if True tries to put all files in folder in the external forecast table
load_sensor
:
False
load_zrxp
:
True
...
...
This diff is collapsed.
Click to expand it.
src/predict_database.py
+
3
−
2
View file @
cb2bc705
...
...
@@ -34,6 +34,7 @@ def get_configs(passed_args: argparse.Namespace) -> Tuple[dict, List[dict]]:
if
isinstance
(
main_config
[
"
zrxp_folder
"
],
str
):
main_config
[
"
zrxp_folder
"
]
=
[
main_config
[
"
zrxp_folder
"
]]
main_config
[
"
zrxp_folder
"
]
=
list
(
map
(
Path
,
main_config
[
"
zrxp_folder
"
]))
main_config
[
"
zrxp_out_folder
"
]
=
Path
(
main_config
[
"
zrxp_out_folder
"
])
main_config
[
"
sensor_folder
"
]
=
Path
(
main_config
[
"
sensor_folder
"
])
main_config
[
"
start
"
]
=
pd
.
to_datetime
(
main_config
[
"
start
"
])
if
"
end
"
in
main_config
:
...
...
@@ -98,8 +99,8 @@ def parse_args() -> argparse.Namespace:
help
=
"
The start date for the prediction. Format: YYYY-MM-DD HH:MM, overwrites start/end/range in the config file.
"
,
)
parser
.
add_argument
(
"
--zrxp
"
,
action
=
"
store_true
"
,
help
=
"
Save predictions as ZRXP files
(not yet implemented)
"
)
#TODO: Implement ZRXP
"
--zrxp
"
,
action
=
"
store_true
"
,
help
=
"
Save predictions as ZRXP files
"
)
return
parser
.
parse_args
()
...
...
This diff is collapsed.
Click to expand it.
src/utils/db_tools.py
+
24
−
0
View file @
cb2bc705
...
...
@@ -432,6 +432,30 @@ class OracleWaVoConnection:
else
:
fcst_values
=
{
f
"
h
{
i
}
"
:
forecast
[
i
-
1
].
item
()
for
i
in
range
(
1
,
49
)}
if
self
.
main_config
.
get
(
"
export_zrxp
"
):
target_file
=
self
.
main_config
[
"
zrxp_out_folder
"
]
/
f
"
{
end_time
.
strftime
(
"
%Y%m%d%H
"
)
}
_
{
sensor_name
}
_
{
model_name
}
_
{
member
}
.zrx
"
#2023 11 19 03
df_zrxp
=
pd
.
DataFrame
(
forecast
,
columns
=
[
"
value
"
])
df_zrxp
[
"
timestamp
"
]
=
end_time
df_zrxp
[
"
forecast
"
]
=
pd
.
date_range
(
start
=
end_time
,
periods
=
49
,
freq
=
"
1h
"
)[
1
:]
df_zrxp
[
"
member
"
]
=
member
df_zrxp
=
df_zrxp
[[
'
timestamp
'
,
'
forecast
'
,
'
member
'
,
'
value
'
]]
with
open
(
target_file
,
'
w
'
,
encoding
=
"
utf-8
"
)
as
file
:
file
.
write
(
'
#REXCHANGEWISKI.
'
+
model_name
.
split
(
"
_
"
)[
0
]
+
'
.W.KNN|*|
\n
'
)
file
.
write
(
'
#RINVAL-777|*|
\n
'
)
file
.
write
(
'
#LAYOUT(timestamp,forecast, member,value)|*|
\n
'
)
df_zrxp
.
to_csv
(
path_or_buf
=
target_file
,
header
=
False
,
index
=
False
,
mode
=
'
a
'
,
sep
=
'
'
,
date_format
=
'
%Y%m%d%H%M
'
)
stmt
=
select
(
PegelForecasts
).
where
(
PegelForecasts
.
tstamp
==
bindparam
(
"
tstamp
"
),
PegelForecasts
.
sensor_name
==
bindparam
(
"
sensor_name
"
),
...
...
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