Пример #1
0
def home(request):
    """
    Controller for the app home page.
    """

    ad_select = SelectInput(
        display_text='Select Additional Layer',
        name='ad_select',
        multiple=False,
        original=True,
        options=additional_layers(),
        initial='pop2020',
    )

    ad_opacity = RangeSlider(
        display_text='Additional Layer Opacity',
        name='ad_opacity',
        min=0,
        max=1,
        step=.05,
        initial=0.8,
    )

    fl_select = SelectInput(
        display_text='Select Flood Layer',
        name='fl_select',
        multiple=False,
        original=True,
        options=flood_layers(),
        initial='comp5',
    )

    fl_opacity = RangeSlider(
        display_text='Flood Layer Opacity',
        name='fl_opacity',
        min=0,
        max=1,
        step=.05,
        initial=.7,
    )

    context = {
        # display options
        'ad_select': ad_select,
        'ad_opacity': ad_opacity,
        'fl_select': fl_select,
        'fl_opacity': fl_opacity,
    }

    return render(request, 'viirs_explorer/home.html', context)
Пример #2
0
def gizmos(request):
    """
    Controller for the app home page.
    """

    date_picker = DatePicker(name='date',
                             display_text='Date',
                             autoclose=True,
                             format='MM d, yyyy',
                             start_date='2/15/2014',
                             start_view='decade',
                             today_button=True,
                             initial='February 15, 2017')

    text_input = TextInput(display_text='Text',
                           name='inputAmount',
                           placeholder='e.g.: 10.00',
                           prepend='$')

    slider1 = RangeSlider(display_text='Slider 1',
                          name='slider1',
                          min=0,
                          max=100,
                          initial=50,
                          step=1)

    context = {
        'date_picker': date_picker,
        'text_input': text_input,
        'slider1': slider1,
    }

    return render(request, 'map_app_lippold/gizmos.html', context)
Пример #3
0
def mapview(request):
    grade_slider = RangeSlider(display_text='Desired Average Grade',
                               name='grade_slider',
                               min=0,
                               max=.1,
                               initial=.05,
                               step=.01)

    find_route_button = Button(display_text='Calculate Route',
                               icon='glyphicon',
                               style='success')

    frontrunner_toggle_switch = ToggleSwitch(
        display_text='Frontrunner Stations', name='toggle1')
    dem_toggle_switch = ToggleSwitch(display_text='Utah DEM', name='toggle4')
    starting_point_button = Button(display_text='Add Starting Location',
                                   icon='glyphicon glyphicon-plus',
                                   style='success')
    ending_point_button = Button(display_text='Add Ending Location',
                                 icon='glyphicon glyphicon-plus',
                                 style='success')
    vertical_buttons = ButtonGroup(
        buttons=[starting_point_button, ending_point_button], vertical=True)

    context = {
        'grade_slider': grade_slider,
        'frontrunner_toggle_switch': frontrunner_toggle_switch,
        'dem_toggle_switch': dem_toggle_switch,
        'vertical_buttons': vertical_buttons,
        'find_route_button': find_route_button,
    }

    return render(request, 'lillywhitejaredmapapp/MapView.html', context)
def map(request):
    slider1 = RangeSlider(display_text='Time of Day',
                          name='slider1',
                          min='6AM',
                          max='9PM',
                          initial='6AM',
                          step=1)
    text_input = TextInput(display_text='Location Search',
                           name='input',
                           placeholder='e.g.: BYU Clyde Building',
                           prepend='')
    map_button = Button(display_text='Calculate',
                        name='map-button',
                        icon='glyphicon glyphicon-globe',
                        style='info',
                        attributes={
                            'data-toggle': 'tooltip',
                            'data-placement': 'top',
                            'onclick': 'app.bufferPoint()',
                            'title': 'Calculate'
                        })

    context = {
        'slider1': slider1,
        'map_button': map_button,
        'text_input': text_input
    }

    return render(request, 'geoids_traveltimepolygons/map.html', context)
Пример #5
0
def mapview(request):
    """
    Controller for the app map page.
    """
    time_slider = RangeSlider(display_text='Time of Day',
                          name='time_slider',
                          min=0,
                          max=24,
                          initial=12,
                          step=1
    )

    adjust_slider = RangeSlider(display_text='Air Quality Adjustment',
                          name='slider2',
                          min=-5,
                          max=5,
                          initial=0,
                          step=0.5,
    )

    search_input = TextInput(display_text='Location Search',
                            name = 'search_input',
                            icon_append = 'glyphicon glyphicon-search',
    )

    date_picker = DatePicker(name='date_picker',
                             display_text='Date',
                             autoclose=True,
                             format='MM d, yyyy',
                             start_date='03/05/18',
                             start_view='decade',
                             today_button=True,
                             initial='March 5, 2018'
    )

    context = {
        'time_slider': time_slider,
        'adjust_slider': adjust_slider,
        'search_input': search_input,
        'date_picker': date_picker,
    }

    return render(request, 'mapapp_gibbons/mapview.html', context)
Пример #6
0
def home(request):
    """
    Controller for the app home page.
    """
    # Get the options for the GLDAS Variables
    variables = gldas_variables()
    variable_opts = []
    for key in sorted(variables.keys()):
        variable_opts.append((key, variables[key]))
    del variables
    date_opts = available_dates()
    color_opts = wms_colors()

    variables = SelectInput(
        display_text='Pick a Variable',
        name='variables',
        multiple=False,
        options=variable_opts,
        initial=['Air Temperature'],
    )

    dates = SelectInput(
        display_text='Date Selection',
        name='dates',
        multiple=False,
        options=date_opts,
        initial=[date_opts[0]],
    )

    rasteropacity = RangeSlider(
        display_text='LDAS Layer Opacity',
        name='rasteropacity',
        min=.4,
        max=1,
        step=.05,
        initial=.8,
    )

    colors = SelectInput(
        display_text='Pick a Color Scale',
        name='colors',
        multiple=False,
        options=color_opts,
        initial=['Red-Blue'],
    )

    context = {
        'variables': variables,
        'dates': dates,
        'rasteropacity': rasteropacity,
        'colors': colors,
    }

    return render(request, 'malaria/home.html', context)
def home(request):
    """
    Controller for the app home page.
    """
    variables = gfs_variables()
    options = []
    for key in sorted(variables.keys()):
        tuple1 = (key, variables[key])
        options.append(tuple1)
    del tuple1, key, variables

    layers = SelectInput(
        display_text='Select GFS Variable',
        name='layers',
        multiple=False,
        original=True,
        options=options,
    )

    colors = SelectInput(
        display_text='Color Scheme',
        name='colors',
        multiple=False,
        original=True,
        options=wms_colors(),
    )

    times = SelectInput(
        display_text='Time Interval',
        name='times',
        multiple=False,
        original=True,
        options=get_times(),
    )

    opacity = RangeSlider(
        display_text='Layer Opacity',
        name='opacity',
        min=.5,
        max=1,
        step=.05,
        initial=.75,
    )

    context = {
        'layers': layers,
        'opacity': opacity,
        'colors': colors,
        'times': times,
    }

    return render(request, 'gfs_viewer/home.html', context)
