def model_api(self) -> dict: """ Class method that retrieves data from hobolink and usgs and processes data, then creates json-like dictionary structure for model output. returns: json-like dictionary """ df = get_data() dfs = { 2: reach_2_model(df), 3: reach_3_model(df), 4: reach_4_model(df), 5: reach_5_model(df) } main = {} models = {} # adds metadata main['version'] = '2020' main['time_returned'] = str(pd.to_datetime('today')) for reach, df in dfs.items(): add_to_dict(models, df, reach) # adds models dict to main dict main['models'] = models return main
def output_model() -> str: df = get_hobolink_data('code_for_boston_export_21d') df = process_data(df) return '<br /><br />'.join( map(stylize_model_output, [ reach_2_model(df), reach_3_model(df), reach_4_model(df), reach_5_model(df) ]))
def index() -> str: df_hobolink = get_hobolink_data('code_for_boston_export_21d') df_usgs = get_usgs_data() df = process_data(df_hobolink, df_usgs) flags = { 2: reach_2_model(df, rows=1)['r2_safe'].iloc[0], 3: reach_3_model(df, rows=1)['r3_safe'].iloc[0], 4: reach_4_model(df, rows=1)['r4_safe'].iloc[0], 5: reach_5_model(df, rows=1)['r5_safe'].iloc[0] } return render_template('index.html', flags=flags)
def output_model() -> str: df_hobolink = get_hobolink_data('code_for_boston_export_21d') df_usgs = get_usgs_data() df = process_data(df_hobolink, df_usgs) table_html = '<br /><br />'.join( map(stylize_model_output, [ reach_2_model(df), reach_3_model(df), reach_4_model(df), reach_5_model(df) ])) return render_template('output_model.html', tables=table_html)
def index() -> str: """ Retrieves data from hobolink and usgs and processes data, then displays data on `index_model.html` returns: render model on index.html """ df = get_data() flags = { 2: reach_2_model(df, rows=1)['safe'].iloc[0], 3: reach_3_model(df, rows=1)['safe'].iloc[0], 4: reach_4_model(df, rows=1)['safe'].iloc[0], 5: reach_5_model(df, rows=1)['safe'].iloc[0] } return render_template('index.html', flags=flags)