Skip to content

Commit 0ca60e6

Browse files
committed
Add cross-referentiable bibliography
1 parent cc085ff commit 0ca60e6

File tree

11 files changed

+204
-71
lines changed

11 files changed

+204
-71
lines changed

docs/bib/bib2md.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""Render bibtex file as markdown with keys as headings that can be cross-referenced."""
2+
3+
from pathlib import Path
4+
5+
import pybtex.backends.markdown as fmt
6+
from pybtex.database import parse_string
7+
from pybtex.richtext import Tag, Text
8+
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
9+
from pybtex.style.formatting.unsrt import field, sentence
10+
11+
fmt.SPECIAL_CHARS.remove("[")
12+
fmt.SPECIAL_CHARS.remove("]")
13+
fmt.SPECIAL_CHARS.remove("(")
14+
fmt.SPECIAL_CHARS.remove(")")
15+
fmt.SPECIAL_CHARS.remove("-")
16+
17+
HERE = Path(__file__).parent
18+
19+
20+
class MyStyle(UnsrtStyle):
21+
# default_sorting_style = "author_year_title"
22+
def format_title(self, e, which_field, as_sentence=True):
23+
formatted_title = field(
24+
which_field,
25+
apply_func=lambda text: Tag("tt", Text('"', text.capitalize(), '"')),
26+
)
27+
if as_sentence:
28+
return sentence[formatted_title]
29+
else:
30+
return formatted_title
31+
32+
33+
bib = parse_string((HERE / "refs.bib").read_text(), "bibtex")
34+
35+
formatted = MyStyle().format_entries(bib.entries.values())
36+
37+
md = ""
38+
for entry in formatted:
39+
md += f"### `{entry.key}`\n\n"
40+
md += entry.text.render_as("markdown") + "\n\n"
41+
42+
(HERE.parent / "references.md").write_text(md)

docs/bib/refs.bib

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
@article{emerick2016a,
2+
title={Analysis of the performance of ensemble-based assimilation of production and seismic data},
3+
author={Emerick, Alexandre A.},
4+
journal={Journal of Petroleum Science and Engineering},
5+
volume={139},
6+
pages={219--239},
7+
year={2016},
8+
publisher={Elsevier}
9+
}
10+
11+
@book{evensen2009a,
12+
title={Data Assimilation},
13+
author={Evensen, Geir},
14+
year={2009},
15+
edition={2},
16+
pages={307},
17+
publisher={Springer}
18+
}
19+
20+
@article{emerick2013a,
21+
title={Ensemble smoother with multiple data assimilation},
22+
author={Emerick, Alexandre A. and Reynolds, Albert C.},
23+
journal={Computers \& Geosciences},
24+
volume={55},
25+
pages={3--15},
26+
year={2013},
27+
publisher={Elsevier}
28+
}
29+
30+
@article{rafiee2017,
31+
title={Theoretical and efficient practical procedures for the generation of inflation factors for ES-MDA},
32+
author={Rafiee, Javad and Reynolds, Albert C},
33+
journal={Inverse Problems},
34+
volume={33},
35+
number={11},
36+
pages={115003},
37+
year={2017},
38+
publisher={IOP Publishing}
39+
}
40+
41+
@article{chen2013,
42+
title={Levenberg--{M}arquardt forms of the iterative ensemble smoother for efficient history matching and uncertainty quantification},
43+
author={Chen, Yan and Oliver, Dean S.},
44+
journal={Computational Geosciences},
45+
volume={17},
46+
number={4},
47+
pages={689--703},
48+
year={2013},
49+
publisher={Springer}
50+
}
51+
52+
@article{raanes2019,
53+
title={Revising the stochastic iterative ensemble smoother},
54+
author={Raanes, Patrick Nima and Stordal, Andreas St{\o}rksen and Evensen, Geir},
55+
doi={10.5194/npg-26-325-2019},
56+
journal={Nonlinear Processes in Geophysics},
57+
volume={26},
58+
number={3},
59+
pages={325--338},
60+
year={2019},
61+
publisher={Copernicus GmbH}
62+
}
63+
64+
@article{evensen2019,
65+
title={Efficient implementation of an iterative ensemble smoother for data assimilation and reservoir history matching},
66+
author={Evensen, Geir and Raanes, Patrick N. and Stordal, Andreas S. and Hove, Joakim},
67+
doi={10.3389/fams.2019.00047},
68+
journal={Frontiers in Applied Mathematics and Statistics},
69+
volume={5},
70+
pages={47},
71+
year={2019},
72+
publisher={Frontiers}
73+
}
74+
75+
@article{kingma2014,
76+
title={Adam: A method for stochastic optimization},
77+
author={Kingma, Diederik P},
78+
journal={arXiv preprint arXiv:1412.6980},
79+
year={2014}
80+
}
81+
82+
@article{hansen2006,
83+
title={The {CMA} evolution strategy: a comparing review},
84+
author={Hansen, Nikolaus},
85+
journal={Towards a new evolutionary computation: Advances in the estimation of distribution algorithms},
86+
pages={75--102},
87+
year={2006},
88+
publisher={Springer}
89+
}

docs/gen_ref_pages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# Generate index.md
3030
parts = parts[:-1] # name of parent dir
3131
path_md = path_md.with_name("index.md")
32-
elif parts[-1] == str(Path(__file__).with_suffix("").name):
32+
elif parts[0] == "docs":
3333
continue
3434

3535
# PS: Uncomment (replace `mkdocs_gen_files.open`) to view actual .md files

docs/references.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
### `emerick2016a`
2+
3+
Alexandre A\. Emerick\.
4+
`"Analysis of the performance of ensemble-based assimilation of production and seismic data"`\.
5+
*Journal of Petroleum Science and Engineering*, 139:219–239, 2016\.
6+
7+
### `evensen2009a`
8+
9+
Geir Evensen\.
10+
*Data Assimilation*\.
11+
Springer, 2 edition, 2009\.
12+
13+
### `emerick2013a`
14+
15+
Alexandre A\. Emerick and Albert C\. Reynolds\.
16+
`"Ensemble smoother with multiple data assimilation"`\.
17+
*Computers & Geosciences*, 55:3–15, 2013\.
18+
19+
### `rafiee2017`
20+
21+
Javad Rafiee and Albert C Reynolds\.
22+
`"Theoretical and efficient practical procedures for the generation of inflation factors for es-mda"`\.
23+
*Inverse Problems*, 33(11):115003, 2017\.
24+
25+
### `chen2013`
26+
27+
Yan Chen and Dean S\. Oliver\.
28+
`"Levenberg–Marquardt forms of the iterative ensemble smoother for efficient history matching and uncertainty quantification"`\.
29+
*Computational Geosciences*, 17(4):689–703, 2013\.
30+
31+
### `raanes2019`
32+
33+
Patrick Nima Raanes, Andreas Størksen Stordal, and Geir Evensen\.
34+
`"Revising the stochastic iterative ensemble smoother"`\.
35+
*Nonlinear Processes in Geophysics*, 26(3):325–338, 2019\.
36+
[doi:10\.5194/npg-26-325-2019](https://doi.org/10.5194/npg-26-325-2019)\.
37+
38+
### `evensen2019`
39+
40+
Geir Evensen, Patrick N\. Raanes, Andreas S\. Stordal, and Joakim Hove\.
41+
`"Efficient implementation of an iterative ensemble smoother for data assimilation and reservoir history matching"`\.
42+
*Frontiers in Applied Mathematics and Statistics*, 5:47, 2019\.
43+
[doi:10\.3389/fams\.2019\.00047](https://doi.org/10.3389/fams.2019.00047)\.
44+
45+
### `kingma2014`
46+
47+
Diederik P Kingma\.
48+
`"Adam: a method for stochastic optimization"`\.
49+
*arXiv preprint arXiv:1412\.6980*, 2014\.
50+
51+
### `hansen2006`
52+
53+
Nikolaus Hansen\.
54+
`"The CMA evolution strategy: a comparing review"`\.
55+
*Towards a new evolutionary computation: Advances in the estimation of distribution algorithms*, pages 75–102, 2006\.
56+

docs/tutorials/pipt/tutorial_pipt.ipynb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,7 @@
303303
"\n",
304304
" keys_en : dict\n",
305305
"\n",
306-
" sim : callable\n",
307-
"\n",
308-
" References\n",
309-
" ----------\n",
310-
" [1] A. Emerick & A. Reynods, Computers & Geosciences, 55, p. 3-15, 2013\n",
311-
" \n"
306+
" sim : callable\n"
312307
]
313308
},
314309
{

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ nav:
1111
- Home: index.md
1212
- Reference: reference/
1313
- Tutorials: tutorials/
14-
# - Bibliography: references.md
14+
- Bibliography: references.md
1515
- dev_guide.md
1616

1717
validation:

pipt/misc_tools/analysis_tools.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
def parallel_upd(list_state, prior_info, states_dict, X, local_mask_info, obs_data, pred_data, parallel, actnum=None,
2222
field_dim=None, act_data_list=None, scale_data=None, num_states=1, emp_d_cov=False):
2323
"""
24-
Script to initialize and control a parallel update of the ensemble state following [1].
24+
Script to initialize and control a parallel update of the ensemble state following [`emerick2016a`][].
2525
2626
Parameters
2727
----------
@@ -57,11 +57,6 @@ def parallel_upd(list_state, prior_info, states_dict, X, local_mask_info, obs_da
5757
Notes
5858
-----
5959
Since the localization matrix is to large for evaluation, we instead calculate it row for row.
60-
61-
References
62-
----------
63-
[1] Emerick, Alexandre A. 2016. “Analysis of the Performance of Ensemble-Based Assimilation of Production and
64-
Seismic Data.” Journal of Petroleum Science and Engineering 139. Elsevier: 219-39. doi:10.1016/j.petrol.2016.01.029
6560
"""
6661
if scale_data is None:
6762
scale_data = np.ones(obs_data.shape[0])
@@ -1060,7 +1055,7 @@ def calc_kalmangain(cov_cross, cov_auto, cov_data, opt=None):
10601055
def calc_subspace_kalmangain(cov_cross, data_pert, cov_data, energy):
10611056
"""
10621057
Compute the Kalman gain in a efficient subspace determined by how much energy (i.e. percentage of singluar values)
1063-
to retain. For more info regarding the implementation, see Chapter 14 in [1].
1058+
to retain. For more info regarding the implementation, see Chapter 14 in [`evensen2009a`][].
10641059
10651060
Parameters
10661061
cov_cross : ndarray
@@ -1074,10 +1069,6 @@ def calc_subspace_kalmangain(cov_cross, data_pert, cov_data, energy):
10741069
-------
10751070
k_g : ndarray
10761071
Subspace Kalman gain
1077-
1078-
References
1079-
----------
1080-
[1] G. Evensen (2009). Data Assimilation: The Ensemble Kalman Filter, Springer.
10811072
"""
10821073
# No. ensemble members
10831074
ne = data_pert.shape[1]

pipt/update_schemes/enrml.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ class gnenrml_margis(gnenrmlMixIn, margIS_update):
645645

646646
class co_lm_enrml(lmenrmlMixIn, approx_update):
647647
"""
648-
This is the implementation of the approximative LM-EnRML algorithm as described in [1].
648+
This is the implementation of the approximative LM-EnRML algorithm as described in [`chen2013`][].
649649
650650
This algorithm is quite similar to the lm_enrml as provided above, and will therefore inherit most of its methods.
651651
We only change the calc_analysis part...
@@ -657,11 +657,6 @@ def __init__(self, keys_da):
657657
"""
658658
The class is initialized by passing the PIPT init. file upwards in the hierarchy to be read and parsed in
659659
`pipt.input_output.pipt_init.ReadInitFile`.
660-
661-
References
662-
----------
663-
[1] Chen Y. & Oliver D.S. 2013, Levenberg-Marquardt Forms of the Iterative Ensemble Smoother for Efficient
664-
History Matching and Uncertainty Quantification. Comput. Geosci., 17 (4): 689-703
665660
"""
666661
# Call __init__ in parent class
667662
super().__init__(keys_da)
@@ -679,11 +674,6 @@ def calc_analysis(self):
679674
-------
680675
success : bool
681676
True if data mismatch is decreasing, False if increasing
682-
683-
References
684-
----------
685-
[1] Chen Y. & Oliver D.S. 2013, Levenberg-Marquardt Forms of the Iterative Ensemble Smoother for Efficient
686-
History Matching and Uncertainty Quantification. Comput. Geosci., 17 (4): 689-703
687677
"""
688678
# Get assimilation order as a list
689679
self.assim_index = [self.keys_da['obsname'], self.keys_da['assimindex'][0]]
@@ -795,8 +785,10 @@ def calc_analysis(self):
795785

796786
class gn_enrml(lmenrmlMixIn):
797787
"""
798-
This is the implementation of the stochastig IES as described in [1]. More information about the method is found in
799-
[2]. This implementation is the Gauss-Newton version.
788+
This is the implementation of the stochastig IES as described in [`raanes2019`][].
789+
790+
More information about the method is found in [`evensen2019`][].
791+
This implementation is the Gauss-Newton version.
800792
801793
This algorithm is quite similar to the `lm_enrml` as provided above, and will therefore inherit most of its methods.
802794
We only change the calc_analysis part...
@@ -806,14 +798,6 @@ def __init__(self, keys_da):
806798
"""
807799
The class is initialized by passing the PIPT init. file upwards in the hierarchy to be read and parsed in
808800
`pipt.input_output.pipt_init.ReadInitFile`.
809-
810-
References
811-
----------
812-
[1] Raanes, P. N., Stordal, A. S., & Evensen, G. (2019). Revising the stochastic iterative ensemble smoother.
813-
Nonlinear Processes in Geophysics, 26(3), 325-338. https://doi.org/10.5194/npg-26-325-2019 <br>
814-
[2] Evensen, G., Raanes, P. N., Stordal, A. S., & Hove, J. (2019). Efficient Implementation of an Iterative
815-
Ensemble Smoother for Data Assimilation and Reservoir History Matching. Frontiers in Applied Mathematics and
816-
Statistics, 5(October), 114. https://doi.org/10.3389/fams.2019.00047
817801
"""
818802
# Call __init__ in parent class
819803
super().__init__(keys_da)

pipt/update_schemes/esmda.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
class esmdaMixIn(Ensemble):
2222
"""
23-
This is the implementation of the ES-MDA algorithm given in [1]. This algorithm have been implemented mostly to
23+
This is the implementation of the ES-MDA algorithm given in [`emerick2013a`][].
24+
This algorithm have been implemented mostly to
2425
illustrate how a algorithm using the Mda loop can be implemented.
2526
"""
2627

@@ -37,10 +38,6 @@ def __init__(self, keys_da, keys_en, sim):
3738
keys_en : dict
3839
3940
sim : callable
40-
41-
References
42-
----------
43-
[1] A. Emerick & A. Reynods, Computers & Geosciences, 55, p. 3-15, 2013
4441
"""
4542
# Pass the init_file upwards in the hierarchy
4643
super().__init__(keys_da, keys_en, sim)
@@ -330,17 +327,13 @@ class esmda_geo(esmda_approx):
330327
"""
331328
This is the implementation of the ES-MDA-GEO algorithm from [1]. The main analysis step in this algorithm is the
332329
same as the standard ES-MDA algorithm (implemented in the `es_mda` class). The difference between this and the
333-
standard algorithm is the calculation of the inflation factor.
330+
standard algorithm is the calculation of the inflation factor. Also see [`rafiee2017`][].
334331
"""
335332

336333
def __init__(self, keys_da):
337334
"""
338335
The class is initialized by passing the PIPT init. file upwards in the hierarchy to be read and parsed in
339336
`pipt.input_output.pipt_init.ReadInitFile`.
340-
341-
References
342-
----------
343-
[1] J. Rafiee & A. Reynolds, Inverse Problems 33 (11), 2017
344337
"""
345338
# Pass the init_file upwards in the hierarchy
346339
super().__init__(keys_da)

popt/update_schemes/cma.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class CMA:
66

77
def __init__(self, ne, dim, alpha_mu=None, n_mu=None, alpha_1=None, alpha_c=None, corr_update=False, equal_weights=True):
88
'''
9-
This is a rather simple simple CMA class
9+
This is a rather simple simple CMA class [`hansen2006`][].
1010
1111
Parameters
1212
----------------------------------------------------------------------------------------------------------
@@ -37,12 +37,6 @@ def __init__(self, ne, dim, alpha_mu=None, n_mu=None, alpha_1=None, alpha_c=None
3737
If True, all n_mu members are assign equal weighting, `w_i = 1/n_mu`.
3838
If False, the weighting scheme proposed in [1], where `w_i = log(n_mu + 1)-log(i)`,
3939
and normalized such that they sum to one. Defualt is True.
40-
41-
References
42-
----------------------------------------------------------------------------------------------------------
43-
[1] Hansen, N. (2006). The CMA evolution strategy: a comparing review.
44-
In J. Lozano, P. Larranaga, I. Inza & E. Bengoetxea (ed.), Towards a new evolutionary computation.
45-
Advances on estimation of distribution algorithms (pp. 75--102) . Springer .
4640
'''
4741
self.alpha_mu = alpha_mu
4842
self.n_mu = n_mu

0 commit comments

Comments
 (0)