@@ -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