arlmet.File#

class arlmet.File(path, mode='r', source=None, grid=None, vertical_axis=None)[source]#

Read or write an ARL meteorology file.

Parameters:
  • path (path-like) – Location of the ARL file on disk.

  • mode ({"r", "w"}, default "r") – File mode. Read mode scans the file immediately; write mode expects the caller to provide source, grid, and vertical_axis before creating records.

  • source (str, optional) – Four-character ARL source identifier used when writing.

  • grid (Grid, optional) – Horizontal grid metadata used when writing.

  • vertical_axis (VerticalAxis, optional) – Vertical axis metadata used when writing.

path#

Filesystem path for the ARL file.

Type:

pathlib.Path

mode#

Active file mode.

Type:

{“r”, “w”}

times#

Sorted valid times discovered in the file.

Type:

list[pandas.Timestamp]

source#

ARL source identifier.

Type:

str

grid#

Horizontal grid metadata.

Type:

Grid

vertical_axis#

Vertical coordinate metadata.

Type:

VerticalAxis

variables#

Lazy accessor for variable-wise views inherited from RecordCollection.

Type:

VariableAccessor

create_grid(...)[source]#

Build and attach a Grid when writing a new file.

create_recordset(time, forecast=None)[source]#

Create a writable RecordSet for one valid time.

sample_points(points, variables, ...)[source]#

Interpolate fields at arbitrary lon/lat/z sample points.

close()[source]#

Flush pending writes and release the file handle.

Examples

>>> import arlmet
>>> with arlmet.File("met.arl") as met:
...     met.times[0]
Timestamp('2024-07-18 00:00:00')

Methods

File.__init__(path[, mode, source, grid, ...])

File.add_record(time, variable, *, level[, ...])

Add one writable DataRecord, creating its RecordSet if needed.

File.close()

Flush pending writes and close the managed binary file handle.

File.create_grid(nx, ny, pole_lat, pole_lon, ...)

Create and attach the horizontal grid metadata for a writable file.

File.create_recordset(time, *[, forecast])

Create a writable RecordSet for one valid time.

File.register_diff_binding(diff_name, ...)

Record and validate the explicit parent binding for a generated DIF name.

File.sample_points(points, variables, *[, ...])

Sample fields from this file at arbitrary lon/lat/z points.

File.to_dataset(*[, drop_variables, bbox, ...])

Project this file into the simplified analysis Dataset representation.

Attributes

File.grid

File.handle

File.record_length

File.records

List of all DataRecords in the file across all RecordSets.

File.size

File.source

File.times

Return a sorted list of timestamps in the file.

File.vertical_axis