nlmod Logo

Contents:

  • Getting Started
    • Getting Python
    • Installing nlmod
    • Using nlmod
    • Dependencies
  • Data Sources
    • Downloading surface water data
      • AHN
      • Layer ‘waterdeel’ from bgt
        • Add minimum surface height around surface water bodies
        • Plot ‘bronhouder’
      • level areas
        • Plot summer stage
        • Add stages to bgt-data
      • Save the data to use in other notebooks as well
    • Using information from GeoTOP
      • Download GeoTOP
      • Add hydrological properties (kh and kv)
        • Based on lithok
        • Based on lithok and strat
      • Aggregate voxels to GeoTOP-layers
      • Aggregate voxels to REGIS-layers
      • Using stochastic data from GeoTOP
    • Downloading meteorological data
      • Generate a model Datset
      • Calculate recharge by subtracting evaporation from precipitation
      • Store precipitation and evaporation to seperate variables
      • Seperate the meteorological measurement values and the station locations
  • Example Models
    • Building a groundwater model from scratch
      • Model parameters
      • Create model dataset
      • Set time discretisation
      • Start building model
      • Add wells
      • Add river
      • Write and run Simulation
      • Load heads
      • Plot heads
      • Plot heads in all layers
    • Building a model anywhere in the Netherlands
      • Model settings
      • Download data
      • Create model
      • Write and Run
      • Visualise
    • Building a model with local grid refinement
      • Model settings
      • Download data
      • Create model
      • Local grid refinement
      • Write and Run
      • Visualise
    • A groundwater model for Schoonhoven
      • Model settings
      • Download data
        • layer ‘waterdeel’ from bgt
        • KNMI
        • REGIS
      • Add grid refinement
      • Add information about time
      • Add knmi recharge to the model dataset
      • Create a groundwater flow model
      • Process surface water
        • Lek as river
        • Other surface water as drains
        • Add lake
      • Run the model
      • Post-processing
        • Get the simulated head
        • Plot the average head in the first layer on a map
        • Plot the average head in a cross-section, from north to south
        • plot a time series at a certain location
        • plot the lake stages
      • Compare with BRO measurements
        • Plot some properties of the first layer
      • Add pathlines
    • Stromingen example: keeping scripts simple
      • Import Python packages
      • Define spatial and temporal properties
      • Get data for the current extent
      • Generate grid with a refinement zone
      • Generate a model
      • Add recharge to the model
      • Add surface water to the model
      • Run model
      • Post-processing
      • References
    • Groundwater transport modeling
  • Utilities
    • Modifying model layers
      • Get data
      • Split layers
      • Combine layers
      • Set new model top
      • Set layer top
      • Set layer bottom
      • Set layer thickness
      • Set minimum layer thickness
    • Caching data in nlmod
      • Cache directory
      • Caching
      • Caching steps
        • Caching functions
      • Checking the cache
      • Clearing the cache
      • Apply caching to a function
      • Technicalities and discussion
        • Notes
        • Storing cache on disk
    • Gridding vector data
      • Grid types
      • Vector to grid
        • Points
        • Lines
        • Polygons
        • Intersect vector data with grid
        • Aggregate parameters per model cell
      • Grid to reclist
        • Mask and layer
        • Only active cells
        • First active_layer
        • Reclist columns
        • Vertex model to reclist
    • Resampling raster data
      • Grid types
        • structured grid
        • structured grid with nan value
        • vertex grid
        • vertex grid with nan
      • Structured grid to fine structured grid
        • Without NaNs
        • With NaNs
        • Rectangular Bivariate Spline
        • Rectangular Bivariate Spline with nans
      • Structured grid to locally refined grid
        • WIthout NaNs
      • Locally refined grid to structured grid
        • Without NaNs
        • With NaNs
      • Fill nan values
        • Structured grid
        • vertex grid
      • Real world example
        • Transform ahn data to structured grid
        • Transform ahn data to vertex grid
    • Exporting model data to GIS
      • Model types
        • structured grid
        • vertex grid
      • Export vector data
        • structured
        • vertex grid
      • Export griddata
        • structured grid
        • vertex grid
      • Add symbology (QGIS)
    • Plot methods in nlmod
      • Maps
      • Cross-sections
      • Animation
      • Time series
  • Workflows
    • Generating model datasets
      • Get REGIS data
      • Define some properties of the grid
      • Regrid data
      • Add data to existing grid
    • Working with grid rotation
      • Generate a model Dataset
      • Use a disv-grid
      • Add AHN
      • Download surface water
      • Download knmi-data
      • Generate flopy-model
      • Add surface water
      • Run the model and read the heads
      • Plot the heads in layer 1
    • Aggregating surface water
      • Model settings
        • layer ‘waterdeel’ from bgt
      • Build model
      • Add surface water
        • Intersect surface water shape with grid
        • Aggregate parameters per model cell
        • Build stress period data
        • Create RIV package
      • Write + run model
      • Visualize results
    • Particle Tracking with MODPATH
      • To-Do
      • Groundwater Flow Model
      • Modpath
        • Backward tracking
        • Forward tracking
        • Backward tracking from general head boundaries
        • Forward tracking from each cell in the top layer
    • Particle Tracking with PRT
      • Setup
        • Packages
        • Logging
        • Load base model
      • PRT
        • Forward
        • Backward and refined
    • Comparing modelled heads to observations
      • Get the modeled heads
      • Interpolating heads
    • Voronoi Example
  • Advanced Stress Packages
    • The Lake Package
      • Define model extent and model workspace
      • Download and prepare data
        • Combine surface water data
      • Generate a model dataset
      • Split surface water shapes by grid
      • Improve model dataset
        • Set the top of the model
        • Set time dimension
        • Download recharge data
      • Generate and run model
        • Generate a FloPy sim and gwf
        • Meteorological stresses
        • Lake package for the Henschotermeer
        • Drain package for all other surface water
        • Write input-files and run Modflow 6
      • Post-processing
        • Plot the head in the top layer
        • Plot the Lake stage
        • Plot a cross-section
        • Plot a water balance of the lake
    • Unsaturated Zone Flow
      • Import packages and setup logging
      • Generate a model Dataset
      • Generate a simulation (sim) and groundwater flow (gwf) object
      • Run model with RCH and EVT packages
      • Run model with UZF package
      • Compare models
  • API-docs
    • nlmod
      • read
        • _assert_as_data_array_is_none()
        • _delete_tiles_from_config_in_data()
        • _download_ahn_ellipsis()
        • _download_ahn_hwh()
        • _download_and_save_json_file()
        • _download_tiles_ellipsis()
        • _download_tiles_hwh()
        • _get_tiles_from_file()
        • _rename_identifier()
        • _round_coordinates()
        • _save_tiles_from_config_in_data()
        • _update_ellipsis_tiles_in_data()
        • discretize_ahn()
        • download_ahn()
        • download_ahn1()
        • download_ahn2()
        • download_ahn3()
        • download_ahn4()
        • download_ahn5()
        • download_ahn6()
        • download_ahn_along_line()
        • download_ahn_at_point()
        • download_latest_ahn_from_wcs()
        • get_ahn()
        • get_ahn1()
        • get_ahn2()
        • get_ahn3()
        • get_ahn4()
        • get_ahn5()
        • get_ahn_along_line()
        • get_ahn_at_point()
        • get_configuration()
        • get_latest_ahn_from_wcs()
        • _update_bronhouder_json()
        • download_bgt()
        • get_bgt()
        • get_bgt_layers()
        • get_bronhouder_names()
        • read_bgt_gml()
        • read_bgt_zipfile()
        • _get_kh_kv_from_df()
        • _handle_nans_in_stochastic_approach()
        • _save_excel_files_as_csv()
        • add_kh_and_kv()
        • add_top_and_botm()
        • aggregate_to_ds()
        • download_geotop()
        • get_geotop()
        • get_kh_kv_table()
        • get_lithok_colors()
        • get_lithok_props()
        • get_strat_props()
        • to_model_layers()
        • discretize_bathymetry()
        • download_bathymetry()
        • get_bathymetry()
        • get_dataset_jarkus()
        • get_jarkus_tilenames()
        • get_netcdf_tiles()
        • _add_ts_to_ds()
        • _download_knmi_at_locations()
        • _get_locations_structured()
        • _get_locations_vertex()
        • _resample_df_to_model_time()
        • discretize_knmi()
        • download_knmi()
        • get_knmi()
        • get_knmi_at_locations()
        • get_locations()
        • get_recharge()
        • add_geotop_to_regis_layers()
        • download_regis()
        • extract_version_from_title()
        • get_combined_layer_models()
        • get_layer_names()
        • get_legend()
        • get_legend_lithoclass()
        • get_legend_lithostratigraphy()
        • get_regis()
        • get_table_name_changes()
        • read_gleg()
        • read_voleg()
        • calculate_sea_coverage()
        • discretize_northsea()
        • discretize_surface_water()
        • download_bathymetry()
        • download_bathymetry_gdf()
        • get_bathymetry()
        • get_bathymetry_gdf()
        • get_gdf_surface_water()
        • get_gdr_configuration()
        • get_northsea()
        • get_surface_water()
        • _set_column_from_columns()
        • download_data()
        • download_polygons()
        • get_configuration()
        • get_data()
        • get_polygons()
      • dims
        • _get_structured_grid_ds()
        • _get_vertex_grid_ds()
        • extrapolate_ds()
        • get_ds()
        • set_ds_attrs()
        • to_model_ds()
        • _agg_area_weighted()
        • _agg_length_weighted()
        • _agg_max_area()
        • _agg_max_length()
        • _agg_nearest()
        • _get_aggregates_values()
        • _get_attrs()
        • affine_transform_gdf()
        • aggregate_vector_per_cell()
        • col_to_list()
        • cols_to_reclist()
        • da_to_reclist()
        • ds_to_gridprops()
        • gdf_area_to_da()
        • gdf_to_bool_da()
        • gdf_to_bool_ds()
        • gdf_to_count_da()
        • gdf_to_count_ds()
        • gdf_to_da()
        • gdf_to_data_array_struc()
        • gdf_to_grid()
        • get_affine()
        • get_affine_mod_to_world()
        • get_affine_world_to_mod()
        • get_cell2d_from_ds()
        • get_cellids_from_xy()
        • get_dims_coords_from_modelgrid()
        • get_extent()
        • get_extent_gdf()
        • get_extent_polygon()
        • get_icell2d_from_xy()
        • get_node_structured()
        • get_node_vertex()
        • get_row_col_from_xy()
        • get_thickness_from_topbot()
        • get_vertices()
        • get_vertices_arr()
        • get_vertices_from_ds()
        • get_xyi_icell2d()
        • gridprops_to_vertex_ds()
        • interpolate_gdf_to_array()
        • lcid_to_reclist()
        • lrc_to_reclist()
        • mask_model_edge()
        • modelgrid_from_ds()
        • modelgrid_to_ds()
        • modelgrid_to_vertex_ds()
        • node_to_lrc()
        • polygon_to_area()
        • polygons_from_ds()
        • refine()
        • snap_extent()
        • update_ds_from_layer_ds()
        • xy_to_icell2d()
        • xy_to_row_col()
        • xyz_to_cid()
        • _add_bathymetry_to_top_bot_kh_kv()
        • _fill_var()
        • _get_empty_layered_da()
        • _get_modellayers_dsobs()
        • _get_new_layer_name()
        • _insert_layer_above()
        • _insert_layer_below()
        • _set_new_layer_values()
        • _split_var()
        • add_bathymetry_to_layer_model()
        • add_kh_kv_from_ml_layer_to_ds()
        • add_layer_dim_to_top()
        • aggregate_by_weighted_mean_to_ds()
        • calculate_resistance()
        • calculate_thickness()
        • calculate_transmissivity()
        • check_elevations_consistency()
        • combine_layers_ds()
        • convert_to_modflow_top_bot()
        • convert_to_regis_top_bot()
        • fill_nan_top_botm()
        • fill_nan_top_botm_kh_kv()
        • fill_top_bot_kh_kv_at_mask()
        • get_first_active_layer()
        • get_first_active_layer_from_idomain()
        • get_idomain()
        • get_isosurface()
        • get_isosurface_1d()
        • get_kh_kv()
        • get_last_active_layer()
        • get_last_active_layer_from_idomain()
        • get_layer_of_z()
        • get_modellayers_indexer()
        • get_modellayers_screens()
        • insert_layer()
        • kheq_combined_layers()
        • kveq_combined_layers()
        • layer_combine_top_bot()
        • remove_inactive_layers()
        • remove_layer()
        • remove_layer_dim_from_top()
        • remove_thin_layers()
        • set_layer_botm()
        • set_layer_thickness()
        • set_layer_top()
        • set_minimum_layer_thickness()
        • set_model_top()
        • set_nan_top_and_botm()
        • split_layers_ds()
        • sum_param_combined_layers()
        • update_idomain_from_thickness()
        • _pd_timestamp_to_cftime()
        • dataframe_to_flopy_timeseries()
        • ds_time_from_model()
        • ds_time_from_modeltime()
        • ds_time_idx()
        • ds_time_idx_from_model()
        • ds_time_idx_from_modeltime()
        • ds_time_idx_from_tdis_settings()
        • ds_time_to_pandas_index()
        • estimate_nstp()
        • get_perlen()
        • get_time_step_length()
        • set_ds_time()
        • set_ds_time_deprecated()
        • set_ds_time_numeric()
        • set_time_variables()
        • _set_angrot_attributes()
        • affine_transform_gdf()
        • ds_to_structured_grid()
        • extent_to_polygon()
        • fillnan_da()
        • fillnan_da_structured_grid()
        • fillnan_da_vertex_grid()
        • get_affine()
        • get_affine_mod_to_world()
        • get_affine_world_to_mod()
        • get_extent()
        • get_extent_polygon()
        • get_xy_mid_structured()
        • structured_da_to_ds()
        • vertex_da_to_ds()
      • sim
        • ems()
        • get_tdis_perioddata()
        • ims()
        • register_ims_package()
        • register_solution_package()
        • sim()
        • tdis()
        • write_and_run()
      • gwf
        • _dis()
        • _disv()
        • _set_record()
        • buy()
        • chd()
        • dis()
        • disv()
        • drn()
        • ds_to_gwf()
        • evt()
        • ghb()
        • gwf()
        • ic()
        • npf()
        • oc()
        • rch()
        • riv()
        • sto()
        • surface_drain_from_ds()
        • uzf()
        • _add_time_series()
        • _get_meteo_da_from_input()
        • _get_unique_series()
        • ds_to_evt()
        • ds_to_rch()
        • ds_to_uzf()
        • _get_start_summer_and_winter()
        • _get_waterboard_selection()
        • _is_in_summer()
        • add_bottom_height_from_waterboards()
        • add_info_to_gdf()
        • add_min_ahn_to_gdf()
        • add_season_timeseries()
        • add_stages_from_waterboards()
        • agg_area_weighted()
        • agg_de_lange()
        • agg_max_area()
        • aggregate()
        • build_spd()
        • coth()
        • de_lange_eqns()
        • distribute_cond_over_lays()
        • download_level_areas()
        • download_watercourses()
        • estimate_polygon_length()
        • gdf_to_seasonal_pkg()
        • get_gdf()
        • get_gdf_stage()
        • get_seaonal_timeseries()
        • get_subsurface_params_by_cellid()
        • get_surfacewater_params()
        • radial_resistance()
        • rivdata_from_xylist()
        • _add_cellid()
        • _get_layer_multiplier_for_well()
        • _get_layer_multiplier_for_wells()
        • maw_from_df()
        • wel_from_df()
        • _copy_da_from_ds()
        • _get_and_check_single_value()
        • _parse_laksetting_value()
        • add_lakeno_to_gdf()
        • clip_meteorological_data_from_ds()
        • copy_meteorological_data_from_ds()
        • lake_from_gdf()
        • _calculate_gxg()
        • calculate_gxg()
        • get_budget_da()
        • get_cellbudgetfile()
        • get_flow_lower_face()
        • get_flow_residuals()
        • get_gwl_from_wet_cells()
        • get_head_at_point()
        • get_headfile()
        • get_heads_da()
      • gwt
        • adv()
        • cnc()
        • dis()
        • disv()
        • dsp()
        • gwfgwt()
        • gwt()
        • ic()
        • mst()
        • oc()
        • ssm()
        • set_default_transport_parameters()
        • freshwater_head()
        • get_concentration_at_gw_surface()
        • get_concentration_da()
        • get_concentration_obj()
        • pointwater_head()
      • plot
      • gis
        • _break_down_dimension()
        • dataarray_to_shapefile()
        • ds_to_ugrid_nc_file()
        • ds_to_vector_file()
        • struc_da_to_gdf()
        • vertex_da_to_gdf()
      • util
        • ColoredFormatter
        • LayerError
        • MissingValueError
        • _get_value_from_ds_attr()
        • _get_value_from_ds_datavar()
        • check_da_dims_coords()
        • check_presence_mfbinaries()
        • compare_model_extents()
        • download_file_from_google_drive()
        • download_mfbinaries()
        • download_modpath_provisional_exe()
        • extent_to_gdf()
        • extent_to_polygon()
        • find_most_recent_file()
        • gdf_from_extent()
        • gdf_intersection_join()
        • gdf_within_extent()
        • get_bin_directory()
        • get_color_logger()
        • get_da_from_da_ds()
        • get_ds_empty()
        • get_exe_path()
        • get_flopy_bin_directories()
        • get_google_drive_filename()
        • get_model_dirs()
        • import_hydropandas()
        • polygon_from_extent()
        • zonal_statistics()
      • cache
        • NumpyEncoder
        • _check_for_data_array()
        • _explicit_dataset_coordinate_comparison()
        • _get_modification_time()
        • _same_function_arguments()
        • _update_docstring_and_signature()
        • cache_netcdf()
        • cache_pickle()
        • clear_cache()
        • ds_contains()
        • hash_xarray_coords()
        • hash_xarray_data_vars()
