anta-database 0.2.0__tar.gz → 0.2.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.
- {anta_database-0.2.0 → anta_database-0.2.1}/PKG-INFO +1 -1
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/plotting/plotting.py +5 -0
- anta_database-0.2.1/anta_database/plotting/site-coords.pkl +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database.egg-info/PKG-INFO +1 -1
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database.egg-info/SOURCES.txt +1 -0
- anta_database-0.2.1/book/figures/Overview_all.png +0 -0
- anta_database-0.2.1/book/quick_start.ipynb +400 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/pyproject.toml +1 -1
- anta_database-0.2.0/book/figures/Overview_all.png +0 -0
- anta_database-0.2.0/book/quick_start.ipynb +0 -559
- {anta_database-0.2.0 → anta_database-0.2.1}/.github/workflows/deploy.yml +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/.github/workflows/release.yml +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/.gitignore +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/LICENSE +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/README.md +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/__init__.py +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/anta_database.py +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/compiling/__init__.py +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/compiling/compile.py +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/database/__init__.py +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/database/database.py +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/figures/AntA_38ka.png +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/indexing/__init__.py +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/indexing/index_database.py +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/plotting/GL.pkl +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database/plotting/__init__.py +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database.egg-info/dependency_links.txt +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database.egg-info/requires.txt +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/anta_database.egg-info/top_level.txt +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/book/_config.yml +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/book/_toc.yml +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/book/advanced.md +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/book/contact.md +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/book/contribute.md +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/book/intro.md +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/book/logo.png +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/book/references.bib +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/book/requirements.txt +0 -0
- {anta_database-0.2.0 → anta_database-0.2.1}/setup.cfg +0 -0
|
@@ -15,6 +15,7 @@ class Plotting:
|
|
|
15
15
|
self._db = database_instance
|
|
16
16
|
module_dir = os.path.dirname(os.path.abspath(__file__))
|
|
17
17
|
self.gl = pd.read_pickle(os.path.join(module_dir, 'GL.pkl'))
|
|
18
|
+
self.site_coords = pd.read_pickle(os.path.join(module_dir, 'site-coords.pkl'))
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
def _pre_plot_check(self,
|
|
@@ -353,6 +354,10 @@ class Plotting:
|
|
|
353
354
|
|
|
354
355
|
plt.tight_layout()
|
|
355
356
|
|
|
357
|
+
# --- Plot ice core sites ---
|
|
358
|
+
for i in self.site_coords.index:
|
|
359
|
+
site = self.site_coords.loc[i]
|
|
360
|
+
ax.scatter(site['x']/1000, site['y']/1000, color='red', s=50, marker='^', edgecolor='black', linewidth=1.5)
|
|
356
361
|
# --- Save/Show ---
|
|
357
362
|
with self._plot_context():
|
|
358
363
|
if save:
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"id": "da20d131",
|
|
6
|
+
"metadata": {},
|
|
7
|
+
"source": [
|
|
8
|
+
"# Quick start\n",
|
|
9
|
+
"\n",
|
|
10
|
+
"## Installation\n",
|
|
11
|
+
"\n",
|
|
12
|
+
"The Python module can be directly installed from [PyPI](https://pypi.org/project/anta-database/) with:\n",
|
|
13
|
+
"\n",
|
|
14
|
+
" pip install anta_database"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"cell_type": "markdown",
|
|
19
|
+
"id": "126ab4cf",
|
|
20
|
+
"metadata": {
|
|
21
|
+
"lines_to_next_cell": 0
|
|
22
|
+
},
|
|
23
|
+
"source": [
|
|
24
|
+
"\n",
|
|
25
|
+
"This Python module is designed to query and visualized data in a AntADatabase folder. The latter has to be first compiled using published IRH datasets, or you can contact for downloading it.\n",
|
|
26
|
+
"You can already have a look at this guide to have an idea of the features of this tool. This Jupyter Notebook can be directly downloaded (top bar) and ran locally (assuming you had downloaded or compiled the AntADatabase folder).\n"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"cell_type": "markdown",
|
|
31
|
+
"id": "338b0e0d",
|
|
32
|
+
"metadata": {},
|
|
33
|
+
"source": [
|
|
34
|
+
"## Browsing the database\n",
|
|
35
|
+
"\n",
|
|
36
|
+
"First, initialize the Database class by providing the full path to the AntADatabase:"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"cell_type": "code",
|
|
41
|
+
"execution_count": null,
|
|
42
|
+
"id": "e8f554db",
|
|
43
|
+
"metadata": {},
|
|
44
|
+
"outputs": [],
|
|
45
|
+
"source": [
|
|
46
|
+
"from anta_database import Database\n",
|
|
47
|
+
"\n",
|
|
48
|
+
"db = Database('/home/anthe/documents/data/isochrones/AntADatabase/')"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"cell_type": "markdown",
|
|
53
|
+
"id": "dafead60",
|
|
54
|
+
"metadata": {},
|
|
55
|
+
"source": [
|
|
56
|
+
"Use the query() function to browse the database. 'query()' without argument will return all metadata contained in the database:"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"cell_type": "code",
|
|
61
|
+
"execution_count": null,
|
|
62
|
+
"id": "527d2e4e",
|
|
63
|
+
"metadata": {},
|
|
64
|
+
"outputs": [],
|
|
65
|
+
"source": [
|
|
66
|
+
"db.query()"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"cell_type": "markdown",
|
|
71
|
+
"id": "115fe971",
|
|
72
|
+
"metadata": {},
|
|
73
|
+
"source": [
|
|
74
|
+
"The query() function takes as argument:\n",
|
|
75
|
+
"- author: author(s) of the datasets of interest\n",
|
|
76
|
+
"- age: age(s) in yrs before present of the layer(s) of interest\n",
|
|
77
|
+
"- var: variables(s) other than age depth such as 'IceThk', 'SurfElev', 'BedElev' or 'BasalUnit'\n",
|
|
78
|
+
"- trace_id: ID of a particular trace. This is useful for explicit trace IDs such as 'DC_LDC_DIVIDE'\n",
|
|
79
|
+
"\n",
|
|
80
|
+
"One can also combine field queries as well as providing lists. Use '%' for searching by regular expressions. Here are a few examples:"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"cell_type": "code",
|
|
85
|
+
"execution_count": null,
|
|
86
|
+
"id": "781cf326",
|
|
87
|
+
"metadata": {},
|
|
88
|
+
"outputs": [],
|
|
89
|
+
"source": [
|
|
90
|
+
"#Examples of queries:\n",
|
|
91
|
+
"db.query(author='Cavitte_2020') # all data from Cavitte et al. 2020\n",
|
|
92
|
+
"db.query(age='38100') # all datasets with the 38.1ka isochrone\n",
|
|
93
|
+
"db.query(var='IceThk') # all datasets with IceThk variable\n",
|
|
94
|
+
"db.query(trace_id='DC_LDC_DIVIDE') # all layers with the trace ID DC_LDC_DIVIDE\n",
|
|
95
|
+
"db.query(trace_id='%WSB%') # all traces with WSB in the trace ID\n",
|
|
96
|
+
"db.query(author=['Franke_2025', 'Winter_2018'], age='38100') # example of multiple criteria"
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"cell_type": "markdown",
|
|
101
|
+
"id": "0df57fa9",
|
|
102
|
+
"metadata": {},
|
|
103
|
+
"source": [
|
|
104
|
+
"## Visualization\n",
|
|
105
|
+
"\n",
|
|
106
|
+
"Use the results of the query in the plotting functions:"
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"cell_type": "code",
|
|
111
|
+
"execution_count": null,
|
|
112
|
+
"id": "da7aa572",
|
|
113
|
+
"metadata": {},
|
|
114
|
+
"outputs": [],
|
|
115
|
+
"source": [
|
|
116
|
+
"results = db.query(age=['38100','38000'])\n",
|
|
117
|
+
"db.plot.author(results,\n",
|
|
118
|
+
" downscale_factor=100, # downscale the datasets n times, which makes no visual difference but it is much lighter\n",
|
|
119
|
+
" title='AntArchitecture 38(.1)ka layer',\n",
|
|
120
|
+
" xlim=(-500, 2400), ylim=(-2200, 2200), # set the plot extent in km\n",
|
|
121
|
+
" scale_factor=0.7, # adjust the size of the plot\n",
|
|
122
|
+
" latex=True, # use latex compilers for plotting if you have them installed on your system\n",
|
|
123
|
+
" # save='AntA_38ka.pdf', # Uncomment to save the figure, otherwise it we visualize with pyplot\n",
|
|
124
|
+
" )"
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"cell_type": "markdown",
|
|
129
|
+
"id": "ea04b98e",
|
|
130
|
+
"metadata": {},
|
|
131
|
+
"source": [
|
|
132
|
+
"Current implemented plotting functions are:\n",
|
|
133
|
+
"- plot.author(): plot locations of the data, with different colors for the different datasets (example above)\n",
|
|
134
|
+
"- plot.depth(): color-coded IRH depth scatter plot. One should provide a valid layer age.\n",
|
|
135
|
+
"- plot.var(): color-coded scatter plot for the additional variables. One should use it for plotting 'IceThk', 'SurfElev', 'BedElev', 'BasalUnit' or 'IRHDensity'\n",
|
|
136
|
+
"- plot.trace_id(): color-coded trace IDs. Useful for identifying specific traces of interest.\n",
|
|
137
|
+
"\n",
|
|
138
|
+
"In Jupyter Notebook, use '%matplotlib qt' or '%matplotlib widget' depending on your IDE, to switch to the matplotlib widget that allows you to zoom in etc.\n",
|
|
139
|
+
"Use '%matplotlib inline' (default) to plot the figure in the notebook"
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"cell_type": "code",
|
|
144
|
+
"execution_count": null,
|
|
145
|
+
"id": "4c05c516",
|
|
146
|
+
"metadata": {
|
|
147
|
+
"lines_to_next_cell": 2
|
|
148
|
+
},
|
|
149
|
+
"outputs": [],
|
|
150
|
+
"source": [
|
|
151
|
+
"# %matplotlib widget\n",
|
|
152
|
+
"%matplotlib inline\n",
|
|
153
|
+
"results = db.query(age=['38100','38000'])\n",
|
|
154
|
+
"db.plot.depth(results, title='AntArchitecture 38(.1)ka isochrone depth',\n",
|
|
155
|
+
" downscale_factor=100,\n",
|
|
156
|
+
" xlim=(-500, 2400),\n",
|
|
157
|
+
" ylim=(-2200, 2200),\n",
|
|
158
|
+
" scale_factor=0.7,\n",
|
|
159
|
+
" latex=True,\n",
|
|
160
|
+
" # save='AntA_38ka_depth.png'\n",
|
|
161
|
+
" )"
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"cell_type": "code",
|
|
166
|
+
"execution_count": null,
|
|
167
|
+
"id": "f04f2c8d",
|
|
168
|
+
"metadata": {},
|
|
169
|
+
"outputs": [],
|
|
170
|
+
"source": [
|
|
171
|
+
"results = db.query(var='IRHDensity')\n",
|
|
172
|
+
"db.plot.var(results, title='IRH Density over the Antarctic Ice Sheet',\n",
|
|
173
|
+
" downscale_factor=100,\n",
|
|
174
|
+
" scale_factor=1,\n",
|
|
175
|
+
" latex=True,\n",
|
|
176
|
+
" )"
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"cell_type": "code",
|
|
181
|
+
"execution_count": null,
|
|
182
|
+
"id": "c7430b95",
|
|
183
|
+
"metadata": {},
|
|
184
|
+
"outputs": [],
|
|
185
|
+
"source": [
|
|
186
|
+
"results = db.query(author='Winter%', var='IRHDensity', trace_id=['EPICA%'])\n",
|
|
187
|
+
"db.plot.trace_id(results, title='Winter et al. 2018 - EPICA',\n",
|
|
188
|
+
" xlim=(-500, 1000),\n",
|
|
189
|
+
" ylim=(1000, 2200),\n",
|
|
190
|
+
" latex=True,\n",
|
|
191
|
+
" )"
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"cell_type": "markdown",
|
|
196
|
+
"id": "49b0f0ae",
|
|
197
|
+
"metadata": {},
|
|
198
|
+
"source": [
|
|
199
|
+
"For an overview of the database, I suggest use plot.author() providing var='IRHDensity'. Indeed this variable is computed for each trace, giving the spatial span of the data: "
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"cell_type": "code",
|
|
204
|
+
"execution_count": null,
|
|
205
|
+
"id": "3ad14a9f",
|
|
206
|
+
"metadata": {},
|
|
207
|
+
"outputs": [],
|
|
208
|
+
"source": [
|
|
209
|
+
"results = db.query(var='IRHDensity')\n",
|
|
210
|
+
"db.plot.author(results, title='Overview of the AntADatabase',\n",
|
|
211
|
+
" downscale_factor=100,\n",
|
|
212
|
+
" latex=True,\n",
|
|
213
|
+
" # save='all_data.png'\n",
|
|
214
|
+
" )\n"
|
|
215
|
+
]
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"cell_type": "markdown",
|
|
219
|
+
"id": "a27f997d",
|
|
220
|
+
"metadata": {},
|
|
221
|
+
"source": [
|
|
222
|
+
"Other possible arguments for the plot methods:\n",
|
|
223
|
+
"- cmap: provide your colormap of choice (as LinearSegmentedColormap). Tip: 'import colormaps as cmaps' for a large choice of colormaps (see [Colormaps docs](https://pratiman-91.github.io/colormaps/)) \n",
|
|
224
|
+
"- marker_size: for setting larger or smaller markers on the scatter plots"
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"cell_type": "markdown",
|
|
229
|
+
"id": "2a08824b",
|
|
230
|
+
"metadata": {},
|
|
231
|
+
"source": [
|
|
232
|
+
"## Generate data from the database\n",
|
|
233
|
+
"\n",
|
|
234
|
+
"Note: This part could be developed further in the future if there is the need. But for now, I am designing a separate Python module for constraining my ice sheet model of use, which is tailored to this database and other parallel processing libraries.\n",
|
|
235
|
+
"\n",
|
|
236
|
+
"The data_generator() function reads the query and 'yield' the dataframes for later use.\n",
|
|
237
|
+
"Here is a quick example of how this can be used for computing the mean layer depth:"
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"cell_type": "code",
|
|
242
|
+
"execution_count": null,
|
|
243
|
+
"id": "313e2ba3",
|
|
244
|
+
"metadata": {},
|
|
245
|
+
"outputs": [],
|
|
246
|
+
"source": [
|
|
247
|
+
"results = db.query(age=['38100'])\n",
|
|
248
|
+
"lazy_dfs = db.data_generator()\n",
|
|
249
|
+
"\n",
|
|
250
|
+
"import numpy as np\n",
|
|
251
|
+
"mean_depth_trs = []\n",
|
|
252
|
+
"min_depth = float('inf')\n",
|
|
253
|
+
"max_depth = float('-inf')\n",
|
|
254
|
+
"for df, md in lazy_dfs:\n",
|
|
255
|
+
" depth_values = df['IRHDepth']\n",
|
|
256
|
+
" mean_depth_trs.append(np.mean(depth_values))\n",
|
|
257
|
+
" min_depth = min(min_depth, min(depth_values))\n",
|
|
258
|
+
" max_depth = max(max_depth, max(depth_values))\n",
|
|
259
|
+
"\n",
|
|
260
|
+
"\n",
|
|
261
|
+
"mean_depth = np.mean(mean_depth_trs)\n",
|
|
262
|
+
"std_dev = np.std(mean_depth_trs, ddof=1)\n",
|
|
263
|
+
"print(f\"The mean depth of the 38ka isochrone across East Antarctica is {round(mean_depth, 2)} m ranging from {round(min_depth, 2)} m to {round(max_depth, 2)} m.\")"
|
|
264
|
+
]
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"cell_type": "markdown",
|
|
268
|
+
"id": "ab55a799",
|
|
269
|
+
"metadata": {},
|
|
270
|
+
"source": [
|
|
271
|
+
"In the for loop, 'df' is an individual dataframe from the database, corresponding to a single layer of a single trace from a single dataset. The 'md' stores the unique metadata from the current 'df'. One can then associate the metadata with the current df, for example:"
|
|
272
|
+
]
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"cell_type": "code",
|
|
276
|
+
"execution_count": null,
|
|
277
|
+
"id": "190de359",
|
|
278
|
+
"metadata": {},
|
|
279
|
+
"outputs": [],
|
|
280
|
+
"source": [
|
|
281
|
+
"results = db.query(author='Cavitte_2020', trace_id='DC_LDC_DIVIDE')\n",
|
|
282
|
+
"lazy_dfs = db.data_generator(results)\n",
|
|
283
|
+
"\n",
|
|
284
|
+
"import matplotlib.pyplot as plt\n",
|
|
285
|
+
"# from matplotlib import rc\n",
|
|
286
|
+
"# rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})\n",
|
|
287
|
+
"# rc('text', usetex=True) # Do you use latex?\n",
|
|
288
|
+
"\n",
|
|
289
|
+
"for df, md in lazy_dfs:\n",
|
|
290
|
+
" if md['age'] is not None:\n",
|
|
291
|
+
" plt.plot(df.distance/1000, df['IRHDepth'], label=md['age'])\n",
|
|
292
|
+
" if md['var'] == 'IceThk':\n",
|
|
293
|
+
" plt.plot(df.distance/1000, df['IceThk'], linewidth=2, color='k', label='Bedrock')\n",
|
|
294
|
+
"\n",
|
|
295
|
+
"plt.legend(ncol=2)\n",
|
|
296
|
+
"plt.xlabel('Distance (km)')\n",
|
|
297
|
+
"plt.ylabel('Depth (m)')\n",
|
|
298
|
+
"plt.ylim(4000, 0)\n",
|
|
299
|
+
"plt.title('Isochronal structure along DC_LDC_DIVIDE transect')\n",
|
|
300
|
+
"plt.show()"
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"cell_type": "markdown",
|
|
305
|
+
"id": "f1b541cf",
|
|
306
|
+
"metadata": {},
|
|
307
|
+
"source": [
|
|
308
|
+
"### Downscale the data\n",
|
|
309
|
+
"\n",
|
|
310
|
+
"The downscale_factor argument in the data_generator reduces the size of the generated data by n times. This is useful when dealing with large data where the downscaling has a neglectable influence on the results.\n",
|
|
311
|
+
"Another solution, probably more straightforward, is the downsample_distance option, which allows to provide a distance in meters by which the data should be average along the transects:"
|
|
312
|
+
]
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"cell_type": "code",
|
|
316
|
+
"execution_count": null,
|
|
317
|
+
"id": "bed8b1c8",
|
|
318
|
+
"metadata": {},
|
|
319
|
+
"outputs": [],
|
|
320
|
+
"source": [
|
|
321
|
+
"import matplotlib.pyplot as plt\n",
|
|
322
|
+
"\n",
|
|
323
|
+
"results = db.query(author='Cavitte_2020', age='278000', trace_id='DC_LDC_DIVIDE')\n",
|
|
324
|
+
"original = db.data_generator(results)\n",
|
|
325
|
+
"downscale_10 = db.data_generator(results, downscale_factor=100)\n",
|
|
326
|
+
"downsampled_by_distance = db.data_generator(results, downsample_distance=5000)\n",
|
|
327
|
+
"\n",
|
|
328
|
+
"list = [original, downscale_10, downsampled_by_distance]\n",
|
|
329
|
+
"labels = ['original', 'downscale 100', 'downsample 5km']\n",
|
|
330
|
+
"\n",
|
|
331
|
+
"for i, lazy_dfs in enumerate(list):\n",
|
|
332
|
+
" for df, md in lazy_dfs:\n",
|
|
333
|
+
" plt.plot(df.distance, df['IRHDepth'],label=labels[i], linestyle='--')\n",
|
|
334
|
+
"\n",
|
|
335
|
+
"plt.ylim(3000, 0)\n",
|
|
336
|
+
"plt.xlabel('Distance along DC_LDC_DIVIDE (km)')\n",
|
|
337
|
+
"plt.ylabel('Depth (m)')\n",
|
|
338
|
+
"plt.legend()\n",
|
|
339
|
+
"plt.title('Different downscaling methods for Cavitte 2020 278ka along DC_LDC_DIVIDE')\n",
|
|
340
|
+
"plt.show()"
|
|
341
|
+
]
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"cell_type": "markdown",
|
|
345
|
+
"id": "90c918f0",
|
|
346
|
+
"metadata": {},
|
|
347
|
+
"source": [
|
|
348
|
+
"# Pro tips\n",
|
|
349
|
+
"\n",
|
|
350
|
+
"The Database methods always keep the last query in memory. This means that one does not have to actually pass argument.\n",
|
|
351
|
+
"Example:"
|
|
352
|
+
]
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"cell_type": "code",
|
|
356
|
+
"execution_count": null,
|
|
357
|
+
"id": "8fa78641",
|
|
358
|
+
"metadata": {},
|
|
359
|
+
"outputs": [],
|
|
360
|
+
"source": [
|
|
361
|
+
"db.query(var='IRHDensity')\n",
|
|
362
|
+
"# db.plot.var() # This is equivalent to the overview plot above. Note that without downscaling it is very heavy to plot.\n",
|
|
363
|
+
"\n",
|
|
364
|
+
"import numpy as np\n",
|
|
365
|
+
"mean_density_trs = []\n",
|
|
366
|
+
"min_density = float('inf')\n",
|
|
367
|
+
"max_density = float('-inf')\n",
|
|
368
|
+
"for df, md in db.data_generator(): # without explicitly passing results, it uses the last query.\n",
|
|
369
|
+
" density_values = df['IRHDensity']\n",
|
|
370
|
+
" mean_density_trs.append(np.mean(density_values))\n",
|
|
371
|
+
" min_density = min(min_density, min(density_values))\n",
|
|
372
|
+
" max_density = max(max_density, max(density_values))\n",
|
|
373
|
+
"\n",
|
|
374
|
+
"mean_density = np.mean(mean_density_trs)\n",
|
|
375
|
+
"print(f\"The average number of picked layers per data point in the AntADatabase is {int(mean_density)}, ranging from {int(min_density)} to {int(max_density)}. \")\n"
|
|
376
|
+
]
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
"metadata": {
|
|
380
|
+
"kernelspec": {
|
|
381
|
+
"display_name": "processing",
|
|
382
|
+
"language": "python",
|
|
383
|
+
"name": "python3"
|
|
384
|
+
},
|
|
385
|
+
"language_info": {
|
|
386
|
+
"codemirror_mode": {
|
|
387
|
+
"name": "ipython",
|
|
388
|
+
"version": 3
|
|
389
|
+
},
|
|
390
|
+
"file_extension": ".py",
|
|
391
|
+
"mimetype": "text/x-python",
|
|
392
|
+
"name": "python",
|
|
393
|
+
"nbconvert_exporter": "python",
|
|
394
|
+
"pygments_lexer": "ipython3",
|
|
395
|
+
"version": "3.13.2"
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
"nbformat": 4,
|
|
399
|
+
"nbformat_minor": 5
|
|
400
|
+
}
|
|
Binary file
|