{"id":315036,"name":"stochLAB","description":"A tool to run collision risk models for seabirds on offshore wind farms.","url":"https://github.com/marinescotlandscience/stochlab","last_synced_at":"2026-04-29T00:02:39.583Z","repository":{"id":44533686,"uuid":"386408413","full_name":"MarineScotlandScience/stochLAB","owner":"MarineScotlandScience","description":"The stochastic collision risk model toolbox","archived":false,"fork":false,"pushed_at":"2025-11-28T16:20:07.000Z","size":40509,"stargazers_count":7,"open_issues_count":11,"forks_count":5,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-04-14T17:04:25.796Z","etag":null,"topics":["collision-risk","migratoryspecies","offshore-wind","seabirds"],"latest_commit_sha":null,"homepage":"https://marinescotlandscience.github.io/stochLAB/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarineScotlandScience.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json","zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-07-15T19:55:27.000Z","updated_at":"2025-11-28T16:10:50.000Z","dependencies_parsed_at":"2024-03-17T04:07:16.327Z","dependency_job_id":"14edb8b3-cc1b-4a60-9c4f-148e27b29fe3","html_url":"https://github.com/MarineScotlandScience/stochLAB","commit_stats":{"total_commits":154,"total_committers":4,"mean_commits":38.5,"dds":0.4285714285714286,"last_synced_commit":"8fd8136da5e4e86977c184b9c35bb8587c3a2ae0"},"previous_names":["marinescotlandscience/stochlab","hidef-aerial-surveying/stochlab"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/MarineScotlandScience/stochLAB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarineScotlandScience%2FstochLAB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarineScotlandScience%2FstochLAB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarineScotlandScience%2FstochLAB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarineScotlandScience%2FstochLAB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarineScotlandScience","download_url":"https://codeload.github.com/MarineScotlandScience/stochLAB/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarineScotlandScience%2FstochLAB/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31980783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"owner":{"login":"MarineScotlandScience","name":"Scottish Government Marine Directorate","uuid":"13151918","kind":"organization","description":"Repository for Marine Science and Data Projects","email":null,"website":"http://www.gov.scot/Topics/marine/science","location":"Scotland","twitter":null,"company":null,"icon_url":"https://avatars.githubusercontent.com/u/13151918?v=4","repositories_count":2,"last_synced_at":"2024-03-25T09:58:18.681Z","metadata":{"has_sponsors_listing":false},"html_url":"https://github.com/MarineScotlandScience","funding_links":[],"total_stars":1,"followers":null,"following":null,"created_at":"2024-03-25T09:58:20.057Z","updated_at":"2024-03-25T09:58:20.057Z","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarineScotlandScience","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarineScotlandScience/repositories"},"packages":[],"commits":{"id":9782103,"full_name":"marinescotlandscience/stochlab","default_branch":"main","total_commits":169,"total_committers":4,"total_bot_commits":0,"total_bot_committers":0,"mean_commits":42.25,"dds":0.47928994082840237,"past_year_total_commits":15,"past_year_total_committers":1,"past_year_total_bot_commits":0,"past_year_total_bot_committers":0,"past_year_mean_commits":15.0,"past_year_dds":0.0,"last_synced_at":"2026-04-26T23:01:36.294Z","last_synced_commit":"f16dab5baa2edb6bd06b8359681bdf7e6d3d359d","created_at":"2025-04-25T00:01:35.575Z","updated_at":"2026-04-26T23:01:19.560Z","committers":[{"name":"Grant_Test","email":"grant.humphries@hidefsurveying.co.uk","login":null,"count":88},{"name":"Grant","email":"humphries.grant@gmail.com","login":"grwhumphries","count":65},{"name":"Bruno Caneco","email":"bruno@dmpstats.com","login":"bcaneco","count":12},{"name":"Maëlle Salmon","email":"maelle.salmon@yahoo.se","login":"maelle","count":4}],"past_year_committers":[{"name":"grwhumphries","email":"humphries.grant@gmail.com","login":"grwhumphries","count":15}],"commits_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub/repositories/marinescotlandscience%2Fstochlab/commits","host":{"name":"GitHub","url":"https://github.com","kind":"github","last_synced_at":"2026-04-29T00:00:10.453Z","repositories_count":6221782,"commits_count":900208448,"contributors_count":34899902,"owners_count":1146921,"icon_url":"https://github.com/github.png","host_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub/repositories"}},"issues_stats":{"full_name":"marinescotlandscience/stochlab","html_url":"https://github.com/marinescotlandscience/stochlab","last_synced_at":"2026-01-26T06:21:33.767Z","status":"error","issues_count":19,"pull_requests_count":15,"avg_time_to_close_issue":8324442.666666667,"avg_time_to_close_pull_request":98380.2,"issues_closed_count":6,"pull_requests_closed_count":15,"pull_request_authors_count":3,"issue_authors_count":6,"avg_comments_per_issue":1.7894736842105263,"avg_comments_per_pull_request":0.0,"merged_pull_requests_count":15,"bot_issues_count":3,"bot_pull_requests_count":0,"past_year_issues_count":2,"past_year_pull_requests_count":0,"past_year_avg_time_to_close_issue":null,"past_year_avg_time_to_close_pull_request":null,"past_year_issues_closed_count":0,"past_year_pull_requests_closed_count":0,"past_year_pull_request_authors_count":0,"past_year_issue_authors_count":2,"past_year_avg_comments_per_issue":1.5,"past_year_avg_comments_per_pull_request":null,"past_year_bot_issues_count":1,"past_year_bot_pull_requests_count":0,"past_year_merged_pull_requests_count":0,"created_at":"2025-04-25T00:01:35.742Z","updated_at":"2026-01-26T06:21:33.768Z","repository_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories/marinescotlandscience%2Fstochlab","issues_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories/marinescotlandscience%2Fstochlab/issues","issue_labels_count":{"enhancement":5,"bug":2,"documentation":1},"pull_request_labels_count":{},"issue_author_associations_count":{"NONE":10,"COLLABORATOR":9},"pull_request_author_associations_count":{"COLLABORATOR":12,"CONTRIBUTOR":3},"issue_authors":{"grwhumphries":8,"JannisLi":5,"github-actions[bot]":3,"bcaneco":1,"heikkiluha-cmyk":1,"mmercker":1},"pull_request_authors":{"grwhumphries":11,"maelle":3,"bcaneco":1},"host":{"name":"GitHub","url":"https://github.com","kind":"github","last_synced_at":"2026-04-29T00:00:10.439Z","repositories_count":14440436,"issues_count":34191912,"pull_requests_count":112291426,"authors_count":11248184,"icon_url":"https://github.com/github.png","host_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories","owners_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/owners","authors_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/authors"},"past_year_issue_labels_count":{},"past_year_pull_request_labels_count":{},"past_year_issue_author_associations_count":{"NONE":2},"past_year_pull_request_author_associations_count":{},"past_year_issue_authors":{"github-actions[bot]":1,"heikkiluha-cmyk":1},"past_year_pull_request_authors":{},"maintainers":[{"login":"grwhumphries","count":19,"url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/authors/grwhumphries"},{"login":"bcaneco","count":2,"url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/authors/bcaneco"}],"active_maintainers":[]},"events":{"total":{"IssuesEvent":2,"DeleteEvent":1,"IssueCommentEvent":7,"PushEvent":7,"ForkEvent":1},"last_year":{"IssuesEvent":2,"DeleteEvent":1,"IssueCommentEvent":7,"PushEvent":7,"ForkEvent":1}},"keywords":["collision-risk","migratoryspecies","offshore-wind","seabirds"],"dependencies":[{"ecosystem":"cran","filepath":"DESCRIPTION","sha":null,"kind":"manifest","created_at":"2022-08-03T17:31:16.422Z","updated_at":"2022-08-03T17:31:16.422Z","repository_link":"https://github.com/MarineScotlandScience/stochLAB/blob/main/DESCRIPTION","dependencies":[{"id":569412954,"package_name":"R","ecosystem":"cran","requirements":"\u003e= 4.0","direct":true,"kind":"depends","optional":false},{"id":569412955,"package_name":"cli","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412956,"package_name":"data.table","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412957,"package_name":"dplyr","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412958,"package_name":"foreach","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412959,"package_name":"glue","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412960,"package_name":"logr","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412961,"package_name":"magrittr","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412962,"package_name":"msm","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412963,"package_name":"pracma","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412964,"package_name":"purrr","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412965,"package_name":"rlang","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412966,"package_name":"stats","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412967,"package_name":"tibble","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412968,"package_name":"tidyr","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":569412969,"package_name":"rmarkdown","ecosystem":"cran","requirements":"*","direct":true,"kind":"suggests","optional":false},{"id":569412970,"package_name":"knitr","ecosystem":"cran","requirements":"*","direct":true,"kind":"suggests","optional":false},{"id":569412971,"package_name":"spelling","ecosystem":"cran","requirements":"*","direct":true,"kind":"suggests","optional":false},{"id":569412972,"package_name":"testthat","ecosystem":"cran","requirements":"\u003e= 3.0.0","direct":true,"kind":"suggests","optional":false},{"id":569412973,"package_name":"covr","ecosystem":"cran","requirements":"*","direct":true,"kind":"suggests","optional":false}]},{"ecosystem":"actions","filepath":".github/workflows/R-CMD-check.yaml","sha":null,"kind":"manifest","created_at":"2023-01-30T04:31:01.607Z","updated_at":"2023-01-30T04:31:01.607Z","repository_link":"https://github.com/MarineScotlandScience/stochLAB/blob/main/.github/workflows/R-CMD-check.yaml","dependencies":[{"id":7240441755,"package_name":"actions/checkout","ecosystem":"actions","requirements":"v2","direct":true,"kind":"composite","optional":false},{"id":7240441756,"package_name":"r-lib/actions/setup-r","ecosystem":"actions","requirements":"v2","direct":true,"kind":"composite","optional":false},{"id":7240441757,"package_name":"r-lib/actions/setup-r-dependencies","ecosystem":"actions","requirements":"v2","direct":true,"kind":"composite","optional":false},{"id":7240441758,"package_name":"r-lib/actions/check-r-package","ecosystem":"actions","requirements":"v1","direct":true,"kind":"composite","optional":false}]},{"ecosystem":"actions","filepath":".github/workflows/pkgcheck.yaml","sha":null,"kind":"manifest","created_at":"2023-01-30T04:31:01.622Z","updated_at":"2023-01-30T04:31:01.622Z","repository_link":"https://github.com/MarineScotlandScience/stochLAB/blob/main/.github/workflows/pkgcheck.yaml","dependencies":[{"id":7240441871,"package_name":"ropensci-review-tools/pkgcheck-action","ecosystem":"actions","requirements":"main","direct":true,"kind":"composite","optional":false}]},{"ecosystem":"actions","filepath":".github/workflows/pkgdown.yaml","sha":null,"kind":"manifest","created_at":"2023-01-30T04:31:01.655Z","updated_at":"2023-01-30T04:31:01.655Z","repository_link":"https://github.com/MarineScotlandScience/stochLAB/blob/main/.github/workflows/pkgdown.yaml","dependencies":[{"id":7240443437,"package_name":"actions/checkout","ecosystem":"actions","requirements":"v2","direct":true,"kind":"composite","optional":false},{"id":7240443438,"package_name":"r-lib/actions/setup-pandoc","ecosystem":"actions","requirements":"v2","direct":true,"kind":"composite","optional":false},{"id":7240443439,"package_name":"r-lib/actions/setup-r","ecosystem":"actions","requirements":"v2","direct":true,"kind":"composite","optional":false},{"id":7240443440,"package_name":"r-lib/actions/setup-r-dependencies","ecosystem":"actions","requirements":"v2","direct":true,"kind":"composite","optional":false}]},{"ecosystem":"actions","filepath":".github/workflows/test-coverage.yaml","sha":null,"kind":"manifest","created_at":"2023-01-30T04:31:01.944Z","updated_at":"2023-01-30T04:31:01.944Z","repository_link":"https://github.com/MarineScotlandScience/stochLAB/blob/main/.github/workflows/test-coverage.yaml","dependencies":[{"id":7240445008,"package_name":"actions/checkout","ecosystem":"actions","requirements":"v2","direct":true,"kind":"composite","optional":false},{"id":7240445011,"package_name":"r-lib/actions/setup-r","ecosystem":"actions","requirements":"v2","direct":true,"kind":"composite","optional":false},{"id":7240445013,"package_name":"r-lib/actions/setup-r-dependencies","ecosystem":"actions","requirements":"v2","direct":true,"kind":"composite","optional":false}]}],"score":4.276666119016055,"created_at":"2025-04-25T00:01:32.808Z","updated_at":"2026-04-29T00:02:39.585Z","avatar_url":"https://github.com/MarineScotlandScience.png","language":"R","category":"Renewable Energy","sub_category":"Wind Energy","monthly_downloads":0,"total_dependent_repos":0,"total_dependent_packages":0,"readme":"---\noutput: github_document\neditor_options: \n  markdown: \n    wrap: 80\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# stochLAB \u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"139\"/\u003e\n\n\u003c!-- badges: start --\u003e\n\n[![test-coverage](https://github.com/MarineScotlandScience/stochLAB/actions/workflows/test-coverage.yaml/badge.svg)](https://github.com/MarineScotlandScience/stochLAB/actions/workflows/test-coverage.yaml)\n[![pkgdown](https://github.com/MarineScotlandScience/stochLAB/actions/workflows/pkgdown.yaml/badge.svg)](https://github.com/MarineScotlandScience/stochLAB/actions/workflows/pkgdown.yaml)\n[![R-CMD-check](https://github.com/MarineScotlandScience/stochLAB/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/MarineScotlandScience/stochLAB/actions/workflows/R-CMD-check.yaml)\n[![pkgcheck](https://github.com/MarineScotlandScience/stochLAB/actions/workflows/pkgcheck.yaml/badge.svg)](https://github.com/MarineScotlandScience/stochLAB/actions/workflows/pkgcheck.yaml)\n[![Status at rOpenSci Software Peer\nReview](https://badges.ropensci.org/551_status.svg)](https://github.com/ropensci/software-review/issues/551)\n\n\u003c!-- badges: end --\u003e\n\n`{stochLAB}` is a tool to run Collision Risk Models (CRMs) for seabirds on\noffshore wind farms.\n\n## Overview\n\nThe `{stochLAB}` package is an adaptation of the [R\ncode](https://data.marine.gov.scot/dataset/developing-avian-collision-risk-model-incorporate-variability-and-uncertainty-r-code-0)\ndeveloped by [Masden\n(2015)](https://data.marine.gov.scot/dataset/developing-avian-collision-risk-model-incorporate-variability-and-uncertainty)\nto incorporate variability and uncertainty in the avian collision risk model\noriginally developed by [Band\n(2012)](https://www.bto.org/sites/default/files/u28/downloads/Projects/Final_Report_SOSS02_Band1ModelGuidance.pdf).\nThe package is for use by individuals modelling collision risk of seabirds at\noffshore wind farms. The primary functions take input information on the\nmorphology, behaviour and densities of seabirds as well data pertaining to the\nproposed wind farm (i.e., turbine dimensions, speed and number).\n\nThese collision risk models are useful for marine ornithologists who are working\nin the offshore wind industry, particularly in UK waters. However, the package\nitself relies on generic biological and windfarm data and can be applied\nanywhere (i.e., in any marine environment) as long as the parameters are\nappropriate for the species and windfarms of interest.\n\nCode developed under `{stochLAB}` substantially re-factored and re-structured\nMasden's (heavily script-based) implementation into a user-friendly,\nstreamlined, well documented and easily distributed tool. Furthermore, the\npackage lays down the code infrastructure for easier incorporation of new\nfunctionality, e.g. extra parameter sampling features, model expansions, etc.\n\nIn addition, previous code underpinning core calculations for the extended model\nhas been replaced by an alternative approach, resulting in significant gains in\ncomputational speed over Masden's code. This optimization is\nparticularly beneficial under a stochastic context, when core calculations are\ncalled repeatedly during simulations.\n\nFor a more detailed overview type `?stochLAB`, once installed!\n\n## Installation\n\nYou can install the released version of stochLAB from\n[CRAN](https://CRAN.R-project.org) with:\n\n``` r\ninstall.packages(\"stochLAB\")\n```\n\nYou can install the development version with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"MarineScotlandScience/stochLAB\")\n```\n\nThis package depends on the following packages, which should be installed\nautomatically:\n\n`cli dplyr glue logr magrittr msm pracma purrr rlang stats tibble tidyr`\n\n## Bug reports\n\nTo report any bugs, please log an\n[ISSUE](https://github.com/MarineScotlandScience/stochLAB/issues)\n\n## Input parameters\n\nMany of the input parameters for the `stoch_crm()` function need to be obtained\nfrom developers (e.g., blade pitch, rotor radius, wind speed, etc...). However,\nthere are many parameters around the morphology and biology of birds that are\nbuilt into the `sCRM` package for UK seabirds, which can be found\n[HERE](https://github.com/dmpstats/sCRM). `sCRM` is an R Shiny application that\nwraps up the `stoch_crm()` and `band_crm()` functions. These biological\nparameters can be accessed by installing the `sCRM` package and running\n`sCRM::spp_dflts`, which will bring up a tibble object with all the relevant\ninformation.\n\nIf performing a collision risk assessment in UK waters, default biological data\nfor the following parameters can be obtained from the `sCRM` package:\n\n`flt_speed_pars, body_lt_pars, wing_span_pars, avoid_bsc_pars, avoid_ext_pars, noct_act_pars, flight_type, gen_fhd_boots`\n\nOther parameters around the species of interest need to be derived from\nsite-based surveys:\n\n`prop_crh_pars, bird_dens_dt,` and `site_fhd_boots`\n\nAll wind farm parameters need to be obtained by the wind farm developers:\n\n`n_blades, air_gap_pars, rtr_radius_pars, bld_width_pars, bld_pitch_pars, rtn_speed_pars, windspd_pars, trb_wind_avbl, trb_downtime_pars, wf_n_trbs, wf_width, wf_latitude, tidal_offset, season_specs, bld_chord_prf, lrg_arr_corr`\n\nThe following parameters refer to the outputs:\n\n`out_format, out_sampled_pars, out_period, verbose, log_file`\n\nMore information on input parameter specifics can be found in the vignettes for\n`stoch_crm` and `band_crm`.\n\n## Outputs\n\nOnce the collision risk model is run, the key outputs are presented as a table\nwhich contains the mean, standard deviation and median number of collisions\nsummarised by month, season, or year. Quantiles of the bootstrapped collisions\nare also presented in the tables. These tables are accessed through calling from\nthe model object. Run the [Examples] to view exemplar outputs.\n\n``` r\nstochOUT \u003c- stochLAB::stoch_crm(...)\n\nstochOUT$collisions$opt1 #For outputs from option 1 of the stochastic collision risk model \nstochOUT$collisions$opt2 #For outputs from option 2 of the stochastic collision risk model \nstochOUT$collisions$opt3 #For outputs from option 3 of the stochastic collision risk model \n```\n\n## Examples\n\n### Simple example\n\nThis is a basic example of running the stochastic collision model for one\nseabird species and one turbine/wind-farm scenario, with fictional input\nparameter data.\n\n``` {r}\nlibrary(stochLAB)\n\n# ------------------------------------------------------\n# Setting some of the required inputs upfront\n\nb_dens \u003c- data.frame(\n  month = month.abb,\n  mean = runif(12, 0.8, 1.5),\n  sd = runif(12, 0.2, 0.3))\n\n# Generic FHD bootstraps for one species, from Johnson et al (2014)\nfhd_boots \u003c- generic_fhd_bootstraps[[1]]\n\n# wind speed vs rotation speed vs pitch\nwind_rtn_ptch \u003c- data.frame(\n  wind_speed = seq_len(30),\n  rtn_speed = 10/(30:1),\n  bld_pitch = c(rep(90, 4), rep(0, 8), 5:22))\n\n# wind availability\nwindavb \u003c- data.frame(\n  month = month.abb,\n  pctg = runif(12, 85, 98))\n\n# maintenance downtime\ndwntm \u003c- data.frame(\n  month = month.abb,\n  mean = runif(12, 6, 10),\n  sd = rep(2, 12))\n\n# seasons specification\nseas_dt \u003c- data.frame(\n  season_id = c(\"a\", \"b\", \"c\"),\n  start_month = c(\"Jan\", \"May\", \"Oct\"), end_month = c(\"Apr\", \"Sep\", \"Dec\"))\n\n# ----------------------------------------------------------\n# Run stochastic CRM, treating rotor radius, air gap and\n# blade width as fixed parameters (i.e. not stochastic)\n\nstoch_crm(\n  model_options = c(1, 2, 3),\n  n_iter = 1000,\n  flt_speed_pars = data.frame(mean = 7.26, sd = 1.5),\n  body_lt_pars = data.frame(mean = 0.39, sd = 0.005),\n  wing_span_pars = data.frame(mean = 1.08, sd = 0.04),\n  avoid_bsc_pars = data.frame(mean = 0.99, sd = 0.001),\n  avoid_ext_pars = data.frame(mean = 0.96, sd = 0.002),\n  noct_act_pars = data.frame(mean = 0.033, sd = 0.005),\n  prop_crh_pars = data.frame(mean = 0.06, sd = 0.009),\n  bird_dens_opt = \"tnorm\",\n  bird_dens_dt = b_dens,\n  flight_type = \"flapping\",\n  prop_upwind = 0.5,\n  gen_fhd_boots = fhd_boots,\n  n_blades = 3,\n  rtr_radius_pars = data.frame(mean = 80, sd = 0), # sd = 0, rotor radius is fixed\n  air_gap_pars = data.frame(mean = 36, sd = 0),    # sd = 0, air gap is fixed\n  bld_width_pars = data.frame(mean = 8, sd = 0),   # sd = 0, blade width is fixed\n  rtn_pitch_opt = \"windSpeedReltn\",\n  windspd_pars = data.frame(mean = 7.74, sd = 3),\n  rtn_pitch_windspd_dt = wind_rtn_ptch,\n  trb_wind_avbl = windavb,\n  trb_downtime_pars = dwntm,\n  wf_n_trbs = 200,\n  wf_width = 15,\n  wf_latitude = 56.9,\n  tidal_offset = 2.5,\n  lrg_arr_corr = TRUE,\n  verbose = TRUE,\n  seed = 1234,\n  out_format = \"summaries\",\n  out_sampled_pars = TRUE,\n  out_period = \"seasons\",\n  season_specs = seas_dt,\n  log_file = paste0(getwd(), \"scrm_example.log\")\n)\n```\n\n### Multiscenario example\n\nThis is an example usage of `stoch_crm()` for multiple scenarios. The aim is\ntwo-fold:\n\n1.  Suggest how input parameter datasets used in the previous implementation can\n    be reshaped to fit `stoch_crm()`'s interface. Suggested code is also\n    relevant in the context of multiple scenarios applications, since the wide\n    tabular structure of these datasets is likely the favoured format for users\n    to compile input parameters under different scenarios.\n\n2.  Propose a functional programming framework to run `stoch_crm()` for multiple\n    species and wind-farm/turbines features.\n\nPlease note the example runs on fictional data.\n\n``` {r}\nlibrary(stochLAB)\n\n# --------------------------------------------------------- #\n# ----      Reshaping into list-column data frames       ----\n# --------------------------------------------------------- #\n#\n# --- bird features\nbird_pars \u003c- bird_pars_wide_example %\u003e%\n  dplyr::relocate(Flight, .after = dplyr::last_col()) %\u003e%\n  tidyr::pivot_longer(AvoidanceBasic:Prop_CRH_ObsSD) %\u003e%\n  dplyr::mutate(\n    par = dplyr::if_else(grepl(\"SD|sd|Sd\", name), \"sd\", \"mean\"),\n    feature = gsub(\"SD|sd|Sd\",\"\", name)) %\u003e%\n  dplyr::select(-name) %\u003e%\n  tidyr::pivot_wider(names_from = par, values_from = value) %\u003e%\n  tidyr::nest(pars = c(mean, sd)) %\u003e%\n  tidyr::pivot_wider(names_from = feature, values_from = pars) %\u003e%\n  tibble::add_column(prop_upwind = 0.5)\n\n# --- bird densities: provided as mean and sd Parameters for Truncated Normal lower\n# bounded at 0\ndens_pars \u003c- dens_tnorm_wide_example %\u003e%\n  tibble::add_column(\n    dens_opt = rep(\"tnorm\", nrow(.)),\n    .after = 1) %\u003e%\n  tidyr::pivot_longer(Jan:DecSD) %\u003e%\n  dplyr::mutate(\n    par = dplyr::if_else(grepl(\"SD|sd|Sd\", name), \"sd\", \"mean\"),\n    month = gsub(\"SD|sd|Sd\",\"\", name)) %\u003e%\n  dplyr::select(-name) %\u003e%\n  tidyr::pivot_wider(names_from = par, values_from = value) %\u003e%\n  tidyr::nest(mth_dens = c(month, mean, sd))\n\n# --- FHD data from Johnson et al (2014) for the species under analysis\ngen_fhd_boots \u003c- generic_fhd_bootstraps[bird_pars$Species]\n\n# --- seasons definitions (made up)\nseason_dt \u003c- list(\n  Arctic_Tern = data.frame(\n    season_id = c(\"breeding\", \"feeding\", \"migrating\"),\n    start_month = c(\"May\", \"Sep\", \"Jan\"),\n    end_month = c(\"Aug\", \"Dec\", \"Apr\")),\n  Black_headed_Gull = data.frame(\n    season_id = c(\"breeding\", \"feeding\", \"migrating\"),\n    start_month = c(\"Jan\", \"May\", \"Oct\"),\n    end_month = c(\"Apr\", \"Sep\", \"Dec\")),\n  Black_legged_Kittiwake = data.frame(\n    season_id = c(\"breeding\", \"feeding\", \"migrating\"),\n    start_month = c(\"Dec\", \"Mar\", \"Sep\"),\n    end_month = c(\"Feb\", \"Aug\", \"Nov\")))\n\n# --- turbine parameters\n## address operation parameters first\ntrb_opr_pars \u003c- turb_pars_wide_example %\u003e%\n  dplyr::select(TurbineModel, JanOp:DecOpSD) %\u003e%\n  tidyr::pivot_longer(JanOp:DecOpSD) %\u003e%\n  dplyr::mutate(\n    month = substr(name, 1, 3),\n    par = dplyr::case_when(\n      grepl(\"SD|sd|Sd\", name) ~ \"sd\",\n      grepl(\"Mean|MEAN|mean\", name) ~ \"mean\",\n      TRUE ~ \"pctg\"\n    )) %\u003e%\n  dplyr::select(-name) %\u003e%\n  tidyr::pivot_wider(names_from = par, values_from = value) %\u003e%\n  tidyr::nest(\n    wind_avbl = c(month, pctg),\n    trb_dwntm = c(month, mean, sd))\n\n## address turbine features and subsequently merge operation parameters\ntrb_pars \u003c- turb_pars_wide_example %\u003e%\n  dplyr::select(TurbineModel:windSpeedSD ) %\u003e%\n  dplyr::relocate(RotorSpeedAndPitch_SimOption, .after = 1) %\u003e%\n  tidyr::pivot_longer(RotorRadius:windSpeedSD) %\u003e%\n  dplyr::mutate(\n    par = dplyr::if_else(grepl(\"SD|sd|Sd\", name), \"sd\", \"mean\"),\n    feature = gsub(\"(SD|sd|Sd)|(Mean|MEAN|mean)\",\"\", name)\n  ) %\u003e%\n  dplyr::select(-name) %\u003e%\n  tidyr::pivot_wider(names_from = par, values_from = value) %\u003e%\n  tidyr::nest(pars = c(mean, sd)) %\u003e%\n  tidyr::pivot_wider(names_from = feature, values_from = pars) %\u003e%\n  dplyr::left_join(., trb_opr_pars)\n\n# --- windspeed, rotation speed and blade pitch relationship\nwndspd_rtn_ptch_example\n\n# --- windfarm parameters\nwf_pars \u003c- data.frame(\n  wf_id = c(\"wf_1\", \"wf_2\"),\n  n_turbs = c(200, 400),\n  wf_width = c(4, 10),\n  wf_lat = c(55.8, 55.0),\n  td_off = c(2.5, 2),\n  large_array_corr = c(FALSE, TRUE)\n)\n\n\n# -------------------------------------------------------------- #\n# ----      Run stoch_crm() for multiple scenarios           ----\n# -------------------------------------------------------------- #\n\n# --- Set up scenario combinations\nscenarios_specs \u003c- tidyr::expand_grid(\n  spp = bird_pars$Species,\n  turb_id = trb_pars$TurbineModel,\n  wf_id = wf_pars$wf_id) %\u003e%\n  tibble::add_column(\n    scenario_id = paste0(\"scenario_\", 1:nrow(.)),\n    .before = 1)\n\n# --- Set up progress bar for the upcoming iterative mapping step\npb \u003c- progress::progress_bar$new(\n  format = \"Running Scenario: :what [:bar] :percent eta: :eta\",\n  width = 100,\n  total = nrow(scenarios_specs))\n\n# --- Map stoch_crm() to each scenario specification via purrr::pmap\noutputs \u003c- scenarios_specs %\u003e%\n  purrr::pmap(function(scenario_id, spp, turb_id, wf_id, ...){\n\n    pb$tick(tokens = list(what = scenario_id))\n\n    # params for current species\n    c_spec \u003c- bird_pars %\u003e%\n      dplyr::filter(Species == {{spp}}) \n\n    # density for current species\n    c_dens \u003c- dens_pars %\u003e%\n      dplyr::filter(Species == {{spp}})\n\n    # params for current turbine scenario\n    c_turb \u003c- trb_pars %\u003e%\n      dplyr::filter(TurbineModel == {{turb_id}})\n\n    # params for current windfarm scenario\n    c_wf \u003c- wf_pars %\u003e%\n      dplyr::filter(wf_id == {{wf_id}})\n\n    # inputs in list-columns need to be unlisted, either via `unlist()` or\n    # indexing `[[1]]`\n    # switching off `verbose`, otherwise console will be \n    # cramped with log messages\n    \n    stoch_crm(\n      model_options = c(1, 2, 3),\n      n_iter = 1000,\n      flt_speed_pars = c_spec$Flight_Speed[[1]],\n      body_lt_pars = c_spec$Body_Length[[1]],\n      wing_span_pars = c_spec$Wingspan[[1]],\n      avoid_bsc_pars = c_spec$AvoidanceBasic[[1]],\n      avoid_ext_pars = c_spec$AvoidanceExtended[[1]],\n      noct_act_pars = c_spec$Nocturnal_Activity[[1]],\n      prop_crh_pars = c_spec$Prop_CRH_Obs[[1]],\n      bird_dens_opt = c_dens$dens_opt,\n      bird_dens_dt = c_dens$mth_dens[[1]],\n      flight_type = c_spec$Flight,\n      prop_upwind = c_spec$prop_upwind,\n      gen_fhd_boots = gen_fhd_boots[[spp]],\n      n_blades = c_turb$Blades,\n      rtr_radius_pars = c_turb$RotorRadius[[1]],\n      air_gap_pars = c_turb$HubHeightAdd[[1]],\n      bld_width_pars = c_turb$BladeWidth[[1]],\n      rtn_pitch_opt = c_turb$RotorSpeedAndPitch_SimOption,\n      bld_pitch_pars = c_turb$Pitch[[1]],\n      rtn_speed_pars = c_turb$RotationSpeed[[1]],\n      windspd_pars = c_turb$windSpeed[[1]],\n      rtn_pitch_windspd_dt = wndspd_rtn_ptch_example,\n      trb_wind_avbl = c_turb$wind_avbl[[1]],\n      trb_downtime_pars = c_turb$trb_dwntm[[1]],\n      wf_n_trbs = c_wf$n_turbs,\n      wf_width = c_wf$wf_width,\n      wf_latitude = c_wf$wf_lat,\n      tidal_offset = c_wf$td_off,\n      lrg_arr_corr = c_wf$large_array_corr,\n      verbose = FALSE,\n      seed = 1234,\n      out_format = \"summaries\",\n      out_sampled_pars = FALSE,\n      out_period = \"seasons\",\n      season_specs = season_dt[[spp]],\n      log_file = NULL\n    )\n  })\n\n# --- close progress bar\npb$terminate()\n\n# --- identify elements of output list\nnames(outputs) \u003c- scenarios_specs$scenario_id\n\noutputs\n```\n\n### Band model example\n\nThis is an example usage of `band_crm()`. This is for a single species and\nsingle set of turbine parameters. This replicates the Band (2012) worksheet. The\n`stoch_crm()` function wraps around this function, where `band_crm()` acts in\nessence as a single draw of `stoch_crm()`.\n\nPlease note the example runs on fictional data.\n\n``` {r}\nlibrary(stochLAB)\n# ------------------------------------------------------\n# Run with arbitrary parameter values, for illustration\n# ------------------------------------------------------\n\n# Setting a dataframe of parameters to draw from\nparams \u003c- data.frame(\n  flight_speed = 13.1,         # Flight speed in m/s\n  body_lt = 0.85,              # Body length in m\n  wing_span = 1.01,            # Wing span in m\n  flight_type = \"flapping\",    # flapping or gliding flight\n  avoid_rt_basic = 0.989,      # avoidance rate for option 1 and 2\n  avoid_rt_ext = 0.981,        # extended avoidance rate for option 3 and 4\n  noct_activity = 0.5,         # proportion of day birds are inactive\n  prop_crh_surv = 0.13,        # proportion of birds at collision risk height (option 1 only)\n  prop_upwind = 0.5,           # proportion of flights that are upwind\n  rotor_speed = 15,            # rotor speed in revolutions/minute (rpm)\n  rotor_radius = 120,          # radius of turbine in m\n  blade_width = 5,             # width of turbine blades at thickest point in m\n  blade_pitch = 15,            # mean radius pitch in Radians\n  n_blades = 3,                # total number of blades per turbine\n  hub_height = 150,            # height of hub in m above HAT\n  n_turbines = 100,            # number of turbines in the wind farm\n  wf_width = 52,               # width across longest section of wind farm\n  wf_latitude = 56,            # latitude of centroid of wind farm\n  tidal_offset = 2.5,          # mean tidal offset from HAT of the wind farm\n  lrg_arr_corr = TRUE          # apply a large array correction?\n)\n\n# Monthly bird densities\nb_dens \u003c- data.frame(\n  month = month.abb,\n  dens = runif(12, 0.8, 1.5)\n)\n\n# flight height distribution from Johnston et al\ngen_fhd_dat \u003c- Johnston_Flight_heights_SOSS %\u003e%\n  dplyr::filter(variable==\"Gannet.est\") %\u003e%\n  dplyr::select(height,prop)\n\n# monthly operational time of the wind farm\nturb_oper \u003c- data.frame(\n  month = month.abb,\n  prop_oper = runif(12,0.5,0.8)\n)\n\n\nstochLAB::band_crm(\n  model_options = c(1,2,3),\n  flight_speed = params$flight_speed,\n  body_lt = params$body_lt,\n  wing_span = params$wing_span,\n  flight_type = params$flight_type,\n  avoid_rt_basic = params$avoid_rt_basic,\n  avoid_rt_ext = params$avoid_rt_ext,\n  noct_activity = params$noct_activity,\n  prop_crh_surv = params$prop_crh_surv,\n  dens_month = b_dens,\n  prop_upwind = params$prop_upwind,\n  gen_fhd = gen_fhd_dat,\n  site_fhd = NULL,  # Option 4 only\n  rotor_speed = params$rotor_speed,\n  rotor_radius = params$rotor_radius,\n  blade_width = params$blade_width,\n  blade_pitch = params$blade_pitch,\n  n_blades = params$n_blades,\n  hub_height = params$hub_height,\n  chord_prof = chord_prof_5MW,\n  n_turbines = params$n_turbines,\n  turb_oper_month = turb_oper,\n  wf_width = params$wf_width,\n  wf_latitude = params$wf_latitude,\n  tidal_offset = params$tidal_offset,\n  lrg_arr_corr = params$lrg_arr_corr\n  )\n```\n","funding_links":[],"readme_doi_urls":[],"works":{},"citation_counts":{},"total_citations":0,"keywords_from_contributors":["geocoding"],"project_url":"https://ost.ecosyste.ms/api/v1/projects/315036","html_url":"https://ost.ecosyste.ms/projects/315036"}