Skip to content

Commit 635490f

Browse files
committed
updated readme and omgph
1 parent 358de15 commit 635490f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

omegaph/omgph.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,16 @@
108108
tloc=coords(i,:);
109109
%first check for GoM locations
110110
if ind_g(i)
111-
d1=findnearest(depth(i),gom.depth);
112-
omega(i)=gom.omega(d1(1));
111+
[~,d1]=min(abs(depth(i)-gom.depth));
112+
omega(i)=gom.omega(d1);
113113
%notice we are grabbing surface ph
114114
ph(i)=gom.ph(1);
115115
dists_om(i)=0;
116116
dists_ph(i)=0;
117117
%next check for Carib location
118118
elseif ind_c(i)
119-
d1=findnearest(depth(i),wdepth);
120-
d1=d1(1);
121-
lat1=findnearest(tloc(2),lat_carib);
119+
[~,d1]=min(abs(depth(i)-wdepth));
120+
lat1=min(abs(tloc(2)-lat_carib));
122121
ph(i)=ph_carib(lat1(1));
123122
omega(i)=omega_carib(lat1(1),d1);
124123
%loop in case you grab a NaN for omega
@@ -138,8 +137,7 @@
138137
if isnan(depth(i))
139138
omega(i)=NaN;
140139
else
141-
dnew=findnearest(depth(i),wdepth);
142-
dnew=dnew(1);
140+
[~,dnew]=min(abs(depth(i)-wdepth));
143141
[dmin,imin]=min(EarthChordDistances_2(locs_obs_omega{dnew},tloc));
144142
%if omega is greater than cutoff, search nearby depths
145143
while dmin > max_dist

readme.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# BAYMAG
22

3-
The BAYMAG package is a set of Bayesian hierarchical models for Mg/Ca in planktic foraminifera. The functions here can be used to both predict Mg/Ca from T, S, pH, Omega, and cleaning method, and predict T given constraints on the other four predictor variables. For a full discussion of this model, please see Tierney et al., 2019, Paleoceanography & Paleoclimatology (in prep).
3+
The BAYMAG package is a set of Bayesian hierarchical models for Mg/Ca in planktic foraminifera. The functions here can be used to both predict Mg/Ca from T, S, pH, Omega, and cleaning method, and predict T given constraints on the other four predictor variables. For a full discussion of this model, please read the source publication:
4+
5+
Jessica E. Tierney, Steven B. Malevich, William Gray, Lael Vetter, and Kaustubh Thirumalai (2019), Bayesian calibration of the Mg/Ca paleothermometer in planktic foraminifera. Paleoceanography & Paleoclimatology 34, 2005--2030, https://doi.org/10.1029/2019PA003744.
46

57
A quick guide to basic use:
68

79
To model Mg/Ca from T, S, pH, Omega, and cleaning values:
8-
Use baymag_forward.m. This function calculates Mg/Ca values using posterior draws from the calibration model (stored in the params.mat files). It has the option to add a normal prior if you would like to place some restrictions on posterior Mg/Ca, and to account for changing Mg/Ca of seawater (for longer geological timescales). baymag_forward has no dependent functions but does need the params.mat files.
10+
Use baymag_forward.m or baymag_forward_ln.m (which calculates ln(Mg/Ca)). These functions calculate Mg/Ca values using posterior draws from the calibration model (stored in the params.mat files). It has the option to add a normal prior if you would like to place some restrictions on posterior Mg/Ca, and an option to account for changing Mg/Ca of seawater (for longer geological timescales). baymag_forward and baymag_forward_ln have no dependent functions but do need the params.mat files.
911

1012
To model SST from Mg/Ca, S, pH, Omega, and cleaning values:
11-
Use baymag_predict.m. This function calculates SST given Mg/Ca and inputs of S, pH, Omega, and cleaning through Bayesian inference. It has an option to correct for Mg/Ca of seawater changes. The Bayesian models are written in Stan (mgpred.stan and mgpred_sw.stan). You will need to install both Stan and MatlabStan in order to use this function. Download the latest version of the command line version of Stan here: https://github.com/stan-dev/cmdstan/releases. BAYMAG has been tested up to v2.19.1. MatlabStan is here: https://github.com/brian-lau/MatlabStan/releases. BAYMAG has been tested with v2.15.1.0. Alternatively, you can run the Stan models from Python or R, but in that case you will need to write your own wrapper like baymag_predict.
13+
Use baymag_predict.m. This function calculates SST given Mg/Ca and inputs of S, pH, Omega, and cleaning through Bayesian inference. It has an option to correct for Mg/Ca of seawater changes. The Bayesian models are written in Stan (mgpred.stan and mgpred_sw.stan). You will need to install both Stan and MatlabStan in order to use this function. Download the latest version of the command line version of Stan here: https://github.com/stan-dev/cmdstan/releases. BAYMAG has been tested up to v2.30.1. MatlabStan is here: https://github.com/brian-lau/MatlabStan/releases. BAYMAG has been tested with the last released version, v2.15.1.0. NOTE: if you try and run MatlabStan and get the error "Having a problem getting stan version", open up StanModel.m and comment out Line 196: ver = self.stan_version(). Add a new line below: ver = '2.30.1'; (or replace with the current version of cmdstan).
14+
15+
Alternatively, you can run the Stan models from Python or R, but in that case you will need to write your own wrapper like baymag_predict.
1216

1317
To model SST from Mg/Ca, S, pH, Omega, and cleaning values and include errors in S, pH, and Omega:
1418
Use baymag_predict_err.m. This version allows the user to input priors for T, S, pH, and Omega and therefore include uncertainties in S, pH, and Omega. It iteratively solves for posteriors for all four variables, thus be advised that it is quite a bit slower than baymag_predict.m. It also has an option for a seawater correction.

0 commit comments

Comments
 (0)