pyIntersecT 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ /dist
2
+ *egg-info
3
+ .vscode
@@ -0,0 +1,263 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "3512ffb9",
6
+ "metadata": {},
7
+ "source": [
8
+ "![IntersecT logo](src/IntersecT/Logo-IntersecT.png)\n",
9
+ "\n",
10
+ "\n",
11
+ "# **IntersecT** \n",
12
+ "# Qcmp from Perple_X models\n",
13
+ "---\n",
14
+ "\n",
15
+ "## Introduction\n",
16
+ "Phase diagrams calculated using forward thermodynamic modelling allow users to determine the pressure (*P*) and temperature (*T*) conditions of mineral assemblage formation for a given bulk composition (*X*). In the last decade, several software solutions have provided quantitative approaches where optimal *P–T* conditions can be calculated from a statistical point of view, resulting in a more accurate interpretation of forward model results (e.g., the quality factor implemented in Bingo-Antidote; Duesterhoeft & Lanari, 2020, https://doi.org/10.1111/jmg.12538).\n",
17
+ "\n",
18
+ "Here the quality factor of the composition (hereby **Qcmp**) as described in Duesterhoeft & Lanari (2020) is applied to the Perple_X results, particularly from the WERAMI output. The Qcmp allows the propagation of uncertainties in the measured mineral composition. In addition, IntersecT applies a reduced chi-squared statistics to assess the weight of the considered phases. This allows for the down-weighting of outlier data, whether due to model problems or incorrect assumptions, including disequilibrium features.\n",
19
+ "\n",
20
+ "##### **Requirements**\n",
21
+ "- python\n",
22
+ "- matplotlib\n",
23
+ "- pandas\n",
24
+ "- tkinter\n",
25
+ "- **IntersecT**\n",
26
+ "\n",
27
+ "## Install and import the required libraries"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": null,
33
+ "id": "1c60b3c3-92b4-4fb1-820d-73faab836c59",
34
+ "metadata": {},
35
+ "outputs": [],
36
+ "source": [
37
+ "# install the required packages in a local environment\n",
38
+ "%pip install pyIntersecT"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "code",
43
+ "execution_count": null,
44
+ "id": "de99adbe",
45
+ "metadata": {},
46
+ "outputs": [],
47
+ "source": [
48
+ "# import IntersecT\n",
49
+ "from pyIntersecT import IntersecT\n",
50
+ "\n",
51
+ "# create a Quality Factor Analysis object\n",
52
+ "InT = IntersecT.QualityFactorAnalysis()"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "markdown",
57
+ "id": "8d4a90d6",
58
+ "metadata": {},
59
+ "source": [
60
+ "## Input files\n",
61
+ "Select your **WERAMI output .tab file**, where you extracted the compositions of your phases supposed to be at equilibrium.\n",
62
+ "\n",
63
+ "N.B. Because it's required to propagate the uncertainty of the measured composition, the extracted composition should be in **a.p.f.u.**"
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "code",
68
+ "execution_count": null,
69
+ "id": "4eceaede",
70
+ "metadata": {},
71
+ "outputs": [],
72
+ "source": [
73
+ "# import the output file from Perple_X\n",
74
+ "InT.import_output_perplex()"
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "markdown",
79
+ "id": "5f319e23",
80
+ "metadata": {},
81
+ "source": [
82
+ "Select a second **.txt** input file with the **a.p.f.u. measured compositions** that match the WERAMI .tab file, the **name** of the considered phases in your rock and the **color scheme** you wish to apply."
83
+ ]
84
+ },
85
+ {
86
+ "cell_type": "code",
87
+ "execution_count": null,
88
+ "id": "dc98d349-0dfb-4b58-a0f6-27237ca9b665",
89
+ "metadata": {},
90
+ "outputs": [],
91
+ "source": [
92
+ "# import the measured compositions\n",
93
+ "InT.import_analytical_compo()"
94
+ ]
95
+ },
96
+ {
97
+ "cell_type": "markdown",
98
+ "id": "3157594d",
99
+ "metadata": {},
100
+ "source": [
101
+ "## Output directory\n",
102
+ "Select a directory where to store the output."
103
+ ]
104
+ },
105
+ {
106
+ "cell_type": "code",
107
+ "execution_count": null,
108
+ "id": "219739c9",
109
+ "metadata": {},
110
+ "outputs": [],
111
+ "source": [
112
+ "# set the output directory\n",
113
+ "InT.set_output_directory()"
114
+ ]
115
+ },
116
+ {
117
+ "cell_type": "markdown",
118
+ "id": "a0b1fc0e",
119
+ "metadata": {},
120
+ "source": [
121
+ "## Qcmp calculation\n",
122
+ "This part of the code **calculates the Qcmp**\n",
123
+ "\n",
124
+ "It then integrates the **reduced chi-squared** statistic to calculate a **weighted Qcmp** based on the best reduced chi-squared value for each phase."
125
+ ]
126
+ },
127
+ {
128
+ "cell_type": "markdown",
129
+ "id": "69031ecf",
130
+ "metadata": {},
131
+ "source": [
132
+ "This first part calculates the Qcmp for each **element** extracted from the WERAMI output"
133
+ ]
134
+ },
135
+ {
136
+ "cell_type": "code",
137
+ "execution_count": null,
138
+ "id": "a97a04b1",
139
+ "metadata": {},
140
+ "outputs": [],
141
+ "source": [
142
+ "# calculate the quality factor for each element\n",
143
+ "InT.Qcmp_elem()"
144
+ ]
145
+ },
146
+ {
147
+ "cell_type": "markdown",
148
+ "id": "11e10ec8",
149
+ "metadata": {},
150
+ "source": [
151
+ "This part calculates the Qcmp for each **phase** (combining all elements)"
152
+ ]
153
+ },
154
+ {
155
+ "cell_type": "code",
156
+ "execution_count": null,
157
+ "id": "23e9f2c6",
158
+ "metadata": {},
159
+ "outputs": [],
160
+ "source": [
161
+ "# calculate the quality factor for each phase\n",
162
+ "Qcmp_phase_tot = InT.Qcmp_phase()"
163
+ ]
164
+ },
165
+ {
166
+ "cell_type": "markdown",
167
+ "id": "85aa1949",
168
+ "metadata": {},
169
+ "source": [
170
+ "This calculates the **reduced chi-squared** for each **phase**"
171
+ ]
172
+ },
173
+ {
174
+ "cell_type": "code",
175
+ "execution_count": null,
176
+ "id": "74ebb1bd",
177
+ "metadata": {},
178
+ "outputs": [],
179
+ "source": [
180
+ "# calculate the reduced chi-squared statistic for each phase\n",
181
+ "redchi2_phase = InT.redchi2_phase()"
182
+ ]
183
+ },
184
+ {
185
+ "cell_type": "markdown",
186
+ "id": "f28fb481",
187
+ "metadata": {},
188
+ "source": [
189
+ "This calculates the **reduced chi-squared** for the **overall dataset**"
190
+ ]
191
+ },
192
+ {
193
+ "cell_type": "code",
194
+ "execution_count": null,
195
+ "id": "19aad46a",
196
+ "metadata": {},
197
+ "outputs": [],
198
+ "source": [
199
+ "# calculate the reduced chi-squared statistic for the overall dataset\n",
200
+ "redchi2_allphases = InT.redchi2_tot()"
201
+ ]
202
+ },
203
+ {
204
+ "cell_type": "markdown",
205
+ "id": "dd91529c",
206
+ "metadata": {},
207
+ "source": [
208
+ "This part calculates an **unweighted** Qcmp for the **overall dataset** (combining all phases)"
209
+ ]
210
+ },
211
+ {
212
+ "cell_type": "code",
213
+ "execution_count": null,
214
+ "id": "996671bc",
215
+ "metadata": {},
216
+ "outputs": [],
217
+ "source": [
218
+ "# calculate the unweighted quality factor for the overall dataset\n",
219
+ "Qcmp_allphases = InT.Qcmp_tot(Qcmp_phase_tot, redchi2_phase)"
220
+ ]
221
+ },
222
+ {
223
+ "cell_type": "markdown",
224
+ "id": "4e783a79",
225
+ "metadata": {},
226
+ "source": [
227
+ "Integrating the reduced chi-squared statistic, this calculates a **weighted Qcmp** for the **overall dataset**"
228
+ ]
229
+ },
230
+ {
231
+ "cell_type": "code",
232
+ "execution_count": null,
233
+ "id": "5197cdff",
234
+ "metadata": {},
235
+ "outputs": [],
236
+ "source": [
237
+ "# calculate the weighted quality factor for the overall dataset\n",
238
+ "Qcmp_allphases_weight = InT.Qcmp_tot_weight(Qcmp_phase_tot, redchi2_phase)"
239
+ ]
240
+ }
241
+ ],
242
+ "metadata": {
243
+ "kernelspec": {
244
+ "display_name": "Python 3",
245
+ "language": "python",
246
+ "name": "python3"
247
+ },
248
+ "language_info": {
249
+ "codemirror_mode": {
250
+ "name": "ipython",
251
+ "version": 3
252
+ },
253
+ "file_extension": ".py",
254
+ "mimetype": "text/x-python",
255
+ "name": "python",
256
+ "nbconvert_exporter": "python",
257
+ "pygments_lexer": "ipython3",
258
+ "version": "3.12.1"
259
+ }
260
+ },
261
+ "nbformat": 4,
262
+ "nbformat_minor": 5
263
+ }