fix(logging): log silently dropped parse failures in grib extractor/wgrib2

- extractor: log warning when point falls outside Lambert grid bounds
- wgrib2: log warning when inventory lines are unparseable
- hrrr_client: optimize wgrib2_match_pattern with uniq_by + map_join
- gefs_client: same optimization
This commit is contained in:
Graham McIntire 2026-05-07 12:15:26 -05:00
parent a4921029e5
commit a8bd29f78c
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
4 changed files with 6 additions and 2 deletions

View file

@ -232,7 +232,7 @@ defmodule Microwaveprop.Weather.GefsClient do
end end
defp wgrib2_match_pattern do defp wgrib2_match_pattern do
vars = @surface_messages |> Enum.map(& &1.var) |> Enum.uniq() |> Enum.join("|") vars = @surface_messages |> Enum.uniq_by(& &1.var) |> Enum.map_join("|", & &1.var)
":(#{vars}):" ":(#{vars}):"
end end

View file

@ -6,6 +6,8 @@ defmodule Microwaveprop.Weather.Grib2.Extractor do
alias Microwaveprop.Weather.Grib2.Section alias Microwaveprop.Weather.Grib2.Section
alias Microwaveprop.Weather.Grib2.SimplePacking alias Microwaveprop.Weather.Grib2.SimplePacking
require Logger
@doc """ @doc """
Extract weather values from a GRIB2 binary blob at the given lat/lon. Extract weather values from a GRIB2 binary blob at the given lat/lon.
@ -129,6 +131,7 @@ defmodule Microwaveprop.Weather.Grib2.Extractor do
[{point, linear_index({i, j}, grid.nx, grid.scan_mode)}] [{point, linear_index({i, j}, grid.nx, grid.scan_mode)}]
{:error, :outside_grid} -> {:error, :outside_grid} ->
Logger.warning("Extractor: point #{lat},#{lon} outside Lambert grid bounds")
[] []
end end
end) end)

View file

@ -309,6 +309,7 @@ defmodule Microwaveprop.Weather.Grib2.Wgrib2 do
[%{var: var, level: level, datetime: parse_wgrib2_date(date)}] [%{var: var, level: level, datetime: parse_wgrib2_date(date)}]
_ -> _ ->
Logger.warning("wgrib2: unparseable inventory line: #{String.slice(line, 0, 120)}")
[] []
end end
end) end)

View file

@ -425,7 +425,7 @@ defmodule Microwaveprop.Weather.HrrrClient do
end end
defp wgrib2_match_pattern(wanted) do defp wgrib2_match_pattern(wanted) do
vars = wanted |> Enum.map(& &1.var) |> Enum.uniq() |> Enum.join("|") vars = wanted |> Enum.uniq_by(& &1.var) |> Enum.map_join("|", & &1.var)
":(#{vars}):" ":(#{vars}):"
end end