r files changes

This commit is contained in:
Aurélien Gauthier 2026-01-16 11:11:44 +01:00
parent 5884d61f26
commit 4cf327504f
6 changed files with 1906 additions and 595 deletions

View file

@ -11,9 +11,9 @@ chemin <- "../data/photo_measures/"
fichiers <- list.files(path = chemin, pattern = "\\.csv$", full.names = TRUE)
liste_data <- lapply(fichiers, read.csv, header = TRUE)
partial_list_data <- liste_data[3:6]
#partial_list_data <- liste_data[3:6]
photo <- do.call(rbind, partial_list_data)
photo <- do.call(rbind, liste_data)
csv_name <- "merged_photo_data.csv"
csv_path_name <- paste(c(chemin, csv_name), collapse = "")

File diff suppressed because it is too large Load diff

View file

@ -19,15 +19,16 @@ summary(liste_data)
print(typeof(liste_data))
# partial_list_data <- liste_data[1:2]
partial_list_data <- liste_data[3:6]
partial_list_data <- liste_data[7:8]
photo <- do.call(rbind, partial_list_data)
max_val_sensor = 254
photo <- photo %>%
mutate(across(starts_with("Photo_sensor"), ~ {
.x <- sqrt(.x)
# .x <- (.x*-1) + max_val_sensor
# .x <- as.numeric(scale(.x, center = TRUE, scale = TRUE))
# .x <- sqrt(.x)
# max_val_sensor = sqrt(max_val_sensor)
.x <- (.x*-1) + max_val_sensor
.x <- as.numeric(scale(.x, center = TRUE, scale = TRUE))
}))
photo$time <- as.POSIXct(photo$Epoch)

View file

@ -5,19 +5,20 @@ library(ggplot2)
library(lubridate)
library(dplyr)
library(randomForest)
library(suntools)
setwd("~/Documents/PlatformIO/Projects/Robot_Go_West/arduino-photometrics/exec")
# Load
solar <- read.csv("../data/solar_pos_data/solar_data_2026-01-05_to_2026-01-10.csv", header=TRUE)
photo <- read.csv("../data/photo_measures/merged_photo_data.csv", header=TRUE)
# solar <- read.csv("../data/solar_pos_data/solar_data_2026-01-13_to_2026-01-16.csv", header=TRUE)
photo <- read.csv("../data/photo_measures/arduino_data_package_auto_20260116_094653.csv", header=TRUE)
# Time type changes
photo$time <- as.POSIXct(photo$Epoch)
# photo$time <- as.POSIXct(photo$Epoch)
photo <- photo %>%
mutate(
datetime = as.POSIXct(Epoch, origin = "1970-01-01", tz = "UTC"),
datetime = as.POSIXct(Epoch, origin = "1970-01-01", tz = "Europe/Paris"),
jour = as.Date(datetime),
num_jour = as.numeric(format(datetime, "%j")),
@ -30,8 +31,6 @@ photo <- photo %>%
cos_hour = cos(rad_hour)
)
# Transform data to improve learning during the training phase
solar$sin_azimut <- sin(solar$azimut)
# Same but normalised values are square root to highlight little light variations
max_val_sensor = 254
@ -46,22 +45,33 @@ photo <- photo %>%
photo <- photo %>%
select(where(~ !all(is.na(.x))))
# select the nearest time raw of the sun position
max_timestamp = as.integer(max(photo$Epoch))
min_timestamp = as.integer(min(photo$Epoch))
elapsed_time = photo$Epoch[4] - photo$Epoch[3]
filtered_solar <- solar %>%
filter(utime > (min_timestamp - elapsed_time) &
utime < (max_timestamp + elapsed_time))
remove(solar)
# merge
binded <- bind_cols(filtered_solar, photo)
# retreive solar pos
remove(filtered_solar, photo)
unix_time <- as.numeric(photo$datetime)
lat <- 44.7912
lon <- -0.6078
coords <- matrix(c(lon, lat), nrow = 1)
positions <- solarpos(coords, photo$datetime)
df_soleil <- data.frame(
timestamp = photo$datetime,
utime = unix_time,
azimut = positions[, 1],
elevation = positions[, 2]
)
# Transform data to improve learning during the training phase
df_soleil$sin_azimut <- sin(df_soleil$azimut)
binded <- bind_cols(df_soleil, photo)
remove(df_soleil)
# Check elapsed time
binded$gap_time <- abs(binded$utime - binded$Epoch)

View file

@ -8,8 +8,8 @@ library(lubridate)
lat <- 44.7912
lon <- -0.6078
tz <- "Europe/Paris"
d_deb <- "2026-01-05"
d_fin <- "2026-01-10"
d_deb <- "2026-01-13"
d_fin <- "2026-01-16"
date_debut <- as.POSIXct(d_deb, tz = tz)
date_fin <- as.POSIXct(d_fin, tz = tz)

View file

@ -15,7 +15,7 @@ uint8_t ledPin = 2, alarm_pin = 19, decTemp = 4, nb_average_measure = 10; // nb
const uint8_t nbPhotoSensor = 6, nbTempSensor = 1;
uint8_t analogPin [nbPhotoSensor] = {A0, A1, A2 ,A3 ,A5 ,A6}, schedule = 0, photo_sensor_size = sizeof(uint8_t), temp_sensor_size = sizeof(uint8_t);
int32_t min_res [nbPhotoSensor] = {128- 30, 160-30, 193-80, 96-10, 323-180, 96-10}; // Manual measurement of personal sensors
int32_t max_res [nbPhotoSensor] = {2062273, 5554006, 784809, 4755895, 1939035, 289546}; // Manual measurement of personal sensors
int32_t max_res [nbPhotoSensor] = {2062273-206227, 5554006-555400, 784809-78480, 4755895-475589, 1939035-193903, 289546-28954}; // Manual measurement of personal sensors // less 10 %, there are more résidual light in the measurement working (city context) than the box calibration
uint32_t time_sec_sum;
bool winter = true, timestamping = true, photo_sensor = true, temp_sensor = true, awake = true;
static byte state = true;