fix(contact): align Mechanism panel with Propagation Analysis ducts

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.
This commit is contained in:
Graham McIntire 2026-04-26 15:24:17 -05:00
parent 4b10d63e67
commit c0a884dc99
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -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 != [] ->