hydromt_sfincs.components.quadtree.SfincsQuadtreeGrid#

class hydromt_sfincs.components.quadtree.SfincsQuadtreeGrid(model: SfincsModel)[source]#

Quadtree grid component attached to an SfincsModel.

All layers live in the data attribute as a xugrid.UgridDataset, but a component may claim the layers it is responsible for through a grid_variables attribute. write() keeps those out of sfincs.nc unless called with write_components=True; the component writes them to its own UGRID netcdf through _write_layers(). Anything not claimed stays in the main file.

Elevation, the SFINCS mask and the SnapWave mask stay in qtrfile. Their component read() methods ensure this grid is loaded, while their write() methods are no-ops; persistence is handled here. Component data properties expose their own layers with the mesh and attributes; this grid remains the full dataset and the destination for set() calls.

Initialise the component with a back-reference to its parent model.

__init__(model: SfincsModel) → None[source]#

Initialise the component with a back-reference to its parent model.

Methods

__init__(model)

Initialise the component with a back-reference to its parent model.

clear_overlay()

Invalidate the cached edge-overlay dataframe.

close()

Clean up all open datasets.

create(x0, y0, nmax, mmax, dx, dy, rotation, ...)

Build the Quadtree grid.

create_from_region(region[, res, crs, ...])

Setup a quadtree grid from a region.

create_index_cog(filename, filename_topobathy)

Write a COG raster mapping each pixel to a quadtree cell index.

create_topobathy_cog(filename, elevation_list)

Write a COG raster sampling the model topobathy.

cut_inactive_cells()

Remove cells that are outside the active mask from the grid.

finish_write()

Finish the write functionality after cleanup was called for all components in the model.

get_indices_at_points(x, y)

Return the cell index at each (x, y) sample.

get_mesh(grid_name[, include_data])

Return a specific grid topology from mesh based on grid_name.

map_overlay(file_name[, xlim, ylim, color, ...])

Render a PNG map overlay of the grid edges.

read([filename, read_components])

Reads a quadtree netcdf file and stores it in the QuadtreeGrid object.

set(data, *[, name, grid_name, overwrite_grid])

Add data to mesh.

snap_to_grid(polyline)

Snap a set of lines to the edges of the quadtree grid.

test_equal(other)

Test if two components are equal.

write([filename, write_components])

Writes a quadtree SFINCS netcdf file.

write_region([filename, to_wgs84, ...])

Write the model region to file.

Attributes

bounds

Returns model mesh bounds.

crs

Return the coordinate reference system of the regular grid.

data

Model static mesh data.

data_catalog

Return the data catalog of the model this component is associated with.

empty_mask

Return an all-zero mask with the shape of the current grid.

exterior

Return the outer boundary of the active grid as polygons.

face_coordinates

Return the (x, y) coordinates of the cell face centres.

is_empty

Check whether the mesh is empty or not.

mask

Return the mask of the quadtree grid.

mesh_datasets

Dictionnary of grid names and corresponding UgridDataset topology and data variables in mesh.

mesh_gdf

Returns dict of geometry of grids in mesh as a gpd.GeoDataFrame.

mesh_grids

Dictionary of grid names and Ugrid topologies in mesh.

mesh_names

List of grid names in mesh.

model

Return the model object this component is associated with.

name_in_model

Find the name of the component in the parent model components.

region

Return the outer boundary of the active grid as polygons

root

Return the root of the model this component is associated with.