Store surface observations (ASOS) and upper-air soundings (RAOB) alongside QSOs for atmospheric propagation correlation. Three new tables: weather_stations, surface_observations, and soundings with JSONB profiles and pre-computed derived parameters (refractivity, gradients, duct detection, stability indices). Includes IEM API client for historical data import and import script seeded with 95 ASOS + 9 sounding stations from PropCast coverage area.
33 lines
883 B
Elixir
33 lines
883 B
Elixir
defmodule Microwaveprop.Weather.Station do
|
|
@moduledoc false
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
|
|
|
@primary_key {:id, :binary_id, autogenerate: true}
|
|
@foreign_key_type :binary_id
|
|
|
|
schema "weather_stations" do
|
|
field :station_code, :string
|
|
field :station_type, :string
|
|
field :wmo_number, :integer
|
|
field :name, :string
|
|
field :lat, :float
|
|
field :lon, :float
|
|
field :elevation_m, :float
|
|
field :state, :string
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
@required_fields ~w(station_code station_type name lat lon)a
|
|
@optional_fields ~w(wmo_number elevation_m state)a
|
|
|
|
def changeset(station, attrs) do
|
|
station
|
|
|> cast(attrs, @required_fields ++ @optional_fields)
|
|
|> validate_required(@required_fields)
|
|
|> validate_inclusion(:station_type, ~w(asos sounding))
|
|
|> unique_constraint([:station_code, :station_type])
|
|
end
|
|
end
|