flasc.data_processing.dataframe_manipulations.is_day_or_night

flasc.data_processing.dataframe_manipulations.is_day_or_night#

flasc.data_processing.dataframe_manipulations.is_day_or_night(df: DataFrame | FlascDataFrame, latitude: float, longitude: float, sunrise_altitude: float = 0, sunset_altitude: float = 0, lag_hours: float = 0, datetime_column: str = 'time') DataFrame | FlascDataFrame[source]#

Determine night or day in dataframe.

Determine whether it's day or night for a given set of coordinates and UTC timestamp in a DataFrame.

Parameters:
  • df (pd.DataFrame | FlascDataFrame) -- A Pandas DataFrame containing the time in UTC and other relevant data.

  • latitude (float) -- The latitude of the location for which to determine day or night.

  • longitude (float) -- The longitude of the location for which to determine day or night.

  • sunrise_altitude (float) -- The altitude of the sun to denote that sunrise has occurred [degress]

  • sunset_altitude (float) -- The altitude of the sun to denote that sunset has occurred [degress]

  • lag_hours (float, optional) -- The number of hours to lag behind the timestamp for the daylight

  • 0. (determination. Default is)

  • datetime_column (str, optional) -- The name of the DataFrame column containing the timestamp in UTC. Default is 'time'.

Returns:

The input DataFrame with two additional

columns: 'sun_altitude' (the sun's altitude at the given timestamp) and 'is_day' (a boolean indicating whether it's daytime at the given timestamp).

Return type:

pd.DataFrame | FlascDataFrame