Function rot in IDL

249 views
Skip to first unread message

Hypnus

unread,
Jul 16, 2012, 12:14:26 PM7/16/12
to su...@googlegroups.com
I'm working in getting a function to sunpy similar to function rot in IDL, what i really need to do is to organize and to implement it.

DVD PS

unread,
Jul 16, 2012, 12:25:11 PM7/16/12
to su...@googlegroups.com

Hi Hypnus,

On 16 July 2012 17:14, Hypnus <hypnu...@gmail.com> wrote:
I'm working in getting a function to sunpy similar to function rot in IDL, what i really need to do is to organize and to implement it.

scipy does not have that already? scipy.ndimage.interpolation.rotate...
the only option I don't see in there is the pivot... but I may be wrong.

David

jose ivan Campos

unread,
Jul 16, 2012, 12:31:38 PM7/16/12
to su...@googlegroups.com
you're ok, but you need to do two modifications...

2012/7/16 DVD PS <dps....@gmail.com>

--
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+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sunpy?hl=en.

jose ivan Campos

unread,
Jul 16, 2012, 1:11:01 PM7/16/12
to su...@googlegroups.com
That is the idea, thank you for your help.....

2012/7/16 Keith Hughitt <keith....@gmail.com>
That would be a helpful contribution. Perhaps it could go in the sunpy.image package? You could then add a convenience method in the Map class, etc. so that you can just do "aiamap.rotate(...)" similar to how the resample functionality is laid handled.

Keith

Keith Hughitt

unread,
Jul 16, 2012, 1:02:35 PM7/16/12
to su...@googlegroups.com
That would be a helpful contribution. Perhaps it could go in the sunpy.image package? You could then add a convenience method in the Map class, etc. so that you can just do "aiamap.rotate(...)" similar to how the resample functionality is laid handled.

Keith

On Mon, Jul 16, 2012 at 12:31 PM, jose ivan Campos <hypnu...@gmail.com> wrote:

jose ivan Campos

unread,
Jul 16, 2012, 1:15:48 PM7/16/12
to su...@googlegroups.com
I'm from Colombia, I'm working with GoSA(Group of Solar Astrophysics) of the Observatorio Astronómico Nacional (Universidad Nacional de Colombia) and i'm very interested in contribute with sunpy project.

2012/7/16 jose ivan Campos <hypnu...@gmail.com>

Jack Ireland

unread,
Jul 16, 2012, 2:10:01 PM7/16/12
to su...@googlegroups.com
I'm a little confused - do you mean rotating an image about a point, or do you mean calculating the rotation due to the differentially rotating Sun?

thanks,

jack

DVD PS

unread,
Jul 16, 2012, 2:38:07 PM7/16/12
to su...@googlegroups.com
¡¡¡Hola José!!! ¡Bienvenido a SunPy!  Nice to have you on-board!


I'm a little confused - do you mean rotating an image about a point, or do you mean calculating the rotation due to the differentially rotating Sun?

I think he means to rotate the image a number a degrees... I could imagine you want to do so for aligning ground-based images to spacecraft ones (they are usually rotated before level1).

David

PS.  ¿¿Se llaman GoSA??? ¿en inglés? bueno supongo que suena mejor que GdAS

jose ivan Campos

unread,
Jul 16, 2012, 3:58:27 PM7/16/12
to su...@googlegroups.com
GoSA stands for Group of Solar Astrophysics


... http://www.observatorio.unal.edu.co/gosa/GOSA/Home.html,  and my first attempt is rotating about a point, i'm going to try get a function to differential rotation.

2012/7/16 DVD PS <dps....@gmail.com>

DVD PS

unread,
Jul 16, 2012, 4:16:15 PM7/16/12
to su...@googlegroups.com
On 16 July 2012 20:58, jose ivan Campos <hypnu...@gmail.com> wrote:
GoSA stands for Group of Solar Astrophysics


... http://www.observatorio.unal.edu.co/gosa/GOSA/Home.html,  

Yeah! I was kidding ;-)

and my first attempt is rotating about a point, i'm going to try get a function to differential rotation.

That's great!! it's one of the functions asked for more people!!!

¡Ten un buen día!
David

Stuart Mumford

unread,
Jul 17, 2012, 3:19:29 AM7/17/12
to su...@googlegroups.com

Hi,

In the AIAPREP routine Keith sent me the other day there is multiple implementations of IDL rot.

Stuart
From a mountain in Scotland.

