Skip to content

Commit

Permalink
Merge pull request #23 from sunpy/cruft/update-1710843577
Browse files Browse the repository at this point in the history
Updates from the package template
  • Loading branch information
Cadair committed Mar 19, 2024
2 parents 0d823ba + d9c6492 commit fa2107c
Show file tree
Hide file tree
Showing 35 changed files with 146 additions and 80 deletions.
14 changes: 14 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[codespell]
skip = *.asdf,*.fits,*.fts,*.header,*.json,*.xsh,*cache*,*egg*,*extern*,.git,.idea,.tox,_build,*truncated,*.svg,.asv_env,.history
ignore-words-list =
als, # magex specific
alog,
nd,
nin,
observ,
ot,
te,
upto,
afile,
precessed,
precess,
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/sunpy/package-template",
"commit": "8d590fba25722f382d4fb5554fa52dfec65952c9",
"commit": "3a8054de27a4af460d7cb737b2b1ec2621456e5f",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ exclude =
__pycache__
docs/conf.py
build
sunkit-magex/__init__.py,
sunkit-magex/__init__.py
rst-directives =
plot
16 changes: 16 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[settings]
balanced_wrapping = true
skip =
docs/conf.py
sunkit_magex/__init__.py
default_section = THIRDPARTY
include_trailing_comma = true
known_astropy = astropy, asdf
known_sunpy = sunpy
known_first_party = sunkit_magex
length_sort = false
length_sort_sections = stdlib
line_length = 110
multi_line_output = 3
no_lines_before = LOCALFOLDER
sections = STDLIB, THIRDPARTY, ASTROPY, SUNPY, FIRSTPARTY, LOCALFOLDER
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ repos:
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|sunkit_magex/extern)$"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand All @@ -20,6 +25,11 @@ repos:
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|.json)$|^CITATION.rst$"
- id: mixed-line-ending
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*)$"
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: [ "--write-changes" ]
ci:
autofix_prs: false
autoupdate_schedule: "quarterly"
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

import os
import datetime

# -- Project information -----------------------------------------------------

# The full version, including alpha/beta/rc tags
from sunkit_magex import __version__

release = __version__
project = "sunkit-magex"
copyright = str(datetime.datetime.now().year) + " , The SunPy Community" # noqa: A001
author = "The SunPy Community"
copyright = f"{datetime.datetime.now().year}, {author}" # noqa: A001

# -- General configuration ---------------------------------------------------

Expand Down
5 changes: 4 additions & 1 deletion examples/finding_data/adapt_map_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
Parse an ADAPT FITS file into a `sunpy.map.MapSequence`.
"""
import matplotlib.pyplot as plt
import sunpy.map
from matplotlib import gridspec

from astropy.io import fits

import sunpy.map

from sunkit_magex import pfss

###############################################################################
Expand Down
6 changes: 4 additions & 2 deletions examples/internals/tracer_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"""
import timeit

import astropy.coordinates
import astropy.units as u
import matplotlib.pyplot as plt
import numpy as np

import astropy.coordinates
import astropy.units as u

import sunpy.map

from sunkit_magex import pfss
Expand Down
10 changes: 6 additions & 4 deletions examples/testing/helpers.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import functools
import pathlib
import functools

import astropy.units as u
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import numpy as np
import scipy.integrate
import sunpy.map
from sympy import acos, asin, cos, lambdify, sin
from sympy.abc import x

import astropy.units as u

import sunpy.map

import sunkit_magex.pfss.analytic as analytic
import sunkit_magex.pfss.utils

Expand All @@ -19,7 +21,7 @@


def theta_phi_grid(nphi, ns):
# Return a theta, phi grid with a given numer of points
# Return a theta, phi grid with a given number of points
phi = np.linspace(0, 2 * np.pi, nphi)
s = np.linspace(-1, 1, ns)
s, phi = np.meshgrid(s, phi)
Expand Down
8 changes: 4 additions & 4 deletions examples/testing/plot_error_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
This script produces a map of errors between analytic field line equations
and field lines numerically traced by `sunkit_magex.pfss`.
"""
import astropy.constants as const
import astropy.units as u
import matplotlib.pyplot as plt
import numpy as np

import astropy.constants as const
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.visualization import quantity_support

from sunkit_magex import pfss

from examples.testing.helpers import pffspy_output, phi_fline_coords, theta_fline_coords
from sunkit_magex import pfss

quantity_support()

Expand Down
2 changes: 1 addition & 1 deletion examples/testing/skip_open_flux_nr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Comparing total unsigned flux to analytic solutions.
This script caclulates the ratio of numeric to analytic total unsigned open
This script calculates the ratio of numeric to analytic total unsigned open
fluxes in PFSS solutions of spherical harmonics, as a function of the number of
radial grid cells in the sunkit_magex.pfss grid.
"""
Expand Down
13 changes: 4 additions & 9 deletions examples/testing/tracer_step_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@
Tracer step size (calculations)
===============================
"""
import astropy.constants as const
import astropy.units as u
import numpy as np
import pandas as pd

import astropy.constants as const
import astropy.units as u
from astropy.coordinates import SkyCoord

from examples.testing.helpers import pffspy_output, phi_fline_coords, result_dir, theta_fline_coords
from sunkit_magex.pfss import tracing

from examples.testing.helpers import (
pffspy_output,
phi_fline_coords,
result_dir,
theta_fline_coords,
)

l = 3
m = 3
nphi = 360
Expand Down
6 changes: 4 additions & 2 deletions examples/using_pfsspy/plot_aia_overplotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

import os

import astropy.units as u
import matplotlib.pyplot as plt
import numpy as np
import sunpy.map

import astropy.units as u
from astropy.coordinates import SkyCoord

import sunpy.map

import sunkit_magex.pfss
import sunkit_magex.pfss.tracing as tracing
from sunkit_magex.pfss.sample_data import get_gong_map
Expand Down
8 changes: 5 additions & 3 deletions examples/using_pfsspy/plot_dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
A simple example showing how to use PFSS to compute the solution to a dipole
source field.
"""
import astropy.constants as const
import astropy.units as u
import matplotlib.patches as mpatch
import matplotlib.pyplot as plt
import numpy as np
import sunpy.map

