.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_data_on_model.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_data_on_model.py: ========================================= Add observational data on model output ========================================= .. GENERATED FROM PYTHON SOURCE LINES 7-41 .. image-sg:: /auto_examples/images/sphx_glr_plot_data_on_model_001.png :alt: plot data on model :srcset: /auto_examples/images/sphx_glr_plot_data_on_model_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/cgeniepy/envs/stable/lib/python3.12/site-packages/cgeniepy/model.py:58: UserWarning: No gemflag is provided, use default gemflags: [biogem] warnings.warn("No gemflag is provided, use default gemflags: [biogem]") /home/docs/checkouts/readthedocs.org/user_builds/cgeniepy/envs/stable/lib/python3.12/site-packages/cgeniepy/plot.py:632: UserWarning: kind is not used for map plotting warnings.warn("kind is not used for map plotting") | .. code-block:: Python import cgeniepy from cgeniepy.table import ScatterData import numpy as np import pandas as pd import matplotlib.pyplot as plt import cartopy.crs as ccrs ## prepare model data, replace sample model with your own model model = cgeniepy.sample_model() sst = model.get_var("ocn_sur_temp").isel(time=-1) # Generate fake "observational" data np.random.seed(319) # Set seed for reproducibility # Create random latitude, longitude, and variable values random_data = pd.DataFrame({ 'lat': np.random.uniform(-90, 90, 100), # Random latitudes between -90 and 90 'lon': np.random.uniform(-180, 180, 100), # Random longitudes between -180 and 180 'temp': np.random.random(100) * 30 # Random variable values between 0 and 30 }) random_data = ScatterData(random_data) random_data.set_index(['lat', 'lon']) ## start plotting fig, ax = plt.subplots(subplot_kw={'projection': ccrs.PlateCarree()}) sst.plot(ax=ax,vmin=0, vmax=35, colorbar=True, outline=True) random_data.plot(var='temp', edgecolor='k', ax=ax, vmin=0, vmax=35, gridline=False, colorbar=False, land_mask=False) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.257 seconds) .. _sphx_glr_download_auto_examples_plot_data_on_model.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_data_on_model.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_data_on_model.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_data_on_model.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_