Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.yml]
[*.{yaml,yml,toml}]
indent_style = space
indent_size = 2
27 changes: 0 additions & 27 deletions .flake8

This file was deleted.

2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ known_sunpy = sunpy
known_first_party = radiospectra
length_sort = false
length_sort_sections = stdlib
line_length = 110
line_length = 120
multi_line_output = 3
no_lines_before = LOCALFOLDER
sections = STDLIB, THIRDPARTY, ASTROPY, SUNPY, FIRSTPARTY, LOCALFOLDER
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
repos:
# This should be before any formatting hooks like isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.14.14"
rev: "v0.15.2"
hooks:
- id: ruff
- id: ruff-check
args: ["--fix"]
- id: ruff-format
- repo: https://github.com/PyCQA/isort
rev: 7.0.0
rev: 8.0.0
hooks:
- id: isort
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|radiospectra/extern)$"
Expand Down
20 changes: 0 additions & 20 deletions .readthedocs.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
elif _version.is_devrelease:
version = release = f"{_version.base_version}.dev{_version.dev}"
is_development = _version.is_devrelease
is_release = not(_version.is_prerelease or _version.is_devrelease)
is_release = not (_version.is_prerelease or _version.is_devrelease)

project = "radiospectra"
author = "The SunPy Community"
Expand Down
21 changes: 0 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,6 @@ exclude = ["radiospectra._dev*"]
[tool.setuptools_scm]
version_file = "radiospectra/_version.py"

