.. 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_skytem.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_skytem.py: Multi-dataset Survey -------------------- This example demonstrates the typical workflow for creating a GS file for an AEM survey in its entirety, i.e., the NetCDF file contains all related datasets together, e.g., raw data, processed data, inverted models, and derivative products. Specifically, this survey contains: 1. Minimally processed (raw) AEM data and raw/processed magnetic data provided by SkyTEM 2. Fully processed AEM data used as input to inversion 3. Laterally constrained inverted resistivity models 4. Point-data estimates of bedrock depth derived from the AEM models 5. Interpolated magnetic and bedrock depth grids Note: To make the size of this example more managable, some of the input datasets have been downsampled relative to the source files in the data release referenced below. 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 20-29 .. 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 30-32 Convert the Skytem csv data to NetCDF +++++++++++++++++++++++++++++++++++++ .. GENERATED FROM PYTHON SOURCE LINES 34-35 Initialize the Survey .. GENERATED FROM PYTHON SOURCE LINES 35-48 .. code-block:: Python # Path to example files data_path = '..//..//..//..//example_material//example_1' # Survey metadata file metadata = join(data_path, "data//WI_SkyTEM_survey_md.yml") # Establish the Survey survey = Survey.from_dict(metadata) data_container = survey.gs.add_container('data', **dict(content = "raw and processed data", comment = "This is a test")) .. GENERATED FROM PYTHON SOURCE LINES 49-52 1 - Raw Data - Import raw AEM data from CSV-format. Define input data file and associated metadata file .. GENERATED FROM PYTHON SOURCE LINES 52-58 .. code-block:: Python d_data1 = join(data_path, 'data//WI_SkyTEM_2021_ContractorData.csv') d_supp1 = join(data_path, 'data//WI_SkyTEM_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, system=survey.nominal_system) .. raw:: html
<xarray.DataTree 'raw_data'>
    Group: /survey/data/raw_data
    │   Dimensions:          (index: 6785, hm_gate_times: 32, lm_gate_times: 28)
    │   Coordinates:
    │     * index            (index) int32 27kB 0 1 2 3 4 5 ... 6780 6781 6782 6783 6784
    │     * hm_gate_times    (hm_gate_times) float64 256B 2.886e-05 ... 0.003544
    │     * lm_gate_times    (lm_gate_times) float64 224B -1.135e-06 ... 0.001394
    │       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 ... 276.4 288.7
    │       t                (index) float64 54kB 4.422e+04 4.422e+04 ... 4.424e+04
    │   Data variables: (12/34)
    │       _60hz_intensity  (index) float64 54kB -5.744e-08 -4.722e-08 ... -1.557e-07
    │       alt              (index) float64 54kB 276.3 270.1 274.2 ... 320.0 331.7
    │       anglex           (index) float64 54kB 3.284 1.052 2.916 ... -4.419 -4.376
    │       angley           (index) float64 54kB -0.9891 -1.999 ... -1.013 -1.103
    │       base_mag         (index) float64 54kB -1e+04 -1e+04 -1e+04 ... -1e+04 -1e+04
    │       curr_hm          (index) float64 54kB 111.6 111.6 111.5 ... 110.4 110.4
    │       ...               ...
    │       mag_raw          (index) float64 54kB 5.481e+04 5.481e+04 ... 5.413e+04
    │       n_nad83          (index) float64 54kB 4.916e+05 4.917e+05 ... 3.866e+05
    │       n_wgs84          (index) float64 54kB 4.968e+06 4.969e+06 ... 4.866e+06
    │       rmf              (index) float64 54kB 210.6 210.6 197.3 ... -124.5 -120.3
    │       time             (index) object 54kB '17:14:42' '17:15:02' ... '15:01:14'
    │       tmi              (index) float64 54kB 5.482e+04 5.482e+04 ... 5.413e+04
    │   Attributes:
    │       content:     raw data
    │       comment:     This dataset includes minimally processed (raw) AEM and raw/...
    │       type:        data
    │       structure:   tabular
    │       mode:        airborne
    │       method:      electromagnetic
    │       submethod:   time domain
    │       instrument:  skytem
    │       property:    
    └── Group: /survey/data/raw_data/nominal_system
            Dimensions:                                      (gate_times: 22, nv: 2,
                                                              lm_gate_times: 28,
                                                              hm_gate_times: 32,
                                                              n_loop_vertices: 8, xyz: 3,
                                                              n_transmitter: 2,
                                                              transmitter_lm_waveform_time: 21,
                                                              transmitter_hm_waveform_time: 36,
                                                              n_receiver: 2, n_component: 4)
            Coordinates:
              * gate_times                                   (gate_times) float64 176B 5....
              * nv                                           (nv) int64 16B 0 1
              * n_loop_vertices                              (n_loop_vertices) int64 64B ...
              * xyz                                          (xyz) int64 24B 0 1 2
              * n_transmitter                                (n_transmitter) int64 16B 0 1
              * transmitter_lm_waveform_time                 (transmitter_lm_waveform_time) float64 168B ...
              * transmitter_hm_waveform_time                 (transmitter_hm_waveform_time) float64 288B ...
              * n_receiver                                   (n_receiver) int64 16B 0 1
              * n_component                                  (n_component) int64 32B 0 1 2 3
            Data variables: (12/31)
                gate_times_bnds                              (gate_times, nv) float64 352B ...
                lm_gate_times_bnds                           (lm_gate_times, nv) float64 448B ...
                hm_gate_times_bnds                           (hm_gate_times, nv) float64 512B ...
                n_loop_vertices_bnds                         (n_loop_vertices, nv) float64 128B ...
                xyz_bnds                                     (xyz, nv) float64 48B -0.5 ....
                transmitter_label                            (n_transmitter) <U2 16B 'LM'...
                ...                                           ...
                component_receivers                          (n_component) <U1 16B 'z' .....
                component_txrx_dx                            (n_component) float64 32B -1...
                component_txrx_dy                            (n_component) float64 32B 0....
                component_txrx_dz                            (n_component) float64 32B -2...
                component_data_type                          (n_component) <U4 64B 'dBdt'...
                component_gate_times                         (n_component) <U13 208B 'lm_...
            Attributes:
                type:                      system
                mode:                      airborne
                method:                    electromagnetic
                submethod:                 time domain
                instrument:                skytem 304M
                name:                      nominal_system
                data_normalized:           True
                skytem_skb_gex_available:  True
                reference_frame:           right-handed positive down
                coil_orientations:         X, Z


