pywatemsedem.io package

Submodules

pywatemsedem.io.folders module

class pywatemsedem.io.folders.CatchmentFolder(home_folder: pathlib.Path, resolution: int)[source]

Bases: object

check_catchment_folder(**options)[source]

Create ‘Data_bekken’ folder

check_home_folder(**options)[source]

Create home folder

check_rst_folder(**options)[source]

Create ‘Data_bekken’ folder

check_vct_folder(**options)[source]

Create home folder

create_all()[source]
home_folder: Path
resolution: int
class pywatemsedem.io.folders.ScenarioFolders(cfolder: CatchmentFolder, scenario_label: str, year: int)[source]

Bases: object

Class for keeping track of Scenario folder names

Parameters:
cfolder: CatchmentFolder
check_cnwsinput(**options)[source]

Create ‘scenario_x/modelinput’ folder

check_cnwsoutput(**options)[source]

Create ‘scenario_x/modeloutput’ folder

check_postprocessing(**options)[source]

Create ‘scenario_x/postprocess’ folder

check_scenario(**options)[source]

Create ‘scenario_x’ folder

check_years(**options)[source]

Create ‘scenario_x/year’ folder

create_all()[source]
scenario_label: str
year: int
pywatemsedem.io.folders.check_and_create_catchment_folder(home_folder, **options)[source]

Check and create home/catchment folder

Parameters:
pywatemsedem.io.folders.check_and_create_cnwsinput_folder(scenario_folder, **options)[source]

Check and create home/scenario_x/modelinput folder

Parameters:
pywatemsedem.io.folders.check_and_create_cnwsoutput_folder(scenario_folder, **options)[source]

Check and create home/scenario_x/modeloutput folder

Parameters:
pywatemsedem.io.folders.check_and_create_folder(folder, msg_subject='Folder', create=False, error_if_empty=False)[source]

Check and create pywatemsedem folder

Parameters:
  • folder (pathlib.Path) – Folder path of pywatemsedem folder

  • msg_subject (str) – Custom message used be to complete message

  • create (bool) – Indicate whether you want to create the folder

  • error_if_empty (bool) – See pywatemsedem.pywatemsedem.folders.error_if_folder_empty()

pywatemsedem.io.folders.check_and_create_home_folder(home_folder, **options)[source]

Check and create home folder

Parameters:
pywatemsedem.io.folders.check_and_create_postprocessing_folder(scenario_folder, **options)[source]

Check and create home/scenario_x/postprocessing folder

Parameters:
pywatemsedem.io.folders.check_and_create_rst_folder(catchment_folder, resolution, **options)[source]

Check and create home/catchment/vct folder

Parameters:
pywatemsedem.io.folders.check_and_create_scenario_folder(home_folder, scenario_label, **options)[source]

Check and create home/scenario_x folder

Parameters:
pywatemsedem.io.folders.check_and_create_vct_folder(catchment_folder, **options)[source]

Check and create home/catchment/vct folder

Parameters:
pywatemsedem.io.folders.check_and_create_vctyears_folder(vct_folder, year, **options)[source]

Check and create home/catchment/shps/year folder

Parameters:
pywatemsedem.io.folders.check_and_create_years_folder(scenario_folder, year, **options)[source]

Check and create home/scenario_x/year folder

Parameters:
pywatemsedem.io.folders.throw_error_if_folder_empty(folder, msg, error_if_empty)[source]

Check if pywatemsedem folder is empty

Parameters:

pywatemsedem.io.ini module

class pywatemsedem.io.ini.IniFile(choices, version, inputfolder, outputfolder)[source]

Bases: object

Create WaTEM/SEDEM ini-file

Parameters:
  • choices (pywatemsedem.pywatemsedem.chocies.UserChoices) – See pywatemsedem.pywatemsedem.userchoices.UserChoices

  • version (str) – Model version

  • inputfolder (pathlib.Path) – WaTEM/SEDEM inputfolder

  • outputfolder (pathlib.Path) – WaTEM/SEDEM outputfolder

