model

Retrieves SMB and firn model parameters for known models and from model definition files

Source code

General Attributes and Methods

FirnCorr.io.load_database(extra_databases: list = [])[source]

Load the JSON database of model files

Parameters:
extra_databases: list, default []

A list of additional databases to load, as either JSON file paths or dictionaries

Returns:
parameters: dict

Database of model parameters

class FirnCorr.io.model(directory: str | Path | None = None, **kwargs)[source]

Retrieves SMB and firn model parameters for named models

Attributes:
compressed: bool

Model files are gzip compressed

directory: str, pathlib.Path or None, default None

Working data directory for SMB and firn models

extra_databases: list, default []

Additional databases for model parameters

verify: bool

Verify that all model files exist

from_database(m: str, group: tuple = ('ais', 'gris'))[source]

Create a model object from database of known models

Parameters:
m: str

Model name

group: tuple, default (“ais”, “gris”)

Model region(s) to extract

from_file(definition_file: str | Path | IOBase, **kwargs)[source]

Create a model object from an input definition file

Parameters:
definition_file: str, pathlib.Path or io.IOBase

Model definition file for creating model object

from_dict(d: dict)[source]

Create a model object from a dictionary of parameters

Parameters:
d: dict

Model object parameters

to_dict(**kwargs)[source]

Create a dictionary from a model object

Parameters:
fields: list, default all

List of model attributes to output

serialize: bool, default False

Serialize dictionary for JSON output

property gzip: str

Returns suffix for gzip compression

property engine: str

Returns the read-write engine for the model

property file_format: str

Returns the file format for the model

property crs

Coordinate reference system of the model

pathfinder(model_file: str | Path | list)[source]

Completes file paths and appends gzip suffix

Parameters:
model_file: str, pathlib.Path or list

Model file(s) to complete

validate_format()[source]

Asserts that the model format is a known type

serialize(d: dict)[source]

Encodes dictionary to be JSON serializable

Parameters:
d: dict

Parameters to serialize

open_dataset(**kwargs)[source]

Open model files as an xarray Dataset

Parameters:
kwargs: dict

Additional keyword arguments for opening model files

Returns:
ds: xarray.Dataset

SMB and firn model data

open_datatree(group: tuple = ('ais', 'gris'), **kwargs)[source]

Open model files as an xarray DataTree

Parameters:
group: tuple, default (‘ais’, ‘gris’)

List of model types to extract

kwargs: dict

Additional keyword arguments for opening model files

Returns:
dtree: xr.DataTree

SMB and firn model data