sunpy contours

284 views
Skip to first unread message

jcmo

unread,
Jun 16, 2012, 5:21:05 PM6/16/12
to su...@googlegroups.com
Hi Everybody,

First of all thank you for all your help at SPD, you answered the majority of questions I had. Still I do not understand how to make contours. As I understood, the idea is to use the sunpy.CompositeMap class to generate the contours, specifying that alpha=0. Is that right? How control the contour levels?

>>> import sunpy
>>> comp_map = sunpy.CompositeMap(sunpy.AIA_171_IMAGE)    
>>> comp_map.add_map(sunpy.RHESSI_IMAGE)
>>> comp_map.alpha = 0
>>> comp_map.show()

This is how should be done?

Juan

Christe, Steven D. (GSFC-6710)

unread,
Jun 17, 2012, 10:37:00 PM6/17/12
to su...@googlegroups.com

Hey Juan,

I am working on a tutorial which goes over a number of the questions that you had. I'll put that up sometime soon.

Based on your question below I looked over the code for doing overlays and it looks like it is not really ready. The multimaps (map cubes, and composite maps) have not really gotten the love or testing that they really need. Let me try work on the code a little over the next few days and I'll get back to you. Of course you are welcome to work on the code yourself as well!

Steven
> --
> You received this message because you are subscribed to the Google Groups "SunPy" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/sunpy/-/4lySrLb6AxcJ.
> To post to this group, send email to su...@googlegroups.com.
> To unsubscribe from this group, send email to sunpy+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sunpy?hl=en.

Christe, Steven D. (GSFC-6710)

unread,
Jun 22, 2012, 5:40:39 PM6/22/12
to su...@googlegroups.com

Hey Juan-Carlos,

I've written up a new guide to maps (which you can find here https://github.com/sunpy/sunpy/blob/master/doc/source/guide/map_guide.rst, by the way it seems like the read-the-docs are not currently working) and I've also added some functionality to the composite map so that it is easier to make contour overlays. Please take a look at it and let me know if it adequately answers your questions! 

Steven Christe, Ph.D.
Solar Physics Laboratory, Code 671
NASA Goddard Space Flight Center
Greenbelt, MD 20771-0001, USA
Telephone: 301-286-7999

On Jun 16, 2012, at 5:21 PM, jcmo wrote:

jcmo

unread,
Jun 22, 2012, 8:33:47 PM6/22/12
to su...@googlegroups.com
Hi Steven,

Thanks! I think your document answer the majority of questions that I had referring to the contours. I'll be playing with this during the weekend and to re-write the read_gong routine. I have the next problem while trying to make run your examples in my computer, in particular with the defininition of the contour levels.

In [6]: my_maps.set_levels(1,[50,60,70,80,90], percent = True)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/Users/oliveros/Downloads/sunpy-sunpy-3286ef5/sunpy/<ipython-input-6-9b1f1aa33f61> in <module>()
----> 1 my_maps.set_levels(1,[50,60,70,80,90], percent = True)

AttributeError: CompositeMap instance has no attribute 'set_levels'

I think I downloaded the latest version using git as is explained in the sunpy webpage

git clone git://github.com/sunpy/sunpy.git
cd sunpy
python setup.py install
Do I need to do something else?

Cheers,

Juan
To unsubscribe from this group, send email to sunpy+unsubscribe@googlegroups.com.

Christe, Steven D. (GSFC-6710)

unread,
Jun 24, 2012, 12:36:33 PM6/24/12
to su...@googlegroups.com
Hey Juan-Carlos, so it looks like this is an installation problem. It is unlikely that the git clone didn't work so I would blame the python install bit. Try running ipython from the directory you ran the git clone to. That should just run sunpy "locally". Just to be sure that git worked you can also just check the compositemap.py code to make sure that set_levels is there. 

Steven

Sent from my iPad

On Jun 22, 2012, at 20:33, "jcmo" <jua...@gmail.com> wrote:

Hi Steven,

Thanks! I think your document answer the majority of questions that I had referring to the contours. I'll be playing with this during the weekend and to re-write the read_gong routine. I have the next problem while trying to make run your examples in my computer, in particular with the defininition of the contour levels.

In [6]: my_maps.set_levels(1,[50,60,70,80,90], percent = True)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/Users/oliveros/Downloads/sunpy-sunpy-3286ef5/sunpy/<ipython-input-6-9b1f1aa33f61> in <module>()
----> 1 my_maps.set_levels(1,[50,60,70,80,90], percent = True)

