Git Product home page Git Product logo

pyvpic's Introduction

pyvpic - Python tools for VPIC data analysis

Installation

pyvpic is designed to work with setuptools so you can install using pip. For a local install:

pip install --user .

Usage

Data Access

Readers for multiple VPIC file formats are provided. These readers can be used directly, or the pyvpic.open function can be used to automatically choose the appropriate reader. Readers provide a simplified memory mapped view into the actual data files. Each dataset is a 4D array. With the default C-ordering, the datasets are indexed as (time, z, y, x). All readers also support an option Fortran ordering by setting order='F' in which case datasets are indexed as (x, y, z, time).

Examples

>>> import pyvpic
>>> import matplotlib.pyplot as plt
>>> reader = pyvpic.open('global.vpc', order='C')
>>> reader.datasets
['fields/bx',
 'fields/by',
 'fields/bz',
...]
>>> bz = reader['fields/bz']
>>> bz.shape
(128, 260, 1, 130)
>>> t, z, y, x = reader.get_grid('fields/bz')
>>> plt.pcolormesh(z, x, bz[0,:,0,:].T)

Data Visualization

A simple data visualization tool is provided for quickly viewing 1D and 2D slices of VPIC data. If installed via pip, this viewer is available as a command line program. Command line arguments are the same as those passed to pyvpic.open, however order is always ignored if present.

# Launch the viewer to read interleaved file-per-rank data.
$ vpicviewer global.vpc --interleave=True

The viewer can also be launched from within an interactive python session.

>>> import pyvpic.viewer
>>> pyvpic.viewer.main('global.vpc', interleave=True)

Data File Specifications

File Per Rank

The pyvpic.readers.FilePerRankReader reader maps the individual datafiles output by VPIC into a 4D dataset. This is done lazily and no data is loaded until the dataset is actually sliced, at which point only files containing the requested data are accessed. To use the File per rank reader, pass a VPIC header file, global.vpc to pyvpic.open. Additionally, VPIC has the option of either outputting banded or band-interleaved data. This choice is currently not recorded in the VPIC header file and must be passed to the reader as well.

GDA Files

GDA files are straight, brick-of-value datafiles with no padding or headers. Data is assumed to be stored using 'float32' format and C-ordered. GDA comes in two flavors both of which are supported by pyvpic.readers.GDAReader:

  1. Single-file, multiple-timesteps - In this case all data is contained within a single file and the 4D dataset maps directly to the file. The number of timesteps is determined from the length of the file.
  2. Single-file, single-timestep - In this case, each timestep is stored as a single file with the naming convention <dataset>_<timestep>.gda. Different files are transparently mapped to different slices of the 4D dataset.

To use the pyvpic.readers.GDAReader, a directory containing GDA files should be passed. By default, the directory is scanned recursively for all GDA files. Each directory containing GDA files should also contain a binary info file structured as:

<Start of file: info>
--      - padding              - 4 bytes
nx      - number of cells in x - float32
ny      - number of cells in y - float32
nz      - number of cells in z - float32
--      - padding              - 8 bytes
Lx      - Domain length in x   - float32
Ly      - Domain length in y   - float32
Lz      - Domain length in z   - float32
...

pyvpic's People

Contributors

jjaraalm avatar

Stargazers

Xiaocan Li avatar Sergei Bastrakov avatar Nick Murphy avatar  avatar Derek avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

Forkers

henry2004y

pyvpic's Issues

reading hydro files

Hi! I've been trying to use pyvpic to read the output of vpic code. I can read the fields data, but it fails when trying to read the hydro file. I was wondering if someone could help me out.
Appreciate it!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.