Examples

>>> choices = Choices(...)
>>> forced_routing = ...
>>> buffers = ...
>>> inifile = IniFile(choices,"WS","modelinput","modeloutput")
>>> inifile.add_model_information()
>>> inifile.add_working_directories()
>>> inifile.add_files()
>>> inifile.add_user_choices()
>>> inifile.add_output_maps()
>>> inifile.add_variables(buffers, forced_routing, river_underground)
>>> inifile.write("modelinput/ini_file.ini")
add_files()[source]

Add section files to config file

add_model_information()[source]

Add section model information to config file

add_output_maps()[source]

Add section outputs config file

add_user_choices()[source]

Add section user choices to config file

add_variables(buffers, forced_routing, river_underground)[source]

Add section variables to config file

Parameters:
  • buffers (pandas.DataFrame) –

    Holding buffer properties, with columns,

    • buffercap (float): Volume

    • hdam (float): Height dam

    • hknijp^ (float): Height opening

    • dknijp (float): Opening area

    • qcoef (float): Discharge coefficient

    • boverl (float): Width dam

    • eff (float): Trapping efficiency

    • BUF_EXID (float): Extension ID

    • BUF_ID (float): Buffer id

  • forced_routing (pandas.DataFrame) –

    Forced routing table with columns, see here

    • NR (int):

    • from col (int): source pixel column

    • from row (int): source pixel row

    • target col (int): target pixel column

    • target row (int): target pixel row

  • river_underground (pandas.DataFrame) –

    River underground routing table with columns, see here

    • NR (int):

    • from col (int): source pixel column

    • from row (int): source pixel row

    • target col (int): target pixel column

    • target row (int): target pixel row

add_working_directories()[source]

Add section working directory to config file

set_cfg_model_version()[source]

Add model version to self.cfg.

set_cfg_only_routing()[source]

Add variables for only routing version of WaTEM/SEDEM.

write(ini)[source]

Write ini file to disk

pywatemsedem.io.ini.add_field(ini, section, key, value)[source]

Add one specific key in ini-file

Loads, writes value to key (in section) and closes file

Parameters:
  • ini (pathlib.Path) – File name

  • section (str) – Section name, i.e. Model information, Working directories, Files, User Choices, Output , Variables, Calibration, Buffer $id and Forced Routing $id.

  • key (str) – Key

  • value (str) – New value

pywatemsedem.io.ini.get_item_from_ini(ini, section, option, dtype)[source]

Gets an item from an option in a certain section of an ini-file

Parameters:
  • ini (pathlib.Path) – File path of the ini-file

  • section (str) – Name of the desired section

  • option (str) – Name of the desired option

  • dtype (dtype) –

    Type of parameter to be read (str, int, float or bool).

    If another string is given to this parameter, a

    TypeError is raised.

Returns:

Settings value of ini-file. If the option or section does not exist in the ini-file or the value of the section-option None is returned.

Return type:

str or int or float or bool or None

pywatemsedem.io.ini.modify_field(ini, section, key, value)[source]

Add one specific key in ini-file

Loads, writes value to key (in section) and closes file

Parameters:
  • ini (pathlib.Path) – File name

  • section (str) – Section name, i.e. Model information, Working directories, Files, User Choices, Output , Variables, Calibration, Buffer $id and Forced Routing $id.

  • key (str) – Key

  • new_value (str) – New value

  • ini_updated (pathlib.Path, default None) – New file to write to

pywatemsedem.io.ini.open_ini(ini)[source]

Open ini file.

Parameters:

ini (pathlib.Path)

Returns:

content

Return type:

list

pywatemsedem.io.modelinput module

class pywatemsedem.io.modelinput.Modelinput(template, resolution, epsg, nodata)[source]

Bases: Factory

property adjacentsegments

Getter adjacentsegments dataframe.

For documentation, see here

property buffers

Getter buffers attribute.

For documentation, see here

