Code Monkey home page Code Monkey logo

sunpy's Introduction

sunpy

SunPy Logo

Release Development Community
Latest PyPi Version Python Versions Matrix Chat Room
Latest Conda Version Project Status: Active OpenAstronomy Discourse
Zenodo - Latest DOI Continuous Integration Status Google Groups Mailing List
sunpy stable documentation CodeCov Code Coverage Powered by NumFOCUS
sunpy citation   pyOpenSci

sunpy is a Python software package that provides fundamental tools for accessing, loading and interacting with solar physics data in Python. It includes an interface for searching and downloading data from multiple data providers, data containers for image and time series data, commonly used solar coordinate frames and associated transformations, as well as other functionality needed for solar data analysis.

Installation

We recommended following the installation guide in the sunpy documentation. This will walk you through installing sunpy and all of its dependencies.

Usage

If you are new to sunpy, the best place to start is the tutorial. the example gallery also includes a collection of shorter and more specific examples of using sunpy.

Changes

See our changelog. for the latest changes in sunpy.

Getting Help

For more information or to ask questions about sunpy or any other SunPy Project package, please check out:

Acknowledging or Citing sunpy

If you use sunpy in your scientific work, we would appreciate your citing it in your publications. The continued growth and development of sunpy is dependent on the community being aware of sunpy.

Contributing

The SunPy Project is a community-driven open-source project that welcomes any and all contributions. Whether you are a developer, student, or user, you can help by contributing code, documentation, or community support.

If you would like to get involved, the Newcomers Guide guide explains the many different ways to contribute to the SunPy Project and also shows how to get set up with a development workflow.

Help is always welcome, so come and say hello by joining the SunPy Chat and look over the Good First Issues list for the ideal places to start.

Code of Conduct

When you are interacting with the SunPy Community you are asked to follow our Code of Conduct.

sunpy's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sunpy's Issues

Create a DifferenceMap and DifferenceSequence class

Create a DifferenceMap class which gets returned when one Map is subtracted from another.

Basic features could include:

  • headers for im1 and im2
  • start_date
  • end_date
  • duration (timedelta)
  • grayscale color table

Also a more useful thing from my perspective is a difference sequence, that could be fed a difference map and then does running or from first frame differences.

To do all of this we need coordinate aware differencing which we do not have currently inside maps, which requires we have a better WCS implementation

Matplotlib windows opened unexpectedly when running in ipython with --pylab

Matplotlib windows are opened unexpectedly when running in ipython with --pylab.
For example

sunpy.Map(sunpy.AIA_171_IMAGE).plot()

or

from sunpy.gui import Plotman
Plotman(sunpy.AIA_171_IMAGE)

will open matplotlib windows where they shouldn't under a "pure" python environment.

This option can be checked for and "fixed" using the following code. Which I would suggest should be added to sunpy/init.py

if plt.isinteractive(): plt.ioff()

However, this could cause unexpected behaviour for the user when using other packages, so alternatively it could be turned on/off at the start/end of methods that would cause matplotlib windows to show.

Thanks to dead_zero for investigating this and finding the above solution.

Maps should assume that files are FITS if there is no file extension

The new maps.io checks the file extension to see whether the file is a FITS file. Many fits files (such as those downloaded from the VSO) do not have a .fits file extension so we should probably not use the file extension to identify files. Maybe by default just try to open the file with pyfits.

Add more coherent set of test files

Currently the test files are rather random. This should be fixed. Here are some useful requirements

  • Two AIA files in the same band which follow each other time so you can test a difference map. Should be a flare occurring during these files (see next requirement).
  • One RHESSI image with the same time as the AIA image so it can be overplotted on top of one of the AIA images.
  • A coronagraph image at the same time as the AIA image so it can be aligned with the AIA images.
  • The RHESSI calibrated event list should be the same data as the data that was used to create the RHESSI fits image file.
    Any other ideas out there?

Add support for user customization using a sunpyrc file.

There is a need to be able to define certain defaults when running SunPy. This could be handled by providing the user with a customizable file such as a sunpyrc. Some examples of parameters that might be set in this file.

  • default download directory
  • default plotting behavior such as plotting the solar limb and solar parallels and meridians.

