簡體   English   中英

Healpix - 將經度、緯度轉換為銀河坐標

[英]Healpix - Converting longitude, latitude to galactic coordinates

我有一個 Healpix 像素協調文件https://wwwmpa.mpa-garching.mpg.de/~ensslin/research/data/faraday2020.html

這包含我想在天空圖中實現的緯度和經度值。 然而,這些值需要首先轉換為銀河坐標 (l,b)。

我的代碼是:

from astropy.io import fits
from astropy import units as u
from astropy.coordinates import Galactic
import matplotlib.pyplot as plt
import h5py
from astropy_healpix import HEALPix

filename='pixel_coords_map_ring_galactic_res9.fits'

hdulist=fits.open(filename) 
nside = hdulist[1].header['NSIDE']
order = hdulist[1].header['ORDERING']
hp = HEALPix(nside=nside, order=order, frame=Galactic())    

print(hdulist[1].header)

ggl = hdulist[1].data['LONGITUDE']           #storing coordinate values in ggl and ggb
ggb = hdulist[1].data['LATITUDE'] 

gl = ggl * u.degree                            #convering to galactic coordinates
gb = ggb * u.degree

c = Galactic(l=gl,b=gb) 

l_rad = c.l.wrap_at(180 * u.deg).radian
b_rad = c.b.radian

有沒有更有效的方法來進行從經緯度到銀河系或 Healpix function 的轉換? 請幫忙。

這段代碼來自我之前寫的一個答案。 它不會在銀河坐標中將 long-lat 轉換為 u.deg 嗎? 參考:使用 astropy 在 skyplot 上繪制均值和標准偏差值
注意:這是我用來獲取 HEALPix 文件的鏈接:( 'pixel_coords_map_ring_galactic_res9.fits')

from astropy.io import fits                        
from astropy import units as u
from astropy.coordinates import SkyCoord

fits_file = 'pixel_coords_map_ring_galactic_res9.fits'  #healpix

with fits.open(fits_file) as hdulist:
    nside = hdulist[1].header['NSIDE']
    order = hdulist[1].header['ORDERING']
        
    ggl = hdulist[1].data['LONGITUDE']           #storing coordinate values in ggl and ggb
    ggb = hdulist[1].data['LATITUDE'] 
    
    gl = ggl * u.degree                            #convering to galactic coordinates
    gb = ggb * u.degree
    
    c = SkyCoord(l=gl,b=gb, frame='galactic', unit = (u.deg, u.deg))  
    l_rad = c.l.wrap_at(180 * u.deg).radian            #X Axis
    b_rad = c.b.radian
    print(len(l_rad), len(b_rad))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM