Skip to content

Commit d837757

Browse files
author
Robert Jackson
committed
ADD: XSAPR
1 parent 73ab23b commit d837757

3 files changed

Lines changed: 44 additions & 23 deletions

File tree

src/radclss/config/default_config.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@
7676
"signal_to_noise_ratio_copolar_v",
7777
"normalized_coherent_power",
7878
"normalized_coherent_power_v",
79+
],
80+
"radar_xsapr": [
81+
"classification_mask",
82+
"censor_mask",
83+
"uncorrected_copol_correlation_coeff",
84+
"uncorrected_differential_phase",
85+
"uncorrected_differential_reflectivity",
86+
"uncorrected_differential_reflectivity_lag_1",
87+
"uncorrected_mean_doppler_velocity_h",
88+
"uncorrected_mean_doppler_velocity_v",
89+
"uncorrected_reflectivity_h",
90+
"uncorrected_reflectivity_v",
91+
"uncorrected_spectral_width_h",
92+
"uncorrected_spectral_width_v",
93+
"signal_to_noise_ratio_copolar_v",
94+
"normalized_coherent_power",
95+
"normalized_coherent_power_v",
96+
"radar_echo_classification"
7997
],
8098
"met": [
8199
"base_time",

src/radclss/core/radclss_core.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import act
55
import numpy as np
66
import pandas as pd
7+
import traceback
78

89

910
from ..util.column_utils import (
@@ -201,8 +202,10 @@ def radclss(
201202
)
202203
columns[k].append(result)
203204

204-
except Exception:
205+
except Exception as e:
205206
result = None
207+
if verbose:
208+
traceback.print_exc()
206209
if verbose:
207210
if result is not None:
208211
print(
@@ -710,7 +713,7 @@ def _get_nexrad_wrapper(time_str):
710713
site = base_station
711714
site = site.upper()
712715

713-
if instrument == "kazr2":
716+
if instrument == "kazr2" or instrument == "kazr":
714717
_instrument_tasks.append(
715718
(
716719
k,

src/radclss/util/column_utils.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def _vpt_to_column_timeseries(radar, height_bins):
150150
]
151151
data_vars = {}
152152
for key in radar.fields:
153+
print(key, radar.fields[key]["data"].dtype)
153154
arr = np.ma.filled(radar.fields[key]["data"], np.nan).astype(float)
154155
attrs = {
155156
tag: radar.fields[key][tag] for tag in da_meta if tag in radar.fields[key]
@@ -518,7 +519,6 @@ def subset_points(
518519
for lat, lon, site in zip(lats, lons, sites):
519520
# Make sure we are interpolating from the radar's location above sea level
520521
# NOTE: interpolating throughout Troposphere to match sonde to in the future
521-
522522
if "vpt" in radar.metadata["scan_mode"]:
523523
if radar.metadata.get("facility_id", "") == site:
524524
da = _vpt_to_column_timeseries(radar, height_bins)
@@ -563,27 +563,27 @@ def subset_points(
563563
da = da.sortby("height")
564564
valid = np.isfinite(da["height"])
565565
n_valid = int(valid.sum())
566+
interpolated = False
567+
dvars = da.data_vars
568+
for v in dvars:
569+
if np.all(np.isnan(da[v].values)):
570+
da = da.drop(v)
566571
if n_valid > 0:
567-
try:
568-
# Drop all NaNs
569-
da = (
570-
da.dropna("height")
571-
.sortby("height")
572-
.interp(height=height_bins)
573-
)
574-
except pd.errors.InvalidIndexError:
575-
da = da.drop_duplicates("height", keep="first")
576-
577-
valid = np.isfinite(da["height"])
578-
da = (
579-
da.dropna("height")
580-
.sortby("height")
581-
.interp(height=height_bins)
582-
)
583-
time_offset = time_offset.drop_duplicates(
584-
"height", keep="first"
585-
)
586-
else:
572+
da_clean = da.dropna("height").sortby("height")
573+
if da_clean.sizes.get("height", 0) > 0:
574+
try:
575+
da = da_clean.interp(height=height_bins)
576+
except pd.errors.InvalidIndexError:
577+
da_clean = da_clean.drop_duplicates(
578+
"height", keep="first"
579+
)
580+
da = da_clean.interp(height=height_bins)
581+
time_offset = time_offset.drop_duplicates(
582+
"height", keep="first"
583+
)
584+
interpolated = True
585+
586+
if not interpolated:
587587
target_height = xr.DataArray(
588588
height_bins, dims="height", name="height"
589589
)

0 commit comments

Comments
 (0)