Validation of FERC Form 1 Fuel Data

This notebook runs sanity checks on the FERC Form 1 fuel table (fuel_ferc1). These are the same tests which are run by the fuel_ferc1 validation tests by PyTest. The notebook and visualizations are meant to be used as a diagnostic tool, to help understand what's wrong when the PyTest based data validations fail for some reason.


In [ ]:
%load_ext autoreload
%autoreload 2

In [ ]:
import sys
import pandas as pd
import sqlalchemy as sa
import pudl
import pudl.validate as pv

In [ ]:
import warnings
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
handler = logging.StreamHandler(stream=sys.stdout)
formatter = logging.Formatter('%(message)s')
handler.setFormatter(formatter)
logger.handlers = [handler]

In [ ]:
import matplotlib.pyplot as plt
import matplotlib as mpl
%matplotlib inline

In [ ]:
plt.style.use('ggplot')
mpl.rcParams['figure.figsize'] = (10,4)
mpl.rcParams['figure.dpi'] = 150
pd.options.display.max_columns = 56

In [ ]:
pudl_settings = pudl.workspace.setup.get_defaults()
ferc1_engine = sa.create_engine(pudl_settings['ferc1_db'])
pudl_engine = sa.create_engine(pudl_settings['pudl_db'])
pudl_settings

Pull fuel_ferc1 and calculate some useful values

First we pull the original (post-ETL) FERC 1 fuel data out of the PUDL database using an output object. The FERC Form 1 data only exists at annual resolution, so there's no inter-frequency aggregation to think about.


In [ ]:
pudl_out = pudl.output.pudltabl.PudlTabl(pudl_engine)
fuel_ferc1 = pudl_out.fuel_ferc1()

Validating Historical Distributions

As a sanity check of the testing process itself, we can check to see whether the entire historical distribution has attributes that place it within the extremes of a historical subsampling of the distribution. In this case, we sample each historical year, and look at the range of values taken on by some quantile, and see whether the same quantile for the whole of the dataset fits within that range

Columns to Validate

  • fuel_cost_per_mmbtu (by fuel, coal, oil, or gas)
  • fuel_cost_per_unit (by fuel, coal, oil, or gas)
  • fuel_mmbtu_per_unit (by fuel, coal, oil, or gas)

Other Quantities to validate..

  • Does cost per unit burned X units burned == total cost?
  • MMBTU per unit X units burned == total MMBTU?

In [ ]:
pudl.validate.plot_vs_self(fuel_ferc1, pv.fuel_ferc1_self)

Validation Against Fixed Bounds

Some of the variables reported in this table have a fixed range of reasonable values, like the heat content per unit of a given fuel type. These varaibles can be tested for validity against external standards directly. In general we have two kinds of tests in this section:

  • Tails: are the exteme values too extreme? Typically, this is at the 5% and 95% level, but depending on the distribution, sometimes other thresholds are used.
  • Middle: Is the central value of the distribution where it should be?

Fuel Heat Content


In [ ]:
pudl.validate.plot_vs_bounds(fuel_ferc1, pv.fuel_ferc1_coal_mmbtu_per_unit_bounds)
pudl.validate.plot_vs_bounds(fuel_ferc1, pv.fuel_ferc1_oil_mmbtu_per_unit_bounds)
pudl.validate.plot_vs_bounds(fuel_ferc1, pv.fuel_ferc1_gas_mmbtu_per_unit_bounds)

Fuel Cost per MMBTU


In [ ]:
pudl.validate.plot_vs_bounds(fuel_ferc1, pv.fuel_ferc1_coal_cost_per_mmbtu_bounds)
pudl.validate.plot_vs_bounds(fuel_ferc1, pv.fuel_ferc1_oil_cost_per_mmbtu_bounds)
pudl.validate.plot_vs_bounds(fuel_ferc1, pv.fuel_ferc1_gas_cost_per_mmbtu_bounds)

Fuel Cost per Unit


In [ ]:
pudl.validate.plot_vs_bounds(fuel_ferc1, pv.fuel_ferc1_coal_cost_per_unit_bounds)
pudl.validate.plot_vs_bounds(fuel_ferc1, pv.fuel_ferc1_oil_cost_per_unit_bounds)
pudl.validate.plot_vs_bounds(fuel_ferc1, pv.fuel_ferc1_gas_cost_per_unit_bounds)