Skip to main content

A python module for handling OPAT files

Project description

opatIO python module

This module defines a set of tools to build, write, and read OPAT files. The OPAT fileformat is a custom file format designed to efficiently store opacity information for a variety of compositions.

Installation

The prefered, stable, way to install opatio is to use the version on pypi

pip install opatio

If you wish to insall from source or for developemnt you can and should clone the git repository instead You can install this module with pip

git clone https://github.com/4D-STAR/opat-core
cd opat-core/opatio-py
pip install . # For non development

or

pip install . -e # for development

General Usage

The general way that this module is mean to be used is to first build a schema for the opacity table and then save that to disk. The module will handle all the byte aligment and lookup table construction for you.

A simple example might look like the following

from opatio import OPAT

opacityFile = OPAT()
opacityFile.set_comment("This is a sample opacity file")
opacityFile.set_source("OPLIB")

# some code to get a logR, logT, and logKappa table
# where logKappa is of size (n,m) if logR is size n and
# logT is size m

card = opacityFile.add_table((X, Z), "data", logR, logT, logKappa, rowName="logR", columnName="logT")
opacityFile.save("opacity.opat")
opacityFile.save_as_ascii("opacity.txt")

If you wish you can add more tables to the same card. This means that there can be multiple tables associated to the same indexing vector (for example you might store data and pre calculated interpolation coefficients along side the same data)

opacityFile.add_table((X, Z), "interp", xOrder, yOrder, coeff, rowName="xCoeff", columnName="yCoeff", card=card)

Note how here I passed the card as an argument. This means that the same card will be modified and then repushed into the file.

You can also read opat files which have been generated with the loadOpat function

from opatio import read_opat

opacityFile = read_opat("opacity.opat")

print(opacityFile.header)

Converting from OPAL type I

Given the prevelence of OPAL type I tables, we have included a utility function to take care of this conversion for you. Assuming there is some OPAL type I file in your current working directory (in the below example we assume it is called GS98hz) then converting is as simple as calling the convert function...

from opatio.convert import OPALI_2_OPAT

OPALI_2_OPAT("GS98hz", "gs98hz.opat")

Problems

If you have problems feel free to either submit an issue to the root github repo (tagged as utils/opatio) or email Emily Boudreaux at emily.boudreaux@dartmouth.edu

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

opatio-0.2.3.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

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

opatio-0.2.3-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file opatio-0.2.3.tar.gz.

File metadata

  • Download URL: opatio-0.2.3.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for opatio-0.2.3.tar.gz
Algorithm Hash digest
SHA256 27f4138aeb9305b741c1f2380b50523957cba5d9d784fa3ccdeb7e5b183826f4
MD5 aa2b3c6fa3282e40e35d88925f2164b9
BLAKE2b-256 75e667d733198eb13d5e7f0789d6c09ebf199a907b56ea42ff3d1749ad4ddd30

See more details on using hashes here.

File details

Details for the file opatio-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: opatio-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for opatio-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 78ab69e63b50530e78b58256a3ea066c7d551a2390ad2720e74f78c4c807e5da
MD5 eff4d899ec13f14181882fdfbad06172
BLAKE2b-256 c1ad8fcd3c6b19139ff612846444a4ab2b4ea05335ac0c94bdccbedf45bc5a6a

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