Skip to content

Clarify pytz localization steps in documentation #1199

@rhine3

Description

@rhine3

Current localization requires pytz-localized timestamps to run (but see: #1197). Add a few clarifying notes about this in the documentation:

  • Expose the documentation about the need for localized datetimes in the higher level localize_detections function, as currently it's only exposed in create_candidate_events -
    Example of adding `start_timestamp` to multi-index of detections df manually:
    ```python
    # assume we have a csv with columns file, start_time, end_time, class1, ...
    # e.g., the output of and opensoundscape CNN prediction workflow
    detections = pd.read_csv('my_opso_detections.csv',index_col=[0,1,2])
    # let's assume all files started recording at the same time for this example:
    import pytz
    import datetime
    tz = pytz.timezone('America/New_York')
    detections = detections.reset_index(drop=False)
    detections['start_timestamp']=[
    datetime.datetime(2024,1,1,10,0,0).astimezonoe(tz)+
    datetime.timedelta(detections.at[i,'start_time'])
    for i in detections.index
    ]
    # add the start_timestamp column into the multi-index
    detections = detections.reset_index(drop=False).set_index(
    ["file", "start_time", "end_time", "start_timestamp"]
    )
    ```
  • See if we can fix the Python code rendering in RTD in this context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions