I have a pandas dataframe indexed by a time series with columns of GPS latitude and acceleration for a satellite orbiting the Earth. This latitude oscillates between maximum and minimum values with a constant time period as expected. What I want to do is integrate the acceleration column over each orbital period.
I understand I need to use the pandas 'groupby' method to group each period. Howeve, I can't figure out how I can group the consecutive rows into orbital periods (say iterating through it and grouping until I hit the maximum latitude value thus defining the end of an orbit?). After grouping I can then apply a numerical integration on each period.
An example code generating a similar DataFrame is given below.
from scipy import signal
t = np.linspace(0, 1, 500)
np.random.seed(0) # make sure we will get the same values every time
df = pd.DataFrame(
{'Lat': signal.sawtooth(2 *np.pi * 5 * t, 0.5),
'Acc': np.random.rand(500)},
index=pd.date_range('1/1/2011 00:00:00.006392', periods=500, freq='10ms')
)
Any help would be much appreciated. And any more information please ask!