Commit f3068b83 authored by Zheng Gaoshan's avatar Zheng Gaoshan
Browse files

Update test.py

parent 5960c93f
from astroquery.mast import Observations
from astropy.io import fits
from astropy.visualization import simple_norm
import matplotlib.pyplot as plt
from ccdproc import CCDData
# 查询并下载观测数据
obs_table = Observations.query_criteria(dataproduct_type=["image"], obs_collection="HST", instrument_name="ACS/WFC")
data_products_by_obs = Observations.get_product_list(obs_table[0])
download_info = Observations.download_products(data_products_by_obs[:1], productType="SCIENCE")
# 加载FITS文件
fits_file_path = download_info['obs_id', 'local_path'][0]['local_path']
hdu_list = fits.open(fits_file_path)
hdu = hdu_list[0]
# 将HDU对象转换为CCDData对象,便于后续处理
ccd_image = CCDData(hdu.data, unit="adu")
# 使用ccdproc进行基本处理,比如减去平均值
processed_image = ccd_image.subtract(ccd_image.mean())
# 显示处理前后的图像
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 7))
norm = simple_norm(hdu.data, 'sqrt', percent=99)
ax1.imshow(hdu.data, norm=norm, origin='lower')
ax1.set_title('原始图像')
norm_processed = simple_norm(processed_image.data, 'sqrt', percent=99)
ax2.imshow(processed_image.data, norm=norm_processed, origin='lower')
ax2.set_title('处理后图像')
plt.show()
# 关闭fits文件以释放资源
hdu_list.close()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment