Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions profiles_eval/real_lidar_corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,11 @@ def _units(entry):
# ------------------------------------------------------------------
# Load data and compute NRB dataset
# ------------------------------------------------------------------
FILE = "/data/archive/sgp/sgpminimplC1.b1/sgpminimplC1.b1.20260214.000009.nc"
FILE = "/data/archive/sgp/sgpminimplC1.b1/sgpminimplC1.b1.20260612.000004.nc" # test case for Donna
FILE = "/data/archive/kcg/kcgmplpolfsM1.b1/kcgmplpolfsM1.b1.20240601.000009.nc"
FILE = "/data/archive/kcg/kcgminimplS1.b1/kcgminimplS1.b1.20240601.000000.nc" # test case from Damao
#FILE = "/data/archive/sgp/sgpmplpolfsC1.b1/sgpmplpolfsC1.b1.20251129.000006.nc" # [MPL] SGP test case #2
#FILE = "/data/archive/kcg/kcgmplpolfsM1.b1/kcgmplpolfsM1.b1.20240601.000009.nc" # [MPL] KCG test case #3
#FILE = "/data/archive/sgp/sgpminimplC1.b1/sgpminimplC1.b1.20260612.000004.nc" # [mini-MPL] SGP test case #1
#FILE = "/data/archive/sgp/sgpminimplC1.b1/sgpminimplC1.b1.20251129.000000.nc" # [mini-MPL] SGP test case #2
#FILE = "/data/archive/kcg/kcgminimplS1.b1/kcgminimplS1.b1.20240601.000000.nc" # [mini-MPL] KCG test case #3
ds = xr.open_dataset(FILE)
result = compute_nrb_dataset(ds, instrument_type="minimpl", config_dir="./configs",
deadtime_poly_degree=1, deadtime_n_extrap_samples=3)
Expand Down Expand Up @@ -588,14 +589,14 @@ def _units(entry):
da.plot.pcolormesh(
ax=ax_c, x="time", y="range",
cmap=cmap, vmin=vmin, vmax=vmax,
#cmap=cmap, vmin=0.0, vmax=0.08,
#cmap=cmap, vmin=0.0, vmax=0.2,
cbar_kwargs={"label": cb_label},
)
ax_c.xaxis.set_major_formatter(mdates.DateFormatter("%H:%M"))
t_base = plot_ds.time.values[0].astype('datetime64[D]')
#ax_c.set_xlim(t_base + np.timedelta64(14, 'h'), t_base + np.timedelta64(17, 'h'))
ax_c.set_ylim(float(plot_ds.range[0]), max_range_km)
#ax_c.set_ylim((0.5, 1.5))
#ax_c.set_ylim((0.0, 2.0))
ax_c.set_title(f"{title} Curtain")
ax_c.set_xlabel("Time (UTC)")
ax_c.set_ylabel("Range (km)")
Expand Down
23 changes: 14 additions & 9 deletions profiles_eval/real_prof_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,22 +586,26 @@ def load_and_process_arm_data(
data_path_template=data_path_template,
)

# Derive range units from the field attribute so that new
# instruments are handled correctly without touching the config.
range_nif = key_to_nif.get("range", "range")
_range_da = ds.get(range_nif, ds.coords.get(range_nif))
# Derive range units from the config, treated as the source of truth
# for the units of the range coordinate values. This ensures correct
# handling regardless of whether NetCDF file attributes are missing.
range_cfg_entry = _cfg_vars.get("range", {})
range_units = (
_range_da.attrs.get("units", "m") if _range_da is not None else "m"
range_cfg_entry.get("units", "m")
if isinstance(range_cfg_entry, dict)
else "m"
)

# Get the actual field name for range in the loaded dataset
range_nif = key_to_nif.get("range", "range")

# ------------------------------------------------------------------
# Capture native resolutions from primary dataset
# ------------------------------------------------------------------
native_time_res = _native_time_res_str(ds.time.values)
range_coord = ds.get(range_nif, ds.coords.get(range_nif))
native_range_res = (
_native_range_res_str(range_coord, range_units)
if range_coord is not None else "unknown"
_native_range_res_str(ds["range"], range_units)
if "range" in ds.coords else "unknown"
)

# ------------------------------------------------------------------
Expand Down Expand Up @@ -693,7 +697,8 @@ def load_and_process_arm_data(
if isinstance(v.get("background_cross_pol"), dict)
else v.get("background_cross_pol", ""),
] + correction_field_names
drop = [f for f in raw_fields_to_drop if f and f in ds_corrected]
# Only drop data_vars, not coordinates (e.g., 'range' used in both data and corrections)
drop = [f for f in raw_fields_to_drop if f and f in ds_corrected.data_vars]
ds = ds_corrected.drop_vars(drop, errors="ignore")

# ------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions profiles_eval/real_prof_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

TIME_MIN = np.datetime64("2026-03-10T20:00:00", "ns")
TIME_MAX = np.datetime64("2026-03-10T21:00:00", "ns")
#TIME_MIN = np.datetime64("2025-11-29T11:00:00", "ns")
#TIME_MAX = np.datetime64("2025-11-29T13:00:00", "ns")

# ARM nested archive: /data/archive/{site}/{site}{instrument_class}{facility}.{level}/
DATA_PATH_TEMPLATE = "/data/archive/{site}/{site}{instrument_class}{facility}.{level}"
Expand Down
10 changes: 7 additions & 3 deletions profiles_eval/real_prof_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def _finite_ylim(da):
def plot_profile_curtains(
variables: "OrderedDict[str, xr.DataArray]",
cmap: str = "viridis",
shared_norm: bool = True,
shared_norm: bool = False,
ylim: tuple[float, float] | None = None,
fig_width: float = 10.0,
panel_height: float = 3.0,
Expand All @@ -544,8 +544,12 @@ def plot_profile_curtains(
cmap : str, optional
Colormap name. Default ``"viridis"``.
shared_norm : bool, optional
When ``True`` (default), all panels share the same color scale,
making inter-instrument differences immediately visible.
When ``True``, all panels share the same color scale, making
inter-instrument differences immediately visible. Default is
``False`` so that each instrument is auto-scaled independently —
this avoids instruments with different physical units (e.g. raw
NRB counts/µs·km² vs. calibrated backscatter m⁻¹sr⁻¹) being
rendered on the same colour range.
ylim : tuple of float, optional
``(ymin, ymax)`` range axis limits in km.
fig_width : float, optional
Expand Down
Loading