Please comment to suggest more!

Update docs to avoid generating Sphinx errors

The code reference section of the documentation for SunPy currently generates about 25 warnings relating to the autodoc module on a clean run. Ideally, no warnings should be generated during the documentation building.

Example error:

[u'Results(callback, n=0, done=None)', u':module: sunpy.net.vso', u'', u'', u'', u'Returned by VSOClient.get. Use .wait to wait', u'for completion of download.', u'', u'', u'.. rubric:: Methods', u'', u'.. autosummary::', u' :toctree:', u'', u' add_error', u' poke', u' require', u' submit', u' wait', u'', u'', u'.. py:method:: Results.wait()', u' :module: sunpy.net.vso', u'', u' ', u' ', u' Wait for result to be complete and return it. ']:8: (ERROR/3) Unknown directive type "autosummary".

submap does not update the header information

Though the code seems to be in place to update the header information (on lines 309 to 314 in basemap.py) when inspecting the final map the header is not updated. Perhaps the header is not copied into the new map? Here is some code.

aia = sunpy.Map(sunpy.AIA_171_IMAGE)
aia_small = aia.submap([-200,300], [-200, 300], units = 'arcseconds')
aia_small.yrange

result is [-250.80000000000004, 248.39999999999995]
aia_small.xrange
result is [-250.80000000000004, 248.39999999999995]
aia_small.header.get('naxis1')
result is 1024

Prevent Plotman from throwing error when all tabs are closed

If all of the tabs in Plotman are closed, and error is thrown:


AttributeError Traceback (most recent call last)

/home/hughitt1/sunpy/sunpy/gui/mainwindow.py in on_tabWidget_currentChanged(self)
39 @pyqtSignature("int")
40 def on_tabWidget_currentChanged(self):
---> 41 self.refresh_color_options()
42
43 @pyqtSignature("int")

/home/hughitt1/sunpy/sunpy/gui/mainwindow.py in refresh_color_options(self)
105 def refresh_color_options(self):
106 """ Set widgets according to focused plot's properties. """
--> 107 self.clipMinDoubleSpinBox.setValue(self.current_tab.canvas.vmin)
108 self.clipMaxDoubleSpinBox.setValue(self.current_tab.canvas.vmax)
109

AttributeError: 'NoneType' object has no attribute 'canvas'

AttributeError Traceback (most recent call last)

/home/hughitt1/sunpy/sunpy/gui/mainwindow.py in on_tabWidget_currentChanged(self)
39 @pyqtSignature("int")
40 def on_tabWidget_currentChanged(self):
---> 41 self.refresh_color_options()
42
43 @pyqtSignature("int")

/home/hughitt1/sunpy/sunpy/gui/mainwindow.py in refresh_color_options(self)
105 def refresh_color_options(self):
106 """ Set widgets according to focused plot's properties. """
--> 107 self.clipMinDoubleSpinBox.setValue(self.current_tab.canvas.vmin)
108 self.clipMaxDoubleSpinBox.setValue(self.current_tab.canvas.vmax)
109

AttributeError: 'NoneType' object has no attribute 'canvas'

Map.show() broken with Matplotlib 1.2.x

In the most recent version of Matplotlib (1.2.x) it looks like the "show" method has been removed from Matplotlib figures:

>>> fig
<matplotlib.figure.Figure object at 0xacbb0ac>
>>> fig.show()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Figure' object has no attribute 'show'

An alternative approach should be taken, if possible, that supports both Matplotlib 1.2.x and also earlier versions.

Port developers' guide documentation to git

Currently the developers' guide is written for LaunchPad and bzr. As SunPy is now hosted at GitHub, the documentation should be updated to introduce developers to GitHub and git. In particular, the usage of forking and the pull request system should be included.

Move anytim logic to a separate module

Instead of going in util/util.py, the anytim (and other date-related code) should probably go in a separate module, e.g. util/date.py, util/time.py, or util/anytim.py.

sunpy.Map will not handle multiple HDUs

sunpy.Map has no capability for dealing with FITS files containing multiple HDUs and currently assumes that the user wishes only to deal with the primary HDU.

For example, AIA data from the HEK cutout service is not adequately handled by the current implementation. This should be made more robust using PyFITS methods to determine the number of HDUs and then handle as appropriate.

