text_html_output_1.png text_plain_output_1.png
import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import pymap3d as pm

nyra_tracking = pd.read_csv('/kaggle/input/big-data-derby-2022/nyra_tracking_table.csv')
nyra_start = pd.read_csv('/kaggle/input/big-data-derby-2022/nyra_start_table.csv')
nyra_race = pd.read_csv('/kaggle/input/big-data-derby-2022/nyra_race_table.csv')

track_id = 'SAR'
race_date = '2019-07-24'
race_number = 5
target_tracking = nyra_tracking.query('track_id == @track_id & race_date == @race_date & race_number == @race_number').sort_values('trakus_index')
target_tracking

dtime = 0.25
if track_id == 'AQU':
    elevation = 3
elif track_id == 'BEL':
    elevation = 20
elif track_id == 'SAR':
    elevation = 93
target_trackings = []
for number, group in target_tracking.groupby('program_number'):
    ecef = np.array(pm.geodetic2ecef(group['latitude'].values, group['longitude'].values, np.array([elevation] * len(group)))).T
    v_ecef = np.sqrt(np.sum(np.diff(ecef, axis=0) ** 2, axis=1)) * 3.6 / dtime
    group['time'] = group['trakus_index'] * dtime - dtime
    group['speed'] = np.insert(v_ecef, 0, 0)
    target_trackings.append(group)
    print('No.', number, ' Mean speed : {:.2f} km/h'.format(np.mean(v_ecef)))
target_tracking = pd.concat(target_trackings)
target_tracking