file_handler#

Read, write, and convert gridded setup files.

The module provides shared helpers for NetCDF, ESRI ASCII, and GeoTIFF-style workflows, including coordinate normalization, header creation, encoding cleanup, grid metadata handling, and output provenance.

Authors#

  • Simon Lüdke

Classes#

ChunkType(value)

Define Types of chunking.

GridDefinition(template, dims)

Container to preserve a dataset's spatial grid metadata.

Functions#

chunk_dataset(ds, chunk_type, available_mem_gib)

Chunk xarray.DataSet depending on chunk_type and available memory.

chunk_dataset_space_and_time(ds, ...[, var_name])

Chunk dataset adjusting chunk size to avaiable memory.

chunk_dataset_space_only(ds, available_mem_gib)

Chunk only in space (lat/lon), leaving time whole, sized to available memory.

create_header(ds[, output_path, ...])

Write a header file from a dataset.

crop_file_by_mask(ds, mask_file)

Crop file by mask.

get_coord_values(ds[, lat, lon])

Get latitude or longitude values from DataSet.

get_dataset_from_path(path[, var_name, ...])

Load a dataset from a file, directory, or pattern.

get_grid(ds[, data_vars])

Extract a grid definition from ds.

get_xarray_ds_from_file(file_path[, ...])

Read file and return xarray dataset.

read_ascii_to_xarray(filepath[, var_name, ...])

Read an mHM readable asci file to an xarray dataset.

set_grid(data, grid, var_name[, data_attrs])

Attach data to a preserved grid definition.

write_xarray_to_ascii(dataset, filepath[, ...])

Write xarray Dataset to an ASCII file that can be read by mHM.

write_xarray_to_file(ds, file_path[, ...])

Write xarray Datasets to file with file type depending on the file suffix.

write_xarray_to_netcdf(ds, file_path[, ...])

Write an xarray Dataset or DataArray to a NetCDF file.