arlmet.IndexRecord#

class arlmet.IndexRecord(header, source, forecast, minutes, pole_lat, pole_lon, tangent_lat, tangent_lon, grid_size, orientation, cone_angle, sync_x, sync_y, sync_lat, sync_lon, reserved, nx, ny, nz, vertical_flag, index_length, levels)[source]#

Index record describing one ARL time step and its contained variables.

Parameters:
  • header (Header) – The header information for the index record.

  • source (str) – Source identifier (4 characters).

  • forecast (int) – Forecast hour.

  • minutes (int) – Minutes after the hour.

  • pole_lat (float) – Pole latitude position of the grid projection. For lat-lon grids: max latitude of the grid.

  • pole_lon (float) – Pole longitude position of the grid projection. For lat-lon grids: max longitude of the grid.

  • tangent_lat (float) – Reference latitude at which the grid spacing is defined. For conical and mercator projections, this is the latitude at which the grid touches the surface. For lat-lon grids: grid spacing in degrees latitude.

  • tangent_lon (float) – Reference longitude at which the grid spacing is defined. For conical and mercator projections, this is the longitude at which the grid touches the surface. For lat-lon grids: grid spacing in degrees longitude.

  • grid_size (float) – Grid spacing in km at the reference position. For lat-lon grids: value of zero signals that the grid is a lat-lon grid.

  • orientation (float) – Angle at the reference point made by the y-axis and the local direction of north. For lat-lon grids: 0

  • cone_angle (float) – Angle between the axis and the surface of the cone. For regular projections it equals the latitude at which the grid is tangent to the earth’s surface. Stereographic: ±90, Mercator: 0, Lambert Conformal: 0 ~ 90 For lat-lon grids: 0

  • sync_x (float) – Grid x-coordinate used to equate a position on the grid with a position on earth. This is a unitless grid index (FORTRAN 1-based).

  • sync_y (float) – Grid y-coordinate used to equate a position on the grid with a position on earth. This is a unitless grid index (FORTRAN 1-based).

  • sync_lat (float) – Earth latitude corresponding to the grid position (sync_x, sync_y). For lat-lon grids: latitude of the (0,0) grid point position.

  • sync_lon (float) – Earth longitude corresponding to the grid position (sync_x, sync_y). For lat-lon grids: longitude of the (0,0) grid point position.

  • nx (int) – Number of grid points in the x-direction (columns).

  • ny (int) – Number of grid points in the y-direction (rows).

  • nz (int) – Number of vertical levels.

  • vertical_flag (int) – Vertical coordinate system type (1=sigma, 2=pressure, 3=terrain, 4=hybrid).

  • index_length (int) – Total length of the index record in bytes, including fixed and variable portions.

  • levels (sequence of LvlInfo) – Variable manifests for each stored vertical level.

N_BYTES_FIXED#

Number of bytes in the fixed portion of the index record (108 bytes).

Type:

int

time#

The valid time of the record, calculated from the header time and minutes.

Type:

pd.Timestamp

from_position(file, position)[source]#

Read and parse an index record from a file handle.

tobytes()[source]#

Serialize the exact used bytes of the index record.

to_record_bytes(record_size)[source]#

Serialize the index record padded to one ARL record.

Examples

>>> from arlmet.header import Header
>>> from arlmet.index import IndexRecord
>>> header = Header(
...     year=2024,
...     month=7,
...     day=18,
...     hour=0,
...     forecast=0,
...     level=0,
...     grid=(0, 0),
...     variable="INDX",
...     exponent=0,
...     precision=0.0,
...     initial_value=0.0,
... )
>>> isinstance(header.time, pd.Timestamp)
True

Methods

IndexRecord.__init__(header, source, ...)

IndexRecord.from_position(file, position)

Create an IndexRecord by reading from a file at a specific position.

IndexRecord.parse_extended(data, nz)

Parse the variable-length portion of an index record.

IndexRecord.parse_fixed(data)

Parse the fixed 108-byte portion of an index record from raw bytes.

IndexRecord.serialize_extended()

Serialize the variable-length level/variable portion of the index record.

IndexRecord.serialize_fixed([index_length])

Serialize the fixed 108-byte portion of the index record.

IndexRecord.to_record_bytes(record_length)

Serialize the index record padded to one full ARL record.

IndexRecord.tobytes()

Serialize the exact used bytes of the index record, including its header.

Attributes

IndexRecord.N_BYTES_FIXED

IndexRecord.grid

Construct a Grid from the index record's projection parameters.

IndexRecord.time

Valid time calculated from header time plus minutes offset.

IndexRecord.total_nx

Total x grid points including thousands from header grid letters.

IndexRecord.total_ny

Total y grid points including thousands from header grid letters.

IndexRecord.vertical_axis

Construct the vertical axis definition from the index record.

IndexRecord.header

IndexRecord.source

IndexRecord.forecast

IndexRecord.minutes

IndexRecord.pole_lat

IndexRecord.pole_lon

IndexRecord.tangent_lat

IndexRecord.tangent_lon

IndexRecord.grid_size

IndexRecord.orientation

IndexRecord.cone_angle

IndexRecord.sync_x

IndexRecord.sync_y

IndexRecord.sync_lat

IndexRecord.sync_lon

IndexRecord.reserved

IndexRecord.nx

IndexRecord.ny

IndexRecord.nz

IndexRecord.vertical_flag

IndexRecord.index_length

IndexRecord.levels