- Schema: Era5Profile → NarrProfile; table renamed via migration rename_era5_profiles_to_narr_profiles (ALTER TABLE + rename indexes, atomic and instant, no row rewrite) - Weather helpers: find_nearest_era5/era5_for_contact/era5_profiles_for_path → find_nearest_narr/narr_for_contact/narr_profiles_for_path - BackfillEnqueueWorker: :era5 → :narr type (virtual, no narr_status column); reconcile_stale_queued_to_unavailable and status_priority_order now skip virtual types via @virtual_types. Fixes the prod crash where the cron tried to update a non-existent era5_status column. - ContactWeatherEnqueueWorker: build_era5_jobs → build_narr_jobs, era5_jobs_for_contact → narr_jobs_for_contact - ContactLive: @era5 → @narr, maybe_enqueue_era5 → maybe_enqueue_narr; UI label "ERA5 (0.25°)" → "NARR (32 km)" - Cron (runtime.exs): args types list now "narr" instead of "era5" - /status: progress row, status-by-type card, totals.narr_profiles, and table-count lookup all target narr_profiles - Drop obsolete Era5CdsJob schema + era5_cds_jobs table (inspection artifact from the retired CDS pipeline; 34 orphan rows in prod) - Misc docstring/comment cleanups (skew_t, about, wgrib2, propagation_train) Includes a regression test for the virtual-type crash.
48 lines
1.6 KiB
Elixir
48 lines
1.6 KiB
Elixir
defmodule Microwaveprop.Weather.NarrProfile do
|
|
@moduledoc """
|
|
Profile rows fetched from NCEP NARR (North American Regional Reanalysis)
|
|
for pre-2014 contacts where the HRRR archive doesn't reach.
|
|
|
|
The table was originally created as `era5_profiles` for the retired
|
|
ERA5/CDS pipeline and reused 1:1 by NARR; the
|
|
`rename_era5_profiles_to_narr_profiles` migration renames it to
|
|
`narr_profiles`.
|
|
"""
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
|
|
|
@primary_key {:id, :binary_id, autogenerate: true}
|
|
@foreign_key_type :binary_id
|
|
|
|
schema "narr_profiles" do
|
|
field :valid_time, :utc_datetime
|
|
field :lat, :float
|
|
field :lon, :float
|
|
field :profile, {:array, :map}
|
|
field :hpbl_m, :float
|
|
field :pwat_mm, :float
|
|
field :surface_temp_c, :float
|
|
field :surface_dewpoint_c, :float
|
|
field :surface_pressure_mb, :float
|
|
field :surface_refractivity, :float
|
|
field :min_refractivity_gradient, :float
|
|
field :ducting_detected, :boolean, default: false
|
|
field :duct_characteristics, {:array, :map}
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
@type t :: %__MODULE__{}
|
|
|
|
@required_fields ~w(valid_time lat lon)a
|
|
@optional_fields ~w(profile hpbl_m pwat_mm surface_temp_c surface_dewpoint_c surface_pressure_mb surface_refractivity min_refractivity_gradient ducting_detected duct_characteristics)a
|
|
|
|
@spec changeset(t() | Ecto.Changeset.t(), map()) :: Ecto.Changeset.t()
|
|
def changeset(profile, attrs) do
|
|
profile
|
|
|> cast(attrs, @required_fields ++ @optional_fields)
|
|
|> validate_required(@required_fields)
|
|
|> unique_constraint([:lat, :lon, :valid_time])
|
|
end
|
|
end
|