jose ivan Campos

unread,
Jul 17, 2012, 8:43:42 AM7/17/12
to su...@googlegroups.com
I known but for example HMI image need rotate 179.99983 degrees (crot2)... i don´t know if aiaprep in sunpy do it.

2012/7/17 Stuart Mumford <little...@gmail.com>

Christe, Steven D. (GSFC-6710)

unread,
Jul 17, 2012, 9:20:58 AM7/17/12
to su...@googlegroups.com

I did not have a chance to look at the aiaprep routine that was sent out but I've attached the (standard) idl diff rot code. This calculates everything in heliographic coordinates (latitude and longitude on the Sun). Usually we want to do differential rotation on an image given in helioprojective-cartesian coordinates (X, Y in arcseconds). This conversion is already implemented in sunpy in the wcs module. So the first task is the implement the following and then add the ability to do differential rotation in helioprojective-cartesian. Finally, a wrapper should be written so that it can performed on a map. Does this help?

Steven
FUNCTION DIFF_ROT, ddays, latitude, howard=howard, allen=allen, $
                   synodic=synodic, sidereal=sidereal
;+
; PROJECT:
;       SOHO - CDS
;
; NAME:	
;       DIFF_ROT()
;
; PURPOSE:
;     Computes the differential rotation of the sun
;       
; EXPLANATION:
;       
; CALLING SEQUENCE: 
;       Result = DIFF_ROT(ddays,latitude)
;
; INPUTS:
;       DDAYS    --  number of days to rotate
;       LATITUDE --  latitude in DEGREES
;       
; OPTIONAL INPUTS: 
;       None.
;
; OUTPUTS:
;       Result -- Change in longitude over ddays days in DEGREES
;
; OPTIONAL OUTPUTS:
;       None.
;
; KEYWORD PARAMETERS: 
;       ALLEN    -- use values from Allen, Astrophysical Quantities (DEFAULT)
;       HOWARD   -- use values for small magnetic features from Howard et al.
;       SIDEREAL -- use sidereal rotation rate (DEFAULT)
;       SYNODIC  -- use synodic rotation rate
;
; CALLS:
;       None.
;
; COMMON BLOCKS:
;       None.
;
; RESTRICTIONS: 
;       None.
;
; SIDE EFFECTS:
;       None.
;
; CATEGORY:
;       
; PREVIOUS HISTORY:
;       Written T. Metcalf  June 1992
;
; MODIFICATION HISTORY:
;       Version 1, Liyun Wang, GSFC/ARC, November 17, 1994
;          Incorporated into the CDS library
;       Version 2, Zarro, GSFC, 1 July 1997 - made Howard the default
;       Version 3, Zarro, GSFC, 19 Sept 1997 - corrected Howard coeff's
;
; VERSION:
;       Version 2
;-
;
   ON_ERROR, 2
   sin2l = (SIN(FLOAT(latitude*!dtor)))^2
   sin4l = sin2l*sin2l
   IF KEYWORD_SET(allen) THEN BEGIN

;  Allen, Astrophysical Quantities

    rotation = ddays*(14.44-3.0*sin2l)
   ENDIF ELSE BEGIN

;  Small magnetic features 
;  (Howard, Harvey, and Forgach, Solar Physics, 130, 295, 1990)

    rotation = 1.e-6*ddays*(2.894-0.428*sin2l-0.37*sin4l)*24.*3600./!dtor
   ENDELSE

   IF KEYWORD_SET(synodic) THEN BEGIN
    rotation = rotation-0.9856*ddays
   ENDIF 
   RETURN, rotation
END

Christe, Steven D. (GSFC-6710)

unread,
Jul 17, 2012, 9:22:18 AM7/17/12
to su...@googlegroups.com

Jose, if you were to rotate that much there would not be anything on the earth-facing side of the sun anymore, right...?

D. Shaun Bloomfield

unread,
Jul 17, 2012, 11:02:50 AM7/17/12
to su...@googlegroups.com
Hi Steven,

I think Jose was first talking about an image rotation about a point, so it's an image roll rotation. After that he will try tackling differential rotation.

>> GoSA stands for Group of Solar Astrophysics
>>
>> ... http://www.observatorio.unal.edu.co/gosa/GOSA/Home.html, and my first attempt is rotating about a point, i'm going to try get a function to differential rotation.

Cheers,

Shaun.

jose ivan Campos

