使用 hdf5 文件中的 astropy 在 skyplot 上绘制均值和标准 dev 值

问题描述

我正在尝试创建一个包含来自 hdf5 文件的平均值和标准开发值的天空图(使用 astropy)。数据链接为 https://wwwmpa.mpa-garching.mpg.de/~ensslin/research/data/faraday2020.html (Faraday Sky 2020)。 到目前为止,我已经编写了以下代码,其中数据从 hdf5 文件读取到 ggl 和 ggb,然后将值转换为 gb 和 gl 中的星系坐标(l 和 b)。我需要在天空图中绘制这些值。

from astropy import units as u
from astropy.coordinates import SkyCoord
import matplotlib.pyplot as plt
import numpy as np
import h5py

dat = []

ggl=[]

ggb=[]

with h5py.File('faraday2020.hdf5','r') as hdf:
    print(list(hdf.keys()))
    faraday_sky_mean = hdf['faraday_sky_mean'][:]
    faraday_sky_std = hdf['faraday_sky_std'][:]
    
print(faraday_sky_mean.shape,faraday_sky_mean.dtype) 
print(f'Max Mean={max(faraday_sky_mean)},Min Mean={min(faraday_sky_mean)}') 
print(faraday_sky_std.shape,faraday_sky_std.dtype) 
print(f'Max StdDev={max(faraday_sky_std)},Min StdDev={min(faraday_sky_std)}') 

ggl = faraday_sky_mean.tolist()
print(len(ggl),type(ggl[0]))
ggb = faraday_sky_std.tolist()
print(len(ggb),type(ggb[0]))

gl = ggl * u.degree
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
b_rad = c.b.radian

###
plt.figure(figsize=(8,4.2))
plt.subplot(111,projection="aitoff")

plt.title("Mean and standard dev",y=1.08,fontsize=20)
plt.grid(True)

P1=plt.plot(l_rad,b_rad,c="blue",s=220,marker="h",alpha=0.7) #,plt.subplots_adjust(top=0.95,bottom=0.0)
plt.xlabel('l (deg)',fontsize=20)
plt.ylabel('b (deg)',fontsize=20)

plt.subplots_adjust(top=0.95,bottom=0.0)
plt.show()

但是,我收到以下错误:

'got {}'.format(angles.to(u.degree)))

ValueError: Latitude angle(s) must be within -90 deg <= angle <= 90 deg,got [1.12490771 0.95323024 0.99124631 ... 4.23648627 4.28821608 5.14498169] deg

请帮助我解决这个问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)