PyOptik


NamePyOptik JSON
Version 1.9.9.5 PyPI version JSON
download
home_pageNone
SummaryA package for refractive index values.
upload_time2024-12-10 14:28:25
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License Copyright (c) 2020 Martin de Sivry Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords refracive index optics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
|logo|

.. list-table::
   :widths: 10 25 25
   :header-rows: 0

   * - Meta
     - |python|
     - |docs|
   * - Testing
     - |ci/cd|
     - |coverage|
   * - PyPi
     - |PyPi|
     - |PyPi_download|
   * - Anaconda
     - |anaconda|
     - |anaconda_download|


PyOptik
=======

PyOptik is a Python tool designed to import refractive indexes and extinction coefficients for various materials across different wavelengths. The data provided by PyOptik can be used in numerous applications, including simulating light interactions with particles. All data is sourced from the reputable RefractiveIndex.INFO database.



Features
********

- **Comprehensive Database Access**: Seamlessly import refractive index and extinction coefficient data for a wide range of materials.
- **Simulation Ready**: Ideal for light-matter interaction simulations, particularly in optics and photonics.
- **Simple API**: Easy-to-use API that integrates well with other Python libraries.
- **Open Source**: Fully open-source.

Installation
************

To install PyOptik, simply use `pip` or `conda`:

.. code:: bash

   pip install PyOptik                               (using PyPi package manager)

   conda install --channels martinpdes pyoptik       (using anaconda environment manager)

Building the Material Library
*****************************

PyOptik allows you to build and customize a local material library, importing material data from various categories. You can download the following categories of materials from the RefractiveIndex.INFO database:

- `classics`: Commonly used optical materials.
- `glasses`: Various types of glass materials.
- `metals`: Different metal materials for optical simulations.
- `organics`: Organic materials with optical properties.
- `others`: Other optical materials.
- `all`: Download all available categories at once.

To build a material library, use the `build_library` function. This will download and save the material data to your local machine.

**Example: Building the Material Library:**

In this example, we will download the `others` category of materials and remove any previously existing data in that category:

.. code:: python

   from PyOptik import MaterialBank

   # Download the 'classics' category and remove previous files
   MaterialBank.build_library('classics', remove_previous=True)

**Available Categories:**

To download materials from another category, simply pass the category name as an argument to `build_library`. For example:

.. code:: python

   # Download materials from the 'glasses' category
   MaterialBank.build_library('glasses')

To download all material categories at once:

.. code:: python

   # Download all available material categories
   MaterialBank.build_library('all')

You can also set the `remove_previous` parameter to `True` to remove old data before downloading new material data.

Viewing Available Materials
***************************

Once you have built the material library, you can view all the available materials using the `MaterialBank` class. This will print a list of materials stored in your local library.

**Example:**

.. code:: python

   from PyOptik import MaterialBank

   # Print the available materials in a tabulated format
   MaterialBank.print_materials()

Simple Usage
************

After installing PyOptik and building the material library, you can easily access material properties:

.. code:: python

   from PyOptik import MaterialBank

   # Access the refractive index of BK7 glass
   bk7 = MaterialBank.BK7
   n = bk7.compute_refractive_index(0.55e-6)
   print(f"Refractive index at 0.55 µm: {n}")

Example
*******

Here is a quick example demonstrating how to use PyOptik to retrieve and plot the refractive index of a material:

.. code:: python

   import numpy as np
   from PyOptik import MaterialBank

   # Define wavelength range
   wavelengths = np.linspace(0.3e-6, 2.5e-6, 100)

   # Retrieve refractive index for BK7 glass
   bk7 = MaterialBank.BK7
   n_values = bk7.compute_refractive_index(wavelengths)

   # Plot the results
   bk7.plot()

This code produces the following figure: |example_bk7|

Adding and Removing Custom Materials
************************************

You can add a custom material to your library by providing a URL from `refractiveindex.info <https://refractiveindex.info>`_.

**Adding a Custom Material:**

.. code:: python

   from PyOptik import MaterialBank, MaterialType

   # Define the URL of the YAML file and the destination
   # Call the function to download the file
   MaterialBank.add_material_to_bank(
      filename='example_download',
      material_type=MaterialType.SELLMEIER,
      url='https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml'
   )

   MaterialBank.print_available()