unread,
Jul 18, 2012, 3:04:00 PM7/18/12
to su...@googlegroups.com
Maybe, my idea is to create in sunpy the rot_map function of ssw, do you know what i mean?

2012/7/17 D. Shaun Bloomfield <shaun.bl...@tcd.ie>

Christe, Steven D. (GSFC-6710)

unread,
Jul 18, 2012, 3:25:35 PM7/18/12
to su...@googlegroups.com

Hi Jose, rot_map is indeed just image rotation and has nothing to do with solar differential rotation. All maps hold their data in numpy arrays so here is a link that might get you started with that


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

Juan Carlos Martinez Oliveros

unread,
Jul 20, 2012, 10:17:20 AM7/20/12
to su...@googlegroups.com
Hello everybody,

I just want to clarify something. What Jose is wants is to write a function that will be comparable to the rot_map.pro routine in SSW, this is in particular needed for HMI and MDI data. He is also beginning to write a differential rotation function.

Juan

Krishna Mooroogen

unread,
Nov 2, 2013, 2:07:29 PM11/2/13
to su...@googlegroups.com
Hi , 

I have also been working on a sunpy implementation of IDL's rot_xy, the following is my current code if this helps anyone. It appears to work well for my current needs of following regions across the disk. Please improve as you see fit. 

def rot_pos(date_start,date_end,x = -600,y=0):

    #calculates days of rotation using date strings

    #converts hpc coord to hg coord

    #applies Howard, Harvey, and Forgach model for differential rotation as used in IDL rot_xy

    #converts hg back into hpc

    #updates and returns coordinate position 

        days              = (sunpy.time.parse_time(date_end)-sunpy.time.parse_time(date_start)).days

        print date_start, date_end

        print days

        longd,latt       = sunpy.wcs.wcs.convert_hpc_hg(x,y)

        sin2l             = (math.sin(math.radians(float(longd))))**2

        sin4l             = sin2l*sin2l

        rott_longd     = (1e-6)*days*(2.894-0.428*sin2l-0.37*sin4l)*24*3600/0.0174532925

        nposx,nposy = sunpy.wcs.wcs.convert_hg_hpc(rott_longd,latt)

        nposx           = nposx+x

        return nposx

Stuart Mumford

unread,
Nov 4, 2013, 10:24:08 AM11/4/13
to su...@googlegroups.com
Hello,

We are currently working on differential rotation and the like, but it is quite complex to integrate into SunPy without just duplicating a lot of code that is in many places in SolarSoft.

Our current implementation can be found here:
https://github.com/sunpy/sunpy/tree/differential_rotation

This is similar to your implementation:
https://github.com/sunpy/sunpy/blob/differential_rotation/sunpy/coords/util.py#L14

If you want to help us out with this it would be great! If you need a hand with install instructions let me know :)

Stuart


To unsubscribe from this group and stop receiving emails from it, send an email to sunpy+un...@googlegroups.com.

To post to this group, send email to su...@googlegroups.com.

Krishna Mooroogen

unread,
Nov 4, 2013, 11:31:00 AM11/4/13
to su...@googlegroups.com
Hey thats great, I didnt know there was already a rot function, is there somewhere I can get a list of all functions currently in sunpy? Id certainly like to help if I can but I'm not sure if I'll be able to. I am still a low level user.  

Krishna


--
You received this message because you are subscribed to a topic in the Google Groups "SunPy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sunpy/k_Z59_N9cU4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sunpy+un...@googlegroups.com.

Stuart Mumford

unread,
Nov 5, 2013, 5:30:28 AM11/5/13
to su...@googlegroups.com
In theory all of the functionality in SunPy is in our documentation, however I think one of the weak points of SunPy at the moment is the documentation (it seems that none of the developers like writing docs!!). The code reference should list ~95% of the available routines: https://sunpy.readthedocs.org/en/latest/reference/index.html the rot stuff is not in that list as we have not finished it yet!! 

If you use the routines you will be helping just by giving us feedback by raising issues on GitHub or on this list, I would be stunned if you use the diff rot code and you don't find a bug!!

How do you have SunPy installed at the moment? You will need to have it installed from our git repo to use the experimental diff rot code, and once you have that set up you are only one small step away from developer land ;)

Stuart

Krishna Mooroogen

unread,
Nov 5, 2013, 7:43:18 AM11/5/13
to su...@googlegroups.com
I think I have V.0.3.1 installed from the sunpy site. 

jcmo

unread,
Aug 6, 2014, 5:56:34 PM8/6/14
to su...@googlegroups.com
Hi Stuart,

