.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/catalog/plot_catalog_search.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_gallery_catalog_plot_catalog_search.py: Search materials and inspect provenance ======================================= Find locally available BK7 datasets, inspect their canonical identities, and compare representative glass pages at a standard wavelength. .. GENERATED FROM PYTHON SOURCE LINES 10-23 .. code-block:: Python import matplotlib.pyplot as plt from TypedUnit import ureg from PyOptik import MaterialCatalog catalog = MaterialCatalog.from_snapshot() matches = catalog.search("BK7", shelf="specs", available=True) print(f"Found {len(matches)} cached BK7 pages") for page in matches[:5]: print(page.id.key, "—", page.description) .. rst-class:: sphx-glr-script-out .. code-block:: none Found 10 cached BK7 pages specs/Cargille/BK7_matching_liquid — BK7 matching liquid specs/HIKARI-optical/E-BK7 — E-BK7 specs/HIKARI-optical/J-BK7 — J-BK7 specs/HIKARI-optical/J-BK7A — J-BK7A specs/SCHOTT-optical/BK7G18 — BK7G18 .. GENERATED FROM PYTHON SOURCE LINES 24-25 Canonical IDs make source selection explicit and reproducible. .. GENERATED FROM PYTHON SOURCE LINES 25-39 .. code-block:: Python identifiers = [ "specs/SCHOTT-optical/N-BK7", "specs/OHARA-optical/S-BSL7", ] wavelength = 587.6 * ureg.nanometer labels, indices = [], [] for identifier in identifiers: page = catalog.get(identifier) material = page.load() labels.append(page.id.page) indices.append(float(material.n(wavelength, out_of_range="raise"))) print(material.provenance) .. rst-class:: sphx-glr-script-out .. code-block:: none {'name': 'N-BK7', 'file_path': '/home/runner/.local/share/PyOptik/rii/specs/schott/optical/N-BK7.yml', 'reference': 'SCHOTT Zemax catalog 2017-01-20b\n(obtained from http://www.schott.com)
\nSee also SCHOTT glass data sheets\n', 'conditions': {'temperature': 293}, 'comments': 'step 0.5 available\n', 'wavelength_range': , 'catalog_id': 'specs/SCHOTT-optical/N-BK7', 'source_url': 'https://refractiveindex.info/database/data/specs/schott/optical/N-BK7.yml'} {'name': 'S-BSL7', 'file_path': '/home/runner/.local/share/PyOptik/rii/specs/ohara/optical/S-BSL7.yml', 'reference': 'OHARA Zemax catalog 2017-11-30 (obtained from http://www.ohara-inc.co.jp)
See also OHARA glass data sheets\n', 'conditions': {'temperature': 298}, 'comments': 'Recommended \n', 'wavelength_range': , 'catalog_id': 'specs/OHARA-optical/S-BSL7', 'source_url': 'https://refractiveindex.info/database/data/specs/ohara/optical/S-BSL7.yml'} .. GENERATED FROM PYTHON SOURCE LINES 40-49 .. code-block:: Python figure, axis = plt.subplots(figsize=(6, 3.5), layout="constrained") axis.bar(labels, indices, color=["tab:blue", "tab:orange"]) axis.set( ylabel="Refractive index at 587.6 nm", title="Catalog-backed glass comparison", ylim=(1.50, 1.54), ) axis.grid(axis="y", alpha=0.25) plt.show() .. image-sg:: /gallery/catalog/images/sphx_glr_plot_catalog_search_001.png :alt: Catalog-backed glass comparison :srcset: /gallery/catalog/images/sphx_glr_plot_catalog_search_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.327 seconds) .. _sphx_glr_download_gallery_catalog_plot_catalog_search.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_catalog_search.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_catalog_search.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_