Geometry module

The module of the package is used to generate the output files after the processing of the raw data is completed. With this module it is possible to convert the weather radar data into a cartesian coordinate system and save it as a netcdf file.

import wrainfo as wrf
[2]:
import xarray as xr
import warnings
warnings.filterwarnings('ignore')

Note

This is only an example how the geometry module works. If you want to save all processed variables in the dataset after clutter and attenuation correction as well as precipitation estimation, please check the json file.

We load an scnx-file as follows.

[3]:
file_path="/tests/data/raw/2022/04/05/2006_20220405_123000_000.scnx.gz"
path_to_config_file="/tests/data/test_settings_wrainfo.json"
[4]:
file_scnx=wrf.reader.read_single_file(file_path,
                                      path=path_to_config_file,
                                      grp="sweep_0")
display(file_scnx)
<xarray.Dataset>
Dimensions:     (azimuth: 720, range: 936)
Coordinates:
  * azimuth     (azimuth) float32 0.25 0.75 1.25 1.75 ... 358.8 359.2 359.8
    elevation   (azimuth) float32 0.5 0.5 0.5 0.5 0.5 ... 0.5 0.5 0.5 0.5 0.5
  * range       (range) float32 37.5 112.5 187.5 ... 7.009e+04 7.016e+04
    time        datetime64[ns] 2022-04-05T12:30:01
    rtime       (azimuth) datetime64[ns] 2022-04-05T12:30:09.601952500 ... 20...
    longitude   float64 13.24
    latitude    float64 53.55
    altitude    float64 38.0
    sweep_mode  <U20 'azimuth_surveillance'
Data variables:
    RATE        (azimuth, range) float32 ...
    DBZH        (azimuth, range) float32 ...
    VRADH       (azimuth, range) float32 ...
    ZDR         (azimuth, range) float32 ...
    KDP         (azimuth, range) float32 ...
    PHIDP       (azimuth, range) float32 ...
    RHOHV       (azimuth, range) float32 ...
    WRADH       (azimuth, range) float32 ...
    QUAL        (azimuth, range) uint16 ...
Attributes:
    fixed_angle:  0.5

Georeferencing

In the function furuno_georeferencing the configuration file is loaded by defining the target coordinate system using the EPSG code and the pixel resolution of the projected data. In addition, the variables to be included in the georeferenced dataset are defined in the configuration file. Afterwards the source and target coordinates are determined in the function. For each variable a new data array with the cartesian coordinates is created and then the single data arrays are merged to a xarray dataset.

Note

The function works only for a dataset of one time step!

[6]:
ds_georef = wrf.geometry.furuno_georeferencing(ds=file_scnx,
                                               path=path_to_config_file)
display(ds_georef)
<xarray.Dataset>
Dimensions:              (y: 1400, x: 1400, time: 1)
Coordinates:
  * time                 (time) datetime64[ns] 2022-04-05T12:30:01
  * x                    (x) float32 3.135e+05 3.136e+05 ... 4.537e+05 4.538e+05
  * y                    (y) float32 5.865e+06 5.865e+06 ... 6.005e+06 6.006e+06
    transverse_mercator  int64 0
Data variables:
    RATE                 (time, y, x) float32 0.31 0.31 0.31 0.0 ... 0.0 0.0 0.0
    DBZH                 (time, y, x) float32 -78.54 -78.54 ... -79.02 -79.02
    ZDR                  (time, y, x) float32 0.39 0.39 0.39 ... 1.31 0.65 0.65
    KDP                  (time, y, x) float32 nan nan nan nan ... nan nan nan
    PHIDP                (time, y, x) float32 48.9 48.9 48.9 ... -132.9 -132.9
    RHOHV                (time, y, x) float32 0.107 0.107 ... 0.3583 0.3583
Attributes:
    Conventions:      CF-1.5
    elevation_angle:  0.5

Now we can plot the georeferenced dataset.

[7]:
ds_georef.DBZH.plot()
[7]:
<matplotlib.collections.QuadMesh at 0x14d6eb3265b0>
../_images/jupyter_notebooks_geometry_module_12_1.png

Output as NetCDF

The processed data can be saved as NetCDF file. For this, we use the function furuno_sweep_to_netcdf. The configuration file is loaded by defining the output path and the variable, which are saved in the output files. The time dimension is used for create the name of the output file and also the output path. If the file was save in the output directory, you get an information where the file was saved.

Note

The function works only for a georeferenced xarray dataset of one time tep!

[8]:
wrf.geometry.furuno_cartesian_sweep_to_netcdf(ds=ds_georef,
                                              path=path_to_config_file,
                                              data_type="Level1")
-- output to tests/data/output/2022/04/05/elev_0.5/NB_WR2120_20220405_123001UTC_elev_0.5_Level1.nc

Library Reference

Seealso

Get more information about the geometry module in the library reference section.