I would like to give a test the diff_rot function. If i create a map, the way to use it will be map.diff_rot(minutes=something)?

Cheers,

Juan

Stuart Mumford

unread,
Aug 7, 2014, 6:41:48 AM8/7/14
to su...@googlegroups.com
Hey Juan,



> I would like to give a test the diff_rot function.

The diff_rot function that is in SunPy master at the moment is only the mathematics of the differential rotation, i.e. you give it a latitude and longitude and a time and it tells you the new position.

> map.diff_rot(minutes=something)

Jack and I started working on this functionality but it has got pushed somewhat to the bottom of the pile. I will try and kick it back into life for you.

What is it you wanted to do with the diff_rot? If you want to cut out a box tracking a feature that is easy enough to do and I have code that does it I can share.

Stuart



On 6 August 2014 22:56, jcmo <jua...@gmail.com> wrote:
Hi Stuart,

Jack Ireland

unread,
Aug 7, 2014, 9:46:03 AM8/7/14
to su...@googlegroups.com
Stuart, Juan,

I've been using a solar rotation compensation function (the IDL equivalent of rot_xy.pro) in one of my 0.3 branches.  I remember that it did not work with more recent branches due to the adoption of astropy units in other pieces of 0.4 and 0.5.

The solar rotation compensation functions rely on the ephemeris information in sunpy.  We know that the ephemeris information is not as accurate as it could be.  That being said, we can still update the solar rotation functionality to call whatever ephemeris sunpy provides.  I'll make updating the solar rotation function my next priority.

Jack
--
You received this message because you are subscribed to the Google Groups "SunPy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sunpy+un...@googlegroups.com.
To post to this group, send email to su...@googlegroups.com.
Visit this group at http://groups.google.com/group/sunpy.
For more options, visit https://groups.google.com/d/optout.

Stuart Mumford

unread,
Aug 7, 2014, 11:05:35 AM8/7/14
to su...@googlegroups.com
Jack,


See this PR: https://github.com/sunpy/sunpy/pull/1125 which is my attempt to rebase the rot_xy stuff on top of current master, it will need some reworking and general love, but at least the branch is now mostly clean and dosen't conflict or overwrite anything it shouldn't.

As I say on the PR it is possible that I have introduced bugs in your code however.

Stuart

Stuart Mumford

unread,
Aug 7, 2014, 12:01:05 PM8/7/14
to su...@googlegroups.com
Juan,

I have re-created a very old PR of mine which allows you to do a image warp like in your original email:

https://github.com/sunpy/sunpy/pull/1126/files

if you are on that branch you *should* be able to do `map.transform_rotation(timedelta)` to warp the map by a certain time.

I haven't tested that code in about a year, so I am almost certain it won't work! If yourself or anyone else wants to work on it however, it should provide a good start.

Stuart

AMRITA UNNIKRISHNAN

unread,
Aug 5, 2017, 6:39:26 AM8/5/17
to SunPy
I am trying to run the differential rotation of Sun in MATLAB(something similar to rot_xy in IDL). I am not sure on how to sent the arguments to the function and implement it. Has anyone worked on this or something similar before.

Thanks

DVD PS

unread,
Aug 5, 2017, 9:18:23 AM8/5/17
to sunpy
Hi Amrita,

On 5 August 2017 at 11:39, AMRITA UNNIKRISHNAN <amrita.un...@gmail.com> wrote:
I am trying to run the differential rotation of Sun in MATLAB(something similar to rot_xy in IDL). I am not sure on how to sent the arguments to the function and implement it. Has anyone worked on this or something similar before.

I don't know whether someone in the list has worked in an implimentation for Matlab. In SunPy (Python) you can use the newest implementation that will hopefully merged soon:

https://github.com/sunpy/sunpy/pull/2227

If you wait for the 0.8 release, happening soon, you will no need to do much to use it. Otherwise you can read how to use features that haven't been merged in:

http://docs.sunpy.org/en/latest/testingfeatures.htm
David

AMRITA UNNIKRISHNAN

unread,
Aug 10, 2017, 5:44:00 AM8/10/17
to su...@googlegroups.com
Thank you. I will have a check and let you know. 

Regards
Amrita Unnikrishnan

--
You received this message because you are subscribed to a topic in the Google Groups "SunPy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sunpy/k_Z59_N9cU4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sunpy+unsubscribe@googlegroups.com.

To post to this group, send email to su...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages