2

我有一组用三脚架上的相机拍摄的许多天文照片。使用气泡水平仪确保框架的长边与地平线平行,并且我知道每张照片中心的 alt/az(和赤道)坐标。

现在我正在编写一些 python 代码来在每个图像上覆盖一个指示器以标记北方向。对于给定的 alt/az 坐标,我可以使用 pyephem 获取北天极方向和水平方向之间的角度吗?有什么线索吗?

4

3 回答 3

2

无论您是想用十字或圆点标记北天极,还是在地平线上的北极点做一个标记,您都在问一个真正与您的相机镜头有关的问题:您的特定镜头如何?拍摄照片时使用的确切焦距,将弯曲的天空映射到相机传感器的平面上?

这不仅是天文学所面临的挑战,任何拍照然后想稍后将图像用于测量或空间计算的人都面临着挑战。

我听说专业天文学家使用了一个名为 FITS 的库。我的印象是,如果你向图书馆解释你的相机有什么样的镜头以及它会产生什么样的失真,它可以告诉你每个像素的坐标——这应该让你找到天北的点:

http://fits.gsfc.nasa.gov/fits_libraries.html

于 2013-06-28T02:43:17.997 回答
2

我会尝试为您的每个图像创建一个“世界坐标系”(WCS),这本质上是您的像素坐标和天空坐标(即 RA 和 12 月)之间的映射。您可以使用诸如http://astrometry.net上提供的工具来根据图像中可见的星形图案自动解决您的图像。这将为图像生成一个 WCS。

astrometry.net 求解器(如果您安装了适当的依赖项)可以生成带有已知天体标记的图像的 png 版本。这可能足以满足您的目的,但如果没有,您可以使用 astropy.wcs 包将图像 WCS 读入 python 并使用它来确定图像的方向,然后根据需要标记图像。

这是一些快速而肮脏的代码,您可能会尝试适应您的目的:

import math
import subprocess
import astropy.units as u
import astropy.fits as fits

## Solve the image using the astrometry.net solve-field tool.
## You'll want to look over the options for solve-field and adapt this call
## to your images.
output = subprocess.check_output(['solve-field', filename])

## Read Header of Image (assumes you are working off a fits file with a WCS)
## If not, you can probably read the text header output my astrometry.net in
## a similar fashion.
hdulist = fits.open(solvedFilename)
header = hdulist[0].header
hdulist.close()
CD11 = float(header['CD1_1'])
CD12 = float(header['CD1_2'])
CD21 = float(header['CD2_1'])
CD22 = float(header['CD2_2'])

## This is my code to interpet the CD matrix in the WCS and determine the
## image orientation (position angle) and flip status.  I've used it and it
## seems to work, but there are some edge cases which are untested, so it
## might fail in those cases.
## Note: I'm using astropy units below, you can strip those out if you keep
## track of degrees and radians manually.
if (abs(CD21) > abs(CD22)) and (CD21 >= 0): 
    North = "Right"
    positionAngle = 270.*u.deg + math.degrees(math.atan(CD22/CD21))*u.deg
elif (abs(CD21) > abs(CD22)) and (CD21 < 0):
    North = "Left"
    positionAngle = 90.*u.deg + math.degrees(math.atan(CD22/CD21))*u.deg
elif (abs(CD21) < abs(CD22)) and (CD22 >= 0):
    North = "Up"
    positionAngle = 0.*u.deg + math.degrees(math.atan(CD21/CD22))*u.deg
elif (abs(CD21) < abs(CD22)) and (CD22 < 0):
    North = "Down"
    positionAngle = 180.*u.deg + math.degrees(math.atan(CD21/CD22))*u.deg
if (abs(CD11) > abs(CD12)) and (CD11 > 0): East = "Right"
if (abs(CD11) > abs(CD12)) and (CD11 < 0): East = "Left"
if (abs(CD11) < abs(CD12)) and (CD12 > 0): East = "Up"
if (abs(CD11) < abs(CD12)) and (CD12 < 0): East = "Down"
if North == "Up" and East == "Left": imageFlipped = False
if North == "Up" and East == "Right": imageFlipped = True
if North == "Down" and East == "Left": imageFlipped = True
if North == "Down" and East == "Right": imageFlipped = False
if North == "Right" and East == "Up": imageFlipped = False
if North == "Right" and East == "Down": imageFlipped = True
if North == "Left" and East == "Up": imageFlipped = True
if North == "Left" and East == "Down": imageFlipped = False
print("Position angle of WCS is {0:.1f} degrees.".format(positionAngle.to(u.deg).value))
print("Image orientation is North {0}, East {1}.".format(North, East))
if imageFlipped:
    print("Image is mirrored.")

## Now you have position angle and flip status and can mark up your image
于 2013-08-12T22:19:09.247 回答
0

只是为了获得正确方向的第一点,所有这些都可以简化为:

    positionAngle = np.degrees(np.arctan2(CD12, CD11))

因为 NumPy (np) 的帮助可以在所有情况下(象限)正确处理 arctan 函数。

米歇尔

编辑:如果您想检测图像是否被镜像:计算矩阵的行列式,如

mirrored = (CD11 * CD22 - CD12 * CD21) < 0

并检查它是否 < 0。比转换内部有镜像。

于 2019-02-13T19:39:32.563 回答