.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/Creating_GS_Files/plot_csv_magnetics.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_Creating_GS_Files_plot_csv_magnetics.py: Magnetic Survey --------------- These magnetic data channels were pulled from the Wisconsin Skytem example in this repository Dataset Reference: 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. .. GENERATED FROM PYTHON SOURCE LINES 11-20 .. code-block:: Python import matplotlib.pyplot as plt from os.path import join import numpy as np import gspy from gspy import Survey import xarray as xr from pprint import pprint .. GENERATED FROM PYTHON SOURCE LINES 21-23 Convert the magnetic csv data to NetCDF +++++++++++++++++++++++++++++++++++++++ .. GENERATED FROM PYTHON SOURCE LINES 25-26 Initialize the Survey .. GENERATED FROM PYTHON SOURCE LINES 26-39 .. code-block:: Python # Path to example files data_path = '..//..//..//..//example_material//mag_example' # Survey metadata file metadata = join(data_path, "WI_Magnetics_survey_md.yml") # Establish the Survey survey = Survey.from_dict(metadata) data_container = survey.gs.add_container('data', **dict(content = "raw and gridded data", comment = "This is a test")) .. GENERATED FROM PYTHON SOURCE LINES 40-43 1 - Raw Data - Import raw mag data from CSV-format. Define input data file and associated metadata file .. GENERATED FROM PYTHON SOURCE LINES 43-49 .. code-block:: Python d_data1 = join(data_path, 'WI_Magnetics.csv') d_supp1 = join(data_path, 'WI_Magnetics_raw_data_md.yml') # Add the raw AEM data as a tabular dataset data_container.gs.add(key='raw_data', data_filename=d_data1, metadata_file=d_supp1) .. raw:: html
<xarray.DataTree 'raw_data'>
    Group: /survey/data/raw_data
    │   Dimensions:      (index: 6785)
    │   Coordinates:
    │     * index        (index) int32 27kB 0 1 2 3 4 5 ... 6780 6781 6782 6783 6784
    │       spatial_ref  float64 8B 0.0
    │       x            (index) float64 54kB 7.243e+05 7.239e+05 ... 6.604e+05
    │       y            (index) float64 54kB 4.916e+05 4.917e+05 ... 3.866e+05
    │       z            (index) float64 54kB 176.8 217.3 231.6 ... 273.2 276.4 288.7
    │   Data variables: (12/20)
    │       fid          (index) float64 54kB 2.349e+05 2.349e+05 ... 1.868e+06
    │       line         (index) int64 54kB 100101 100101 100101 ... 115201 115201
    │       e_nad83      (index) float64 54kB 7.243e+05 7.239e+05 ... 6.604e+05
    │       n_nad83      (index) float64 54kB 4.916e+05 4.917e+05 ... 3.866e+05
    │       lon          (index) float64 54kB -87.41 -87.42 -87.42 ... -88.25 -88.25
    │       lat          (index) float64 54kB 44.87 44.87 44.87 ... 43.94 43.94 43.94
    │       ...           ...
    │       mag_raw      (index) float64 54kB 5.481e+04 5.481e+04 ... 5.413e+04
    │       tmi          (index) float64 54kB 5.482e+04 5.482e+04 ... 5.413e+04
    │       rmf          (index) float64 54kB 210.6 210.6 197.3 ... -122.7 -124.5 -120.3
    │       igrf         (index) float64 54kB 5.461e+04 5.461e+04 ... 5.425e+04
    │       inc          (index) float64 54kB 71.13 71.13 71.13 ... 70.48 70.48 70.48
    │       dec          (index) float64 54kB -4.796 -4.792 -4.787 ... -3.975 -3.972
    │   Attributes:
    │       content:     raw data
    │       comment:     Contains mag data
    │       type:        data
    │       structure:   tabular
    │       mode:        airborne
    │       method:      magnetic
    │       submethod:   total field
    │       instrument:  cesium vapour
    │       property:    magnetic susceptibility
    └── Group: /survey/data/raw_data/magnetic_system
            Dimensions:      (dim_0: 1)
            Dimensions without coordinates: dim_0
            Data variables:
                sample_rate  (dim_0) float64 8B 0.1
                resolution   (dim_0) float64 8B 0.002
            Attributes:
                type:        system
                mode:        airborne
                method:      magnetic
                submethod:   total field
                instrument:  cesium vapour
                name:        magnetic_system