Пример #8
0
def data(request):
    slider1 = RangeSlider(display_text='Slider 1',
                          name='slider1',
                          min=0,
                          max=100,
                          initial=50,
                          step=1)

    slider2 = RangeSlider(display_text='Slider 2',
                          name='slider2',
                          min=0,
                          max=1,
                          initial=0.5,
                          step=0.1,
                          disabled=True,
                          error='Incorrect, please choose another value.')

    context = {
        'slider1': slider1,
        'slider2': slider2,
    }

    return render(request, 'izzatmapapp/data.html', context)
def costpath(request):
    """
    Controller for the app home page.
    """
    slider_bar = RangeSlider(display_text='Desired Trail Grade',
                             name='slider_bar',
                             min=0,
                             max=20,
                             initial=10,
                             step=1)

    button = Button(display_text='Calculate',
                    name='button',
                    attributes={
                        'data-toggle': 'tooltip',
                        'data-placement': 'top',
                        'title': 'Calculate',
                        'onclick': 'calculate()'
                    })

    line_plot_view = LinePlot(engine='highcharts',
                              title='Elevation Profile',
                              subtitle='Utah Bike Trail',
                              spline=True,
                              x_axis_title='Distance',
                              x_axis_units='mi',
                              y_axis_title='Elevation',
                              y_axis_units='Ft',
                              series=[
                                  {
                                      'name':
                                      'Elevation',
                                      'color':
                                      '#0066ff',
                                      'marker': {
                                          'enabled': False
                                      },
                                      'data': [[0, 5], [10, -70], [20, -86.5],
                                               [30, -66.5], [40, -32.1],
                                               [50, -12.5], [60, -47.7],
                                               [70, -85.7], [80, -106.5]]
                                  },
                              ])

    context = {
        'button': button,
        'slider_bar': slider_bar,
        'line_plot_view': line_plot_view
    }
    return render(request, 'stevenevansmapapp/costpath.html', context)
Пример #10
0
def home(request):
    """
    Controller for the app home page.
    """

    chirpsproducts = SelectInput(
        display_text='Select a CHIRPS product',
        name='chirpsproducts',
        multiple=False,
        original=True,
        options=(
            ('CHIRPS GEFS 5 day forecast (average)', 'gefs_05day'),
            ('CHIRPS GEFS 10 day forecast (average)', 'gefs_10day'),
            ('CHIRPS GEFS 15 day forecast (average)', 'gefs_15day'),
        ),
    )

    colorscheme = SelectInput(display_text='Forecast Layer Color Scheme',
                              name='colorscheme',
                              multiple=False,
                              original=True,
                              options=(
                                  ('Precipitation', 'precipitation'),
                                  ('Greyscale', 'greyscale'),
                                  ('Rainbow', 'rainbow'),
                                  ('OCCAM', 'occam'),
                                  ('Red-Blue', 'redblue'),
                                  ('ALG', 'alg'),
                              ))

    opacity_raster = RangeSlider(
        display_text='Forecast Layer Opacity',
        name='opacity_raster',
        min=0,
        max=1,
        step=.05,
        initial=.5,
    )

    context = {
        'chirpsproducts': chirpsproducts,
        'colorscheme': colorscheme,
        'opacity_raster': opacity_raster,
        'filenames': get_forecast_netcdf_names(),
        'thredds_url': App.get_custom_setting('thredds_url'),
    }

    return render(request, 'chirps/home.html', context)
Пример #11
0
def mockup(request):
    slider_grade = RangeSlider(display_text='Desired Average Grade (ft/ft)',
                          name='slider_grade',
                          min=0.0001,
                          max=2,
                          initial=0.1,
                          step=0.0001,
                          attributes={
                              'onchange': 'get_grade_value();'
                          })

    context = {
        'slider_grade': slider_grade,
    }

    return render(request, 'cgmapapp/mockup.html', context)
Пример #12
0
def mapview(request):
    """
    map view page for my app
    """
    toggle_switch_DEM = ToggleSwitch(display_text='Utah DEM',
                                     name='DEM_toggle',
                                     on_label='Yes',
                                     off_label='No',
                                     on_style='success',
                                     off_style='danger',
                                     initial=True,
                                     size='large')

    toggle_switch_road = ToggleSwitch(display_text='Roads',
                                      name='road_toggle',
                                      on_label='Yes',
                                      off_label='No',
                                      on_style='success',
                                      off_style='danger',
                                      initial=True,
                                      size='large')

    date_picker = DatePicker(name='date1',
                             display_text='Prediction Date',
                             autoclose=True,
                             format='MM d, yyyy',
                             start_date='3/6/2018',
                             start_view='month',
                             today_button=True,
                             initial='March 6, 2018')

    distance_slider = RangeSlider(display_text='Distance of Interest (km)',
                                  name='distance_slider',
                                  min=0,
                                  max=50,
                                  initial=25,
                                  step=5)

    context = {
        'toggle_switch_DEM': toggle_switch_DEM,
        'toggle_switch_road': toggle_switch_road,
        'date_picker': date_picker,
        'distance_slider': distance_slider
    }

    return render(request, 'jacobmapapp/mapview.html', context)
Пример #13
0
def home(request):

    gp_button = Button(display_text='Run',
                       name='gp_button',
                       icon='glyphicon glyphicon-globe',
                       attributes={
                           'data-toggle': 'tooltip',
                           'data-placement': 'top',
                           'title': 'Run GeoProcessing Service'
                       })

    slider1 = RangeSlider(display_text='Buffer Radius (miles)',
                          name='distance_slider',
                          min=1,
                          max=10,
                          initial=2,
                          step=1)

    info_box = MessageBox(
        name='info_box',
        title='Info',
        message=
        'Click on the map within the SLC county. Select your buffer distance and then click on Run. This service takes about 15s to run.',
        affirmative_button='Ok',
        width=400,
        affirmative_attributes='href=javascript:void(0);')

    refresh_button = Button(
        display_text='Refresh',
        name='button',
        attributes={
            'data-toggle': 'tooltip',
            'data-placement': 'top',
            'title': 'refresh',
            'onclick': 'app.refresh()'
        },
    )

    return render(
        request, 'valor_airquality/home-map.html', {
            'gp_button': gp_button,
            'slider1': slider1,
            'info_box': info_box,
            'refresh_button': refresh_button
        })
Пример #14
0
def home(request):
    """
    Controller for the app home page.
    """
    variables = gldas_variables()
    options = []
    for key in sorted(variables.keys()):
        tuple1 = (key, variables[key])
        options.append(tuple1)
    del tuple1, key, variables

    variables = SelectInput(
        display_text='Select GLDAS Variable',
        name='variables',
        multiple=False,
        original=True,
        options=options,
    )

    dates = SelectInput(display_text='Time Interval',
                        name='dates',
                        multiple=False,
                        original=True,
                        options=timecoverage(),
                        initial='alltimes')

    colorscheme = SelectInput(display_text='Raster Color Scheme',
                              name='colorscheme',
                              multiple=False,
                              original=True,
                              options=wms_colors(),
                              initial='rainbow')

    opacity_raster = RangeSlider(
        display_text='Raster Opacity',
        name='opacity_raster',
        min=.5,
        max=1,
        step=.05,
        initial=1,
    )

    colors_geojson = SelectInput(display_text='Boundary Colors',
                                 name='colors_geojson',
                                 multiple=False,
                                 original=True,
                                 options=geojson_colors(),
                                 initial='#ffffff')

    opacity_geojson = RangeSlider(
        display_text='Boundary Opacity',
        name='opacity_geojson',
        min=.0,
        max=1,
        step=.1,
        initial=1,
    )

    charttype = SelectInput(
        display_text='Choose a Plot Type',
        name='charttype',
        multiple=False,
        original=True,
        options=get_charttypes(),
    )

    context = {
        'variables': variables,
        'dates': dates,
        'colorscheme': colorscheme,
        'opacity_raster': opacity_raster,
        'colors_geojson': colors_geojson,
        'opacity_geojson': opacity_geojson,
        'charttype': charttype,
        'youtubelink': App.youtubelink,
        'githublink': App.githublink,
        'gldaslink': App.gldaslink,
        'version': App.version,
    }

    return render(request, 'ldas_central/home.html', context)
Пример #15
0
def home(request):
    colorscheme = SelectInput(display_text='GLDAS Color Scheme',
                              name='colorscheme',
                              multiple=False,
                              original=True,
                              options=wms_colors(),
                              initial='rainbow')

    opacity = RangeSlider(
        display_text='GLDAS Layer Opacity',
        name='opacity',
        min=.5,
        max=1,
        step=.05,
        initial=1,
    )

    gj_color = SelectInput(display_text='Boundary Border Colors',
                           name='gjClr',
                           multiple=False,
                           original=True,
                           options=geojson_colors(),
                           initial='#ffffff')

    gj_opacity = RangeSlider(
        display_text='Boundary Border Opacity',
        name='gjOp',
        min=0,
        max=1,
        step=.1,
        initial=1,
    )

    gj_weight = RangeSlider(
        display_text='Boundary Border Thickness',
        name='gjWt',
        min=1,
        max=5,
        step=1,
        initial=2,
    )

    gj_fillcolor = SelectInput(display_text='Boundary Fill Color',
                               name='gjFlClr',
                               multiple=False,
                               original=True,
                               options=geojson_colors(),
                               initial='rgb(0,0,0,0)')

    gj_fillopacity = RangeSlider(
        display_text='Boundary Fill Opacity',
        name='gjFlOp',
        min=0,
        max=1,
        step=.1,
        initial=.5,
    )

    context = {
        # variable data
        'layer': 'Infection',

        # display options
        'colorscheme': colorscheme,
        'opacity': opacity,
        'gjClr': gj_color,
        'gjOp': gj_opacity,
        'gjWt': gj_weight,
        'gjFlClr': gj_fillcolor,
        'gjFlOp': gj_fillopacity,

        # metadata
        'app': App.package,
        'thredds_url': App.get_custom_setting('thredds_url'),
        'instance_id': new_id(),
    }

    return render(request, 'infection/home.html', context)
Пример #16
0
def home(request):
    """
    Controller for the app home page.
    """

    gfsdate = currentgfs()

    variables = SelectInput(
        display_text='Select GFS Variable',
        name='variables',
        multiple=False,
        original=True,
        options=gfs_variables(),
    )

    levels = SelectInput(
        display_text='Available Forecast Levels',
        name='levels',
        multiple=False,
        original=True,
        options=variable_levels()['al'],
    )

    regions = SelectInput(
        display_text='Pick A World Region (ESRI Living Atlas)',
        name='regions',
        multiple=False,
        original=True,
        options=list(worldregions())
    )

    colorscheme = SelectInput(
        display_text='GFS Color Scheme',
        name='colorscheme',
        multiple=False,
        original=True,
        options=wms_colors(),
        initial='rainbow'
    )

    opacity = RangeSlider(
        display_text='GFS Layer Opacity',
        name='opacity',
        min=.5,
        max=1,
        step=.05,
        initial=1,
    )

    gj_color = SelectInput(
        display_text='Boundary Border Colors',
        name='gjClr',
        multiple=False,
        original=True,
        options=geojson_colors(),
        initial='#ffffff'
    )

    gj_opacity = RangeSlider(
        display_text='Boundary Border Opacity',
        name='gjOp',
        min=0,
        max=1,
        step=.1,
        initial=1,
    )

    gj_weight = RangeSlider(
        display_text='Boundary Border Thickness',
        name='gjWt',
        min=1,
        max=5,
        step=1,
        initial=2,
    )

    gj_fillcolor = SelectInput(
        display_text='Boundary Fill Color',
        name='gjFlClr',
        multiple=False,
        original=True,
        options=geojson_colors(),
        initial='rgb(0,0,0,0)'
    )

    gj_fillopacity = RangeSlider(
        display_text='Boundary Fill Opacity',
        name='gjFlOp',
        min=0,
        max=1,
        step=.1,
        initial=.5,
    )

    context = {
        # data options
        'variables': variables,
        'levels': levels,
        'gfsdate': gfsdate,
        'regions': regions,

        # display options
        'colorscheme': colorscheme,
        'opacity': opacity,
        'gjClr': gj_color,
        'gjOp': gj_opacity,
        'gjWt': gj_weight,
        'gjFlClr': gj_fillcolor,
        'gjFlOp': gj_fillopacity,

        # metadata
        'app': App.package,
        'githublink': App.githublink,
        'datawebsite': App.datawebsite,
        'version': App.version,
        'thredds_url': App.get_custom_setting('thredds_url'),
        'instance_id': new_id(),
    }

    return render(request, 'gfs/home.html', context)
Пример #17
0
def home(request):
    variables = SelectInput(
        display_text='Select GLDAS Variable',
        name='variables',
        multiple=False,
        original=True,
        options=gldas_variables(),
    )
    dates = SelectInput(
        display_text='Time Interval',
        name='dates',
        multiple=False,
        original=True,
        options=timeintervals(),
        initial='2010s'
    )

    charttype = SelectInput(
        display_text='Choose a Plot Type',
        name='charttype',
        multiple=False,
        original=True,
        options=get_charttypes(),
    )

    regions = SelectInput(
        display_text='Pick A World Region (ESRI Living Atlas)',
        name='regions',
        multiple=False,
        original=True,
        options=list(worldregions())
    )

    colorscheme = SelectInput(
        display_text='GLDAS Color Scheme',
        name='colorscheme',
        multiple=False,
        original=True,
        options=wms_colors(),
        initial='rainbow'
    )

    opacity = RangeSlider(
        display_text='GLDAS Layer Opacity',
        name='opacity',
        min=.5,
        max=1,
        step=.05,
        initial=1,
    )

    gj_color = SelectInput(
        display_text='Boundary Border Colors',
        name='gjClr',
        multiple=False,
        original=True,
        options=geojson_colors(),
        initial='#ffffff'
    )

    gj_opacity = RangeSlider(
        display_text='Boundary Border Opacity',
        name='gjOp',
        min=0,
        max=1,
        step=.1,
        initial=1,
    )

    gj_weight = RangeSlider(
        display_text='Boundary Border Thickness',
        name='gjWt',
        min=1,
        max=5,
        step=1,
        initial=2,
    )

    gj_fillcolor = SelectInput(
        display_text='Boundary Fill Color',
        name='gjFlClr',
        multiple=False,
        original=True,
        options=geojson_colors(),
        initial='rgb(0,0,0,0)'
    )

    gj_fillopacity = RangeSlider(
        display_text='Boundary Fill Opacity',
        name='gjFlOp',
        min=0,
        max=1,
        step=.1,
        initial=.5,
    )

    context = {
        # data options
        'variables': variables,
        'dates': dates,
        'charttype': charttype,
        'regions': regions,

        # display options
        'colorscheme': colorscheme,
        'opacity': opacity,
        'gjClr': gj_color,
        'gjOp': gj_opacity,
        'gjWt': gj_weight,
        'gjFlClr': gj_fillcolor,
        'gjFlOp': gj_fillopacity,

        # metadata
        'app': App.package,
        'githublink': App.githublink,
        'datawebsite': App.datawebsite,
        'version': App.version,
        'thredds_url': App.get_custom_setting('thredds_url'),
        'instance_id': new_id(),
    }

    return render(request, 'gldas/home.html', context)
