From eb1311e46d29fdaed839c7b2b77c31bf424b1aae Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Wed, 19 Oct 2022 16:02:45 -0700 Subject: [PATCH 1/3] tidy up readme and docs a bit --- MANIFEST.in | 20 ------- README.rst | 89 ++++++++++++++++---------------- docs/index.rst | 38 ++++++++++++-- docs/{guide.rst => overview.rst} | 64 +++++++++-------------- setup.cfg | 26 +--------- setup.py | 7 ++- 6 files changed, 113 insertions(+), 131 deletions(-) rename docs/{guide.rst => overview.rst} (72%) diff --git a/MANIFEST.in b/MANIFEST.in index 7835417..b4c59a5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,23 +1,3 @@ -include README.rst -include CHANGES.rst -include setup.cfg -include LICENSE.rst -include pyproject.toml - -recursive-include radiospectra *.pyx *.c *.pxd -recursive-include docs * -recursive-include licenses * -recursive-include cextern * -recursive-include scripts * -recursive-include **tests/data/* -recursive-include tests/data/* - -prune build -prune docs/_build -prune docs/api - -global-exclude *.pyc *.o - # This subpackage is only used in development checkouts and should not be # included in built tarballs prune radiospectra/_dev diff --git a/README.rst b/README.rst index 929da3f..6ba1c50 100644 --- a/README.rst +++ b/README.rst @@ -1,52 +1,53 @@ -Provide support for some type of radio spectra in solar physics ---------------------------------------------------------------- - -.. image:: http://img.shields.io/badge/powered%20by-SunPy-orange.svg?style=flat +**************** +``radiospectra`` +**************** + +|Latest Version| |matrix| |codecov| |Powered by NumFOCUS| |Powered by SunPy| + +.. |Latest Version| image:: https://img.shields.io/pypi/v/radiospectra.svg + :target: https://pypi.python.org/pypi/radiospectra/ +.. |matrix| image:: https://img.shields.io/matrix/sunpy:openastronomy.org.svg?colorB=%23FE7900&label=Chat&logo=matrix&server_fqdn=openastronomy.modular.im + :target: https://openastronomy.element.io/#/room/#sunpy:openastronomy.org +.. |codecov| image:: https://codecov.io/gh/sunpy/radiospectra/branch/main/graph/badge.svg + :target: https://codecov.io/gh/sunpy/radiospectra +.. |Binder| image:: https://mybinder.org/badge_logo.svg + :target: https://mybinder.org/v2/gh/sunpy/sunpy/main?filepath=examples +.. |Powered by NumFOCUS| image:: https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A + :target: https://numfocus.org +.. |Powered by SunPy| image:: http://img.shields.io/badge/powered%20by-SunPy-orange.svg?style=flat :target: http://www.sunpy.org :alt: Powered by SunPy Badge -License -------- +``radiospectra`` is a Python software package that provides support for some type of radio spectra in solar physics. + +To see the latest changes in ``radiospectra`` see our `changelog `__. + +Installation +============ +The recommended way to install ``radiospectra`` is with `miniforge `__. +To install ``radiospectra`` once miniforge is installed run the following command: + +.. code:: bash -This project is Copyright (c) SunPy Developers and licensed under -the terms of the BSD 2-Clause license. This package is based upon -the `Openastronomy packaging guide `_ -which is licensed under the BSD 3-clause licence. See the licenses folder for -more information. + $ conda install radiospectra -Documentation -------------- +For detailed installation instructions, see the `installation guide `__ in the ``sunpy`` docs. -The `latest documentation `__. +Getting Help +============ +For more information or to ask questions about ``radiospectra`` or any other SunPy library, check out: + +- `sunpy documentation `__ +- `SunPy Chat`_ +- `SunPy mailing list `__ Contributing ------------- - -We love contributions! radiospectra is open source, -built on open source, and we'd love to have you hang out in our community. - -**Imposter syndrome disclaimer**: We want your help. No, really. - -There may be a little voice inside your head that is telling you that you're not -ready to be an open source contributor; that your skills aren't nearly good -enough to contribute. What could you possibly offer a project like this one? - -We assure you - the little voice in your head is wrong. If you can write code at -all, you can contribute code to open source. Contributing to open source -projects is a fantastic way to advance one's coding skills. Writing perfect code -isn't the measure of a good developer (that would disqualify all of us!); it's -trying to create something, making mistakes, and learning from those -mistakes. That's how we all improve, and we are happy to help others learn. - -Being an open source contributor doesn't just mean writing code, either. You can -help out by writing documentation, tests, or even giving feedback about the -project (and yes - that includes giving feedback about the contribution -process). Some of these contributions may be the most valuable to the project as -a whole, because you're coming to the project with fresh eyes, so you can see -the errors and assumptions that seasoned contributors have glossed over. - -Note: This disclaimer was originally written by -`Adrienne Lowe `_ for a -`PyCon talk `_, and was adapted by -radiospectra based on its use in the README file for the -`MetPy project `_. +============ +If you would like to get involved, start by joining the `SunPy Chat`_ and check out our `Newcomers' guide `__. +This will walk you through getting set up for contributing. + +Code of Conduct +=============== +When you are interacting with the SunPy community you are asked to follow our `Code of Conduct `__. + +.. _SunPy Chat: https://openastronomy.element.io/#/room/#sunpy:openastronomy.org diff --git a/docs/index.rst b/docs/index.rst index 075bc02..37c0e51 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,11 +1,43 @@ +************************** radiospectra Documentation --------------------------- +************************** -This is the documentation for radiospectra. +``radiospectra`` is a Python software package that provides support for some type of radio spectra in solar physics. + +Installation +============ +The recommended way to install ``radiospectra`` is with `miniforge `__. +To install ``radiospectra`` once miniforge is installed run the following command: + +.. code:: bash + + $ conda install radiospectra + +For detailed installation instructions, see the `installation guide `__ in the ``sunpy`` docs. + +Getting Help +============ +For more information or to ask questions about ``radiospectra`` or any other SunPy library, check out: + +- `sunpy documentation `__ +- `SunPy Chat`_ +- `SunPy mailing list `__ + +Contributing +============ +If you would like to get involved, start by joining the `SunPy Chat`_ and check out our `Newcomers' guide `__. +This will walk you through getting set up for contributing. + +Code of Conduct +=============== + +When you are interacting with the SunPy community you are asked to follow our `Code of Conduct `__. + +.. _SunPy Chat: https://openastronomy.element.io/#/room/#sunpy:openastronomy.org .. toctree:: :maxdepth: 2 - guide + overview code_ref/index whatsnew/index diff --git a/docs/guide.rst b/docs/overview.rst similarity index 72% rename from docs/guide.rst rename to docs/overview.rst index 3a12b98..ca4617f 100644 --- a/docs/guide.rst +++ b/docs/overview.rst @@ -1,35 +1,15 @@ -===== -Guide -===== +******** +Overview +******** -Radiospectra is a Python package to enable SunPy to access to radio spectra. - -Installation ------------- - -To install radiospectra you can either use `conda` or `pip`. -Follow the instructions on the `SunPy installation guide`_ to know more about it. - -To install it using `conda`, run:: - - conda install radiospectra - -If you prefer to use `pip` then simply run:: - - pip install radiospectra - -Spectrograms ------------- - -SunPy currently supports reading dynamic spectra from `e-Callisto`_ instruments. +``radiospectra`` currently supports reading dynamic spectra from `e-Callisto `__ instruments. The main class that is used for this is `~radiospectra.sources.callisto.CallistoSpectrogram`. -SunPy also comes with an example image that shows a radio burst observed at `Rosse Observatory`_ that can be found in `sunpy.data.sample.CALLISTO_SPECTRUM`. +``sunpy`` comes with an example image that shows a radio burst observed at `Rosse Observatory `__ that can be found in `sunpy.data.sample.CALLISTO_SPECTRUM`. .. plot:: :include-source: import matplotlib.pyplot as plt - import radiospectra import sunpy.data.sample from radiospectra.sources.callisto import CallistoSpectrogram @@ -37,12 +17,20 @@ SunPy also comes with an example image that shows a radio burst observed at `Ros image.peek() We now notice that there seems to be something interesting that has been cut off at the corner of the image, so we use the extend method to request more data from the server. -It optionally takes the amount of minutes we want to request from the server (negative values mean we want to add data that was registered before our existing local data), if none are given it defaults to 15 minutes (the size of one e-Callisto file):: +It optionally takes the amount of minutes we want to request from the server (negative values mean we want to add data that was registered before our existing local data), if none are given it defaults to 15 minutes (the size of one e-Callisto file): +.. plot:: + :include-source: + + import matplotlib.pyplot as plt + import sunpy.data.sample + from radiospectra.sources.callisto import CallistoSpectrogram + + image = CallistoSpectrogram.read(sunpy.data.sample.CALLISTO_SPECTRUM) more = image.extend() more.peek() -We will, for the purposes of this demonstration, continue working with the original image, though. +We will, for the purposes of this demonstration, continue working with the original image. You can then perform automatic constant background subtraction by using the :meth:`~radiospectra.spectrogram.Spectrogram.subtract_bg` method. The resulting image will be clipped at 0 using the ``min`` parameter of peek in order to avoid negative values. @@ -59,13 +47,12 @@ The resulting image will be clipped at 0 using the ``min`` parameter of peek in nobg = image.subtract_bg() nobg.peek(vmin=0) -If you want to see the background determined by the automatic subtraction, you can use the :meth:`~radiospectra.spectrogram.Spectrogram.auto_const_bg` method and visualize the resulting data using :func:`pyplot.plot` +If you want to see the background determined by the automatic subtraction, you can use the :meth:`~radiospectra.spectrogram.Spectrogram.auto_const_bg` method and visualize the resulting data. .. plot:: :include-source: from matplotlib import pyplot as plt - import sunpy import sunpy.data.sample from radiospectra.sources.callisto import CallistoSpectrogram @@ -107,17 +94,16 @@ To get rid of the noise, we could also clip low intensities by setting vmin interesting = nobg.in_interval("06:27") interesting.peek(vmin=20) -If we want more context, we can also join together different images into a large one in time (note that this does more than just concatenating the array and the axes -- it also considers possible overlap or gaps):: +If we want more context, we can also join together different images into a large one in time (note that this does more than just concatenating the array and the axes -- it also considers possible overlap or gaps): - c1 = CallistoSpectrogram.read('BIR_20110922_101500_01.fit') - c2 = CallistoSpectrogram.read('BIR_20110922_103000_01.fit') - d = CallistoSpectrogram.join_many([c1, c2]) +.. code-block:: python -We could also get the from_range method to get data between those two points directly from the archive and joined together (though that will fetch all frequencies of BIR):: + c1 = CallistoSpectrogram.read('BIR_20110922_101500_01.fit') # doctest: +SKIP + c2 = CallistoSpectrogram.read('BIR_20110922_103000_01.fit') # doctest: +SKIP + d = CallistoSpectrogram.join_many([c1, c2]) # doctest: +SKIP - from radiospectra.sources.callisto import CallistoSpectrogram - d = CallistoSpectrogram.from_range('BIR', '2011-09-22 10:15:00', '2011-09-22 10:45:00') +We could also get the from_range method to get data between those two points directly from the archive and joined together (though that will fetch all frequencies of BIR): + +.. code-block:: python -.. _SunPy installation guide: https://docs.sunpy.org/en/stable/guide/installation/index.html -.. _e-Callisto: http://www.e-callisto.org/ -.. _Rosse Observatory: http://www.rosseobservatory.ie/ + d = CallistoSpectrogram.from_range('BIR', '2011-09-22 10:15:00', '2011-09-22 10:45:00') # doctest: +SKIP diff --git a/setup.cfg b/setup.cfg index aa2002a..75344ce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,7 @@ long_description_content_type = text/x-rst author = The SunPy Community author_email = sunpy@googlegroups.com license = BSD 2-Clause -license_file = LICENSE.rst +license_files = LICENSE.rst url = https://sunpy.org edit_on_github = True github_project = sunpy/radiospectra @@ -79,34 +79,12 @@ filterwarnings = # is being ignored # # - # See https://github.com/spacetelescope/asdf/issues/789 - ignore:direct construction of AsdfSchemaFile has been deprecated - ignore:direct construction of AsdfSchemaItem has been deprecated - ignore:direct construction of AsdfSchemaExampleItem has been deprecated - # See https://github.com/Cadair/parfive/issues/41 - ignore:The loop argument is deprecated # This is due to dependencies building with a numpy version different from # the local installed numpy version, but should be fine # See https://github.com/numpy/numpy/issues/15748#issuecomment-598584838 ignore:numpy.ufunc size changed:RuntimeWarning ignore:numpy.ndarray size changed:RuntimeWarning - # See https://github.com/mvantellingen/python-zeep/issues/956 - ignore:defusedxml.lxml is no longer supported:DeprecationWarning - # See https://github.com/aio-libs/aiohttp/issues/4842 - ignore:"@coroutine" decorator is deprecated - # See https://github.com/spacetelescope/asdf/issues/789 - ignore:direct construction of AsdfSchemaFile has been deprecated - ignore:direct construction of AsdfSchemaItem has been deprecated - ignore:direct construction of AsdfSchemaExampleItem has been deprecated - # See https://github.com/scikit-image/scikit-image/issues/4848 - ignore:Converting `np.inexact` or `np.floating` to a dtype is deprecated - # See https://github.com/astropy/astropy/pull/10570 - ignore:leap-second auto-update failed - # See https://github.com/astropy/extension-helpers/issues/23 - ignore:Distutils was imported before Setuptools - # toolz internal deprecation warning https://github.com/pytoolz/toolz/issues/500 - ignore:The toolz.compatibility module is no longer needed:DeprecationWarning - ignore:distutils Version classes are deprecated. Use packaging.version instead. + [pycodestyle] max_line_length = 100 diff --git a/setup.py b/setup.py index 4d83ca9..ee9f057 100755 --- a/setup.py +++ b/setup.py @@ -3,7 +3,12 @@ import os from itertools import chain -from setuptools.config import read_configuration +try: + # Recommended for setuptools 61.0.0+ + # (though may disappear in the future) + from setuptools.config.setupcfg import read_configuration +except ImportError: + from setuptools.config import read_configuration ################################################################################ # Programmatically generate some extras combos. From e67fc89a0bd0a8abffeab45ae3281ef757929c0d Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Wed, 19 Oct 2022 16:08:24 -0700 Subject: [PATCH 2/3] clean up ci a bit --- azure-pipelines.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6da43e9..6bb4988 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -44,14 +44,7 @@ stages: coverage: codecov toxdeps: tox-pypi-filter posargs: -n=4 - libraries: - apt: - - libopenjp2-7 envs: - - linux: codestyle - name: style_check - pytest: false - libraries: {} - linux: py310 - stage: SecondPhaseTests @@ -67,10 +60,7 @@ stages: posargs: -n=4 libraries: apt: - - libopenjp2-7 - graphviz - brew: - - openjpeg envs: - macos: py38 - windows: py39 @@ -92,9 +82,6 @@ stages: coverage: codecov toxdeps: tox-pypi-filter posargs: -n=4 - libraries: - apt: - - libopenjp2-7 envs: - linux: py310-devdeps - linux: py39-conda From fd85209f9224b5998ebd7620f37cfd87dd5cbfd3 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Wed, 19 Oct 2022 16:19:51 -0700 Subject: [PATCH 3/3] tests --- radiospectra/sources/callisto.py | 18 +++--------------- radiospectra/spectrogram.py | 18 +++--------------- radiospectra/tests/test_callisto.py | 8 ++------ 3 files changed, 8 insertions(+), 36 deletions(-) diff --git a/radiospectra/sources/callisto.py b/radiospectra/sources/callisto.py index 9a0ee86..4c6d8ae 100644 --- a/radiospectra/sources/callisto.py +++ b/radiospectra/sources/callisto.py @@ -1,7 +1,6 @@ import urllib import datetime from collections import defaultdict -from distutils.version import LooseVersion import numpy as np from bs4 import BeautifulSoup @@ -9,7 +8,6 @@ from scipy.optimize import leastsq from astropy.io import fits -from sunpy import __version__ from sunpy.time import parse_time from sunpy.util.net import download_file @@ -19,7 +17,6 @@ __all__ = ["CallistoSpectrogram"] -SUNPY_LT_1 = LooseVersion(__version__) < LooseVersion("1.0") TIME_STR = "%Y%m%d%H%M%S" DEFAULT_URL = "http://soleil.i4ds.ch/solarradio/data/2002-20yy_Callisto/" _DAY = datetime.timedelta(days=1) @@ -107,12 +104,7 @@ def _parse_header_time(date, time): """ if time is not None: date = date + "T" + time - - if SUNPY_LT_1: - time = parse_time(date) - else: - time = parse_time(date).datetime - + time = parse_time(date).datetime return time @@ -384,12 +376,8 @@ def from_range(cls, instrument, start, end, **kwargs): } kw.update(kwargs) - if SUNPY_LT_1: - start = parse_time(start) - end = parse_time(end) - else: - start = parse_time(start).datetime - end = parse_time(end).datetime + start = parse_time(start).datetime + end = parse_time(end).datetime urls = query(start, end, [instrument]) data = list(map(cls.from_url, urls)) freq_buckets = defaultdict(list) diff --git a/radiospectra/spectrogram.py b/radiospectra/spectrogram.py index 2343efa..d7e5a70 100644 --- a/radiospectra/spectrogram.py +++ b/radiospectra/spectrogram.py @@ -6,7 +6,6 @@ from copy import copy from math import floor from random import randint -from distutils.version import LooseVersion import numpy as np from matplotlib import pyplot as plt @@ -16,7 +15,6 @@ from numpy import ma from scipy import ndimage -from sunpy import __version__ from sunpy.time import parse_time from radiospectra.spectrum import Spectrum @@ -24,7 +22,6 @@ __all__ = ["Spectrogram", "LinearTimeSpectrogram"] -SUNPY_LT_1 = LooseVersion(__version__) < LooseVersion("1.0") # 1080 because that usually is the maximum vertical pixel count on modern # screens nowadays (2012). @@ -1131,10 +1128,7 @@ def time_to_x(self, time): """ # This is impossible for frequencies because that mapping # is not injective. - if SUNPY_LT_1: - time = parse_time(time) - else: - time = parse_time(time).datetime + time = parse_time(time).datetime diff = time - self.start diff_s = SECONDS_PER_DAY * diff.days + diff.seconds result = diff_s // self.t_delt @@ -1254,10 +1248,7 @@ def in_interval(self, start=None, end=None): """ if start is not None: try: - if SUNPY_LT_1: - start = parse_time(start) - else: - start = parse_time(start).datetime + start = parse_time(start).datetime except ValueError: # XXX: We could do better than that. if get_day(self.start) != get_day(self.end): @@ -1268,10 +1259,7 @@ def in_interval(self, start=None, end=None): start = self.time_to_x(start) if end is not None: try: - if SUNPY_LT_1: - end = parse_time(end) - else: - end = parse_time(end).datetime + end = parse_time(end).datetime except ValueError: if get_day(self.start) != get_day(self.end): raise TypeError("Time ambiguous because data spans over more than one day") diff --git a/radiospectra/tests/test_callisto.py b/radiospectra/tests/test_callisto.py index b1ef384..3e03f5a 100644 --- a/radiospectra/tests/test_callisto.py +++ b/radiospectra/tests/test_callisto.py @@ -63,24 +63,20 @@ def test_query(): assert URL + item in result -@pytest.mark.xfail +@pytest.mark.remote_data def test_query_number(): - result = list(query(datetime(2011, 9, 22, 5), datetime(2011, 9, 22, 6), {("BIR", 1)})) RESULTS = [ "BIR_20110922_050000_01.fit.gz", "BIR_20110922_051500_01.fit.gz", "BIR_20110922_053000_01.fit.gz", ] - RESULTS.sort() # Should be sorted anyway, but better to assume as little as possible. result.sort() - assert len(result) == len(RESULTS) -@pytest.mark.xfail @pytest.mark.remote_data def test_download(): directory = mkdtemp() @@ -349,7 +345,7 @@ def test_homogenize_rightfq(): @pytest.mark.remote_data -@pytest.mark.skip(reason="Looks like data changed") +@pytest.mark.xfail def test_extend(CALLISTO_IMAGE): im = CallistoSpectrogram.create(CALLISTO_IMAGE) im2 = im.extend()