property cfactor

Getter cfactor attribute.

For documentation, see here

property compositelanduse

Getter landuseparcels attribute.

For documentation, see here

property dtm

Getter dtm attribute.

For documentation, see here

property kfactor

Getter kfactor attribute. For documentation, see here

property ktc

Getter kTC parameter attribute.

For documentation, see here

property outlet

Getter outlet attribute.

For documentation, see here

property pfactor

Getter P-factor attribute.

For documentation, see here

property ptef

Getter ptef attribute.

For documentation, see here

property riverrouting

Getter riverrouting attribute.

For documentation, see here

property riversegments

Getter riversegments attribute.

For documentation, see here

property sewers

Getter sewers attribute.

For documentation, see here

property upstreamsegments

Getter upstreamsegments dataframe.

For documentation, see here

pywatemsedem.io.modelinput.valid_segments(func)[source]

Check if you have defined a river segments raster.

pywatemsedem.io.modeloutput module

class pywatemsedem.io.modeloutput.Modeloutput(template, resolution, epsg, nodata)[source]

Bases: Factory

property capacity

Getter capacity attribute.

For documentation, see here

property ls

Getter LS (length-slope) attribute.

For documentation, see here

make_routing_vector(landuse, sediout, percentile=90, routing_missing=False)[source]

Converts pandas dataframe of routing or routing_missing to a geopandas dataframe

Parameters:
  • landuse (pathlib.Path | str | str) – Path of landuse raster

  • sediout (pathlib.Path | str | str) – Path of sediout raster

  • percentile (int, default = 90) – Only vectors belonging to SediOutdata percentile and higher is kept

  • routing_missing (bool, default = False) – set to True to apply function to routing_missing instead of routing

Return type:

geopandas.GeoDataFrame

property routing

Getter routing attribute. For documentation, see here

property routing_missing

Getter routing_missing attribute. For documentation, see here

property rusle

Getter rusle attribute.

For documentation, see here

property sedi_export

Getter SediExport attribute.

For documentation, see here

property sedi_in

Getter SediIn attribute.

For documentation, see here

property sediout

Getter SediOut attribute.

For documentation, see here

property sewer_in

Getter sewer_in attribute.

For documentation, see here

property slope

Getter slope attribute.

For documentation, see here

property total_sediment

Getter total sediment attribute.

For documentation, see here. For explanation on colmun variables of dataframe: see pywatemsedem.pywatemsedem.cnwsoutput.load_total_sediment_file().

property uparea

Getter uparea attribute.

For documentation, see here

pywatemsedem.io.modeloutput.check_segment_edges(adj_edges, up_edges, arr)[source]

Check river segment their edges. All the segments present in adj_edges and up_edges must be present in the array from the segments raster.

Parameters:
Returns:

  • adj_edges (pandas.DataFrame) – Filtered

  • up_edges (pandas.DataFrame) – Filtered

  • filt (bool) – Flag indicating filtering of dataframes

pywatemsedem.io.modeloutput.compute_cumulative_loads_in_sinks(df_sediexport, profile, threshold, delta=10, plot=False)[source]

Analyse cumulative sediment load by sorting SediExport values from high to low

Parameters:
  • df_sediexport (pandas.DataFrame) – Data Frame format of SediExport raster (format: see pywatemsedem.pywatemsedem.utils.raster_array_to_pandas_dataframe())

  • profile (rasterio.profiles) – See rasterio.open()

  • threshold (int) – x percentage highest load that the user wants to analyse

  • delta (int) – Delta used to iterate percentage

  • plot (bool, default False) – True if you want a cumulative SediExport plot

Returns:

  • df_sediexport (pandas.DataFrame) – Data Frame format of SediExport raster (format: see pywatemsedem.pywatemsedem.utils.raster_array_to_pandas_dataframe()) added with:

    • cum_perc (float): cumulative highest load

    • perc (float): percentage highest load

    • class (int): class as defined by delta_perc

  • percentage (str) – updated percentage

