Skip to content

Commit

Permalink
add _read_Illuminance_file tool
Browse files Browse the repository at this point in the history
  • Loading branch information
anine09 committed May 10, 2023
1 parent 2ea9693 commit cb61889
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mpone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from .utils._show_versions import show_versions
from .utils._list_instrument import list_instrument
from .graph import *
from .utils.read_thermometer_file import read_thermometer_file
from .utils._read_thermometer_file import read_thermometer_file
from .utils._read_Illuminance_file import read_Illuminance_file


__all__ = [
"plot"
Expand Down
17 changes: 17 additions & 0 deletions mpone/utils/_read_Illuminance_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pandas as pd

def read_Illuminance_file(file):
data = pd.read_excel(file)
time_data =pd.read_excel(file, sheet_name="Metadata Time")

start_time = time_data.loc[time_data['event'] == 'START', 'system time text'].item()[:-10]

data['Time (s)'] = pd.to_datetime(start_time) + pd.to_timedelta(data['Time (s)'], unit='s')
data['Time (s)'] = data['Time (s)'].dt.strftime('%H:%M:%S')

data_mean = data.groupby("Time (s)")["Illuminance (lx)"].mean().reset_index()
data_result = data_mean[data_mean["Illuminance (lx)"].notnull()].drop_duplicates()
data_result = data_result.rename(columns={'Time (s)': 'Time'})
data_result = data_result.rename(columns={'Illuminance (lx)': 'Illuminance'})

return data_result
File renamed without changes.

0 comments on commit cb61889

Please sign in to comment.