Skip to main content

Readers and writers for data formats used by Predictive Science Inc.

Project description

psi-io


Python utilities for interacting with scientific data formats used by Predictive Science Inc. (PSI).

Primarily this includes the HDF file format used by several of PSI's scientific codes for simulating the solar surface, solar corona, and inner heliosphere, including:

Installation


pip install psi-io

Usage


Basic Reading

Read the entire dataset from a 3D Br HDF file output by a POT3D solution (spherical r,t,p):

import psi_io
r, t, p, br = psi_io.rdhdf_3d('br.h5')

Here r, t, and p are the 1D coordinate arrays. br is the 3D data array.

There are equivalent routines rdhdf_1d, and rdhdf_2d for 1D and 2D HDF files.

Optimized Reading and Interpolation

One can also read a specific subset of the datasets from disk.

Extract a wedge of data that just spans a range of interest:

r_range = [1.0, 1.2]
t_range = [0.5, 1.0]
p_range = [2.0, 3.0]
brx, rx, tx, px = psi_io.read_hdf_by_value(r_range, t_range, p_range, ifile='br.h5')

Get 2D t,p slice of data interpolated to a specific radius (e.g. 2.0 Rs).

br_slice, t, p = psi_io.np_interpolate_slice_from_hdf(2.5, None, None, ifile='br.h5')

Interpolate the data to specific r, t, p positions (supplied as 1D, 2D, or 3D arrays).

import numpy as np
r_vals = np.array([1.0, 1.1])
t_vals = np.array([0.7, 0.7])
t_vals = np.array([1.5, 1.5])
br_vals = psi_io.interpolate_positions_from_hdf(r_vals, t_vals, t_vals, ifile='br.h5')

Writing

Write a new 3D file:

psi_io.wrhdf_3d('br_mod.h5', r, t, p, br_mod)

As before r, t, and p are the 1D coordinate arrays. br_mod is the 3D data array.

There are equivalent routines wrhdf_1d, and wrhdf_2d for 1D and 2D HDF files.

Requirements


This package requires the python HDF5 interface, h5py, to work with .h5 files.

If you are working with HDF4 .hdf files then you must also have the optional pyhdf HDF4 python interface installed.

Because these packages require the underlying C HDF libraries to be installed, we generally recommend using conda to install these dependencies. This often makes life much easier than installing from source:

for HDF5

conda install h5py

for HDF4

conda install pyhdf

To isolate these to a specific environment, see environment.yml

Disclaimer


This package is currently in a pre-release state as we transition from having copies of these routines everywhere to centralizing them in a pip-installable Python package. Although the basic readers are unlikely to change for historical compatibility reasons, some of the newer things like optimized i/o and object oriented hdf reader interface may be more likely to evolve quickly.

Automated tests and basic documentation are coming soon!

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

psi_io-1.0.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

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

psi_io-1.0.0-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file psi_io-1.0.0.tar.gz.

File metadata

  • Download URL: psi_io-1.0.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for psi_io-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0c5bd8aab0d03340acab19019b01798c4e92b81d66225effe8aac55ef1cbdf56
MD5 de044a5f2f5fc0c47e60ee03464a531c
BLAKE2b-256 60d18dbb302ef34726aeab9fd01da2ab591869fc56b49ce60dece56ac8eaa5a0

See more details on using hashes here.

File details

Details for the file psi_io-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: psi_io-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for psi_io-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bdf49f4662e9223a0077ce56010d1ee7181ba433c1fd058da4725af8a86d279b
MD5 e084dc88bec9c90fafa48ec0d8f20eeb
BLAKE2b-256 855e385a41155b23269d8fd283bf0b490266ce7a985d15726a66dfb51cf61015

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