Exemplo n.º 1
0
def param_rdb_download(request):
    form = DataParamForm(request.GET)
    if form.is_valid():
        _logger.info(
            "requested data download for %s with params %s"
            % (form.cleaned_data["site_list"], form.cleaned_data["params"])
        )

        beginDate = form.cleaned_data["timeseries_start"]
        endDate = form.cleaned_data["timeseries_end"]
        gage = form.cleaned_data["site_list"]
        p = form.cleaned_data["params"][0]

        station_list = stage_queries.station_list([gage])
        pt = Plottable(station_list[0], p, beginDate, endDate)
        data_seq = pt.sequence()

        # fifth parameter to create_metadata_header is list of Station objects
        station_list = stage_queries.station_list([gage])
        query_metadata_list = create_metadata_header(
            GENERAL_MESSAGE, EDEN_CONTACT, END_OF_HEADER, form.cleaned_data, station_list, water_level=False
        )

        response = HttpResponse(content_type="text/csv")
        stage_data.write_rdb(data_seq, response, metadata=query_metadata_list)

        return response
    else:
        return HttpResponseBadRequest(",".join(form.errors))
Exemplo n.º 2
0
def plot_image_simple(request):
    form = DataParamForm(request.GET)

    if form.is_valid():
        beginDate = form.cleaned_data["timeseries_start"]
        endDate = form.cleaned_data["timeseries_end"]
        gage = form.cleaned_data['site_list']
        p = form.cleaned_data['params'][0]
        fmt = request.GET.get('format', 'png')

        response = _plot_simple(gage, p, beginDate=beginDate, endDate=endDate, format=fmt, show_logo=decide_logo(request))

        return response
    else:
        return HttpResponseBadRequest(",".join(form.errors))
Exemplo n.º 3
0
def plot_image_simple(request):
    form = DataParamForm(request.GET)

    if form.is_valid():
        beginDate = form.cleaned_data["timeseries_start"]
        endDate = form.cleaned_data["timeseries_end"]
        gage = form.cleaned_data["site_list"]
        p = form.cleaned_data["params"][0]
        format = request.GET["format"] or "png"

        response = _plot_simple(
            gage, p, beginDate=beginDate, endDate=endDate, format=format, show_logo=decide_logo(request)
        )

        return response
    else:
        return HttpResponseBadRequest(",".join(form.errors))
Exemplo n.º 4
0
def param_data_download(request):

    form = DataParamForm(request.GET)
    if form.is_valid():
        _logger.info("requested plot data for %s with params %s" % (form.cleaned_data['site_list'], form.cleaned_data['params']))

        beginDate = form.cleaned_data["timeseries_start"]
        endDate = form.cleaned_data["timeseries_end"]
        gage = form.cleaned_data['site_list']
        p = form.cleaned_data['params'][0]

        station_list = stage_queries.station_list([gage])
        pt = Plottable(station_list[0], p, beginDate, endDate)

        data_seq = pt.sequence()

        response = HttpResponse(content_type='text/csv')
        stage_data.write_csv(data_seq, response)

        return response
    else:
        return HttpResponseBadRequest(",".join(form.errors))
Exemplo n.º 5
0
def param_data_download(request):

    form = DataParamForm(request.GET)
    if form.is_valid():
        _logger.info(
            "requested plot data for %s with params %s" % (form.cleaned_data["site_list"], form.cleaned_data["params"])
        )

        beginDate = form.cleaned_data["timeseries_start"]
        endDate = form.cleaned_data["timeseries_end"]
        gage = form.cleaned_data["site_list"]
        p = form.cleaned_data["params"][0]

        station_list = stage_queries.station_list([gage])
        pt = Plottable(station_list[0], p, beginDate, endDate)

        data_seq = pt.sequence()

        response = HttpResponse(content_type="text/csv")
        stage_data.write_csv(data_seq, response)

        return response
    else:
        return HttpResponseBadRequest(",".join(form.errors))
Exemplo n.º 6
0
def param_rdb_download(request):
    form = DataParamForm(request.GET)
    if form.is_valid():
        _logger.info("requested data download for %s with params %s" % (form.cleaned_data['site_list'], form.cleaned_data['params']))

        beginDate = form.cleaned_data["timeseries_start"]
        endDate = form.cleaned_data["timeseries_end"]
        gage = form.cleaned_data['site_list']
        p = form.cleaned_data['params'][0]

        station_list = stage_queries.station_list([gage])
        pt = Plottable(station_list[0], p, beginDate, endDate)
        data_seq = pt.sequence()

        # fifth parameter to create_metadata_header is list of Station objects
        station_list = stage_queries.station_list([gage])
        query_metadata_list = create_metadata_header(GENERAL_MESSAGE, EDEN_CONTACT, END_OF_HEADER, form.cleaned_data, station_list, water_level=False)

        response = HttpResponse(content_type='text/csv')
        stage_data.write_rdb(data_seq, response, metadata=query_metadata_list)

        return response
    else:
        return HttpResponseBadRequest(",".join(form.errors))