Пример #18
0
def home(request):
    """
    Controller for the app home page.
    """

    gfs_date, wrfpr_date = get_forecastdates()

    ffgsregions = SelectInput(
        display_text='Choose a FFGS Region',
        name='region',
        multiple=False,
        original=True,
        options=ffgs_regions(),
    )

    hisp_models = SelectInput(
        display_text='Choose a Forecast Model',
        name='hisp_models',
        multiple=False,
        original=True,
        options=hispaniola_models(),
    )

    central_models = SelectInput(
        display_text='Choose a Forecast Model',
        name='central_models',
        multiple=False,
        original=True,
        options=centralamerica_models(),
    )

    chartoptions = SelectInput(
        display_text='Choose a Chart Type',
        name='chartoptions',
        multiple=False,
        original=True,
        options=chart_options(),
    )

    resulttypeoptions = SelectInput(
        display_text='Color Regions By Result Type',
        name='resulttype',
        multiple=False,
        original=True,
        options=resulttype_options(),
    )

    colorscheme = SelectInput(
        display_text='Forecast Layer Color Scheme',
        name='colorscheme',
        multiple=False,
        original=True,
        options=wms_colors(),
    )

    opacity_raster = RangeSlider(
        display_text='Forecast Layer Opacity',
        name='opacity_raster',
        min=0,
        max=1,
        step=.05,
        initial=.5,
    )

    legendintervals = RangeSlider(
        display_text='Color Scale Intervals',
        name='legendintervals',
        min=1,
        max=20,
        step=1,
        initial=5,
    )

    context = {
        'gfs_forecastdate': gfs_date,
        'wrfpr_forecastdate': wrfpr_date,
        'hisp_models': hisp_models,
        'central_models': central_models,
        'ffgsregions': ffgsregions,
        'chartoptions': chartoptions,
        'resulttypeoptions': resulttypeoptions,
        'colorscheme': colorscheme,
        'opacity_raster': opacity_raster,
        'legendintervals': legendintervals,
        'githublink': App.githublink,
        'version': App.version,
    }

    return render(request, 'ffgs/home.html', context)
def historical(request):
    """
    Controller for the app home page.
    """
    mekongBuffer = ee.FeatureCollection(
        'ft:1LEGeqwlBCAlN61ie5ol24NdUDqB1MgpFR_sJNWQJ')
    mekongRegion = mekongBuffer.geometry()

    region = ee.Geometry.Rectangle([-180, -90, 180, 90])

    algorithm_selection = SelectInput(
        # display_text='Select Surface Water Algorithm:',
        name='algorithm_selection',
        multiple=False,
        options=[('Surface Water Tool', 'SWT'), ('JRC Tool', 'JRC')],
        initial=['JRC Tool'],
    )

    # Date Picker Options
    date_picker1 = DatePicker(
        name='date_picker1',
        # display_text='Start Date',
        autoclose=True,
        format='yyyy-mm-dd',
        start_date='1/1/1990',
        start_view='decade',
        today_button=True,
        initial='2000-01-01')

    # Date Picker Options
    date_picker2 = DatePicker(
        name='date_picker2',
        # display_text='End Date',
        autoclose=True,
        format='yyyy-mm-dd',
        start_date='1/1/1990',
        start_view='decade',
        today_button=True,
        initial='2015-12-31')

    month_slider = RangeSlider(display_text='Month',
                               name='month_slider',
                               min=1,
                               max=12,
                               initial=7,
                               step=1)

    view_options = MVView(projection='EPSG:4326',
                          center=[101.75, 16.50],
                          zoom=5,
                          maxZoom=18,
                          minZoom=2)

    water_map = MapView(height='100%',
                        width='100%',
                        controls=[
                            'FullScreen', {
                                'MousePosition': {
                                    'projection': 'EPSG:4326'
                                }
                            }
                        ],
                        basemap='OpenSteetMap',
                        view=view_options)

    update_button = Button(display_text='Update Map',
                           name='update-button',
                           icon='glyphicon glyphicon-refresh',
                           style='success',
                           attributes={'title': 'Update Map'})

    context = {
        'update_button': update_button,
        'date_picker1': date_picker1,
        'date_picker2': date_picker2,
        'month_slider': month_slider,
        'algorithm_selection': algorithm_selection,
        'water_layer': water_layer,
        'water_map': water_map,
    }

    return render(request, 'hydraviewer/historical.html', context)
Пример #20
0
def home(request):
    """
    Controller for the app home page.
    """
    variables = SelectInput(
        display_text='Select NLDAS Variable',
        name='variables',
        multiple=False,
        original=True,
        options=nldas_variables(),
    )
    events = SelectInput(
        display_text='Pick an Event',
        name='events',
        multiple=False,
        original=True,
        options=onion_creek_events(),
    )

    colorscheme = SelectInput(display_text='NLDAS Color Scheme',
                              name='colorscheme',
                              multiple=False,
                              original=True,
                              options=wms_colors(),
                              initial='rainbow')

    opacity = RangeSlider(
        display_text='NLDAS Layer Opacity',
        name='opacity',
        min=.5,
        max=1,
        step=.05,
        initial=1,
    )

    gj_color = SelectInput(display_text='Boundary Border Colors',
                           name='gjClr',
                           multiple=False,
                           original=True,
                           options=geojson_colors(),
                           initial='#ffffff')

    gj_opacity = RangeSlider(
        display_text='Boundary Border Opacity',
        name='gjOp',
        min=0,
        max=1,
        step=.1,
        initial=1,
    )

    gj_weight = RangeSlider(
        display_text='Boundary Border Thickness',
        name='gjWt',
        min=1,
        max=5,
        step=1,
        initial=2,
    )

    gj_fillcolor = SelectInput(display_text='Boundary Fill Color',
                               name='gjFlClr',
                               multiple=False,
                               original=True,
                               options=geojson_colors(),
                               initial='rgb(0,0,0,0)')

    gj_fillopacity = RangeSlider(
        display_text='Boundary Fill Opacity',
        name='gjFlOp',
        min=0,
        max=1,
        step=.1,
        initial=.5,
    )

    context = {
        # data options
        'variables': variables,
        'events': events,

        # display options
        'colorscheme': colorscheme,
        'opacity': opacity,
        'gjClr': gj_color,
        'gjOp': gj_opacity,
        'gjWt': gj_weight,
        'gjFlClr': gj_fillcolor,
        'gjFlOp': gj_fillopacity,

        # metadata
        'app': App.package,
        'githublink': App.githublink,
        'datawebsite': App.datawebsite,
        'version': App.version,
        'thredds_url': App.get_custom_setting('thredds_url'),
        'instance_id': new_id(),
    }

    return render(request, 'nldas/home.html', context)
Пример #21
0
def home(request, app_workspace):
    """
    Controller for the app home page.
    """
    geojson_colors = [('White', '#ffffff'),
                      ('Transparent', 'rgb(0,0,0,0)'),
                      ('Red', '#ff0000'),
                      ('Green', '#00ff00'),
                      ('Blue', '#0000ff'),
                      ('Black', '#000000'),
                      ('Pink', '#ff69b4'),
                      ('Orange', '#ffa500'),
                      ('Teal', '#008080'),
                      ('Purple', '#800080'), ]

    variables = SelectInput(
        display_text='Select a Dataset',
        name='variables',
        multiple=False,
        original=True,
        options=(('None', '1'),
                 #('GPM IMERG 7 Day Other', '2'),
                 #('GPM IMERG 30 min Precip. Accumulation', '2'),
                 #('GPM IMERG 3 hour Precip. Accumulation', '3'),
                 #('GPM IMERG 1 day Precip. Accumulation', '3'),
                 #('Landslide Susceptibility', '2')
                 ('GPM IMERG 7 day Precip. Accumulation', '3'),
                 ('Global Landslide Nowcast updated every 3 hours', '4')),
                 #('Points Test', '5')),
    )

    states_json_file_path = os.path.join(app_workspace.path, 'brazil-states.json')

    options = [('None', 'none')]
    with open(states_json_file_path, encoding='utf-8') as f:
        data = json.load(f)
        features = data.get('features')
        for feature in features:
            newOption = (feature.get('properties').get('name'), feature.get('properties').get('id'))
            options.append(newOption)

    # points_json_file_path = os.path.join(app_workspace.path, 'points.json')
    #
    # options = [('None', 'none')]
    # with open(points_json_file_path) as p:
    #     data = json.load(p)
    #     features = data.get('features')
    #     for feature in features:
    #         get = (feature.get('properties').get('name'), feature.get('properties').get('OBJECTID'))
    #         options.append(get)


    states = SelectInput(
        display_text='Pick A State (ESRI Living Atlas)',
        name='states',
        multiple=False,
        original=True,
        options=tuple(options)
    )

    colorscheme = SelectInput(
        display_text='GLDAS Raster Color Scheme',
        name='colorscheme',
        multiple=False,
        original=True,
        options=(('SST-36', 'sst_36'),
                 ('Greyscale', 'greyscale'),
                 ('Rainbow', 'rainbow'),
                 ('OCCAM', 'occam'),
                 ('OCCAM Pastel', 'occam_pastel-30'),
                 ('Red-Blue', 'redblue'),
                 ('NetCDF Viewer', 'ncview'),
                 ('ALG', 'alg'),
                 ('ALG 2', 'alg2'),
                 ('Ferret', 'ferret'),),
        initial='rainbow'
    )

    opacity = RangeSlider(
        display_text='GLDAS Layer Opacity',
        name='opacity',
        min=.5,
        max=1,
        step=.05,
        initial=1,
    )

    gj_color = SelectInput(
        display_text='Boundary Border Colors',
        name='gjClr',
        multiple=False,
        original=True,
        options=geojson_colors,
        initial='#ffffff'
    )

    gj_opacity = RangeSlider(
        display_text='Boundary Border Opacity',
        name='gjOp',
        min=0,
        max=1,
        step=.1,
        initial=1,
    )

    gj_weight = RangeSlider(
        display_text='Boundary Border Thickness',
        name='gjWt',
        min=1,
        max=5,
        step=1,
        initial=2,
    )

    gj_fillcolor = SelectInput(
        display_text='Boundary Fill Color',
        name='gjFlClr',
        multiple=False,
        original=True,
        options=geojson_colors,
        initial='rgb(0,0,0,0)'
    )

    gj_fillopacity = RangeSlider(
        display_text='Boundary Fill Opacity',
        name='gjFlOp',
        min=0,
        max=1,
        step=.1,
        initial=.5,
    )

    context = {
        # data options
        'variables': variables,
        'states': states,
        # display options
        'colorscheme': colorscheme,
        'opacity': opacity,
        'gjClr': gj_color,
        'gjOp': gj_opacity,
        'gjWt': gj_weight,
        'gjFlClr': gj_fillcolor,
        'gjFlOp': gj_fillopacity,

    }

    return render(request, 'lhasa_app/home.html', context)
def home(request):
    """
    Controller for the app home page.
    """

    gage_names = []
    select_gage_options_tuple = []

    # This is new
    temp_dir = RecessionAnalyzer.get_app_workspace().path
    #res_ids = request.GET.getlist('WofUri')
    res_ids = []
    res_ids.append('cuahsi-wdc-2017-04-03-30616779')
    res_ids.append('cuahsi-wdc-2017-04-03-30650403')
    res_ids.append('cuahsi-wdc-2017-04-03-30705857')
    for res_id in res_ids:
        url_zip = 'http://qa-webclient-solr.azurewebsites.net/CUAHSI/HydroClient/WaterOneFlowArchive/' + res_id + '/zip'
        r = requests.get(url_zip, verify=False)
        z = zipfile.ZipFile(io.BytesIO(r.content))
        file_list = z.namelist()

        for file in file_list:
            file_data = z.read(file)
            file_path = temp_dir + '/id/' + res_id + '.xml'
            with open(file_path, 'wb') as f:
                f.write(file_data)

        gage_name = getSite(res_id)
        gage_names.append(gage_name)
        select_gage_options_tuple.append((gage_name, gage_name))
    # New stuff ends here

    concave_initial = False
    nonlinear_fitting_initial = False
    rec_sense_initial = 1
    min_length_initial = 4
    antecedent_moisture_initial = 1
    lag_start_initial = 0

    #select_gage_options_initial = ['11476500']
    select_gage_options_initial = gage_names
    #select_gage_options_tuple = [('11476500', '11476500'), ('11477000', '11477000')]
    #select_gage_options_tuple = [(getSite(res_id), getSite(res_id))]

    abJson = ''
    seriesDict = {}
    scatter_plot_view = []
    line_plot_view = []
    context = {}
    gage_json = ''
    ab_stats = buildStatTable({'stats': []})
    submitted = False

    sites = pd.read_csv(
        '/usr/lib/tethys/src/tethys_apps/tethysapp/recession_analyzer/public/huc_18.tsv',
        sep='\t',
        header=30,
        index_col=False,
        skiprows=[31])
    sites = sites[sites.site_tp_cd == 'ST']
    names = sites.station_nm

    values = [str(x) for x in list(sites.site_no)]
    text = [num + ' ' + name[0:20] for (num, name) in zip(values, names)]
    gages_options_options = zip(text, values)
    gages_options_options_dict = dict(zip(values, text))

    # "Analyze recessions" button has been pressed
    # this stores new set of analysis parameters
    # and performs recession analysis, stores data in dictionaries
    # creates a new dropdown box with user gages

    if request.POST and 'analyze' in request.POST:

        # PRESERVE THE PREVIOUS STATE #

        gages_initial = request.POST.getlist("gages_input")
        start_initial = request.POST['start_input']
        stop_initial = request.POST['stop_input']

        if 'concave_input' in request.POST:
            concave_initial = True
        else:
            concave_initial = False

        if 'nonlinear_fitting_input' in request.POST:
            nonlinear_fitting_initial = True
        else:
            nonlinear_fitting_initial = False

        rec_sense_initial = request.POST['rec_sense_input']
        min_length_initial = request.POST['min_length_input']
        lag_start_initial = request.POST['lag_start_input']

        antecedent_moisture_initial = request.POST['antecedent_moisture_input']

        ########################################

        app_workspace = RecessionAnalyzer.get_user_workspace(request.user)
        new_file_path = os.path.join(app_workspace.path, 'current_plot.txt')
        pickle.dump(request.POST, open(new_file_path[:-4] + '.p', 'w'))
        post = pickle.load(open(new_file_path[:-4] + '.p', 'r'))

        submitted = True

        gage_json = json.dumps(gage_names)
        start = post['start_input']
        stop = post['stop_input']
        rec_sense = post['rec_sense_input']
        min_length = post['min_length_input']

        nonlin_fit = post.get('nonlinear_fitting_input', False)

        min_length = float(min_length)
        selectivity = float(rec_sense) * 500

        sitesDict, startStopDict = recessionExtract(gage_names,
                                                    res_ids,
                                                    start,
                                                    stop,
                                                    ante=10,
                                                    alph=0.90,
                                                    window=3,
                                                    selectivity=selectivity,
                                                    minLen=min_length,
                                                    option=1,
                                                    nonlin_fit=nonlin_fit)

        abJson, abDict = createAbJson(sitesDict, gage_names)

        a = []
        a0 = []
        b = []
        q = []
        g = []
        flow = np.array([])
        time = np.array([], dtype='<U10')
        gage_flow = []

        for gage in gage_names:
            a = a + abDict[gage]['a']
            a0 = a0 + abDict[gage]['a0']
            b = b + abDict[gage]['b']
            q = q + abDict[gage]['q']
            g = g + [str(gage)] * len(abDict[gage]['a'])

            flow2 = sitesDict[gage][gage].values
            flow = np.concatenate((flow, flow2), axis=0)
            time2 = sitesDict[gage].index.strftime('%Y-%m-%d')
            time = np.concatenate((time, time2), axis=0)
            gage_flow = gage_flow + [str(gage)] * len(sitesDict[gage][gage])

        dfinfo = np.array([g, a, a0, b, q])
        flow_info = np.array([gage_flow, time, flow])
        df = pd.DataFrame(data=np.transpose(dfinfo),
                          columns=['Gage', 'a', 'a0', 'b', 'q'])
        flow_df = pd.DataFrame(data=np.transpose(flow_info),
                               columns=['Gage', 'Time', 'Flow rate'])

        new_file_path = "/usr/local/lib/tethys/src/tethys_apps/tethysapp/recession_analyzer/templates/recession_analyzer/flowdata.html"
        flow_df.to_html(new_file_path)
        newline = '{% extends "recession_analyzer/base.html" %}\n{% load tethys_gizmos %}\n{% block app_content %}'
        line_prepender(new_file_path, newline)
        newline = '{% endblock %}'
        line_appender(new_file_path, newline)

        new_file_path = "/usr/local/lib/tethys/src/tethys_apps/tethysapp/recession_analyzer/templates/recession_analyzer/dataframe.html"
        df.to_html(new_file_path)
        newline = '{% extends "recession_analyzer/base.html" %}\n{% load tethys_gizmos %}\n{% block app_content %}'
        line_prepender(new_file_path, newline)
        newline = '{% endblock %}'
        line_appender(new_file_path, newline)

        # FIXME: Throw error here if len(gage_names) == 0

        for gage in gage_names:
            ts = sitesDict[gage]
            startStop = startStopDict[gage]
            startVec = startStop[0]
            endVec = startStop[1]
            flow = ts[gage]
            tsinds = ts.index

            series = []
            series.append({
                'name':
                ' ',
                'color':
                '#0066ff',
                'data':
                zip(flow[tsinds[0]:startVec[0]].index,
                    flow[tsinds[0]:startVec[0]])
            })
            series.append({
                'name':
                ' ',
                'color':
                '#ff6600',
                'data':
                zip(flow[startVec[0]:endVec[0]].index,
                    flow[startVec[0]:endVec[0]])
            })
            for i in np.arange(0, len(startVec) - 1):
                series.append({
                    'name':
                    ' ',
                    'color':
                    '#0066ff',
                    'data':
                    zip(flow[endVec[i]:startVec[i + 1]].index,
                        flow[endVec[i]:startVec[i + 1]])
                })
                series.append({
                    'name':
                    ' ',
                    'color':
                    '#ff6600',
                    'data':
                    zip(flow[startVec[i + 1]:endVec[i + 1]].index,
                        flow[startVec[i + 1]:endVec[i + 1]])
                })

            series.append({
                'name':
                ' ',
                'color':
                '#0066ff',
                'data':
                zip(flow[endVec[-1]:tsinds[-1]].index,
                    flow[endVec[-1]:tsinds[-1]])
            })

            seriesDict[gage] = series
            line_plot_view.append(
                buildFlowTimeSeriesPlot(series=seriesDict[gage], name=gage))

            avals = ts['A0n'][ts['A0n'] > 0].values
            bvals = ts['Bn'][ts['Bn'] > 0].values
            tuplelist = zip(avals, bvals)
            scatter_plot_view.append(
                buildRecParamPlot(tuplelist=tuplelist, name=gage))

        stats_dict = createStatsInfo(abJson)
        ab_stats = buildStatTable(stats_dict)

    gages_options = SelectInput(
        display_text='Select gage(s)',
        name='gages_input',
        multiple=True,
        options=gages_options_options,
        initial=[gages_options_options_dict[init] for init in gages_initial])

    start_options = DatePicker(name='start_input',
                               display_text='Start date',
                               autoclose=True,
                               format='yyyy-m-d',
                               start_date='01/01/1910',
                               initial=start_initial)

    stop_options = DatePicker(name='stop_input',
                              display_text='Stop date',
                              autoclose=True,
                              format='yyyy-m-d',
                              start_date='01/01/1910',
                              initial=stop_initial)

    concave_options = ToggleSwitch(name='concave_input',
                                   size='small',
                                   initial=concave_initial,
                                   display_text='Concave recessions')

    nonlinear_fitting_options = ToggleSwitch(name='nonlinear_fitting_input',
                                             display_text='Nonlinear fitting',
                                             size='small',
                                             initial=nonlinear_fitting_initial)

    min_length_options = RangeSlider(
        name='min_length_input',
        min=4,
        max=10,
        initial=min_length_initial,
        step=1,
        attributes={"onchange": "showValue(this.value,'min_length_initial');"})

    rec_sense_options = RangeSlider(
        name='rec_sense_input',
        min=0,
        max=1,
        initial=rec_sense_initial,
        step=0.01,
        attributes={"onchange": "showValue(this.value,'rec_sense_initial');"})

    antecedent_moisture_options = RangeSlider(
        name='antecedent_moisture_input',
        min=0,
        max=1,
        initial=antecedent_moisture_initial,
        step=0.01,
        attributes={
            "onchange": "showValue(this.value,'antecedent_moisture_initial');"
        })

    lag_start_options = RangeSlider(
        name='lag_start_input',
        min=0,
        max=3,
        initial=lag_start_initial,
        step=1,
        attributes={"onchange": "showValue(this.value,'lag_start_initial');"})

    select_gage_options = SelectInput(
        display_text='Select gage',
        name='gage_input',
        multiple=False,
        initial=select_gage_options_initial,
        options=select_gage_options_tuple,
        attributes={"onchange": "updatePlots(this.value);"})

    context.update({
        'rec_sense_initial': rec_sense_initial,
        'antecedent_moisture_initial': antecedent_moisture_initial,
        'lag_start_initial': lag_start_initial,
        'gage_json': gage_json,
        'min_length_initial': min_length_initial,
        'concave_options': concave_options,
        'nonlinear_fitting_options': nonlinear_fitting_options,
        'min_length_options': min_length_options,
        'submitted': submitted,
        'antecedent_moisture_options': antecedent_moisture_options,
        'lag_start_options': lag_start_options,
        'rec_sense_options': rec_sense_options,
        'line_plot_view': line_plot_view,
        'ab_stats': ab_stats,
        'scatter_plot_view': scatter_plot_view,
        'select_gage_options': select_gage_options,
        'abJson': abJson,
        'seriesDict': seriesDict,
        'gages_options': gages_options,
        'start_options': start_options,
        'stop_options': stop_options
    })

    return render(request, 'recession_analyzer/home.html', context)
Пример #23
0
def visualize_events(request,event_id,sub_event):
    event_id = int(event_id)
    sub_event = int(sub_event)
    event_number = sub_event+1
    
    if event_number < 1:
        event_number = 1
    metrics = retrieve_metrics(int(event_id),int(sub_event))
    #update metrics 
    
    if len(metrics)<1:
        try: 
            
            success = update_segmentation(int(event_id))
            metrics = retrieve_metrics(int(event_id),int(sub_event))
        except Exception as e:
            # Careful not to hide error. At the very least log it to the console
            print(e)
            
            return False
    
    
    if metrics[0]['Event Duration (hours)'] == '-1':
        try: 
            
            success = update_segmentation(int(event_id))
            metrics = retrieve_metrics(int(event_id),int(sub_event))
        except Exception as e:
            # Careful not to hide error. At the very least log it to the console
            print(e)
            
            return False
        
     
    
    
    
    time,flow,concentration,segments=get_conc_flow_seg(event_id)
    start_seg = 0
    end_seg = len(segments)-1
    
    if int(sub_event) > int(end_seg):
        sub_event = int(sub_event) - 1 
        event_number = sub_event + 1
        messages.info(request, 'Event '+str(end_seg+1)+' is the last event.')
     
    if int(sub_event) < 0:
        sub_event = int(sub_event) + 1 
        event_number = sub_event + 1
        messages.info(request, 'Event 1 is the first event.')   
        
        
    if request.POST and 'download-button' in request.POST:
        # Get Values
        has_errors = False
        

        if not has_errors:
            # create and write file here
            #print('no errors')
            
            success = 1
            # Provide feedback to user
            if success:
                
               
                
                fileDir = os.path.dirname(__file__)
                fname = fileDir+'/public/files/'+str(event_id)+'_file_metrics_temp.csv'
                fout = open(fname, 'w')
                fieldnames = metrics[0].keys()
                csvw = csv.DictWriter(fout, fieldnames = fieldnames)
                csvw.writeheader()
                csvw.writerows(metrics)
                fout.close()
                
                
                #remove old files
                if int(event_id) > 40:
                    fname2 = 'tethysdev/tethysapp-heda/tethysapp/heda/public/files/'+str(int(event_id)-30)+'_file_metrics_temp.csv'
                    if os.path.exists(fname2):
                        os.remove(fname2)
        
            
            
                filename = fname    
                fname = 'HEDA_download'
                content = FileWrapper(open(filename))
                response = HttpResponse(content, content_type='text/csv')
                response['Content-Disposition'] = 'attachment; filename=%s' % fname
                
                
                return response
                
                   
            else:
                messages.info(request, 'Unable to download data file.')
            
            return redirect(reverse('heda:add_data', kwargs={"event_id": event_id}))

        messages.error(request, "Unknown problem.")
        
    
    
    download_button = Button(
        display_text='Download metrics',
        name='download-button',
        submit=True,
        icon='glyphicon glyphicon-download',
        style='success',
        attributes={'form': 'slider-data-form'},
        
        
    )
    
    
    
    
    cancel_button = Button(
        display_text='Cancel',
        name='cancel-button',
        href=reverse('heda:home')
    )
    
    previous_button = Button(
        display_text='Previous',
        name='previous-button',
        icon='glyphicon glyphicon-step-backward',
        href=reverse('heda:visualize_events', kwargs={"event_id": event_id,"sub_event": str(int(sub_event)-1)}),
        style='success',
    )
        
    
    
    next_button = Button(
    display_text='Next',
        name='next-button',
        icon='glyphicon glyphicon-step-forward',
        href=reverse('heda:visualize_events', kwargs={"event_id": event_id,"sub_event": str(int(sub_event)+1)}),
        style='success',
    )
    
    cqt_cq_plot = cqt_cq_event_plot(int(event_id),int(sub_event))
    
    table_rows = []
    
    metrics_dict = OrderedDict()
    if len(metrics)>0:
        metrics_dict = metrics[int(sub_event)]
        
        for k in metrics_dict.keys():
            table_rows.append((k,metrics_dict[k]))
        
    
    
    
    
    if request.POST and 'event-number' in request.POST:
        sub_event = request.POST.get('event-number', None)
        sub_event = int(sub_event) - 1
        sub_event = str(sub_event)
        return redirect(reverse('heda:visualize_events', kwargs={"event_id": event_id,"sub_event": sub_event}))
            
    metric_table = DataTableView(
        column_names=('Name', 'Value'),
        rows=table_rows,
        searching=False,
        orderClasses=False,
        lengthMenu=[ [10, 25, 50, -1], [10, 25, 50, "All"] ],
        DisplayLength = -1,
        ordering = False,
    )
    
    
    
    event_number_slider = RangeSlider(display_text='',
                      name='event-number',
                      min=start_seg+1,
                      max=end_seg+1,
                      initial=event_number,
                      step=1,
                      attributes={'form': 'slider-data-form'},
                      )
                      
                      
    jump_button = Button(
        display_text='Jump using slider',
        name='jump-button',
        icon='',
        style='success',
        attributes={'form': 'slider-data-form'},
        #href=reverse('heda:add_data', kwargs={"event_id": event_id}),
        #disabled=segment_button_disable,
        submit=True
    )

    
    context = {

        'cq_plot':cqt_cq_plot, 
        'cancel_button': cancel_button,
        'previous_button': previous_button,
        'download_button':download_button,
        'next_button':next_button,
        'metric_table':metric_table,
        'event_number_slider':event_number_slider,
        'sub_event': sub_event,
        'jump_button':jump_button,
        'event_number':event_number,

    }
    
    
    return render(request, 'heda/visualize_events.html', context)
def home(request):
    """
    Controller for the app home page.
    """
    geojson_colors = [
        ('White', '#ffffff'),
        ('Transparent', 'rgb(0,0,0,0)'),
        ('Red', '#ff0000'),
        ('Green', '#00ff00'),
        ('Blue', '#0000ff'),
        ('Black', '#000000'),
        ('Pink', '#ff69b4'),
        ('Orange', '#ffa500'),
        ('Teal', '#008080'),
        ('Purple', '#800080'),
    ]

    variables = SelectInput(
        display_text='Select GLDAS Variable',
        name='variables',
        multiple=False,
        original=True,
        options=(('Air Temperature', 'Tair_f_inst'), ('Canopy Water Amount',
                                                      'CanopInt_inst'),
                 ('Downward Heat Flux In Soil',
                  'Qg_tavg'), ('Evaporation Flux From Canopy', 'ECanop_tavg'),
                 ('Evaporation Flux From Soil',
                  'ESoil_tavg'), ('Potential Evaporation Flux',
                                  'PotEvap_tavg'), ('Precipitation Flux',
                                                    'Rainf_f_tavg'),
                 ('Rainfall Flux', 'Rainf_tavg'), ('Root Zone Soil Moisture',
                                                   'RootMoist_inst'),
                 ('Snowfall Flux', 'Snowf_tavg'), ('Soil Temperature',
                                                   'SoilTMP0_10cm_inst'),
                 ('Specific Humidity',
                  'Qair_f_inst'), ('Subsurface Runoff Amount', 'Qsb_acc'),
                 ('Surface Air Pressure', 'Psurf_f_inst'), ('Surface Albedo',
                                                            'Albedo_inst'),
                 ('Surface Downwelling Longwave Flux In Air', 'LWdown_f_tavg'),
                 ('Surface Downwelling Shortwave Flux In Air',
                  'SWdown_f_tavg'), ('Surface Net Downward Longwave Flux',
                                     'Lwnet_tavg'),
                 ('Surface Net Downward Shortwave Flux',
                  'Swnet_tavg'), ('Surface Runoff Amount', 'Qs_acc'),
                 ('Surface Snow Amount',
                  'SWE_inst'), ('Surface Snow Melt Amount',
                                'Qsm_acc'), ('Surface Snow Thickness',
                                             'SnowDepth_inst'),
                 ('Surface Temperature',
                  'AvgSurfT_inst'), ('Surface Upward Latent Heat Flux',
                                     'Qle_tavg'),
                 ('Surface Upward Sensible Heat Flux',
                  'Qh_tavg'), ('Transpiration Flux From Veg',
                               'Tveg_tavg'), ('Water Evaporation Flux',
                                              'Evap_tavg'), ('Wind Speed',
                                                             'Wind_f_inst')),
    )

    regions = SelectInput(
        display_text='Pick A World Region (ESRI Living Atlas)',
        name='regions',
        multiple=False,
        original=True,
        options=(
            ('All World Regions', ''),
            ('Antarctica', 'Antarctica'),
            ('Asiatic Russia', 'Asiatic Russia'),
            ('Australia/New Zealand', 'Australia/New Zealand'),
            ('Caribbean', 'Caribbean'),
            ('Central America', 'Central America'),
            ('Central Asia', 'Central Asia'),
            ('Eastern Africa', 'Eastern Africa'),
            ('Eastern Asia', 'Eastern Asia'),
            ('Eastern Europe', 'Eastern Europe'),
            ('European Russia', 'European Russia'),
            ('Melanesia', 'Melanesia'),
            ('Micronesia', 'Micronesia'),
            ('Middle Africa', 'Middle Africa'),
            ('Northern Africa', 'Northern Africa'),
            ('Northern America', 'Northern America'),
            ('Northern Europe', 'Northern Europe'),
            ('Polynesia', 'Polynesia'),
            ('South America', 'South America'),
            ('Southeastern Asia', 'Southeastern Asia'),
            ('Southern Africa', 'Southern Africa'),
            ('Southern Asia', 'Southern Asia'),
            ('Southern Europe', 'Southern Europe'),
            ('Western Africa', 'Western Africa'),
            ('Western Asia', 'Western Asia'),
            ('Western Europe', 'Western Europe'),
            ('None', 'none'),
        ))

    colorscheme = SelectInput(display_text='GLDAS Raster Color Scheme',
                              name='colorscheme',
                              multiple=False,
                              original=True,
                              options=(
                                  ('SST-36', 'sst_36'),
                                  ('Greyscale', 'greyscale'),
                                  ('Rainbow', 'rainbow'),
                                  ('OCCAM', 'occam'),
                                  ('OCCAM Pastel', 'occam_pastel-30'),
                                  ('Red-Blue', 'redblue'),
                                  ('NetCDF Viewer', 'ncview'),
                                  ('ALG', 'alg'),
                                  ('ALG 2', 'alg2'),
                                  ('Ferret', 'ferret'),
                              ),
                              initial='rainbow')

    opacity = RangeSlider(
        display_text='GLDAS Layer Opacity',
        name='opacity',
        min=.5,
        max=1,
        step=.05,
        initial=1,
    )

    gj_color = SelectInput(display_text='Boundary Border Colors',
                           name='gjClr',
                           multiple=False,
                           original=True,
                           options=geojson_colors,
                           initial='#ffffff')

    gj_opacity = RangeSlider(
        display_text='Boundary Border Opacity',
        name='gjOp',
        min=0,
        max=1,
        step=.1,
        initial=1,
    )

    gj_weight = RangeSlider(
        display_text='Boundary Border Thickness',
        name='gjWt',
        min=1,
        max=5,
        step=1,
        initial=2,
    )

    gj_fillcolor = SelectInput(display_text='Boundary Fill Color',
                               name='gjFlClr',
                               multiple=False,
                               original=True,
                               options=geojson_colors,
                               initial='rgb(0,0,0,0)')

    gj_fillopacity = RangeSlider(
        display_text='Boundary Fill Opacity',
        name='gjFlOp',
        min=0,
        max=1,
        step=.1,
        initial=.5,
    )

    context = {
        # data options
        'variables': variables,
        'regions': regions,

        # display options
        'colorscheme': colorscheme,
        'opacity': opacity,
        'gjClr': gj_color,
        'gjOp': gj_opacity,
        'gjWt': gj_weight,
        'gjFlClr': gj_fillcolor,
        'gjFlOp': gj_fillopacity,

        # metadata
        'thredds_url': App.get_custom_setting('thredds_url'),
    }

    return render(request, 'multidimensional_series_template/home.html',
                  context)