Exemplo n.º 1
0
 def data_function(self, crop_mix, data, groups):
     if not groups:
         raise Http404("Crop groups are required.")
     revenue = data.get_derived_table("Revenue", groups)
     cpi_data = econ.models.ConsumerPriceIndexData.as_dataframe()
     revenue_adjusted = waterkit.econ.analysis.adjust_cpi(
         revenue,
         get_bls_key(),
         crop_mix.cpi_adjustment_year,
         cpi_data
     )
     self.ylabel = str(crop_mix.cpi_adjustment_year) + " $"
     return revenue_adjusted
 def _plot_crop_mix(self, crop_mix):
     crop_mix, data, years, commodities = read_crop_mix(crop_mix.id)
     groups = [g.as_cropgroup() for g in crop_mix.cropmixgroup_set.all()]
     if groups:
         revenue_table = data.get_derived_table("Revenue", groups)
         revenue_table_cpi = econ_analysis.adjust_cpi(
             revenue_table, get_bls_key(), crop_mix.cpi_adjustment_year,
             ConsumerPriceIndexData.as_dataframe())
         niwr_table = data.get_derived_table("NIWR", groups)
         labor_table = data.get_derived_table("Labor", groups)
         revenue_af_plot = econ.plots.plot_revenue_af_table(
             revenue_table_cpi, niwr_table)
         labor_plot = econ.plots.plot_labor_table(labor_table)
         return self.EconPlots(crop_mix.name, revenue_af_plot, labor_plot)
     else:
         # Just do the best we can with what we have and return only the
         # acreages.
         acre_plot = econ.plots.plot_acres(data, groups)
         acre_fraction_plot = econ.plots.plot_acre_fractions(data, groups)
         return self.EconPlots(crop_mix.name, acre_plot, acre_fraction_plot)
Exemplo n.º 3
0
 def _plot_crop_mix(self, crop_mix):
     crop_mix, data, years, commodities = read_crop_mix(crop_mix.id)
     groups = [g.as_cropgroup() for g in crop_mix.cropmixgroup_set.all()]
     if groups:
         revenue_table = data.get_derived_table("Revenue", groups)
         revenue_table_cpi = econ_analysis.adjust_cpi(
             revenue_table,
             get_bls_key(),
             crop_mix.cpi_adjustment_year,
             ConsumerPriceIndexData.as_dataframe()
         )
         niwr_table = data.get_derived_table("NIWR", groups)
         labor_table = data.get_derived_table("Labor", groups)
         revenue_af_plot = econ.plots.plot_revenue_af_table(revenue_table_cpi, niwr_table)
         labor_plot = econ.plots.plot_labor_table(labor_table)
         return self.EconPlots(crop_mix.name, revenue_af_plot, labor_plot)
     else:
         # Just do the best we can with what we have and return only the
         # acreages.
         acre_plot = econ.plots.plot_acres(data, groups)
         acre_fraction_plot = econ.plots.plot_acre_fractions(data, groups)
         return self.EconPlots(crop_mix.name, acre_plot, acre_fraction_plot)