<?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 by Jack Ireland</title>
  <updated>2026-04-16T16:25:22.163515+00:00</updated>
  <link href="https://sunpy.org/"/>
  <link href="https://sunpy.org/blog/author/jack-ireland/atom.xml" rel="self"/>
  <generator uri="https://ablog.readthedocs.io/" version="0.11.13">ABlog</generator>
  <entry>
    <id>https://sunpy.org/posts/2020/2020-06-03_hdee_sunpy/</id>
    <title>SunPy awarded a NASA HDEE Grant</title>
    <updated>2020-06-05T00:00:00+00:00</updated>
    <author>
      <name>Jack Ireland</name>
    </author>
    <content type="html">&lt;section id="sunpy-awarded-a-nasa-hdee-grant"&gt;

&lt;p&gt;A NASA Heliophysics Data Environment Enhancement (HDEE) grant has been
awarded to a proposal submitted to support SunPy development. The
grant was awarded through NASA’s 2019 ROSES grant solicitation.&lt;/p&gt;
&lt;p&gt;The grant supports the following development goals:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Creation of a report on the state of the SunPy codebase by analyzing
output from code coverage and API inspection tools, etc, identifying
areas in the existing codebase that need more coverage, can be
consolidated or removed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provide the ability to read spectroscopic data into a spectral data
object, thereby enabling its later scientific analysis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Implement a number of heliophysical coordinate systems using the
existing SunPy and Astropy-based coordinate system framework.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create example code snippets that use SunPy and packages from the
Python in Heliophysics Community; these examples will be shared via
the Python in Heliophysics Community.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The PI of the grant is Jack Ireland, and the co-I of the grant is Andy
Terrel (NumFOCUS). The grant has a one year duration. The bulk of
the code development will be undertaken by a developer hired through
NuMFOCUS. We look forward to supporting the development of SunPy
through this grant.&lt;/p&gt;
&lt;p&gt;Jack&lt;/p&gt;
&lt;/section&gt;
</content>
    <link href="https://sunpy.org/posts/2020/2020-06-03_hdee_sunpy/"/>
    <summary>A NASA Heliophysics Data Environment Enhancement (HDEE) grant has been
awarded to a proposal submitted to support SunPy development. The
grant was awarded through NASA’s 2019 ROSES grant solicitation.</summary>
    <category term="sunpy" label="sunpy"/>
    <published>2020-06-05T00: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>