.. GENERATED FROM PYTHON SOURCE LINES 59-62 2 - Processed Data - Import processed AEM data from CSV-format. Define input data file and associated metadata file .. GENERATED FROM PYTHON SOURCE LINES 62-71 .. code-block:: Python d_data2 = join(data_path, 'data//WI_SkyTEM_2021_ProcessedData.csv') d_supp2 = join(data_path, 'data//WI_SkyTEM_processed_data_md.yml') system = {"skytem_system" : survey["nominal_system"].isel(lm_gate_times=np.s_[1:], hm_gate_times=np.s_[10:]), "magnetic_system" : survey["magnetic_system"]} # Add the processed AEM data as a tabular dataset pd = data_container.gs.add(key='processed_data', data_filename=d_data2, metadata_file=d_supp2, system=system) .. GENERATED FROM PYTHON SOURCE LINES 72-73 3 - Inverted Models - .. GENERATED FROM PYTHON SOURCE LINES 73-89 .. code-block:: Python # Create a new container for models model_container = survey.gs.add_container('models', **dict(content = "Inverted models", comment = "This is a test")) # pprint(survey.gs.get_all_attr('standard_name')) print(survey.gs.tree) # Import inverted AEM models from CSV-format. # Define input data file and associated metadata file m_data3 = join(data_path, 'model//WI_SkyTEM_2021_InvertedModels.csv') m_supp3 = join(data_path, 'model//WI_SkyTEM_inverted_models_md.yml') # Add the inverted AEM models as a tabular dataset model_container.gs.add(key='inverted_models', data_filename=m_data3, metadata_file=m_supp3) .. rst-class:: sphx-glr-script-out .. code-block:: none /survey /survey/nominal_system /survey/magnetic_system /survey/data /survey/models /survey/data/raw_data /survey/data/processed_data /survey/data/raw_data/nominal_system /survey/data/processed_data/skytem_system /survey/data/processed_data/magnetic_system .. raw:: html
<xarray.DataTree 'inverted_models'>
    Group: /survey/models/inverted_models
        Dimensions:           (index: 11677, layer_depth: 40, nv: 2)
        Coordinates:
          * index             (index) int32 47kB 0 1 2 3 4 ... 11673 11674 11675 11676
          * layer_depth       (layer_depth) float64 320B 0.375 1.16 2.02 ... 262.6 343.8
          * nv                (nv) int64 16B 0 1
            spatial_ref       float64 8B 0.0
            x                 (index) float64 93kB 7.243e+05 7.241e+05 ... 7.108e+05
            y                 (index) float64 93kB 4.916e+05 4.916e+05 ... 4.621e+05
            z                 (index) float64 93kB 177.1 190.4 208.5 ... 231.2 238.8
            t                 (index) float64 93kB 4.422e+04 4.422e+04 ... 4.421e+04
        Data variables: (12/22)
            layer_depth_bnds  (layer_depth, nv) float64 640B -1.89 2.64 ... 341.5 346.0
            pindex            (index) int64 93kB 0 10 20 30 ... 122341 122351 122361
            sline_no          (index) int64 93kB 100100 100100 100100 ... 920000 920000
            e_n83wtm          (index) float64 93kB 7.243e+05 7.241e+05 ... 7.108e+05
            n_n83wtm          (index) float64 93kB 4.916e+05 4.916e+05 ... 4.621e+05
            timestamp         (index) float64 93kB 4.422e+04 4.422e+04 ... 4.421e+04
            ...                ...
            RHO_I_STD         (index, layer_depth) float64 4MB 3.78 2.32 ... 1.33 3.34
            DEP_TOP           (index, layer_depth) float64 4MB 0.0 0.75 ... 250.1 275.0
            DEP_BOT           (index, layer_depth) float64 4MB 0.75 1.57 ... 275.0 412.5
            doi_conservative  (index) float64 93kB 168.7 190.7 189.8 ... 228.0 233.6
            doi_standard      (index) float64 93kB 186.8 212.1 208.0 ... 254.0 262.3
            line_no           (index) int64 93kB 100101 100101 100101 ... 920006 920006
        Attributes:
            content:     inverted resistivity models
            comment:     This dataset includes inverted resistivity models derived fr...
            type:        model
            structure:   tabular
            mode:        airborne
            method:      electromagnetic
            submethod:   time domain
            instrument:  skytem
            property:    electrical resistivity


