CroatianMeteorNetwork / RMS

RPi Meteor Station
https://globalmeteornetwork.org/
GNU General Public License v3.0
169 stars 47 forks source link

rotationWrtHorizon function logic? #211

Closed Cybis320 closed 7 months ago

Cybis320 commented 9 months ago

The rotationWrtHorizon function in ApplyAstrometry.py is calculating the rotation from horizontal by comparing the altitude of a point 10 px right of image center to the altitude of the image center. However, even for a perfectly undistorted level image this calculation would not give a rotation of zero because the altitudes would typically decrease panning away from the image center. Even over only 10 px, the error is not negligible (in the order of 0.2 degrees).

comparing 5px on each side of center might be better, no? Like so:

def rotationWrtHorizon(platepar):

    dx = 5

    # Image coordiantes left of the center
    img_mid_w = (platepar.X_res/2) - dx
    img_mid_h = platepar.Y_res/2

    # Image coordinate slighty right of the center (horizontal)
    img_up_w = img_mid_w + 2*dx
    img_up_h = img_mid_h

Also this bit is problematic:

rot_angle = np.degrees(np.arctan2(alt_up - alt_mid, azim_up - azim_mid))

Let's say the image center is close to north, the azim_mid might be 359, and azim_up might be 1 deg. We would then measure the alt diff over -358 deg instead of 2 deg.

This would solve the issue:

# Compute the rotation wrt horizon (deg)
    diff = azim_up - azim_mid
    print(diff)
    while diff < -np.pi:
        diff += 2 * np.pi
    while diff > np.pi:
        diff -= 2 * np.pi
    print(diff)
    rot_angle = np.degrees(np.arctan2(alt_up - alt_mid, diff))

I was also wondering: it's calculating negative values for image rotated clockwise; meaning if we associate clockwise with positive, it's calculating the stars rotation relative to the image, not the image rotation relative to the stars. Was that the intention?

Cybis320 commented 7 months ago

I'm closing this issue as the RMS code doesn't actually need an accurate rotation with respect to horizon. All it needs is a consistent rotation anchor, which the original code provides. The somewhat arbitrary number provided is fine as long as it is consistent. My suggestion above to compute an accurate angle doesn't actually accomplish that.