Skip to content
Snippets Groups Projects
Commit 17e235fb authored by Martin Lange's avatar Martin Lange
Browse files

implement untested LAI adapter, set up test barebone

parent e5be31f6
No related branches found
No related tags found
No related merge requests found
from .mhm import Mhm
from .lai_adapter import YearlyToMonthly
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
import unittest
from datetime import datetime, timedelta
from finam_mhm_module import YearlyToMonthly
class TestLaiAdapter(unittest.TestCase):
def test_adapter(self):
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment