Пример #1
0
def get_data_rod_plot2(req_get, point_lon_lat):
    start_date = req_get['startDate']
    end_date = req_get['endDate']

    # 1st variable
    model1 = req_get['model']
    variable1 = req_get['variable']
    superstring1 = get_datarods_tsb()[model1]

    dr_link1 = str(superstring1.format(variable1, point_lon_lat.replace(',', ',%20'),
                                       start_date, end_date))

    data1 = get_data_from_nasa_server(dr_link1)

    # 2nd variable
    model2 = req_get['model2']
    variable2 = req_get['variable2']
    superstring2 = get_datarods_tsb()[model2]

    dr_link2 = str(superstring2.format(variable2, point_lon_lat.replace(',', ',%20'),
                                       start_date, end_date))
    data2 = get_data_from_nasa_server(dr_link2)
    # Create list
    dr_ts = [{'name': get_wms_vars()[model1][variable1][1] + ' (' + get_wms_vars()[model1][variable1][2] + ')',
              'data': data1,
              'code': str(variable1) + ' (' + get_wms_vars()[model1][variable1][2] + ')'},
             {'name': get_wms_vars()[model2][variable2][1] + ' (' + get_wms_vars()[model2][variable2][2] + ')',
              'data': data2,
              'code': str(variable2) + ' (' + get_wms_vars()[model2][variable2][2] + ')'}]

    datarods_urls_dict = generate_datarods_urls_dict([dr_link1, dr_link2])
    return dr_ts, datarods_urls_dict
Пример #2
0
def get_data_rod_years(req_post, point_lon_lat):
    variable = req_post['variable']
    model = req_post['model']
    superstring = get_datarods_tsb()[model]
    overlap_years = True if 'true' in req_post['overlap_years'] else False

    dr_ts = []
    dr_links = []
    for year in req_post['years'].split(','):
        if '-' in year:
            year_range = year.split('-')
            for yyyy in range(int(year_range[0]), int(year_range[1]) + 1):
                dr_link = superstring.format(variable, point_lon_lat.replace(',', ',%20'),
                                             '{0}-01-01T00'.format(yyyy),
                                             '{0}-12-31T23'.format(yyyy))
                data = get_data_from_nasa_server(dr_link, overlap_years)
                dr_ts.append({'name': yyyy,
                              'data': data})
                dr_links.append(dr_link)
        else:
            dr_link = str(superstring.format(variable, point_lon_lat.replace(',', ',%20'),
                                             '{0}-01-01T00'.format(year),
                                             '{0}-12-31T23'.format(year)))

            data = get_data_from_nasa_server(dr_link, overlap_years)
            dr_ts.append({'name': year,
                          'data': data})
            dr_links.append(dr_link)

    datarods_urls_dict = generate_datarods_urls_dict(dr_links)

    return dr_ts, datarods_urls_dict
Пример #3
0
def get_data_rod_years(req_post, point_lon_lat):
    variable = req_post['variable']
    model = req_post['model']
    superstring = get_datarods_tsb()[model]
    overlap_years = True if 'true' in req_post['overlap_years'] else False

    dr_ts = []
    dr_links = []
    for year in req_post['years'].split(','):
        if '-' in year:
            year_range = year.split('-')
            for yyyy in range(int(year_range[0]), int(year_range[1]) + 1):
                dr_link = superstring.format(
                    variable, point_lon_lat.replace(',', ',%20'),
                    '{0}-01-01T00'.format(yyyy), '{0}-12-31T23'.format(yyyy))
                data = get_data_from_nasa_server(dr_link, overlap_years)
                dr_ts.append({'name': yyyy, 'data': data})
                dr_links.append(dr_link)
        else:
            dr_link = str(
                superstring.format(variable,
                                   point_lon_lat.replace(',', ',%20'),
                                   '{0}-01-01T00'.format(year),
                                   '{0}-12-31T23'.format(year)))

            data = get_data_from_nasa_server(dr_link, overlap_years)
            dr_ts.append({'name': year, 'data': data})
            dr_links.append(dr_link)

    datarods_urls_dict = generate_datarods_urls_dict(dr_links)

    return dr_ts, datarods_urls_dict
Пример #4
0
def get_data_rod_plot2(req_get, point_lon_lat):
    start_date = req_get['startDate']
    end_date = req_get['endDate']

    # 1st variable
    model1 = req_get['model']
    variable1 = req_get['variable']
    superstring1 = get_datarods_tsb()[model1]

    dr_link1 = str(
        superstring1.format(variable1, point_lon_lat.replace(',', ',%20'),
                            start_date, end_date))

    data1 = get_data_from_nasa_server(dr_link1)

    # 2nd variable
    model2 = req_get['model2']
    variable2 = req_get['variable2']
    superstring2 = get_datarods_tsb()[model2]

    dr_link2 = str(
        superstring2.format(variable2, point_lon_lat.replace(',', ',%20'),
                            start_date, end_date))
    data2 = get_data_from_nasa_server(dr_link2)
    # Create list
    dr_ts = [{
        'name':
        get_wms_vars()[model1][variable1][1] + ' (' +
        get_wms_vars()[model1][variable1][2] + ')',
        'data':
        data1,
        'code':
        str(variable1) + ' (' + get_wms_vars()[model1][variable1][2] + ')'
    }, {
        'name':
        get_wms_vars()[model2][variable2][1] + ' (' +
        get_wms_vars()[model2][variable2][2] + ')',
        'data':
        data2,
        'code':
        str(variable2) + ' (' + get_wms_vars()[model2][variable2][2] + ')'
    }]

    datarods_urls_dict = generate_datarods_urls_dict([dr_link1, dr_link2])
    return dr_ts, datarods_urls_dict
Пример #5
0
def get_data_rod_plot(req_get, point_lon_lat):
    model = req_get['model']
    variable = req_get['variable']
    superstring = get_datarods_tsb()[model]

    dr_link = str(superstring.format(variable, point_lon_lat.replace(',', ',%20'),
                                     req_get['startDate'], req_get['endDate']))

    dr_ts = get_data_from_nasa_server(dr_link)

    datarods_urls_dict = generate_datarods_urls_dict([dr_link])

    return dr_ts, datarods_urls_dict
Пример #6
0
def get_data_rod_plot(req_get, point_lon_lat):
    model = req_get['model']
    variable = req_get['variable']
    superstring = get_datarods_tsb()[model]

    dr_link = str(
        superstring.format(variable, point_lon_lat.replace(',', ',%20'),
                           req_get['startDate'], req_get['endDate']))

    dr_ts = get_data_from_nasa_server(dr_link)

    datarods_urls_dict = generate_datarods_urls_dict([dr_link])

    return dr_ts, datarods_urls_dict
Пример #7
0
def home(request):
    """
    Controller for the app 'home' page.
    """

    init_model()

    model = get_model_options()[0][1]

    select_model = create_select_model(model)
    select_date, select_hour = create_map_date_ctrls(model)

    # Load map
    map_view, map_view_options = create_map()

    start_date1, end_date1, plot_button1 = create_plot_ctrls(model, 'plot')
    start_date2, end_date2, plot_button2 = create_plot_ctrls(model, 'plot2')
    select_model2 = SelectInput(display_text='',
                                name='model2',
                                multiple=False,
                                original=True,
                                options=get_model_options(),
                                attributes="onchange=oc_model2();"
                                )

    years_list = create_years_list(1979)
    select_years = SelectInput(display_text='',
                               name='years',
                               multiple=True,
                               original=False,
                               options=years_list,
                               attributes="onchange=oc_years();"
                               )

    plot_button3 = Button(display_text='Plot',
                          name='years',
                          style='',
                          icon='',
                          href='',
                          submit=False,
                          disabled=False,
                          attributes='onclick=createPlot(this.name);',
                          classes='btn-plot')

    # Context variables
    context = {
        'select_model': select_model,
        'MapView': map_view,
        'map_view_options': map_view_options,
        'select_date': select_date,
        'select_hour': select_hour,
        'MODEL_FENCES': dumps(get_model_fences()),
        'VAR_DICT': dumps(get_var_dict()),
        'DATARODS_PNG': dumps(get_datarods_png()),
        'DATARODS_TSB': dumps(get_datarods_tsb()),
        'WMS_VARS': dumps(get_wms_vars()),
        'start_date1': start_date1,
        'end_date1': end_date1,
        'plot_button1': plot_button1,
        'start_date2': start_date2,
        'end_date2': end_date2,
        'plot_button2': plot_button2,
        'select_model2': select_model2,
        'plot_button3': plot_button3,
        'select_years': select_years,
        # 'messages': [{
        #     'category': 'info',
        #     'text': 'Click on the map to define data query location.',
        #     'id': 'click-map'
        # }]
    }

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

    init_model()

    model = get_model_options()[0][1]

    select_model = create_select_model(model)
    select_date, select_hour = create_map_date_ctrls(model)

    # Load map
    map_view, map_view_options = create_map()

    start_date1, end_date1, plot_button1 = create_plot_ctrls(model, 'plot')
    start_date2, end_date2, plot_button2 = create_plot_ctrls(model, 'plot2')
    select_model2 = SelectInput(display_text='',
                                name='model2',
                                multiple=False,
                                original=True,
                                options=get_model_options(),
                                attributes="onchange=oc_model2();"
                                )

    years_list = create_years_list(1979)
    select_years = SelectInput(display_text='',
                               name='years',
                               multiple=True,
                               original=False,
                               options=years_list,
                               attributes="onchange=oc_years();"
                               )

    plot_button3 = Button(display_text='Plot',
                          name='years',
                          style='',
                          icon='',
                          href='',
                          submit=False,
                          disabled=False,
                          attributes='onclick=createPlot(this.name);',
                          classes='btn-plot')

    # Context variables
    context = {
        'select_model': select_model,
        'MapView': map_view,
        'map_view_options': map_view_options,
        'select_date': select_date,
        'select_hour': select_hour,
        'MODEL_FENCES': dumps(get_model_fences()),
        'VAR_DICT': dumps(get_var_dict()),
        'DATARODS_PNG': dumps(get_datarods_png()),
        'DATARODS_TSB': dumps(get_datarods_tsb()),
        'WMS_VARS': dumps(get_wms_vars()),
        'start_date1': start_date1,
        'end_date1': end_date1,
        'plot_button1': plot_button1,
        'start_date2': start_date2,
        'end_date2': end_date2,
        'plot_button2': plot_button2,
        'select_model2': select_model2,
        'plot_button3': plot_button3,
        'select_years': select_years
    }

    return render(request, 'data_rods_explorer/app_base_dre.html', context)