Skip to main content

A python package to plot pixelmaps generated by Domino.

Project description

pix2py

Tests PyPI Compatible Python Versions

A python package to plot pixelmaps generated by Theriak-Domino using matplotlib.

DOI

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:

pip install pix2py

Quickstart

In your Python script or notebook you must first import PixelMap from pix2py.

from pix2py import PixelMap

To use pix2py, you need to have a pixelmap folder called _pixelmaps generated by Domino in your working directory. Or you can specify the path to the pixelmap folder:

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:

LOCAL_ENDMEMBER_DICT = {}
LOCAL_ENDMEMBER_DICT["biotite"] = "phl", "annm", "obi", "east", "tbi", "fbi", "mnbi"

Additonal phases can be added to the dictionary as needed:

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.

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.

pixmap.plot_pixelmap("vol", mineral="LIQtc6")

Pixelmap of melt (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.

pixmap.plot_isolines("vol", mineral="LIQtc6")

Isolines of melt (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 available in matplotlib.

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.

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.

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.

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.

fig, ax = pixmap.plot_pixelmap("vol", mineral="LIQtc6")
ax.set_title("LIQtc6 Volume Fraction")

Full Example

To run an example look into the folder example, where a runable python script is provided along a _pixelmaps directory containing the data generate by Domino.

from pix2py import PixelMap
from pathlib import Path

pixelmap_dir = Path("example", "_pixelmaps")

LOCAL_ENDMEMBER_DICT = {}
LOCAL_ENDMEMBER_DICT["biotite"] = "phl", "annm", "obi", "east", "tbi", "fbi", "mnbi"
LOCAL_ENDMEMBER_DICT["LIQtc6"] = "q4L", "abL", "kspL", "anL", "slL", "fo2L", "fa2L", "h2oL"

pixmap = PixelMap(pixelmap_dir, LOCAL_ENDMEMBER_DICT)

fig, ax = pixmap.plot_pixelmap("vol", mineral="LIQtc6")
fig.savefig("LIQtc6_vol.png", dpi=300)

fig, ax = pixmap.plot_isolines("vol", mineral="LIQtc6")
fig.savefig("LIQtc6_vol_isolines.png", dpi=300)

fig, ax = pixmap.plot_pixelmap("Mg#", mineral="biotite")
fig.savefig("Biotite_Mg.png", dpi=300)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pix2py-1.0.1.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pix2py-1.0.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file pix2py-1.0.1.tar.gz.

File metadata

  • Download URL: pix2py-1.0.1.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.10 Linux/6.11.0-1013-azure

File hashes

Hashes for pix2py-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5253ca3cc2a3b16ee4a1fea8ea862e2c5f01e0659508993c7494398e819dd324
MD5 79f8ad7d02f8b659c37d9c3a09fb13a3
BLAKE2b-256 8348a30aab8139ccff8477e87f3e625dac5b079499f631f3e454924374a1c261

See more details on using hashes here.

File details

Details for the file pix2py-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pix2py-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.10 Linux/6.11.0-1013-azure

File hashes

Hashes for pix2py-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a7783b7f5b0d104a2d75acecef3a32ea8d77a0cf01fa9c20c0fcd13d0d508c0
MD5 35d9f431287d15c3805ea0ca8c4903e6
BLAKE2b-256 b15239e9a2f3593c6d1c90c7f7d012c06033265e67f9a3bf68100fd8e6055411

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page