Basic Class Structure

The three primary classes (Survey, Tabular, and Raster) all contain data and metadata within Xarray Datasets. This example demonstrates how to access the xarray object for each class, and methods for exploring the data and metadata.

This example uses ASEG-formatted raw AEM data from the Tempest system, and a 2-D GeoTiFF of magnetic data.

Dataset Reference: Minsley, B.J., James, S.R., Bedrosian, P.A., Pace, M.D., Hoogenboom, B.E., and Burton, B.L., 2021, Airborne electromagnetic, magnetic, and radiometric survey of the Mississippi Alluvial Plain, November 2019 - March 2020: U.S. Geological Survey data release, https://doi.org/10.5066/P9E44CTQ.

import matplotlib.pyplot as plt
from os.path import join
import gspy
from gspy import Survey
from pprint import pprint

First open the netcdf GS standard survey file.

survey = gspy.open_datatree("..//data_files//tempest_aseg//Tempest.nc")['survey']

Accessing the Xarray object

Survey

# The Survey's metadata is accessed through the xarray property
print('Survey:')
print(survey)
Survey:
<xarray.DataTree 'survey'>
Group: /survey
│   Dimensions:                 ()
│   Coordinates:
│       spatial_ref             float64 8B ...
│   Data variables:
│       survey_information      float64 8B ...
│       survey_units            float64 8B ...
│       flightline_information  float64 8B ...
│       survey_equipment        float64 8B ...
│   Attributes:
│       uuid:         6475fff9-4236-4c02-897a-df0cc69e4a2a
│       title:        Example Tempest Airborne Electromagnetic (AEM) Dataset
│       institution:  USGS Geology, Geophysics, & Geochemistry Science Center
│       source:       Contractor provided ASEG-formatted data
│       history:      <date and time when the data were produced and/or modified>
│       references:   <data release reference>
│       comment:      <additional details or ancillary information>
│       content:      <summary list of file contents, e.g. raw data (/survey/tabu...
│       conventions:  CF-1.8, GS-0.0
│       created_by:   gspy==0.0.1
│       type:         survey
├── Group: /survey/data
│   │   Dimensions:      ()
│   │   Data variables:
│   │       spatial_ref  float64 8B ...
│   │   Attributes:
│   │       content:  raw and processed data
│   │       type:     container
│   ├── Group: /survey/data/raw_data
│   │   │   Dimensions:          (index: 2001, gate_times: 15)
│   │   │   Coordinates:
│   │   │     * index            (index) int32 8kB 0 1 2 3 4 5 ... 1996 1997 1998 1999 2000
│   │   │     * gate_times       (gate_times) float64 120B 1.085e-05 3.255e-05 ... 0.01338
│   │   │       spatial_ref      float64 8B ...
│   │   │       x                (index) float64 16kB ...
│   │   │       y                (index) float64 16kB ...
│   │   │       z                (index) float64 16kB ...
│   │   │   Data variables: (12/61)
│   │   │       line             (index) int32 8kB ...
│   │   │       flight           (index) int32 8kB ...
│   │   │       fiducial         (index) float64 16kB ...
│   │   │       proj_cgg         (index) int32 8kB ...
│   │   │       proj_client      (index) int32 8kB ...
│   │   │       date             (index) int32 8kB ...
│   │   │       ...               ...
│   │   │       z_primaryfield   (index) float64 16kB ...
│   │   │       z_vlf1           (index) float64 16kB ...
│   │   │       z_vlf2           (index) float64 16kB ...
│   │   │       z_vlf3           (index) float64 16kB ...
│   │   │       z_vlf4           (index) float64 16kB ...
│   │   │       z_geofact        (index) float64 16kB ...
│   │   │   Attributes:
│   │   │       uuid:     fcc5f052-ddc6-4bc9-a6d4-f5dd27e22eae
│   │   │       content:  raw data
│   │   │       comment:  This dataset includes minimally processed (raw) AEM data
│   │   ├── Group: /survey/data/raw_data/tempest_system
│   │   │       Dimensions:                       (gate_times: 15, nv: 2, n_transmitter: 1,
│   │   │                                          waveform_time: 7, n_receiver: 2,
│   │   │                                          n_component: 2)
│   │   │       Coordinates:
│   │   │         * nv                            (nv) int64 16B 0 1
│   │   │         * n_transmitter                 (n_transmitter) int64 8B 0
│   │   │         * waveform_time                 (waveform_time) float64 56B -0.01667 ... 0....
│   │   │         * n_receiver                    (n_receiver) int64 16B 0 1
│   │   │         * n_component                   (n_component) int64 16B 0 1
│   │   │       Data variables: (12/21)
│   │   │           gate_times_bnds               (gate_times, nv) float64 240B ...
│   │   │           transmitter_label             (n_transmitter) <U1 4B ...
│   │   │           transmitter_area              (n_transmitter) int64 8B ...
│   │   │           transmitter_waveform_type     (n_transmitter) <U6 24B ...
│   │   │           transmitter_waveform_current  (waveform_time) float64 56B ...
│   │   │           transmitter_scale_factor      (n_transmitter) float64 8B ...
│   │   │           ...                            ...
│   │   │           component_label               (n_component) <U3 24B ...
│   │   │           component_transmitters        (n_component) <U1 8B ...
│   │   │           component_receivers           (n_component) <U1 8B ...
│   │   │           component_txrx_dx             (n_component) int64 16B ...
│   │   │           component_txrx_dy             (n_component) int64 16B ...
│   │   │           component_txrx_dz             (n_component) int64 16B ...
│   │   │       Attributes: (12/13)
│   │   │           type:                     system
│   │   │           mode:                     airborne
│   │   │           method:                   electromagnetic
│   │   │           submethod:                time domain
│   │   │           instrument:               tempest
│   │   │           uuid:                     51b3d522-c7af-4c64-867b-65b1bc14358d
│   │   │           ...                       ...
│   │   │           structure:                tabular
│   │   │           data_normalized:          True
│   │   │           output_data_type:         B
│   │   │           reference_frame:          right-handed positive up
│   │   │           output_sample_frequency:  5
│   │   │           digitization_frequency:   92160
│   │   ├── Group: /survey/data/raw_data/magnetic_system
│   │   │       Attributes:
│   │   │           type:              system
│   │   │           mode:              airborne
│   │   │           method:            magnetic
│   │   │           submethod:         not_defined
│   │   │           instrument:        not_defiend
│   │   │           name:              magnetic_system
│   │   │           sample_frequency:  1.0
│   │   │           resolution:        0.001
│   │   └── Group: /survey/data/raw_data/radiometric_system
│   │           Attributes:
│   │               type:              system
│   │               mode:              airborne
│   │               method:            radiometric
│   │               submethod:         not_defined
│   │               instrument:        not_defined
│   │               name:              radiometric_system
│   │               sample_frequency:  1.0
│   └── Group: /survey/data/derived_maps
│       │   Dimensions:      ()
│       │   Data variables:
│       │       spatial_ref  float64 8B ...
│       │   Attributes:
│       │       content:  derived maps
│       │       type:     container
│       └── Group: /survey/data/derived_maps/maps
│               Dimensions:       (x: 599, nv: 2, y: 1212)
│               Coordinates:
│                 * x             (x) float64 5kB 2.928e+05 2.934e+05 ... 6.51e+05 6.516e+05
│                 * nv            (nv) int64 16B 0 1
│                 * y             (y) float64 10kB 1.607e+06 1.606e+06 ... 8.808e+05 8.802e+05
│                   spatial_ref   float64 8B ...
│               Data variables:
│                   x_bnds        (x, nv) float64 10kB ...
│                   y_bnds        (y, nv) float64 19kB ...
│                   magnetic_tmi  (y, x) float64 6MB ...
│               Attributes:
│                   uuid:     497f4feb-ff9f-4a4c-9a2c-3a23b65bef62
│                   comment:  <additional details or ancillary information>
│                   content:  gridded magnetic map
└── Group: /survey/models
    │   Dimensions:      ()
    │   Data variables:
    │       spatial_ref  float64 8B ...
    │   Attributes:
    │       content:  inverted models
    │       type:     container
    └── Group: /survey/models/inverted_models
            Dimensions:                  (layer_depth: 30, nv: 2, gate_times: 15,
                                          index: 2001)
            Coordinates:
              * layer_depth              (layer_depth) float64 240B 1.5 4.65 ... 424.2 467.5
              * nv                       (nv) int64 16B 0 1
              * gate_times               (gate_times) float64 120B 1.085e-05 ... 0.01338
              * index                    (index) int32 8kB 0 1 2 3 4 ... 1997 1998 1999 2000
                spatial_ref              float64 8B ...
                x                        (index) float64 16kB ...
                y                        (index) float64 16kB ...
                z                        (index) float64 16kB ...
            Data variables: (12/49)
                layer_depth_bnds         (layer_depth, nv) float64 480B ...
                gate_times_bnds          (gate_times, nv) float64 240B ...
                uniqueid                 (index) int32 8kB ...
                survey                   (index) int32 8kB ...
                date                     (index) int32 8kB ...
                flight                   (index) int32 8kB ...
                ...                       ...
                phic                     (index) float64 16kB ...
                phit                     (index) float64 16kB ...
                phig                     (index) float64 16kB ...
                phis                     (index) float64 16kB ...
                lambda                   (index) float64 16kB ...
                iterations               (index) int32 8kB ...
            Attributes:
                uuid:     b41252cd-a11d-4d2e-acc5-dffd2b18c237
                content:  inverted resistivity models
                comment:  This dataset includes inverted resistivity models derived from ...

To look just at the attributes

print('Survey Attributes:\n')
pprint(survey.attrs)
Survey Attributes:

{'comment': '<additional details or ancillary information>',
 'content': '<summary list of file contents, e.g. raw data '
            '(/survey/tabular/0), processed data (/survey/tabular/1)>',
 'conventions': 'CF-1.8, GS-0.0',
 'created_by': 'gspy==0.0.1',
 'history': '<date and time when the data were produced and/or modified>',
 'institution': 'USGS Geology, Geophysics, & Geochemistry Science Center',
 'references': '<data release reference>',
 'source': 'Contractor provided ASEG-formatted data',
 'title': 'Example Tempest Airborne Electromagnetic (AEM) Dataset',
 'type': 'survey',
 'uuid': '6475fff9-4236-4c02-897a-df0cc69e4a2a'}

Or expand a specific variable

print('Survey Information:\n')
print(survey['survey_information'])
Survey Information:

<xarray.DataArray 'survey_information' ()> Size: 8B
[1 values with dtype=float64]
Coordinates:
    spatial_ref  float64 8B ...
Attributes:
    contractor_project_number:  603756FWA
    contractor:                 CGG Canada Services Ltd.
    client:                     U.S. Geological Survey
    survey_type:                electromagneticmagneticradiometric
    survey_area_name:           Mississippi Alluvial Plain (MAP)
    state:                      MOARTNMSLAILKY
    country:                    USA
    acquisition_start:          20191120
    acquisition_end:            20200307
    dataset_created:            20200420

Datasets Get the list of datasets attached to the survey

print(survey.items)
<bound method Mapping.items of <xarray.DataTree 'survey'>
Group: /survey
│   Dimensions:                 ()
│   Coordinates:
│       spatial_ref             float64 8B ...
│   Data variables:
│       survey_information      float64 8B ...
│       survey_units            float64 8B ...
│       flightline_information  float64 8B ...
│       survey_equipment        float64 8B ...
│   Attributes:
│       uuid:         6475fff9-4236-4c02-897a-df0cc69e4a2a
│       title:        Example Tempest Airborne Electromagnetic (AEM) Dataset
│       institution:  USGS Geology, Geophysics, & Geochemistry Science Center
│       source:       Contractor provided ASEG-formatted data
│       history:      <date and time when the data were produced and/or modified>
│       references:   <data release reference>
│       comment:      <additional details or ancillary information>
│       content:      <summary list of file contents, e.g. raw data (/survey/tabu...
│       conventions:  CF-1.8, GS-0.0
│       created_by:   gspy==0.0.1
│       type:         survey
├── Group: /survey/data
│   │   Dimensions:      ()
│   │   Data variables:
│   │       spatial_ref  float64 8B ...
│   │   Attributes:
│   │       content:  raw and processed data
│   │       type:     container
│   ├── Group: /survey/data/raw_data
│   │   │   Dimensions:          (index: 2001, gate_times: 15)
│   │   │   Coordinates:
│   │   │     * index            (index) int32 8kB 0 1 2 3 4 5 ... 1996 1997 1998 1999 2000
│   │   │     * gate_times       (gate_times) float64 120B 1.085e-05 3.255e-05 ... 0.01338
│   │   │       spatial_ref      float64 8B ...
│   │   │       x                (index) float64 16kB ...
│   │   │       y                (index) float64 16kB ...
│   │   │       z                (index) float64 16kB ...
│   │   │   Data variables: (12/61)
│   │   │       line             (index) int32 8kB ...
│   │   │       flight           (index) int32 8kB ...
│   │   │       fiducial         (index) float64 16kB ...
│   │   │       proj_cgg         (index) int32 8kB ...
│   │   │       proj_client      (index) int32 8kB ...
│   │   │       date             (index) int32 8kB ...
│   │   │       ...               ...
│   │   │       z_primaryfield   (index) float64 16kB ...
│   │   │       z_vlf1           (index) float64 16kB ...
│   │   │       z_vlf2           (index) float64 16kB ...
│   │   │       z_vlf3           (index) float64 16kB ...
│   │   │       z_vlf4           (index) float64 16kB ...
│   │   │       z_geofact        (index) float64 16kB ...
│   │   │   Attributes:
│   │   │       uuid:     fcc5f052-ddc6-4bc9-a6d4-f5dd27e22eae
│   │   │       content:  raw data
│   │   │       comment:  This dataset includes minimally processed (raw) AEM data
│   │   ├── Group: /survey/data/raw_data/tempest_system
│   │   │       Dimensions:                       (gate_times: 15, nv: 2, n_transmitter: 1,
│   │   │                                          waveform_time: 7, n_receiver: 2,
│   │   │                                          n_component: 2)
│   │   │       Coordinates:
│   │   │         * nv                            (nv) int64 16B 0 1
│   │   │         * n_transmitter                 (n_transmitter) int64 8B 0
│   │   │         * waveform_time                 (waveform_time) float64 56B -0.01667 ... 0....
│   │   │         * n_receiver                    (n_receiver) int64 16B 0 1
│   │   │         * n_component                   (n_component) int64 16B 0 1
│   │   │       Data variables: (12/21)
│   │   │           gate_times_bnds               (gate_times, nv) float64 240B ...
│   │   │           transmitter_label             (n_transmitter) <U1 4B ...
│   │   │           transmitter_area              (n_transmitter) int64 8B ...
│   │   │           transmitter_waveform_type     (n_transmitter) <U6 24B ...
│   │   │           transmitter_waveform_current  (waveform_time) float64 56B ...
│   │   │           transmitter_scale_factor      (n_transmitter) float64 8B ...
│   │   │           ...                            ...
│   │   │           component_label               (n_component) <U3 24B ...
│   │   │           component_transmitters        (n_component) <U1 8B ...
│   │   │           component_receivers           (n_component) <U1 8B ...
│   │   │           component_txrx_dx             (n_component) int64 16B ...
│   │   │           component_txrx_dy             (n_component) int64 16B ...
│   │   │           component_txrx_dz             (n_component) int64 16B ...
│   │   │       Attributes: (12/13)
│   │   │           type:                     system
│   │   │           mode:                     airborne
│   │   │           method:                   electromagnetic
│   │   │           submethod:                time domain
│   │   │           instrument:               tempest
│   │   │           uuid:                     51b3d522-c7af-4c64-867b-65b1bc14358d
│   │   │           ...                       ...
│   │   │           structure:                tabular
│   │   │           data_normalized:          True
│   │   │           output_data_type:         B
│   │   │           reference_frame:          right-handed positive up
│   │   │           output_sample_frequency:  5
│   │   │           digitization_frequency:   92160
│   │   ├── Group: /survey/data/raw_data/magnetic_system
│   │   │       Attributes:
│   │   │           type:              system
│   │   │           mode:              airborne
│   │   │           method:            magnetic
│   │   │           submethod:         not_defined
│   │   │           instrument:        not_defiend
│   │   │           name:              magnetic_system
│   │   │           sample_frequency:  1.0
│   │   │           resolution:        0.001
│   │   └── Group: /survey/data/raw_data/radiometric_system
│   │           Attributes:
│   │               type:              system
│   │               mode:              airborne
│   │               method:            radiometric
│   │               submethod:         not_defined
│   │               instrument:        not_defined
│   │               name:              radiometric_system
│   │               sample_frequency:  1.0
│   └── Group: /survey/data/derived_maps
│       │   Dimensions:      ()
│       │   Data variables:
│       │       spatial_ref  float64 8B ...
│       │   Attributes:
│       │       content:  derived maps
│       │       type:     container
│       └── Group: /survey/data/derived_maps/maps
│               Dimensions:       (x: 599, nv: 2, y: 1212)
│               Coordinates:
│                 * x             (x) float64 5kB 2.928e+05 2.934e+05 ... 6.51e+05 6.516e+05
│                 * nv            (nv) int64 16B 0 1
│                 * y             (y) float64 10kB 1.607e+06 1.606e+06 ... 8.808e+05 8.802e+05
│                   spatial_ref   float64 8B ...
│               Data variables:
│                   x_bnds        (x, nv) float64 10kB ...
│                   y_bnds        (y, nv) float64 19kB ...
│                   magnetic_tmi  (y, x) float64 6MB ...
│               Attributes:
│                   uuid:     497f4feb-ff9f-4a4c-9a2c-3a23b65bef62
│                   comment:  <additional details or ancillary information>
│                   content:  gridded magnetic map
└── Group: /survey/models
    │   Dimensions:      ()
    │   Data variables:
    │       spatial_ref  float64 8B ...
    │   Attributes:
    │       content:  inverted models
    │       type:     container
    └── Group: /survey/models/inverted_models
            Dimensions:                  (layer_depth: 30, nv: 2, gate_times: 15,
                                          index: 2001)
            Coordinates:
              * layer_depth              (layer_depth) float64 240B 1.5 4.65 ... 424.2 467.5
              * nv                       (nv) int64 16B 0 1
              * gate_times               (gate_times) float64 120B 1.085e-05 ... 0.01338
              * index                    (index) int32 8kB 0 1 2 3 4 ... 1997 1998 1999 2000
                spatial_ref              float64 8B ...
                x                        (index) float64 16kB ...
                y                        (index) float64 16kB ...
                z                        (index) float64 16kB ...
            Data variables: (12/49)
                layer_depth_bnds         (layer_depth, nv) float64 480B ...
                gate_times_bnds          (gate_times, nv) float64 240B ...
                uniqueid                 (index) int32 8kB ...
                survey                   (index) int32 8kB ...
                date                     (index) int32 8kB ...
                flight                   (index) int32 8kB ...
                ...                       ...
                phic                     (index) float64 16kB ...
                phit                     (index) float64 16kB ...
                phig                     (index) float64 16kB ...
                phis                     (index) float64 16kB ...
                lambda                   (index) float64 16kB ...
                iterations               (index) int32 8kB ...
            Attributes:
                uuid:     b41252cd-a11d-4d2e-acc5-dffd2b18c237
                content:  inverted resistivity models
                comment:  This dataset includes inverted resistivity models derived from ...>

Datasets are attached to the Survey regardless of their format whether unstructured tabular data or image-type raster data

# Tabular
print('Tabular:\n')
print(survey['data'])

# Raster
print('\nRaster:\n')
print(survey['data/derived_maps/maps'])
Tabular:

<xarray.DataTree 'data'>
Group: /survey/data
│   Dimensions:      ()
│   Data variables:
│       spatial_ref  float64 8B ...
│   Attributes:
│       content:  raw and processed data
│       type:     container
├── Group: /survey/data/raw_data
│   │   Dimensions:          (index: 2001, gate_times: 15)
│   │   Coordinates:
│   │     * index            (index) int32 8kB 0 1 2 3 4 5 ... 1996 1997 1998 1999 2000
│   │     * gate_times       (gate_times) float64 120B 1.085e-05 3.255e-05 ... 0.01338
│   │       spatial_ref      float64 8B ...
│   │       x                (index) float64 16kB ...
│   │       y                (index) float64 16kB ...
│   │       z                (index) float64 16kB ...
│   │   Data variables: (12/61)
│   │       line             (index) int32 8kB ...
│   │       flight           (index) int32 8kB ...
│   │       fiducial         (index) float64 16kB ...
│   │       proj_cgg         (index) int32 8kB ...
│   │       proj_client      (index) int32 8kB ...
│   │       date             (index) int32 8kB ...
│   │       ...               ...
│   │       z_primaryfield   (index) float64 16kB ...
│   │       z_vlf1           (index) float64 16kB ...
│   │       z_vlf2           (index) float64 16kB ...
│   │       z_vlf3           (index) float64 16kB ...
│   │       z_vlf4           (index) float64 16kB ...
│   │       z_geofact        (index) float64 16kB ...
│   │   Attributes:
│   │       uuid:     fcc5f052-ddc6-4bc9-a6d4-f5dd27e22eae
│   │       content:  raw data
│   │       comment:  This dataset includes minimally processed (raw) AEM data
│   ├── Group: /survey/data/raw_data/tempest_system
│   │       Dimensions:                       (gate_times: 15, nv: 2, n_transmitter: 1,
│   │                                          waveform_time: 7, n_receiver: 2,
│   │                                          n_component: 2)
│   │       Coordinates:
│   │         * nv                            (nv) int64 16B 0 1
│   │         * n_transmitter                 (n_transmitter) int64 8B 0
│   │         * waveform_time                 (waveform_time) float64 56B -0.01667 ... 0....
│   │         * n_receiver                    (n_receiver) int64 16B 0 1
│   │         * n_component                   (n_component) int64 16B 0 1
│   │       Data variables: (12/21)
│   │           gate_times_bnds               (gate_times, nv) float64 240B ...
│   │           transmitter_label             (n_transmitter) <U1 4B ...
│   │           transmitter_area              (n_transmitter) int64 8B ...
│   │           transmitter_waveform_type     (n_transmitter) <U6 24B ...
│   │           transmitter_waveform_current  (waveform_time) float64 56B ...
│   │           transmitter_scale_factor      (n_transmitter) float64 8B ...
│   │           ...                            ...
│   │           component_label               (n_component) <U3 24B ...
│   │           component_transmitters        (n_component) <U1 8B ...
│   │           component_receivers           (n_component) <U1 8B ...
│   │           component_txrx_dx             (n_component) int64 16B ...
│   │           component_txrx_dy             (n_component) int64 16B ...
│   │           component_txrx_dz             (n_component) int64 16B ...
│   │       Attributes: (12/13)
│   │           type:                     system
│   │           mode:                     airborne
│   │           method:                   electromagnetic
│   │           submethod:                time domain
│   │           instrument:               tempest
│   │           uuid:                     51b3d522-c7af-4c64-867b-65b1bc14358d
│   │           ...                       ...
│   │           structure:                tabular
│   │           data_normalized:          True
│   │           output_data_type:         B
│   │           reference_frame:          right-handed positive up
│   │           output_sample_frequency:  5
│   │           digitization_frequency:   92160
│   ├── Group: /survey/data/raw_data/magnetic_system
│   │       Attributes:
│   │           type:              system
│   │           mode:              airborne
│   │           method:            magnetic
│   │           submethod:         not_defined
│   │           instrument:        not_defiend
│   │           name:              magnetic_system
│   │           sample_frequency:  1.0
│   │           resolution:        0.001
│   └── Group: /survey/data/raw_data/radiometric_system
│           Attributes:
│               type:              system
│               mode:              airborne
│               method:            radiometric
│               submethod:         not_defined
│               instrument:        not_defined
│               name:              radiometric_system
│               sample_frequency:  1.0
└── Group: /survey/data/derived_maps
    │   Dimensions:      ()
    │   Data variables:
    │       spatial_ref  float64 8B ...
    │   Attributes:
    │       content:  derived maps
    │       type:     container
    └── Group: /survey/data/derived_maps/maps
            Dimensions:       (x: 599, nv: 2, y: 1212)
            Coordinates:
              * x             (x) float64 5kB 2.928e+05 2.934e+05 ... 6.51e+05 6.516e+05
              * nv            (nv) int64 16B 0 1
              * y             (y) float64 10kB 1.607e+06 1.606e+06 ... 8.808e+05 8.802e+05
                spatial_ref   float64 8B ...
            Data variables:
                x_bnds        (x, nv) float64 10kB ...
                y_bnds        (y, nv) float64 19kB ...
                magnetic_tmi  (y, x) float64 6MB ...
            Attributes:
                uuid:     497f4feb-ff9f-4a4c-9a2c-3a23b65bef62
                comment:  <additional details or ancillary information>
                content:  gridded magnetic map

Raster:

<xarray.DataTree 'maps'>
Group: /survey/data/derived_maps/maps
    Dimensions:       (x: 599, nv: 2, y: 1212)
    Coordinates:
      * x             (x) float64 5kB 2.928e+05 2.934e+05 ... 6.51e+05 6.516e+05
      * nv            (nv) int64 16B 0 1
      * y             (y) float64 10kB 1.607e+06 1.606e+06 ... 8.808e+05 8.802e+05
        spatial_ref   float64 8B ...
    Data variables:
        x_bnds        (x, nv) float64 10kB ...
        y_bnds        (y, nv) float64 19kB ...
        magnetic_tmi  (y, x) float64 6MB ...
    Attributes:
        uuid:     497f4feb-ff9f-4a4c-9a2c-3a23b65bef62
        comment:  <additional details or ancillary information>
        content:  gridded magnetic map

and the second is located at index 1

print('Second Tabular Group:\n')
print(survey['models/inverted_models'])
Second Tabular Group:

<xarray.DataTree 'inverted_models'>
Group: /survey/models/inverted_models
    Dimensions:                  (layer_depth: 30, nv: 2, gate_times: 15,
                                  index: 2001)
    Coordinates:
      * layer_depth              (layer_depth) float64 240B 1.5 4.65 ... 424.2 467.5
      * nv                       (nv) int64 16B 0 1
      * gate_times               (gate_times) float64 120B 1.085e-05 ... 0.01338
      * index                    (index) int32 8kB 0 1 2 3 4 ... 1997 1998 1999 2000
        spatial_ref              float64 8B ...
        x                        (index) float64 16kB ...
        y                        (index) float64 16kB ...
        z                        (index) float64 16kB ...
    Data variables: (12/49)
        layer_depth_bnds         (layer_depth, nv) float64 480B ...
        gate_times_bnds          (gate_times, nv) float64 240B ...
        uniqueid                 (index) int32 8kB ...
        survey                   (index) int32 8kB ...
        date                     (index) int32 8kB ...
        flight                   (index) int32 8kB ...
        ...                       ...
        phic                     (index) float64 16kB ...
        phit                     (index) float64 16kB ...
        phig                     (index) float64 16kB ...
        phis                     (index) float64 16kB ...
        lambda                   (index) float64 16kB ...
        iterations               (index) int32 8kB ...
    Attributes:
        uuid:     b41252cd-a11d-4d2e-acc5-dffd2b18c237
        content:  inverted resistivity models
        comment:  This dataset includes inverted resistivity models derived from ...

Coordinates, Dimensions, and Attributes

All data variables must have dimensions, coordinate, and attributes

Dimensions

Tabular data are typicaly 1-D or 2-D variables with the primary dimension being index, which corresponds to the rows of the input text file representing individual measurements.

print(survey['models/inverted_models']['index'])
<xarray.DataArray 'index' (index: 2001)> Size: 8kB
array([   0,    1,    2, ..., 1998, 1999, 2000], shape=(2001,), dtype=int32)
Coordinates:
  * index        (index) int32 8kB 0 1 2 3 4 5 ... 1995 1996 1997 1998 1999 2000
    spatial_ref  float64 8B ...
    x            (index) float64 16kB ...
    y            (index) float64 16kB ...
    z            (index) float64 16kB ...
Attributes:
    standard_name:  index
    long_name:      Index of individual data points
    units:          not_defined
    null_value:     not_defined
    valid_range:    [   0. 2000.]
    grid_mapping:   spatial_ref

If a dimension is not discrete, meaning it represents ranges (such as depth layers), then the bounds on each dimension value also need to be defined, and are linked to the dimension through the “bounds” attribute.

print('example non-discrete dimension:\n')
print(survey['models/inverted_models']['gate_times'])
print('\n\ncorresponding bounds on non-discrete dimension:\n')
print(survey['models/inverted_models']['gate_times_bnds'])
example non-discrete dimension:

<xarray.DataArray 'gate_times' (gate_times: 15)> Size: 120B
array([1.085000e-05, 3.255000e-05, 5.426000e-05, 8.681000e-05, 1.410600e-04,
       2.278700e-04, 3.689300e-04, 5.859500e-04, 9.114800e-04, 1.410630e-03,
       2.191900e-03, 3.418070e-03, 5.338690e-03, 8.301020e-03, 1.337928e-02])
Coordinates:
  * gate_times   (gate_times) float64 120B 1.085e-05 3.255e-05 ... 0.01338
    spatial_ref  float64 8B ...
Attributes:
    standard_name:  gate_times
    long_name:      receiver gate times
    units:          seconds
    null_value:     not_defined
    valid_range:    [1.085000e-05 1.337928e-02]
    grid_mapping:   spatial_ref
    bounds:         gate_times_bnds


corresponding bounds on non-discrete dimension:

<xarray.DataArray 'gate_times_bnds' (gate_times: 15, nv: 2)> Size: 240B
[30 values with dtype=float64]
Coordinates:
  * gate_times   (gate_times) float64 120B 1.085e-05 3.255e-05 ... 0.01338
  * nv           (nv) int64 16B 0 1
    spatial_ref  float64 8B ...
Attributes:
    standard_name:  gate_times_bounds
    long_name:      receiver gate times cell boundaries
    null_value:     not_defined
    valid_range:    [-0.00012479  0.01351492]
    grid_mapping:   spatial_ref

Coordinates

Coordinates define the spatial and temporal positioning of the data (X Y Z T). Additionally, all dimensions are by default classified as a coordinate. This means a dataset can have both dimensional and non-dimensional coordinates. Dimensional coordinates are noted with a * (or bold text) in printed output of the xarray, such as index, gate_times, nv in this example:

print(survey['data'].dataset.coords)
Coordinates:
    *empty*

Tabular Coordinates

In Tabular data, coordinates are typically non-dimensional, since the primary dataset dimension is index. By default, we define the spatial coordinates, x and y, based on the longitude and latitude (or easting/northing) data variables. If relevant, z and t coordinate variables can also be defined, representing the vertical and temporal coordinates of the data points.

Note: All coordinates must match the coordinate reference system defined in the Survey.

Raster Coordinates

Raster data are gridded, typically representing maps or multi-dimensional models. Therefore, Raster data almost always have dimensional coordinates, i.e., the data dimensions correspond directly to either spatial or temporal coordinates (x, y, z, t).

print(survey['data/derived_maps/maps'].coords)
Coordinates:
  * x            (x) float64 5kB 2.928e+05 2.934e+05 ... 6.51e+05 6.516e+05
  * nv           (nv) int64 16B 0 1
  * y            (y) float64 10kB 1.607e+06 1.606e+06 ... 8.808e+05 8.802e+05
    spatial_ref  float64 8B ...

The Spatial Reference Coordinate

the spatial_ref coordinate variable is a non-dimensional coordinate that contains information on the coordinate reference system. For more information, see Coordinate Reference Systems.

Attributes

Both datasets and data variables have attributes (metadata fields). Certain attributes are required, see our documentation on the GS standard. for more details.

Dataset attributes

Dataset attributes provide users a way to document and describe supplementary information about a dataset group as a whole, such as model inversion parameters or other processing descriptions. At a minimum, a content attribute should contain a brief summary of the contents of the dataset.

pprint(survey['models/inverted_models'].attrs)
{'comment': 'This dataset includes inverted resistivity models derived from '
            'processed AEM data produced by USGS',
 'content': 'inverted resistivity models',
 'uuid': 'b41252cd-a11d-4d2e-acc5-dffd2b18c237'}

Variable attributes

Each data variable must contain attributes detailing the metadata of that individual variable. These follow the Climate and Forecast (CF) metadata conventions.

pprint(survey['models/inverted_models']['conductivity'].attrs)
{'format': '30e15.6',
 'grid_mapping': 'spatial_ref',
 'long_name': 'Layer conductivity',
 'null_value': 'not_defined',
 'standard_name': 'conductivity',
 'units': 'S/m',
 'valid_range': array([1.456164e-04, 1.000000e+01])}

Total running time of the script: (0 minutes 0.142 seconds)

Gallery generated by Sphinx-Gallery