# Load required library library(lubridate) # Parameters min_temp_K <- 278.15 # Minimum temperature (in K) max_temp_K <- 298.15 # Maximum temperature (in K) period_hours <- 24 # Period of the sine wave (in hours) total_days <- 7 # Total length of the time series (in days) half_hourly_intervals <- total_days * 24 * 2 # Half-hourly intervals in the time series # Generate time values (half-hourly intervals) for 7 days start_time <- as.POSIXct("1995-06-30 00:00:00", format = "%d/%m/%Y %H:%M") time_values <- seq(start_time, by = "30 mins", length.out = half_hourly_intervals) # Generate the corresponding temperature values as a sine wave in Kelvin time_hours <- as.numeric(difftime(time_values, start_time, units = "hours")) temperature_values_K <- ((max_temp_K - min_temp_K) / 2) * sin(time_hours * (2 * pi / period_hours)) + (max_temp_K + min_temp_K) / 2 # Create a data frame with time and temperature in Kelvin temperature_data_K <- data.frame(Time = format(time_values, format = "%d/%m/%Y %H:%M"), Temperature_K = temperature_values_K) # Save the data frame to a CSV file write.csv(temperature_data_K, file = "temperature_data_Kelvin.csv", row.names = FALSE)