CfRadial1 <-> CfRadial2#

Imports#

import xarray as xr
from open_radar_data import DATASETS

import xradar as xd

Load Data#

file = DATASETS.fetch("cfrad.20080604_002217_000_SPOL_v36_SUR.nc")
dtree = xd.io.open_cfradial1_datatree(file)
display(dtree)
<xarray.DataTree>
Group: /
│   Dimensions:              (sweep: 9)
│   Coordinates:
│       latitude             float64 8B ...
│       longitude            float64 8B ...
│       altitude             float64 8B ...
│   Dimensions without coordinates: sweep
│   Data variables:
│       volume_number        int32 4B ...
│       platform_type        |S32 32B ...
│       primary_axis         |S32 32B ...
│       status_str           |S1 1B ...
│       instrument_type      |S32 32B ...
│       time_coverage_start  |S32 32B ...
│       time_coverage_end    |S32 32B ...
│       sweep_group_name     (sweep) <U7 252B 'sweep_0' 'sweep_1' ... 'sweep_8'
│       sweep_fixed_angle    (sweep) float32 36B ...
│   Attributes: (12/13)
│       Conventions:         CF/Radial instrument_parameters radar_parameters rad...
│       version:             1.2
│       title:               TIMREX
│       institution:         
│       references:          
│       source:              
│       ...                  ...
│       comment:             
│       instrument_name:     SPOLRVP8
│       site_name:           
│       scan_name:           
│       scan_id:             0
│       platform_is_mobile:  false
├── Group: /sweep_0
│       Dimensions:                    (azimuth: 483, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:15:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 483B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_1
│       Dimensions:                    (azimuth: 483, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:16:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 483B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_2
│       Dimensions:                    (azimuth: 482, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:17:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 482B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_3
│       Dimensions:                    (azimuth: 483, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:17:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 483B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_4
│       Dimensions:                    (azimuth: 481, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:18:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 481B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_5
│       Dimensions:                    (azimuth: 482, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:19:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 482B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_6
│       Dimensions:                    (azimuth: 482, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:20:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 482B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_7
│       Dimensions:                    (azimuth: 484, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:21:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 484B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
└── Group: /sweep_8
        Dimensions:                    (azimuth: 483, range: 996)
        Coordinates:
          * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
            elevation                  (azimuth) float32 2kB ...
            time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:21:...
          * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
        Data variables: (12/18)
            sweep_number               int32 4B ...
            sweep_mode                 <U20 80B 'azimuth_surveillance'
            prt_mode                   |S32 32B ...
            follow_mode                |S32 32B ...
            sweep_fixed_angle          float32 4B ...
            pulse_width                (azimuth) float32 2kB ...
            ...                         ...
            r_calib_index              (azimuth) int8 483B ...
            measured_transmit_power_h  (azimuth) float32 2kB ...
            measured_transmit_power_v  (azimuth) float32 2kB ...
            scan_rate                  (azimuth) float32 2kB ...
            DBZ                        (azimuth, range) float32 2MB ...
            VR                         (azimuth, range) float32 2MB ...

Transform CF2 to CF1#

ds = dtree.xradar.to_cfradial1_dataset()
display(ds)
<xarray.Dataset> Size: 35MB
Dimensions:                    (time: 4343, range: 996, sweep: 9)
Coordinates:
  * time                       (time) datetime64[ns] 35kB 2008-06-04T00:15:03...
  * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
    latitude                   float64 8B ...
    longitude                  float64 8B ...
    altitude                   float64 8B ...
Dimensions without coordinates: sweep
Data variables: (12/30)
    pulse_width                (time) float32 17kB 0.0 0.0 0.0 ... 0.0 0.0 0.0
    prt                        (time) float32 17kB -9.999e+03 ... -9.999e+03
    prt_ratio                  (time) float32 17kB -9.999e+03 ... -9.999e+03
    nyquist_velocity           (time) float32 17kB 26.92 26.92 ... 26.92 26.92
    unambiguous_range          (time) float32 17kB 1.5e+05 1.5e+05 ... 1.5e+05
    antenna_transition         (time) int8 4kB 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0
    ...                         ...
    platform_type              |S32 32B ...
    primary_axis               |S32 32B ...
    status_str                 |S1 1B ...
    instrument_type            |S32 32B ...
    time_coverage_start        |S32 32B ...
    time_coverage_end          |S32 32B ...
Attributes: (12/13)
    Conventions:         Cf/Radial
    version:             1.2
    title:               TIMREX
    institution:         
    references:          
    source:              
    ...                  ...
    comment:             
    instrument_name:     SPOLRVP8
    site_name:           
    scan_name:           
    scan_id:             0
    platform_is_mobile:  false

Transform CF1 to CF2#

dtree = ds.xradar.to_cfradial2_datatree()
display(dtree)
<xarray.DataTree 'root'>
Group: /
│   Dimensions:              (sweep: 9)
│   Coordinates:
│       latitude             float64 8B ...
│       longitude            float64 8B ...
│       altitude             float64 8B ...
│   Dimensions without coordinates: sweep
│   Data variables:
│       sweep_group_name     (sweep) <U7 252B 'sweep_0' 'sweep_1' ... 'sweep_8'
│       sweep_fixed_angle    (sweep) float32 36B 0.4999 1.099 1.802 ... 9.102 12.8
│       volume_number        int32 4B ...
│       platform_type        |S32 32B ...
│       primary_axis         |S32 32B ...
│       status_str           |S1 1B ...
│       instrument_type      |S32 32B ...
│       time_coverage_start  |S32 32B ...
│       time_coverage_end    |S32 32B ...
│   Attributes: (12/13)
│       Conventions:         Cf/Radial
│       version:             1.2
│       title:               TIMREX
│       institution:         
│       references:          
│       source:              
│       ...                  ...
│       comment:             
│       instrument_name:     SPOLRVP8
│       site_name:           
│       scan_name:           
│       scan_id:             0
│       platform_is_mobile:  false
├── Group: /sweep_0
│       Dimensions:                    (azimuth: 483, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB 0.5164 0.5219 ... 0.5219
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:15:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           pulse_width                (azimuth) float32 2kB 0.0 0.0 0.0 ... 0.0 0.0 0.0
│           prt                        (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           prt_ratio                  (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           nyquist_velocity           (azimuth) float32 2kB 26.92 26.92 ... 26.92 26.92
│           unambiguous_range          (azimuth) float32 2kB 1.5e+05 1.5e+05 ... 1.5e+05
│           antenna_transition         (azimuth) int8 483B 0 0 0 0 0 0 0 ... 0 0 0 0 0 0
│           ...                         ...
│           VR                         (azimuth, range) float32 2MB -23.38 ... -25.39
│           sweep_number               int32 4B 0
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B b'not_set'
│           follow_mode                |S32 32B b'not_set'
│           sweep_fixed_angle          float32 4B 0.4999
├── Group: /sweep_1
│       Dimensions:                    (azimuth: 483, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB 1.104 1.104 ... 1.104 1.104
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:16:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           pulse_width                (azimuth) float32 2kB 0.0 0.0 0.0 ... 0.0 0.0 0.0
│           prt                        (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           prt_ratio                  (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           nyquist_velocity           (azimuth) float32 2kB 26.92 26.92 ... 26.92 26.92
│           unambiguous_range          (azimuth) float32 2kB 1.5e+05 1.5e+05 ... 1.5e+05
│           antenna_transition         (azimuth) int8 483B 0 0 0 0 0 0 0 ... 0 0 0 0 0 0
│           ...                         ...
│           VR                         (azimuth, range) float32 2MB -0.31 ... -25.83
│           sweep_number               int32 4B 1
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B b'not_set'
│           follow_mode                |S32 32B b'not_set'
│           sweep_fixed_angle          float32 4B 1.099
├── Group: /sweep_2
│       Dimensions:                    (azimuth: 482, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB 1.796 1.796 ... 1.796 1.796
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:17:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           pulse_width                (azimuth) float32 2kB 0.0 0.0 0.0 ... 0.0 0.0 0.0
│           prt                        (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           prt_ratio                  (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           nyquist_velocity           (azimuth) float32 2kB 26.92 26.92 ... 26.92 26.92
│           unambiguous_range          (azimuth) float32 2kB 1.5e+05 1.5e+05 ... 1.5e+05
│           antenna_transition         (azimuth) int8 482B 0 0 0 0 0 0 0 ... 0 0 0 0 0 0
│           ...                         ...
│           VR                         (azimuth, range) float32 2MB 0.3901 ... -23.2
│           sweep_number               int32 4B 2
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B b'not_set'
│           follow_mode                |S32 32B b'not_set'
│           sweep_fixed_angle          float32 4B 1.802
├── Group: /sweep_3
│       Dimensions:                    (azimuth: 483, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB 2.598 2.598 ... 2.598 2.598
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:17:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           pulse_width                (azimuth) float32 2kB 0.0 0.0 0.0 ... 0.0 0.0 0.0
│           prt                        (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           prt_ratio                  (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           nyquist_velocity           (azimuth) float32 2kB 26.92 26.92 ... 26.92 26.92
│           unambiguous_range          (azimuth) float32 2kB 1.5e+05 1.5e+05 ... 1.5e+05
│           antenna_transition         (azimuth) int8 483B 0 0 0 0 0 0 0 ... 0 0 0 0 0 0
│           ...                         ...
│           VR                         (azimuth, range) float32 2MB 0.2699 3.88 ... nan
│           sweep_number               int32 4B 3
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B b'not_set'
│           follow_mode                |S32 32B b'not_set'
│           sweep_fixed_angle          float32 4B 2.598
├── Group: /sweep_4
│       Dimensions:                    (azimuth: 481, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB 3.598 3.598 ... 3.598 3.598
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:18:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           pulse_width                (azimuth) float32 2kB 0.0 0.0 0.0 ... 0.0 0.0 0.0
│           prt                        (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           prt_ratio                  (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           nyquist_velocity           (azimuth) float32 2kB 26.92 26.92 ... 26.92 26.92
│           unambiguous_range          (azimuth) float32 2kB 1.5e+05 1.5e+05 ... 1.5e+05
│           antenna_transition         (azimuth) int8 481B 0 0 0 0 0 0 0 ... 0 0 0 0 0 0
│           ...                         ...
│           VR                         (azimuth, range) float32 2MB 21.18 10.64 ... nan
│           sweep_number               int32 4B 4
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B b'not_set'
│           follow_mode                |S32 32B b'not_set'
│           sweep_fixed_angle          float32 4B 3.598
├── Group: /sweep_5
│       Dimensions:                    (azimuth: 482, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB 4.708 4.708 ... 4.708 4.708
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:19:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           pulse_width                (azimuth) float32 2kB 0.0 0.0 0.0 ... 0.0 0.0 0.0
│           prt                        (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           prt_ratio                  (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           nyquist_velocity           (azimuth) float32 2kB 26.92 26.92 ... 26.92 26.92
│           unambiguous_range          (azimuth) float32 2kB 1.5e+05 1.5e+05 ... 1.5e+05
│           antenna_transition         (azimuth) int8 482B 0 0 0 0 0 0 0 ... 0 0 0 0 0 0
│           ...                         ...
│           VR                         (azimuth, range) float32 2MB -0.07034 ... nan
│           sweep_number               int32 4B 5
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B b'not_set'
│           follow_mode                |S32 32B b'not_set'
│           sweep_fixed_angle          float32 4B 4.702
├── Group: /sweep_6
│       Dimensions:                    (azimuth: 482, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB 6.471 6.471 ... 6.471 6.471
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:20:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           pulse_width                (azimuth) float32 2kB 0.0 0.0 0.0 ... 0.0 0.0 0.0
│           prt                        (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           prt_ratio                  (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           nyquist_velocity           (azimuth) float32 2kB 26.92 26.92 ... 26.92 26.92
│           unambiguous_range          (azimuth) float32 2kB 1.5e+05 1.5e+05 ... 1.5e+05
│           antenna_transition         (azimuth) int8 482B 0 0 0 0 0 0 0 ... 0 0 0 0 0 0
│           ...                         ...
│           VR                         (azimuth, range) float32 2MB -26.38 ... -24.67
│           sweep_number               int32 4B 6
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B b'not_set'
│           follow_mode                |S32 32B b'not_set'
│           sweep_fixed_angle          float32 4B 6.498
├── Group: /sweep_7
│       Dimensions:                    (azimuth: 484, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB 9.102 9.102 ... 9.102 9.102
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:21:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           pulse_width                (azimuth) float32 2kB 0.0 0.0 0.0 ... 0.0 0.0 0.0
│           prt                        (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           prt_ratio                  (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
│           nyquist_velocity           (azimuth) float32 2kB 26.92 26.92 ... 26.92 26.92
│           unambiguous_range          (azimuth) float32 2kB 1.5e+05 1.5e+05 ... 1.5e+05
│           antenna_transition         (azimuth) int8 484B 0 0 0 0 0 0 0 ... 0 0 0 0 0 0
│           ...                         ...
│           VR                         (azimuth, range) float32 2MB -0.4204 ... 11.4
│           sweep_number               int32 4B 7
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B b'not_set'
│           follow_mode                |S32 32B b'not_set'
│           sweep_fixed_angle          float32 4B 9.102
└── Group: /sweep_8
        Dimensions:                    (azimuth: 483, range: 996)
        Coordinates:
          * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
            elevation                  (azimuth) float32 2kB 12.8 12.8 ... 12.79 12.8
            time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:21:...
          * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
        Data variables: (12/18)
            pulse_width                (azimuth) float32 2kB 0.0 0.0 0.0 ... 0.0 0.0 0.0
            prt                        (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
            prt_ratio                  (azimuth) float32 2kB -9.999e+03 ... -9.999e+03
            nyquist_velocity           (azimuth) float32 2kB 26.92 26.92 ... 26.92 26.92
            unambiguous_range          (azimuth) float32 2kB 1.5e+05 1.5e+05 ... 1.5e+05
            antenna_transition         (azimuth) int8 483B 0 0 0 0 0 0 0 ... 0 0 0 0 0 0
            ...                         ...
            VR                         (azimuth, range) float32 2MB -12.58 ... nan
            sweep_number               int32 4B 8
            sweep_mode                 <U20 80B 'azimuth_surveillance'
            prt_mode                   |S32 32B b'not_set'
            follow_mode                |S32 32B b'not_set'
            sweep_fixed_angle          float32 4B 12.8
del ds, dtree

Alternate Method#

We can directly use xarray to read the data and then transform it to CF2 datatree.

ds = xr.open_dataset(file)
ds
<xarray.Dataset> Size: 35MB
Dimensions:                           (sweep: 9, r_calib: 1, time: 4343,
                                       range: 996)
Coordinates:
  * time                              (time) datetime64[ns] 35kB 2008-06-04T0...
  * range                             (range) float32 4kB 150.0 ... 1.494e+05
Dimensions without coordinates: sweep, r_calib
Data variables: (12/100)
    volume_number                     int32 4B ...
    platform_type                     |S32 32B ...
    primary_axis                      |S32 32B ...
    status_xml                        |S1 1B ...
    instrument_type                   |S32 32B ...
    radar_antenna_gain_h              float32 4B ...
    ...                                ...
    r_calib_index                     (time) int8 4kB ...
    measured_transmit_power_h         (time) float32 17kB ...
    measured_transmit_power_v         (time) float32 17kB ...
    scan_rate                         (time) float32 17kB ...
    DBZ                               (time, range) float32 17MB ...
    VR                                (time, range) float32 17MB ...
Attributes: (12/14)
    Conventions:         CF/Radial instrument_parameters radar_parameters rad...
    version:             1.2
    title:               TIMREX
    institution:         
    references:          
    source:              
    ...                  ...
    instrument_name:     SPOLRVP8
    site_name:           
    scan_name:           
    scan_id:             0
    platform_is_mobile:  false
    n_gates_vary:        false
radar = ds.xradar.to_cf2()
display(radar)
<xarray.DataTree 'root'>
Group: /
│   Dimensions:              (sweep: 9)
│   Coordinates:
│       latitude             float64 8B ...
│       longitude            float64 8B ...
│       altitude             float64 8B ...
│   Dimensions without coordinates: sweep
│   Data variables:
│       volume_number        int32 4B ...
│       platform_type        |S32 32B ...
│       primary_axis         |S32 32B ...
│       status_str           |S1 1B ...
│       instrument_type      |S32 32B ...
│       time_coverage_start  |S32 32B ...
│       time_coverage_end    |S32 32B ...
│       sweep_group_name     (sweep) <U7 252B 'sweep_0' 'sweep_1' ... 'sweep_8'
│       sweep_fixed_angle    (sweep) float32 36B ...
│   Attributes: (12/13)
│       Conventions:         CF/Radial instrument_parameters radar_parameters rad...
│       version:             1.2
│       title:               TIMREX
│       institution:         
│       references:          
│       source:              
│       ...                  ...
│       comment:             
│       instrument_name:     SPOLRVP8
│       site_name:           
│       scan_name:           
│       scan_id:             0
│       platform_is_mobile:  false
├── Group: /radar_parameters
│       Dimensions:                   ()
│       Data variables:
│           radar_antenna_gain_h      float32 4B ...
│           radar_beam_width_h        float32 4B ...
│           radar_beam_width_v        float32 4B ...
│           radar_antenna_gain_v      float32 4B ...
│           radar_receiver_bandwidth  float32 4B ...
├── Group: /radar_calibration
│       Dimensions:                   ()
│       Data variables: (12/45)
│           time                      |S32 32B ...
│           pulse_width               float32 4B ...
│           xmit_power_h              float32 4B ...
│           xmit_power_v              float32 4B ...
│           two_way_waveguide_loss_h  float32 4B ...
│           two_way_waveguide_loss_v  float32 4B ...
│           ...                        ...
│           test_power_h              float32 4B ...
│           test_power_v              float32 4B ...
│           receiver_slope_hc         float32 4B ...
│           receiver_slope_vc         float32 4B ...
│           receiver_slope_hx         float32 4B ...
│           receiver_slope_vx         float32 4B ...
├── Group: /georeferencing_correction
│       Dimensions:                            ()
│       Data variables: (12/16)
│           azimuth_correction                 float32 4B ...
│           vertical_velocity_correction       float32 4B ...
│           elevation_correction               float32 4B ...
│           longitude_correction               float32 4B ...
│           pitch_correction                   float32 4B ...
│           heading_correction                 float32 4B ...
│           ...                                 ...
│           radar_altitude_correction          float32 4B ...
│           tilt_correction                    float32 4B ...
│           northward_ground_speed_correction  float32 4B ...
│           rotation_correction                float32 4B ...
│           roll_correction                    float32 4B ...
│           drift_correction                   float32 4B ...
├── Group: /sweep_0
│       Dimensions:                    (azimuth: 483, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:15:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 483B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_1
│       Dimensions:                    (azimuth: 483, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:16:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 483B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_2
│       Dimensions:                    (azimuth: 482, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:17:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 482B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_3
│       Dimensions:                    (azimuth: 483, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:17:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 483B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_4
│       Dimensions:                    (azimuth: 481, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:18:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 481B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_5
│       Dimensions:                    (azimuth: 482, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:19:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 482B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_6
│       Dimensions:                    (azimuth: 482, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:20:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 482B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
├── Group: /sweep_7
│       Dimensions:                    (azimuth: 484, range: 996)
│       Coordinates:
│         * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
│           elevation                  (azimuth) float32 2kB ...
│           time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:21:...
│         * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
│       Data variables: (12/18)
│           sweep_number               int32 4B ...
│           sweep_mode                 <U20 80B 'azimuth_surveillance'
│           prt_mode                   |S32 32B ...
│           follow_mode                |S32 32B ...
│           sweep_fixed_angle          float32 4B ...
│           pulse_width                (azimuth) float32 2kB ...
│           ...                         ...
│           r_calib_index              (azimuth) int8 484B ...
│           measured_transmit_power_h  (azimuth) float32 2kB ...
│           measured_transmit_power_v  (azimuth) float32 2kB ...
│           scan_rate                  (azimuth) float32 2kB ...
│           DBZ                        (azimuth, range) float32 2MB ...
│           VR                         (azimuth, range) float32 2MB ...
└── Group: /sweep_8
        Dimensions:                    (azimuth: 483, range: 996)
        Coordinates:
          * azimuth                    (azimuth) float32 2kB 0.0 0.75 ... 358.5 359.2
            elevation                  (azimuth) float32 2kB ...
            time                       (azimuth) datetime64[ns] 4kB 2008-06-04T00:21:...
          * range                      (range) float32 4kB 150.0 300.0 ... 1.494e+05
        Data variables: (12/18)
            sweep_number               int32 4B ...
            sweep_mode                 <U20 80B 'azimuth_surveillance'
            prt_mode                   |S32 32B ...
            follow_mode                |S32 32B ...
            sweep_fixed_angle          float32 4B ...
            pulse_width                (azimuth) float32 2kB ...
            ...                         ...
            r_calib_index              (azimuth) int8 483B ...
            measured_transmit_power_h  (azimuth) float32 2kB ...
            measured_transmit_power_v  (azimuth) float32 2kB ...
            scan_rate                  (azimuth) float32 2kB ...
            DBZ                        (azimuth, range) float32 2MB ...
            VR                         (azimuth, range) float32 2MB ...