<p>Below is my current solution, run once to calculate the angle at start of observation, then when run again at any time give you the live rotation angle. It's far from perfect but does work. Unsure if something like this could be improved and included in Skyfield</p>
<pre><code>def fieldRotationRef(self,Object1=None,Object2=None): #both objects in absolute positions

    #Find the angle of Object2 with respect to the plane defined by horizon to Object1
    me = self.obs + self.planets['earth']
    mexyz = me.at(t).position.au
    alt1,az1,dist1 = Object1.apparent().altaz()
    alt2,az2,dist2 = Object2.apparent().altaz()
    alt1r = alt1.radians
    alt2r = alt2.radians
    az1r = az1.radians
    az2r = az2.radians
    alt1 = alt1.degrees
    alt2 = alt2.degrees
    az1 = az1.degrees
    az2 = az2.degrees
    Object1xyz = np.array([math.cos(az1r)*math.cos(alt1r),math.sin(az1r)*math.cos(alt1r),math.sin(alt1r)])
    Object2xyz = np.array([math.cos(az2r)*math.cos(alt2r),math.sin(az2r)*math.cos(alt2r),math.sin(alt2r)])
    Object0xyz = np.array([math.cos(az1r)*math.cos(alt1r),math.sin(az1r)*math.cos(alt1r),0])
    v01 = Object1xyz - Object0xyz
    v02 = Object2xyz - Object0xyz
    cosine_angle = np.dot(v01, v02) / (np.linalg.norm(v01) * np.linalg.norm(v02))
    angle = np.degrees(np.arccos(cosine_angle))
</code></pre>

CC BY-SA 4.0
2024-05-17T00:28:31.950Z
2024-05-17T00:28:31.950Z
Tanenthor
<p>I have the formulae to calculate the rate of field rotation at any given time, and using a python script with Skyfield I can generate a a value incrementing every 10th of a second based on the live data, but is there any way to calculate how much field rotation there has been between now and start of observation ~10 minutes ago without drift?</p>

<rotation><python><skyfield>
Calculating field rotation between two times
Tanenthor
# Calculating field rotation between two times

(Asked by: username_0 on 2024-04-26)

I have the formulae to calculate the rate of field rotation at any given time, and using a python script with Skyfield I can generate a a value incrementing every 10th of a second based on the live data, but is there any way to calculate how much field rotation there has been between now and start of observation ~10 minutes ago without drift?

**Tags:** rotation, python, skyfield


---

## 1 answers

### Answer by username_0 on 2024-05-17. Score: 1

Below is my current solution, run once to calculate the angle at start of observation, then when run again at any time give you the live rotation angle. It's far from perfect but does work. Unsure if something like this could be improved and included in Skyfield

```
def fieldRotationRef(self,Object1=None,Object2=None): #both objects in absolute positions

    #Find the angle of Object2 with respect to the plane defined by horizon to Object1
    me = self.obs + self.planets['earth']
    mexyz = me.at(t).position.au
    alt1,az1,dist1 = Object1.apparent().altaz()
    alt2,az2,dist2 = Object2.apparent().altaz()
    alt1r = alt1.radians
    alt2r = alt2.radians
    az1r = az1.radians
    az2r = az2.radians
    alt1 = alt1.degrees
    alt2 = alt2.degrees
    az1 = az1.degrees
    az2 = az2.degrees
    Object1xyz = np.array([math.cos(az1r)*math.cos(alt1r),math.sin(az1r)*math.cos(alt1r),math.sin(alt1r)])
    Object2xyz = np.array([math.cos(az2r)*math.cos(alt2r),math.sin(az2r)*math.cos(alt2r),math.sin(alt2r)])
    Object0xyz = np.array([math.cos(az1r)*math.cos(alt1r),math.sin(az1r)*math.cos(alt1r),0])
    v01 = Object1xyz - Object0xyz
    v02 = Object2xyz - Object0xyz
    cosine_angle = np.dot(v01, v02) / (np.linalg.norm(v01) * np.linalg.norm(v02))
    angle = np.degrees(np.arccos(cosine_angle))

```


---