**Removing a Material:**

You can also remove a material from the library as follows:

.. code:: python

   from PyOptik.utils import remove_element

   MaterialBank.remove_item(filename='example_download')

Testing
*******

To test locally after cloning the GitHub repository, install the dependencies and run the tests:

.. code:: bash

   git clone https://github.com/MartinPdeS/PyOptik.git
   cd PyOptik
   pip install .
   pytest

Contributing
************

PyOptik is open to contributions. Whether you're fixing bugs, adding new features, or improving documentation, your help is welcome! Please feel free to fork the repository and submit pull requests.

Contact Information
*******************

As of 2024, PyOptik is still under development. If you would like to collaborate, it would be a pleasure to hear from you. Contact me at:

**Author**: `Martin Poinsinet de Sivry-Houle <https://github.com/MartinPdS>`_

**Email**: `martin.poinsinet.de.sivry@gmail.com <mailto:martin.poinsinet.de.sivry@gmail.com?subject=PyOptik>`_

.. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg
   :alt: Python
   :target: https://www.python.org/

.. |logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png
   :alt: PyOptik logo

.. |example_bk7| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/example_bk7.png
   :alt: PyOptik example: BK7
   :target: https://github.com/MartinPdeS/PyOptik/blob/master/docs/images/example_bk7.png

.. |docs| image:: https://github.com/martinpdes/pyoptik/actions/workflows/deploy_documentation.yml/badge.svg
   :target: https://martinpdes.github.io/PyOptik/
   :alt: Documentation Status

.. |ci/cd| image:: https://github.com/martinpdes/pyoptik/actions/workflows/deploy_coverage.yml/badge.svg
   :target: https://martinpdes.github.io/PyOptik/actions
   :alt: Unittest Status

.. |PyPi| image:: https://badge.fury.io/py/pyoptik.svg
   :alt: PyPi version
   :target: https://badge.fury.io/py/pyoptik

.. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyoptik.svg
   :alt: PyPi version
   :target: https://pypistats.org/packages/pyoptik

.. |anaconda_download| image:: https://anaconda.org/martinpdes/pyoptik/badges/downloads.svg
   :alt: Anaconda downloads
   :target: https://anaconda.org/martinpdes/pyoptik

.. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/PyOptik/python-coverage-comment-action-data/badge.svg
   :alt: Unittest coverage
   :target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/PyOptik/blob/python-coverage-comment-action-data/htmlcov/index.html

