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

Home » Public Forums » archive » Re: GEOMAGNETIC to GEOGRAPHIC coordinate conversion
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
Re: GEOMAGNETIC to GEOGRAPHIC coordinate conversion [message #2466] Wed, 13 July 1994 07:25
zawodny is currently offline  zawodny
Messages: 121
Registered: August 1992
Senior Member
In article <CsuDEA.xt@ngdc.noaa.gov> greg@farpoint.ngdc.noaa.gov (Greg Ushomirskiy) writes:
> Has anyone written an IDL routine to convert from geomagnetic latitude/longitude
> to geographic lat/lon?
>


Well here is what I use.

;+
; NAME: MAGLAT
;
; PURPOSE: Convert geographic latitude and longitude to magnetic
; latitude and longitude.
;
; CATEGORY: Coordinate transformation
;
; CALLING SEQUENCE:
; mlat = MAGLAT(lat,lon,mlon)
; INPUTS:
; Lat A scalar or vector of geographic latitudes
; Lon A scalar or vector of geographic longitudes
;
; OUTPUTS:
; Mlat Primary result, a scalar/vector of magnetic latitudes
; Mlon Optional result, a scalar/vector of magnetic longitudes
;
; COMMON BLOCKS: None
;
; SIDE EFFECTS: None
;
; RESTRICTIONS: Latitude should be -90 <= lat <= 90.
;
; PROCEDURE:
; STRAIGHTFORWARD (seems to be the default value of this field).
; MODIFICATION HISTORY:
; Version 1.1, Jan 1993 by J.M.Zawodny NASA LaRC
; zawodny@arbd0.larc.nasa.gov
;-
function MAGLAT,glat,glon,mlon

; Convert to radians
a117 = 11.7/!radeg
alat = glat/!radeg
alon = (glon-291.)/!radeg

; Calculate the latitude
slat = sin(alat)*cos(a117) + cos(alat)*sin(a117)*cos(alon)
mlat = asin(slat)

; If user wants geomagnetic longitude as well
if(n_params(0) eq 3) then begin
ylon = cos(alat)*sin(alon)
xlon = sin(alat)*sin(a117) - cos(alat)*cos(alon)*cos(a117)
mlon = atan(ylon,xlon)*!radeg
endif

; Return the geomagnetic latitude (in degrees)
return,mlat*!radeg
end


--
Joseph M. Zawodny (KO4LW) NASA Langley Research Center
Internet: zawodny@arbd0.larc.nasa.gov MS-475, Hampton VA, 23681-0001
TCP/IP: ko4lw@ko4lw.ampr.org Packet: ko4lw@n4hog.va.usa
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Xmanager/multitasking windows
Next Topic: IDL source code for NR functions....

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

Current Time: Wed Oct 08 13:48:04 PDT 2025

Total time taken to generate the page: 0.00513 seconds