averageSPalongSeason: Compute a seasonal timeseries of an average snowprofile

Description Usage Arguments Value Note Author(s) References See Also Examples

View source: R/averageSPalongSeason.R

Description

This routine computes the seasonal timeseries of the average snow profile for a given region/set of profiles. The total snow height of the seasonal average profile closely follows the median snow height represented by the group of profiles each day. Also the new snow amounts represent the median new snow amounts within the group (i.e., PP and DF grains). The routine maintains temporal consistency by using the previous day average profile as initial condition to derive the next day's. This creates the need for re-scaling the layer thicknesses each day to account for snow settlement and melting. Two different re-scaling approaches have been implemented, which both aim to re-scale the old snow part of the column (i.e., the snow which was on the ground already at the previous day). See parameter description for more details. Also note, that the routine can be started at any day of the season by providing an average profile from the previous day. The routine modifies several parameters, which are passed on to dtwSP. These parameters differ from the defaults specified in dtwSP, which are held very generic, whereas the application in this function is much more specific to certain requirements and algorithm behavior. For more details, refer to the reference paper.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
averageSPalongSeason(
  SPx,
  sm = summary(SPx),
  AvgDayBefore = NULL,
  DateEnd = max(sm$date),
  keep.profiles = TRUE,
  progressbar = require("progress", quietly = TRUE, character.only = TRUE),
  dailyRescaling = c("settleTopOldSnow", "settleEntireOldSnow")[1],
  proportionPWL = 0.3,
  breakAtSim = 0.9,
  breakAfter = 2,
  verbose = FALSE,
  resamplingRate = 0.5,
  top.down = FALSE,
  checkGlobalAlignment = FALSE,
  prefLayerWeights = NA,
  dims = c("gtype", "hardness", "ddate"),
  weights = c(0.375, 0.125, 0.5),
  ...
)

Arguments

SPx

a snowprofileSet that contains all profiles from the region to be averaged at all days of the season for which you want to compute the average profile. Identically to dbaSP, weak layers need to be labeled prior to this function call, see dbaSP and sarp.snowprofile::labelPWL. Note that only daily sampling is allowed at this point (i.e., one profile per grid point per day).

sm

a summary of SPx containing meta-data

AvgDayBefore

an average snowprofile from the previous day. This is only necessary if you want to resume the computation mid season.

DateEnd

an end date character string ("YYYY-MM-DD") if you only want to compute the timeseries up to a certain point in time. Defaults to the future-most date contained in the meta-data object sm.

keep.profiles

Do you want to keep the (resampled) individual snow profiles from SPx in your return object? Note that this must be TRUE if you plan to backtrackLayers to derive any kind of summary statistics for the averaged layers. See Notes below, and examples of how to conveniently backtrackLayers.

progressbar

display a progress bar during computation?

dailyRescaling

choose between two settlement rescaling approaches. settleEntireOldSnow re-scales the entire old snow column so that the average snow height represents the median snow height from the profile set. settleTopOldSnow (the default) re-scales the upper part of the old snow column to achieve the same goal. While the former mostly leads to buried layers being settled to too deep snow depths, the default approach aims to leave those buried layers unchanged, which are located at depths that represent the median depths of their aligned layers.

proportionPWL

decimal number that specifies the proportion required to average an ensemble of grain types as weak layer type. A value of 0.3, for example, means that layers will get averaged to a PWL type if 30% of the layers are of PWL type. Meaningful range is between [0.1, 0.5]. Values larger than 0.5 get set to 0.5.

breakAtSim

stop iterations when simSP between the last average profiles is beyond that value. Can range between [0, 1]. Default values differ between dbaSP and averageSP.

breakAfter

integer specifying how many values of simSP need to be above breakAtSim to stop iterating. Default values differ between dbaSP and averageSP.

verbose

print similarities between old and new average in between iterations?

resamplingRate

Resampling rate for a regular depth grid among the profiles

top.down

a dtwSP parameter, which needs to be set to FALSE to ensure correct growing of the snowpack during snowfall.

checkGlobalAlignment

a dtwSP parameter, which needs to be set to FALSE analogous to top.down

prefLayerWeights

a dtwSP parameter. Might be best to set this to NA, but can potentially be set to layerWeightingMat(FALSE) in case of averaging a very large geographic region with temporal lags between weather events.

dims

a dtwSP parameter, which is modified to include deposition date alignments per default

weights

a dtwSP parameter that sets the according weights to the dims specified above.

...

any other parameters passed on to dbaSP and then dtwSP.

Value

A list of class avgSP_timeseries containing the fields $avgs with a snowprofileSet of the average profiles at each day. If keep.profiles == TRUE a field $sets with the according profiles informing the average profile at each day (which can be used to backtrackLayers to compute summary statistics of the averaged layers). And two fields $call and $meta. The latter contains several useful meta-information such as ...$date, ...$hs, ...$hs_median, ...$thicknessPPDF_median, or ...$rmse, which gauges the representativity of the average profile (the closer to 0, the better; the closer to 1, the worse).

Note

Author(s)

fherla

References

Herla, F., Haegeli, P., and Mair, P.: Brief communication: A numerical tool for averaging large data sets of snow stratigraphy profiles useful for avalanche forecasting, The Cryosphere Discuss., https://doi.org/10.5194/tc-2022-29, in review, 2022.

See Also

dbaSP, averageSP, sarp.snowprofile::labelPWL

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
run_the_examples <- FALSE  # exclude long-running examples
if (run_the_examples) {

## compute average seasonal profile for an entire season
## takes about 60 mins for a region of hundred profiles and max 150 cm snow depth
avgGNP <- averageSPalongSeason(gnp_dataset, keep.profiles = TRUE)
## explore resulting object
names(avgGNP)
plot(avgGNP$avgs)  # timeseries figure
lines(avgGNP$meta$date, avgGNP$meta$hs_median)  # add line representing median snow height
plot(avgGNP$sets$`2018-12-08`, SortMethod = "hs")  # plot individual profiles at a given day

## backtrack individual layers of the average profile...
individualLayers <- backtrackLayers(avgProfile = avgGNP$avgs$`2018-12-08`,
                      profileSet = avgGNP$sets$`2018-12-08`,
                      layer = findPWL(avgGNP$avgs$`2018-12-08`, pwl_gtype = c("SH", "DH"),
                                      pwl_date = "2018-11-23"))
## ... to retrieve summary statistics or distributions, e.g. stability distribution
hist(individualLayers$rta)


}

sarp.snowprofile.alignment documentation built on Feb. 10, 2022, 5:07 p.m.