via https
pip install git+https://github.com/RUBclim/isithotvia ssh
pip install git+ssh://git@github.com/RUBclim/isithotAn initial app can be create quite simple by adding a single data provider.
- Add a new
isithot.DataProviderinstance. TheDataProvider.get_current_dataandDataProvider.get_daily_datamethods need to be implemented. - Create a
isithot.ColumnMappinginstance which maps the columns of your data source to the columns the package expects. - Create a dictionary of
isithot.DataProviderwhere the key must match theid. - register the data providers with the current app
app.config['DATA_PROVIDERS'] = data_providers.
see the full documentation
from datetime import date
import pandas as pd
from flask import Flask
from isithot import ColumnMapping
from isithot import create_app
from isithot import DataProvider
from isithot.config import Config
class TestProvider(DataProvider):
def get_current_data(self, d: date) -> pd.DataFrame:
df = pd.DataFrame({
'date': [pd.Timestamp(d)],
'temp_max': [30.0],
'temp_min': [20.0],
})
return df.set_index('date')
def get_daily_data(self, d: date) -> pd.DataFrame:
x = pd.read_csv(
'testing/monthly_input_data/lmss_daily_long.csv',
parse_dates=['date'],
index_col='date',
)
x['doy'] = x.index.dayofyear
return x
def my_app() -> Flask:
col_map = ColumnMapping(
datetime='date',
temp_mean='temp_mean_mannheim',
temp_max='temp_max',
temp_min='temp_min',
day_of_year='doy',
)
data_providers = {
'test': TestProvider(
col_mapping=col_map,
name='Test',
id='test',
min_year=2010,
),
}
app = create_app(Config)
app.config['DATA_PROVIDERS'] = data_providers
return app
if __name__ == '__main__':
app = my_app()
app.run(debug=True)