Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mHM Tools
Manage
Activity
Members
Labels
Plan
Issues
7
Issue boards
Milestones
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Contributor 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
mhm
mHM Tools
Commits
5e32f015
Commit
5e32f015
authored
1 month ago
by
Valentin Simon Lüdke
Browse files
Options
Downloads
Patches
Plain Diff
Fix header creation
parent
d9c16b88
No related branches found
Branches containing commit
No related tags found
2 merge requests
!16
Generate classical mhm setups from classical setup
,
!8
Draft: Resolve "Pre-Proc: incorporate tools for creating global setups"
Pipeline
#269497
passed with stages
Stage: test
Stage: build
in 2 minutes and 30 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mhm_tools/common/file_handler.py
+1
-6
1 addition, 6 deletions
src/mhm_tools/common/file_handler.py
src/mhm_tools/pre/crop_mhm_setup.py
+4
-7
4 additions, 7 deletions
src/mhm_tools/pre/crop_mhm_setup.py
with
5 additions
and
13 deletions
src/mhm_tools/common/file_handler.py
+
1
−
6
View file @
5e32f015
...
...
@@ -22,14 +22,9 @@ def create_header(ds, output_path=None, no_data_value="-9999", write=True):
lon_key
=
get_coord_key
(
ds
,
lon
=
True
)
x
=
ds
[
lon_key
].
values
y
=
ds
[
lat_key
].
values
# x = x[np.where((x >= mask.lon.values[0]) & (x <= mask.lon.values[-1]))]
# y = y[np.where((y >= mask.lat.values[0]) & (y <= mask.lat.values[-1]))]
cellsize
=
abs
(
x
[
1
]
-
x
[
0
])
xllcorner
=
np
.
nanmin
(
x
)
-
0.5
*
cellsize
if
np
.
nanmin
(
y
)
==
y
[
-
1
]:
yllcorner
=
np
.
nanmin
(
y
)
+
0.5
*
cellsize
else
:
yllcorner
=
np
.
nanmin
(
y
)
-
0.5
*
cellsize
yllcorner
=
np
.
nanmin
(
y
)
-
0.5
*
cellsize
ncols
=
len
(
x
)
-
1
nrows
=
len
(
y
)
-
1
...
...
This diff is collapsed.
Click to expand it.
src/mhm_tools/pre/crop_mhm_setup.py
+
4
−
7
View file @
5e32f015
...
...
@@ -86,20 +86,17 @@ def crop_file_with_header(ds, file_path, mask, output_path):
lat_key
=
get_coord_key
(
ds
,
lat
=
True
,
raise_exception
=
True
)
# x values
mask_res
=
round
(
mask
.
lon
.
values
[
1
]
-
mask
.
lon
.
values
[
0
],
6
)
x_mask
=
(
lon
>=
mask
.
lon
.
values
[
0
]
-
mask_res
/
2
)
&
(
lon
<
mask
.
lon
.
values
[
-
1
]
-
mask_res
/
2
x_mask
=
(
lon
>=
float
(
mask
.
lon
.
min
())
-
mask_res
/
2
)
&
(
lon
<
float
(
mask
.
lon
.
max
())
-
mask_res
/
2
)
x
=
np
.
arange
(
0
,
ds
.
sizes
[
lon_key
],
1
)
x_cropped
=
x
[
x_mask
]
# y values
y_mask
=
(
lat
>=
mask
.
lat
.
values
[
0
]
+
mask_res
/
2
)
&
(
lat
<
mask
.
lat
.
values
[
-
1
]
+
mask_res
/
2
y_mask
=
(
lat
>=
float
(
mask
.
lat
.
min
())
-
mask_res
/
2
)
&
(
lat
<
float
(
mask
.
lat
.
max
())
-
mask_res
/
2
)
y
=
np
.
arange
(
0
,
ds
.
sizes
[
lat_key
],
1
)
y_cropped
=
y
[
y_mask
]
if
not
y_cropped
:
# if y_cropped empty reverse slicing order
y_mask
=
(
lat
>=
mask
.
lat
.
values
[
-
1
])
&
(
lat
<=
mask
.
lat
.
values
[
0
])
y_cropped
=
y
[
y_mask
]
# write header file
header_out_path
=
output_path
/
header
.
name
xll
=
d
[
"
xllcorner
"
]
+
d
[
"
cellsize
"
]
*
np
.
nanmin
(
x_cropped
)
...
...
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