.. GENERATED FROM PYTHON SOURCE LINES 90-93 4 - Bedrock Picks - Import AEM-based estimated of depth to bedrock from CSV-format. Define input data file and associated metadata file .. GENERATED FROM PYTHON SOURCE LINES 93-99 .. code-block:: Python d_data4 = join(data_path, 'data//topDolomite_Blocky_LidarDEM.csv') d_supp4 = join(data_path, 'data//WI_SkyTEM_bedrock_picks_md.yml') # Add the AEM-based estimated of depth to bedrock as a tabular dataset data_container.gs.add(key='depth_to_bedrock', data_filename=d_data4, metadata_file=d_supp4) .. raw:: html
<xarray.DataTree 'depth_to_bedrock'>
    Group: /survey/data/depth_to_bedrock
        Dimensions:       (index: 82864)
        Coordinates:
          * index         (index) int32 331kB 0 1 2 3 4 ... 82860 82861 82862 82863
            spatial_ref   float64 8B 0.0
            x             (index) float64 663kB 7.243e+05 7.243e+05 ... 6.594e+05
            y             (index) float64 663kB 4.916e+05 4.916e+05 ... 4e+05 4e+05
        Data variables:
            id            (index) int64 663kB 1 2 3 4 5 ... 102684 102685 102686 102687
            e_n83wtm      (index) float64 663kB 7.243e+05 7.243e+05 ... 6.594e+05
            n_n83wtm      (index) float64 663kB 4.916e+05 4.916e+05 ... 4e+05 4e+05
            br_elevation  (index) float64 663kB 167.8 178.3 180.2 ... 291.3 291.3 292.7
            zstd          (index) float64 663kB 1.01 1.01 1.01 1.01 ... 1.11 1.11 1.11
            origintype    (index) int64 663kB 3 3 3 3 3 3 3 3 3 3 ... 0 0 0 0 0 0 0 0 0
            editdate      (index) object 663kB '6/6/2021 21:46' ... '7/23/2021 23:22'
        Attributes:
            content:     bedrock elevation points
            comment:     This dataset includes AEM-derived point estimates of the ele...
            type:        data
            structure:   tabular
            mode:        
            method:      
            submethod:   
            instrument:  
            property:    


