Skip to content

Commit

Permalink
make luc_sectors explicit and allow Gridder to be instatiated with them
Browse files Browse the repository at this point in the history
  • Loading branch information
gidden committed Aug 21, 2023
1 parent 9c69460 commit 17f3641
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/aneris/downscaling/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(
hist: DataFrame,
year: int,
region_mapping: Series,
luc_sectors: Sequence[str] = [],
index: Sequence[str] = DEFAULT_INDEX,
method_choice: Optional[callable] = None,
return_type=DataFrame,
Expand Down Expand Up @@ -80,6 +81,7 @@ def __init__(
self.intensity_method = None
self.luc_method = None
self.method_choice = None
self.luc_sectors = luc_sectors

@property
def index(self):
Expand Down Expand Up @@ -207,6 +209,7 @@ def methods(self, method_choice=None, overwrites=None):
"fallback_method": self.fallback_method,
"intensity_method": self.intensity_method,
"luc_method": self.luc_method,
"luc_sectors": self.luc_sectors,
}

hist_agg = (
Expand Down
6 changes: 4 additions & 2 deletions src/aneris/downscaling/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def simple_proxy(
proxy_name: str,
) -> DataFrame:
"""
Downscales emission data using the shares in a proxy scenario
Downscales emission data using the shares in a proxy scenario.
Parameters
----------
Expand Down Expand Up @@ -161,18 +161,20 @@ def default_method_choice(
fallback_method="proxy_gdp",
intensity_method="ipat_2100_gdp",
luc_method="base_year_pattern",
luc_sectors=None,
):
"""
Default downscaling decision tree.
"""
luc_sectors = luc_sectors or ("Agriculture", "LULUCF")

# special cases
if traj.h == 0:
return fallback_method
if traj.zero_m:
return fallback_method

if traj.get("sector", None) in ("Agriculture", "LULUCF"):
if traj.get("sector", None) in luc_sectors:
return luc_method

return intensity_method

0 comments on commit 17f3641

Please sign in to comment.