Python client for the MSWIM2D solar wind model
Project description
CSEM-MSWIM2D
Python client for the MSWIM2D solar wind model - a 2-D MHD model of the heliospheric equatorial plane, driven by in-situ observations and propagated outward to the orbits of the planets and deep-space spacecraft.
All data products are served as static files and returned as xarray Datasets, cached locally after first download.
Install
pip install mswim2d
Quickstart
Model values sampled along a body's trajectory:
import mswim2d
mswim2d.list_bodies()
# ['Cassini', 'Earth', 'Galileo', 'Juno', 'Jupiter', ... 'Voyager1', 'Voyager2']
data = mswim2d.get_trajectory("Earth", "2015-01-01", "2015-02-01")
print(data)
<xarray.Dataset>
Dimensions: (time: 745)
Coordinates:
* time (time) datetime64[ns] 2015-01-01 ... 2015-02-01
Data variables:
r_AU (time) float64 ... # heliocentric radius [AU, HGI]
phi_deg (time) float64 ... # heliocentric longitude [deg, HGI]
rho (time) float64 ... # density [amu/cm^3]
ux, uy, uz (time) float64 ... # bulk velocity [km/s, HGI]
bx, by, bz (time) float64 ... # magnetic field [nT, HGI]
p (time) float64 ... # thermal pressure [erg/cm^3]
neurho ... ne4p (time) float64 ... # neutral-hydrogen populations
Attributes:
source: MSWIM2D
url: https://csem.engin.umich.edu/MSWIM2D/
body: Earth
coordinate_system: HGI
product: trajectory
More products
# A body's position (r, phi, and Cartesian x/y in AU)
mswim2d.get_orbit("Voyager1", "2010-01-01", "2012-01-01")
# The in-situ inputs that drive the model
mswim2d.list_inputs() # ['l1', 'stereoA', 'stereoB', 'solo']
mswim2d.get_input("l1", "2015-01-01", "2015-02-01")
mswim2d.get_input("solo", "2023-01-01", "2023-02-01") # propagated -> orig_r/orig_lon
# 2-D field snapshots of the equatorial plane, dims (time, phi, r)
mswim2d.get_field("2015-03-17T00:00:00") # nearest single frame
mswim2d.get_field("2015-03-17T00:00:00", "2015-03-18T00:00:00") # all frames in range
The base URL defaults to the staging host; override it with the
MSWIM2D_BASE_URL environment variable.
Saving to file
data = mswim2d.get_trajectory("Earth", "2015-01-01", "2015-02-01")
mswim2d.to_csv(data, "earth.csv")
mswim2d.to_dat(data, "earth.dat") # matches the website download format
to_dat chooses its layout from the dataset's product attribute (trajectory,
orbit, or input). The 2-D field product has no .dat form — save it with
mswim2d.to_csv (tidy long form), or field.to_netcdf("field.nc") if you have a
netCDF backend installed (pip install netCDF4 or h5netcdf). Data is cached
locally after the first download.
Using with spacepy
MSWIM2D Datasets convert to a spacepy SpaceData
in a few lines:
import mswim2d
from spacepy.datamodel import SpaceData, dmarray
ds = mswim2d.get_trajectory("Earth", "2015-01-01", "2015-02-01")
sd = SpaceData(attrs=dict(ds.attrs))
sd["Epoch"] = dmarray(ds["time"].values, attrs={"units": "UTC"})
for name, da in ds.data_vars.items():
sd[name] = dmarray(da.values, attrs=dict(da.attrs))
Not yet supported
- Interpolation along custom / uploaded trajectories (the website's dynamic
interpolate.phppath). Only the precomputed bodies are available here.
See also
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mswim2d-0.1.0.tar.gz.
File metadata
- Download URL: mswim2d-0.1.0.tar.gz
- Upload date:
- Size: 88.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d067afe135ae9acf3dffb9f4622f6bf240e6548282c0be9468910932381f0f21
|
|
| MD5 |
c65c54124573ee6cc0e2485f02189c16
|
|
| BLAKE2b-256 |
fc566953736216eb726f5e5627ff252de43ef95ac5f570f301f30eedec437c65
|
File details
Details for the file mswim2d-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mswim2d-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ebbdb79b74b1aa00de5e87431291f223094ea73dfad997d957041a6cf8013d5
|
|
| MD5 |
af8924ee82d4b4e93bb25b77af2902b9
|
|
| BLAKE2b-256 |
9ae36504f6f96165a7aa1a4d6f89438dea62a76a3f4323a55e2fee4efc6c1077
|