私はPythonコードにそれを作って、このウェブサイトhttp://wdc.kugi.kyoto-u.ac.jp/igrf/gggm/index.htmlで検証してみました。私は
- 磁極が、私は1995年の値を使用するために、上記の計算を設定しても年1995年
- のために、私はかなり正しい一致を取得しないということであることがわかりました。
京都、日本(35N、135.45W)の値を使用しました。 Webページが計算されました(25.18、-155.80)。私は得た(25.33580652、-155.82724011)。私は、アプリケーションに応じて...
import numpy as np
from numpy import pi, cos, sin, arctan2, sqrt, dot
def geo2mag(incoord):
"""geographic coordinate to magnetic coordinate:
incoord is numpy array of shape (2,*)
array([[glat0,glat1,glat2,...],
[glon0,glon1,glon2,...])
where glat, glon are geographic latitude and longitude
(or if you have only one point it is [[glat,glon]])
returns
array([mlat0,mlat1,...],
[mlon0,mlon1,...]])
"""
# SOME 'constants'...
lon = 288.59 # or 71.41W
lat = 79.3
r = 1.0
# convert first to radians
lon, lat = [x*pi/180 for x in lon,lat]
glat = incoord[0] * pi/180.0
glon = incoord[1] * pi/180.0
galt = glat * 0. + r
coord = np.vstack([glat,glon,galt])
# convert to rectangular coordinates
x = coord[2]*cos(coord[0])*cos(coord[1])
y = coord[2]*cos(coord[0])*sin(coord[1])
z = coord[2]*sin(coord[0])
xyz = np.vstack((x,y,z))
# computer 1st rotation matrix:
geo2maglon = np.zeros((3,3), dtype='float64')
geo2maglon[0,0] = cos(lon)
geo2maglon[0,1] = sin(lon)
geo2maglon[1,0] = -sin(lon)
geo2maglon[1,1] = cos(lon)
geo2maglon[2,2] = 1.
out = dot(geo2maglon , xyz)
tomaglat = np.zeros((3,3), dtype='float64')
tomaglat[0,0] = cos(.5*pi-lat)
tomaglat[0,2] = -sin(.5*pi-lat)
tomaglat[2,0] = sin(.5*pi-lat)
tomaglat[2,2] = cos(.5*pi-lat)
tomaglat[1,1] = 1.
out = dot(tomaglat , out)
mlat = arctan2(out[2],
sqrt(out[0]*out[0] + out[1]*out[1]))
mlat = mlat * 180/pi
mlon = arctan2(out[1], out[0])
mlon = mlon * 180/pi
outcoord = np.vstack((mlat, mlon))
return outcoord
if __name__ == '__main__':
mag = geo2mag(np.array([[79.3,288.59]]).T).T
print mag # should be [90,0]
mag = geo2mag(np.array([[90,0]]).T).T
print mag # should be [79.3,*]
mag = geo2mag(np.array([
[79.3,288.59],
[90,0]
]).T).T
print mag # should be [ [90,0]. [79.3,*] ]
# kyoto, japan
mag = geo2mag(np.array([[35.,135.45]]).T).T
print mag # should be [25.18, -155.80], according to
# this site using value for 1995
# http://wdc.kugi.kyoto-u.ac.jp/igrf/gggm/index.html
あなたが見つけたスクリプトは、Prologで書かれていません。 –
さらに調査すると、代わりにION Scriptと関係があるかもしれません:http://idlastro.gsfc.nasa.gov/idl_html_help/What_Is_ION_Script.html –
私はそれがidlスクリプトだと確信しています。そんな宇宙人はそんなに好きです。 – yosukesabai