Name | pix2py JSON |
Version |
1.0.0
JSON |
| download |
home_page | None |
Summary | A python package to plot pixelmaps generated by Domino. |
upload_time | 2024-03-20 15:51:58 |
maintainer | None |
docs_url | None |
author | Philip Hartmeier |
requires_python | <4.0,>=3.10 |
license | GPL-3.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pix2py
[](https://github.com/Philipsite/pix2py/actions/workflows/CI.yml)
[](https://pypi.python.org/pypi/pix2py)
[](https://pypi.python.org/pypi/pix2py/)
A python package to plot pixelmaps generated by [Theriak-Domino](https://github.com/Theriak-Domino) using [matplotlib](https://matplotlib.org/).
[](https://doi.org/10.5281/zenodo.10844777)
The pix2py package is registered on Zenodo. If you use pix2py to generate pixelmaps for your research, please cite it. This DOI will resolve to the latest version of pix2py.
## Installation
The latest version of pix2py can be installed using pip:
```bash
pip install pix2py
```
## Quickstart
In your Python script or notebook you must first import ```PixelMap``` from ```pix2py```.
```python
from pix2py import PixelMap
```
To use pix2py, you need to have a pixelmap folder called ```_pixelmaps``` generated by [Domino](https://github.com/Theriak-Domino) in your working directory. Or you can specify the path to the pixelmap folder:
```python
from pathlib import Path
pixelmap_dir = Path("{INSERT PATH HERE}", "_pixelmaps")
```
Since the individual pixelmaps for solid solution phases are named after the dominant endmember, you need to provide a dictionary to map a phase name to all endmember names for that phase in the thermodynamic database used to generate the pixelmaps.\
This dictionary has the general form:
```ENDMEMBER_DICT = {"phase_name": "endmember1, endmember2, ...", ...}```. Create a local dictionary for the project by:
```python
LOCAL_ENDMEMBER_DICT = {}
LOCAL_ENDMEMBER_DICT["biotite"] = "phl", "annm", "obi", "east", "tbi", "fbi", "mnbi"
```
Additonal phases can be added to the dictionary as needed:
```python
LOCAL_ENDMEMBER_DICT["LIQtc6"] = "q4L", "abL", "kspL", "anL", "slL", "fo2L", "fa2L", "h2oL"
```
Next, set up a pixelmap object by passing the path to the pixelmap folder and the endmember dictionary.
```python
pixmap = PixelMap(pixelmap_dir, LOCAL_ENDMEMBER_DICT)
```
To plot a pixelmap, use the ```plot_pixelmap``` method of the pixelmap object. The method takes a variable to plot (```variable```) the phase name (```mineral```) as input arguments and returns a matplotlib figure object and ax object.
```python
pixmap.plot_pixelmap("vol", mineral="LIQtc6")
```
 volume fraction")
To plot isolines, use the ```plot_isolines``` method of the pixelmap object. The method takes a variable to plot (```variable```) and the phase name (```mineral```) as input arguments and returns a matplotlib figure object and ax object.
```python
pixmap.plot_isolines("vol", mineral="LIQtc6")
```
 volume fraction")
### Customising the plots
If you want to customise the plots, you can pass additional arguments to the ```plot_pixelmap``` and ```plot_isolines``` methods. For example, you can set the colormap, the number of contour levels, and the contour levels to plot.
To change the colormap, pass the name of the colormap to the ```colormap``` argument. The default colormap is "viridis". You can use any of the [colormaps](https://matplotlib.org/stable/users/explain/colors/colormaps.html) available in matplotlib.
```python
pixmap.plot_pixelmap("vol", mineral="LIQtc6", colormap="plasma")
```
If you plot isolines, you can set the number of contour levels or specify the contour levels to plot using the ```isolines``` argument. The default number of isolines is 5. Pass an integer to the ```isolines``` argument to set the number of contour levels.
```python
pixmap.plot_isolines("vol", mineral="LIQtc6", isolines=10)
```
You can also explicitly set the contour levels to plot by passing a list of values to the ```isolines``` argument.
```python
pixmap.plot_isolines("vol", mineral="LIQtc6", isolines=[0.1, 0.2, 0.3, 0.4, 0.5])
```
### Save the pixelmap
Capture the figure and ax objects to save or further customise the plotted pixelmap.
```python
fig, ax = pixmap.plot_pixelmap("vol", mineral="LIQtc6")
fig.savefig("LIQtc6_vol.png", dpi=300)
```
You can use matplotlib's functions to further customise the plotted pixelmap.
```python
fig, ax = pixmap.plot_pixelmap("vol", mineral="LIQtc6")
ax.set_title("LIQtc6 Volume Fraction")
```
### Full Example
```python
from pix2py import PixelMap
from pathlib import Path
pixelmap_dir = Path("{path_to_pixelmap_folder}", "_pixelmaps")
LOCAL_ENDMEMBER_DICT = {}
LOCAL_ENDMEMBER_DICT["biotite"] = "phl", "annm", "obi", "east", "tbi", "fbi", "mnbi"
pixmap = PixelMap(pixelmap_dir, LOCAL_ENDMEMBER_DICT)
fig, ax = pixmap.plot_pixelmap("#Mg", mineral="biotite")
fig.savefig("Biotite_Mg.png", dpi=300)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "pix2py",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Philip Hartmeier",
"author_email": "philip.hartmeier@hotmail.com",
"download_url": "https://files.pythonhosted.org/packages/23/50/b3fccfa8beca8734cbd2da0f4eabf2798faca4db303fa6bd36f851126475/pix2py-1.0.0.tar.gz",
"platform": null,
"description": "# pix2py\n\n[](https://github.com/Philipsite/pix2py/actions/workflows/CI.yml)\n[](https://pypi.python.org/pypi/pix2py)\n[](https://pypi.python.org/pypi/pix2py/)\n\nA python package to plot pixelmaps generated by [Theriak-Domino](https://github.com/Theriak-Domino) using [matplotlib](https://matplotlib.org/).\n\n\n[](https://doi.org/10.5281/zenodo.10844777)\n\nThe pix2py package is registered on Zenodo. If you use pix2py to generate pixelmaps for your research, please cite it. This DOI will resolve to the latest version of pix2py.\n\n## Installation\n\nThe latest version of pix2py can be installed using pip:\n\n```bash\npip install pix2py\n```\n\n## Quickstart\n\nIn your Python script or notebook you must first import ```PixelMap``` from ```pix2py```.\n\n```python\nfrom pix2py import PixelMap\n```\n\nTo use pix2py, you need to have a pixelmap folder called ```_pixelmaps``` generated by [Domino](https://github.com/Theriak-Domino) in your working directory. Or you can specify the path to the pixelmap folder:\n\n```python\nfrom pathlib import Path\n\npixelmap_dir = Path(\"{INSERT PATH HERE}\", \"_pixelmaps\")\n```\n\nSince the individual pixelmaps for solid solution phases are named after the dominant endmember, you need to provide a dictionary to map a phase name to all endmember names for that phase in the thermodynamic database used to generate the pixelmaps.\\\nThis dictionary has the general form:\n```ENDMEMBER_DICT = {\"phase_name\": \"endmember1, endmember2, ...\", ...}```. Create a local dictionary for the project by:\n\n```python\nLOCAL_ENDMEMBER_DICT = {}\nLOCAL_ENDMEMBER_DICT[\"biotite\"] = \"phl\", \"annm\", \"obi\", \"east\", \"tbi\", \"fbi\", \"mnbi\"\n```\nAdditonal phases can be added to the dictionary as needed:\n\n```python\nLOCAL_ENDMEMBER_DICT[\"LIQtc6\"] = \"q4L\", \"abL\", \"kspL\", \"anL\", \"slL\", \"fo2L\", \"fa2L\", \"h2oL\"\n```\n\nNext, set up a pixelmap object by passing the path to the pixelmap folder and the endmember dictionary.\n\n```python\npixmap = PixelMap(pixelmap_dir, LOCAL_ENDMEMBER_DICT)\n```\n\nTo plot a pixelmap, use the ```plot_pixelmap``` method of the pixelmap object. The method takes a variable to plot (```variable```) the phase name (```mineral```) as input arguments and returns a matplotlib figure object and ax object.\n\n```python\npixmap.plot_pixelmap(\"vol\", mineral=\"LIQtc6\")\n```\n volume fraction\")\n\nTo plot isolines, use the ```plot_isolines``` method of the pixelmap object. The method takes a variable to plot (```variable```) and the phase name (```mineral```) as input arguments and returns a matplotlib figure object and ax object.\n\n```python\npixmap.plot_isolines(\"vol\", mineral=\"LIQtc6\")\n```\n\n volume fraction\")\n\n### Customising the plots\nIf you want to customise the plots, you can pass additional arguments to the ```plot_pixelmap``` and ```plot_isolines``` methods. For example, you can set the colormap, the number of contour levels, and the contour levels to plot.\n\nTo change the colormap, pass the name of the colormap to the ```colormap``` argument. The default colormap is \"viridis\". You can use any of the [colormaps](https://matplotlib.org/stable/users/explain/colors/colormaps.html) available in matplotlib.\n```python\npixmap.plot_pixelmap(\"vol\", mineral=\"LIQtc6\", colormap=\"plasma\")\n```\nIf you plot isolines, you can set the number of contour levels or specify the contour levels to plot using the ```isolines``` argument. The default number of isolines is 5. Pass an integer to the ```isolines``` argument to set the number of contour levels.\n```python\npixmap.plot_isolines(\"vol\", mineral=\"LIQtc6\", isolines=10)\n```\nYou can also explicitly set the contour levels to plot by passing a list of values to the ```isolines``` argument.\n```python\npixmap.plot_isolines(\"vol\", mineral=\"LIQtc6\", isolines=[0.1, 0.2, 0.3, 0.4, 0.5])\n```\n\n### Save the pixelmap\nCapture the figure and ax objects to save or further customise the plotted pixelmap.\n\n```python\nfig, ax = pixmap.plot_pixelmap(\"vol\", mineral=\"LIQtc6\")\nfig.savefig(\"LIQtc6_vol.png\", dpi=300)\n```\nYou can use matplotlib's functions to further customise the plotted pixelmap.\n\n```python\nfig, ax = pixmap.plot_pixelmap(\"vol\", mineral=\"LIQtc6\")\nax.set_title(\"LIQtc6 Volume Fraction\")\n```\n\n### Full Example\n\n```python\nfrom pix2py import PixelMap\nfrom pathlib import Path\n\npixelmap_dir = Path(\"{path_to_pixelmap_folder}\", \"_pixelmaps\")\n\nLOCAL_ENDMEMBER_DICT = {}\nLOCAL_ENDMEMBER_DICT[\"biotite\"] = \"phl\", \"annm\", \"obi\", \"east\", \"tbi\", \"fbi\", \"mnbi\"\n\npixmap = PixelMap(pixelmap_dir, LOCAL_ENDMEMBER_DICT)\n\nfig, ax = pixmap.plot_pixelmap(\"#Mg\", mineral=\"biotite\")\nfig.savefig(\"Biotite_Mg.png\", dpi=300)\n```\n",
"bugtrack_url": null,
"license": "GPL-3.0",
"summary": "A python package to plot pixelmaps generated by Domino.",
"version": "1.0.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e31c8cd918e163ac56f3b1aac69b21be973c56221658ff2a6d7163100ab7d86e",
"md5": "5aae5dd1932ad3adab736be716fc1169",
"sha256": "f6fe8bdb03640d6c10044588abd40b6eb4f9c009d9d9a008e0520a973f9cd7dc"
},
"downloads": -1,
"filename": "pix2py-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5aae5dd1932ad3adab736be716fc1169",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 18498,
"upload_time": "2024-03-20T15:51:57",
"upload_time_iso_8601": "2024-03-20T15:51:57.002779Z",
"url": "https://files.pythonhosted.org/packages/e3/1c/8cd918e163ac56f3b1aac69b21be973c56221658ff2a6d7163100ab7d86e/pix2py-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2350b3fccfa8beca8734cbd2da0f4eabf2798faca4db303fa6bd36f851126475",
"md5": "1dc9514816992ae09e0371dd7db5b874",
"sha256": "6e3ee34995992b4c57cd61850bfa8b2027e46eb50c433bd0680c59a9afaf491a"
},
"downloads": -1,
"filename": "pix2py-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "1dc9514816992ae09e0371dd7db5b874",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 18023,
"upload_time": "2024-03-20T15:51:58",
"upload_time_iso_8601": "2024-03-20T15:51:58.720822Z",
"url": "https://files.pythonhosted.org/packages/23/50/b3fccfa8beca8734cbd2da0f4eabf2798faca4db303fa6bd36f851126475/pix2py-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-20 15:51:58",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pix2py"
}