AttributeError: CompositeMap instance has no attribute 'set_levels'

I think I downloaded the latest version using git as is explained in the sunpy webpage

Nggit clone git://github.com/sunpy/sunpy.git
To view this discussion on the web visit https://groups.google.com/d/msg/sunpy/-/7KlSwdLKg-AJ.

To post to this group, send email to su...@googlegroups.com.
To unsubscribe from this group, send email to sunpy+un...@googlegroups.com.

Keith Hughitt

unread,
Jun 25, 2012, 10:22:59 AM6/25/12
to su...@googlegroups.com
Hey Steven,

It looks like you may not have merged the changes which include the "set_levels" method in yet:


Maybe you need to merge your working branch into your master?

Keith

Christe, Steven D. (GSFC-6710)

unread,
Jun 25, 2012, 11:01:18 AM6/25/12
to su...@googlegroups.com

Ha! sorry about that. That code is somehow still on my home computer. Not sure how I did that. Sorry Juan-Carlos. It looks like this is my mistake. I'll issue a pull request tonight. Thanks for pointing this out Keith.

Steven Christe, Ph.D.
Solar Physics Laboratory, Code 671
NASA Goddard Space Flight Center
Greenbelt, MD 20771-0001, USA
Telephone: 301-286-7999

jcmo

unread,
Jun 25, 2012, 6:22:38 PM6/25/12
to su...@googlegroups.com
Hi Steven,

Thanks for all your help, what is the best way to update sunpy to add your new code? Tonight and/or tomorrow I will play with the contours and make some images related to my work. Also, if is ok with you, I will use your tutorial ina presentation I need to make for a summer school in solar physics.

Thanks again,

Juan

Christe, Steven D. (GSFC-6710)

unread,
Jun 25, 2012, 10:17:21 PM6/25/12
to su...@googlegroups.com
Hey Juan

I've submitted a pull request with my code which means it is now up for code review. Someone should be taking a look at it tomorrow and the code should be integrated soon after that. I use github to keep my code up to date but you can also use pip (which also essentially uses github). I think the new installation code talks about this or just read Andy's previous email. 

You are welcome to use my tutorial. We also have some other materials like presentations and posters which you can also use if you'd like. Just let us know what you need. If you come up with your own tutorial would you be willing to share it back? Weve been talking about putting something together ourselves but haven't gotten around to it yet. 

Sent from my iPad
--
You received this message because you are subscribed to the Google Groups "SunPy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sunpy/-/cqxRt2-h-kIJ.

Keith Hughitt

unread,
Jun 26, 2012, 10:31:22 AM6/26/12
to su...@googlegroups.com
Okay, I merged the commit so it is not in github.com/sunpy/sunpy.

Juan - 

My favorite way to keep SunPy up to date is to use git to clone the branch, and then use "sudo paver develop" to create a symlink to the cloned branch. This way, all you have to do to get the latest version of SunPy is to run "git pull" in the directory of the branch you cloned.

Check out:


Best,
Keith

jcmo

unread,
Jun 30, 2012, 11:16:20 PM6/30/12
to su...@googlegroups.com
Thank you all for your help. Sunpy is great! I do like how it works... I have now another question, to force python to plot the contour in one color I should use set_color='color'? Will that work? I made some experiments overlapping, and in works awesome, some minor things that I don't know how to make like an arbitrary rotation of the MDI data, I solve the problem making a 180 degrees rotation with numpy rot90.

As I mention I would like to present sunpy in a summer school, next week. I downloaded Florian's presentation, I think that will be enough, but if you happen to have the original, I can include some of my own slides to it.

Thanks again,

Juan

Christe, Steven D. (GSFC-6710)

unread,
Jul 5, 2012, 4:51:24 PM7/5/12
to su...@googlegroups.com

You can get access to Florian's original presentation here


Steven Christe, Ph.D.
Solar Physics Laboratory, Code 671
NASA Goddard Space Flight Center
Greenbelt, MD 20771-0001, USA
Telephone: 301-286-7999

--
You received this message because you are subscribed to the Google Groups "SunPy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sunpy/-/eW8_USTb0MMJ.

Keith Hughitt

unread,
Jul 9, 2012, 9:52:56 AM7/9/12
to su...@googlegroups.com
Hi Juan,

You may be able to use scipy.ndimage.interpolation.rotate to do arbitrary data rotations. It would not be hard to add a convenience method to SunPy if this is something that people would find generally useful.

