Skip to content

Commit

Permalink
ran precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
nabobalis committed Sep 10, 2024
1 parent d68331d commit 5d6cabc
Show file tree
Hide file tree
Showing 27 changed files with 101 additions and 95 deletions.
10 changes: 6 additions & 4 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
[codespell]
skip = *.asdf,*.fits,*.fts,*.header,*.json,*.xsh,*cache*,*egg*,*extern*,.git,.idea,.tox,_build,*truncated,*.svg,.asv_env,.history
ignore-words-list =
afile,
alog,
datas,
nd,
nin,
observ,
ot,
te,
upto,
afile,
precess,
precessed,
precess
sav,
te,
upto
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author_email": "[email protected]",
"project_url": "https://sunpy.org",
"license": "BSD 3-Clause",
"minimum_python_version": "3.9",
"minimum_python_version": "3.10",
"use_compiled_extensions": "n",
"enable_dynamic_dev_versions": "y",
"include_example_code": "n",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
needs: [core]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
default_python: '3.10'
default_python: '3.12'
submodules: false
pytest: false
toxdeps: tox-pypi-filter
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ sunkit_instruments/_version.py
.history
*.orig
.tmp
requirements-min.txt

# Example files
dr_suvi-l2-thmap_g16_s20220101T000000Z_e20220101T000400Z_v1-0-2.fits
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Breaking Changes
Backwards Incompatible Changes
------------------------------

- This removes the older verison of `sunkit_instruments.goes_xrs.calculate_temperature_em` that no longer works for the re-processed netcdf files and new GOES-R data.
- This removes the older version of `sunkit_instruments.goes_xrs.calculate_temperature_em` that no longer works for the re-processed netcdf files and new GOES-R data.

This also removes the `sunkit_instruments.goes_xrs.calculate_radiative_loss_rate` and `sunkit_instruments.goes_xrs.calculate_xray_luminosity` functions that also no longer work in their current form.

Expand Down
5 changes: 3 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@
default_role = "obj"

# -- Options for HTML output ---------------------------------------------------

from sunpy_sphinx_theme import PNG_ICON

html_theme = "sunpy"
from sunpy_sphinx_theme import *

# -- Other options ----------------------------------------------------------

Expand All @@ -128,7 +130,6 @@
"examples_dirs": os.path.join("..", "examples"),
"gallery_dirs": os.path.join("generated", "gallery"),
"matplotlib_animations": True,
# Comes from the theme.
"default_thumb_file": PNG_ICON,
"abort_on_example_error": False,
"plot_gallery": "True",
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Once you have that virtual environment, you will want to fork the repo and then
whatsnew/index


Note that the code in this package is **not** maintained by or neccesarily contributed to by instrument teams.
Note that the code in this package is **not** maintained by or necessarily contributed to by instrument teams.
Some instruments have individual packages for analysis in Python, including:

- `aiapy <https://aiapy.readthedocs.io/>`__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

import matplotlib.pyplot as plt

from sunpy import timeseries as ts
from sunpy.data.sample import GOES_XRS_TIMESERIES

Expand Down
3 changes: 2 additions & 1 deletion examples/plot_suvi_thematic_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
"""

import matplotlib.pyplot as plt
from astropy.io import fits
from matplotlib.colors import ListedColormap
from matplotlib.patches import Patch
from parfive import Downloader

from astropy.io import fits

from sunkit_instruments.suvi._variables import SOLAR_CLASS_NAME, SOLAR_COLORS

###############################################################################
Expand Down
27 changes: 3 additions & 24 deletions sunkit_instruments/__init__.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
"""
Sunkit-instruments
sunkit-instruments
==================
A SunPy-affiliated package for solar instrument-specific tools.
A SunPy Affiliated Package for solar instrument-specific tools.
* Homepage: https://sunpy.org
* Documentation: https://docs.sunpy.org/projects/sunkit-instruments/en/latest/
* Source code: https://github.com/sunpy/sunkit-instruments
"""

import sys

from .version import version as __version__ # NOQA

# Enforce Python version check during package import.
__minimum_python_version__ = "3.7"


class UnsupportedPythonError(Exception):
"""
Running on an unsupported version of Python.
"""


if sys.version_info < tuple(int(val) for val in __minimum_python_version__.split(".")):
# This has to be .format to keep backwards compatibly.
raise UnsupportedPythonError(
"sunkit_instruments does not support Python < {}".format(
__minimum_python_version__
)
)
from .version import version as __version__

__all__ = ["__version__"]
2 changes: 1 addition & 1 deletion sunkit_instruments/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ def func(mocked):
mocker.patch(mocked, cache)
return cache

yield func
return func
4 changes: 2 additions & 2 deletions sunkit_instruments/data/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
This package contains all of sunkit-instruments's test data.
"""

