USEPA / ElectricityLCI

Creative Commons Zero v1.0 Universal
24 stars 10 forks source link

No 2022 EIA transmission and distribution loss data #235

Open dt-woods opened 3 months ago

dt-woods commented 3 months ago

The state-based archive data used for T&D calculation comes from EIA (see here) and, as of writing, historical data are available up to 2021.

https://github.com/USEPA/ElectricityLCI/blob/2232c41f2cb4fd333ad59c8710aa55906e6a7ed3/electricitylci/eia_trans_dist_grid_loss.py#L100

The eia_gen_year modelconfig is used to pull the T&D loss data and is currently failing for 2022 baseline.

dt-woods commented 3 months ago

A possible work-around is to use 2021 T&D losses for 2022 by implementing a if-else for 2022 gen years found in get_distribution_mix_df:

https://github.com/USEPA/ElectricityLCI/blob/2232c41f2cb4fd333ad59c8710aa55906e6a7ed3/electricitylci/__init__.py#L521

dt-woods commented 3 months ago

I guess the problem isn't that 2022 data isn't available. The problem is that the archive URL now redirects rather than fails.

The 2022 URL is the url_b.

dt-woods commented 3 months ago

Implementing secondary check against requests' headers:

r = requests.get(url_a)
r_head = r.headers.get("Content-Type", "")
if not r.ok or r_head.startswith("text"):
    logging.info(f"Trying alternative site {STATE_ABBREV[key]}")
    r = requests.get(url_b)