Skip to content

Instantly share code, notes, and snippets.

@randyzwitch
Created March 4, 2020 20:17
Show Gist options
  • Select an option

  • Save randyzwitch/db0b7b6cb6dd7b4afa2358f19e18686a to your computer and use it in GitHub Desktop.

Select an option

Save randyzwitch/db0b7b6cb6dd7b4afa2358f19e18686a to your computer and use it in GitHub Desktop.

Revisions

  1. randyzwitch created this gist Mar 4, 2020.
    20 changes: 20 additions & 0 deletions telemetry.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    def get_telemetry_data(sessionuid, lapstarttime, lapendtime, playercarindex, metric):

    conn = pymapd.connect(host = host, user = user, password = password, dbname = dbname, port = port)

    ## get telemetry data
    ## by specifying the timestamps and sessionuid, it implies a single track
    tele = f"""select
    packettime,
    max({metric}) as {metric}
    from gtc_cartelemetry_v2
    where sessionuid = '{sessionuid}' and
    packettime between '{lapstarttime}' and '{lapendtime}' and
    playercarindex = {playercarindex}
    group by 1
    order by 1
    """

    telemetry_ref = pd.read_sql(tele, conn)

    return telemetry_ref