Skip to main content

Class: RawScalarField<ArrayType, GridType>

Defined in: RawField.ts:112

A class representing a raw 2D field of gridded data, such as height or u wind.

Extends​

Type Parameters​

Type Parameter
ArrayType extends TypedArray
GridType extends Grid

Constructors​

Constructor​

new RawScalarField<ArrayType, GridType>(grid, data): RawScalarField<ArrayType, GridType>

Defined in: RawField.ts:123

Create a data field.

Parameters​

ParameterTypeDescription
gridGridTypeThe grid on which the data are defined
dataArrayTypeThe data, which should be given as a 1D array in row-major order, with the first element being at the lower-left corner of the grid.

Returns​

RawScalarField<ArrayType, GridType>

Overrides​

ExpressionScalarField.constructor

Properties​

PropertyModifierTypeOverridesDefined in
datareadonlyArrayType-RawField.ts:114
gridreadonlyGridTypeExpressionScalarField.gridRawField.ts:113

Methods​

add()​

add(other): ComputedScalarField<ArrayType, GridType>

Defined in: RawField.ts:91

Add this field to another scalar. The computation occurs on the GPU if the resulting field is used in a plot component or on the CPU if renderCPU() is called on the resulting field.

Parameters​

ParameterTypeDescription
othernumber | ExpressionScalarField<ArrayType, GridType>Scalar to add to this field

Returns​

ComputedScalarField<ArrayType, GridType>

A ComputedScalarField representing the added field

Inherited from​

ExpressionScalarField.add


divide()​

divide(other): ComputedScalarField<ArrayType, GridType>

Defined in: RawField.ts:81

Divide this field by another scalar. The computation occurs on the GPU if the resulting field is used in a plot component or on the CPU if renderCPU() is called on the resulting field.

Parameters​

ParameterTypeDescription
othernumber | ExpressionScalarField<ArrayType, GridType>Scalar to divide this field by

Returns​

ComputedScalarField<ArrayType, GridType>

A ComputedScalarField representing the divided field

Inherited from​

ExpressionScalarField.divide


getContours()​

getContours(opts): Promise<ContourData>

Defined in: RawField.ts:230

Get contour data as an object with each contour level being a separate property.

Parameters​

ParameterTypeDescription
optsFieldContourOptsOptions for doing the contouring

Returns​

Promise<ContourData>

contour data as an object


multiply()​

multiply(other): ComputedScalarField<ArrayType, GridType>

Defined in: RawField.ts:71

Multiply this field by another scalar. The computation occurs on the GPU if the resulting field is used in a plot component or on the CPU if renderCPU() is called on the resulting field.

Parameters​

ParameterTypeDescription
othernumber | ExpressionScalarField<ArrayType, GridType>Scalar to multiply this field by

Returns​

ComputedScalarField<ArrayType, GridType>

A ComputedScalarField representing the multiplied field

Inherited from​

ExpressionScalarField.multiply


renderCPU()​

renderCPU(): RawScalarField<ArrayType, GridType>

Defined in: RawField.ts:251

Run computations on a scalar field on the CPU (for a RawScalarField, this is a no-op). The function blocks the main thread, so avoid calling it if possible.

Returns​

RawScalarField<ArrayType, GridType>

The computed grid in a RawScalarField

Overrides​

ExpressionScalarField.renderCPU


sampleField()​

sampleField(lon, lat): number

Defined in: RawField.ts:286

Sample this field at a given latitude and longitude.

Parameters​

ParameterTypeDescription
lonnumberLongitude of the sample in degrees east
latnumberLatitude of the sample in degrees north

Returns​

number

The value of the nearest grid point, or NaN if the point is outside the grid.

Overrides​

ExpressionScalarField.sampleField


sampleFieldWithCoord()​

sampleFieldWithCoord(lon, lat): object

Defined in: RawField.ts:276

Sample this field at a given latitude and longitude.

Parameters​

ParameterTypeDescription
lonnumberLongitude of the sample in degrees east
latnumberLatitude of the sample in degrees north

Returns​

object

The value of the nearest grid point along with the grid point latitude and longitude, or NaNs if the point is outside the grid.

sample​

sample: number

sample_lat​

sample_lat: number

sample_lon​

sample_lon: number

Overrides​

ExpressionScalarField.sampleFieldWithCoord


subtract()​

subtract(other): ComputedScalarField<ArrayType, GridType>

Defined in: RawField.ts:101

Subtract another scalar from this field. The computation occurs on the GPU if the resulting field is used in a plot component or on the CPU if renderCPU() is called on the resulting field.

Parameters​

ParameterTypeDescription
othernumber | ExpressionScalarField<ArrayType, GridType>Scalar to subtract from this field

Returns​

ComputedScalarField<ArrayType, GridType>

A ComputedScalarField representing the subtracted field

Inherited from​

ExpressionScalarField.subtract


updateTexImageData()​

updateTexImageData(gl, image_mag_filter, fill_textures): Map<string, WGLTexture>

Defined in: RawField.ts:185

Parameters​

ParameterType
glWebGLAnyRenderingContext
image_mag_filternumber
fill_texturesMap<string, WGLTexture> | null

Returns​

Map<string, WGLTexture>

Overrides​

ExpressionScalarField.updateTexImageData


aggregateFields()​

static aggregateFields<ArrayType, GridType>(func, ...args): RawScalarField<ArrayType, GridType>

Defined in: RawField.ts:243

Create a new field by aggregating a number of fields using a specific function. This computation occurs on the CPU.

Type Parameters​

Type Parameter
ArrayType extends TypedArray
GridType extends Grid

Parameters​

ParameterTypeDescription
func(...args) => numberA function that will be applied each element of the field. It should take the same number of arguments as fields you have and return a single number.
...argsRawScalarField<ArrayType, GridType>[]The RawScalarFields to aggregate

Returns​

RawScalarField<ArrayType, GridType>

a new gridded field

Example​

// Compute wind speed from u and v
wind_speed_field = RawScalarField.aggreateFields(Math.hypot, u_field, v_field);