.. GENERATED FROM PYTHON SOURCE LINES 50-52 1 - Gridded Data - Import a tif of gridded mag data. .. GENERATED FROM PYTHON SOURCE LINES 52-57 .. code-block:: Python d_supp1 = join(data_path, 'WI_Magnetics_grids_md.yml') # Add the raw AEM data as a tabular dataset data_container.gs.add(key='grids', metadata_file=d_supp1) .. raw:: html
<xarray.DataTree 'grids'>
    Group: /survey/data/grids
        Dimensions:       (x: 799, nv: 2, y: 1155)
        Coordinates:
          * x             (x) float64 6kB 6.551e+05 6.552e+05 ... 7.348e+05 7.349e+05
          * nv            (nv) int64 16B 0 1
          * y             (y) float64 9kB 4.953e+05 4.952e+05 ... 3.8e+05 3.799e+05
            spatial_ref   float64 8B 0.0
        Data variables:
            x_bnds        (x, nv) float64 13kB 6.55e+05 6.551e+05 ... 7.349e+05
            y_bnds        (y, nv) float64 18kB 4.954e+05 4.953e+05 ... 3.8e+05 3.799e+05
            magnetic_tmi  (y, x) float64 7MB nan nan nan nan nan ... nan nan nan nan nan
            magnetic_rmf  (y, x) float64 7MB nan nan nan nan nan ... nan nan nan nan nan
        Attributes:
            content:     gridded magnetic maps
            comment:     This dataset includes AEM-derived estimates of the elevation...
            type:        data
            structure:   raster
            mode:        airborne
            method:      magnetic
            submethod:   total field
            instrument:  cesium vapour
            property:    magnetic