import fnmatch
import glob
import os
import re
import glob
import fnmatch

from astropy.utils.data import get_pkg_data_filename

Expand Down
16 changes: 8 additions & 8 deletions sunkit_instruments/fermi/fermi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
(FGST), formerly called the Gamma-ray Large Area Space Telescope (GLAST).
"""

import copy
import os
import tempfile
import copy
import urllib
import tempfile
from collections import OrderedDict

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

import astropy.units as u
from astropy.coordinates import Latitude, Longitude
from astropy.io import fits
from astropy.time import TimeDelta

from sunpy.coordinates import sun
from sunpy.time import TimeRange, parse_time
from sunpy.time.time import _variables_for_parse_time_docstring
Expand Down Expand Up @@ -249,9 +251,7 @@ def plot_detector_sun_angles(angles):
plt.plot(
angle_times,
angles[n].value,
label="{lab} ({val})".format(
lab=n, val=str(np.mean(angles[n].value))[0:5]
),
label=f"{n} ({str(np.mean(angles[n].value))[0:5]})",
)
plt.ylim(180, 0)
plt.ylabel("angle (degrees)")
Expand Down Expand Up @@ -434,7 +434,7 @@ def nai_detector_radecs(detectors, scx, scz, time):
# For each detector, do the rotation depending on the detector zenith and
# azimuth angles.
detector_radecs = copy.deepcopy(detectors)
for l, d in detectors.items():
for l, d in detectors.items(): # NOQA: E741
phi = d[0].value
theta = d[1].value

Expand Down Expand Up @@ -507,7 +507,7 @@ def get_detector_separation_angles(detector_radecs, sunpos):
<Latitude 22.66 deg>]``
"""
angles = copy.deepcopy(detector_radecs)
for l, d in detector_radecs.items():
for l, d in detector_radecs.items(): # NOQA: E741
if not l == "time":
angle = separation_angle(d, sunpos)
angles[l] = angle
Expand Down
6 changes: 4 additions & 2 deletions sunkit_instruments/fermi/tests/test_fermi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import astropy.units as u
import pytest
from numpy.testing import assert_almost_equal

import astropy.units as u

from sunpy.time import parse_time

from sunkit_instruments import fermi
Expand Down Expand Up @@ -47,7 +49,7 @@ def test_detector_angles_2(pointing_file):
parse_time("2012-02-15 02:00"), pointing_file[1]
)
assert len(det2) == 13
assert type(det2) == dict
assert isinstance(det2, dict)
assert_almost_equal(det2["n0"].value, 83.54, decimal=1)
assert_almost_equal(det2["n1"].value, 66.50, decimal=1)
assert_almost_equal(det2["n10"].value, 123.39, decimal=1)
Expand Down
6 changes: 4 additions & 2 deletions sunkit_instruments/goes_xrs/goes_chianti_tem.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import numpy as np
import pandas as pd
from scipy import interpolate

from astropy import units as u
from astropy.io import fits
from astropy.time import Time
from scipy import interpolate

from sunpy import timeseries as ts
from sunpy.data import manager
from sunpy.time import parse_time
Expand Down Expand Up @@ -113,7 +115,7 @@ def calculate_temperature_em(goes_ts, abundance="coronal"):
output = _chianti_temp_emiss(goes_ts, satellite_number, abundance=abundance)