nlmod
  • nlmod
  • View page source

nlmod

nlmod is a Python package to build, run and visualize MODFLOW 6 groundwater models in the Netherlands. The main focus is on building models in the Netherlands using publicly available datasets, though lots of functionality could be applied to groundwater models elsewhere.

The logo of nlmod The logo of Artesia

nlmod relies on the wonderful features of xarray and geopandas for storing and manipulating data and flopy is used for building and running groundwater models.

We thank the following institutions for their contributions to the development of nlmod:

The logo of PWN The logo of Hoogheemraadschap Hollands Noorderkwartier The logo of Waternet The logo of Vitens The logo of Evides The logo of Brabant Water

Contents:

  • Getting Started
    • Getting Python
    • Installing nlmod
    • Using nlmod
    • Dependencies
  • Data Sources
    • Downloading surface water data
    • Using information from GeoTOP
    • Downloading meteorological data
  • Example Models
    • Building a groundwater model from scratch
    • Building a model anywhere in the Netherlands
    • Building a model with local grid refinement
    • A groundwater model for Schoonhoven
    • Stromingen example: keeping scripts simple
    • Groundwater transport modeling
  • Utilities
    • Modifying model layers
    • Caching data in nlmod
    • Gridding vector data
    • Resampling raster data
    • Exporting model data to GIS
    • Plot methods in nlmod
  • Workflows
    • Generating model datasets
    • Working with grid rotation
    • Aggregating surface water
    • Particle Tracking with MODPATH
    • Particle Tracking with PRT
    • Comparing modelled heads to observations
    • Voronoi Example
  • Advanced Stress Packages
    • The Lake Package
    • Unsaturated Zone Flow
  • API-docs
    • nlmod

Indices and tables

  • Index

Next

© Copyright 2026, O.N. Ebbens, D.A. Brakenhoff, R.J. Caljé.

Built with Sphinx using a theme provided by Read the Docs.