.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_other_models.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_other_models.py: ============================= Plot Other Models' output ============================= This example shows how to use cgeniepy to plot gridded data from other models (CESM and HadCM3 here). You can download them from https://zenodo.org/records/13786014. .. GENERATED FROM PYTHON SOURCE LINES 9-47 .. image-sg:: /auto_examples/images/sphx_glr_plot_other_models_001.png :alt: CESM LGM, HadCM3L LGM :srcset: /auto_examples/images/sphx_glr_plot_other_models_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none File CESM_LGM_var_regrid.nc already exists at /home/docs/.cgeniepy/CESM_LGM_var_regrid.nc. Skipping download. Downloading teitu_020_o.pgclann.nc to /home/docs/.cgeniepy/teitu_020_o.pgclann.nc... Download complete. | .. code-block:: Python from cgeniepy.array import GriddedData import xarray as xr import matplotlib.pyplot as plt import cartopy.crs as ccrs from cgeniepy.utils import download_zenodo_file # Define the Zenodo record and the files needed zenodo_record_id = "13786013" required_files = ["CESM_LGM_var_regrid.nc", "teitu_020_o.pgclann.nc"] # Download the files cesm_file_path = download_zenodo_file(zenodo_record_id, required_files[0]) hadcm3_file_path = download_zenodo_file(zenodo_record_id, required_files[1]) # Read in the data using the downloaded file paths cesm_lgm = xr.load_dataset(cesm_file_path) hadcm3_lgm = xr.load_dataset(hadcm3_file_path, decode_times=False) # Construct GriddedData objects cesm_temp = GriddedData(cesm_lgm['TEMP'], attrs=cesm_lgm['TEMP'].attrs) hadcm3_temp = GriddedData(hadcm3_lgm['temp_ym_dpth'], attrs=hadcm3_lgm['temp_ym_dpth'].attrs) # Create the plot fig, axs = plt.subplots(1, 2, figsize=(10, 5), subplot_kw={'projection': ccrs.Robinson()}) p = cesm_temp.isel(time=0, z_t=0).to_GriddedDataVis() p.aes_dict['pcolormesh_kwargs']['vmax'] = 30 p.plot(ax=axs[0], outline=True, colorbar=False) axs[0].set_title('CESM LGM') p2 = hadcm3_temp.isel(t=0, depth_1=0).to_GriddedDataVis() p2.aes_dict['pcolormesh_kwargs']['vmax'] = 30 im = p2.plot(ax=axs[1], outline=True, colorbar=False) axs[1].set_title('HadCM3L LGM') fig.colorbar(im, ax=axs, orientation='horizontal', label='Sea surface temperature (°C)', fraction=0.05, pad=0.07) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 9.974 seconds) .. _sphx_glr_download_auto_examples_plot_other_models.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_other_models.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_other_models.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_other_models.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_