Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 13, 2023
1 parent 715c890 commit 9c24337
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 19 deletions.
2 changes: 0 additions & 2 deletions carbonplan_forest_risks/load/cmip.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def cmip(
historical=False,
remove_nans=False,
):

with warnings.catch_warnings():
warnings.simplefilter('ignore', category=ResourceWarning)
warnings.simplefilter('ignore', category=FutureWarning)
Expand All @@ -50,7 +49,6 @@ def cmip(
if member is None:
member = members[model]


path = setup.loading(store)

prefix = f'cmip6/{method}/conus/4000m/{sampling}/{model}.{scenario}.{member}.zarr'
Expand Down
1 change: 0 additions & 1 deletion carbonplan_forest_risks/load/terraclim.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def terraclim(
group_repeats=False,
remove_nans=False,
):

with warnings.catch_warnings():
warnings.simplefilter('ignore', category=ResourceWarning)
warnings.simplefilter('ignore', category=FutureWarning)
Expand Down
2 changes: 1 addition & 1 deletion carbonplan_forest_risks/load/tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def impacts(
if met_data == 'cmip':
for scenario in scenarios:
impact_ds = xr.Dataset()
for (gcm, ensemble_member) in gcms:
for gcm, ensemble_member in gcms:
year_coords, impact_ds_list = [], []
for start_year, end_year in zip(start_years, end_years):
if start_year < 2005:
Expand Down
1 change: 0 additions & 1 deletion carbonplan_forest_risks/plot/fire.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ def full_eval(
comparison=True,
clabel=None,
):

a = data[data_var].mean("time").values.flatten()
b = model[model_var].mean("time").values.flatten()
inds = ~np.isnan(a) & ~np.isnan(b)
Expand Down
4 changes: 1 addition & 3 deletions carbonplan_forest_risks/plot/paper.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def ts_pretty(ax, impact, ylims):


def multipanel_ts(results_dict, region_bboxes, fig_path):

gcms = [
("MRI-ESM2-0", (0, 0)),
("MIROC-ES2L", (1, 0)),
Expand Down Expand Up @@ -149,7 +148,6 @@ def multipanel_ts(results_dict, region_bboxes, fig_path):


def plot_future_ts_traces(ax, ds, scenario, gcms):

scenario_colors = {
"ssp245": "#59A82F",
"ssp370": "#D8B525",
Expand All @@ -163,7 +161,7 @@ def plot_future_ts_traces(ax, ds, scenario, gcms):

ssp_rename = {"ssp245": "SSP2-4.5", "ssp370": "SSP3-7.0", "ssp585": "SSP5-8.5"}

for (gcm, location) in gcms:
for gcm, location in gcms:
ds.sel(gcm=gcm, scenario=scenario).plot(ax=ax, color=scenario_colors_light[scenario])

ds.sel(scenario=scenario).mean(dim="gcm").plot(
Expand Down
1 change: 0 additions & 1 deletion carbonplan_forest_risks/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def insects(df, eval_only=False, duration=10):
return x, meta

else:

fit_vars = [
'ppt_sum_min_1',
'tavg_mean_max_1',
Expand Down
2 changes: 1 addition & 1 deletion carbonplan_forest_risks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def weighted_mean(ds, *args, **kwargs):


def get_store(bucket, prefix, account_key=None):
''' helper function to create a zarr store'''
'''helper function to create a zarr store'''

if account_key is None:
account_key = os.environ.get('BLOB_ACCOUNT_KEY', None)
Expand Down
3 changes: 1 addition & 2 deletions notebooks/fire/fire_model_redux.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,8 @@
"source": [
"downscaling = \"quantile-mapping\"\n",
"sampling = \"monthly\"\n",
"for (model, member) in cmip_models:\n",
"for model, member in cmip_models:\n",
" for scenario in [\"historical\", \"ssp245\", \"ssp370\", \"ssp585\"]:\n",
"\n",
" prefix = f\"cmip6/{downscaling}/conus/4000m/{sampling}/{model}.{scenario}.{member}.zarr\".format()\n",
"\n",
" if store == \"az\":\n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/paper/Figure-2/Figure-2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
"## Fire\n",
"\n",
"for scenario in [\"ssp245\", \"ssp370\", \"ssp585\"]:\n",
" for (gcm, location) in gcms:\n",
" for gcm, location in gcms:\n",
" future_ts[\"fire\"].probability.sel(gcm=gcm, scenario=scenario).sel(\n",
" year=slice(\"1970\", \"2099\")\n",
" ).plot(ax=axarr[0], color=scenario_colors_light[scenario], alpha=1)\n",
Expand All @@ -303,7 +303,7 @@
" )\n",
"\n",
" for scenario in [\"ssp245\", \"ssp370\", \"ssp585\"]:\n",
" for (gcm, location) in gcms:\n",
" for gcm, location in gcms:\n",
" future_ts[impact].probability.sel(scenario=scenario, gcm=gcm).sel(\n",
" year=slice(1970, 2099)\n",
" ).plot(\n",
Expand Down
8 changes: 4 additions & 4 deletions scripts/article_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def build_climate_cube(
all_scenarios = []
for scenario in scenarios:
all_gcms = []
for (gcm, ensemble_member) in gcms:
for gcm, ensemble_member in gcms:
cmip = load.cmip(
store='az',
model=gcm,
Expand Down Expand Up @@ -106,7 +106,7 @@ def repackage_drought_insects(ds):
scenarios = ['ssp245', 'ssp370', 'ssp585']

all_gcms = []
for (gcm, ensemble_member) in gcms:
for gcm, ensemble_member in gcms:
all_gcms.append(
ds[['{}-{}'.format(gcm, scenario) for scenario in scenarios]]
.to_array(dim='scenario', name='probability')
Expand All @@ -129,7 +129,7 @@ def timeseries_dict(ds, time_period='historical'):

mean = []
gcm_dict = {}
for (gcm, ensemble_member) in gcms:
for gcm, ensemble_member in gcms:
gcm_dict[gcm] = []
if time_period == 'historical':
years = np.arange(1980, 2020, 10)
Expand All @@ -144,7 +144,7 @@ def timeseries_dict(ds, time_period='historical'):
}
)
# then populate all the gcms
for (gcm, ensemble_member) in gcms:
for gcm, ensemble_member in gcms:
gcm_dict[gcm].append({'y': year, 'r': ds.sel(gcm=gcm, year=year).values.item()})
return mean, gcm_dict

Expand Down
2 changes: 1 addition & 1 deletion scripts/fire.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
('MPI-ESM1-2-LR', 'r10i1p1f1'),
]
scenarios = ['ssp245', 'ssp370', 'ssp585']
for (cmip_model, member) in cmip_models:
for cmip_model, member in cmip_models:
for scenario in tqdm(scenarios):
results = []
climate = load.cmip(
Expand Down

0 comments on commit 9c24337

Please sign in to comment.