Skip to main content

Simple time series plotting library based on pyspedas and matplotlib.

Project description

stpp_tplot

Simple time series plotting library based on pyspedas and matplotlib.

Overview

stpp_tplot is a Python library that provides convenient functions for plotting time series data, especially for space physics data processed by pyspedas. It simplifies the creation of publication-quality plots with features like:

  • Multiple panel plots with shared x-axis
  • Spectrogram plots with colorbar
  • Orbit parameter labels panel
  • Customizable plot options

Installation

pip install stpp_tplot==0.1.9

Usage

Plotting with default options: mp

from stpp_tplot import mp, sd, op
from pyspedas.erg import pwe_ofa, mgf, orb

# Load data
trange = ['2017-03-27', '2017-03-28']
pwe_ofa(trange=trange)
mgf(trange=trange)
orb(trange=trange)

# Plot data
mp(['erg_pwe_ofa_l2_spec_B_spectra_132', 'erg_mgf_l2_mag_8sec_sm'], var_label='erg_orb_l2_pos_rmlatmlt')

alt text

If you do not need the orbit parameter labels, var_label can be set to None.

mp(['erg_pwe_ofa_l2_spec_B_spectra_132', 'erg_mgf_l2_mag_8sec_sm'], var_label=None)

alt text

Plotting with custom options: op & mp

op('erg_pwe_ofa_l2_spec_B_spectra_132', ylog=0, zlog=1, z_range=[1e-4, 1e2], colormap='viridis')
mp(['erg_pwe_ofa_l2_spec_B_spectra_132'], var_label=None)

alt text

Following are the available options for the op function:

  • y_label: y axis label (str, optional)
  • ylog: y axis type (bool, optional)
  • y_range: y axis range (list, optional)
  • axis_subtitle: axis subtitle (str, optional)
  • zlog: z axis type (bool, optional)
  • z_range: z axis range (list, optional)
  • z_label: z axis label (str, optional)
  • spec: spectrogram (0 or 1, optional)
  • colormap: colormap (list, optional)
  • legend_names: legend names (list, optional)
  • line_color: line color (str, optional)
  • line_width: line width (int, optional)
  • line_style: line style (str, optional)

Storing Data: sd

from pyspedas import data_quants
import numpy as np
magt = data_quants['erg_mgf_l2_magt_8sec']
electron_mass = 9.1094e-31
electron_charge = 1.602e-19
fc = 1 / (2*np.pi) * electron_charge * magt * 1e-9 / electron_mass * 1e-3
sd('fc', data={'x': magt.time, 'y':fc})
sd('05fc', data={'x': magt.time, 'y':fc*0.5})
op('fc', line_color='black')
op('05fc', line_color='red')
mp('fc')

alt text

Overplotting

Give the list of variables to be overplotted as a list of lists.

mp([['fc', '05fc']])

alt text

mp([['fc', 'erg_pwe_ofa_l2_spec_B_spectra_132'], 'fc'], var_label='erg_orb_l2_pos_rmlatmlt')

alt text

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

stpp_tplot-0.1.9.tar.gz (9.8 kB view details)

Uploaded Source

File details

Details for the file stpp_tplot-0.1.9.tar.gz.

File metadata

  • Download URL: stpp_tplot-0.1.9.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for stpp_tplot-0.1.9.tar.gz
Algorithm Hash digest
SHA256 32b47fed1192d226d8e0be933c6b5cc41ad4ec9e6b547d01a57cdfe75231708d
MD5 3cc04f75d47dd7989515467349f44ec2
BLAKE2b-256 0d153c02d94d265b92fcc7fc167b87a936ba36e752cbd44c1e69c7a0a9f268cb

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