From 6017d34373949834f4eb065ac42858cd710acfac Mon Sep 17 00:00:00 2001 From: romainsacchi Date: Thu, 7 Sep 2023 08:40:11 +0000 Subject: [PATCH] Black reformating --- premise/data_collection.py | 14 +++++--------- premise/fuels.py | 14 ++++++++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/premise/data_collection.py b/premise/data_collection.py index d3635c86..64d34a1b 100644 --- a/premise/data_collection.py +++ b/premise/data_collection.py @@ -593,17 +593,16 @@ def __init__( self.fertilizer_use = ( fertilizer / crops_production.sel( - variables=fertilizer.coords["variables"].values, - region=fertilizer.coords["region"].values, - year=fertilizer.coords["year"].values, - ) + variables=fertilizer.coords["variables"].values, + region=fertilizer.coords["region"].values, + year=fertilizer.coords["year"].values, + ) ) * np.where(crops_production > 0, 1, np.nan) self.fertilizer_use /= self.fertilizer_use.sel(year=2020) self.fertilizer_use = self.fertilizer_use.interpolate_na( dim="year", method="linear", fill_value="extrapolate" ) - self.trsp_cars = get_vehicle_fleet_composition(self.model, vehicle_type="car") self.trsp_trucks = get_vehicle_fleet_composition( self.model, vehicle_type="truck" @@ -807,8 +806,6 @@ def __fetch_market_data( .sum(dim="variables") ) - - # back-fill nans market_data = market_data.bfill(dim="year") # fill NaNs with zeros @@ -1081,8 +1078,7 @@ def __get_iam_production_volumes( if available_vars: data_to_return = data.loc[ - :, [v for v in flatten(input_vars.values()) - if v in available_vars], : + :, [v for v in flatten(input_vars.values()) if v in available_vars], : ] else: diff --git a/premise/fuels.py b/premise/fuels.py index 3989d3e2..15d580ad 100644 --- a/premise/fuels.py +++ b/premise/fuels.py @@ -1788,10 +1788,16 @@ def should_adjust_land_use_change_emissions( ) def adjust_fertilizer_use(self, dataset: dict, crop_type: str) -> dict: - - scaling_factor = self.iam_data.fertilizer_use.sel( - region=dataset["location"] if dataset["location"] in self.regions else self.ecoinvent_to_iam_loc[dataset["location"]], variables=crop_type - ).interp(year=self.year).values.item(0) + scaling_factor = ( + self.iam_data.fertilizer_use.sel( + region=dataset["location"] + if dataset["location"] in self.regions + else self.ecoinvent_to_iam_loc[dataset["location"]], + variables=crop_type, + ) + .interp(year=self.year) + .values.item(0) + ) if np.isnan(scaling_factor): scaling_factor = 1.0