Skip to content

Commit b21d693

Browse files
committed
docs
1 parent e642ff3 commit b21d693

File tree

93 files changed

+3822
-691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3822
-691
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"\n# Magnetic Survey\n\nThese magnetic data channels were pulled from the Wisconsin Skytem example in this repository\n\nDataset Reference:\nMinsley, B.J, Bloss, B.R., Hart, D.J., Fitzpatrick, W., Muldoon, M.A., Stewart, E.K., Hunt, R.J., James, S.R., Foks, N.L., and Komiskey, M.J., 2022, Airborne electromagnetic and magnetic survey data, northeast Wisconsin (ver. 1.1, June 2022): U.S. Geological Survey data release, https://doi.org/10.5066/P93SY9LI.\n"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {
14+
"collapsed": false
15+
},
16+
"outputs": [],
17+
"source": [
18+
"import matplotlib.pyplot as plt\nfrom os.path import join\nimport numpy as np\nimport gspy\nfrom gspy import Survey\nimport xarray as xr\nfrom pprint import pprint"
19+
]
20+
},
21+
{
22+
"cell_type": "markdown",
23+
"metadata": {},
24+
"source": [
25+
"## Convert the magnetic csv data to NetCDF\n\n"
26+
]
27+
},
28+
{
29+
"cell_type": "markdown",
30+
"metadata": {},
31+
"source": [
32+
"Initialize the Survey\n\n"
33+
]
34+
},
35+
{
36+
"cell_type": "code",
37+
"execution_count": null,
38+
"metadata": {
39+
"collapsed": false
40+
},
41+
"outputs": [],
42+
"source": [
43+
"# Path to example files\ndata_path = '..//..//..//..//example_material//mag_example'\n\n# Survey metadata file\nmetadata = join(data_path, \"WI_Magnetics_survey_md.yml\")\n\n# Establish the Survey\nsurvey = Survey.from_dict(metadata)\n\ndata_container = survey.gs.add_container('data', **dict(content = \"raw and gridded data\",\n comment = \"This is a test\"))"
44+
]
45+
},
46+
{
47+
"cell_type": "markdown",
48+
"metadata": {},
49+
"source": [
50+
"1 - Raw Data -\nImport raw mag data from CSV-format.\nDefine input data file and associated metadata file\n\n"
51+
]
52+
},
53+
{
54+
"cell_type": "code",
55+
"execution_count": null,
56+
"metadata": {
57+
"collapsed": false
58+
},
59+
"outputs": [],
60+
"source": [
61+
"d_data1 = join(data_path, 'WI_Magnetics.csv')\nd_supp1 = join(data_path, 'WI_Magnetics_raw_data_md.yml')\n\n# Add the raw AEM data as a tabular dataset\ndata_container.gs.add(key='raw_data', data_filename=d_data1, metadata_file=d_supp1)"
62+
]
63+
},
64+
{
65+
"cell_type": "markdown",
66+
"metadata": {},
67+
"source": [
68+
"1 - Gridded Data -\nImport a tif of gridded mag data.\n\n"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": null,
74+
"metadata": {
75+
"collapsed": false
76+
},
77+
"outputs": [],
78+
"source": [
79+
"d_supp1 = join(data_path, 'WI_Magnetics_grids_md.yml')\n\n# Add the raw AEM data as a tabular dataset\ndata_container.gs.add(key='grids', metadata_file=d_supp1)"
80+
]
81+
},
82+
{
83+
"cell_type": "markdown",
84+
"metadata": {},
85+
"source": [
86+
"Save to NetCDF file\n\n"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": null,
92+
"metadata": {
93+
"collapsed": false
94+
},
95+
"outputs": [],
96+
"source": [
97+
"d_out = join(data_path, 'WI_Magnetics.nc')\nsurvey.gs.to_netcdf(d_out)"
98+
]
99+
},
100+
{
101+
"cell_type": "markdown",
102+
"metadata": {},
103+
"source": [
104+
"Reading back in\n\n"
105+
]
106+
},
107+
{
108+
"cell_type": "code",
109+
"execution_count": null,
110+
"metadata": {
111+
"collapsed": false
112+
},
113+
"outputs": [],
114+
"source": [
115+
"new_survey = gspy.open_datatree(d_out)['survey']\n\nprint(new_survey)"
116+
]
117+
},
118+
{
119+
"cell_type": "markdown",
120+
"metadata": {},
121+
"source": [
122+
"Plotting\n\n"
123+
]
124+
},
125+
{
126+
"cell_type": "code",
127+
"execution_count": null,
128+
"metadata": {
129+
"collapsed": false
130+
},
131+
"outputs": [],
132+
"source": [
133+
"plt.figure()\nnew_survey['data/raw_data']['height'].plot()\nplt.tight_layout()\n\npd = new_survey['data/raw_data']['tmi']\nplt.figure()\npd.plot()\nplt.tight_layout()\n\nm = new_survey['data/grids/magnetic_tmi']\nplt.figure()\nm.plot(cmap='jet')\nplt.tight_layout()\n\nplt.show()"
134+
]
135+
}
136+
],
137+
"metadata": {
138+
"kernelspec": {
139+
"display_name": "Python 3",
140+
"language": "python",
141+
"name": "python3"
142+
},
143+
"language_info": {
144+
"codemirror_mode": {
145+
"name": "ipython",
146+
"version": 3
147+
},
148+
"file_extension": ".py",
149+
"mimetype": "text/x-python",
150+
"name": "python",
151+
"nbconvert_exporter": "python",
152+
"pygments_lexer": "ipython3",
153+
"version": "3.12.11"
154+
}
155+
},
156+
"nbformat": 4,
157+
"nbformat_minor": 0
158+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
"""
2+
Magnetic Survey
3+
---------------
4+
5+
These magnetic data channels were pulled from the Wisconsin Skytem example in this repository
6+
7+
Dataset Reference:
8+
Minsley, B.J, Bloss, B.R., Hart, D.J., Fitzpatrick, W., Muldoon, M.A., Stewart, E.K., Hunt, R.J., James, S.R., Foks, N.L., and Komiskey, M.J., 2022, Airborne electromagnetic and magnetic survey data, northeast Wisconsin (ver. 1.1, June 2022): U.S. Geological Survey data release, https://doi.org/10.5066/P93SY9LI.
9+
"""
10+
#%%
11+
import matplotlib.pyplot as plt
12+
from os.path import join
13+
import numpy as np
14+
import gspy
15+
from gspy import Survey
16+
import xarray as xr
17+
from pprint import pprint
18+
19+
20+
#%%
21+
# Convert the magnetic csv data to NetCDF
22+
# +++++++++++++++++++++++++++++++++++++++
23+
24+
#%%
25+
# Initialize the Survey
26+
27+
# Path to example files
28+
data_path = '..//..//..//..//example_material//mag_example'
29+
30+
# Survey metadata file
31+
metadata = join(data_path, "WI_Magnetics_survey_md.yml")
32+
33+
# Establish the Survey
34+
survey = Survey.from_dict(metadata)
35+
36+
data_container = survey.gs.add_container('data', **dict(content = "raw and gridded data",
37+
comment = "This is a test"))
38+
39+
#%%
40+
# 1 - Raw Data -
41+
# Import raw mag data from CSV-format.
42+
# Define input data file and associated metadata file
43+
d_data1 = join(data_path, 'WI_Magnetics.csv')
44+
d_supp1 = join(data_path, 'WI_Magnetics_raw_data_md.yml')
45+
46+
# Add the raw AEM data as a tabular dataset
47+
data_container.gs.add(key='raw_data', data_filename=d_data1, metadata_file=d_supp1)
48+
49+
#%%
50+
# 1 - Gridded Data -
51+
# Import a tif of gridded mag data.
52+
d_supp1 = join(data_path, 'WI_Magnetics_grids_md.yml')
53+
54+
# Add the raw AEM data as a tabular dataset
55+
data_container.gs.add(key='grids', metadata_file=d_supp1)
56+
57+
#%%
58+
# Save to NetCDF file
59+
d_out = join(data_path, 'WI_Magnetics.nc')
60+
survey.gs.to_netcdf(d_out)
61+
62+
#%%
63+
# Reading back in
64+
new_survey = gspy.open_datatree(d_out)['survey']
65+
66+
print(new_survey)
67+
68+
#%%
69+
# Plotting
70+
plt.figure()
71+
new_survey['data/raw_data']['height'].plot()
72+
plt.tight_layout()
73+
74+
pd = new_survey['data/raw_data']['tmi']
75+
plt.figure()
76+
pd.plot()
77+
plt.tight_layout()
78+
79+
m = new_survey['data/grids/magnetic_tmi']
80+
plt.figure()
81+
m.plot(cmap='jet')
82+
plt.tight_layout()
83+
84+
plt.show()
85+
86+
87+
Binary file not shown.

0 commit comments

Comments
 (0)