Skip to content

Commit

Permalink
Add threadpoolctl to requirements for improved parallel processing
Browse files Browse the repository at this point in the history
  • Loading branch information
jgieseler committed Nov 14, 2024
1 parent 5110fcd commit 9014c72
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ setuptools
speasy>=1.2.7
sunkit_magex
sunpy
threadpoolctl
tqdm
zeep
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ install_requires =
speasy>=1.2.7
sunkit_magex
sunpy
threadpoolctl
tqdm
zeep

Expand Down
14 changes: 8 additions & 6 deletions solarmach/pfss_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np
import sunkit_magex.pfss as pfsspy
import sunpy.map
import threadpoolctl
from astropy.coordinates import SkyCoord
from sunpy.net import Fido
from sunpy.net import attrs as a
Expand Down Expand Up @@ -567,18 +568,18 @@ def calculate_pfss_solution(gong_map, rss, coord_sys, nrho=35):
Parameters:
-----------
gong_map : {SunPy Map}
GONG map as SunPy Map object obtained with get_gong_map()
gong_map : {sunpy.map.Map}
GONG map in Carrington or Stonyhurst coordinates, obtained with get_gong_map()
rss : {float}
source surface height in solar radii
coord_sys: {str}
cordinate system used: either 'car' or 'Carrington', or 'sto' or 'Stonyhurst'
nrho : {float/int}
rho = ln(r) -> nrho is the amount of points in this logarithmic range
nrho : {float/int, optional}
rho = ln(r) -> nrho is the amount of points in this logarithmic range. Default is 35.
Returns:
----------
pfss_solution : {pfsspy solution object}
pfss_solution : {pfsspy.Output}
The PFSS solution that can be used to plot magnetic field lines under the source surface
"""
# GONG map is in Carrington coordinates
Expand All @@ -604,7 +605,8 @@ def calculate_pfss_solution(gong_map, rss, coord_sys, nrho=35):
pfss_in = pfsspy.Input(gong_map, nrho, rss)

# This is the pfss solution, calculated from the input object
pfss_solution = pfsspy.pfss(pfss_in)
with threadpoolctl.threadpool_limits(limits=1, user_api='blas'):
pfss_solution = pfsspy.pfss(pfss_in)

return pfss_solution

Expand Down

0 comments on commit 9014c72

Please sign in to comment.