Class WeatherGridProcessorBase
The format-neutral part of a weather grid processor: everything after the reader has produced a WeatherGridSet. The NetCDF-CF processor (NetCdfDatasetProcessor) and the GRIB2 processor (GribDatasetProcessor) derive from it and only open their files (design note weather-sources.md §3.3).
public abstract class WeatherGridProcessorBase : IDatasetProcessor, ICoveragePortrayalSource, IHeadlessImageRenderer, ITimeAwareDatasetProcessor, ICoverageSampler, ILoadedDatasetProjection, IDisposable
- Inheritance
-
WeatherGridProcessorBase
- Implements
- Derived
- Inherited Members
- Extension Methods
Remarks
What it provides:
- Drawing. One WeatherCoverageSource per parameter group (CreateForGroups(WeatherGridSet, SpecRef, int)), drawn with the code-defined weather styles that apply to it and are switched on, through BuildAsync(WeatherCoverageSource, IReadOnlyList<WeatherCoverageStyle>, string, RenderContext?, string?, CancellationToken). Every applicable style is offered; each render draws those that IsDrawnWith(EcdisDisplaySettings?) the context's EcdisDisplay: the map-wide switches in LayerVisibility (the viewer's Display controls Weather section), or each style's default when unset. By default the wave height fill, wind barbs and isobars are drawn and the wind speed fill and wave arrows aren't (design note §10.1). Each drawn style is one layer stack entry, on the plane and priority of design note §5; a style switched off isn't built, so it isn't listed. The overview level of each source is chosen from the viewport's cells per pixel, as S-102 does.
- Time. ITimeAwareDatasetProcessor: the union of the parameters' valid times, forecast steps (analysis steps when the data has no reference time) drawn from the nearest step within the typical step, and the model run (ForecastRun).
- Sampling and picking. ICoverageSampler returns CoverageFieldsSamples with each field's quantity and unit; GetCoverageInfo(double, double, DateTime?) leads with NotForNavigationNotice.
- Headless rendering (IHeadlessImageRenderer) through the HeadlessCompositor, and the catalog payload (WeatherGridDatasetData) through ILoadedDatasetProjection.
It lives in EncDotNet.S100.Datasets.Pipelines rather than
EncDotNet.S100.Datasets.Weather because the capabilities it
implements (IHeadlessImageRenderer,
ILoadedDatasetProjection, HeadlessCompositor)
are defined here, and this project already references every dataset
project; the format readers don't reference it, or each other.
Constructors
WeatherGridProcessorBase(WeatherGridSet, SpecRef, string, DateTime?, ICrsTransformFactory, string?)
Creates the processor over a grid set a reader produced.
protected WeatherGridProcessorBase(WeatherGridSet gridSet, SpecRef spec, string fileName, DateTime? referenceTime, ICrsTransformFactory crsTransformFactory, string? contentHash = null)
Parameters
gridSetWeatherGridSetThe grid set.
specSpecRefThe file format and version, for example
NetCDF/4.0.0.fileNamestringThe dataset's file name, its stable id.
referenceTimeDateTime?The model run's reference time (UTC), or null when the data doesn't give one.
crsTransformFactoryICrsTransformFactoryCreates the transforms the headless compositor needs.
contentHashstringA hash of the file's bytes for ContentScope, or null.
Fields
NotForNavigationNotice
The first line of every pick report on weather data (design note §3.1).
public const string NotForNavigationNotice = "Weather model data, not for navigation."
Field Value
Properties
AvailableTimes
The ordered, distinct set of time steps available in the dataset. Empty when the dataset carries no temporal dimension.
public IReadOnlyList<DateTime> AvailableTimes { get; }
Property Value
Contents
What the file holds, for info output: every parameter of the grid
set (the ones the weather table knows are used; unknown ones aren't
drawn or sampled, with why), then what the reader left out of the grid
set altogether, with why (for GRIB2, fields with an unsupported
template such as CCSDS; for NetCDF, variables on other dimensions).
public IReadOnlyList<WeatherDatasetContent> Contents { get; }
Property Value
FileName
The dataset's file name.
public string FileName { get; }
Property Value
ForecastRun
The model run: the model the file names (CF source,
institution or title; for GRIB2 the generating process,
file name or centre, see Model) and its
reference time when the data gives one.
public DatasetForecastRun ForecastRun { get; }
Property Value
GridSet
The grid set the reader produced.
public WeatherGridSet GridSet { get; }
Property Value
LayerKeys
The layer keys offered, one per style that applies, in stack order. Which of them a render draws depends on its display settings (IsDrawnWith(EcdisDisplaySettings?)).
public IReadOnlyList<string> LayerKeys { get; }
Property Value
Metadata
The lightweight, product-agnostic DatasetMetadata for this dataset — its declared specification and, where cheaply derivable, its geographic extent, horizontal CRS, display-scale window, and temporal coverage. Overriding processors derive it once from the already-parsed dataset (never a second parse) and cache it, so hosts can frame a viewport, register a layer, draw an out-of-scale indicator, or gate visibility without re-reading the dataset. The default implementation does not override this and instead returns a fresh, minimal value carrying only Spec on each access; processors that can supply an extent (and other facts) override it with the derive-once-and-cache behaviour above. See issue #467 / #460.
public DatasetMetadata Metadata { get; }
Property Value
Remarks
Derived once from the grid: the cells' WGS-84 extent (half a cell beyond the outer nodes), EPSG:4326, and the first to last valid time.
ReferenceTime
The model run's reference time (UTC), or null when the data doesn't give one.
public DateTime? ReferenceTime { get; }
Property Value
Sources
One coverage source per parameter group, in the order the groups first appear.
public IReadOnlyList<WeatherCoverageSource> Sources { get; }
Property Value
Spec
The product specification (name + edition) this dataset declares
conformance to. Each per-spec processor returns a fixed name (e.g.
"S-101"); the edition portion is populated from the dataset itself
(HDF5 productSpecification attribute, GML application
namespace, S-101 ProductSpecificationEdition, etc.) when known,
otherwise defaults to SpecVersion default.
public SpecRef Spec { get; }
Property Value
TimeSemantics
What the time steps are, which one is drawn between steps, and how long a step stays valid. Defaults to Default: forecast steps, nearest within the typical step.
public TimeSemantics TimeSemantics { get; }
Property Value
Methods
BuildCoveragePortrayalAsync(RenderContext?, CancellationToken)
Builds an immutable, Mapsui-free snapshot of this dataset's coverage portrayal for the supplied render context. Implementations run under a render gate and materialise the styled coverage (including the selected time step) so the result is safe to convert to Mapsui layers off the gate.
public Task<CoveragePortrayalResult> BuildCoveragePortrayalAsync(RenderContext? context = null, CancellationToken cancellationToken = default)
Parameters
contextRenderContextOptional render context (palette, mariner, time step).
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<CoveragePortrayalResult>
The Mapsui-free coverage portrayal result.
BuildMetadata(WeatherGridSet, SpecRef, IReadOnlyList<DateTime>)
Builds the dataset metadata of a weather grid: the cells' WGS-84 extent (half a cell beyond the outer nodes), EPSG:4326 and the time coverage. Shared by the processors and the registrations' metadata readers.
public static DatasetMetadata BuildMetadata(WeatherGridSet gridSet, SpecRef spec, IReadOnlyList<DateTime> times)
Parameters
gridSetWeatherGridSetThe grid set.
specSpecRefThe file format and version.
timesIReadOnlyList<DateTime>The valid times, in any order.
Returns
CreateLoadedData()
Allocates the LoadedDatasetData variant wrapping this processor's already-parsed model. Never re-reads the source bytes.
public LoadedDatasetData CreateLoadedData()
Returns
- LoadedDatasetData
The catalog payload wrapping the resident model (e.g. an
S125DatasetDataorS102CoverageData).
Describe(WeatherParameter, string?)
Describes one parameter of the grid set for Contents.
protected static WeatherDatasetContent Describe(WeatherParameter parameter, string? reason)
Parameters
parameterWeatherParameterThe parameter.
reasonstringWhy an unknown parameter isn't used, or null for the default.
Returns
DescribeContents()
Lists Contents. The default lists the grid set's parameters, unknown ones as not in the weather parameter table; readers add what they left out.
protected virtual IEnumerable<WeatherDatasetContent> DescribeContents()
Returns
Dispose()
Releases the file and the render gate.
public void Dispose()
Dispose(bool)
Releases the reader's file. Called once, from Dispose().
protected abstract void Dispose(bool disposing)
Parameters
FindSites(CoverageSampleQuery)
Finds the places in this dataset that can answer a sample at the query's point: the grid node nearest to it, or every station of a station-series dataset (the nearest across datasets is chosen later).
public CoverageSiteSearch FindSites(CoverageSampleQuery query)
Parameters
queryCoverageSampleQueryThe point to sample, with the transforms that reproject it into the dataset's CRS.
Returns
- CoverageSiteSearch
The sites, or an empty search when the dataset does not cover the point. Implementations may throw ObjectDisposedException when the dataset was closed during the call.
Remarks
Every known parameter at the grid node nearest the point, at the step nearest the requested time; see FindSites(CoverageSampleQuery).
GetCoverageInfo(double, double, DateTime?)
Samples every parameter at the grid node nearest the point and the step
nearest time (the first step when null).
The first attribute is NotForNavigationNotice (a
NavigationNotice(string) row), then the
model run and valid time, then each value with its unit: wave heights
in metres, wind speed in knots (raw value in m/s), directions in
degrees ("from"; current direction "to"), periods in seconds, sea
surface temperature in degrees Celsius (raw value in kelvin), current
speed in knots (raw value in m/s).
public FeatureInfo? GetCoverageInfo(double latitude, double longitude, DateTime? time)
Parameters
latitudedoubleLatitude, WGS-84 degrees.
longitudedoubleLongitude, WGS-84 degrees.
timeDateTime?The selected time step, or null.
Returns
- FeatureInfo
The pick, or null outside the grid or where no parameter has data.
GetFeatureInfo(string)
Always null: a weather grid has no discrete features; see GetCoverageInfo(double, double, DateTime?).
public FeatureInfo? GetFeatureInfo(string featureRef)
Parameters
featureRefstringIgnored.
Returns
RenderHeadlessAsync(int, int, RenderContext?, RgbaColor?, CancellationToken)
Renders the weather layers to a bitmap through the headless compositor, framed on the grid (or on Viewport), at the context's time step (the first step when unset).
public Task<SKBitmap> RenderHeadlessAsync(int widthPixels, int heightPixels, RenderContext? context = null, RgbaColor? background = null, CancellationToken cancellationToken = default)
Parameters
widthPixelsintOutput width in pixels.
heightPixelsintOutput height in pixels.
contextRenderContextPalette, time step, symbol scale and viewport.
backgroundRgbaColor?Background fill; opaque white by default.
cancellationTokenCancellationTokenCancellation token.