Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
finam-mhm
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Service Desk
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
Afid Nur Kholis
finam-mhm
Commits
9025aaad
Commit
9025aaad
authored
2 years ago
by
Sebastian Müller
🐈
Browse files
Options
Downloads
Patches
Plain Diff
Grid: solve flipping issue
parent
693a0106
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/finam_mhm_module/mhm.py
+18
-11
18 additions, 11 deletions
src/finam_mhm_module/mhm.py
with
18 additions
and
11 deletions
src/finam_mhm_module/mhm.py
+
18
−
11
View file @
9025aaad
...
...
@@ -4,6 +4,7 @@ FINAM mHM module.
from
datetime
import
datetime
import
mhm_pybind
as
mp
import
numpy
as
np
from
finam.core.interfaces
import
ComponentStatus
from
finam.core.sdk
import
ATimeComponent
,
Input
,
Output
from
finam.data.grid
import
Grid
,
GridSpec
...
...
@@ -73,24 +74,24 @@ class Mhm(ATimeComponent):
hour
=
max
(
hour
,
0
)
# fix for first time step
self
.
_time
=
datetime
(
year
=
year
,
month
=
month
,
day
=
day
,
hour
=
hour
)
self
.
gridspec
=
{}
# get grid info l0
n
col
s
,
n
row
s
,
__
,
xll
,
yll
,
cell_size
,
no_data
=
mp
.
get
.
l0_domain_info
()
# get grid info l0
(swap rows/cols to get "ij" indexing)
n
row
s
,
n
col
s
,
__
,
xll
,
yll
,
cell_size
,
no_data
=
mp
.
get
.
l0_domain_info
()
self
.
no_data
=
no_data
self
.
gridspec
[
"
L0
"
]
=
GridSpec
(
ncols
=
ncols
,
nrows
=
nrows
,
cell_size
=
cell_size
,
xll
=
xll
,
yll
=
yll
)
# get grid info l1
n
col
s
,
n
row
s
,
__
,
xll
,
yll
,
cell_size
,
no_data
=
mp
.
get
.
l1_domain_info
()
# get grid info l1
(swap rows/cols to get "ij" indexing)
n
row
s
,
n
col
s
,
__
,
xll
,
yll
,
cell_size
,
no_data
=
mp
.
get
.
l1_domain_info
()
self
.
gridspec
[
"
L1
"
]
=
GridSpec
(
ncols
=
ncols
,
nrows
=
nrows
,
cell_size
=
cell_size
,
xll
=
xll
,
yll
=
yll
)
# get grid info l11
n
col
s
,
n
row
s
,
__
,
xll
,
yll
,
cell_size
,
no_data
=
mp
.
get
.
l11_domain_info
()
# get grid info l11
(swap rows/cols to get "ij" indexing)
n
row
s
,
n
col
s
,
__
,
xll
,
yll
,
cell_size
,
no_data
=
mp
.
get
.
l11_domain_info
()
self
.
gridspec
[
"
L11
"
]
=
GridSpec
(
ncols
=
ncols
,
nrows
=
nrows
,
cell_size
=
cell_size
,
xll
=
xll
,
yll
=
yll
)
# get grid info l2
n
col
s
,
n
row
s
,
__
,
xll
,
yll
,
cell_size
,
no_data
=
mp
.
get
.
l2_domain_info
()
# get grid info l2
(swap rows/cols to get "ij" indexing)
n
row
s
,
n
col
s
,
__
,
xll
,
yll
,
cell_size
,
no_data
=
mp
.
get
.
l2_domain_info
()
self
.
gridspec
[
"
L2
"
]
=
GridSpec
(
ncols
=
ncols
,
nrows
=
nrows
,
cell_size
=
cell_size
,
xll
=
xll
,
yll
=
yll
)
...
...
@@ -110,7 +111,10 @@ class Mhm(ATimeComponent):
data
=
Grid
(
spec
=
self
.
gridspec
[
var
.
split
(
"
_
"
)[
0
]],
no_data
=
self
.
no_data
,
data
=
mp
.
get_variable
(
var
).
filled
().
reshape
(
-
1
),
# flip upside down to use lower-left corner as origin
data
=
np
.
flipud
(
mp
.
get_variable
(
var
,
indexing
=
"
ij
"
).
filled
()
).
reshape
(
-
1
),
),
time
=
self
.
time
,
)
...
...
@@ -118,6 +122,7 @@ class Mhm(ATimeComponent):
def
validate
(
self
):
super
().
validate
()
# TODO: add checks if connected outputs are compatible with process selection
self
.
_status
=
ComponentStatus
.
VALIDATED
@execute_in_cwd
...
...
@@ -127,7 +132,6 @@ class Mhm(ATimeComponent):
# Don't run further than mHM can
if
mp
.
run
.
finished
():
return
mp
.
run
.
do_time_step
()
mp
.
run
.
write_output
()
# do we want this here?
# update time
...
...
@@ -141,7 +145,10 @@ class Mhm(ATimeComponent):
data
=
Grid
(
spec
=
self
.
gridspec
[
var
.
split
(
"
_
"
)[
0
]],
no_data
=
self
.
no_data
,
data
=
mp
.
get_variable
(
var
).
filled
().
reshape
(
-
1
),
# flip upside down to use lower-left corner as origin
data
=
np
.
flipud
(
mp
.
get_variable
(
var
,
indexing
=
"
ij
"
).
filled
()
).
reshape
(
-
1
),
),
time
=
self
.
time
,
)
...
...
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