Filter a time series of vertical profiles ('vpts') by a start and end time, for night or day time, or extract profile nearest to provided timestamp. Use argument night = TRUE to select only time stamps between sunset and sunrise, or night = FALSE to select daytime (sunrise to sunset). Selection for night and day uses check_night().

filter_vpts(x, min, max, nearest, night, elev = -0.268, offset = 0)

Arguments

x

A vpts object.

min

POSIXct date or character. Minimum datetime to be included.

max

POSIXct date or character. Datetime up to this maximum included.

nearest

POSIXct date or character. If specified, min and max are ignored and the profile (vp) nearest to the specified datetime is returned that matches the day/night selection criteria.

night

When TRUE selects only nighttime profiles, when FALSE selects only daytime profiles, as classified by check_night().

elev

Numeric (vector). Sun elevation in degrees defining nighttime. May also be a numeric vector of length two, with first element giving sunset elevation, and second element sunrise elevation.

offset

Numeric (vector). Time duration in seconds by which to shift the start and end of nighttime. May also be a numeric vector of length two, with first element added to moment of sunset and second element added to moment of sunrise. See check_night() for details.

Value

A vpts object, or a vp object when nearest is specified.

Details

Returns profiles for which min <= timestamp profile < max. Selection for night and day occurs by check_night.

Examples

# Select profiles later than 02 Sep 2016

# Select the profile nearest to 2016-09-01 03:00 UTC
filter_vpts(example_vpts, nearest = "2016-09-01 03:00")
#>                Vertical profile (class vp)
#> 
#>        radar:  KBGM 
#>       source:  
#> nominal time:  2016-09-01 03:02:00 
#> generated by:   

# Select profiles between than 01:00 and 03:00 UTC on 02 Sep 2016
filter_vpts(example_vpts, min = "2016-09-02 01:00", max = "2016-09-02 03:00")
#>                    Irregular time series of vertical profiles (class vpts)
#> 
#>            radar:  KBGM 
#>       # profiles:  13 
#> time range (UTC):  2016-09-02 01:04:00 - 2016-09-02 02:59:00 
#>    time step (s):  min: 540     max:  600 

# Select daytime profiles (i.e. profiles between sunrise and sunset)
filter_vpts(example_vpts, night = FALSE)
#>                    Irregular time series of vertical profiles (class vpts)
#> 
#>            radar:  KBGM 
#>       # profiles:  910 
#> time range (UTC):  2016-09-01 10:35:00 - 2016-09-10 11:56:00 
#>    time step (s):  min: 180     max:  41460 

# Select nighttime profiles, with nights starting and ending at
# civil twilight (when the sun is 6 degrees below the horizon)
filter_vpts(example_vpts, night = TRUE, elev = -6)
#>                    Irregular time series of vertical profiles (class vpts)
#> 
#>            radar:  KBGM 
#>       # profiles:  938 
#> time range (UTC):  2016-09-01 00:10:00 - 2016-09-10 10:10:00 
#>    time step (s):  min: 180     max:  55200 

# Select nighttime profiles from 3h after sunset to 2h before sunrise
filter_vpts(example_vpts, night = TRUE, offset = c(3, -2)*3600)
#>                    Irregular time series of vertical profiles (class vpts)
#> 
#>            radar:  KBGM 
#>       # profiles:  578 
#> time range (UTC):  2016-09-01 02:39:00 - 2016-09-10 08:41:00 
#>    time step (s):  min: 180     max:  65460