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
9d9a4c37
Commit
9d9a4c37
authored
7 months ago
by
Michel Spils
Browse files
Options
Downloads
Patches
Plain Diff
wiski export
parent
cd43fc61
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scripts/bsh_extractor_v2.py
+8
-3
8 additions, 3 deletions
src/scripts/bsh_extractor_v2.py
with
8 additions
and
3 deletions
src/scripts/bsh_extractor_v2.py
+
8
−
3
View file @
9d9a4c37
...
...
@@ -107,13 +107,14 @@ def read_dat_file(zip_file:Path,dat_file:str,tsVorh:str) -> pd.DataFrame:
df
=
df
[[
"
timestamp
"
,
"
forecast
"
,
"
member
"
,
"
pegel
"
]]
return
df
def
writeZrxp
(
target_file
:
Path
,
df
:
pd
.
DataFrame
):
def
writeZrxp
(
target_file
:
Path
,
df
:
pd
.
DataFrame
,
only_two
=
False
):
"""
Writes the DataFrame to a .zrx file with the correct header.
Overwrites the file if it already exists.
Args:
target_file (Path): Where the file should be saved
df (pd.DataFrame): DataFrame with zrx data
only_two (bool, optional): If True, only the cols for wiski are written.
"""
if
target_file
.
exists
():
print
(
f
"
Overwriting existing file
{
target_file
}
"
)
...
...
@@ -122,6 +123,10 @@ def writeZrxp(target_file:Path,df:pd.DataFrame):
with
open
(
target_file
,
'
w
'
,
encoding
=
'
utf-8
'
)
as
file
:
file
.
write
(
'
#REXCHANGE9530010.W.BSH_VH|*|
\n
'
)
file
.
write
(
'
#RINVAL-777|*|
\n
'
)
if
only_two
:
file
.
write
(
'
#LAYOUT(timestamp,value)|*|
\n
'
)
df
=
df
[[
"
forecast
"
,
"
pegel
"
]]
else
:
file
.
write
(
'
#LAYOUT(timestamp,forecast,member,value)|*|
\n
'
)
df
.
to_csv
(
path_or_buf
=
target_file
,
...
...
@@ -158,7 +163,7 @@ def main():
target_file
=
make_target_file_name
(
base_dir
/
'
4WISKI
'
,
tsVorh
)
df
=
read_dat_file
(
mos_file_name
,
dat_file
,
tsVorh
)
writeZrxp
(
target_file
,
df
)
writeZrxp
(
target_file
,
df
,
only_two
=
True
)
#Resample and cut data to fit the 3h interval, hourly sample rate used by ICON
df2
=
df
[[
"
forecast
"
,
"
pegel
"
]].
resample
(
"
1h
"
,
on
=
"
forecast
"
).
first
()
...
...
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