.. |anaconda| image:: https://anaconda.org/martinpdes/pyoptik/badges/version.svg
   :alt: Anaconda version
   :target: https://anaconda.org/martinpdes/pyoptik

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "PyOptik",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "refracive index, optics",
    "author": null,
    "author_email": "Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/12/f9/0429680e7802e0533d7db83dea593a2ff5a44fe8586134778ed35c779e26/pyoptik-1.9.9.5.tar.gz",
    "platform": null,
    "description": "\n|logo|\n\n.. list-table::\n   :widths: 10 25 25\n   :header-rows: 0\n\n   * - Meta\n     - |python|\n     - |docs|\n   * - Testing\n     - |ci/cd|\n     - |coverage|\n   * - PyPi\n     - |PyPi|\n     - |PyPi_download|\n   * - Anaconda\n     - |anaconda|\n     - |anaconda_download|\n\n\nPyOptik\n=======\n\nPyOptik is a Python tool designed to import refractive indexes and extinction coefficients for various materials across different wavelengths. The data provided by PyOptik can be used in numerous applications, including simulating light interactions with particles. All data is sourced from the reputable RefractiveIndex.INFO database.\n\n\n\nFeatures\n********\n\n- **Comprehensive Database Access**: Seamlessly import refractive index and extinction coefficient data for a wide range of materials.\n- **Simulation Ready**: Ideal for light-matter interaction simulations, particularly in optics and photonics.\n- **Simple API**: Easy-to-use API that integrates well with other Python libraries.\n- **Open Source**: Fully open-source.\n\nInstallation\n************\n\nTo install PyOptik, simply use `pip` or `conda`:\n\n.. code:: bash\n\n   pip install PyOptik                               (using PyPi package manager)\n\n   conda install --channels martinpdes pyoptik       (using anaconda environment manager)\n\nBuilding the Material Library\n*****************************\n\nPyOptik allows you to build and customize a local material library, importing material data from various categories. You can download the following categories of materials from the RefractiveIndex.INFO database:\n\n- `classics`: Commonly used optical materials.\n- `glasses`: Various types of glass materials.\n- `metals`: Different metal materials for optical simulations.\n- `organics`: Organic materials with optical properties.\n- `others`: Other optical materials.\n- `all`: Download all available categories at once.\n\nTo build a material library, use the `build_library` function. This will download and save the material data to your local machine.\n\n**Example: Building the Material Library:**\n\nIn this example, we will download the `others` category of materials and remove any previously existing data in that category:\n\n.. code:: python\n\n   from PyOptik import MaterialBank\n\n   # Download the 'classics' category and remove previous files\n   MaterialBank.build_library('classics', remove_previous=True)\n\n**Available Categories:**\n\nTo download materials from another category, simply pass the category name as an argument to `build_library`. For example:\n\n.. code:: python\n\n   # Download materials from the 'glasses' category\n   MaterialBank.build_library('glasses')\n\nTo download all material categories at once:\n\n.. code:: python\n\n   # Download all available material categories\n   MaterialBank.build_library('all')\n\nYou can also set the `remove_previous` parameter to `True` to remove old data before downloading new material data.\n\nViewing Available Materials\n***************************\n\nOnce you have built the material library, you can view all the available materials using the `MaterialBank` class. This will print a list of materials stored in your local library.\n\n**Example:**\n\n.. code:: python\n\n   from PyOptik import MaterialBank\n\n   # Print the available materials in a tabulated format\n   MaterialBank.print_materials()\n\nSimple Usage\n************\n\nAfter installing PyOptik and building the material library, you can easily access material properties:\n\n.. code:: python\n\n   from PyOptik import MaterialBank\n\n   # Access the refractive index of BK7 glass\n   bk7 = MaterialBank.BK7\n   n = bk7.compute_refractive_index(0.55e-6)\n   print(f\"Refractive index at 0.55 \u00b5m: {n}\")\n\nExample\n*******\n\nHere is a quick example demonstrating how to use PyOptik to retrieve and plot the refractive index of a material:\n\n.. code:: python\n\n   import numpy as np\n   from PyOptik import MaterialBank\n\n   # Define wavelength range\n   wavelengths = np.linspace(0.3e-6, 2.5e-6, 100)\n\n   # Retrieve refractive index for BK7 glass\n   bk7 = MaterialBank.BK7\n   n_values = bk7.compute_refractive_index(wavelengths)\n\n   # Plot the results\n   bk7.plot()\n\nThis code produces the following figure: |example_bk7|\n\nAdding and Removing Custom Materials\n************************************\n\nYou can add a custom material to your library by providing a URL from `refractiveindex.info <https://refractiveindex.info>`_.\n\n**Adding a Custom Material:**\n\n.. code:: python\n\n   from PyOptik import MaterialBank, MaterialType\n\n   # Define the URL of the YAML file and the destination\n   # Call the function to download the file\n   MaterialBank.add_material_to_bank(\n      filename='example_download',\n      material_type=MaterialType.SELLMEIER,\n      url='https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml'\n   )\n\n   MaterialBank.print_available()\n\n**Removing a Material:**\n\nYou can also remove a material from the library as follows:\n\n.. code:: python\n\n   from PyOptik.utils import remove_element\n\n   MaterialBank.remove_item(filename='example_download')\n\nTesting\n*******\n\nTo test locally after cloning the GitHub repository, install the dependencies and run the tests:\n\n.. code:: bash\n\n   git clone https://github.com/MartinPdeS/PyOptik.git\n   cd PyOptik\n   pip install .\n   pytest\n\nContributing\n************\n\nPyOptik is open to contributions. Whether you're fixing bugs, adding new features, or improving documentation, your help is welcome! Please feel free to fork the repository and submit pull requests.\n\nContact Information\n*******************\n\nAs of 2024, PyOptik is still under development. If you would like to collaborate, it would be a pleasure to hear from you. Contact me at:\n\n**Author**: `Martin Poinsinet de Sivry-Houle <https://github.com/MartinPdS>`_\n\n**Email**: `martin.poinsinet.de.sivry@gmail.com <mailto:martin.poinsinet.de.sivry@gmail.com?subject=PyOptik>`_\n\n.. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg\n   :alt: Python\n   :target: https://www.python.org/\n\n.. |logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png\n   :alt: PyOptik logo\n\n.. |example_bk7| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/example_bk7.png\n   :alt: PyOptik example: BK7\n   :target: https://github.com/MartinPdeS/PyOptik/blob/master/docs/images/example_bk7.png\n\n.. |docs| image:: https://github.com/martinpdes/pyoptik/actions/workflows/deploy_documentation.yml/badge.svg\n   :target: https://martinpdes.github.io/PyOptik/\n   :alt: Documentation Status\n\n.. |ci/cd| image:: https://github.com/martinpdes/pyoptik/actions/workflows/deploy_coverage.yml/badge.svg\n   :target: https://martinpdes.github.io/PyOptik/actions\n   :alt: Unittest Status\n\n.. |PyPi| image:: https://badge.fury.io/py/pyoptik.svg\n   :alt: PyPi version\n   :target: https://badge.fury.io/py/pyoptik\n\n.. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyoptik.svg\n   :alt: PyPi version\n   :target: https://pypistats.org/packages/pyoptik\n\n.. |anaconda_download| image:: https://anaconda.org/martinpdes/pyoptik/badges/downloads.svg\n   :alt: Anaconda downloads\n   :target: https://anaconda.org/martinpdes/pyoptik\n\n.. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/PyOptik/python-coverage-comment-action-data/badge.svg\n   :alt: Unittest coverage\n   :target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/PyOptik/blob/python-coverage-comment-action-data/htmlcov/index.html\n\n.. |anaconda| image:: https://anaconda.org/martinpdes/pyoptik/badges/version.svg\n   :alt: Anaconda version\n   :target: https://anaconda.org/martinpdes/pyoptik\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2020 Martin de Sivry  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A package for refractive index values.",
    "version": "1.9.9.5",
    "project_urls": null,
    "split_keywords": [
        "refracive index",
        " optics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c1b034ada034a3a34ddeb65600390ba561c210a6984a1b6107cdbe53566493c3",
                "md5": "6638fb0b8f7e32df502872a9672c8f7f",
                "sha256": "7d6698a2672d4e1bdcedac9a2974054eeeb865ac432d5c750aa4289bc60c75bb"
            },
            "downloads": -1,
            "filename": "PyOptik-1.9.9.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6638fb0b8f7e32df502872a9672c8f7f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 47151,
            "upload_time": "2024-12-10T14:28:22",
            "upload_time_iso_8601": "2024-12-10T14:28:22.621224Z",
            "url": "https://files.pythonhosted.org/packages/c1/b0/34ada034a3a34ddeb65600390ba561c210a6984a1b6107cdbe53566493c3/PyOptik-1.9.9.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "12f90429680e7802e0533d7db83dea593a2ff5a44fe8586134778ed35c779e26",
                "md5": "20c66aa291aa877233975ae087479ca7",
                "sha256": "f3e245703f0dd0ce289e87f8324b1ab0660c3d8a3c0e9cac77621eea6035c944"
            },
            "downloads": -1,
            "filename": "pyoptik-1.9.9.5.tar.gz",
            "has_sig": false,
            "md5_digest": "20c66aa291aa877233975ae087479ca7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 543172,
            "upload_time": "2024-12-10T14:28:25",
            "upload_time_iso_8601": "2024-12-10T14:28:25.294993Z",
            "url": "https://files.pythonhosted.org/packages/12/f9/0429680e7802e0533d7db83dea593a2ff5a44fe8586134778ed35c779e26/pyoptik-1.9.9.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-10 14:28:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pyoptik"
}
        
Elapsed time: 0.53289s