Skip to content

Commit

Permalink
Merge pull request #75 from sunpy/docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nabobalis authored Oct 19, 2022
2 parents d92d8b9 + fd85209 commit 8be9523
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 180 deletions.
20 changes: 0 additions & 20 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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
89 changes: 45 additions & 44 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://docs.sunpy.org/projects/radiospectra/en/latest/whatsnew/changelog.html>`__.

Installation
============
The recommended way to install ``radiospectra`` is with `miniforge <https://github.com/conda-forge/miniforge#miniforge3>`__.
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 <https://github.com/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 <https://docs.sunpy.org/en/stable/guide/installation.html>`__ in the ``sunpy`` docs.

The `latest documentation <https://docs.sunpy.org/projects/radiospectra/en/latest/>`__.
Getting Help
============
For more information or to ask questions about ``radiospectra`` or any other SunPy library, check out:

- `sunpy documentation <https://docs.sunpy.org/projects/radiospectra/en/latest/index.html/>`__
- `SunPy Chat`_
- `SunPy mailing list <https://groups.google.com/forum/#!forum/sunpy>`__

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 <https://github.com/adriennefriend>`_ for a
`PyCon talk <https://www.youtube.com/watch?v=6Uj746j9Heo>`_, and was adapted by
radiospectra based on its use in the README file for the
`MetPy project <https://github.com/Unidata/MetPy>`_.
============
If you would like to get involved, start by joining the `SunPy Chat`_ and check out our `Newcomers' guide <https://docs.sunpy.org/en/latest/dev_guide/contents/newcomers.html>`__.
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 <https://sunpy.org/coc>`__.

.. _SunPy Chat: https://openastronomy.element.io/#/room/#sunpy:openastronomy.org
13 changes: 0 additions & 13 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -67,10 +60,7 @@ stages:
posargs: -n=4
libraries:
apt:
- libopenjp2-7
- graphviz
brew:
- openjpeg
envs:
- macos: py38
- windows: py39
Expand All @@ -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
Expand Down
38 changes: 35 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/conda-forge/miniforge#miniforge3>`__.
To install ``radiospectra`` once miniforge is installed run the following command:

.. code:: bash
$ conda install radiospectra
For detailed installation instructions, see the `installation guide <https://docs.sunpy.org/en/stable/guide/installation.html>`__ in the ``sunpy`` docs.

Getting Help
============
For more information or to ask questions about ``radiospectra`` or any other SunPy library, check out:

- `sunpy documentation <https://docs.sunpy.org/projects/radiospectra/en/latest/index.html/>`__
- `SunPy Chat`_
- `SunPy mailing list <https://groups.google.com/forum/#!forum/sunpy>`__

Contributing
============
If you would like to get involved, start by joining the `SunPy Chat`_ and check out our `Newcomers' guide <https://docs.sunpy.org/en/latest/dev_guide/contents/newcomers.html>`__.
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 <https://sunpy.org/coc>`__.

.. _SunPy Chat: https://openastronomy.element.io/#/room/#sunpy:openastronomy.org

.. toctree::
:maxdepth: 2

guide
overview
code_ref/index
whatsnew/index
64 changes: 25 additions & 39 deletions docs/guide.rst → docs/overview.rst
Original file line number Diff line number Diff line change
@@ -1,48 +1,36 @@
=====
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 <http://www.e-callisto.org/>`__ 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 <http://www.rosseobservatory.ie/>`__ 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

image = CallistoSpectrogram.read(sunpy.data.sample.CALLISTO_SPECTRUM)
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.
Expand All @@ -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

Expand Down Expand Up @@ -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
18 changes: 3 additions & 15 deletions radiospectra/sources/callisto.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import urllib
import datetime
from collections import defaultdict
from distutils.version import LooseVersion

import numpy as np
from bs4 import BeautifulSoup
from scipy.ndimage import gaussian_filter1d
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

Expand All @@ -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)
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 8be9523

Please sign in to comment.