Skip to content

Commit

Permalink
remove only robustness
Browse files Browse the repository at this point in the history
  • Loading branch information
juliettelavoie committed Feb 6, 2024
1 parent 0902b32 commit 180ce5a
Showing 1 changed file with 82 additions and 82 deletions.
164 changes: 82 additions & 82 deletions docs/notebooks/figanos_multiplots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,45 +127,45 @@
"metadata": {},
"outputs": [],
"source": [
"from xclim import ensembles\n",
"urls = ['https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/ouranos/portraits-clim-1.1/NorESM1-M_rcp85_prcptot_monthly.nc',\n",
" 'https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/ouranos/portraits-clim-1.1/MPI-ESM-LR_rcp85_prcptot_monthly.nc',\n",
" 'https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/ouranos/portraits-clim-1.1/IPSL-CM5B-LR_rcp85_prcptot_monthly.nc',\n",
" ]\n",
"ens = ensembles.create_ensemble(urls)\n",
"s8=[]\n",
"i5=[]\n",
"for horizon in [[\\\"2020\\\", \\\"2050\\\"],['2050','2080']]:\n",
" fut = ens.sel(time=slice(*map(str, horizon))).prcptot\n",
" ref = ens.sel(time=slice(\\\"1990\\\", \\\"2020\\\")).prcptot\n",
" chng_f= ensembles.robustness_fractions(\n",
" fut, ref, test=\\\"threshold\\\", abs_thresh=2\n",
" )\n",
" s8.append(chng_f.where(chng_f.changed>0.8).assign_coords(horizon=horizon).changed)\n",
" i5.append(chng_f.where(chng_f.changed<0.5).assign_coords(horizon=horizon).changed)\n",
"sup_8=xr.concat(s8, dim='horizon')\n",
"inf_5=xr.concat(i5, dim='horizon') \n",
"# from xclim import ensembles\n",
"# urls = ['https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/ouranos/portraits-clim-1.1/NorESM1-M_rcp85_prcptot_monthly.nc',\n",
"# 'https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/ouranos/portraits-clim-1.1/MPI-ESM-LR_rcp85_prcptot_monthly.nc',\n",
"# 'https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/ouranos/portraits-clim-1.1/IPSL-CM5B-LR_rcp85_prcptot_monthly.nc',\n",
"# ]\n",
"# ens = ensembles.create_ensemble(urls)\n",
"# s8=[]\n",
"# i5=[]\n",
"# for horizon in [[\"2020\", \"2050\"],['2050','2080']]:\n",
"# fut = ens.sel(time=slice(*map(str, horizon))).prcptot\n",
"# ref = ens.sel(time=slice(\"1990\", \"2020\")).prcptot\n",
"# chng_f= ensembles.robustness_fractions(\n",
"# fut, ref, test=\"threshold\", abs_thresh=2\n",
"# )\n",
"# s8.append(chng_f.where(chng_f.changed>0.8).assign_coords(horizon=horizon).changed)\n",
"# i5.append(chng_f.where(chng_f.changed<0.5).assign_coords(horizon=horizon).changed)\n",
"# sup_8=xr.concat(s8, dim='horizon')\n",
"# inf_5=xr.concat(i5, dim='horizon') \n",
"\n",
"im = fg.hatchmap({'sup_8': sup_8, 'inf_5': inf_5},\n",
" plot_kw={\n",
" 'sup_8': {\n",
" 'hatches': '*',\n",
" 'col': 'horizon',\n",
" \"x\": \"lon\",\n",
" \"y\": \"lat\"\n",
" },\n",
" 'inf_5': {\n",
" 'hatches': 'x',\n",
" 'col': 'horizon',\n",
" \"x\": \"lon\",\n",
" \"y\": \"lat\"\n",
" },\n",
" },\n",
" features = ['coastline','ocean'],\n",
" frame = True,\n",
" legend_kw = {'title': 'Ensemble change'})\n",
"# im = fg.hatchmap({'sup_8': sup_8, 'inf_5': inf_5},\n",
"# plot_kw={\n",
"# 'sup_8': {\n",
"# 'hatches': '*',\n",
"# 'col': 'horizon',\n",
"# \"x\": \"lon\",\n",
"# \"y\": \"lat\"\n",
"# },\n",
"# 'inf_5': {\n",
"# 'hatches': 'x',\n",
"# 'col': 'horizon',\n",
"# \"x\": \"lon\",\n",
"# \"y\": \"lat\"\n",
"# },\n",
"# },\n",
"# features = ['coastline','ocean'],\n",
"# frame = True,\n",
"# legend_kw = {'title': 'Ensemble change'})\n",
"\n",
"im.fig.suptitle(\"Multiple hatchmaps\", y=1.08)\n"
"# im.fig.suptitle(\"Multiple hatchmaps\", y=1.08)\n"
]
},
{
Expand Down Expand Up @@ -258,26 +258,26 @@
"metadata": {},
"outputs": [],
"source": [
"# #Selecting a time and slicing our starting Dataset\n",
"# ds_space = opened[['tx_max_p50']].isel(time=[0, 1, 2]).sel(lat=slice(40,65), lon=slice(-90,-55))\n",
"#Selecting a time and slicing our starting Dataset\n",
"ds_space = opened[['tx_max_p50']].isel(time=[0, 1, 2]).sel(lat=slice(40,65), lon=slice(-90,-55))\n",
"\n",
"# im = fg.gridmap(ds_space,\n",
"# projection = ccrs.LambertConformal(),\n",
"# plot_kw = {\"col\": \"time\",\n",
"# \"col_wrap\": 2},\n",
"# features = ['coastline','ocean'],\n",
"# frame = False,\n",
"# use_attrs={\"suptitle\": \"long_name\"},\n",
"# fig_kw = {\"figsize\": (6, 6)}\n",
"# )\n",
"# for i, fax in enumerate(im.axs.flat):\n",
"# fax.set_extent([\n",
"# ds_space.lon.min().item(),\n",
"# ds_space.lon.max().item(),\n",
"# ds_space.lat.min().item(),\n",
"# ds_space.lat.max().item(),\n",
"# ]\n",
"# )\n"
"im = fg.gridmap(ds_space,\n",
" projection = ccrs.LambertConformal(),\n",
" plot_kw = {\"col\": \"time\",\n",
" \"col_wrap\": 2},\n",
" features = ['coastline','ocean'],\n",
" frame = False,\n",
" use_attrs={\"suptitle\": \"long_name\"},\n",
" fig_kw = {\"figsize\": (6, 6)}\n",
" )\n",
"for i, fax in enumerate(im.axs.flat):\n",
" fax.set_extent([\n",
" ds_space.lon.min().item(),\n",
" ds_space.lon.max().item(),\n",
" ds_space.lat.min().item(),\n",
" ds_space.lat.max().item(),\n",
" ]\n",
" )\n"
]
},
{
Expand All @@ -293,34 +293,34 @@
"metadata": {},
"outputs": [],
"source": [
"# import numpy as np\n",
"# op = opened.isel(time=[0, 1])\n",
"# data = xr.DataArray(\n",
"# data=np.array([op.tx_max_p10.values, op.tx_max_p50.values, op.tx_max_p90.values]),\n",
"# dims=['percentile', 'time', 'lat', 'lon'],\n",
"# coords={'percentile': [10, 50, 90], 'time': op.time.values, 'lat': op.lat.values, 'lon': op.lon.values},\n",
"# attrs = {'units': 'degC', 'standard_name': 'air_temperature', 'long_name': 'Near-Surface Daily Maximum Air Temperature'}\n",
"# )\n",
"import numpy as np\n",
"op = opened.isel(time=[0, 1])\n",
"data = xr.DataArray(\n",
" data=np.array([op.tx_max_p10.values, op.tx_max_p50.values, op.tx_max_p90.values]),\n",
" dims=['percentile', 'time', 'lat', 'lon'],\n",
" coords={'percentile': [10, 50, 90], 'time': op.time.values, 'lat': op.lat.values, 'lon': op.lon.values},\n",
" attrs = {'units': 'degC', 'standard_name': 'air_temperature', 'long_name': 'Near-Surface Daily Maximum Air Temperature'}\n",
" )\n",
"\n",
"# im = fg.gridmap(data,\n",
"# projection = ccrs.LambertConformal(),\n",
"# plot_kw = {\"col\": \"time\",\n",
"# \"row\": \"percentile\",\n",
"# },\n",
"# features = ['coastline','ocean'],\n",
"# frame = False,\n",
"# use_attrs = {\"suptitle\": \"long_name\"},\n",
"# fig_kw = {\"figsize\": (8, 7)},\n",
"# )\n",
"im = fg.gridmap(data,\n",
" projection = ccrs.LambertConformal(),\n",
" plot_kw = {\"col\": \"time\",\n",
" \"row\": \"percentile\",\n",
" },\n",
" features = ['coastline','ocean'],\n",
" frame = False,\n",
" use_attrs = {\"suptitle\": \"long_name\"},\n",
" fig_kw = {\"figsize\": (8, 7)},\n",
" )\n",
"\n",
"# # modify xlabels positions (hardcoded in xarray.plot)\n",
"# for i, fax in enumerate(im.axs.flat):\n",
"# for txt in fax.texts:\n",
"# if len(txt.get_text()) > 0:\n",
"# txt.set_x(-1.2)\n",
"# txt.set_text('percentile ' + txt.get_text())\n",
"# txt.set_rotation('vertical')\n",
"# # txt.set_visible(False)\n",
"# modify xlabels positions (hardcoded in xarray.plot)\n",
"for i, fax in enumerate(im.axs.flat):\n",
" for txt in fax.texts:\n",
" if len(txt.get_text()) > 0:\n",
" txt.set_x(-1.2)\n",
" txt.set_text('percentile ' + txt.get_text())\n",
" txt.set_rotation('vertical')\n",
" # txt.set_visible(False)\n",
"\n"
]
}
Expand Down

0 comments on commit 180ce5a

Please sign in to comment.