[tool.black]
line-length = 120
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs
| \.git
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| docs
| .history
)/
)
'''

[tool.gilesbot]
[tool.gilesbot.pull_requests]
enabled = true
Expand Down
1 change: 0 additions & 1 deletion radiospectra/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from .version import version as __version__

__all__ = ["__version__"]
4 changes: 2 additions & 2 deletions radiospectra/_dev/scm_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
try:
from setuptools_scm import get_version

version = get_version(root=Path('../..'), relative_to=__file__)
version = get_version(root=Path("../.."), relative_to=__file__)
except ImportError:
raise
except Exception as e:
raise ValueError('setuptools_scm can not determine version.') from e
raise ValueError("setuptools_scm can not determine version.") from e
8 changes: 6 additions & 2 deletions radiospectra/net/sources/eovsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ class EOVSAClient(GenericClient):
<BLANKLINE>
<BLANKLINE>
"""

from sunpy import __version__

if __version__ >= "6.1.0":
pattern = ("https://ovsa.njit.edu/fits/synoptic/{{year:4d}}/{{month:2d}}/{{day:2d}}/"
"EOVSA_{{PolType:5l}}_{{year:4d}}{{month:2d}}{{day:2d}}.fts")
pattern = (
"https://ovsa.njit.edu/fits/synoptic/{{year:4d}}/{{month:2d}}/{{day:2d}}/"
"EOVSA_{{PolType:5l}}_{{year:4d}}{{month:2d}}{{day:2d}}.fts"
)
else:
baseurl = "https://ovsa.njit.edu/fits/synoptic/%Y/%m/%d/EOVSA_.*_%Y%m%d.fts"
pattern = "{}/synoptic/{year:4d}/{month:2d}/{day:2d}/EOVSA_{PolType:5l}_{year:4d}{month:2d}{day:2d}.fts"
Expand Down
2 changes: 1 addition & 1 deletion radiospectra/net/sources/tests/test_ilofar.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_ilofar_client_polarisation(mock_urlopen, client, html_responses):
assert query_x[0]["Source"] == "ILOFAR"
assert query_x[0]["Provider"] == "ILOFAR"
assert query_x[0]["Start Time"].iso == "2018-06-01 10:00:41.000"
assert query_x[0]["Polarisation"] =='X'
assert query_x[0]["Polarisation"] == "X"


@mock.patch("sunpy.net.scraper.urlopen")
Expand Down
4 changes: 2 additions & 2 deletions radiospectra/net/sources/tests/test_psp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def test_search_with_wavelength(mock_urlopen, client, http_responces):

@pytest.mark.remote_data
def test_get_url_for_time_range(client):
url_start = "https://spdf.gsfc.nasa.gov/pub/data/psp/fields/l2/rfs_lfr/2019/" "psp_fld_l2_rfs_lfr_20191001_v03.cdf"
url_end = "https://spdf.gsfc.nasa.gov/pub/data/psp/fields/l2/rfs_hfr/2019/" "psp_fld_l2_rfs_hfr_20191015_v03.cdf"
url_start = "https://spdf.gsfc.nasa.gov/pub/data/psp/fields/l2/rfs_lfr/2019/psp_fld_l2_rfs_lfr_20191001_v03.cdf"
url_end = "https://spdf.gsfc.nasa.gov/pub/data/psp/fields/l2/rfs_hfr/2019/psp_fld_l2_rfs_hfr_20191015_v03.cdf"
tr = a.Time("2019/10/01", "2019/10/15")
res = client.search(tr)
urls = [i["url"] for i in res]
Expand Down
7 changes: 4 additions & 3 deletions radiospectra/spectrogram/sources/tests/test_solo_rpw.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
def test_solo_rpw_tnr(parse_path_moc):
start_time = Time("2024-03-23 00:00:00.000")
end_time = Time("2024-03-24 00:00:00.000")

# fmt: off
meta = {
"cdf_meta": {
"Project": "SOLO>Solar Orbiter",
Expand Down Expand Up @@ -51,7 +51,7 @@ def test_solo_rpw_tnr(parse_path_moc):
634525, 662618, 691955, 722590, 754582, 787990, 822878, 859310, 897355,
937084, 978572]) * u.Hz,
}

# fmt: on

array = np.zeros((128, 7322))
parse_path_moc.return_value = [(array, meta)]
Expand All @@ -74,6 +74,7 @@ def test_solo_rpw_hfr(parse_path_moc):
start_time = Time("2024-03-23 00:00:00.000")
end_time = Time("2024-03-24 00:00:00.000")

# fmt: off
meta = {
"cdf_meta": {
"Project": "SOLO>Solar Orbiter",
Expand All @@ -100,7 +101,7 @@ def test_solo_rpw_hfr(parse_path_moc):
13375000, 13725000, 14375000, 14925000, 15275000, 15625000,
16075000, 16325000]) * u.Hz,
}

# fmt: on

array = np.zeros((50, 16499))
parse_path_moc.return_value = [(array, meta)]
Expand Down
23 changes: 10 additions & 13 deletions radiospectra/spectrogram/spectrogram_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,24 +441,21 @@ def _read_cdf(file):
"freqs": freqs,
}
return data, meta
elif ("SOLO" in cdf_globals.get("Project", "")[0]):
elif "SOLO" in cdf_globals.get("Project", "")[0]:
data_type = cdf_globals.get("Data_type", [""])[0]
data_descriptor = cdf_globals.get("Descriptor", "")[0]
if ("RPW-HFR-SURV" not in data_descriptor
and "RPW-TNR-SURV-FLUX" not in data_descriptor):
raise ValueError(
f"Currently radiospectra supports Level 2 HFR survey data "
"and Level 3 HFR, TNR survey data the file "
f'{file.name} is {cdf_globals.get("Logical_source_description", [""])[0]}'
)
if("L3" in data_type):
if "RPW-HFR-SURV" not in data_descriptor and "RPW-TNR-SURV-FLUX" not in data_descriptor:
raise ValueError(
f"Currently radiospectra supports Level 2 HFR survey data "
"and Level 3 HFR, TNR survey data the file "
f"{file.name} is {cdf_globals.get('Logical_source_description', [''])[0]}"
)
if "L3" in data_type:
epoch = cdf.varget("Epoch")
times = Time("J2000.0") + epoch * u.ns
freqs = cdf.varget("FREQUENCY") << u.Unit(
cdf.varattsget("FREQUENCY")["UNITS"]
)
freqs = cdf.varget("FREQUENCY") << u.Unit(cdf.varattsget("FREQUENCY")["UNITS"])
data = cdf.varget("PSD_SFU")
data = np.squeeze(data).T << sfu
data = np.squeeze(data).T << sfu
detector = cdf_globals.get("Instrument", [""])[0].split(">")[0]
meta = {
"cdf_globals": cdf_globals,
Expand Down
79 changes: 79 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
target-version = "py312"
line-length = 120
exclude = [
".git,",
"__pycache__",
"build",
"radiospectra/version.py",
]

[lint]
select = [
"E",
"F",
"W",
"UP",
"PT",
"BLE",
"A",
"C4",
"INP",
"PIE",
"T20",
"RET",
"TID",
"PTH",
"PD",
"PLC",
"PLE",
"FLY",
"NPY",
"PERF",
"RUF",
]
extend-ignore = [
# pycodestyle (E, W)
"E501", # ignore line length will use a formatter instead
# pytest (PT)
"PT001", # Always use pytest.fixture()
"PT023", # Always use () on pytest decorators
# flake8-pie (PIE)
"PIE808", # Disallow passing 0 as the first argument to range
# flake8-use-pathlib (PTH)
"PTH123", # open() should be replaced by Path.open()
# Ruff (RUF)
"RUF003", # Ignore ambiguous quote marks, doesn't allow ' in comments
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF013", # PEP 484 prohibits implicit `Optional`
"RUF015", # Prefer `next(iter(...))` over single element slice
]

[lint.per-file-ignores]
"setup.py" = [
"INP001", # File is part of an implicit namespace package.
]
"conftest.py" = [
"INP001", # File is part of an implicit namespace package.
]
"docs/conf.py" = [
"E402" # Module imports not at top of file
]
"docs/*.py" = [
"INP001", # File is part of an implicit namespace package.
]
"examples/**.py" = [
"T201", # allow use of print in examples
"INP001", # File is part of an implicit namespace package.
]
"__init__.py" = [
"E402", # Module level import not at top of cell
"F401", # Unused import
"F403", # from {name} import * used; unable to detect undefined names
"F405", # {name} may be undefined, or defined from star imports
]
"test_*.py" = [
"E402", # Module level import not at top of cell
]

[lint.pydocstyle]
convention = "numpy"