fits = pyfits.open(input_)
data = fits[0].data  # We cannot always assume fits[0] is the sole/desired HDU.
header = fits[0].header

Automatic normalization of images with map.plot()

The default behavior when using the vanilla plot command should be that the color range is normalized to the data being plotted. This should be set on import of the data using get_properties() as there is a parameter for the map object called norm to hold this information. The current problem is that get_properties() may not have access to the map objects data (to my knowledge). This should be fixed so that norm can be define with something like

'norm': mpl.colors.Normalize(vmin=map.min(), vmax=map.max())

Port basic AIA prep functionality

AIA files available from the VSO are only available as unprepared (level 1.0) data meaning that the standard headers are not yet calculated. We need to port this functionality directly from the existing IDL function aia_prep.pro so that SunPy can read automatically deal with level 1.0 AIA data.

SunPy Docs Cleanup

The Docs need to be cleaned up. The following issues need to be addressed.

  • Break out the python installation instructions for different OSs into their own files.
  • Expand the sunpy installation instructions to include ways besides using git (too hard).
  • Need to add example code for each of the newly developed modules (vso, hek, etc.).

SunPy GUI from CLI

The SunPy GUI (aka plotman) needs to be callable from the command line.

VSO download runaway threads

If a download is begun it may never return never give back control to the interactive console. There is also no way to send it a signal to quit.

Create a MapHeader class to handle header parsing

Currently BaseMap.header uses a PyFITS header object. A better approach would be to create a new class (based on dict) that handles the complexity of parsing FITS, JPEG2000, etc. headers, and can be easily created from scratch for simulations, etc.

Overview:

  1. Subclass dict
  2. Create different readers for handling FITS, JPEG2000, etc. headers
  3. Add methods which normalize certain useful header tags (e.g. rsun, wcs fields, etc)

Add sytem_info to import of util

Running the following import

from sunpy.util import util

does not import system_info() which is very confusing since you can use

import sunpy
sunpy.util.system_info()

The first command should also import system_info.

Have WCS routines check for crval1/2

Some files (e.g. MDI magnetograms) do not have crval1/2. Either an alternative value should be used, or basemap should fall-back on non-WCS based functions.

Confusing and cluttered namespace

There are two related issues with SunPy's organization that should be tackled sooner rather than later.

Confusing hierarchy

SunPy's package/module hierarchy is currently rather confusing. Let's take sunpy.util as an example. Importing sunpy.util means that one accesses the function anytim as

import sunpy.util
sunpy.util.util.anytim(blah)

There are of course ways to map down sunpy.util.util as something more tractable, but I suggest that the various __init__.py files should be set up to pull the functions out from the extra layer. In this case, util\util.py would have the line:

__all__ = ["anytim", etc.]

and util\__init__.py would have the line:

from . util import *

Thus, following an import sunpy.util, the function would now just be sunpy.util.anytim. As an example from NumPy, the function meshgrid has been pulled out from numpy.lib.function_base.meshgrid to be simply numpy.meshgrid.

Cluttered namespace

Regarding the cluttered namespace, I will also use sunpy.util to illustrate. Because util.py has the line import numpy as np at the global level, sunpy.util.util.np now exists. These "extra" packages then show up under tab completion, which seems undesirable. I see two remedies that should both be used, as appropriate:

  • One can avoid imports at the global level, and instead import only within function definitions. The namespace is cleaner, but at the expense of repeated imports if multiple functions in the same module use the same packages.
  • If the aforementioned "pulling out" of functions is implemented, then sunpy.util.util will still be cluttered, but sunpy.util can be kept clean.

VSO downloads: allow directories for path keyword

e.g. "/home/user/" or "{source}/{instrument}/{time.start}/”

In the first case, a default path scheme would be used with /home/user as the root directory. In the second case, the specified path would be used as if "{source}/{instrument}/{time.start}/{file}” were specified.

Add support for reading RHESSI images

We need to add the capability to read in a RHESSI image fits file. Such files may contain multiple images made at different energies or different times which makes them a bit different than regular fits files.

Fix AIA color tables

