2014-12-02 1 views
0

나는 RGB 이미지 세트를 가지고 있는데 RGB 이미지를 aplpy으로 맞추고 이미지에 약간의 등고선을 입혔지만 이미지를 자르고 이미지를 작게 만들고 싶습니다. 윤곽선이 보일 것입니다.천문학적 인 이미지에서 서브 플로트 만들기

import aplpy 
import atpy 
from pyavm import AVM 
import asciitable 
import matplotlib 
import matplotlib.pyplot as plt 
from matplotlib.colors import LogNorm,BoundaryNorm 
import montage_wrapper 
from astropy.io import fits 
import pyfits 
from astropy import wcs 
fitsfile = 'rgb.fits' 
fitsfile_2d = 'rgb_2d.fits' 
pngfile = 'rgb_arcsinh_contour.png' 

figfile = 'rgb.png' 
w = wcs.WCS(naxis=2) 

# Set up an "Airy's zenithal" projection 
# Vector properties may be set with Python lists, or Numpy arrays 
w.wcs.crpix = [5.70000000E+03, 3.05000000E+03] 
w.wcs.cdelt = np.array([-6.611111263E-05, 6.611111263E-05]) 
w.wcs.crval = [23.166667, -7.666667] 
w.wcs.ctype = ["RA---TAN", "DEC--TAN"] 
w.wcs.cunit =["deg","deg"] 

# Print out all of the contents of the WCS object 
w.wcs.print_contents() 

# Some pixel coordinates of interest. 
pixcrd = np.array([[0,0],[24,38],[45,98]], np.float_) 

# Convert pixel coordinates to world coordinates 
world = w.wcs_pix2world(pixcrd, 1) 
print world 

# Convert the same coordinates back to pixel coordinates. 
pixcrd2 = w.wcs_world2pix(world, 1) 
print pixcrd2 

# These should be the same as the original pixel coordinates, modulo 
# some floating-point error. 
assert np.max(np.abs(pixcrd - pixcrd2)) < 1e-6 

# Now, write out the WCS object as a FITS header 
header = w.to_header() 
hdu = pyfits.open(fitsfile) 
# header is an astropy.io.fits.Header object. We can use it to create a new 
# PrimaryHDU and write it to a file. 
hdu = fits.PrimaryHDU(header=header) 


# make rgb image 
aplpy.make_rgb_image(fitsfile, pngfile, 
        vmin_r=-0.005, vmax_r=0.2, 
        vmin_g=-0.02, vmax_g=0.1, 
        vmin_b=-0.02,vmax_b=0.04, 
        embed_avm_tags=False) 

# make a figure 
img = aplpy.FITSFigure(fitsfile_2d) 
img.show_rgb(pngfile) 
img.set_nan_color('white') 
standard_setup(img) 

주어진 크기의 이미지 좌표에서 서브 그림을 만들 수 있습니까?

답변

1

APLpy 문서에 따르면, 당신은 subplots을 할 수 있습니다 : 기본적으로

는 FITSFigure는 전체 그림을 차지 하나의 부가 적 줄거리와 그림을 만듭니다. 그러나 APLpy를 사용하면 기존 matplotlib Figure 인스턴스에 하위 그림을 배치 할 수 있습니다. 이렇게하려면 다음과 같이 FITSFigure은 = 그림과 인수를 호출해야합니다 :

import aplpy 
import matplotlib.pyplot as mpl 

fig = mpl.figure() 
f = aplpy.FITSFigure('some_image.fits', figure=fig) 

recenter 당신의 그림 :

그림은 대화식으로 줌과 패닝으로 탐색 할 수 있습니다.

fig.recenter(33.23, 55.33, radius=0.3) # degrees

또는 별도의 폭과 높이 : I가 테스트 한

fig.recenter(33.23, 55.33, width=0.3, height=0.2) # degrees

프로그램 특정 영역에 다시 가운데에 하나 반경을 지정하여 다음 방법을 사용 왜냐하면 나 또한 APLpy를 사용하기 때문에 나에게 도움이된다.

HTH,

German.

+0

축의 일부만을 원할 경우 FITSFigure에''subplot'' 인수를 추가 할 수 있습니다. – astrofrog

+0

@astrofrog 어떻게하면 저장된 그림의 해상도를 높이고 적절한 배경색을 조정할 수 있습니까? – Dalek

+0

해결 방법은 다음을 추가하십시오. ''d' = 300''을''save'' 명령에 사용합니다. 배경색은 축이나 그림을 의미합니까? – astrofrog

관련 문제