pywatemsedem.io.modeloutput.compute_efficiency_buffers(rst_buffer, rst_sediin, rst_sediout)[source]

Compute efficiency per buffer

This function calculates the incoming and outgoing sediment per buffer. The deposition is computed by substracting the outgoing from the ingoing sediment.

Parameters:
  • rst_buffer (str or pathlib.Path | str) – File path of buffer raster with buffer id’s

  • rst_sediin (str or ppathlib.Path | str) – File path of CNWS SediIn raster, incoming sediment per pixel

  • rst_sediout (str or pathlib.Path | str) – File path of CNWS SediOut raster, outgoing sediment per pixel

Returns:

df_output – Holding results of mass balance of buffers.

  • buf_id (float): id of the buffer (as in the buffer raster)

  • sediin (float): total incoming sediment in the buffer.

  • sediout (float): total outgoing sediment in the buffer.

  • buff_sed (float): amount sediment deposited in the buffer.

Return type:

pandas.DataFrame

pywatemsedem.io.modeloutput.condition_routing_dataframe_on_extent(df_routing, rstparams, extent)[source]

Clip routing_dataframe on defined extent

Parameters:
Returns:

df_routing – See pywatemsedem.io.modeloutput.open_txt_routing_file()

Return type:

pandas.DataFrame

pywatemsedem.io.modeloutput.create_deposition_raster(rst_watereros)[source]

Create deposition raster from watereros.

Extract positve values from Watereros raster and set negatives to 0

Parameters:

rst_watereros (str or pathlib.Path | str) – File path to WaTEM/SEDEM watereros raster.

Returns:

rst_deposition – File path to pywatemsedem erosion raster.

Return type:

pathlib.Path | str

pywatemsedem.io.modeloutput.create_erosion_raster(rst_watereros)[source]

Create erosion raster from watereros.

Extract negative values from Watereros raster and set positives to 0. Erosion values in this raster are positive (inverse of watereros)

Parameters:

rst_watereros (str or pathlib.Path | str) – File path to WaTEM/SEDEM watereros raster.

Returns:

rst_erosion – File path to pywatemsedem erosion raster.

Return type:

pathlib.Path | str

pywatemsedem.io.modeloutput.create_id_raster_for_highest_value_arr(arr, id_, profile, resmap)[source]

Create a raster with an id value assigned to the highest value in the raster”

Parameters:
  • arr (str or pathlib.Path | str) – with floats

  • id (int) – Sequential number of the catchment

  • profile (rasterio profile) – Rasterio profile of the sedout raster

  • resmap (str or pathlib.Path | str, optional) – Folder path to write results to

Returns:

  • rst_id (str) – File path of the raster with id for highest value in raster

  • val (float) – Maximum value in raster

pywatemsedem.io.modeloutput.define_subcatchments_saga(rst_in, txt_routing, resmap, rasterprop, tag='')[source]

Define subcatchment for several points defined with a unique id in the raster

Parameters:
  • rst_in – Raster with single-pixels for which subcatchment should be determined > 0: determine subcatchment = 0: don’t determine subcatchments

  • txt_routing_nonriver (str or pathlib.Path | str) – File path of the WaTEM/SEDEMrouting table

  • resmap (str or pathlib.Path | str) – Folder path where results should be saved

  • rasterprop (dict) – rasterio profile dictionary holding all metadata for geotiff rasters

  • tag (str or pathlib.Path | str) – File path of output shape and raster

  • catchment_name (str) – Name of catchment, default “”

  • scenario_label (str, default "") – Scenario number or letter.

Returns:

  • rst_subcatchments (str or pathlib.Path | str) – File path of raster with pixels beloging to a subcatchment having id equal to id sink in rst_in

  • vct_subcatchments (str or pathlib.Path | str:) – File path of shapefile with polygon being the subcatchment having an id equal to id sink in rst_in

pywatemsedem.io.modeloutput.get_prckrt_statistics(rst_prckrt, unit='ha', resolution=20)[source]

Get the statistics of the WaTEM/SEDEM perceelskaart

Load the WaTEM/SEDEM perceelskaart and compute for every unique id the area (ha or m2).

Parameters:
  • rst_prckrt (str or pathlib.Path | str) – File path ofWaTEM/SEDEM perceelskaart

  • unit (str) – The unit of the output, currently pixel, m2 and ha implemented

  • resolution (int) – Resolution of the rasters

Returns:

out

Area for each class, keys:

  • agriculture (float): area (ha/m2)

  • river (float): area (ha/m2)

  • infrastructure (float): area (ha/m2)

  • forest (float): area (ha/m2)

  • meadow (float): area (ha/m2)

  • open_water (float): area (ha/m2)

  • gras_strip (float): area (ha/m2)

Return type:

dict,

pywatemsedem.io.modeloutput.identify_individual_priority_catchments(arr_sediout, rst_profile, txt_routing_non_river, nmax, resmap=PosixPath('/home/runner/work/pywatemsedem/pywatemsedem'), epsg='')[source]

identify the individual priority catchments and add them to a raster and shapes dictionary

Parameters:
  • arr_sediout (numpy.ndarray) – numpy array format of sedout raster

  • rst_profile (rasterio profile) – rasterio profile of the sedout raster

  • txt_routing_nonriver (str or pathlib.Path | str) – File path of the WaTEM/SEDEM routing table

  • nmax (int) – maximum number of catchment

Returns:

subcatchmentpriority – catchment shapes with number of catchment

Return type:

geopandas.GeoDataFrame

pywatemsedem.io.modeloutput.identify_rank_sediment_loads(rst_sediexport, threshold, rst_out, rst_endpoints=None)[source]

Identify the highest threshold percentage sediment loads.

This functions identifies the cumulative distribution of the sediexport (and sewerin, optional) raster:

  • (optional) map sewerin raster to sediexport raster

  • convert sediexport raster to a list-format

  • sort from high to low

  • compute cumulative distribution

  • classify

Parameters:
Returns:

pywatemsedem.io.modeloutput.load_total_sediment_file(txt_total_sediment_file)[source]

Load the total sediment file of CNWS written in CNWS dict_output map

Parameters:

txt_total_sediment_file (str or pathlib.Path | str) – File Path of the sediment file

Returns:

dict_output – The dict_output sediment data dictionary contains the following data:

  • erosion (float): total amount of erosion (kg)

  • deposition (float): total amount of deposition (kg)

  • river (float): total amount of sediment run-off to the river (kg)

  • outside_domain (float): total amount of sediment run-off out of the catchment (kg)

  • buffers (float): total amount of sediment trapped in buffers (kg)

  • endpoints (float): total sewer of sediment trapped in sewers and ditches (kg)

Return type:

dict

pywatemsedem.io.modeloutput.make_routing_vct_saga(txt_routing, rst_prckrt, vct_out, rstparams, extent=None, tile_number=None)[source]

Generate a routing vct routing file (added with CNWS landuse) based on the routing table extent and tilenumber are defined to make a routing file only for a certain extent

Parameters:
  • txt_routing (str or pathlib.Path | str) – File path of the WaTEM/SEDEM routing tabl

  • rst_prckrt (str) – name of CNWS input ‘perceelskaart’

  • vct_out – name of the shape outputfile

  • rstparams (dict) – gdal dictionary holding all metadata for idrisi rasters

  • extent (list, default None) – list holding value of extent to consider, xmin,ymin,xmax,ymax

  • tile_number (int, optional, default None) – number of the tile, used to add to filename

Returns:

vct_out – The resulting vector file will contain following features:

  • col (int): source column number.

  • row (int): source row number.

  • targetcol (int): target column number.

  • targetcol (int): source column number.

  • part (float): fraction of source that flows to target (between 0 and 1).

  • distance (float): distance of routing (m)

  • landuSource (int): landuse code of source pixel

  • landuTarg (int): landuse code of target pixel

  • jump (int): yes (1) or no (0)

  • targetX (float): x coor value of target

  • targetY (float): y coor value of target

  • sourceX (float): x coor value of source

  • sourceY (float): y coor value of source