import astropy.constants as const
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.time import Time

import sunpy.map

from sunkit_magex import pfss

###############################################################################
Expand Down
6 changes: 4 additions & 2 deletions examples/using_pfsspy/plot_field_line_magnetic_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
How to get the value of the magnetic field along a field line traced through
the PFSS solution.
"""
import matplotlib.pyplot as plt

import astropy.constants as const
import astropy.units as u
import matplotlib.pyplot as plt
import sunpy.map
from astropy.coordinates import SkyCoord

import sunpy.map

from sunkit_magex import pfss

###############################################################################
Expand Down
8 changes: 5 additions & 3 deletions examples/using_pfsspy/plot_gong.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
"""
# sphinx_gallery_thumbnail_number = 4

import astropy.constants as const
import astropy.units as u
import matplotlib.pyplot as plt
import numpy as np
import sunpy.map

import astropy.constants as const
import astropy.units as u
from astropy.coordinates import SkyCoord

import sunpy.map

from sunkit_magex import pfss

###############################################################################
Expand Down
6 changes: 4 additions & 2 deletions examples/using_pfsspy/plot_hmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Calculating a PFSS solution from a HMI synoptic map.
This example shows how to calcualte a PFSS solution from a HMI synoptic map.
This example shows how to calculate a PFSS solution from a HMI synoptic map.
There are a couple of important things that this example shows:
- HMI maps have non-standard metadata, so this needs to be fixed
Expand All @@ -13,8 +13,10 @@
"""
import os

import astropy.units as u
import matplotlib.pyplot as plt

import astropy.units as u

import sunpy.map
from sunpy.net import Fido
from sunpy.net import attrs as a
Expand Down
8 changes: 5 additions & 3 deletions examples/using_pfsspy/plot_open_closed_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
Creating an open/closed field map on the solar surface.
"""
import astropy.constants as const
import astropy.units as u
import matplotlib.colors as mcolor
import matplotlib.pyplot as plt
import numpy as np
import sunpy.map

import astropy.constants as const
import astropy.units as u
from astropy.coordinates import SkyCoord

import sunpy.map

from sunkit_magex import pfss

###############################################################################
Expand Down
6 changes: 3 additions & 3 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[pytest]
minversion = 7.0
testpaths =
sunkit_magex
docs
sunkit_magex
docs
norecursedirs =
.tox
build
Expand All @@ -26,7 +26,7 @@ filterwarnings =
# add a comment or ideally a link to an issue that explains why the warning
# is being ignored
ignore:numpy.ndarray size changed, may indicate binary incompatibility:RuntimeWarning
# This seems to be a transitive faliure we should investigate
# This seems to be a transitive failure we should investigate
ignore:unclosed event loop:ResourceWarning
# https://github.com/pytest-dev/pytest-cov/issues/557
# It was fixed and released but it does not seem to be fixed
Expand Down
6 changes: 1 addition & 5 deletions sunkit_magex/pfss/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Import this to register map sources
import sunkit_magex.pfss.map as _
from sunkit_magex.pfss import coords
from sunkit_magex.pfss import fieldline
from sunkit_magex.pfss import sample_data
from sunkit_magex.pfss import tracing
from sunkit_magex.pfss import utils
from sunkit_magex.pfss import coords, fieldline, sample_data, tracing, utils
from sunkit_magex.pfss.input import Input
from sunkit_magex.pfss.output import Output
from sunkit_magex.pfss.pfss import pfss
Expand Down
7 changes: 4 additions & 3 deletions sunkit_magex/pfss/analytic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
Using this module requires ``sympy`` to be installed.
"""

import astropy.units as u
import numpy as np
import scipy.special
import sympy

import astropy.units as u


@u.quantity_input
def _normalise_angles(theta: u.deg, phi: u.deg):
Expand All @@ -36,7 +37,7 @@ def _normalise_angles(theta: u.deg, phi: u.deg):

def _Ynm(l, m, theta, phi): # NOQA: E741
"""
Return values of spherical harmonic with numbers l, m at coordiantes
Return values of spherical harmonic with numbers l, m at coordinates
theta, phi.
"""
# Note swapped arguments phi, theta, as scipy has a different
Expand Down Expand Up @@ -73,7 +74,7 @@ def _spherical_harmonic_sympy(l, m): # NOQA: E741
theta, phi = sympy.symbols('theta, phi')
harm = sympy.Ynm(L, M, theta, phi)
if m < 0:
# Phase shift to align definition of Ymn with defnition in paper.
# Phase shift to align definition of Ymn with definition in paper.
harm *= -1j
harm = harm.subs([(L, l), (M, m)])
return harm, theta, phi
Expand Down

0 comments on commit fa2107c

Please sign in to comment.