Astropy Cutout2D,提升值

2024-04-18 02:48:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用Astropy的Cutout2D测试presented procedure。我的目标是使用RA和DEC为我在ground truth目录中的每个源提取一个.png图像

文件的标题:

SIMPLE  =                    T  /                                               
BITPIX  =                  -32  /                                               
NAXIS   =                    4  /                                               
NAXIS1  =                30000  /                                               
NAXIS2  =                30000  /                                               
NAXIS3  =                    1  /                                               
NAXIS4  =                    1  /                                               
EXTEND  =                    T  /                                               
BSCALE  =    1.00000000000E+00  /                                               
BZERO   =    0.00000000000E+00  /                                               
BLANK   =                   -1  /                                               
BUNIT   = 'JY/BEAM '  /                                                         
DATE-OBS= '2000-01-01T12:00:00.0'  /                                            
CRPIX1  =    1.63840000000E+04  /                                               
CDELT1  =   -6.71387000000E-05  /                                               
CRVAL1  =    0.00000000000E+00  /                                               
CTYPE1  = 'RA---SIN'  /                                                         
CRPIX2  =    1.63840000000E+04  /                                               
CDELT2  =    6.71387000000E-05  /                                               
CRVAL2  =   -3.00000000000E+01  /                                               
CTYPE2  = 'DEC--SIN'  /                                                         
CRPIX3  =    1.00000000000E+00  /                                               
CDELT3  =    4.20000000000E+08  /                                               
CRVAL3  =    1.40000000000E+09  /                                               
CTYPE3  = 'FREQ    '  /                                                         
CRPIX4  =    1.00000000000E+00  /                                               
CDELT4  =    1.00000000000E+00  /                                               
CRVAL4  =    1.00000000000E+00  /                                               
CTYPE4  = 'STOKES  '  /        
...      

我使用从文档中复制的小脚本:

^{pr2}$

我明白了:

Traceback (most recent call last):
  File "###/Cutoff_patches.py", line 113, in <module>
    cutout = Cutout2D(data, position, size,   wcs=w)
  File "##_venv/lib/python3.5/site-packages/astropy/nddata/utils.py", line 686, in __init__
    return_position=True)
  File "##_venv/lib/python3.5/site-packages/astropy/nddata/utils.py", line 211, in extract_array
    shape, position, mode=mode)
  File "##_venv/lib/python3.5/site-packages/astropy/nddata/utils.py", line 91, in overlap_slices
    raise ValueError('"large_array_shape" and "small_array_shape" must '
ValueError: "large_array_shape" and "small_array_shape" must have the same number of dimensions.

我不知道为什么会这样,也不知道怎么解决。在

我还尝试了重塑,如前所述:

data = data.reshape(data.shape[2:])

而且

data=np.squeeze(data)

但我发现他们俩都是一样的:

Traceback (most recent call last):
  File "##/Cutoff_patches.py", line 114, in <module>
    cutout = Cutout2D(data, position, size,   wcs=w)
  File "##venv/lib/python3.5/site-packages/astropy/nddata/utils.py", line 686, in __init__
    return_position=True)
  File "/##_venv/lib/python3.5/site-packages/astropy/nddata/utils.py", line 211, in extract_array
    shape, position, mode=mode)
  File "##_venv/lib/python3.5/site-packages/astropy/nddata/utils.py", line 106, in overlap_slices
    raise NoOverlapError('Arrays do not overlap.')
astropy.nddata.utils.NoOverlapError: Arrays do not overlap.

Process finished with exit code 1

Tags: inpydatavenvlibpackageslinesite