From 4d694e3ffdba4f28d72f0311319b86906de0afc7 Mon Sep 17 00:00:00 2001 From: Max Grover Date: Fri, 12 Apr 2024 08:30:32 -0500 Subject: [PATCH] ADD: Add frequency in sigmet/iris IO (#1557) --- pyart/io/sigmet.py | 12 ++++++++++-- tests/io/test_sigmet.py | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pyart/io/sigmet.py b/pyart/io/sigmet.py index e0965af99f..a1cf739161 100644 --- a/pyart/io/sigmet.py +++ b/pyart/io/sigmet.py @@ -7,6 +7,7 @@ import warnings import numpy as np +from scipy.constants import lambda2nu from ..config import FileMetadata, get_fillvalue from ..core.radar import Radar @@ -386,6 +387,7 @@ def read_sigmet( beam_width_v = filemetadata("radar_beam_width_v") pulse_width = filemetadata("pulse_width") prt_ratio = filemetadata("prt_ratio") + frequency = filemetadata("frequency") prt_value = 1.0 / sigmetfile.product_hdr["product_end"]["prf"] prt["data"] = prt_value * np.ones(total_rays, dtype="float32") @@ -403,8 +405,13 @@ def read_sigmet( prt_mode["data"] = np.array(nsweeps * ["fixed"], dtype="S") prt_ratio["data"] = np.ones(total_rays, dtype="float32") - wavelength_cm = sigmetfile.product_hdr["product_end"]["wavelength"] - nv_value = wavelength_cm / (10000.0 * 4.0 * prt_value) * prf_multiplier + wavelength_m = sigmetfile.product_hdr["product_end"]["wavelength"] / 10000.0 + + # Compute the frequency from the wavelength + frequency["data"] = np.array([lambda2nu(wavelength_m)], dtype="float32") + + # Compute the nyquist velocity from the wavelength + nv_value = wavelength_m / (4.0 * prt_value) * prf_multiplier nyquist_velocity["data"] = nv_value * np.ones(total_rays, dtype="float32") beam_width_h["data"] = np.array( [bin4_to_angle(task_config["task_misc_info"]["horizontal_beamwidth"])], @@ -428,6 +435,7 @@ def read_sigmet( "radar_beam_width_h": beam_width_h, "radar_beam_width_v": beam_width_v, "pulse_width": pulse_width, + "frequency": frequency, } if prf_multiplier != 1: prf_flag = filemetadata("prf_flag") diff --git a/tests/io/test_sigmet.py b/tests/io/test_sigmet.py index 05fd8e4d35..3495439126 100644 --- a/tests/io/test_sigmet.py +++ b/tests/io/test_sigmet.py @@ -387,3 +387,9 @@ def test_1byte_datatype(): result = pyart.io._sigmetfile.convert_sigmet_data(data_type, data, nbins) assert np.all(result == -31.5) assert result.shape == (2, 2) + + +def test_frequency(): + frequency = radar.instrument_parameters["frequency"] + frequency["units"] == "s-1" + assert_almost_equal(frequency["data"], 9.670725e09)