Table of Contents

Class WeatherGridProcessorBase

Namespace
EncDotNet.S100.Datasets.Pipelines
Assembly
EncDotNet.S100.Datasets.Pipelines.dll

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:

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

gridSet WeatherGridSet

The grid set.

spec SpecRef

The file format and version, for example NetCDF/4.0.0.

fileName string

The dataset's file name, its stable id.

referenceTime DateTime?

The model run's reference time (UTC), or null when the data doesn't give one.

crsTransformFactory ICrsTransformFactory

Creates the transforms the headless compositor needs.

contentHash string

A 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

string

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

IReadOnlyList<DateTime>

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

IReadOnlyList<WeatherDatasetContent>

FileName

The dataset's file name.

public string FileName { get; }

Property Value

string

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

DatasetForecastRun

GridSet

The grid set the reader produced.

public WeatherGridSet GridSet { get; }

Property Value

WeatherGridSet

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

IReadOnlyList<string>

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

DatasetMetadata

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

DateTime?

Sources

One coverage source per parameter group, in the order the groups first appear.

public IReadOnlyList<WeatherCoverageSource> Sources { get; }

Property Value

IReadOnlyList<WeatherCoverageSource>

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

SpecRef

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

TimeSemantics

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

context RenderContext

Optional render context (palette, mariner, time step).

cancellationToken CancellationToken

Cancellation 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

gridSet WeatherGridSet

The grid set.

spec SpecRef

The file format and version.

times IReadOnlyList<DateTime>

The valid times, in any order.

Returns

DatasetMetadata

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 S125DatasetData or S102CoverageData).

Describe(WeatherParameter, string?)

Describes one parameter of the grid set for Contents.

protected static WeatherDatasetContent Describe(WeatherParameter parameter, string? reason)

Parameters

parameter WeatherParameter

The parameter.

reason string

Why an unknown parameter isn't used, or null for the default.

Returns

WeatherDatasetContent

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

IEnumerable<WeatherDatasetContent>

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

disposing bool

Always true.

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

query CoverageSampleQuery

The 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

latitude double

Latitude, WGS-84 degrees.

longitude double

Longitude, WGS-84 degrees.

time DateTime?

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

featureRef string

Ignored.

Returns

FeatureInfo

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

widthPixels int

Output width in pixels.

heightPixels int

Output height in pixels.

context RenderContext

Palette, time step, symbol scale and viewport.

background RgbaColor?

Background fill; opaque white by default.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<SKBitmap>

A new bitmap owned by the caller.