Table of Contents

Class WeatherGridLayout

Namespace
EncDotNet.S100.Datasets.Weather
Assembly
EncDotNet.S100.Datasets.Weather.dll

How a file's grid (WeatherNativeGrid) maps onto the normalised WeatherGrid, and the code that reorders a decoded step to match (design note weather-sources.md §3.4).

public sealed class WeatherGridLayout
Inheritance
WeatherGridLayout
Inherited Members

Remarks

Normalisation does four things:

  • Rows that run north to south are flipped, so the origin is the southern row.
  • Columns that run west are flipped, so columns run east.
  • Longitudes are moved into −180 to 180. A grid that lies on one side of 180° is shifted as a whole: a 0 to 360 grid entirely east of 180° (for example 185°E to 225°E) gets −360. A global grid has its columns at 180° and above moved to the west, and a repeated wrap-around column (0° and 360°) is dropped.
  • Missing values become NaN.

A regional grid that truly crosses the antimeridian, such as 175°E to 225°E (175°E to 135°W), has no contiguous −180 to 180 form and is rejected with UnsupportedWeatherGridException (open question §10.3).

Properties

ColumnRotation

For a global grid, the number of columns (after any flip) moved from the east end to the west end so the grid starts at −180°; otherwise 0.

public int ColumnRotation { get; }

Property Value

int

ColumnsFlipped

Whether the file's columns run west and are flipped.

public bool ColumnsFlipped { get; }

Property Value

bool

DroppedColumns

The number of repeated wrap-around columns dropped from a global grid whose last column repeats its first (for example 0° and 360°).

public int DroppedColumns { get; }

Property Value

int

Grid

The normalised grid.

public WeatherGrid Grid { get; }

Property Value

WeatherGrid

Native

The grid as the file stores it.

public WeatherNativeGrid Native { get; }

Property Value

WeatherNativeGrid

RowsFlipped

Whether the file's rows run north to south and are flipped.

public bool RowsFlipped { get; }

Property Value

bool

Methods

Create(WeatherNativeGrid)

Works out the normalised grid for native.

public static WeatherGridLayout Create(WeatherNativeGrid native)

Parameters

native WeatherNativeGrid

The grid as the file stores it.

Returns

WeatherGridLayout

The layout.

Exceptions

UnsupportedWeatherGridException

The grid has no points, a zero or non-finite increment, latitudes outside ±90°, or crosses the antimeridian without being global.

Normalize(ReadOnlySpan<float>, IReadOnlyList<float>?)

Reorders one decoded step from the file's order into the normalised grid's order, replacing missing values with NaN.

public float[] Normalize(ReadOnlySpan<float> nativeValues, IReadOnlyList<float>? missingValues = null)

Parameters

nativeValues ReadOnlySpan<float>

The step's values in the file's row-major order, of length Rows × Columns.

missingValues IReadOnlyList<float>

Sentinel values that mark missing points, for example a CF _FillValue and missing_value. NaN is always missing.

Returns

float[]

A new array of length CellCount.

Exceptions

ArgumentException

nativeValues has the wrong length.