Example #1
0
def project_deficit_days_annual_csv(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    result = __get_deficit_days_comparison(project,
        lambda d, g, t: analysis.annual_deficit_pct(d, g), "Annual Average").mean()
    response = HttpResponse(content_type="text/csv")
    result.to_csv(response, index_label="Scenario", header=['Annual Average'])
    return response
def project_deficit_days_annual_csv(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    result = __get_deficit_days_comparison(
        project, lambda d, g, t: analysis.annual_deficit_pct(d, g),
        "Annual Average").mean()
    response = HttpResponse(content_type="text/csv")
    result.to_csv(response, index_label="Scenario", header=['Annual Average'])
    return response
Example #3
0
def plot_drought_temporal_deficit(scenario, quantile=0.1):
    flowdata = scenario.get_data()
    gap_attribute = scenario.get_gap_attribute_name()
    temporal_deficit = flow_analysis.annual_deficit_pct(flowdata[gap_attribute])
    plot = plot_drought_deficit(scenario, temporal_deficit, quantile)
    plot.y_range = Range1d(0, 1)
    plot._yaxis.formatter = NumeralTickFormatter(format="00%")
    plot.title = "Temporal deficit during drought"
    plot._yaxis.axis_label = "Temporal Deficit (% days)"
    return plot
Example #4
0
def plot_drought_temporal_deficit(scenario, quantile=0.1):
    flowdata = scenario.get_data()
    gap_attribute = scenario.get_gap_attribute_name()
    temporal_deficit = flow_analysis.annual_deficit_pct(
        flowdata[gap_attribute])
    plot = plot_drought_deficit(scenario, temporal_deficit, quantile)
    plot.y_range = Range1d(0, 1)
    plot._yaxis.formatter = NumeralTickFormatter(format="00%")
    plot.title = "Temporal deficit during drought"
    plot._yaxis.axis_label = "Temporal Deficit (% days)"
    return plot
Example #5
0
def project_deficit_days_csv(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    monthly_result = __get_deficit_days_comparison(project,
        lambda d, g, t: analysis.monthly_deficit_pct(d, g),
        "Month")
    annual_result = __get_deficit_days_comparison(project,
        lambda d, g, t: analysis.annual_deficit_pct(d, g), "Annual Average").mean()
    annual_result.name = "Annual Average"
    result = pd.concat([monthly_result, annual_result.to_frame().transpose()], axis=0)
    result.index.name = "Month"
    response = HttpResponse(content_type="text/csv")
    result.to_csv(response)
    return response
def project_deficit_days_csv(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    monthly_result = __get_deficit_days_comparison(
        project, lambda d, g, t: analysis.monthly_deficit_pct(d, g), "Month")
    annual_result = __get_deficit_days_comparison(
        project, lambda d, g, t: analysis.annual_deficit_pct(d, g),
        "Annual Average").mean()
    annual_result.name = "Annual Average"
    result = pd.concat(
        [monthly_result, annual_result.to_frame().transpose()], axis=0)
    result.index.name = "Month"
    response = HttpResponse(content_type="text/csv")
    result.to_csv(response)
    return response
Example #7
0
 def get_data(self, request, scenario_id):
     scenario = get_object_or_404(Scenario, pk=scenario_id)
     data = analysis.annual_deficit_pct(scenario.get_data(), scenario.get_gap_attribute_name())
     return data.reset_index()
Example #8
0
def plot_drought_temporal_deficit_mpl(scenario, quantile=0.1):
    flowdata = scenario.get_data()
    gap_attribute = scenario.get_gap_attribute_name()
    temporal_deficit = flow_analysis.annual_deficit_pct(flowdata[gap_attribute])
    return plot_drought_deficit_mpl(scenario, temporal_deficit, quantile)
Example #9
0
def plot_drought_temporal_deficit_mpl(scenario, quantile=0.1):
    flowdata = scenario.get_data()
    gap_attribute = scenario.get_gap_attribute_name()
    temporal_deficit = flow_analysis.annual_deficit_pct(
        flowdata[gap_attribute])
    return plot_drought_deficit_mpl(scenario, temporal_deficit, quantile)