import astropy.units as u
import numpy as np
from astropy.io import fits
from astropy.wcs import WCS
import matplotlib.pyplot as plt
from astropy.visualization import simple_norm
from astropy.coordinates import SkyCoord, Galactic
file = "hi4pi-hvc-vlsr-gal-car.fits"
hdul = fits.open(file)
hdr = hdul[0].header
data = hdul[0].data
wcs = WCS(hdr)
norm = simple_norm(data, "linear")
# Plot image on axes ax
fig, ax = plt.subplots(figsize=(10, 6), subplot_kw={"projection": wcs})
cmap = plt.get_cmap("RdBu", 20)
im = ax.imshow(data, cmap=cmap)
ax.set_xlabel("Galactic Longitude")
ax.set_ylabel("Galactic Latitude")
overlay = ax.get_coords_overlay("icrs")
major_ticks = np.arange(0, 360, 30)
#ax.set_xticks(major_ticks)
overlay.grid(color="grey", ls="dotted")
plt.colorbar(im, orientation="horizontal")
plt.savefig("area.png", dpi=300, bbox_inches="tight")
plt.show()
我想将 RA 网格设置为
np.arange(0,360,30)
,30 度间隔而不是 90 度间隔。
右侧的
dec
标签最好是Dec
,但我不知道如何更改它。
适合的文件在这里:Westmeier 2018
WCS Keywords
Number of WCS axes: 2
CTYPE : 'GLON' 'GLAT'
CRVAL : np.float64(180.000000024) np.float64(0.0)
CRPIX : np.float64(2162.0) np.float64(1080.0)
PC1_1 PC1_2 : np.float64(1.0) np.float64(0.0)
PC2_1 PC2_2 : np.float64(0.0) np.float64(1.0)
CDELT : np.float64(-0.0833333333) np.float64(0.0833333333)
NAXIS : 4323 2144
不知道如何设置
overlay.grid
的网格间隔。我检查了文档,但似乎没有任何功能。