Closed mattprill closed 5 months ago
Is anyone able to help me with this please? Thanks for reading.
Hi Matt,
mc_calc_vwc() needs myClim object as a data input (see http://labgis.ibot.cas.cz/myclim/reference/mc_calc_vwc.html), but it seems to me that you are trying to run the function with dataframe as input. Therefore, try to convert your dataframe to myClim object first and then run the function. BTW, I noticed that you have changed the parameter frozen2NA = F, which is something I would not really recommend to do.
Best regards,
martin
Hi Martin, Thank you for your response. I no longer have access to the data loggers or the raw imported files. After looking into mc_read_data(), it seems like I might need access to this. Is there a way to turn my dataframe into something compatible another way? Best, Matt
sure - see mc_read_wide() http://labgis.ibot.cas.cz/myclim/reference/mc_read_wide.html
Hi, this function also seems to require a datetime column whereas I am trying to calculate a VWC with only soil moisture and temperature columns. Is there a way to circumnavigate this?
Hi, you can use similar script:
library(tibble)
library(lubridate)
library(dplyr)
library(myClim)
daggers_cropped <- tribble(
~soil_temp, ~soil_moisture,
13.2500, 1395,
13.2500, 1395,
13.2500, 1399,
13.0000, 1405,
12.9375, 1415,
12.8125, 1426,
)
names(daggers_cropped) <- c("TMS_T1", "TMS_moist")
start <- ymd_h("2024-01-01 0")
daggers_cropped$datetime <- seq(from=start, length.out=nrow(daggers_cropped), by="15 min")
df <- pivot_longer(daggers_cropped, !datetime, names_to="sensor_name", values_to="value")
df$locality_id <- "ABC"
data <- mc_read_long(df)
data <- mc_calc_vwc(data, moist_sensor="TMS_moist", temp_sensor="TMS_T1")
Hi, thank you for this! When I ran it it seemed to work but gave the error:
rror in purrr::map()
:
i In index: 1.
i With name: ABC.
Caused by error in purrr::map()
:
i In index: 1.
Caused by error:
! no slot of name "locality_id" for this object of class "mc_LoggerMetadata"
But it does generate a list. What is the best way to extract the VWCs from this because I cant convert to a dataframe? Thanks again.
The script should work in the latest version of myClim. Make sure you are using version >= 1.1.0.
packageVersion("myClim")
For extract a data.frame you can use the function mc_reshape_wide .
Thank you very much for your help, it worked perfectly.
Thanks again, Matt
Hi there! I'm having an issue with a myClim function
I'm using a dataframe with raw soil moisture recordings and raw temperature recordings to try and convert my soil moisture data to VWC.
head(daggers_cropped) soil_temp soil_moisture 1 13.2500 1395 2 13.2500 1395 3 13.2500 1399 4 13.0000 1405 5 12.9375 1415 6 12.8125 1426
This is my code: mc_calc_vwc( daggers_cropped, moist_sensor = soil_moisture, temp_sensor = soil_temp, output_sensor = "VWC_moisture", soiltype = "universal", localities = NULL, frozen2NA = F, ref_t = 24, acor_t = 1.91132689118083, wcor_t = 0.64108)
And this is my error message: Error in .common_is_agg_format(data) : trying to get slot "format_type" from an object of a basic class ("NULL") with no slots