.. GENERATED FROM PYTHON SOURCE LINES 58-59 Save to NetCDF file .. GENERATED FROM PYTHON SOURCE LINES 59-62 .. code-block:: Python d_out = join(data_path, 'WI_Magnetics.nc') survey.gs.to_netcdf(d_out) .. GENERATED FROM PYTHON SOURCE LINES 63-64 Reading back in .. GENERATED FROM PYTHON SOURCE LINES 64-68 .. code-block:: Python new_survey = gspy.open_datatree(d_out)['survey'] print(new_survey) .. rst-class:: sphx-glr-script-out .. code-block:: none Group: /survey │ Dimensions: () │ Coordinates: │ spatial_ref float64 8B ... │ Data variables: │ survey_information float64 8B ... │ flightline_information float64 8B ... │ survey_equipment float64 8B ... │ Attributes: │ title: Magnetic data from SkyTEM Airborne Electromagnetic (AEM) Su... │ institution: USGS Geology, Geophysics, and Geochemistry Science Center │ source: SkyTEM raw data, USGS processed data │ history: (1) Data acquisition 01/2021 - 02/2021 by SkyTEM Canada Inc... │ references: Minsley, Burke J., B.R. Bloss, D.J. Hart, W. Fitzpatrick, M... │ comment: This dataset includes minimally processed (raw) AEM and raw... │ summary: Magnetic survey data were collected during January and Febr... │ content: Data │ created_by: gspy==2.0.0 │ conventions: CF-1.8, GS-2.0 │ type: survey └── Group: /survey/data │ Dimensions: () │ Data variables: │ spatial_ref float64 8B ... │ Attributes: │ content: raw and gridded data │ comment: This is a test │ type: container ├── Group: /survey/data/raw_data │ │ Dimensions: (index: 6785) │ │ Coordinates: │ │ * index (index) int32 27kB 0 1 2 3 4 5 ... 6780 6781 6782 6783 6784 │ │ spatial_ref float64 8B ... │ │ x (index) float64 54kB ... │ │ y (index) float64 54kB ... │ │ z (index) float64 54kB ... │ │ Data variables: (12/20) │ │ fid (index) float64 54kB ... │ │ line (index) int64 54kB ... │ │ e_nad83 (index) float64 54kB ... │ │ n_nad83 (index) float64 54kB ... │ │ lon (index) float64 54kB ... │ │ lat (index) float64 54kB ... │ │ ... ... │ │ mag_raw (index) float64 54kB ... │ │ tmi (index) float64 54kB ... │ │ rmf (index) float64 54kB ... │ │ igrf (index) float64 54kB ... │ │ inc (index) float64 54kB ... │ │ dec (index) float64 54kB ... │ │ Attributes: │ │ content: raw data │ │ comment: Contains mag data │ │ type: data │ │ structure: tabular │ │ mode: airborne │ │ method: magnetic │ │ submethod: total field │ │ instrument: cesium vapour │ │ property: magnetic susceptibility │ └── Group: /survey/data/raw_data/magnetic_system │ Dimensions: (dim_0: 1) │ Dimensions without coordinates: dim_0 │ Data variables: │ sample_rate (dim_0) float64 8B ... │ resolution (dim_0) float64 8B ... │ Attributes: │ type: system │ mode: airborne │ method: magnetic │ submethod: total field │ instrument: cesium vapour │ name: magnetic_system └── Group: /survey/data/grids Dimensions: (x: 799, nv: 2, y: 1155) Coordinates: * x (x) float64 6kB 6.551e+05 6.552e+05 ... 7.348e+05 7.349e+05 * nv (nv) int64 16B 0 1 * y (y) float64 9kB 4.953e+05 4.952e+05 ... 3.8e+05 3.799e+05 spatial_ref float64 8B ... Data variables: x_bnds (x, nv) float64 13kB ... y_bnds (y, nv) float64 18kB ... magnetic_tmi (y, x) float64 7MB ... magnetic_rmf (y, x) float64 7MB ... Attributes: content: gridded magnetic maps comment: This dataset includes AEM-derived estimates of the elevation... type: data structure: raster mode: airborne method: magnetic submethod: total field instrument: cesium vapour property: magnetic .. GENERATED FROM PYTHON SOURCE LINES 69-70 Plotting .. GENERATED FROM PYTHON SOURCE LINES 70-88 .. code-block:: Python plt.figure() new_survey['data/raw_data']['height'].plot() plt.tight_layout() pd = new_survey['data/raw_data']['tmi'] plt.figure() pd.plot() plt.tight_layout() m = new_survey['data/grids/magnetic_tmi'] plt.figure() m.plot(cmap='jet') plt.tight_layout() plt.show() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/Creating_GS_Files/images/sphx_glr_plot_csv_magnetics_001.png :alt: spatial_ref = 0.0 :srcset: /examples/Creating_GS_Files/images/sphx_glr_plot_csv_magnetics_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/Creating_GS_Files/images/sphx_glr_plot_csv_magnetics_002.png :alt: spatial_ref = 0.0 :srcset: /examples/Creating_GS_Files/images/sphx_glr_plot_csv_magnetics_002.png :class: sphx-glr-multi-img * .. image-sg:: /examples/Creating_GS_Files/images/sphx_glr_plot_csv_magnetics_003.png :alt: spatial_ref = 0.0 :srcset: /examples/Creating_GS_Files/images/sphx_glr_plot_csv_magnetics_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.409 seconds) .. _sphx_glr_download_examples_Creating_GS_Files_plot_csv_magnetics.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_csv_magnetics.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_csv_magnetics.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_csv_magnetics.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_