def pinalito(request): """ Controller for the Add Dam page. """ comids = ['790'] forecastinfo = getforecastflows(comids) data = gethistoricaldata('Pinalito') timeseries_plot = TimeSeries( height='500px', width='500px', engine='highcharts', title='Pinalito', y_axis_title='Niveles de agua', y_axis_units='m', series=[{ 'name': 'Historico', 'data': data }], y_min = 1160 ) #This creates the table table_view = TableView(column_names=('Caudales/Niveles',forecastinfo['timestep'][0], forecastinfo['timestep'][1], forecastinfo['timestep'][2], forecastinfo['timestep'][3], forecastinfo['timestep'][4], forecastinfo['timestep'][5], forecastinfo['timestep'][6]), rows=[('Caudal de Entrada (Total)',forecastinfo['total'][0], forecastinfo['total'][1], forecastinfo['total'][2],forecastinfo['total'][3],forecastinfo['total'][4],forecastinfo['total'][5],forecastinfo['total'][6]), ('Caudal de Entrada (790)', forecastinfo['790'][0], forecastinfo['790'][1], forecastinfo['790'][2], forecastinfo['790'][3], forecastinfo['790'][4], forecastinfo['790'][5], forecastinfo['790'][6]), ('Niveles','368', '370', '369', '374','373','371','372')], hover=True, striped=True, bordered=True, condensed=False) outflow_edit = TableView(column_names=('Dia', 'Caudal de Salida (cms)', 'Tiempo de salida (horas)'), rows=[(forecasteddata['dates'][0], '0', '0'), (forecasteddata['dates'][1], '0', '0'), (forecasteddata['dates'][2], '0', '0'), (forecasteddata['dates'][3], '0', '0'), (forecasteddata['dates'][4], '0', '0'), (forecasteddata['dates'][5], '0', '0'), (forecasteddata['dates'][6], '0', '0'), ], hover=True, striped=True, bordered=True, condensed=True, editable_columns=(False, 'Outflow', 'Time'), row_ids=['day1', 'day2', 'day3', 'day4', 'day5', 'day6', 'day7'], classes="outflowtable" ) calculate = Button(display_text='Calcular Niveles del Embalse', name='calculate', style='', icon='', href='', submit=False, disabled=False, attributes={"onclick": "calculatelevels()"}, classes='calcbut' ) outflow_button = Button(display_text='Ingresar caudales de salida', name='dimensions', style='', icon='', href='', submit=False, disabled=False, attributes={"onclick": "outflowmodal()"}, classes='outflow_button' ) context = { 'timeseries_plot': timeseries_plot, 'table_view': table_view, 'outflow_button': outflow_button, 'calculate': calculate, 'outflow_edit': outflow_edit, } return render(request, 'reservoir_management/pinalito.html', context)
def valdesia(request): """ Controller for the Add Dam page. """ comids = ['159'] forecasteddata = gettabledates(comids) data = gethistoricaldata('Valdesia') min_level = [[data[0][0], 130.75], [data[-1][0], 130.75]] max_level = [[data[0][0], 150.00], [data[-1][0], 150.00]] timeseries_plot = TimeSeries( height='500px', width='500px', engine='highcharts', title='Valdesia', y_axis_title='Niveles de agua', y_axis_units='m', series=[ {'name': 'Historico','data': data}, {'name': 'Nivel Minimo', 'data': min_level, 'type': 'line', 'color': '#660066'}, {'name': 'Nivel Maximo', 'data': max_level, 'type': 'line', 'color': '#FF0000'} ], y_min = 110 ) outflow_edit = TableView(column_names=('Dia', 'Caudal de Salida (cms)', 'Tiempo de salida (horas)'), rows=[(forecasteddata[0], '0', '0'), (forecasteddata[1], '0', '0'), (forecasteddata[2], '0', '0'), (forecasteddata[3], '0', '0'), (forecasteddata[4], '0', '0'), (forecasteddata[5], '0', '0'), (forecasteddata[6], '0', '0'), ], hover=True, striped=True, bordered=True, condensed=True, editable_columns=(False, 'Outflow', 'Time'), row_ids=['day1', 'day2', 'day3', 'day4', 'day5', 'day6', 'day7'], classes="outflowtable" ) calculate = Button(display_text='Calcular Niveles del Embalse', name='calculate', style='', icon='', href='', submit=False, disabled=False, attributes={"onclick": "calculatelevels()"}, classes='calcbut' ) outflow_button = Button(display_text='Ingresar caudales de salida', name='dimensions', style='', icon='', href='', submit=False, disabled=False, attributes={"onclick": "outflowmodal()"}, classes='outflow_button' ) context = { 'timeseries_plot': timeseries_plot, 'outflow_button': outflow_button, 'calculate': calculate, 'outflow_edit': outflow_edit, } return render(request, 'reservoir_management/valdesia.html', context)
def site_handler(request, site_name): """ Main controller for the dams page. """ gen_urls(request) site_name = site_name.replace('_', " ") # Get config site_config = config(site_name) comids = site_config['comids'] forecasteddata = gettabledates(comids) historyname = site_name if (site_config['custom_history_name']): historyname = site_config['custom_history_name'] data = gethistoricaldata(historyname) min_level = [[data[0][0], site_config['min_level']], [data[-1][0], site_config['min_level']]] max_level = [[data[0][0], site_config['max_level']], [data[-1][0], site_config['max_level']]] timeseries_plot = TimeSeries(height='500px', width='500px', engine='highcharts', title=site_name, y_axis_title='Niveles de agua', y_axis_units='m', series=[{ 'name': 'Historico', 'data': data }, { 'name': 'Nivel Minimo de Operacion', 'data': min_level, 'type': 'line', 'color': '#660066' }, { 'name': 'Nivel Maximo de Operacion', 'data': max_level, 'type': 'line', 'color': '#FF0000' }], y_min=site_config['ymin']) outflow_edit = TableView( column_names=('Dia', 'Caudal de Salida (cms)', 'Tiempo de salida (horas)'), rows=[ (forecasteddata[0], '0', '0'), (forecasteddata[1], '0', '0'), (forecasteddata[2], '0', '0'), (forecasteddata[3], '0', '0'), (forecasteddata[4], '0', '0'), (forecasteddata[5], '0', '0'), (forecasteddata[6], '0', '0'), ], hover=True, striped=True, bordered=True, condensed=True, editable_columns=(False, 'Outflow', 'Time'), row_ids=['day1', 'day2', 'day3', 'day4', 'day5', 'day6', 'day7'], classes="outflowtable") calculate = Button(display_text='Calcular Niveles del Embalse', name='calculate', style='', icon='', href='', submit=False, disabled=False, attributes={"onclick": "calculatelevels()"}, classes='calcbut') outflow_button = Button(display_text='Ingresar caudales de salida', name='dimensions', style='', icon='', href='', submit=False, disabled=False, attributes={"onclick": "outflowmodal()"}, classes='outflow_button') context = { 'site_urls': gen_urls(request), 'name': site_name, 'timeseries_plot': timeseries_plot, 'outflow_button': edit_passthrough(request, outflow_button), 'calculate': calculate, 'outflow_edit': outflow_edit, 'show_edit': has_permission(request, 'update_data') } return render(request, 'reservoir_management/site_renderer.html', context)