From c0a884dc9985eeefb56b6d8298d4bd511d2dc88a Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 26 Apr 2026 15:24:17 -0500 Subject: [PATCH] fix(contact): align Mechanism panel with Propagation Analysis ducts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The radar-only RainScatterClassifier sees ducting only when HRRR's pressure-level M-profile flagged it. Sounding-detected and gradient- inferred ducts surface in elevation_profile.ducts via the analysis pipeline — promote those into :tropo_duct so the Mechanism badge agrees with the narrative. --- .../live/contact_live/show.ex | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/microwaveprop_web/live/contact_live/show.ex b/lib/microwaveprop_web/live/contact_live/show.ex index 7a77e287..f05f7c3c 100644 --- a/lib/microwaveprop_web/live/contact_live/show.ex +++ b/lib/microwaveprop_web/live/contact_live/show.ex @@ -624,13 +624,31 @@ defmodule MicrowavepropWeb.ContactLive.Show do elevation_profile ) + mechanism = upgrade_mechanism(socket.assigns[:mechanism], elevation_profile) + assign(socket, elevation_profile: elevation_profile, propagation_analysis: propagation_analysis, - data_sources: data_sources + data_sources: data_sources, + mechanism: mechanism ) end + # The radar-only RainScatterClassifier sees ducting only when HRRR's + # pressure-level M-profile already flagged it. Sounding and gradient- + # inferred ducts surface in elevation_profile.ducts via the analysis + # pipeline — promote those into :tropo_duct so the Mechanism panel + # agrees with the Propagation Analysis narrative. + defp upgrade_mechanism(nil, _profile), do: nil + defp upgrade_mechanism(:tropo_duct, _profile), do: :tropo_duct + defp upgrade_mechanism(:likely_rainscatter, _profile), do: :likely_rainscatter + + defp upgrade_mechanism(mechanism, %{ducts: [_ | _] = ducts}) do + if Enum.any?(ducts, &Map.get(&1, :likely)), do: :tropo_duct, else: mechanism + end + + defp upgrade_mechanism(mechanism, _profile), do: mechanism + defp load_iemre(contact) do case Weather.iemre_for_contact(contact) do %{hourly: hourly} = obs when is_list(hourly) and hourly != [] ->