From 43239dbb155420ef976bbc413a6a0c16cdc69ce1 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 15 May 2026 09:06:23 -0500 Subject: [PATCH] =?UTF-8?q?fix(path):=20show=20non-zero=20gas/O=E2=82=82/H?= =?UTF-8?q?=E2=82=82O=20rates=20on=20loss=20budget=20detail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit format_number rounds to 1 decimal, so the tiny per-km coefficients (o2_db_km: 0.007 at 10 GHz, gas rate ~0.007 dB/km) all displayed as '0.0'. Added format_small with 4-decimal precision for those fields. --- lib/microwaveprop_web/live/path_live.ex | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/microwaveprop_web/live/path_live.ex b/lib/microwaveprop_web/live/path_live.ex index 4f5a8e76..99cdfb4d 100644 --- a/lib/microwaveprop_web/live/path_live.ex +++ b/lib/microwaveprop_web/live/path_live.ex @@ -464,6 +464,9 @@ defmodule MicrowavepropWeb.PathLive do defp format_number(n) when is_float(n), do: :erlang.float_to_binary(n, decimals: 1) defp format_number(n), do: to_string(n) + defp format_small(n) when is_float(n), do: :erlang.float_to_binary(n, decimals: 4) + defp format_small(n), do: to_string(n) + defp format_km_mi(km), do: Microwaveprop.Format.distance_km(km) defp format_utc_hour(%DateTime{} = dt), do: Calendar.strftime(dt, "%H:%M") @@ -727,16 +730,13 @@ defmodule MicrowavepropWeb.PathLive do
- Gas rate: {format_number( - Float.round( - (@result.loss_budget.o2 + @result.loss_budget.h2o) / max(@result.dist_km, 0.001), - 4 - ) + Gas rate: {format_small( + (@result.loss_budget.o2 + @result.loss_budget.h2o) / max(@result.dist_km, 0.001) )} dB/km
- H₂O: {format_number(@result.band_config.h2o_coeff)} dB/km/g · - O₂: {format_number(@result.band_config.o2_db_km)} dB/km + H₂O: {format_small(@result.band_config.h2o_coeff)} dB/km/g · + O₂: {format_small(@result.band_config.o2_db_km)} dB/km
<%= if @result.conditions do %>
Abs humidity avg: {format_number(@result.conditions.abs_humidity)} g/m³