1- # ' Estimate bird flux
1+ # ' Estimate BirdFlow Migration Traffic Rate (BMTR)
22# '
3- # ' `calc_flux ()` estimates the proportion of the species that passes near
3+ # ' `calc_bmtr ()` estimates the proportion of the species that passes near
44# ' a set of points during each transition in a BirdFlow model.
55# '
66# ' @section Units:
1818# '
1919# ' @section Limitations:
2020# '
21- # ' `calc_flux ()` makes the incorrect simplifying assumption
21+ # ' `calc_bmtr ()` makes the incorrect simplifying assumption
2222# ' that birds follow the shortest (great circle) path
2323# ' between the center of the the source and destination raster cells. Caution
2424# ' should be used when interpreting the results especially around
2525# ' major geographic features such as coasts, large lakes, mountain ranges, and
2626# ' ecological system boundaries that might result in non-linear migration paths.
2727# '
28- # ' `calc_flux ()` assumes that a line passes by a point if any part of the line
28+ # ' `calc_bmtr ()` assumes that a line passes by a point if any part of the line
2929# ' is within the radius of the point. This assumption breaks down if the
3030# ' radius is much larger than the movement lengths as points that are ahead of
3131# ' the line may still be within a radius of the line. In the extreme a large
3434# ' the default points and radius as the points ahead of the line will never be
3535# ' within the radius.
3636# '
37- # ' The default points for `calc_flux ()` are aligned with the cell centers as
37+ # ' The default points for `calc_bmtr ()` are aligned with the cell centers as
3838# ' are the movement lines. This alignment means that a very small radius will
39- # ' result in an overestimate of flux . The default value of half the cell size
39+ # ' result in an overestimate of bmtr . The default value of half the cell size
4040# ' is sufficient for this not to be a problem, as we are capturing and
4141# ' standardizing the units based on the entire cell area that that point
4242# ' represents.
5656# ' or an even number. This is a placeholder, currently only `1` is supported.
5757# ' @param format The format to return the results in one of:
5858# ' \describe{
59- # ' \item{`"points"`}{Returns a list with `flux ` a matrix or array of
60- # ' flux values, and `points` a data frame of either the input `points` or the
59+ # ' \item{`"points"`}{Returns a list with `bmtr ` a matrix or array of
60+ # ' bmtr values, and `points` a data frame of either the input `points` or the
6161# ' default cell center derived points.}
6262# ' \item{`"dataframe"`}{Returns a "long" data frame with columns:
6363# ' * `x` and `y` coordinates of the points.
6464# ' * `transition` Transition code.
65- # ' * `flux ` The flux at the point. See "Units" below .
65+ # ' * `bmtr ` The bmtr at the point. See "Units" below .
6666# ' * `date` The date associated with the transition, will be at the midpoint
6767# ' between timesteps.
6868# '
7171# ' transition.}
7272# '}
7373# ' @inheritParams is_between
74- # ' @param weighted If `FALSE` use the original and quicker version of flux
74+ # ' @param weighted If `FALSE` use the original and quicker version of bmtr
7575# ' that sums all the marginal probability for transitions that pass within a
7676# ' fixed distance of the point. If `TRUE` assign a weight to the point and
7777# ' transition combo that then is multiplied by the marginal probability before
8686# '
8787# ' \dontrun{
8888# ' bf <- BirdFlowModels::amewoo
89- # ' flux <- calc_flux (bf)
89+ # ' bmtr <- calc_bmtr (bf)
9090# '
91- # ' plot_flux(flux , bf)
91+ # ' plot_bmtr(bmtr , bf)
9292# '
93- # ' animate_flux(flux , bf)
93+ # ' animate_bmtr(bmtr , bf)
9494# ' }
9595# '
96- calc_flux <- function (bf , points = NULL , radius = NULL , n_directions = 1 ,
96+ calc_bmtr <- function (bf , points = NULL , radius = NULL , n_directions = 1 ,
9797 format = NULL , batch_size = 5e5 , check_radius = TRUE ,
9898 weighted = FALSE ) {
9999
100100
101101 if (! requireNamespace(" SparseArray" , quietly = TRUE )) {
102- stop(" The SparseArray package is required to use calc_flux (). " ,
102+ stop(" The SparseArray package is required to use calc_bmtr (). " ,
103103 " Please install it prior to calling this function." )
104104 }
105105
106106 if (n_directions != 1 )
107- stop(" Only one directional flux is supported at the moment." )
107+ stop(" Only one directional bmtr is supported at the moment." )
108108
109109 if (is.null(format )) {
110110 if (is.null(points )) {
@@ -131,7 +131,7 @@ calc_flux <- function(bf, points = NULL, radius = NULL, n_directions = 1,
131131 points <- result $ points
132132 radius_km <- result $ radius / 1000
133133
134- bf_msg(" Calculating Flux \n " )
134+ bf_msg(" Calculating BMTR \n " )
135135
136136 timesteps <- lookup_timestep_sequence(bf )
137137 transitions <- lookup_transitions(bf )
@@ -174,12 +174,12 @@ calc_flux <- function(bf, points = NULL, radius = NULL, n_directions = 1,
174174 }
175175 }
176176
177- bf_msg(" Formatting flux \n " )
177+ bf_msg(" Formatting BMTR \n " )
178178 # Standardize to P of population to pass through KM of transect in a week
179179 net_movement <- net_movement / (radius_km * 2 )
180180
181181 if (format == " points" ) {
182- return (list (flux = net_movement , point = points ))
182+ return (list (bmtr = net_movement , point = points ))
183183 }
184184
185185 if (format == " spatraster" ) {
@@ -205,7 +205,7 @@ calc_flux <- function(bf, points = NULL, radius = NULL, n_directions = 1,
205205 wide <- cbind(as.data.frame(points )[, c(" x" , " y" )],
206206 net_movement )
207207 long <- tidyr :: pivot_longer(wide , cols = setdiff(names(wide ), c(" x" , " y" )),
208- names_to = " transition" , values_to = " flux " )
208+ names_to = " transition" , values_to = " bmtr " )
209209
210210 long $ date <- as.character(lookup_date(long $ transition , bf ))
211211
@@ -215,3 +215,20 @@ calc_flux <- function(bf, points = NULL, radius = NULL, n_directions = 1,
215215
216216 stop(format , " is not a recoginized format." ) # shouldn't ever get here
217217}
218+
219+
220+
221+
222+ # ' Calculate Bird Flow Migration Traffic Rate
223+ # '
224+ # ' DEPRECATED FUNCTION. Please use [calc_bmtr()] instead.
225+ # ' @inheritDotParams calc_bmtr
226+ # '
227+ # ' @inherit calc_bmtr return
228+ # ' @export
229+ calc_flux <- function (... ){
230+ warning(" calc_flux() is deprecated. " ,
231+ " Please use calc_bmtr() instead." )
232+ calc_bmtr(... )
233+
234+ }
0 commit comments