.. GENERATED FROM PYTHON SOURCE LINES 100-101 5 - Derivative Maps - .. GENERATED FROM PYTHON SOURCE LINES 101-114 .. code-block:: Python # We can add arbitrarily named containers to the survey derived_products = survey.gs.add_container('derived_products', **dict(content = "products derived from other data and models")) # Import interpolated bedrock and magnetic maps from TIF-format. # Define input metadata file (which contains the TIF filenames linked to variable names) m_supp5 = join(data_path, 'data//WI_SkyTEM_mag_bedrock_grids_md.yml') # Add the interpolated maps as a raster dataset derived_products.gs.add(key='maps', metadata_file=m_supp5) print(survey.gs.tree) .. rst-class:: sphx-glr-script-out .. code-block:: none /survey /survey/nominal_system /survey/magnetic_system /survey/data /survey/models /survey/derived_products /survey/data/raw_data /survey/data/processed_data /survey/data/depth_to_bedrock /survey/models/inverted_models /survey/derived_products/maps /survey/data/raw_data/nominal_system /survey/data/processed_data/skytem_system /survey/data/processed_data/magnetic_system .. GENERATED FROM PYTHON SOURCE LINES 115-116 Save to NetCDF file .. GENERATED FROM PYTHON SOURCE LINES 116-119 .. code-block:: Python d_out = join(data_path, 'model//WISkyTEM.nc') survey.gs.to_netcdf(d_out) .. GENERATED FROM PYTHON SOURCE LINES 120-121 The gspy goal is to have the complete survey in a single file. However, we can also save containers or datasets separately. .. GENERATED FROM PYTHON SOURCE LINES 121-124 .. code-block:: Python data_container.gs.to_netcdf('test_datacontainer.nc') .. GENERATED FROM PYTHON SOURCE LINES 125-126 Reading back in .. GENERATED FROM PYTHON SOURCE LINES 126-130 .. 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: SkyTEM Airborne Electromagnetic (AEM) Survey, Northeast Wis... │ institution: USGS Geology, Geophysics, and Geochemistry Science Center │ source: SkyTEM raw data, USGS processed data and inverted resistivi... │ 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: Airborne electromagnetic (AEM) and magnetic survey data wer... │ content: survey information (group /survey), raw data (group /survey... │ 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 processed data │ │ comment: This is a test │ │ type: container │ ├── Group: /survey/data/raw_data │ │ │ Dimensions: (index: 6785, hm_gate_times: 32, lm_gate_times: 28) │ │ │ Coordinates: │ │ │ * index (index) int32 27kB 0 1 2 3 4 5 ... 6780 6781 6782 6783 6784 │ │ │ * hm_gate_times (hm_gate_times) float64 256B 2.886e-05 ... 0.003544 │ │ │ * lm_gate_times (lm_gate_times) float64 224B -1.135e-06 ... 0.001394 │ │ │ spatial_ref float64 8B ... │ │ │ x (index) float64 54kB ... │ │ │ y (index) float64 54kB ... │ │ │ z (index) float64 54kB ... │ │ │ t (index) float64 54kB ... │ │ │ Data variables: (12/34) │ │ │ _60hz_intensity (index) float64 54kB ... │ │ │ alt (index) float64 54kB ... │ │ │ anglex (index) float64 54kB ... │ │ │ angley (index) float64 54kB ... │ │ │ base_mag (index) float64 54kB ... │ │ │ curr_hm (index) float64 54kB ... │ │ │ ... ... │ │ │ mag_raw (index) float64 54kB ... │ │ │ n_nad83 (index) float64 54kB ... │ │ │ n_wgs84 (index) float64 54kB ... │ │ │ rmf (index) float64 54kB ... │ │ │ time (index) ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_csv_skytem.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_csv_skytem.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_