<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <id>https://sunpy.org/</id>
  <title>Blog - Posts tagged 0.3</title>
  <updated>2026-04-16T16:25:23.389939+00:00</updated>
  <link href="https://sunpy.org/"/>
  <link href="https://sunpy.org/blog/tag/03/atom.xml" rel="self"/>
  <generator uri="https://ablog.readthedocs.io/" version="0.11.13">ABlog</generator>
  <entry>
    <id>https://sunpy.org/posts/2013/2013-08-30-Announcing-SunPy-0.3/</id>
    <title>Announcing SunPy 0.3</title>
    <updated>2013-08-30T00:00:00+00:00</updated>
    <author>
      <name>Stuart Mumford</name>
    </author>
    <content type="html">&lt;section id="announcing-sunpy-0-3"&gt;

&lt;p&gt;It gives me great pleasure to announce the release of a new version of SunPy.
This version has been rather too long in the making, but is here at last!&lt;/p&gt;
&lt;p&gt;SunPy 0.3 is now available through &lt;a class="reference external" href="https://pypi.python.org/pypi/sunpy"&gt;PyPI&lt;/a&gt; and via &lt;a class="reference external" href="https://github.com/sunpy/sunpy/releases/tag/v0.3.0"&gt;GitHub&lt;/a&gt;.
The biggest change in 0.3 is a shift away from our Map and Spectra datatypes inheriting numpy.ndarray to having their array in a &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;data&lt;/span&gt;&lt;/code&gt; attribute.
This was done to make development of these objects easier and more flexible and also to improve our compatibility with Astropy.
In the process of doing this the map submodule has undergone a massive refactor to streamline the creation and inheritance structure of the module.&lt;/p&gt;
&lt;p&gt;Below I highlight some of the major changes, the full change log can be found here.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;The biggest change to the Map API is the deprecation of the &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;make_map&lt;/span&gt;&lt;/code&gt; function. It has been replaced by the new &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;sunpy.Map&lt;/span&gt;&lt;/code&gt; factory which is much more intelligent and able to have custom map sources external to the SunPy library register with it, which is handy if you are developing a custom Map source. Along with this change the old top-level map class Map is now called &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;GenericMap&lt;/span&gt;&lt;/code&gt; and is to be created using the Map factory under normal circumstances.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;MapCube&lt;/span&gt;&lt;/code&gt; and &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;CompositeMap&lt;/span&gt;&lt;/code&gt; have also seen some improvements, including the implementation of &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;draw_limb&lt;/span&gt;&lt;/code&gt; and &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;draw_grid&lt;/span&gt;&lt;/code&gt; for both datatypes and a new animation based &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;plot()&lt;/span&gt;&lt;/code&gt; method for &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;MapCube&lt;/span&gt;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To facilitate the changes to map there have also been a lot of improvements to the &lt;a class="reference external" href="https://docs.python.org/3/library/io.html#module-io" title="(in Python v3.14)"&gt;&lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;io&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; submodule, including the ability to read all the HDUs from a FITS file and the addition of a &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;extract_waveunit&lt;/span&gt;&lt;/code&gt; function that checks the header for common ways to encode the wavelength unit.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There has also been a big cleanup of the various top level and submodule namespaces to make imports simpler. Most of this has not changed the user facing API, however there are not nicer ways to import submodules, like &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;sunpy.util.util&lt;/span&gt;&lt;/code&gt; is now the same as sunpy.util.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The spectra module has been refactored so it also has a &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;data&lt;/span&gt;&lt;/code&gt; attribute and it’s plotting API is now consistent with that of Map and LightCurve&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;SunPy 0.3 consists of 9 months of work from 15 people and over 300 commits to the git repository.
The people who have contributed to this release are (in commit order):&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Stuart Mumford&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Russell Hewett&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Florian Mayer&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Steven Christe&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Albert Shih&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Simon Liedtke&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ankit Angrawal&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Jack Ireland&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Matt Bates&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Nabil Freij&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keith Hughitt&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;David Perez-Suarez&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tomas Meszaros&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Benjamin Mampaey&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Andrew Leonard&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On behalf of all the SunPy developers, we hope you enjoy 0.3!&lt;/p&gt;
&lt;/section&gt;
</content>
    <link href="https://sunpy.org/posts/2013/2013-08-30-Announcing-SunPy-0.3/"/>
    <summary>It gives me great pleasure to announce the release of a new version of SunPy.
This version has been rather too long in the making, but is here at last!</summary>
    <category term="0.3" label="0.3"/>
    <category term="sunpy" label="sunpy"/>
    <published>2013-08-30T00:00:00+00:00</published>
  </entry>
  <entry>
    <id>https://sunpy.org/posts/2013/2013-08-29-Experiments-in-animating-plots/</id>
    <title>Experiments in animating plots and saving movies in SunPy 0.3</title>
    <updated>2013-08-29T00:00:00+00:00</updated>
    <author>
      <name>Jack Ireland</name>
    </author>
    <content type="html">&lt;section id="experiments-in-animating-plots-and-saving-movies-in-sunpy-0-3"&gt;

