Skip to main content

MicPy is a Python package to facilitate MICRESS workflows.

Project description

MicPy logo

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


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

micress_micpy-0.2.13b4-py3-none-any.whl (14.6 kB view hashes)

Uploaded Python 3

Supported by

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