GetWeightedMeans

This application will find the weighted mean coordinates of all patches with abundance greater than zero, for each time step of the simulation, and calculates the change in position of the mean from the previous time step. That is, the application tracks the movement of the weighted centroid of the metapopulation.

Arguments

There are four mandatory arguments and four optional arguments to this application. Optional arguments are listed between brackets below:

MPFile Start_Year X | Y Delimiter [burn-in patch_abundance_threshold smoothing_method (sma | exp) window_size]

MPFile is the metapop file to process
Start_Year is the first year of the simulation. Each subsequent time-step is assumed to be one year after this
X | Y if X then the metapopulation movement will be tracked along the East-West axis, if Y the movement will  be tracked along the North-South axis
Delimiter is the character used to delimit the fields in the outputs
burn-in is the number of years to ignore at the start of the simulation, if a "burn-in" period is being used
patch_abundance_threshold is the minimum abundance threshold, any patch with an abundance less than this will not be included in the calculations
smoothing_method is the method to use to smooth the time-series output by the application. Options are sma for simple moving average and exp for exponential smoothing
window_size is the number of years to include in the smoothing method. Although exponential smoothing doesn't strictly use a smoothing window, the application does use the window size to calculate the weighting factor

Outputs

The outputs of the application are the number of patches loaded, the number of years the simulation was run for, the initial coordinates of the centroid, and a time-series of the movements of the centroid per year of the simulation.

Examples

The following command:

getweightedmeans example.mp 2000 Y ,

Yields this output:

Num patches loaded,358
Resolution(km),1
Total years,20
Initial Coords,10.6767,19.8521,
Year,X,Y
2000,0,0
2001,0.0134572,0.0603431
2002,-0.0560208,0.33439
2003,-0.123066,0.615723
2004,0.061508,1.08798
2005,0.204739,1.70441
2006,0.0794108,2.65377
2007,0.0131057,3.32111
2008,0.0509039,3.83135
2009,0.039517,4.32882
2010,0.0225946,4.87822
2011,0.0120997,5.38816
2012,-0.0037582,6.02571
2013,0.0386129,6.5573
2014,0.0254308,7.03798
2015,0.0536344,7.74734
2016,0.0822584,8.27443
2017,0.120087,8.66858
2018,0.177045,9.02342
2019,0.202829,9.06149


Applying a three-year burn-in period with the following command:

getweightedmeans example.mp 2000 Y , 3

outputs:

Num patches loaded,358
Resolution(km),1
Total years,20
Burn-in years,3
Initial Coords,10.7997,19.2363,
Year,X,Y
2003,0,0
2004,0.184574,0.472252
2005,0.327804,1.08868
2006,0.202477,2.03804
2007,0.136172,2.70538
2008,0.17397,3.21563
2009,0.162583,3.71309
2010,0.14566,4.26249
2011,0.135166,4.77244
2012,0.119308,5.40999
2013,0.161679,5.94157
2014,0.148497,6.42225
2015,0.1767,7.13162
2016,0.205324,7.65871
2017,0.243152,8.05286
2018,0.300111,8.40769
2019,0.325895,8.44576


Patches with abundance less than five are filtered out as follows:

getweightedmeans example.mp 2000 Y , 3 5

Which gives the following output:

Num patches loaded,358
Patch size threshold,5
Num patches after cleaning,203
Resolution(km),1
Total years,20
Burn-in years,3
Initial Coords,10.7627,19.1272,
Year,X,Y
2003,0,0
2004,0.167418,0.444759
2005,0.29462,1.06314
2006,0.140464,2.06953
2007,0.0840521,2.68106
2008,0.127238,3.15402
2009,0.121315,3.60845
2010,0.10518,4.1618
2011,0.0940567,4.67234
2012,0.0796866,5.32504
2013,0.107215,5.97261
2014,0.0944773,6.44392
2015,0.138482,7.02015
2016,0.169746,7.56285
2017,0.209391,7.95948
2018,0.266162,8.25057
2019,0.283712,8.29459


Note that the output now includes the patch size threshold, and the number of retained patches.

Finally, the output time-series is smoothed using exponential smoothing, with the following command:

getweightedmeans example.mp 2000 Y , 3  5 exp 3

Which gives the following output:

Num patches loaded,358
Patch size threshold,5
Num patches after cleaning,203
Resolution(km),1
Total years,20
Burn-in years,3
Exponential smoothing window,3
Initial Coords,10.7627,19.1272,
Year,X,Y
2003,0,0
2004,0.083709,0.22238
2005,0.189164,0.642759
2006,0.164814,1.35614
2007,0.124433,2.0186
2008,0.125836,2.58631
2009,0.123575,3.09738
2010,0.114378,3.62959
2011,0.104217,4.15096
2012,0.0919519,4.738
2013,0.0995834,5.3553
2014,0.0970303,5.89961
2015,0.117756,6.45988
2016,0.143751,7.01137
2017,0.176571,7.48542
2018,0.221367,7.868
2019,0.252539,8.08129




Back to RAMAS Metapop Tools main page.


Maintained by Dr Michael J. Watts