This function crops data by datetime

mc_prep_crop(
  data,
  start = NULL,
  end = NULL,
  localities = NULL,
  end_included = TRUE,
  crop_table = NULL
)

Arguments

data

myClim object see myClim-package

start

optional; POSIXct datetime in UTC value; start datetime is included (default NULL)

end

optional; POSIXct datetime in UTC value (default NULL)

localities

vector of locality_ids to be cropped; if NULL then all localities are cropped (default NULL)

end_included

if TRUE then end datetime is included (default TRUE), see details

crop_table

data.frame (table) for advanced cropping; see details

Value

cropped data in the same myClim format as input.

Details

Function is able to crop data from start to end but works also with start only or end only. When only start is provided, then function crops only the beginning of the time-series and vice versa using end.

For advanced cropping per individual locality and logger use crop_table parameter. Crop_table is r data.frame containing columns:

  • locality_id - e.g. Loc_A1

  • logger_name - e.g. TMS_1 see mc_info_logger

  • start - POSIXct datetime in UTC

  • end - POSIXct datetime in UTC

If logger_name is NA, then all loggers at certain locality are cropped. The column logger_name is ignored in agg-format. The start or end can be NA, then the data are not cropped. If the crop_table is provided, then start, end and localities parameters must be NULL.

The end_included parameter is used for specification, whether to return data which contains end time or not. For example when cropping the data to rounded days, typically users use midnight. 2023-06-15 00:00:00 UTC. But midnight is the last date of ending day and the same time first date of the next day. This will create the last day of time-series containing single record (midnight). This can be confusing when user performs aggregation with such data (e.g. daily mean of single record per day, typically NA) so sometimes it is better to use end_included = FALSE excluding end record and crop at 2023-06-14 23:45:00 UTC (15 minutes records).

Examples

cropped_data <- mc_prep_crop(mc_data_example_clean, end=as.POSIXct("2020-02-01", tz="UTC"))