Skip to content

Commit

Permalink
Merge pull request #86 from nmfs-fish-tools/add_wiki_doc
Browse files Browse the repository at this point in the history
documentation, small fixes
  • Loading branch information
k-doering-NOAA authored Oct 7, 2021
2 parents 1507268 + 16cb9ab commit 0fd673f
Show file tree
Hide file tree
Showing 49 changed files with 1,659 additions and 693 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: SSMSE
Type: Package
Title: Management Strategy Evaluation (MSE) using Stock Synthesis (SS)
Version: 0.2.0
Version: 0.2.1
Authors@R: c(
person("Kathryn", "Doering", email = "[email protected]",
role = c("aut", "cre")),
Expand All @@ -19,7 +19,7 @@ URL: https://github.com/nmfs-fish-tools/SSMSE
BugReports: https://github.com/nmfs-fish-tools/SSMSE/issues
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
Imports:
stats,
utils,
Expand Down
4 changes: 1 addition & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Generated by roxygen2: do not edit by hand

export(SSMSE_summary_all)
export(SSMSE_summary_iter)
export(SSMSE_summary_scen)
export(create_future_om_list)
export(create_sample_struct)
export(create_scen_list)
export(develop_OMs)
export(get_bin)
export(get_input_value)
export(parse_MS)
export(plot_comp_sampling)
export(plot_index_sampling)
export(run_EM)
Expand Down
3 changes: 3 additions & 0 deletions R/initOM.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ create_OM <- function(OM_out_dir,
datsource = dat, ctlsource = ctl,
verbose = FALSE
)
if(ctl[["EmpiricalWAA"]] == 1) {
stop("OM is an empirical weight at age model, which is not yet possible to use.")
}
# model checks ----
if (ctl[["F_Method"]] == 1) {
stop(
Expand Down
5 changes: 5 additions & 0 deletions R/parse_MS.R
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,11 @@ parse_MS <- function(MS, EM_out_dir = NULL, EM_init_dir = NULL,
do_checks = TRUE,
verbose = verbose
)
ctl <- SS_readctl(file.path(EM_out_dir, start[["ctlfile"]]),
datlist = new_EM_dat)
if(ctl[["EmpiricalWAA"]] == 1) {
stop("EM uses empirical weight at age, which is not yet possible to use.")
}
} else {
if (!is.null(sample_struct)) {
sample_struct_sub <- lapply(sample_struct,
Expand Down
5 changes: 5 additions & 0 deletions R/runSSMSE.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ run_SSMSE <- function(scen_name_vec,
)
}
}


# make sure the output directories exist
result <- lapply(out_dir_scen_vec, function(x) if(!dir.exists(x)) dir.create(x, showWarnings = FALSE))

# check and add implicit inputs to the future_om_list
future_om_list <- check_future_om_list_str(future_om_list = future_om_list)
# Note that all input checks are done in the check_scen_list function.
Expand Down
10 changes: 6 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#' expected value with the reference value identifying the lag in years for availability
#' of the index (Ref_years: vector length n indices).
#' @author Kathryn Doering
#' @export
#' @examples
#' scen_list <- create_scen_list(
#' scen_name_vec = c("scen 1", "scen_2"),
Expand Down Expand Up @@ -328,14 +329,14 @@ clean_init_mod_files <- function(OM_out_dir, EM_out_dir = NULL, MS = "EM",
#' "value" = c(2, 2, 2, 3, 3),
#' "se_log" = 0.2
#' )
#' get_input_value(
#' SSMSE:::get_input_value(
#' data = dfr, method = "most_common_value", colname = "se_log",
#' group = "value"
#' )
#' get_input_value(data = dfr, method = "most_common_value", colname = "value")
#' get_input_value(data = dfr, method = "only_value", colname = "se_log")
#' SSMSE:::get_input_value(data = dfr, method = "most_common_value", colname = "value")
#' SSMSE:::get_input_value(data = dfr, method = "only_value", colname = "se_log")
#' # generates an error:
#' # get_input_value(data = dfr, method = "only_value", colname = "value")
#' # SSMSE:::get_input_value(data = dfr, method = "only_value", colname = "value")
get_input_value <- function(data,
method = "most_common_value",
colname,
Expand Down Expand Up @@ -698,6 +699,7 @@ combine_cols <- function(dat_list, list_item, colnames) {
#' Can be 1) NULL (default); 2) An integer vector of length 1, length 1+length(scen_name_vec), or length 1 + length(scen_name_vec)+sum(iter_vec); 3) A list with 3 components the same as teh output of set_MSE_seeds
#' @param iter_vec The number of iterations per scenario. A vector of integers
#' in the same order as scen_name_vec.
#' @export
#' @returns A list of length 3 with 1) the global seed value; 2) the scenario seed values; and 3) the iteration seed values.
#' @examples
#' seeds <- set_MSE_seeds(seed = seq(10, 80, by = 10), iter_vec = c(2, 3))
Expand Down
308 changes: 308 additions & 0 deletions docs/manual/404.html

Large diffs are not rendered by default.

332 changes: 173 additions & 159 deletions docs/manual/SSMSE.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

326 changes: 326 additions & 0 deletions docs/manual/glossary-of-mse-terms.html

Large diffs are not rendered by default.

88 changes: 55 additions & 33 deletions docs/manual/helper.html

Large diffs are not rendered by default.

90 changes: 56 additions & 34 deletions docs/manual/index.html

Large diffs are not rendered by default.

96 changes: 59 additions & 37 deletions docs/manual/intro.html

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/manual/libs/anchor-sections-1.0.1/anchor-sections.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Styles for section anchors */
a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
a.anchor-section::before {content: '#';}
.hasAnchor:hover a.anchor-section {visibility: visible;}
ul > li > .anchor-section {display: none;}
33 changes: 33 additions & 0 deletions docs/manual/libs/anchor-sections-1.0.1/anchor-sections.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
document.addEventListener('DOMContentLoaded', function() {
// Do nothing if AnchorJS is used
if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
return;
}

const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');

// Do nothing if sections are already anchored
if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
return null;
}

// Use section id when pandoc runs with --section-divs
const section_id = function(x) {
return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
? x.id : '');
};

// Add anchors
h.forEach(function(x) {
const id = x.id || section_id(x.parentElement);
if (id === '' || x.matches(':empty')) {
return null;
}
let anchor = document.createElement('a');
anchor.href = '#' + id;
anchor.classList = ['anchor-section'];
x.classList.add('hasAnchor');
x.appendChild(anchor);
});
});
6 changes: 6 additions & 0 deletions docs/manual/libs/gitbook-2.6.7/css/plugin-bookdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,9 @@ div.proof>*:last-child:after {
.header-section-number {
padding-right: .5em;
}
#header .multi-author {
margin: 0.5em 0 -0.5em 0;
}
#header .date {
margin-top: 1.5em;
}
11 changes: 11 additions & 0 deletions docs/manual/libs/gitbook-2.6.7/css/plugin-fontsettings.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,24 @@
line-height: 30px;
font-size: 1em;
}

/* sidebar transition background */
div.book.color-theme-1 {
background: #f3eacb;
}
.book.color-theme-1 .book-body {
color: #704214;
background: #f3eacb;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section {
background: #f3eacb;
}

/* sidebar transition background */
div.book.color-theme-2 {
background: #1c1f2b;
}

.book.color-theme-2 .book-body {
color: #bdcadb;
background: #1c1f2b;
Expand Down
9 changes: 7 additions & 2 deletions docs/manual/libs/gitbook-2.6.7/css/style.css

Large diffs are not rendered by default.

93 changes: 70 additions & 23 deletions docs/manual/libs/gitbook-2.6.7/js/plugin-search.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
var index = null;
var fuse = null;
var _search = {engine: 'lunr', opts: {}};
var $searchInput, $searchLabel, $searchForm;
var $highlighted = [], hi, hiOpts = { className: 'search-highlight' };
var collapse = false, toc_visible = [];

function init(config) {
// Instantiate search settings
_search = gitbook.storage.get("search", {
engine: config.search.engine || 'lunr',
opts: config.search.options || {},
});
};

// Save current search settings
function saveSearchSettings() {
gitbook.storage.set("search", _search);
}

// Use a specific index
function loadIndex(data) {
// [Yihui] In bookdown, I use a character matrix to store the chapter
Expand All @@ -14,18 +29,36 @@ gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
// lunr cannot handle non-English text very well, e.g. the default
// tokenizer cannot deal with Chinese text, so we may want to replace
// lunr with a dumb simple text matching approach.
index = lunr(function () {
this.ref('url');
this.field('title', { boost: 10 });
this.field('body');
});
data.map(function(item) {
index.add({
url: item[0],
title: item[1],
body: item[2]
if (_search.engine === 'lunr') {
index = lunr(function () {
this.ref('url');
this.field('title', { boost: 10 });
this.field('body');
});
});
data.map(function(item) {
index.add({
url: item[0],
title: item[1],
body: item[2]
});
});
return;
}
fuse = new Fuse(data.map((_data => {
return {
url: _data[0],
title: _data[1],
body: _data[2]
};
})), Object.assign(
{
includeScore: true,
threshold: 0.1,
ignoreLocation: true,
keys: ["title", "body"]
},
_search.opts
));
}

// Fetch the search index
Expand All @@ -36,20 +69,33 @@ gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {

// Search for a term and return results
function search(q) {
if (!index) return;

var results = _.chain(index.search(q))
.map(function(result) {
var parts = result.ref.split("#");
return {
path: parts[0],
hash: parts[1]
};
})
.value();
let results = [];
switch (_search.engine) {
case 'fuse':
if (!fuse) return;
results = fuse.search(q).map(function(result) {
var parts = result.item.url.split('#');
return {
path: parts[0],
hash: parts[1]
};
});
break;
case 'lunr':
default:
if (!index) return;
results = _.chain(index.search(q)).map(function(result) {
var parts = result.ref.split("#");
return {
path: parts[0],
hash: parts[1]
};
})
.value();
}

// [Yihui] Highlight the search keyword on current page
$highlighted = results.length === 0 ? [] : $('.page-inner')
$highlighted = $('.page-inner')
.unhighlight(hiOpts).highlight(q, hiOpts).find('span.search-highlight');
scrollToHighlighted(0);

Expand Down Expand Up @@ -172,6 +218,7 @@ gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
gitbook.events.bind("start", function(e, config) {
// [Yihui] disable search
if (config.search === false) return;
init(config);
collapse = !config.toc || config.toc.collapse === 'section' ||
config.toc.collapse === 'subsection';

Expand Down
15 changes: 13 additions & 2 deletions docs/manual/libs/gitbook-2.6.7/js/plugin-sharing.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,21 @@ gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
e.preventDefault();
window.open("http://vkontakte.ru/share.php?url="+encodeURIComponent(location.href));
}
}
},
'whatsapp': {
'label': 'Whatsapp',
'icon': 'fa fa-whatsapp',
'onClick': function(e) {
e.preventDefault();
var url = encodeURIComponent(location.href);
window.open((isMobile() ? "whatsapp://send" : "https://web.whatsapp.com/send") + "?text=" + url);
}
},
};


function isMobile() {
return !!navigator.maxTouchPoints;
}

gitbook.events.bind("start", function(e, config) {
var opts = config.sharing;
Expand Down
12 changes: 12 additions & 0 deletions docs/manual/libs/header-attrs-2.11/header-attrs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
// be compatible with the behavior of Pandoc < 2.8).
document.addEventListener('DOMContentLoaded', function(e) {
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
var i, h, a;
for (i = 0; i < hs.length; i++) {
h = hs[i];
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
a = h.attributes;
while (a.length > 0) h.removeAttribute(a[0].name);
}
});
2 changes: 2 additions & 0 deletions docs/manual/libs/jquery-3.6.0/jquery-3.6.0.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 0fd673f

Please sign in to comment.