4

我正在尝试使用 astropy 中的 SphericalCircle 模块在银河坐标系中绘制球面。我无法将银河经度角包裹在 (-180, 180) 度而不是默认的 (0, 360) 度之间。下面是我正在尝试做的一个例子。

import numpy as np
import matplotlib.pyplot as plt
from astropy import units as u
from astropy.coordinates import SkyCoord
from matplotlib.collections import PatchCollection
from astropy.visualization.wcsaxes import SphericalCircle

glat = np.random.uniform(-90, 90, 100)
glong = np.random.uniform(-180, 180, 100)
data = np.column_stack((glong, glat)) 
gal = SkyCoord(l = data[:,0] * u.deg, b = data[:,1] * u.deg, frame='galactic')
gal_long = gal.l.wrap_at(180*u.deg).deg 

fig,ax = plt.subplots(1)

all_beams = []
for i in range(len(gal)):

    beam = SphericalCircle(center=(gal_long[i] * u.deg, gal[i].b.deg * u.deg), \
                          radius = 7*u.arcmin, facecolor="None",  edgecolor="black", linewidth=2)

    all_beams.append(beam)


pc = PatchCollection(all_beams, match_original=False, lw=3,  facecolor='white', 
edgecolor='k')
ax.add_collection(pc)
ax.set_xlim(-180,360)
ax.set_ylim(-90,90)
plt.show()

更新 1:添加更多详细信息。行 gal_long = gal.l.wrap_at(180*u.deg).deg 将经度包裹在 (-180, 180) 之间,但看起来 SphericalCircle 默认将其更改回 (0, 360)。有没有办法强制 SphericalCircle 在 (-180, 180) 约定中返回圆?

4

0 回答 0