This page was generated from docs/Examples/4e. other_error.ipynb. Interactive online version: Binder badge.

Python Notebook Download

4e. Monte Carlo approach for errors on melt composition

This allows you to use a Monte Carlo approach to calculate the various compositions of a given melt within specified errors.

Python set-up

You need to install VolFe once on your machine, if you haven’t yet. Then we need to import a few Python packages (including VolFe).

[1]:
# Install VolFe on your machine. Don't remove the # from this line!
# pip install VolFe # Remove the first # in this line if you have not installed VolFe on your machine before.

# import python packages
import pandas as pd
import matplotlib.pyplot as plt
import VolFe as vf

Definte the inputs

The melt composition, temperature, and associated errors can be given in a dataframe, or read from a csv file. The size of the error and its type (i.e., R = relative or A = absolute) must be specified.

In this example it is read from a dataframe:

[4]:
my_analyses = pd.read_csv("../files/example_marianas_wT.csv")  # load data

Run the calculation

And then calculate 50 versions (last number) for row number 29 (middle number).

[5]:
vf.calc_comp_error(my_analyses,29,50)
[5]:
Sample T_C SiO2 TiO2 Al2O3 FeOT MnO MgO CaO Na2O K2O P2O5 H2O CO2ppm Xppm STppm Fe3FeT
1 Ala02-16A 1200 43.97 0.7 19.09 9.36 0.22 6.76 13.28 1.46 0.37 0.11 4.32 999 0 1544.07 0.238
2 sds 0.01 0.05 0.01 0.01 0.05 0.01 0.01 0.01 0.05 0.05 0.25 75 0 100 0.005
3 sd types R R R R R R R R R R A A A A A
4 29 1200 43.492294 0.700604 19.104957 9.380647 0.221504 6.776891 13.363895 1.481518 0.371929 0.107746 4.667413 1027.370362 0.0 1522.486314 0.232664
5 29 1200 43.699984 0.789328 19.206477 9.228089 0.24087 6.842727 13.374412 1.46053 0.376602 0.113082 4.12724 1021.121919 0.0 1395.069449 0.227176
6 29 1200 44.341452 0.708732 19.316096 9.325322 0.216973 6.891873 13.161528 1.485737 0.391169 0.117245 4.362767 1029.989059 0.0 1385.235187 0.228095
7 29 1200 43.72343 0.782993 19.165176 9.448362 0.21416 6.845775 13.429698 1.468796 0.326891 0.109856 4.472351 926.945077 0.0 1592.957784 0.244078
8 29 1200 44.327725 0.703916 19.171718 9.337419 0.215364 6.773963 13.141357 1.447546 0.334356 0.114912 4.333905 945.508938 0.0 1627.374309 0.245801
9 29 1200 43.445399 0.709615 19.048732 9.383361 0.209258 6.650155 13.304776 1.488822 0.354108 0.117471 4.216744 843.519806 0.0 1635.593573 0.232164
10 29 1200 43.665766 0.648681 18.981298 9.309443 0.214209 6.686915 13.197334 1.475805 0.378279 0.113747 4.315099 1193.8749 0.0 1599.545616 0.235223
11 29 1200 44.686811 0.720756 19.085082 9.472572 0.217927 6.780296 13.460011 1.488355 0.392499 0.109724 4.338568 1138.164016 0.0 1543.860302 0.231942
12 29 1200 44.200792 0.744299 19.14058 9.193596 0.221465 6.740652 13.299842 1.478217 0.361144 0.116281 4.39815 1082.733319 0.0 1587.460345 0.241328
13 29 1200 44.713282 0.676253 19.089949 9.456022 0.22656 6.790454 13.258116 1.463195 0.390343 0.109899 4.276809 942.325382 0.0 1635.258895 0.243809
14 29 1200 44.240178 0.65719 19.206907 9.310391 0.210962 6.813238 13.520333 1.448826 0.36463 0.102059 4.070174 947.933566 0.0 1564.337144 0.250178
15 29 1200 43.908047 0.679829 18.980097 9.371746 0.208664 6.811198 13.079984 1.433581 0.347361 0.113575 4.424176 1000.06122 0.0 1613.930774 0.235752
16 29 1200 44.150178 0.667668 18.699405 9.347138 0.222872 6.732251 13.205388 1.45673 0.391725 0.108969 3.856246 986.455957 0.0 1775.324305 0.243901
17 29 1200 44.432107 0.652906 19.234759 9.404858 0.23594 6.786409 13.370133 1.481343 0.398791 0.112005 3.914394 1078.658085 0.0 1801.188876 0.231448
18 29 1200 43.981403 0.722547 19.171629 9.51004 0.21115 6.711398 13.365762 1.46213 0.416281 0.102292 4.403714 935.676198 0.0 1618.881682 0.227654
19 29 1200 44.297989 0.622613 19.350142 9.324711 0.221942 6.717626 13.343027 1.465968 0.380829 0.113261 4.045715 1045.052683 0.0 1304.673451 0.239003
20 29 1200 44.148016 0.738097 19.366471 9.354367 0.219616 6.673864 13.1454 1.440118 0.373962 0.112602 4.339856 1008.782977 0.0 1600.995744 0.235279
21 29 1200 44.7145 0.661599 19.263313 9.224883 0.215717 6.686877 13.230175 1.453365 0.386632 0.109087 4.106869 931.102199 0.0 1704.918711 0.243478
22 29 1200 43.663924 0.745548 19.031171 9.264562 0.20557 6.737609 13.441857 1.454634 0.378786 0.108398 4.409521 874.132132 0.0 1629.267272 0.241317
23 29 1200 44.424053 0.690766 19.110631 9.456249 0.240029 6.825719 13.389175 1.476053 0.381389 0.111292 4.176697 997.771692 0.0 1632.991298 0.240582
24 29 1200 43.796838 0.710532 19.541126 9.58271 0.199618 6.746838 13.358001 1.473664 0.35609 0.109681 4.331799 1040.875407 0.0 1699.692866 0.230592
25 29 1200 44.587223 0.70231 19.461602 9.319447 0.220242 6.715725 13.310739 1.446644 0.387752 0.10878 4.460826 979.891431 0.0 1532.633418 0.238441
26 29 1200 44.442309 0.690041 19.15542 9.475661 0.223572 6.775171 13.212262 1.456161 0.352139 0.1082 4.247956 1061.791376 0.0 1585.042808 0.248404
27 29 1200 43.90267 0.724708 19.231145 9.292592 0.237997 6.751415 13.190443 1.437604 0.354914 0.117909 4.675176 976.122926 0.0 1517.690863 0.236569
28 29 1200 43.12831 0.713801 19.271057 9.420975 0.248435 6.74914 13.066253 1.467704 0.407568 0.113431 4.303281 963.087801 0.0 1712.09 0.236268
29 29 1200 44.306994 0.728679 18.923893 9.271533 0.223005 6.718395 13.279591 1.452717 0.345827 0.112789 4.593974 1160.669133 0.0 1678.2394 0.227182
30 29 1200 43.76908 0.680471 19.070716 9.378608 0.205754 6.765318 13.062402 1.472113 0.376461 0.108449 4.170577 996.037704 0.0 1539.622349 0.238542
31 29 1200 43.392221 0.685353 19.08496 9.307277 0.191188 6.908128 13.367261 1.45352 0.400263 0.107726 4.47365 1122.775035 0.0 1533.027369 0.23362
32 29 1200 44.324145 0.769371 19.129561 9.342489 0.231949 6.752541 13.440442 1.43367 0.400788 0.105656 4.30654 921.13761 0.0 1404.296101 0.238582
33 29 1200 44.736429 0.678605 18.961839 9.50516 0.219787 6.894508 13.410175 1.476835 0.348503 0.119127 4.08783 1036.652657 0.0 1441.358521 0.237492
34 29 1200 44.046685 0.683486 19.211456 9.26906 0.223999 6.818507 13.208145 1.45779 0.336217 0.112302 4.653409 1035.074529 0.0 1658.016188 0.232469
35 29 1200 43.580517 0.735733 19.053397 9.339462 0.232999 6.794395 13.348612 1.450421 0.360893 0.110183 4.12065 995.061245 0.0 1604.00072 0.234714
36 29 1200 44.50666 0.678726 19.578375 9.394451 0.22845 6.861766 13.373681 1.457784 0.375266 0.114059 4.825341 863.556293 0.0 1752.785814 0.247001
37 29 1200 44.67878 0.781093 18.675126 9.194347 0.22292 6.803605 13.482582 1.477621 0.3355 0.112655 4.468948 995.328127 0.0 1635.701246 0.23757
38 29 1200 43.701506 0.63293 19.208332 9.234954 0.210494 6.649366 13.149255 1.455507 0.396825 0.10778 3.951969 980.035533 0.0 1778.122711 0.239776
39 29 1200 43.049115 0.686705 19.618806 9.486796 0.236432 6.732568 13.095247 1.462762 0.360359 0.103343 4.169188 1081.523262 0.0 1539.761708 0.233111
40 29 1200 44.770515 0.708771 18.963172 9.395814 0.217261 6.785645 13.274776 1.444858 0.385249 0.117641 4.238615 1089.025268 0.0 1601.733763 0.233946
41 29 1200 43.263535 0.718849 19.278691 9.401648 0.200404 6.786487 13.290115 1.436638 0.402499 0.105152 4.360818 996.144351 0.0 1620.295963 0.244046
42 29 1200 43.940875 0.736015 18.882935 9.335818 0.224211 6.884706 13.277355 1.455011 0.385394 0.11312 4.058611 1039.751455 0.0 1549.050372 0.234062
43 29 1200 44.171598 0.729358 19.065782 9.459613 0.215508 6.809008 13.30287 1.458624 0.342678 0.108302 4.676664 1026.426587 0.0 1615.544955 0.23025
44 29 1200 43.353353 0.729949 19.238693 9.344044 0.204355 6.776455 13.34937 1.458403 0.393296 0.116069 3.956577 1113.844319 0.0 1538.60807 0.231908
45 29 1200 43.642745 0.759195 19.002606 9.448796 0.225489 6.740649 13.478277 1.438106 0.380612 0.110198 3.952846 1056.435717 0.0 1514.782862 0.23424
46 29 1200 43.859826 0.666607 18.860764 9.349348 0.220956 6.697337 13.162407 1.489681 0.366784 0.110183 4.288626 997.156506 0.0 1578.398163 0.236465
47 29 1200 43.65781 0.705336 19.485612 9.475089 0.202206 6.842934 13.15392 1.435485 0.366094 0.107631 4.164924 955.978183 0.0 1413.343724 0.23962
48 29 1200 43.349076 0.747788 18.824621 9.240216 0.217991 6.708542 13.700027 1.455188 0.370771 0.102871 3.70975 1054.907963 0.0 1488.514135 0.240292
49 29 1200 44.094892 0.665216 19.232082 9.338916 0.225369 6.871103 13.512645 1.471766 0.351561 0.109482 4.148637 960.052889 0.0 1443.89743 0.229757
50 29 1200 43.897917 0.721302 19.066518 9.489858 0.22888 6.754505 13.441531 1.452966 0.380994 0.107229 4.311599 1032.613079 0.0 1610.141517 0.236531
51 29 1200 43.744046 0.657079 19.275849 9.33357 0.220779 6.715952 13.089618 1.444975 0.37466 0.106399 4.719468 1043.020865 0.0 1598.537893 0.23441
52 29 1200 44.516305 0.658388 19.116765 9.275448 0.229067 6.674448 13.551765 1.461458 0.399959 0.116299 4.531881 992.919983 0.0 1355.240764 0.242655
53 29 1200 44.512398 0.659741 18.995534 9.448387 0.212327 6.642021 13.272935 1.46007 0.363085 0.107975 4.576778 870.169799 0.0 1463.515374 0.240544