.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/formats/GINI_Water_Vapor.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_examples_formats_GINI_Water_Vapor.py: ======================== GINI Water Vapor Imagery ======================== Use MetPy's support for GINI files to read in a water vapor satellite image and plot the data using CartoPy. .. GENERATED FROM PYTHON SOURCE LINES 12-19 .. code-block:: default import cartopy.feature as cfeature import matplotlib.pyplot as plt import xarray as xr from metpy.cbook import get_test_data from metpy.plots import add_metpy_logo, add_timestamp, colortables .. GENERATED FROM PYTHON SOURCE LINES 20-25 .. code-block:: default # Use Xarray together with MetPy's GINI backend to directly open the file from the test data ds = xr.open_dataset(get_test_data('WEST-CONUS_4km_WV_20151208_2200.gini', as_file_obj=False)) print(ds) .. rst-class:: sphx-glr-script-out .. code-block:: none Dimensions: (y: 1280, x: 1100) Coordinates: * x (x) float64 -4.226e+06 -4.222e+06 ... 2.357e+05 2.397e+05 * y (y) float64 4.365e+06 4.36e+06 ... -8.286e+05 -8.327e+05 lon (y, x) float64 ... lat (y, x) float64 ... time datetime64[ns] ... Data variables: projection int64 ... WV (y, x) float32 ... Attributes: satellite: GOES-15 sector: West CONUS .. GENERATED FROM PYTHON SOURCE LINES 26-28 Pull out the data and (x, y) coordinates. We use `metpy.parse_cf` to handle parsing some netCDF Climate and Forecasting (CF) metadata to simplify working with projections. .. GENERATED FROM PYTHON SOURCE LINES 28-32 .. code-block:: default x = ds.variables['x'][:] y = ds.variables['y'][:] dat = ds.metpy.parse_cf('WV') .. GENERATED FROM PYTHON SOURCE LINES 33-35 Plot the image. We use MetPy's xarray/cartopy integration to automatically handle parsing the projection information. .. GENERATED FROM PYTHON SOURCE LINES 35-46 .. code-block:: default fig = plt.figure(figsize=(10, 12)) add_metpy_logo(fig, 125, 145) ax = fig.add_subplot(1, 1, 1, projection=dat.metpy.cartopy_crs) wv_norm, wv_cmap = colortables.get_with_range('WVCIMSS', 100, 260) wv_cmap.set_under('k') im = ax.imshow(dat[:], cmap=wv_cmap, norm=wv_norm, extent=(x.min(), x.max(), y.min(), y.max()), origin='upper') ax.add_feature(cfeature.COASTLINE.with_scale('50m')) add_timestamp(ax, ds.time.dt, y=0.02, high_contrast=True) plt.show() .. image-sg:: /examples/formats/images/sphx_glr_GINI_Water_Vapor_001.png :alt: GINI Water Vapor :srcset: /examples/formats/images/sphx_glr_GINI_Water_Vapor_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.902 seconds) .. _sphx_glr_download_examples_formats_GINI_Water_Vapor.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: GINI_Water_Vapor.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: GINI_Water_Vapor.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_