dstansby / pfsspy

Potential Field Source Surface model package for Python
https://pfsspy.readthedocs.io/
Other
41 stars 18 forks source link

Streamtracer does not load for "Open/closed field map" example #327

Closed pymilo closed 3 years ago

pymilo commented 3 years ago

Using the piece of code below given as the "Open/closed field map" example rises the next error:

Using FortranTracer requires the streamtracer module, but streamtracer could not be loaded

Am I lacking an extra package, or is this a bug?

` import astropy.units as u import astropy.constants as const from astropy.coordinates import SkyCoord import matplotlib.pyplot as plt import matplotlib.colors as mcolor import numpy as np import sunpy.map import pfsspy from pfsspy import tracing from pfsspy.sample_data import get_gong_map

gong_fname = get_gong_map()

gong_map = sunpy.map.Map(gong_fname)

Remove the mean

gong_map = sunpy.map.Map(gong_map.data - np.mean(gong_map.data), gong_map.meta)

nrho = 60 rss = 2.5

input = pfsspy.Input(gong_map, nrho, rss) output = pfsspy.pfss(input)

r = const.R_sun

Number of steps in cos(latitude)

nsteps = 90 lon_1d = np.linspace(0, 2 np.pi, nsteps 2 + 1) lat_1d = np.arcsin(np.linspace(-1, 1, nsteps + 1)) lon, lat = np.meshgrid(lon_1d, lat_1d, indexing='ij') lon, lat = lonu.rad, latu.rad seeds = SkyCoord(lon.ravel(), lat.ravel(), r, frame=output.coordinate_frame)

print('Tracing field lines...') tracer = tracing.FortranTracer(max_steps=2000) field_lines = tracer.trace(seeds, output) print('Finished tracing field lines') `

dstansby commented 3 years ago

Yes, you need to install the streamtracer package, see https://streamtracer.readthedocs.io/en/stable/. Hope that works, let me know if it doesn't!

pymilo commented 3 years ago

Yap it did the trick. Thanks! I wonder whether this extra instruction is something you guys want explicitly suggested in the installation instructions, together with numba.