Return type:

str

pywatemsedem.io.modeloutput.map_rank_sediment_loads(rst_sediexport, threshold, vct_out='rank.shp', rst_endpoints=None, unit='kg')[source]

Rank the sediment loads in sediexport (and sewerin) from high to low

This function uses the rank output raster/dataframe of pywatemsedem.io.modeloutput.identify_rank_sediment_loads() to map a vector point file with information on rank, sediment output.

For computation details, see pywatemsedem.io.modeloutput.identify_rank_sediment_loads()

Parameters:

Note

Only points are taken into account that account for x of the highest sediment loads. x is determined by threshold.

pywatemsedem.io.modeloutput.open_txt_routing_file(txt_routing)[source]

Open routing file with exceptions and seperators as needed

Parameters:

txt_routing (str or pathlib.Path | str) – File path of the WaTEM/SEDEM routing table

Returns:

df_routing – The routing DataFrame contains the following columns:

  • col (int): source column in rasters

  • row (int): source row in rasters

  • target1col (int): first target column in rasters

  • target1row (int): first target row in rasters

  • part1 (float): Part that flows to target1

  • distance1 (float): Distance of 1st vector

  • target2col (int): second target column in rasters

  • target2row (int): second target row in rasters

  • part2 (float): Part that flows to target2

  • distance2 (float): Distance of 2nd vector

Return type:

pandas.DataFrame

pywatemsedem.io.modeloutput.prepare_make_routing_vct_saga(txt_routing, vct_out, seperator, rstparams, extent, tile_number)[source]

Prepare the input files for make routing vct_saga If an extension is defined, then this function will clip the file to this rectangular geographical extent

Parameters:
  • txt_routing_nonriver (str or pathlib.Path | str) – File path of the WaTEM/SEDEM routing tabl

  • vct_out (str) – name of output shapefile for ‘run_saga_make_routing_shp_cmd’ fuction

  • seperator (str) – current delimited of txt_routing

  • rstparams (dict) – gdal dictionary holding all metadata for idrisi rasters

  • extent (list) – min and max of rectangular frame to clip df [xmin, xmax, ymin, ymax]

  • tile_number (int) – number of tile

Returns:

  • vct_temp (str) – The resulting vector file will contain following features:

    • col (int): source column number.

    • row (int): source row number.

    • targetcol (int): target column number.

    • targetcol (int): source column number.

    • part (float): fraction of source that flows to target (between 0 and 1).

    • distance (float): distance of routing (m)

    • landuSource (int): landuse code of source pixel

    • landuTarg (int): landuse code of target pixel

    • jump (int): yes (1) or no (0)

    • targetX (float): x coor value of target

    • targetY (float): y coor value of target

    • sourceX (float): x coor value of source

    • sourceY (float): y coor value of source

  • condition (boolean) – True if make_routing_shp has to be run

pywatemsedem.io.modeloutput.remove_river_routing(df_routing)[source]

Remove river routing from routing dataframe

Parameters:

df_routing (pandas.DataFrame) – Long format of routing table

Returns:

Long format of routing table, with river routing removed

Return type:

df_routing

pywatemsedem.io.modeloutput.run_saga_make_routing_shp_cmd(txt_routing, rst_prckrt, vct_out)[source]

Run the saga make routing shape command. This command makes from a pywatemsedem routing table and a pywatemsedem ‘perceelskaart’ a routing shapfile representation.

The resulting vector file will contain following features:

  • col (int): source column number.

  • row (int): source row number.

  • targetcol (int): target column number.

  • targetcol (int): source column number.

  • part (float): fraction of source that flows to target (between 0 and 1).

  • distance (float): distance of routing (m)

  • landuSource (int): landuse code of source pixel

  • landuTarg (int): landuse code of target pixel

  • jump (int): yes (1) or no (0)

  • targetX (float): x coor value of target

  • targetY (float): y coor value of target

  • sourceX (float): x coor value of source

  • sourceY (float): y coor value of source

Parameters:
  • txt_routing_nonriver (str or pathlib.Path | str) – File path of the WaTEM/SEDEM routing table

  • rst_prckrt (str) – File path of the WaTEM/SEDEM ‘perceelskaart’ raster

  • vct_out (str) – File path of the output file

pywatemsedem.io.modeloutput.verify_highest_load_with_threshold(df_sediexport, threshold)[source]

Verify whether that the highest load is not accountable for more than 50 percent of all the load in a catchment. If this is true, adapt threshold.

Parameters:
Returns:

threshold_ – Adapted threshold (depending on if-else clause).

Return type:

float

pywatemsedem.io.plots module

pywatemsedem.io.plots.axes_creator(fig, ax)[source]

Creates fig and ax object if none ar given

Parameters:
Returns:

  • fig (matplotlib.figure.Figure)

  • ax (matplotlib.pyplot.axis)

pywatemsedem.io.plots.log_scale_enabler(arr, cnorm)[source]

Checks if log scale is supplied. If minimum is lower or equal to zero, changes lower bound to smallest value above zero.

Parameters:
Returns:

lower – lower value for colorscale

Return type:

float

pywatemsedem.io.plots.normalising_function(mini, Q25, Q50, Q75, maxi)[source]

Custom normalisation function for maptlotlib plotting

Parameters:
  • mini – minimum of the colorscale

  • Q25 – 25th percentile

  • Q50 – 50th percentile

  • Q75 – 75th percentile

  • maxi – maximum of the colorscale

Returns:

norm

Return type:

matplotlib.colors.Normalize

pywatemsedem.io.plots.plot_continuous_raster(fig, ax, arr, bounds, cmap='cividis', norm=None, colorbar=True, ticks=None, *args, **kwargs)[source]
Parameters:
Returns:

  • fig (matplotlib.figure.Figure)

  • ax (matplotlib.pyplot.axis)

pywatemsedem.io.plots.plot_discrete_raster(fig, ax, arr, bounds, labels, cmap='cividis', norm=None, *args, **kwargs)[source]
Parameters:
Returns:

  • fig (matplotlib.figure.Figure)

  • ax (matplotlib.pyplot.axis)

pywatemsedem.io.plots.plot_output_raster(fig, ax, arr, mask, bounds, title='none', ticks=None, *args, **kwargs)[source]

Standard non-linear continuous raster plot for output raster

Parameters:
Returns:

  • fig (matplotlib.figure.Figure)

  • ax (matplotlib.pyplot.axis)

pywatemsedem.io.valid module

pywatemsedem.io.valid.valid_array_type(arr, required_type)[source]

Checks if arr is 1) a numpy.dtype 2) the desired numpy.dtype

Parameters:
Return type:

True

pywatemsedem.io.valid.valid_boundaries(arr, lower=None, upper=None)[source]

Checks if values are within specified boundaries

Parameters:
Return type:

True

pywatemsedem.io.valid.valid_nodata(arr, nodata_value=-9999)[source]

Checks if a nodata value is present in arr

Parameters:
  • arr (numpy.ndarray) – Input array

  • nodata_value (int, default -9999) – Value to be interpreted as no data present

Return type:

True

pywatemsedem.io.valid.valid_non_nan(arr)[source]

Checks if Nan are present in the array

Parameters:

arr (numpy.ndarray) – Input array

Return type:

True

pywatemsedem.io.valid.valid_values(arr, unique_values)[source]

Checks if values in an array are within the set of unique values

The input array can only have the input values defined in unique_values.

Parameters:
  • arr (numpy.ndarray) – Input array

  • unique_values (list) – Unique values that the raster can have

Return type:

True

Module contents