Ejemplo n.º 1
0
 def get_data(self, request, scenario_id):
     scenario = get_object_or_404(Scenario, pk=scenario_id)
     data = analysis.monthly_volume_deficit_pct(
         scenario.get_data(),
         scenario.get_gap_attribute_name(),
         scenario.get_target_attribute_name(),
         analysis.CFS_TO_AFD
     )
     return data.reset_index()
def project_deficit_stats_pct_plot(request, project_id):
    return __dataframe_barplot_helper(
        request,
        project_id,
        "Average monthly volume deficit relative to target",
        lambda d, g, t: analysis.monthly_volume_deficit_pct(
            d, g, t, CFS_TO_AFD).mean().abs(),
        "%",
        formatter=FuncFormatter(to_percent),
        ylim=[0.0, 1.0])
def project_deficit_stats_pct_csv(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    monthly_result = __get_deficit_stats_comparison(
        project, lambda d, g, t: analysis.monthly_volume_deficit_pct(
            d, g, t, CFS_TO_AFD).mean().abs(), "%")
    annual_result = __get_deficit_stats_comparison(
        project, lambda d, g, t: analysis.annual_volume_deficit_pct(
            d, g, t, CFS_TO_AFD), "%").mean().abs()
    annual_result.name = "Annual Average"
    response = HttpResponse(content_type="text/csv")
    result = pd.concat(
        [monthly_result, annual_result.to_frame().transpose()], axis=0)
    result.to_csv(response)
    return response
Ejemplo n.º 4
0
def project_deficit_stats_pct_csv(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    monthly_result = __get_deficit_stats_comparison(
        project,
        lambda d, g, t: analysis.monthly_volume_deficit_pct(d, g, t, CFS_TO_AFD).mean().abs(),
        "%")
    annual_result = __get_deficit_stats_comparison(
        project,
        lambda d, g, t: analysis.annual_volume_deficit_pct(d, g, t, CFS_TO_AFD),
        "%").mean().abs()
    annual_result.name = "Annual Average"
    response = HttpResponse(content_type="text/csv")
    result = pd.concat([monthly_result, annual_result.to_frame().transpose()], axis=0)
    result.to_csv(response)
    return response
Ejemplo n.º 5
0
def project_deficit_stats_pct_plot(request, project_id):
    return __dataframe_barplot_helper(request, project_id,
        "Average monthly volume deficit relative to target",
        lambda d, g, t: analysis.monthly_volume_deficit_pct(d, g, t, CFS_TO_AFD).mean().abs(),
        "%", formatter=FuncFormatter(to_percent), ylim=[0.0, 1.0])