# Check if the older files are passed, and if so then the scaling factor needs to be removed.
# The newer netcdf files now return "true" fluxes so this SWPC factor doesnt need to be removed.
# The newer netcdf files now return "true" fluxes so this SWPC factor doesn't need to be removed.
else:
if ("Origin" in goes_ts.meta.metas[0]) and (
goes_ts.meta.metas[0].get("Origin") == "SDAC/GSFC"
Expand Down
7 changes: 4 additions & 3 deletions sunkit_instruments/goes_xrs/goes_xrs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import numpy as np

from astropy import units as u

from sunpy.time import parse_time

GOES_CONVERSION_DICT = {
Expand Down Expand Up @@ -110,10 +112,9 @@ def flareclass_to_flux(flareclass):
>>> flareclass_to_flux('X2.4')
<Quantity 0.00024 W / m2>
"""
if not isinstance(flareclass, type("str")):
raise TypeError(f"Input must be a string, not {type(goests)}")
if not isinstance(flareclass, str):
raise TypeError(f"Input must be a string, not {type(flareclass)}")
# TODO should probably make sure the string is in the expected format.

flareclass = flareclass.upper()
# invert the conversion dictionary
# conversion_dict = {v: k for k, v in GOES_CONVERSION_DICT.items()}
Expand Down
39 changes: 21 additions & 18 deletions sunkit_instruments/goes_xrs/tests/test_goes_xrs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import astropy.units as u
import numpy as np
import pytest
from astropy.time import Time
from astropy.units.quantity import Quantity
from numpy.testing import assert_almost_equal, assert_array_equal
from scipy.io import readsav

import astropy.units as u
from astropy.time import Time
from astropy.units.quantity import Quantity

from sunpy import timeseries
from sunpy.time import TimeRange, is_time_equal, parse_time
from sunpy.util.exceptions import SunpyUserWarning
Expand Down Expand Up @@ -37,11 +39,12 @@ def test_calculate_temperature_em(goes_files, max_temperature):
# check that it returns a timeseries
assert isinstance(goes_temp_em, timeseries.GenericTimeSeries)
# check that both temperature and emission measure in the columns
assert "temperature" and "emission_measure" in goes_temp_em.columns
assert "temperature" in goes_temp_em.columns
assert "emission_measure" in goes_temp_em.columns
# check units
assert goes_temp_em.units["emission_measure"].to(u.cm**-3) == 1
assert goes_temp_em.units["temperature"].to(u.MK) == 1
# check time index isnt changed
# check time index isn't changed
assert np.all(goeslc.time == goes_temp_em.time)

assert u.allclose(
Expand Down Expand Up @@ -149,34 +152,34 @@ def test_goes_event_list():
trange = TimeRange("2011-06-07 00:00", "2011-06-08 00:00")
# Test case where GOES class filter is applied
result = goes.get_goes_event_list(trange, goes_class_filter="M1")
assert type(result) == list
assert type(result[0]) == dict
assert type(result[0]["event_date"]) == str
assert type(result[0]["goes_location"]) == tuple
assert isinstance(result, list)
assert isinstance(result[0], dict)
assert isinstance(result[0]["event_date"], str)
assert isinstance(result[0]["goes_location"], tuple)
assert isinstance(result[0]["peak_time"], Time)
assert isinstance(result[0]["start_time"], Time)
assert isinstance(result[0]["end_time"], Time)
assert type(result[0]["goes_class"]) == str
assert type(result[0]["noaa_active_region"]) == np.int64
assert isinstance(result[0]["goes_class"], str)
assert isinstance(result[0]["noaa_active_region"], np.int64)
assert result[0]["event_date"] == "2011-06-07"
assert result[0]["goes_location"] == (54, -21)
# float errror
# float error
assert is_time_equal(result[0]["start_time"], parse_time((2011, 6, 7, 6, 16)))
assert is_time_equal(result[0]["peak_time"], parse_time((2011, 6, 7, 6, 41)))
assert is_time_equal(result[0]["end_time"], parse_time((2011, 6, 7, 6, 59)))
assert result[0]["goes_class"] == "M2.5"
assert result[0]["noaa_active_region"] == 11226
# Test case where GOES class filter not applied
result = goes.get_goes_event_list(trange)
assert type(result) == list
assert type(result[0]) == dict
assert type(result[0]["event_date"]) == str
assert type(result[0]["goes_location"]) == tuple
assert isinstance(result, list)
assert isinstance(result[0], dict)
assert isinstance(result[0]["event_date"], str)
assert isinstance(result[0]["goes_location"], tuple)
assert isinstance(result[0]["peak_time"], Time)
assert isinstance(result[0]["start_time"], Time)
assert isinstance(result[0]["end_time"], Time)
assert type(result[0]["goes_class"]) == str
assert type(result[0]["noaa_active_region"]) == np.int64
assert isinstance(result[0]["goes_class"], str)
assert isinstance(result[0]["noaa_active_region"], np.int64)
assert result[0]["event_date"] == "2011-06-07"
assert result[0]["goes_location"] == (54, -21)
assert is_time_equal(result[0]["start_time"], parse_time((2011, 6, 7, 6, 16)))
Expand Down
2 changes: 1 addition & 1 deletion sunkit_instruments/iris/iris.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def SJI_to_sequence(filename, start=0, stop=None, hdu=0):
File to read.
start: `int`, optional
Temporal axis index to create `~sunpy.map.MapSequence` from.
Defaults to 0, which will start from the begining.
Defaults to 0, which will start from the beginning.
stop: `int`, optional
Temporal index to stop `~sunpy.map.MapSequence` at.
Defaults to `None`, which will use the entire index.
Expand Down
1 change: 1 addition & 0 deletions sunkit_instruments/iris/tests/test_iris.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import pytest

import sunpy.map

from sunkit_instruments import iris
Expand Down
Loading

0 comments on commit 5d6cabc

Please sign in to comment.