MicPy is a Python package to facilitate MICRESS workflows.
Project description
MicPy
MicPy is a Python package to facilitate MICRESS workflows. Whether you aim to visualize, convert, or manipulate MICRESS data, MicPy provides the necessary tools.
Installation
pip install micress-micpy
Dependencies
MicPy requires the following dependencies:
- Python (>= 3.9)
- Pandas (>= 1.1)
- Matplotlib (>= 3) as an optional dependency for plotting
Examples
Below are some examples demonstrating how to use MicPy.
bin
module
Read one field at a time
from micpy import bin
for field in bin.File("A001_Delta_Gamma.conc1"):
print(field)
Read all fields
from micpy import bin
with bin.File("A001_Delta_Gamma.conc1") as file:
fields = file.read()
print(fields)
Read a subset of fields providing a list of indices
from micpy import bin
with bin.File("A001_Delta_Gamma.conc1") as file:
fields = file.read([0, 1, -2, -1])
print(fields)
Read a subset of fields providing a condition function
from micpy import bin
with bin.File("A001_Delta_Gamma.conc1") as file:
fields = file.read(lambda field: field.time >= 10 and field.time <= 20)
print(fields)
Read fields opening and closing the file manually
from micpy import bin
file = bin.File("A001_Delta_Gamma.conc1")
file.open()
first_field = file.read(0)
second_field = file.read(1)
file.close()
print(first_field, second_field)
Plot a field
from micpy import bin
with bin.File("A001_Delta_Gamma.conc1") as file:
field = file[-1]
fig, ax = field.plot()
Plot a list of fields normalizing the data
from micpy import bin
with bin.File("A001_Delta_Gamma.conc1") as file:
fields = file[[0, 1, -2, -1]]
fig, ax = fields.plot(normalize=True, figsize=(8, 8))
Plot a specific plane of a field
from micpy import bin
with bin.File("A005_Grain_Growth_Misorientation_3D.korn") as file:
field = file[0]
fig, ax = field.plot(plane="xy", slice=50)
tab
module
Read a table
from micpy import tab
table = tab.read("A001_Delta_Gamma.TabF")
Plot a table
from micpy import tab
table = tab.read("A001_Delta_Gamma.TabF")
fig, ax = table.plot(x=1, y=[2, 3, 4])
Extract a subset of a table
from micpy import tab
table = tab.read("A001_Delta_Gamma.TabF")
table.loc[
table["Fraction Phase 2 FCC_A1"] > 0,
["Temperature [K]", "Fraction Phase 1 BCC_A2", "Fraction Phase 2 FCC_A1"]
]
Convert a table to different file formats
from micpy import tab
table = tab.read("A001_Delta_Gamma.TabF")
table.to_csv("A001_Delta_Gamma.TabF.csv")
table.to_excel("A001_Delta_Gamma.TabF.xlsx")
table.to_json("A001_Delta_Gamma.TabF.json")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for micress_micpy-0.2.14b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce373c7011621f029543c607abae3d866b494c77fd0c6a484b3d45238dc4111a |
|
MD5 | e9691efdf5663f901096db8a58a07c37 |
|
BLAKE2b-256 | 08d9f2d3dceaa2cb453859be0e9c3c5fa5ae8e164ceb8caf1a3504d7b15968dd |