Top of the color table sometimes shows up as green (for example the aia 193 table). This might occur more often when the image shows bright features.

Rescale images when plotting

Currently, the implementation of BaseMap.plot() does not have any checks regarding image size and will attempt to plot images much larger (e.g. 4k x 4k) than are possible for the screen resolution and available memory.

Since BaseMap.plot() uses matplotlib.pyplot.imshow internally, one possibility would be to try and handle the rescaling there (aspect="auto"?)

Another option would be to use scipy, e.g.:

scipy.misc.imresize(arr, (512,512))

In either case, we could check to see what the screen resolution is and bound the largest dimension to that and rescale the smaller dimension proportionately. We should also provide an option to either manually set the dimensions, or to skip the rescaling and simply display the image as is.

Add support for Python 2.6

When modifying code to support earlier versions, comment out any non-working lines of code and add a note at the top specifying which version is require for that line to work. This way if we decide in the future to increase the version requirements again we can quickly roll-back any changes made now.

Switch to using distribute for deployment

After our discussion with STScI, using distribute instead of distutils looks like it would be a good option for SunPy deployment.

Advantages:

  • Python 3 support (not in setuptools)
  • 2to3 integration
  • Dependency specification

Add EIT color maps

The default EIT color maps are missing in the cm module. They need to be added and coded into soho.py.

BaseMap class cannot be used directly

The BaseMap class itself cannot be used directly (i.e., instead of using one of its derived classes) because both __init__ and __array_finalize__ call self.get_properties(header), but BaseMap only defines get_properties(cls) without defining a get_properties(cls,header). While the latter is defined in all of the derived classes, it seems improper to me for the base class not to be able to initialize itself.

I have currently "fixed" this bug on my own fork by replacing (line 203 of map\basemap.py):

def get_properties(cls):

with

def get_properties(cls, header=None):

Someone else should take a look at the class design to figure out if this or some other fix makes sense. For example, perhaps BaseMap.get_properties should insist on a header argument (i.e., instead of it being optional as I made it), even if it does nothing with it.

An assortment of bugs with VSO queries and gets

I've been playing around with VSO queries and gets, and I've come across some bugs. It's possible some of these bugs are related to my being on Windows. Here is the base code, which successfully retrieves 4 EUVI files and downloads them to a temporary directory:

from sunpy.net import vso

client = vso.VSOClient()

queryresult = client.query(
    vso.attrs.Time((2011, 9, 22, 10, 55), (2011, 9, 22, 11, 00)),
    vso.attrs.Instrument('euvi')
)

result = client.get(queryresult).wait()

First bug: cannot query AIA data

If I instead try to query for AIA data, there is an unceremonious crash.

queryresult = client.query(
    vso.attrs.Time((2011, 9, 22, 10, 55), (2011, 9, 22, 11, 00)),
    vso.attrs.Instrument('aia')
)

Second bug: unexpected behavior of path for get()

To specify the download path, I apparently cannot specify just the folder name, but rather I also need to include {file}. Otherwise, .get() will try to write over the folder itself, which will generate an error, of course. Is this intended/desired behavior?

result = client.get(queryresult, path="c:\\users\\ayshih\\downloads\\{file}").wait()

Third bug: wait() is not aware when get() crashes

If .get() crashes due to a bad specification for path (see above, and possibly for other reasons), the .wait() appears to cause Python to get stuck waiting for a thread that will never finish properly. Control+C does not restore control.

Add menubar to Plotman

Having a standard menu bar (file, edit, etc) as an alternative to the icons would be useful. This way we could also add other things that might not be helpful to have icons for, and perhaps we could let users control which icons are hidden/visible.

Overlays should not change the extent of map.show()

Here is some example code to illustrate the problem.

import sunpy.instr.rhessi as rhessi
import sunpy
map = rhessi.backprojection(sunpy.RHESSI_EVENT_LIST)

Compare the following two plots.

map.show()
map.show(draw_grid = True)

Installation Instructions for SunPy are poor quality

Most of the installation instructions deal with how to install python and the prereqs for sunpy and provide only one method for installing sunpy which is through git. We should provide instructions for other ways to install sunpy since we now have that capability in setup.py. Instructions for installing the prereqs should probably be broken out into its own doc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.