Giter Club home page Giter Club logo

starwinds-readplt's Introduction

Python package Codacy Badge Codacy Badge DOI Code style: black

The readplt project is a Python library for reading and parsing SWMF/BATSRUS output files in .dat and .plt format. The library may also be able to read other .plt files but only a core subset of the .plt format specification is supported. The project also includes a use case in the form of a 'quicklook' command sw-quick that can visualise two-dimensional SWMF/BATSRUS output.

Installation

After cloning this repository, the project may be installed with pip in the regular way:

cd <project>
pip install .

Python code to access file data

This code reads a dataset named <file> and stores the dataset variable named Rho [g/cm^3] in a local variable named density_g_cm3.

from starwinds_readplt.dataset import Dataset
ds = Dataset.from_file('<file>')
print(ds)
density_g_cm3 = ds('Rho [g/cm^3]')

Running the quicklook command

A simple 'quicklook' shell command is included which permits plotting of two-dimensional slices of the SWMF/BATSRUS results. Irregularly gridded data is accepted. The quicklook command uses the plot function in basicplot.py but this may be extended by the user.

To create a quicklook .png file from the included file examples/x=0_var_2_n00000000.plt run

cd examples
sw-quick x=0_var_2_n00000000.plt

This will create a file named ql-x-0-var-2-n00000000-plt-rho-g-cm-3.png; the name comprises the prefix ql, the file name, and the name of the plotted variable. The name is sanitised using slugify to replace spaces and other problematic characters in the output file name with dashes.

A wildcard pattern may be used; in this case one .png file is created for each file matching the wildcard pattern:

sw-quick x*.plt

Development and testing

To install the project in editable mode and enable testing do

cd <project>
pip install --editable .[tests]

Now it is possible to run the test suite by typing

pytest

starwinds-readplt's People

Contributors

svaberg avatar

Watchers

 avatar

Forkers

floriandriessen

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.