comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » map function for astronomy
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
map function for astronomy [message #89877] Mon, 15 December 2014 15:21 Go to next message
eshaya is currently offline  eshaya
Messages: 4
Registered: December 2014
Junior Member
I want to use the map function for plots of the sky. In the map_set procedure there was a simple reverse=1 keyword to do this. How do we do this with the map function?
Re: map function for astronomy [message #89878 is a reply to message #89877] Mon, 15 December 2014 17:18 Go to previous messageGo to next message
Jim  Pendleton is currently offline  Jim Pendleton
Messages: 165
Registered: November 2011
Senior Member
On Monday, December 15, 2014 4:21:40 PM UTC-7, esh...@umd.edu wrote:
> I want to use the map function for plots of the sky. In the map_set procedure there was a simple reverse=1 keyword to do this. How do we do this with the map function?

All this really means is that the longitudinal orientation is reversed, as you would likely prefer if you were plotting coordinates defined in terms of galactic latitude and longitude, for example. With this keyword, you don't have to resort to tricks with respect to labeling the axes in a custom way or reversing the sense of your data.

Consider this example, with reverse set to 0 or 1:

map_set, /mercator, reverse = 1, /grid, $
xmargin = 5, ymargin = 5, label = 1, /continents, /iso
Re: map function for astronomy [message #89882 is a reply to message #89878] Tue, 16 December 2014 11:11 Go to previous messageGo to next message
eshaya is currently offline  eshaya
Messages: 4
Registered: December 2014
Junior Member
That is the way I was doing it. But, starting with IDL version 8.0, the map_set was replaced by the map function. As the Help Manual says:
"MAP_SET Procedure - Please see the MAP function, which replicates the functionality of this routine and offers an interactive interface."

The new plotting functions (plot(),surface(),plot3d(),map(), etc) that have replaced the old procedures have big advantages in that you can interactively adjust almost anything and then easily output to any graphic format.
But, I don't see how to get map() reverse the longitude which is required for most astronomical purposes. If I change the limits, it just changes them back.
Re: map function for astronomy [message #89883 is a reply to message #89877] Tue, 16 December 2014 13:24 Go to previous messageGo to next message
eshaya is currently offline  eshaya
Messages: 4
Registered: December 2014
Junior Member
On Monday, December 15, 2014 6:21:40 PM UTC-5, esh...@umd.edu wrote:
> I want to use the map function for plots of the sky. In the map_set procedure there was a simple reverse=1 keyword to do this. How do we do this with the map function?

Well, I have gone ahead and wrote the code to force a reversal of the longitude and at least make it possible to plot skymaps with the map procedure. Here is what I did (but if anyone can find an easier way, I am all ears). First, I use the negative of the RA values in the limits:

limit = [decmin,-ramax,decmax,-ramin]

and call the map function with label_format keyword:

map1 = map('Orthographic', limit=limit, label_format = 'mapgrid_labels_reverse')

The label_format keyword is a callback to a user supplied function that can alter the labels. So mine is call mapgrid_labels_reverse:
function MapGrid_Labels_Reverse, orientation, location, fractional, defaultlabel
; Reverse RA labels for skymaps
; Be sure to reverse both the RA limits and the RA values
; And then use map function like so
; m = MAP(orthographic, LABEL_FORMAT='MapGrid_Labels_Reverse', limit=limit)

; If grid line is RA (orientation = 0), then reverse it
if (orientation eq 0) then begin
location = -location
if (location lt 0) then location = location + 360.
endif

degree = '!M' + STRING(176b) ; Use the Math symbol

label = STRTRIM(ROUND(location),2) + degree

return, label
end
----
This just uses degrees. Of course, one could be fancy here and output hours, min, sec etc instead.
Next one has to use the reverse of the ra in plotting any values:
map1 = plot(/overplot,-ra,dec,symbol='+',linestyle='')

Again, hopefully, I am just being silly here and there is some keyword or something that does all of this automagically.
Re: map function for astronomy [message #90060 is a reply to message #89883] Wed, 21 January 2015 10:23 Go to previous message
Matt Haffner is currently offline  Matt Haffner
Messages: 34
Registered: October 2000
Member
I've also had to do something similar with the new function graphic calls to get astronomical images plotted correctly. I haven't found anything in testing or in the docs that suggests longitude can be projected in the opposite direction.

In the old days, I flipped the sign, like you've done and just dealt with having to pass negative longitudes for overplotting, labels, etc. But with the new mapping functions, the LIMIT keyword's longitudes can't be less than -180. So, there's a problem if your image has sky coordinates above +180.

However, the *maximum* longitude in LIMIT is allowed to be as high as +540. So I now "flip" the longitude with this function:

new_lon = (360 - orig_lon)

A simple label_format function looks like this then:

function mapgrid_gal_360flip_labels, orient, value, fractional, default

if orient eq 0 then v = 360-value else v = value

if fractional eq 0 then begin
l = string(v, format = '(I4)')
endif else begin
l = string(v, format = '(F6.2)')
endelse

return, l

end

Any overplotting, etc. needs to convert coordinates with (360 - lon), which is a bit more annoying than just negating. But it works.

STILL, I'd like to make a plea to the developers to please consider adding a simple /REVERSE keyword for projections again for those of us who like to plot data on the inside of spheres :) I'm enjoying a lot of the flexibility and output of the function graphics and would love to move more of our code library in that direction.

- mh

On Tuesday, December 16, 2014 at 3:24:46 PM UTC-6, esh...@umd.edu wrote:
> On Monday, December 15, 2014 6:21:40 PM UTC-5, esh...@umd.edu wrote:
>> I want to use the map function for plots of the sky. In the map_set procedure there was a simple reverse=1 keyword to do this. How do we do this with the map function?
>
> Well, I have gone ahead and wrote the code to force a reversal of the longitude and at least make it possible to plot skymaps with the map procedure. Here is what I did (but if anyone can find an easier way, I am all ears). First, I use the negative of the RA values in the limits:
>
> limit = [decmin,-ramax,decmax,-ramin]
>
> and call the map function with label_format keyword:
>
> map1 = map('Orthographic', limit=limit, label_format = 'mapgrid_labels_reverse')
>
> The label_format keyword is a callback to a user supplied function that can alter the labels. So mine is call mapgrid_labels_reverse:
> function MapGrid_Labels_Reverse, orientation, location, fractional, defaultlabel
> ; Reverse RA labels for skymaps
> ; Be sure to reverse both the RA limits and the RA values
> ; And then use map function like so
> ; m = MAP(orthographic, LABEL_FORMAT='MapGrid_Labels_Reverse', limit=limit)
>
> ; If grid line is RA (orientation = 0), then reverse it
> if (orientation eq 0) then begin
> location = -location
> if (location lt 0) then location = location + 360.
> endif
>
> degree = '!M' + STRING(176b) ; Use the Math symbol
>
> label = STRTRIM(ROUND(location),2) + degree
>
> return, label
> end
> ----
> This just uses degrees. Of course, one could be fancy here and output hours, min, sec etc instead.
> Next one has to use the reverse of the ra in plotting any values:
> map1 = plot(/overplot,-ra,dec,symbol='+',linestyle='')
>
> Again, hopefully, I am just being silly here and there is some keyword or something that does all of this automagically.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: FINITE function
Next Topic: Map method bug?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 07:23:53 PDT 2025

Total time taken to generate the page: 0.00577 seconds