AE Overview
Exploring the regional response to a warmer world
This notebook allows you to explore the regional response to a warmer world at a series of global warming levels (changes in global mean temperature relative to the historical baseline): 1.5˚, 2˚, 3˚, and 4˚C. Warming levels can be used to explore future possible trajectories of any climate variable of interest for a given increase in global mean temperature.
Because warming levels are defined based on amount of global mean temperature change, they can be used to compare possible outcomes across multiple scenarios or model simulations. Warming levels are often used in international policy discussions, such as the Paris Agreement to limit warming to 2˚C.
For a given warming level, we will then use this tool to:
- Examine the range of possibility in maps of regional changes across climate models
- Map day-of-year/time-of-day combinations with especially large increases in temperature, and overlay the locations of power plants to help identify vulnerable assets
Intended Application: As a user, I want to apply a global warming levels approach to understand the regional response:
- Visualize and compare the difference in the regional response across models at a selected warming level
- Extract model data at a warming level for my specific application needs
Step 0: Setup
Import libraries needed.
import climakitae as ck
from climakitae.explore import warming_levels
Step 1: Explore data
1a) Select data of interest
We recommend selecting the coarsest time-scale available (i.e., monthly) for the visualization, unless you plan to export the data at a higher time-resolution.
wl = warming_levels()
wl.choose_data()
1b) Retrieve and process the data
The calculate step may take a while to complete depending on whether you selected dynamical
(WRF) or statistical
(LOCA2) data for your analysis. Selecting statistical downscaling will take longer because there are more simulations to work with, and they are at the highest spatial resolution (~10-15min).
%%time
wl.calculate()
1c) Visualize the regional response at a series of global warming levels
Use the drop down menu to visualize when a specified global warming level in reached for a scenario of interest. Scenarios shown are Shared Socioeconomic Pathways (SSPs): ranging from low (SSP 1-1.9) to high (SSP 5-8.5) emissions trajectories. This step is optional if you want to directly extract the data.
To learn more about the data available on the Analytics Engine, see our data catalog.
wl.visualize()
If you want to extract the data from within the figure above, you can use the gwl_snapshots
function below. With this function, you can examine the data being plotted above and plot it in a different way, or save it out.
regional_response = wl.gwl_snapshots
1d) Extract slices of data centered on the selected warming level
data_at_warming_level = wl.sliced_data
Optional: Get a feel for how the data is stored, by looking at timeseries for a single grid cell. The 30-year slice is different for each simulation, with some that reach the warming level sooner or later that others.
if wl.wl_params.downscaling_method == ['Dynamical']:
out = data_at_warming_level.sel(warming_level="2.0").mean(['x','y']).squeeze().to_pandas()
else:
out = data_at_warming_level.sel(warming_level="2.0").mean(['lat','lon']).squeeze().to_pandas()
out.plot.line(legend=None,figsize=[13,2])
Step 2: Application
2a) Select data
Prepare a map of the changes for a day and time when the largest temperature increases are projected, and overlay the locations of California power plants and substations on the map to identify vulnerable assets.
We’ll start by retrieving some data, making sure that it is hourly time-resolution.
wl2 = warming_levels()
wl2.choose_data()
We provide some recommended options below, by focusing over the whole state of California. Then we will prepare and process the data by running the calculate()
function.
wl2.wl_params.downscaling_method=['Dynamical']
wl2.wl_params.timescale = 'hourly'
wl2.wl_params.resolution = '45 km'
wl2.wl_params.variable='Air Temperature at 2m'
wl2.wl_params.units='degF'
wl2.calculate()
Select a global warming level of interest. We default to 2°C here, but common options for representing global warming levels are: 1.5°C, 2°C, 3°C, and 4°C.
my_gwl = 2 # global warming level in degC
my_data = wl2.catalog_data
Here we select a particular day of the year and time of day to investigate:
one_day = my_data.isel(time=(my_data.time.dt.dayofyear == 216))
one_hour = one_day.isel(time=(one_day.time.dt.hour == 23))
from climakitae.explore.warming import get_sliced_data
from climakitae.util.utils import read_csv_file
from climakitae.core.paths import gwl_1981_2010_file
gwl_lookup = read_csv_file(gwl_1981_2010_file, index_col=[0, 1, 2])
to_plot = one_hour.groupby('all_sims').apply(get_sliced_data,years=gwl_lookup,window=wl2.wl_params.window)
And format the information to be plotted for a given warming level:
to_plot = to_plot.sel(warming_level=str(float(my_gwl)))
to_plot = to_plot.mean('time')
to_plot.name = 'degrees warmer'
Force the data to be computed and ready to plot. This may take a minute.
to_plot = ck.load(to_plot)
Next, we’ll load data that contains locations of power plants to visualize against the regional warming response.
import geopandas as gpd
# URLs to shapefiles for example point data from CEC (power plants and substations available)
URLs = {
'power_plants' : "https://opendata.arcgis.com/api/v3/datasets/4a702cd67be24ae7ab8173423a768e1b_0/downloads/data?format=geojson&spatialRefId=4326&where=1%3D1",
'substations' : "https://cecgis-caenergy.opendata.arcgis.com/datasets/CAEnergy::california-electric-substations.geojson?outSR=%7B%22latestWkid%22%3A3857%2C%22wkid%22%3A102100%7D"
}
# Download the desired data
power_plants = gpd.read_file(URLs['power_plants']).rename(columns = {'Lon_WGS84':'lon', 'Lat_WGS84':'lat'})
Finally, prepare the map, and display it with power plant locations overlaid.
import cartopy.crs as ccrs
from climakitae.util.utils import read_ae_colormap
cmap = read_ae_colormap(cmap='ae_diverging', cmap_hex=False)
gridded = to_plot.plot.pcolormesh(x='lon',y='lat', col='all_sims',
transform=ccrs.PlateCarree(),subplot_kws={'projection': ccrs.Orthographic(-100,40)},
figsize=[15,3],cmap=cmap)
for ax in gridded.axes.flat:
ax.coastlines()
ax.scatter(power_plants.geometry.x, power_plants.geometry.y, transform=ccrs.PlateCarree(),s=0.2,c='k')
Step 3: Export
To save data as a file, call export
and provide the following:
- data to export – an xarray DataArray or Dataset, as output by either the
gwl_snapshots()
orsliced_data()
functions on any warming levels object - output file name (without file extension)
- file format (“NetCDF” or “CSV”)
To learn more about the file format options, see getting_started.ipynb.
ck.export(regional_response, "my_filename", "NetCDF")