&lt;p&gt;Just over a year ago this post described a simple method for saving a movie of SunPy maps.
Since then, SunPy and matplotlib have moved on, and I’d like to describe an updated method for animating SunPy maps, and saving the results as an mp4 file.&lt;/p&gt;
&lt;p&gt;First off, all these experiments were conducted on Ubuntu 12.04.
The code below is based on this &lt;a class="reference external" href="https://stackoverflow.com/questions/18019226/matplotlib-artistanimation-gives-typeerror-axesimage-object-is-not-iterable"&gt;StackOverflow&lt;/a&gt; question and answer (where would we be without StackOverflow???? - thanks!), and some googling around concerning Ubuntu and ffmpeg.&lt;/p&gt;
&lt;p&gt;So, to begin, I fired up &lt;a class="reference external" href="https://ipython.org/"&gt;ipython&lt;/a&gt;.
I tried the StackOverflow code (including the correction in the answer) and got stuck in an ipython error loop.
The solution - upgrading to ipython 1.0.0.  Trying again, the code crashed because I did not have ffmpeg installed.
Matplotlib looks for movie writers it can use, and since I had specified one that was not present, it crashed.
You can find which movie writers are present with &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;animation.writers.list()&lt;/span&gt;&lt;/code&gt; (having imported the animation module as below).
I put ffmpeg capabilities on my system through sudo apt-get install libav-tools.&lt;/p&gt;
&lt;p&gt;So, the StackOverflow code worked!
It was quite simple to adapt it plotting SunPy 0.3 maps.
I want to read in a bunch of time-ordered AIA FITS files, and make a movie of them.
A very typical use case for a solar physicist.  Here is what I managed to get to work.&lt;/p&gt;
&lt;div class="highlight-default notranslate"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib&lt;/span&gt;
&lt;span class="n"&gt;matplotlib&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Agg&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;plt&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib.animation&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;animation&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sunpy&lt;/span&gt;

&lt;span class="c1"&gt;# Set up formatting for the movie files&lt;/span&gt;
&lt;span class="n"&gt;Writer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;animation&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;ffmpeg&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;writer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Writer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;artist&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Me&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;bitrate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1800&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Get some data&lt;/span&gt;
&lt;span class="n"&gt;imagedir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;/home/ireland/Data/AIA_Data/&amp;#39;&lt;/span&gt;
&lt;span class="n"&gt;filenames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;listdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;imagedir&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;fig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;An SDO movie&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;filenames&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Processing &lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;im&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sunpy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;imagedir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;im&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;()])&lt;/span&gt;

&lt;span class="n"&gt;ani&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;animation&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ArtistAnimation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;interval&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;blit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;repeat_delay&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ani&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;output_movie.mp4&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The code creates a SunPy map, and then creates a list of plots of those maps for the animator to work with.
The animator then saves the animation as a movie using the ffmpeg writer.
Works quite well.
The resulting movie is here.
As you can see the title above each image remains the same, whereas in each individual frame the titles differ (according to the observation time).  That needs fixing, and it &lt;a class="reference external" href="https://stackoverflow.com/questions/17558096/animated-title-in-matplotlib"&gt;seems it is possible&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Animating a set of plots is also quite easy.
The code is almost the same as above.
Just comment out the line &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;matplotlib.use('Agg')&lt;/span&gt;&lt;/code&gt; and replace the line &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;ani.save(…)&lt;/span&gt;&lt;/code&gt; with &lt;code class="xref py py-obj docutils literal notranslate"&gt;&lt;span class="pre"&gt;plt.show()&lt;/span&gt;&lt;/code&gt;.
A matplotlib window appears, and the animation plays in it.
The interactive zoom feature of the matplotlib window also works, and that is pretty cool.&lt;/p&gt;
&lt;p&gt;I have not yet worked out how to animate a set of plots, and then save it as an mp4 movie.
These simple &lt;a class="reference external" href="https://matplotlib.org/stable/search.html?q=animation&amp;amp;check_keywords=yes&amp;amp;area=default"&gt;examples&lt;/a&gt; are enough I think, however, to get you going with animating your own plots.
And by plots, I mean any kind of plots, not just movies of 2-d image data.
The matplotlib site has examples of how to animate line plots, for example.&lt;/p&gt;
&lt;p&gt;Obviously it would be extremely useful to have the animation and movie saving capability baked in to the mapcube functionality of SunPy.
The code above is just an experiment, so if you have any improvements, or whole new and better methods, please let me know leave a comment below.
Thanks again to SunPy, StackOverflow and matplotlib!&lt;/p&gt;
&lt;/section&gt;
</content>
    <link href="https://sunpy.org/posts/2013/2013-08-29-Experiments-in-animating-plots/"/>
    <summary>Just over a year ago this post described a simple method for saving a movie of SunPy maps.
Since then, SunPy and matplotlib have moved on, and I’d like to describe an updated method for animating SunPy maps, and saving the results as an mp4 file.</summary>
    <category term="0.3" label="0.3"/>
    <category term="movies" label="movies"/>
    <category term="sunpy" label="sunpy"/>
    <published>2013-08-29T00:00:00+00:00</published>
  </entry>
</feed>
