diff --git a/carbonplan_forest_risks/load/cmip.py b/carbonplan_forest_risks/load/cmip.py index d7dfb85..6970fd7 100644 --- a/carbonplan_forest_risks/load/cmip.py +++ b/carbonplan_forest_risks/load/cmip.py @@ -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) @@ -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' diff --git a/carbonplan_forest_risks/load/terraclim.py b/carbonplan_forest_risks/load/terraclim.py index e15d557..7a8cf15 100644 --- a/carbonplan_forest_risks/load/terraclim.py +++ b/carbonplan_forest_risks/load/terraclim.py @@ -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) diff --git a/carbonplan_forest_risks/load/tiff.py b/carbonplan_forest_risks/load/tiff.py index 745f8ba..3ed5b0c 100644 --- a/carbonplan_forest_risks/load/tiff.py +++ b/carbonplan_forest_risks/load/tiff.py @@ -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: diff --git a/carbonplan_forest_risks/plot/fire.py b/carbonplan_forest_risks/plot/fire.py index 009911c..cbd1e7d 100644 --- a/carbonplan_forest_risks/plot/fire.py +++ b/carbonplan_forest_risks/plot/fire.py @@ -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) diff --git a/carbonplan_forest_risks/plot/paper.py b/carbonplan_forest_risks/plot/paper.py index e372430..cd8aac9 100644 --- a/carbonplan_forest_risks/plot/paper.py +++ b/carbonplan_forest_risks/plot/paper.py @@ -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)), @@ -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", @@ -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( diff --git a/carbonplan_forest_risks/prepare.py b/carbonplan_forest_risks/prepare.py index dbee1c0..51da24c 100644 --- a/carbonplan_forest_risks/prepare.py +++ b/carbonplan_forest_risks/prepare.py @@ -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', diff --git a/carbonplan_forest_risks/utils.py b/carbonplan_forest_risks/utils.py index 42d687d..15b0788 100644 --- a/carbonplan_forest_risks/utils.py +++ b/carbonplan_forest_risks/utils.py @@ -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) diff --git a/notebooks/fire/fire_model_redux.ipynb b/notebooks/fire/fire_model_redux.ipynb index b5d7852..5afebe4 100644 --- a/notebooks/fire/fire_model_redux.ipynb +++ b/notebooks/fire/fire_model_redux.ipynb @@ -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", diff --git a/notebooks/paper/Figure-2/Figure-2.ipynb b/notebooks/paper/Figure-2/Figure-2.ipynb index 27d2431..30488ca 100644 --- a/notebooks/paper/Figure-2/Figure-2.ipynb +++ b/notebooks/paper/Figure-2/Figure-2.ipynb @@ -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", @@ -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", diff --git a/scripts/article_prep.py b/scripts/article_prep.py index 98149b6..5018774 100644 --- a/scripts/article_prep.py +++ b/scripts/article_prep.py @@ -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, @@ -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') @@ -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) @@ -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 diff --git a/scripts/fire.py b/scripts/fire.py index 657bbb0..aeeff27 100644 --- a/scripts/fire.py +++ b/scripts/fire.py @@ -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(