3.2. cpforager.processing.add_is_night

cpforager.processing.add_is_night(df, params)

Add to the dataframe an additional is_night boolean column worth 1 if it is night, 0 otherwise.

Parameters:
  • df (pandas.DataFrame) – dataframe with a datetime column.

  • params (dict) – parameters dictionary.

Returns:

the dataframe with an additional is_night boolean column worth 1 if it is night, 0 otherwise.

Return type:

pandas.DataFrame

The boolean value is computed using suntime and pytz Python package. Night is defined using the sunrise and sunset times at the colony center.

Note

The required fields in the parameters dictionary are colony and local_tz.

Warning

Dataframe datetime column must be at local time. The accuracy of is_night column depends on it.