I'm not sure about setting the contour plot colors. It looks like the way CompositeMap is set up right now you can only specifying Matplotlib keyword arguments (kwargs) once and they are applied to all layers in the composite. Perhaps a better approach would be to accept a tuple/list of kwargs.. then you could do something like:

    composite.show(..., (plot1_param1, plot1_param2), (plot2_param1), etc)

Since Matplotlib's contour() method supports a large number of keyword arguments, including a "colors", this would enable you to override the default values.

What do you think?
Keith

jcmo

unread,
Jul 9, 2012, 10:46:27 AM7/9/12
to su...@googlegroups.com
Hi Keith, 

Thanks, I made a presentation on SunPy in Bogota and I have a group of people interested in do all this jobs. In particular, I ask them to make as a project the arbitrary rotation of an image, such as MDI and HMI which are rotated. I hope by next week to have for you something like the SSW rot_map routine and if you agree incorporate it into sunpy. Also, I have a student which will re-write the utplot routine, that sound ok for you?

I will play with the matplotlib contour to understand how to change the colors, my question is, will that work with sunpy.make_map?  What I mean is that using Steven notes on maps, the way to make the contour overlaying is using sunpy.make_map, is that using CompositeMap?

my_maps = sunpy.make_map([sunpy.EIT_195_IMAGE, sunpy.RHESSI_IMAGE])
my_maps.add_map(sunpy.AIA_171_IMAGE)
my_maps.set_alpha(2,0.5)
my_maps.set_levels(1,[50,60,70,80,90], percent = True)
my_maps.show()

Cheers,

Juan
To unsubscribe from this group, send email to sunpy+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/sunpy?hl=en.

--
You received this message because you are subscribed to the Google Groups "SunPy" group.
To post to this group, send email to su...@googlegroups.com.
To unsubscribe from this group, send email to sunpy+unsubscribe@googlegroups.com.

Christe, Steven D. (GSFC-6710)

unread,
Jul 9, 2012, 3:27:57 PM7/9/12
to su...@googlegroups.com

Hey Juan,

Differential rotation is something that we definitely need in sunpy. Please let your student know that we already have coordinate transformations in available in the wcs module which he/she can use which I think will make things significantly easier.

Regarding utplot, we recently have developed a new lightcurve object which uses pandas. Pandas is an amazingly full-featured time series module and includes something akin to utplot within in. I would recommend that you point your student to study the new light curve object (and perhaps write up a tutorial similar to the map tutorial while he/she is learning? that would be very useful for everyone). If that does not do what you need then we can look further into pandas and see what is available there and possibly incorporate it into the light curve object. What do you think?

Regarding colors, is it not possible to just set_colors? It looks to me like it just passes the color argument to contour plot so you should be able to do exactly what they do in this example,


Sorry but I can't test it right now.

Steven Christe, Ph.D.
Solar Physics Laboratory, Code 671
NASA Goddard Space Flight Center
Greenbelt, MD 20771-0001, USA
Telephone: 301-286-7999

To view this discussion on the web visit https://groups.google.com/d/msg/sunpy/-/0TNVS6jdRsIJ.

To post to this group, send email to su...@googlegroups.com.
To unsubscribe from this group, send email to sunpy+un...@googlegroups.com.

jcmo

unread,
Jul 31, 2012, 12:03:32 PM7/31/12
to su...@googlegroups.com
Hi Steven,

Thanks for all your help. I think I am almost done asking things about the contours, but still I cannot make the contours to plot in a different color. If understood you well from your last post, I should use "set_colors" is that right? This is what I did:

omap = sunpy.make_map([smap,mapx])
omap.set_levels(1,[50,70,90], percent = True)
omap.set_colors(1, 'green')
omap.show(cmap=cm.hot,colorbar=False)

this is not giving me green contours, instead the contours colors change with the colormap of the figure, that is exactly what I don't want. 

Cheers,

Juan



On Saturday, June 16, 2012 2:21:05 PM UTC-7, jcmo wrote:

jcmo

unread,
Jul 31, 2012, 8:34:36 PM7/31/12
to su...@googlegroups.com
Hello!

I think I understood how to make it! and pretty happy, I think this way of plotting is much better than the IDL way, because the change of color intensity shows the different values you want to show. Now some questions, how I can tell sunpy to use just certain part of the colormap? If you the figure below, both contours have the same color for the lowest value which is white. How I can change that? Also, how i can change the thickness of the line?

Thanks,

Juan




On Saturday, June 16, 2012 2:21:05 PM UTC-7, jcmo wrote:
Reply all
Reply to author
Forward
0 new messages