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
17e235fb
Commit
17e235fb
authored
2 years ago
by
Martin Lange
Browse files
Options
Downloads
Patches
Plain Diff
implement untested LAI adapter, set up test barebone
parent
e5be31f6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/finam_mhm_module/__init__.py
+1
-0
1 addition, 0 deletions
src/finam_mhm_module/__init__.py
src/finam_mhm_module/lai_adapter.py
+35
-0
35 additions, 0 deletions
src/finam_mhm_module/lai_adapter.py
tests/test_lai_adapter.py
+9
-0
9 additions, 0 deletions
tests/test_lai_adapter.py
with
45 additions
and
0 deletions
src/finam_mhm_module/__init__.py
+
1
−
0
View file @
17e235fb
from
.mhm
import
Mhm
from
.lai_adapter
import
YearlyToMonthly
This diff is collapsed.
Click to expand it.
src/finam_mhm_module/lai_adapter.py
0 → 100644
+
35
−
0
View file @
17e235fb
from
datetime
import
datetime
from
finam.core.sdk
import
AAdapter
class
YearlyToMonthly
(
AAdapter
):
"""
Disaggregates yearly LAI to a stack of monthly LAIs.
"""
def
__init__
(
self
,
lai_curve
):
super
().
__init__
()
self
.
data
=
None
self
.
month
=
0
if
len
(
lai_curve
)
!=
12
:
raise
ValueError
(
"
LAI curve must be an array of 12 values
"
)
self
.
lai_curve
=
lai_curve
def
source_changed
(
self
,
time
):
if
not
isinstance
(
time
,
datetime
):
raise
ValueError
(
"
Time must be of type datetime
"
)
self
.
data
=
self
.
pull_data
(
time
)
self
.
month
=
time
.
month
self
.
notify_targets
(
time
)
def
get_data
(
self
,
time
):
if
not
isinstance
(
time
,
datetime
):
raise
ValueError
(
"
Time must be of type datetime
"
)
new_month
=
time
.
month
lai
=
[]
for
m
in
range
(
self
.
month
-
1
,
new_month
):
lai
.
append
(
self
.
data
*
self
.
lai_curve
[
m
])
return
lai
This diff is collapsed.
Click to expand it.
tests/test_lai_adapter.py
0 → 100644
+
9
−
0
View file @
17e235fb
import
unittest
from
datetime
import
datetime
,
timedelta
from
finam_mhm_module
import
YearlyToMonthly
class
TestLaiAdapter
(
unittest
.
TestCase
):
def
test_adapter
(
self
):
pass
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