schimpy package

Submodules

schimpy.archive_ts module

schimpy.base_io module

This module is a simple common base for text file IO. @outhor: Kijin Nam, knam@water.ca.gov

class schimpy.base_io.BaseIO(logger=None)

Bases: object

Common IO routines to handle text inputs

Attributes:
linecounter
property linecounter

schimpy.batch_metrics module

schimpy.bctide module

schimpy.bound_linear module

schimpy.bound_linear.bound_linear(z, z_low, z_high, val_low, val_high)

schimpy.cencoos_download module

schimpy.cencoos_download.cencoos_schism_opendap(lat_lo, lon_lo, lat_hi, lon_hi, file_base, to_cache, from_cache)

Download cencoos opendap data for all time based on a bounding set of lat/lon file_base : str prefix for files to_cache : bool whether to stash data in numpy arrays to make it easier next time from_cache : use cache rather than download)

The strategy for this download may change with time. When the script was originally written, blocking the query in time was very inefficient

schimpy.cencoos_download.merc_to_latlon(x, y)
schimpy.cencoos_download.time_block_report(message, told)

This routine is for reporting incremental timing of parts of the script

schimpy.check_mesh_skewness module

schimpy.clip_dems module

schimpy.clip_dems.bounding_coords(image)
schimpy.clip_dems.clip_dem(xlo, xhi, demlist='dem.txt', outformat='AAIGrid', hshift=False, prefix='clipped', verbose=False)
schimpy.clip_dems.create_arg_parser()
schimpy.clip_dems.main()

schimpy.combine_consume module

schimpy.combine_consume.appears_done(wdir, fb, exten, firstblock, lastblock)

Decide if entire file block already appears to have been combined based on existence of combined file. Date not checked

schimpy.combine_consume.archive_blocks(ar_file, tbase, blocks_per_day=1, ndxmin=1, ndxmax=None)
schimpy.combine_consume.combine(wdir, blocks, fbase, combine_exe, consume=True, assume_done=True)
schimpy.combine_consume.combine_consume(is_test=False)
schimpy.combine_consume.combine_hotstart(wdir, combine_hotstart_exe, minstep=0, maxstep=99999999, consume=True)
schimpy.combine_consume.create_arg_parser()

Create argument parser for

schimpy.combine_consume.detect_min_max_index(wdir, sample_fbase)
schimpy.combine_consume.do_combine(wdir, begin, end, filebase)
schimpy.combine_consume.do_combine_hotstart(wdir, step)
schimpy.combine_consume.failed_incomplete(e)
schimpy.combine_consume.gather_ppf_names(wdir, blocks)
schimpy.combine_consume.main()
schimpy.combine_consume.prune_ppf_files(wdir, blocks, fbase, list_only=False)
schimpy.combine_consume.setup(wdir, filebase)
schimpy.combine_consume.split(alist, n)
schimpy.combine_consume.touch(fname, times=None)

schimpy.combine_flux module

Command line tool to merge possibly overlapping flux.dat files from hotstart runs

schimpy.combine_flux.combine_flux(infiles, outfile, prefer_last=False)

Merge possibly overlapping flux.dat files from hostart runs

schimpy.combine_flux.create_arg_parser()
schimpy.combine_flux.main()

Driver to parse arguments

schimpy.combine_flux.test_combine_flux()

schimpy.contour_smooth module

This module contains tools for a smoother for DEMs (currently tiff format) based on curvature flow The algorithm is based on one by Malladi and Sethian, and results in a simplification of contours while allowing sharp gradients as long as they are persistent. So it is not a cure for pressure gradient errors a la Hannah. The script shows some artefacts of a time when it wasn’t particularly stable and could run out of memory. In particular, the algorithm dumps out intermediate arrays as it goes along and these have to be visualized or saved using the appropriate subcommands or functions. Stability is no longer an issue. it has been good for quite a while. Not so sure about memory. We’ve not tested a big problem yet on a big DEM on 64bit python.

class schimpy.contour_smooth.RasterWrapper(filename)

Bases: object

Methods

write_copy

write_copy(filename, data)
schimpy.contour_smooth.calc_f(t, data, width_shape)

Right hand side of the semi-discretized operator (in space) so that it can be integrated in time

schimpy.contour_smooth.contour_smooth(input, scales, max_time, nstep, report_interval, fill_val=2.0, **kwargs)

Driver function for smoothing a DEM

schimpy.contour_smooth.contour_smooth2d(dem, scales, max_time, nstep, report_interval)
schimpy.contour_smooth.create_arg_parser()
schimpy.contour_smooth.main()
schimpy.contour_smooth.save_smooth(dumpfile, original, outfile, **kwargs)
schimpy.contour_smooth.view_smooth(file0, file1, levels, vmin, vmax, **kwargs)

View the dumped files to graphically explore smoothing progress

schimpy.convert_linestrings module

Command line tool to convert SCHISM line strings in YAML to Shapefile and vice versa

schimpy.convert_linestrings.create_arg_parser()

Create an argument parser

schimpy.convert_linestrings.main()

A main function to convert polygon files

schimpy.convert_mesh module

schimpy.convert_points module

schimpy.convert_polygons module

Command line tool to convert SCHISM polygons in YAML to Shapefile and vice versa

schimpy.convert_polygons.create_arg_parser()

Create an argument parser

schimpy.convert_polygons.main()

A main function to convert polygon files

schimpy.convert_sav_class_to_number module

schimpy.create_mesh_n_levels module

schimpy.create_vgrid_lsc2 module

schimpy.cruise module

schimpy.cruise.create_arg_parser()
schimpy.cruise.cruise_xyt(path, station_data, base_time, outfile)
schimpy.cruise.do_depth_plot(station, cruise_data, surrounding_profiles, ax, xlabel, ylabel, add_legend=False)
schimpy.cruise.gen_profile_plot(base_date, cruise_time, survey_file, model_file, station_file, xytfile)
schimpy.cruise.gen_station_xyt(base_date, cruise_time, survey_file, station_file, xytfile)
schimpy.cruise.longitudinal(cruise_data, station_data, ax, context_label=None, add_labels=False, xlabel=None, xmin=None, xmax=None, max_depth=None)
schimpy.cruise.main(base_date, cruise_time, obs_file, model_file, station_file, xytfile)
schimpy.cruise.match_cruise(time, station, x, z, times, data)
schimpy.cruise.model_data_for_longitude(cruise_data, station_data, x, z, times, model_data, base_date)
schimpy.cruise.process_cruise(path)
schimpy.cruise.process_stations(station_file)
schimpy.cruise.process_xyt(path, casts, base_time)

schimpy.cut_mesh module

schimpy.download_hrrr module

Created on Fri Jan 20 09:07:50 2023 Download NOAA High-Resolution Rapid Refresh (HRRR) Model using AWS bucket service

schimpy.download_hrrr.create_arg_parser()

Create an argument parser return: argparse.ArgumentParser

schimpy.download_hrrr.download_hrr(start_date, rnday, pscr, bbox)
schimpy.download_hrrr.main()

Main function

schimpy.embed_raster module

Embed finer gridded data in coarser, using curvature flow smoothing to reconcile

Main function is called embed_fine

schimpy.embed_raster.create_arg_parser()
schimpy.embed_raster.embed_raster(input_fg, input_bg, output, nsmooth_init=2, nsmooth_final=1, plot=False, max_time_init=3, max_time_final=1, nstep=50, report_interval=1, **kwargs)

Embed a smoother DEM in a coarser

The two inputs and output are filenames. The basic plans is this: 1. Smooth the fine data enough to resample without aliasing or distortion 2. Interpolate/resample the result to the coarser mesh 3. Where the result of 1-2 has good data, replace coarser data 4. Smooth the final grid lightly to remove kinks/discontinuity

The smoothing is done with contour_smooth2d

schimpy.gaussian_quadrature module

Gaussian quadrature in 2D space

class schimpy.gaussian_quadrature.GaussianQuadrature(order)

Bases: object

Abstract base class of GaussianQuadrature

Methods

average(vertices, values)

Calculate the average of the value over the domain.

calculate_quadrature_points_and_weights()

Calculate quadrature points and weights

domain_size(vertices)

Abstract method to calculate the size of the domain

integrate(vertices[, values])

Integrate values over a quad element

jacobian_det(vertices)

Determinant of Jacobian at quadrature points

number_of_quadrature_points()

Get the number of quadrature points

quadrature_vector(vertices)

Create a quadrature matrix for quadrature integration Taking a dot product this quadrature matrix and the values at the quadrature points will result in quadrature

shape(pts)

Abstract shape function

shape_derivative(pts)

Abstract shape derivative function

values_at_quadrature_points(values)

Get quadrature points

average(vertices, values)

Calculate the average of the value over the domain.

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) The shape needs to be (:, 2) or more columns. The values in the first two columns will be used.

Returns:
float

the length of the line

calculate_quadrature_points_and_weights()

Calculate quadrature points and weights

Parameters:
pts: np.ndarray

Coordinates of the nodes

Returns:
ptsreal

quadrature points

domain_size(vertices)

Abstract method to calculate the size of the domain

integrate(vertices, values=None)

Integrate values over a quad element

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) with values. The shape needs to be (:, 2)

values: numpy.array, optional

A value vector at vertices If it is not provided, the thrid column will be used as values

Returns:
float

result of integration

jacobian_det(vertices)

Determinant of Jacobian at quadrature points

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) The shape needs to be (:, 2) or more columns. The values in the first two columns will be used.

Returns:
numpy.array

array of determinant ant quadrature points

number_of_quadrature_points()

Get the number of quadrature points

Returns:
int

Number of quadrature points

quadrature_vector(vertices)

Create a quadrature matrix for quadrature integration Taking a dot product this quadrature matrix and the values at the quadrature points will result in quadrature

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) with values. The shape needs to be (:, 2)

Returns:
numpy.array

two-dimensional matrix of quadrature matrix

shape(pts)

Abstract shape function

Parameters:
pts: np.ndarray

Coordinates of the nodes

shape_derivative(pts)

Abstract shape derivative function

Parameters:
pts: np.ndarray

Coordinates of the nodes

values_at_quadrature_points(values)

Get quadrature points

Parameters:
values: numpy.array

values at quadrature points

Returns:
numpy.array

values of Gaussian quadrature points

class schimpy.gaussian_quadrature.GaussianQuadratureLine2(order)

Bases: GaussianQuadrature

Gaussian quadrature on line with two end points in 2-D space

Methods

average(vertices, values)

Integrate values over a quad element

calculate_quadrature_points_and_weights()

Calculate quadrature points and weights

domain_size(vertices)

Size of domian, which is the length of the line in this case

integrate(vertices[, values])

Integrate values over a quad element

jacobian_det(vertices)

Determinant of Jacobian at quadrature points, 1-D version

number_of_quadrature_points()

Get the number of quadrature points

quadrature_vector(vertices)

Create a quadrature matrix for quadrature integration Taking a dot product this quadrature matrix and the values at the quadrature points will result in quadrature

shape(pts)

Shape functions Ordering is counter-clockwise direction

shape_derivative(pts)

Derivatives of shape functions

values_at_quadrature_points(values)

Get quadrature points

average(vertices, values)

Integrate values over a quad element

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) with values. The shape needs to be (-1, 2)

values: numpy.array

The values at vertices

Returns:
averagefloat

result of integration

calculate_quadrature_points_and_weights()

Calculate quadrature points and weights

Parameters:
pts: np.ndarray

Coordinates of the nodes

Returns:
ptsreal

quadrature points

domain_size(vertices)

Size of domian, which is the length of the line in this case

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) The shape needs to be (2, 2) or more columns. The values in the first two columns will be used.

Returns:
float

the length of the line

jacobian_det(vertices)

Determinant of Jacobian at quadrature points, 1-D version

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) The shape needs to be (-1, 2) or more columns. The values in the first two columns will be used.

Returns:
numpy.array

array of determinant ant quadrature points

shape(pts)

Shape functions Ordering is counter-clockwise direction

Parameters:
pts: numpy.array

Local coordinates.

Returns:
numpy.array

matrix of shape function value at the given points

shape_derivative(pts)

Derivatives of shape functions

Parameters:
pts: numpy.array

Local coordinates. The dimension is (-1, 2)

Returns:
numpy.array

matrix of shape function derivative wrt xi value at (*, eta)

class schimpy.gaussian_quadrature.GaussianQuadratureQuad4(order)

Bases: GaussianQuadrature

Gaussian Quadrature for a quadrilateral with four nodes

Methods

average(vertices, values)

Calculate the average of the value over the domain.

calculate_quadrature_points_and_weights()

Calculate quadrature points and weights

domain_size(vertices)

Size of domain, which is the area of the quadrilateral in this case.

integrate(vertices[, values])

Integrate values over a quad element

jacobian(vertices[, local_coord])

Create a Jacobian matrix or matrixes at the given local coordinates

jacobian_det(vertices)

Determinant of Jacobian at quadrature points

number_of_quadrature_points()

Get the number of quadrature points

quadrature_vector(vertices)

Create a quadrature matrix for quadrature integration Taking a dot product this quadrature matrix and the values at the quadrature points will result in quadrature

shape(pts)

Shape functions Ordering is counter-clockwise direction

shape_derivative(pts)

Derivatives of shape functions

values_at_quadrature_points(values)

Get quadrature points

calculate_quadrature_points_and_weights()

Calculate quadrature points and weights

domain_size(vertices)

Size of domain, which is the area of the quadrilateral in this case. The area is calculated with shoelace equation.

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) The shape needs to be (4, 2) or more columns. The values in the first two columns will be used.

Returns:
ret_size: float

the length of the line

jacobian(vertices, local_coord=None)

Create a Jacobian matrix or matrixes at the given local coordinates

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) The shape needs to be (4, 2) or more columns. The values in the first two columns will be used.

local_coord: numpy.array

local coordinates where a Jacobian is calculated

Returns:
numpy.array

Jacobian matrix

shape(pts)

Shape functions Ordering is counter-clockwise direction

Parameters:
pts: numpy.array

Local coordinates. The dimension is (-1, 2)

Returns:
numpy.array

matrix of shape function value at (xi, eta)

shape_derivative(pts)

Derivatives of shape functions

Parameters:
pts: numpy.array

Local coordinates. The dimension is (-1, 2)

Returns:
numpy.array

matrix of shape function derivative wrt xi value at (*, eta)

class schimpy.gaussian_quadrature.GaussianQuadratureTri3(order)

Bases: GaussianQuadrature

Gaussian Quadrature for triangles with three nodes

Methods

average(vertices, values)

Calculate the average of the value over the domain.

calculate_quadrature_points_and_weights()

Calculate quadrature points and weights

domain_size(vertices)

Size of domian, which is the area of the quadrilateral in this case.

integrate(vertices[, values])

Integrate values over a quad element

jacobian(vertices[, local_coord])

Create a Jacobian matrix or matrixes at the given local coordinates

jacobian_det(vertices)

Determinant of Jacobian at quadrature points

number_of_quadrature_points()

Get the number of quadrature points

quadrature_vector(vertices)

Create a quadrature matrix for quadrature integration Taking a dot product this quadrature matrix and the values at the quadrature points will result in quadrature

shape(pts)

Shape functions Ordering is counter-clockwise direction

shape_derivative(pts)

Derivatives of shape functions

values_at_quadrature_points(values)

Get quadrature points

calculate_quadrature_points_and_weights()

Calculate quadrature points and weights

domain_size(vertices)

Size of domian, which is the area of the quadrilateral in this case. The area is calculated with shoelace equation.

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) The shape needs to be (3, 2) or more columns. The values in the first two columns will be used.

Returns:
float

the length of the line

jacobian(vertices, local_coord=None)

Create a Jacobian matrix or matrixes at the given local coordinates

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) The shape needs to be (4, 2) or more columns. The values in the first two columns will be used.

local_coord: numpy.array

local coordinates where a Jacobian is calculated

Returns:
numpy.array

Jacobian matrix

jacobian_det(vertices)

Determinant of Jacobian at quadrature points

Parameters:
vertices: numpy.array

coordinates of vertices (or nodes) but it is not used

Returns:
numpy.array

array of determinant ant quadrature points

shape(pts)

Shape functions Ordering is counter-clockwise direction

Parameters:
pts: numpy.array

Local coordinates. Not used

Returns:
numpy.array

matrix of shape function value at (xi, eta)

shape_derivative(pts)

Derivatives of shape functions

Parameters:
pts: numpy.array

Local coordinates. Not used

Returns:
numpy.array

matrix of shape function derivative wrt xi value at (*, eta)

schimpy.gen_elev2d module

schimpy.geo_tools module

schimpy.geo_tools.FindMultiPoly(poly_array)
schimpy.geo_tools.Polylen(poly)
schimpy.geo_tools.geometry2coords(geo_obj)
schimpy.geo_tools.geometry2coords_points(geo_obj)
schimpy.geo_tools.ic_to_gpd(fn, crs=None)

Read ic yaml file and convert the polygons to geopandas format

schimpy.geo_tools.ll2utm(lonlat, crs=None)

lonlat can be numpy arrays. lonlat = np.asarray([lon,lat]) default crs = epsg:26910

schimpy.geo_tools.partition_check(mesh, poly_fn, regions, centering='node', crs=None, allow_overlap=False, allow_incomplete=False)

Check if the schism mesh division by the polygon features in poly_fn is unique and complete. The partition check is based on either node or element, and the function checks:

  • if there are any orphaned nodes, and

  • if any nodes/elems were assigned to multiple polygons.

schimpy.geo_tools.project_fun(crs=None)
schimpy.geo_tools.shapely_to_geopandas(features, crs=None, shp_fn=None)

Convert shapely features to geopandas and generate shapefiles as needed

schimpy.geo_tools.shp2yaml(shp_fn, yaml_fn=None, crs=None)

Convert a shapefile to yaml file

Parameters:
shp_fnstr

Input shape filename

yaml_fnstr

Output yaml filename

crsstr, optional

Output projection. The default is None.

Returns:
None.
schimpy.geo_tools.utm2ll(utm_xy, crs=None)

utm_xy can be numpy arrays. utm_xy = np.asarray([utm_x,utm_y]) default crs = epsg:26910

schimpy.geo_tools.yaml2shp(fn, shp_fn=None, crs=None)

schimpy.gr3 module

schimpy.grid_opt module

schimpy.hotstart_inventory module

schimpy.hotstart_inventory.create_arg_parser()
schimpy.hotstart_inventory.hotstart_inventory(run_start=None, dt=None, nday=None, workdir='.', paramfile=None, hot_freq=None)

Create an inventory of existing hotstarts or expected hotstarts

Existing vs expected depends on whether workdir is an outputs or study dir.

Parameters:
startConvertible to Datetime

Start date of run. If None inferred from paramfile. Error if

dtfloat

dt in seconds, for instance perhaps 90s for clinic or 120s for tropic. This is needed to intepret the so-called iteration number in the hotstart labels which are really time step numbers.

workdirstr

Directory to inventory. If it is an outputs directory, the inventory

comprise existing hotstarts.
paramfilestr

Name of param.nml file, expected in workdir or workdir/.. If None, then both start and dt must be supplied. If all three are None, the name “param.nml” will be attempted

Returns:
Dataframe, if programatic, listing hotstarts. Should look like “Date, Iteration” pairs. CLI should print it out.

Notes

If the listing is done in the run dir, this will be the expected hotstarts. If it is in the outputs dir, it will be an inventory of existing hotstarts.

schimpy.hotstart_inventory.hotstart_inventory2(start, dt=90)
schimpy.hotstart_inventory.main()

schimpy.hrr3 module

adapted from pyschism, original work of Linlin Cui.

class schimpy.hrr3.AWSGrib2Inventory(start_date: datetime | None = None, record=1, pscr=None, product='conus')

Bases: object

Attributes:
bucket
files
output_interval
s3
tmpdir
property bucket
property files
property output_interval: timedelta
property s3
property tmpdir
class schimpy.hrr3.HRRR(start_date=None, rnday=None, pscr=None, record=1, bbox=None)

Bases: object

Methods

gen_sflux

modified_latlon

gen_sflux(date, record, pscr)
modified_latlon(grbfile)
schimpy.hrr3.localize_datetime(d)
schimpy.hrr3.nearest_cycle(input_datetime=None, period=6, method='floor')

schimpy.interp_2d module

invdisttree.py: inverse-distance-weighted interpolation using KDTree

class schimpy.interp_2d.Invdisttree(x, nnear=10, leafsize=10)

Bases: object

Inverse-distance-weighted interpolation using KDTree

Examples

tree = interp_2d.Invdisttree(obs_xy) # initialize KDTree with observational points tree.weights(node_xy) # calculate weights for each node. values_v = tree.interp(obs.temperature.values) # perform spatial interpolation with the calculated weights from the previous step

Methods

interp(obs[, ninterp])

Perform interpolation

weights(node_xy[, eps, p, weights])

Find the nearest neighbors and assign weights to each neibors

interp(obs, ninterp=6)

Perform interpolation

Parameters:
obsnp.ndarray

observational values; nan values are allowed and will be ignored.

ninterppositive int, ninterp<=nnear

The number of nearest points to perform interpolation The default is 6.

Returns:
val_interpnp.ndarray

interpolated values

weights(node_xy, eps=0, p=2, weights=None)

Find the nearest neighbors and assign weights to each neibors

Parameters:
node_xynp.ndarray, shape (n,2)

Coordinates of the query points n is the number of query points

epspositive float, optional

approximate nearest, dist <= (1 + eps) * true nearest. The default is 0.

ppositive int, optional

power. The default is 2.

weightsfloat, optional

optional multiplier for weights, same dimension as node_xy The default is None.

Returns:
None.

schimpy.interpolate_structure module

schimpy.interpolate_structure.create_arg_parser()
schimpy.interpolate_structure.ensure_offset(arg)
schimpy.interpolate_structure.interpolate_structure(template_th, output_th, dt=None, int_cols=['install', 'ndup_weir', 'ndup_culvert', 'ndup_pipe'])

Interpolate a dated th “template” for a structure The interpolation adds time detail, maintain data types. Comments are removed and floating precision is hardwired to two digits

The input template file must have a header and time stamps that are neat with respect to dt. This is checked.

Parameters:
template_thstr

Path to the template file

output_thstr

Name of the output file

dtinterval_type

Number of hours between changes, default is 1 hour. Can be any time (string, delta, offset) that can be coerced to offset

int_colslist

List of column names that should be integers. This can be a superset, and it shouldn’t change much if you name your template columns the standard way.

schimpy.interpolate_structure.main()
schimpy.interpolate_structure.test_date_label_correct(fname_th)

Make sure that the date column in the file doens’t have comment marker and raise error if it does

schimpy.interpolate_structure.test_template_times(template, dt)

schimpy.laplace_smooth_data module

schimpy.laplace_smooth_data.laplace_smooth_data(mesh, data, rate=0.05, iter_total=150)
schimpy.laplace_smooth_data.laplace_smooth_data2(mesh, data, kappa=0.05, dt=1.0, iter_total=150)
schimpy.laplace_smooth_data.laplace_smooth_with_vel(mesh, data, vel, kappa=0.05, dt=1.0, iter_total=1)
schimpy.laplace_smooth_data.laplace_smooth_with_vel2(mesh, data, vel, kappa=0.05, dt=1.0, iter_total=1)
schimpy.laplace_smooth_data.laplace_smooth_with_vel3(mesh, nlayer, data, vel, kappa=0.05, dt=1.0, iter_total=1)

schimpy.lsc2 module

Methods for generating local sigma coordinates These routines are meant to be called a pair. First, default_num_layers is called to obtain the recommended number of layers for each node based on depth. Then, gen_sigma is called to generate the actual local sigma values at each level (nlevels = nlayers+1).

Note that in this script eta is the “reference” free surface at which the mesh is conditioned, which can be a global scalar or array of local nodal values. Using a medium-higher value (2-4 depending on typical flood levels) usually does’t hurt the final product in low water. The example() shows how to visualize a mesh generated on one ref water surface on another surface.

The major user parameters are already set at their defaults. It is mildly important to realize that the S coordinate parameters have the same qualitative interpretation, but that the S system is really just used as a heuristic and everything is manipulated locally.

Besides theta (refinement to the surface) the mostly likely item to manipulate will be minlayer and maxlayer. These can be supplied locally (if these are given as arrays) or globally (if provided as scalars).

class schimpy.lsc2.BilinearMeshDensity

Bases: object

Methods

density

depth

density(z, h, x)
depth(t, h, x)
class schimpy.lsc2.CubicLSC2MeshFunction

Bases: object

Methods

density

depth

density(x, tlev)
depth(x, tlev)
schimpy.lsc2.default_num_layers(x, eta, h0, minlayer, maxlayer, dz_target, meshfun, maxlev=100)

Returns the number of layers that, according to meshfun, gives a depth matching eta + h0 In the (likely) case of inexact fit) the lower bound n- of the number of layers not yet outfitted for variation in x

schimpy.lsc2.default_num_layers0(total_ref_depth, minlayer, maxlayer)
schimpy.lsc2.example()
schimpy.lsc2.example2()
schimpy.lsc2.example3()
schimpy.lsc2.flip_sigma(sigma)

Flip the ordering of non-nan sigma values.

The output of get_sigma starts from 0.0, but sigma in vgrid.in from -0.1. So it needs to be flipped for further use.

Parameters:
sigma: numpy.ndarray
Returns:
numpy.ndarray

New sigma array that has flipped ordering.

schimpy.lsc2.gen_sigma(nlayer, minlayer, maxlayer, eta, h, mesh, meshfun, nsmoothlay=0)

“ Generate local sigma coordinates based on # layers, reference surface and depth

Parameters:
nlayer: ndarray

Veector of size np (number of nodes) giving desired # layers for each node in the mesh

eta: ndarray or float

reference water level heights at each node at which generation is to occur.

h: ndarray

unperturbed depth for each node in the mesh

meshfloat

maximum theta to use in S calculations. This is interpreted the same as a standard S grid theta although it will be varied according to depth

meshfun: float

S coordinate parameter b

nsmoothlay: how many layers to smooth on the bottom
hc: float

S coordinate parameter hc (do not alter)

schimpy.lsc2.label_components(mesh, nlayer, thresh, exclude)
schimpy.lsc2.lowest_layer_height(htrans, nlevel, klev=0)
schimpy.lsc2.mesh_function_depths(nlayer, depth, mesh, meshfun)
schimpy.lsc2.plot_mesh(ax, x, zcor, startvis, stopvis, c='black', linewidth=1)
schimpy.lsc2.process_orphans(mesh, nlayer, depth, hcor)
schimpy.lsc2.process_orphans2(mesh, nlayer, depth, hcor)
schimpy.lsc2.sigma_z(sigma, eta, h)
schimpy.lsc2.smooth_bed(mesh, eta, h, hcor, nlevel, speed)
schimpy.lsc2.szcoord(s, h, eta, theta, b, hc)
schimpy.lsc2.z_sigma(zcor)

schimpy.material_poly module

schimpy.material_poly.create_arg_parser()
schimpy.material_poly.create_poly(shapefile, dsetname, keyfile, polyfile, type, default=None)

Converts a polygon shapefile to the yaml input of the preprocessor

schimpy.material_poly.read_keyfile(keyfile)

Reads a file pairing labels and values

schimpy.merge_th module

schimpy.merge_th.create_arg_parser()
schimpy.merge_th.main()
schimpy.merge_th.merge_th(th_spec)
schimpy.merge_th.read_data(fname, variable)
schimpy.merge_th.read_locations_from_input(fname, role)
schimpy.merge_th.read_th_spec(fname)
schimpy.merge_th.write_th(df, fname, elapsed, ref_time=None)

schimpy.metricsplot module

Metrics plot

schimpy.metricsplot.plot_comparison(*args, style_palette, **kwargs)

Create a simple comparison plot without metrics calculation

Parameters:
*args: variable number of TimeSeries
Returns:
matplotlib.pyplot.figure.Figure
schimpy.metricsplot.plot_metrics(obs, tssim, style_palette, **kwargs)

Create a metrics plot

Parameters:
*args: variable number of TimeSeries
Returns:
matplotlib.pyplot.figure.Figure

schimpy.model_time module

Script to make model date conversion convenient, converting elapsed model seconds to or from dates

schimpy.model_time.clip(args)

Clip file to dates

schimpy.model_time.create_arg_parser()
schimpy.model_time.describe_elapsed(times, start, dt=None)
schimpy.model_time.describe_timestamps(timestamps, start, dt=None)
schimpy.model_time.file_to_elapsed(infile, start, outpath=None, annotate=False, skip_nan=False)
schimpy.model_time.file_to_timestamp(infile, start, outpath=None, annotate=False, elapsed_unit='s', time_format='%Y-%m-%dT%H:%M ')
schimpy.model_time.main()
schimpy.model_time.multi_file_to_elapsed(input_files, output, start, name_transform='prune_dated')
schimpy.model_time.prune_dated(name)
schimpy.model_time.to_datetime(args)

Convert elapsed inputs to dated

schimpy.model_time.to_elapsed(args)

Convert dated inputs to elapsed times

schimpy.nml module

class schimpy.nml.Namelist(d)

Bases: object

The Namelist class simply creates an attribute for each key-value pair in the dictionary.

class schimpy.nml.TopLevelNamelist(d)

Bases: object

TopLevelNamelist is a class for the top-level elements of the dictionary, and Namelist is a class for all other nested elements. The TopLevelNamelist class creates attributes for each key-value pair in the dictionary and, if the value is itself a dictionary, creates a new Namelist object with the nested dictionary.

schimpy.nml.map_to_dict(obj)

This function takes an object of type TopLevelNamelist as input and returns a dictionary representation of the object. The function uses the vars built-in function to get a dictionary of attributes and values for the object, and then iterates over the key-value pairs in the dictionary. If the value is an instance of the Namelist class, it recursively maps the Namelist object to a dictionary using the map_to_dict function. If the value is not an instance of the Namelist class, it simply adds the key-value pair to the dictionary. This way, you can easily map an object of type TopLevelNamelist back to a dictionary representation, preserving the structure of the original dictionary.

schimpy.nml.map_to_object(d)

In this example, TopLevelNamelist is a class for the top-level elements of the dictionary, and Namelist is a class for all other nested elements. The TopLevelNamelist class creates attributes for each key-value pair in the dictionary and, if the value is itself a dictionary, creates a new Namelist object with the nested dictionary. The Namelist class simply creates an attribute for each key-value pair in the dictionary.

The map_to_object function takes a dictionary d as input and returns a new TopLevelNamelist object with the values from d.

This way, you can easily map the dictionary returned by parse_namelist to objects, with different classes for the top-level and nested elements, and access the values in the dictionary as attributes of the objects.

schimpy.nml.parse(file_content)

Here’s a simple implementation of a parser for the Fortran namelist format If there’s a line starting with !, the parser will store it as the full_line_comment and attach it to the next key-value pair it encounters. If there’s an inline comment starting with !, it will be stored as inline_comment.

For the most part this parser is comment preserving; you might notice some whitespace and blank line(s) being eliminated in the round trip through write method below

schimpy.nml.write(namelist_data)

writes out the namelist dictionary from the parse method to a string. The comments are preserved but not the whitespace or indentations

schimpy.nudging module

schimpy.param module

class schimpy.param.Params(fname, default=None)

Bases: object

Attributes:
hotstart_freq
nc_out_freq
nc_stack
run_start

Get start time as datetime

station_out_freq

Methods

adjust_dt()

Adjust dt without perturbing variables that depend on it

copy()

Return a copy of this Params set

diff(other[, defaults])

Compare to another instance of Params

get_run_start()

Get start time as datetime

process_default(default)

Process default parameters

searchfor(key[, section])

Search for key in all the sections

set_hotstart_freq(freq)

Set hotstart frequency using Pandas offset or string that evaluates as offset

set_interval(name, freq)

Set binary output frequency using Pandas offset or string that evaluates as offset

set_nc_out_freq(freq)

Set binary output frequency using Pandas offset or string that evaluates as offset

set_nc_stack(freq)

Set binary output frequency using Pandas offset or string that evaluates as offset

set_run_start(run_start)

Set start time

set_station_out_freq(freq)

Set station output frequency

update(other[, defaults])

Update from another instance of Params in-place

validate()

Validation tests

get_hotstart_freq

get_interval

get_nc_out_freq

get_nc_stack

get_station_out_freq

sections

to_dataframe

write

adjust_dt()

Adjust dt without perturbing variables that depend on it

copy()

Return a copy of this Params set

diff(other, defaults=False)

Compare to another instance of Params

Parameters:
other: str | Params

Can be a string that evaluates to param filename, a Param object

defaultsbool

Search includes defaults

Returns:
diffpd.DataFrame

Data with multi index for section and parameter, including only parameters that are different, including possibly one being absent from one Param set

get_hotstart_freq()
get_interval(name)
get_nc_out_freq()
get_nc_stack()
get_run_start()

Get start time as datetime

get_station_out_freq()
property hotstart_freq
property nc_out_freq
property nc_stack
process_default(default)

Process default parameters

Parameters:
defaultstr or Param instance or ‘repo’

If default is ‘repo’, default is the GitHub repo version. If it is a filename, that name is evaluated. If it is a templated version, that version is read. (config part of this not done yet)

property run_start

Get start time as datetime

searchfor(key, section=False)

Search for key in all the sections

Parameters:
keystr

Key to search for

section = bool If boolean, returns a tuple of section, value

default = str Name of default to use for backup

Returns

Value cached under key

Raises

IndexError if key not present

sections(defaults=False)
set_hotstart_freq(freq)

Set hotstart frequency using Pandas offset or string that evaluates as offset

Parameters:
freq
If None, frequency will be set using default (or 1 Hour) and station output disabled
set_interval(name, freq)

Set binary output frequency using Pandas offset or string that evaluates as offset

set_nc_out_freq(freq)

Set binary output frequency using Pandas offset or string that evaluates as offset

set_nc_stack(freq)

Set binary output frequency using Pandas offset or string that evaluates as offset

set_run_start(run_start)

Set start time

Parameters:
startdatetime
Coercible to datetime
set_station_out_freq(freq)

Set station output frequency

Parameters:
freqoffset or string

Sets output interval for staout files and ensures that output is enabled. If None, frequency will be set using default (or 1 Hour) and station output disabled

property station_out_freq
to_dataframe(defaults=None)
update(other, defaults=False)

Update from another instance of Params in-place

Parameters:
other: str | Params

Can be a string that evaluates to param filename, a Param object

defaultsbool

Search includes defaults

validate()

Validation tests

write(fname)
schimpy.param.param_from_template(name)

Returns param based on named template files

schimpy.param.read_params(fname, default=None)
schimpy.param.test_param()

schimpy.params module

class schimpy.params.Core(*, dt, eco_class, ibc, ibtp, ihfskip, ipre, mdc2, msc2, nspool, ntracer_age, ntracer_gen, rnday, sed_class, name)

Bases: Parameterized

dt = 0.0
eco_class = 0
ibc = 0
ibtp = 0
ihfskip = 0
ipre = 0
mdc2 = 0
msc2 = 0
name = 'Core'
nspool = 0
ntracer_age = 0
ntracer_gen = 0
rnday = 0.0
sed_class = 0
class schimpy.params.HydroOutput(*, air_pressure, air_temperature, barotropic_pres_grad_xy, bottom_stress_xy, depth_avg_vel_xy, diffusivity, downward_longwave, dry_flag_node, elevation, evaporation_rate, horizontal_side_vel_xy, horizontal_vel_xy, latent_heat, mixing_length, precipitation_rate, salinity, salinity_at_element, sensible_heat, solar_radiation, specific_humidity, temperature, temperature_at_element, total_heat, turbulent_kinetic_ener, upward_longwave, vertical_vel_at_element, vertical_velocity, viscosity, water_density, wind_speed_xy, wind_stress_xy, z_coordinates, name)

Bases: OutControls

Class to specify which variables to output from the SCHISM model

Methods

from_iof_array

get_iof_array_names

to_iof_array

air_pressure = False
air_temperature = False
barotropic_pres_grad_xy = False
bottom_stress_xy = False
depth_avg_vel_xy = False
diffusivity = False
downward_longwave = False
dry_flag_node = True
elevation = False
evaporation_rate = False
horizontal_side_vel_xy = False
horizontal_vel_xy = False
latent_heat = False
mixing_length = False
name = 'HydroOutput'
precipitation_rate = False
salinity = False
salinity_at_element = False
sensible_heat = False
solar_radiation = False
specific_humidity = False
temperature = False
temperature_at_element = False
total_heat = False
turbulent_kinetic_ener = False
upward_longwave = False
vertical_vel_at_element = False
vertical_velocity = False
viscosity = False
water_density = False
wind_speed_xy = False
wind_stress_xy = False
z_coordinates = False
class schimpy.params.Opt(*, alphaw, btrack_nudge, coricoef, courant_weno, cur_wwm, dfh0, dfv0, dramp, dramp_ss, drampbc, drampwafo, drampwind, dtb_max, dtb_min, dzb_min, eos_a, eos_b, eps1_tvd_imp, eps2_tvd_imp, epsilon1, epsilon2, epsilon3, flag_fib, flag_ic, fwvor_advxy_stokes, fwvor_advz_stokes, fwvor_breaking, fwvor_gradpress, fwvor_streaming, fwvor_wveg, fwvor_wveg_NL, gen_wsett, h0, h1_bcc, h1_pp, h2_bcc, h2_pp, h_bcc1, h_massconsv, h_tvd, hmin_airsea_ex, hmin_man, hmin_radstress, hmin_salt_ex, hvis_coef0, hw_depth, hw_ratio, i_hmin_airsea_ex, i_hmin_salt_ex, i_prtnftl_weno, iadjust_mass_consv0, ibcc_mean, ibdef, ibtrack_test, ic_elev, icou_elfe_wwm, ics, ielad_weno, ielm_transport, ieos_pres, ieos_type, if_source, iflux, iflux_out_format, iharind, ihconsv, ihdif, ihhat, ihorcon, ihot, ihydraulics, iloadtide, imm, indvel, inter_mom, inu_elev, inu_tr, inu_uv, inunfl, inv_atm_bnd, ip_weno, ipre2, iprecip_off_bnd, irouse_test, isav, isconsv, ishapiro, itr_met, itransport_only, itur, iunder_deep, iupwind_mom, iwbl, iwind_form, iwindoff, izonal5, kr_co, lev_tr_source, level_age, loadtide_coef, max_subcyc, meth_sink, mid, moitn0, mxitn0, nadv, nchi, ncor, niter_shap, nquad, nramp_elev, nstep_ice, nstep_wwm, ntd_weno, nu_sum_mult, nws, prmsl_ref, rearth_eq, rearth_pole, rho0, rinflation_icm, rlatitude, rmaxvel, rtol0, s1_mxnbt, s2_mxnbt, sfea0, shapiro0, shorewafo, shw, slam0, slr_rate, small_elad, stab, start_day, start_hour, start_month, start_year, step_nu_tr, tdmin_pp1, tdmin_pp2, thetai, turbinj, turbinjds, utc_start, vclose_surf_frac, vdmax_pp1, vdmax_pp2, vdmin_pp1, vdmin_pp2, velmin_btrack, vnf1, vnf2, vnh1, vnh2, wafo_obcramp, wtiminc, xlsc0, name)

Bases: Parameterized

alphaw = 0.0
btrack_nudge = 0.009013
coricoef = 1.0
courant_weno = 0.8
cur_wwm = False
dfh0 = 0.0
dfv0 = 1.0
dramp = 1.0
dramp_ss = 60.0
drampbc = 1.0
drampwafo = 0.0
drampwind = 86400.0
dtb_max = 100.0
dtb_min = 1.0
dzb_min = 1e-05
eos_a = -0.1
eos_b = 1001.0
eps1_tvd_imp = 0.001
eps2_tvd_imp = 0.0001
epsilon1 = 1e-05
epsilon2 = 0.001
epsilon3 = 0.0001
flag_fib = 0
flag_ic = 0
fwvor_advxy_stokes = False
fwvor_advz_stokes = False
fwvor_breaking = False
fwvor_gradpress = False
fwvor_streaming = False
fwvor_wveg = False
fwvor_wveg_NL = False
gen_wsett = True
h0 = 1.0
h1_bcc = 1.0
h1_pp = 0.2
h2_bcc = 0.5
h2_pp = 1.0
h_bcc1 = 1.5
h_massconsv = 0.001
h_tvd = 2.0
hmin_airsea_ex = 0.01
hmin_man = 0.05
hmin_radstress = 0.1
hmin_salt_ex = 0.01
hvis_coef0 = 0.1
hw_depth = 15.0
hw_ratio = 1.2
i_hmin_airsea_ex = 1
i_hmin_salt_ex = 1
i_prtnftl_weno = 1
iadjust_mass_consv0 = 1
ibcc_mean = 0
ibdef = 10
ibtrack_test = 1
ic_elev = 0.0
icou_elfe_wwm = 0
ics = 0
ielad_weno = 0
ielm_transport = 0
ieos_pres = 0.0
ieos_type = 0
if_source = 2
iflux = 2
iflux_out_format = 0
iharind = 1
ihconsv = 0
ihdif = 0
ihhat = 0
ihorcon = 0
ihot = 0
ihydraulics = 0
iloadtide = 0
imm = 0
indvel = 0
inter_mom = 1
inu_elev = 1
inu_tr = 0
inu_uv = 1
inunfl = True
inv_atm_bnd = False
ip_weno = 0
ipre2 = 0
iprecip_off_bnd = 1
irouse_test = 0
isav = 0
isconsv = 0
ishapiro = 0
itr_met = 3
itransport_only = 0
itur = 0
iunder_deep = 0
iupwind_mom = 0
iwbl = 0
iwind_form = 1
iwindoff = 0
izonal5 = 0
kr_co = 0.5
lev_tr_source = 1
level_age = [-999.0]
loadtide_coef = 1.0
max_subcyc = 10
meth_sink = 2
mid = 'KL'
moitn0 = 0.1
mxitn0 = 5
nadv = 3
name = 'Opt'
nchi = 50
ncor = 1
niter_shap = 0
nquad = 5
nramp_elev = 0.0
nstep_ice = 0
nstep_wwm = 1
ntd_weno = 1
nu_sum_mult = 1.0
nws = 0
prmsl_ref = 1013.25
rearth_eq = 6378.137
rearth_pole = 6356.75
rho0 = 1000.0
rinflation_icm = 2.0
rlatitude = 47.5
rmaxvel = 2.0
rtol0 = 1e-06
s1_mxnbt = 0.0
s2_mxnbt = 0.0
sfea0 = 45
shapiro0 = 0.8
shorewafo = 0.0
shw = 0.025
slam0 = -124
slr_rate = 0.0
small_elad = 1e-06
stab = 'GA'
start_day = 1
start_hour = 0
start_month = 1
start_year = 2000
step_nu_tr = 0.001
tdmin_pp1 = 0.01
tdmin_pp2 = 0.001
thetai = 0.7
turbinj = False
turbinjds = 0.0
utc_start = 8
vclose_surf_frac = 0.0
vdmax_pp1 = 0.02
vdmax_pp2 = 0.01
vdmin_pp1 = 1e-05
vdmin_pp2 = 1e-05
velmin_btrack = 0.0001
vnf1 = 1
vnf2 = 1
vnh1 = 1
vnh2 = 0
wafo_obcramp = 1
wtiminc = 3600.0
xlsc0 = 1.0
class schimpy.params.OutControls(*, name)

Bases: Parameterized

Parameters controlling output

Methods

from_iof_array

get_iof_array_names

to_iof_array

from_iof_array(iof_array)
get_iof_array_names()
name = 'OutControls'
to_iof_array()
class schimpy.params.Params(core, opt, schout)

Bases: tuple

Methods

count(value, /)

Return number of occurrences of value.

index(value[, start, stop])

Return first index of value.

core

Alias for field number 0

opt

Alias for field number 1

schout

Alias for field number 2

class schimpy.params.Schout(*, iof_age, iof_ana, iof_cos, iof_dvd, iof_eco, iof_fib, iof_ice, iof_icm_ba, iof_icm_cbp, iof_icm_core, iof_icm_dbg, iof_icm_ph, iof_icm_sav, iof_icm_sed, iof_icm_silica, iof_icm_veg, iof_icm_zb, iof_marsh, iof_sed, iof_sed2d, iof_ugrid, iout_sta, nc_out, nhot, nhot_write, nspool_sta, name)

Bases: Parameterized

iof_age = False
iof_ana = False
iof_cos = False
iof_dvd = False
iof_eco = False
iof_fib = False
iof_gen = TracerGenOutput(name='TracerGenOutput00004', ntracer_gen=0)
iof_hydro = HydroOutput(air_pressure=False, air_temperature=False, barotropic_pres_grad_xy=False, bottom_stress_xy=False, depth_avg_vel_xy=False, diffusivity=False, downward_longwave=False, dry_flag_node=True, elevation=False, evaporation_rate=False, horizontal_side_vel_xy=False, horizontal_vel_xy=False, latent_heat=False, mixing_length=False, name='HydroOutput00002', precipitation_rate=False, salinity=False, salinity_at_element=False, sensible_heat=False, solar_radiation=False, specific_humidity=False, temperature=False, temperature_at_element=False, total_heat=False, turbulent_kinetic_ener=False, upward_longwave=False, vertical_vel_at_element=False, vertical_velocity=False, viscosity=False, water_density=False, wind_speed_xy=False, wind_stress_xy=False, z_coordinates=False)
iof_ice = False
iof_icm_ba = False
iof_icm_cbp = False
iof_icm_core = False
iof_icm_dbg = False
iof_icm_ph = False
iof_icm_sav = False
iof_icm_sed = False
iof_icm_silica = False
iof_icm_veg = False
iof_icm_zb = False
iof_marsh = False
iof_sed = False
iof_sed2d = False
iof_ugrid = False
iof_wwm = WindWaveOutput(bottom_excursion_period=True, bottom_wave_period=True, charnock_coeff=True, continuous_peak_period=True, discrete_peak_direction=True, diss_rate_bott_friction=True, diss_rate_dep_breaking=True, diss_rate_vegetation=True, diss_rate_whitecapping=True, dominant_direction=True, energy_input_atmos=True, frictional_velocity=True, mean_dir_spreading=True, mean_wave_direction=True, mean_wave_length=True, mean_wave_number=True, mean_wave_period=True, name='WindWaveOutput00003', orbital_velocity=True, peak_group_vel=True, peak_n_factor=True, peak_period=True, peak_phase_vel=True, peak_spreading=True, peak_wave_length=True, peak_wave_number=True, rms_orbital_velocity=True, roller_diss_rate=True, roughness_length=True, sig_wave_height=True, tm_10=True, u_resell_number=True, wave_energy_dir_x=True, wave_energy_dir_y=True, zero_downcross_period=True)
iout_sta = 0
name = 'Schout'
nc_out = True
nhot = 0
nhot_write = 0
nspool_sta = 0
class schimpy.params.TracerGenOutput(*, ntracer_gen, name)

Bases: Parameterized

Methods

get_tracer_names

get_tracer_names()
name = 'TracerGenOutput'
ntracer_gen = 0
class schimpy.params.WindWaveOutput(*, bottom_excursion_period, bottom_wave_period, charnock_coeff, continuous_peak_period, discrete_peak_direction, diss_rate_bott_friction, diss_rate_dep_breaking, diss_rate_vegetation, diss_rate_whitecapping, dominant_direction, energy_input_atmos, frictional_velocity, mean_dir_spreading, mean_wave_direction, mean_wave_length, mean_wave_number, mean_wave_period, orbital_velocity, peak_group_vel, peak_n_factor, peak_period, peak_phase_vel, peak_spreading, peak_wave_length, peak_wave_number, rms_orbital_velocity, roller_diss_rate, roughness_length, sig_wave_height, tm_10, u_resell_number, wave_energy_dir_x, wave_energy_dir_y, zero_downcross_period, name)

Bases: OutControls

A collection of parameters that define the wind wave outputs.

Methods

from_iof_array

get_iof_array_names

to_iof_array

bottom_excursion_period = True
bottom_wave_period = True
charnock_coeff = True
continuous_peak_period = True
discrete_peak_direction = True
diss_rate_bott_friction = True
diss_rate_dep_breaking = True
diss_rate_vegetation = True
diss_rate_whitecapping = True
dominant_direction = True
energy_input_atmos = True
frictional_velocity = True
mean_dir_spreading = True
mean_wave_direction = True
mean_wave_length = True
mean_wave_number = True
mean_wave_period = True
name = 'WindWaveOutput'
orbital_velocity = True
peak_group_vel = True
peak_n_factor = True
peak_period = True
peak_phase_vel = True
peak_spreading = True
peak_wave_length = True
peak_wave_number = True
rms_orbital_velocity = True
roller_diss_rate = True
roughness_length = True
sig_wave_height = True
tm_10 = True
u_resell_number = True
wave_energy_dir_x = True
wave_energy_dir_y = True
zero_downcross_period = True
schimpy.params.build_iof_dict(iof_name, vdict, cls)

Builds dictionary of names from the class cls and the values that have the form iof_name(n) = 0 or 1 where n is an integer and the values are 0 or 1 which map onto False (0) or True (1)

schimpy.params.coerce_to_type(schema, value)
schimpy.params.create_params(namelists)
schimpy.params.get_type_dict(cls)
schimpy.params.get_value_dict(map, cls)

Create a dict from namelist from name: value elements and coerce to the type in the schema

schimpy.plot_default_formats module

Convenient routines to set up and to tweak matplotlib plots.

schimpy.plot_default_formats.set_color_cycle_dark2()

Set color cycles of Dark2 theme of colorbrewer.org globally. Just calling this function once before finalize a plot is enough to change the color cycles.

Returns:
brewer_colors: list

list of the colors

schimpy.plot_default_formats.set_dual_axes(ax, ts, cell_method='inst')

Create a dual y-axis with unit information in the given time series. It converts SI units to non-SI one.

Parameters:
ax: matplotlib.axes

axes of a plot to manage

ts: vtools.data.TimeSeries

timeseries with unit information

schimpy.plot_default_formats.set_dual_axes_elev(ax1, filtered=False)

Set dual axes for elevation.

Parameters:
ax: matplotlib axes
schimpy.plot_default_formats.set_dual_axes_salt(ax1, filtered=False)

Set a dual y-axis for salt with a PSU y-axis

Parameters:
ax: axis

a Matplotlib axes

schimpy.prepare_schism module

schimpy.priority_queue module

class schimpy.priority_queue.priorityDictionary

Bases: dict

Methods

clear()

copy()

fromkeys(iterable[, value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(key[, default])

If key is not found, default is returned if given, otherwise KeyError is raised

popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key, val)

Reimplement setdefault to call our customized __setitem__.

smallest()

Find smallest item after removing deleted items from heap.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

setdefault(key, val)

Reimplement setdefault to call our customized __setitem__.

smallest()

Find smallest item after removing deleted items from heap.

schimpy.profile_plot module

schimpy.profile_plot.get_index_bounds()
schimpy.profile_plot.nearest_neighbor_fill(arr)
schimpy.profile_plot.profile_plot(x, z, data, ax, context_label=None, add_labels=False, xlabel=None, xmin=None, xmax=None, max_depth=None)

UnTRIM-like profile plot of salinity xmin,xmax are the bounds (in km) of the profile max_depth is the maximum depth, data assumed to be

schimpy.profile_plot.set_index_bounds(min_station, max_station, max_depth)
schimpy.profile_plot.vertical_fill(arr)

schimpy.raster_to_nodes module

Functions to process raster data for schimpy pre-processing.

This add rasterstats, boto3 dependency to calculate raster stastistics such as means.

schimpy.raster_to_nodes.raster_to_nodes(mesh, nodes_sel, path_raster, bins=None, mapped_values=None, mask_value=None, fill_value=None, band=1)

Applies raster values to mesh by calculating means over surrounding elementss.

When an element contains no raster data, zero will be assigned. When an element is partly covered by the raster data, an masked average is calculated.

If the bins are provided, the raster data will be binned and bins mapped to the mapped_values before the averaging begins. The binning uses numpy.digitize to classification, and in particular the i’th mapped value is used between the values of bins (i-1) and (i). There are some extra padding values provided as shown in the example

If the mask_value is given, raster data with the given mask value will be replaced with the fill_value before binning the data. This masking will only be used when bins are provided and pertains to special cases involving vegetation data.

Parameters:
mesh: schimpy.SchismMesh

The base mesh to work on

nodes_sel: array-like

The array or list of the nodes to process

path_raster: string-like

File fath to the raster data

bins: array-like, optional

Array of bins. It has to be 1-dimensional and monotonic

mapped_values: array-like, optional

The values of the classes. It should be bigger by one than the bins. The i’th value will be applied between the (i-1) and i value of bins.

band: int, optional

The band index to use from the raster data. The default value is 1.

Returns:
numpy.array

means of raster values of the element balls around the nodes

Notes

An example of this function in the pre-processor yaml is below:

gr3:
  sav_N.gr3:
   default: 0.
   polygons:
     - attribute: raster_to_nodes.raster_to_nodes(mesh, nodes_sel, 'NDVI.tif', bins=[-998., 0.0001, 0.3, 0.6, 1.0], mapped_values=[-999., 0., 40., 70., 100., -999.], maske_value=-10., fill_value=0.1)
       imports: schimpy.raster_to_nodes
       type: none
       vertices:
       #...

The values mesh and node_sel mean the SCHISM mesh and the selected node indices by a polygon. The example bins (or classifies) the raster values from 0.0001 to 0.3 and assigns the value 0., then assigns 40. for values between 0.3 and 0.6 and so forth.

schimpy.read_output_xyt module

Read outputs from read_output*_xyt and create a neat list of Vtools time series. This module depends on deprecated vtools code and is scheduled for removal

schimpy.read_output_xyt.read_depth_avg_from_output7b_xyt(fpath, time_basis)

Read output file from read_output7b_xyt and return depth and depth-averaged values in vtools.data.timeseries.

Parameters:
fpath: str

master input file name of read_output7b_xyt

time_basis: datetime.datetime

time base of the outputs

Returns:
lists of a set vtools.data.timeseries of depth and depth-averaged values

For scalars, the list has only one set of time series. For vectors, the list has two sets of time series. Each time series has multiple columns of data, and each column is for stations.

schimpy.schism_hotstart module

schimpy.schism_input module

schimpy.schism_linestring module

Line String data based on Shapely LineStrings

class schimpy.schism_linestring.LineString(coordinates=None, prop=None)

Bases: LineString

Attributes:
area

Unitless area of the geometry (float)

boundary

Returns a lower dimension geometry that bounds the object

bounds

Returns minimum bounding region (minx, miny, maxx, maxy)

centroid

Returns the geometric center of the object

convex_hull

Imagine an elastic band stretched around the geometry: that’s a

coords

Access to geometry’s coordinates (CoordinateSequence)

envelope

A figure that envelopes the geometry

geom_type

Name of the geometry’s type, such as ‘Point’

has_z

True if the geometry’s coordinate sequence(s) have z values (are

is_closed

True if the geometry is closed, else False

is_empty

True if the set of points in this geometry is empty, else False

is_ring

True if the geometry is a closed ring, else False

is_simple

True if the geometry is simple, meaning that any self-intersections

is_valid

True if the geometry is valid (definition depends on sub-class),

length

Unitless length of the geometry (float)

minimum_clearance

Unitless distance by which a node could be moved to produce an invalid geometry (float)

minimum_rotated_rectangle

Returns the oriented envelope (minimum rotated rectangle) that encloses the geometry.

oriented_envelope

Returns the oriented envelope (minimum rotated rectangle) that encloses the geometry.

prop
type
wkb

WKB representation of the geometry

wkb_hex

WKB hex representation of the geometry

wkt

WKT representation of the geometry

xy

Separate arrays of X and Y coordinate values

Methods

almost_equals(other[, decimal])

True if geometries are equal at all coordinates to a specified decimal place.

buffer(distance[, quad_segs, cap_style, ...])

Get a geometry that represents all points within a distance of this geometry.

contains(other)

Returns True if the geometry contains the other, else False

contains_properly(other)

Returns True if the geometry completely contains the other, with no common boundary points, else False

covered_by(other)

Returns True if the geometry is covered by the other, else False

covers(other)

Returns True if the geometry covers the other, else False

crosses(other)

Returns True if the geometries cross, else False

difference(other[, grid_size])

Returns the difference of the geometries.

disjoint(other)

Returns True if geometries are disjoint, else False

distance(other)

Unitless distance to other geometry (float)

dwithin(other, distance)

Returns True if geometry is within a given distance from the other, else False.

equals(other)

Returns True if geometries are equal, else False.

equals_exact(other, tolerance)

True if geometries are equal to within a specified tolerance.

hausdorff_distance(other)

Unitless hausdorff distance to other geometry (float)

interpolate(distance[, normalized])

Return a point at the specified distance along a linear geometry

intersection(other[, grid_size])

Returns the intersection of the geometries.

intersects(other)

Returns True if geometries intersect, else False

line_interpolate_point(distance[, normalized])

Return a point at the specified distance along a linear geometry

line_locate_point(other[, normalized])

Returns the distance along this geometry to a point nearest the specified point

normalize()

Converts geometry to normal form (or canonical form).

offset_curve(distance[, quad_segs, ...])

Returns a LineString or MultiLineString geometry at a distance from the object on its right or its left side.

overlaps(other)

Returns True if geometries overlap, else False

parallel_offset(distance[, side, ...])

Alternative method to offset_curve() method.

point_on_surface()

Returns a point guaranteed to be within the object, cheaply.

project(other[, normalized])

Returns the distance along this geometry to a point nearest the specified point

relate(other)

Returns the DE-9IM intersection matrix for the two geometries (string)

relate_pattern(other, pattern)

Returns True if the DE-9IM string code for the relationship between the geometries satisfies the pattern, else False

representative_point()

Returns a point guaranteed to be within the object, cheaply.

reverse()

Returns a copy of this geometry with the order of coordinates reversed.

segmentize(max_segment_length)

Adds vertices to line segments based on maximum segment length.

simplify(tolerance[, preserve_topology])

Returns a simplified geometry produced by the Douglas-Peucker algorithm

svg([scale_factor, stroke_color, opacity])

Returns SVG polyline element for the LineString geometry.

symmetric_difference(other[, grid_size])

Returns the symmetric difference of the geometries.

touches(other)

Returns True if geometries touch, else False

union(other[, grid_size])

Returns the union of the geometries.

within(other)

Returns True if geometry is within the other, else False

geometryType

property prop
class schimpy.schism_linestring.LineStringIo

Bases: object

Methods

read

write

read(**kwargs)
write(**kwargs)
class schimpy.schism_linestring.LineStringIoFactory

Bases: object

Methods

get_reader

get_writer

get_reader(name)
get_writer(name)
registered_readers = {'shp': 'LineStringShapefileReader', 'yaml': 'LineStringYamlReader'}
registered_writers = {'shp': 'LineStringShapefileWriter', 'yaml': 'LineStringYamlWriter'}
class schimpy.schism_linestring.LineStringShapefileReader

Bases: LineStringIo

Methods

read(fpath, **kwargs)

write

read(fpath, **kwargs)
Parameters:
fpath: str

input file name

Returns:
lines

list of LineStrings

class schimpy.schism_linestring.LineStringShapefileWriter

Bases: LineStringIo

Methods

write(fpath, lines[, spatial_reference, ...])

read

write(fpath, lines, spatial_reference=None, driver_name=None, **kwargs)
Parameters:
fpath: str

output file name

lines: array of schism_linestring.LineString

list of LineStrings

spatial_reference: osgeo.osr.SpatialReference
default: NAD83, UTM zone 10N, meter
todo: reference needs to be in api right now hard to use
class schimpy.schism_linestring.LineStringYamlReader

Bases: LineStringIo

Methods

read

write

read(fpath, **kwargs)
class schimpy.schism_linestring.LineStringYamlWriter

Bases: LineStringIo

Write line strings from a YAML file

Methods

read

write

write(fpath, lines)
schimpy.schism_linestring.read_linestrings(fpath)
schimpy.schism_linestring.write_linestrings(fpath, lines)
Parameters:
fpath: str

output file name

lines: array of schism_linestring.LineString

list of LineStrings

schimpy.schism_mesh module

schimpy.schism_polygon module

Polygon data structure with preprocessor-related attributes and converters

class schimpy.schism_polygon.SchismPolygon(shell=None, holes=None, prop=None)

Bases: Polygon

A polygon class based on shapely.geometry.Polygon. This class has extra information

Attributes:
area

Unitless area of the geometry (float)

attribute
boundary

Returns a lower dimension geometry that bounds the object

bounds

Returns minimum bounding region (minx, miny, maxx, maxy)

centroid

Returns the geometric center of the object

convex_hull

Imagine an elastic band stretched around the geometry: that’s a

coords

Access to geometry’s coordinates (CoordinateSequence)

envelope

A figure that envelopes the geometry

exterior
geom_type

Name of the geometry’s type, such as ‘Point’

has_z

True if the geometry’s coordinate sequence(s) have z values (are

interiors
is_closed

True if the geometry is closed, else False

is_empty

True if the set of points in this geometry is empty, else False

is_ring

True if the geometry is a closed ring, else False

is_simple

True if the geometry is simple, meaning that any self-intersections

is_valid

True if the geometry is valid (definition depends on sub-class),

length

Unitless length of the geometry (float)

minimum_clearance

Unitless distance by which a node could be moved to produce an invalid geometry (float)

minimum_rotated_rectangle

Returns the oriented envelope (minimum rotated rectangle) that encloses the geometry.

name
oriented_envelope

Returns the oriented envelope (minimum rotated rectangle) that encloses the geometry.

prop
type
wkb

WKB representation of the geometry

wkb_hex

WKB hex representation of the geometry

wkt

WKT representation of the geometry

xy

Separate arrays of X and Y coordinate values

Methods

almost_equals(other[, decimal])

True if geometries are equal at all coordinates to a specified decimal place.

buffer(distance[, quad_segs, cap_style, ...])

Get a geometry that represents all points within a distance of this geometry.

contains(point)

Check the polygon contains the point

contains_properly(other)

Returns True if the geometry completely contains the other, with no common boundary points, else False

covered_by(other)

Returns True if the geometry is covered by the other, else False

covers(other)

Returns True if the geometry covers the other, else False

crosses(other)

Returns True if the geometries cross, else False

difference(other[, grid_size])

Returns the difference of the geometries.

disjoint(other)

Returns True if geometries are disjoint, else False

distance(other)

Unitless distance to other geometry (float)

dwithin(other, distance)

Returns True if geometry is within a given distance from the other, else False.

equals(other)

Returns True if geometries are equal, else False.

equals_exact(other, tolerance)

True if geometries are equal to within a specified tolerance.

from_bounds(xmin, ymin, xmax, ymax)

Construct a Polygon() from spatial bounds.

hausdorff_distance(other)

Unitless hausdorff distance to other geometry (float)

interpolate(distance[, normalized])

Return a point at the specified distance along a linear geometry

intersection(other[, grid_size])

Returns the intersection of the geometries.

intersects(val)

Check the polygon intersects with the point

line_interpolate_point(distance[, normalized])

Return a point at the specified distance along a linear geometry

line_locate_point(other[, normalized])

Returns the distance along this geometry to a point nearest the specified point

normalize()

Converts geometry to normal form (or canonical form).

overlaps(other)

Returns True if geometries overlap, else False

point_on_surface()

Returns a point guaranteed to be within the object, cheaply.

project(other[, normalized])

Returns the distance along this geometry to a point nearest the specified point

relate(other)

Returns the DE-9IM intersection matrix for the two geometries (string)

relate_pattern(other, pattern)

Returns True if the DE-9IM string code for the relationship between the geometries satisfies the pattern, else False

representative_point()

Returns a point guaranteed to be within the object, cheaply.

reverse()

Returns a copy of this geometry with the order of coordinates reversed.

segmentize(max_segment_length)

Adds vertices to line segments based on maximum segment length.

simplify(tolerance[, preserve_topology])

Returns a simplified geometry produced by the Douglas-Peucker algorithm

svg([scale_factor, fill_color, opacity])

Returns SVG path element for the Polygon geometry.

symmetric_difference(other[, grid_size])

Returns the symmetric difference of the geometries.

touches(other)

Returns True if geometries touch, else False

union(other[, grid_size])

Returns the union of the geometries.

within(other)

Returns True if geometry is within the other, else False

geometryType

property attribute
contains(point)

Check the polygon contains the point

Parameters:
point: np.ndarray or shapely.geometry.polygon.Polygon
Returns:
bool
intersects(val)

Check the polygon intersects with the point

Parameters:
point: np.ndarray or shapely.geometry.polygon.Polygon
Returns:
bool
property name
property prop
property type
class schimpy.schism_polygon.SchismPolygonDictConverter

Bases: SchismPolygonIo

Convert a tree to a list of polygons

Methods

read

read(data)
class schimpy.schism_polygon.SchismPolygonIo

Bases: object

SchismPolygon I/O abstract class

Methods

read

read(stream)
class schimpy.schism_polygon.SchismPolygonIoFactory

Bases: object

A factory class for SchismPolygonIo

Methods

get_reader

get_writer

show_registered_readers

get_reader(name)
get_writer(name)
registered_readers = {'dict': 'SchismPolygonDictConverter', 'shp': 'SchismPolygonShapefileReader', 'yaml': 'SchismPolygonYamlReader'}
registered_writers = {'shp': 'SchismPolygonShapefileWriter', 'yaml': 'SchismPolygonYamlWriter'}
show_registered_readers()
class schimpy.schism_polygon.SchismPolygonShapefileReader

Bases: SchismPolygonIo

Read polygons from a shape file

Methods

read(fpath)

Read polygons from a Shapefile and return a list of SchismPolygons.

read(fpath)

Read polygons from a Shapefile and return a list of SchismPolygons.

Parameters:
fpath: str

Filename of a Shapefile containing Polygons with data columns such as name, type, and attribute.

Returns:
list

list of SchismPolygons

class schimpy.schism_polygon.SchismPolygonShapefileWriter

Bases: SchismPolygonIo

Methods

write(fpath, polygons[, spatial_reference, ...])

Convert SCHISM polygon YAML file to a shapefile

read

write(fpath, polygons, spatial_reference=None, driver_name=None)

Convert SCHISM polygon YAML file to a shapefile

Parameters:
fpath: str

output file name

polygons: array of schism_polygon.SchismPolygon

polygons to write

spatial_reference: osgeo.osr.SpatialReference or crs string

default: NAD83, UTM zone 10N, meter

driver_name: osgeo.ogr Driver name

default: ESRI Shapefile

class schimpy.schism_polygon.SchismPolygonYamlReader

Bases: SchismPolygonIo

Read polygons from a SCHISM YAML polygon file

Methods

read

read(fpath)
class schimpy.schism_polygon.SchismPolygonYamlWriter

Bases: SchismPolygonIo

Write polygons into a YAML file

Methods

read

write

write(fpath, polygons)
schimpy.schism_polygon.read_polygons(fpath)

Read a polygon file

schimpy.schism_polygon.write_polygons(fpath, polygons)

schimpy.schism_setup module

schimpy.schism_source module

class schimpy.schism_source.SchismSource

Bases: object

A class to hold structure information

Attributes:
coord
element_id
note
type
property coord
property element_id
property note
property type
class schimpy.schism_source.SchismSourceIO(input)

Bases: object

A class to manage source/sink I/O

Methods

read

write

read(fname)
write(fname='source_sink.in')
schimpy.schism_source.read_sources(fname)

schimpy.schism_sources_sinks module

schimpy.schism_structure module

class schimpy.schism_structure.SchismStructure

Bases: object

A class to hold structure information

Attributes:
coords
n_duplicate
name
node_pairs
properties
reference
reference_pair
type
use_timeseries

Methods

n_node_pairs

property coords
property n_duplicate
n_node_pairs()
property name
property node_pairs
property properties
property reference
property reference_pair
property type
property use_timeseries
class schimpy.schism_structure.SchismStructureIO(input)

Bases: BaseIO

A class to manage hydraulic structure I/O files

Attributes:
linecounter

Methods

read(fname)

Read in 'hydraulics.in' file.

write([fname])

Write out 'hydraulics.in' file.

read(fname)

Read in ‘hydraulics.in’ file.

write(fname='hydraulics.in')

Write out ‘hydraulics.in’ file.

schimpy.schism_vertical_mesh module

SchismVerticalMesh class with a reader

schimpy.schism_vertical_mesh.read_vmesh(fpath_vmesh, vgrid_version=None)

Read a vgrid file

schimpy.schism_yaml module

A customized version of YAML parser for SCHISM It stores document in an ordered dict and supports variable substitution.

class schimpy.schism_yaml.ArgumentParserYaml(prog=None, usage=None, description=None, epilog=None, version=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True)

Bases: ArgumentParser

Extended parser to handle YAML file as file input for ArgumentParser. If a file input given with ‘fromfile_prefix_chars’ has a YAML extension, ‘.yaml’, it will be handled as optional pairs for ArgumentParser. For example, ‘script.py’ can use a YAML file for an input file of ArgumentParser as follow: parser = schism_yaml.ArgumentParserYaml(fromfile_prefix_chars=’@’) parser.parse_arg()

$script.py @args.yaml

And when ‘args.yaml’ contains: input1: 1 input2: 2 3

it has the same effect as $script.py –input1 1 –input2 2 3

Methods

add_argument(add_argument)

add_subparsers(**kwargs)

error(message)

Prints a usage message incorporating the message to stderr and exits.

exit([status, message])

format_usage()

parse_args([args, namespace])

print_usage([file])

register(registry_name, value, object)

set_defaults(**kwargs)

add_argument_group

add_mutually_exclusive_group

convert_arg_line_to_args

format_help

get_default

parse_intermixed_args

parse_known_args

parse_known_intermixed_args

print_help

class schimpy.schism_yaml.YamlAction(option_strings, dest, nargs=None, **kwargs)

Bases: Action

Custom action to parse YAML files for argparse. This action reads in simple pairs of data from a YAML file, and feeds them to the parser. A YAML file must be a list of pairs without multiple levels of tree. Example: parser.add_argument(”–yaml”, action=YamlAction)

Methods

__call__(parser, namespace, values[, ...])

Call self as a function.

format_usage

schimpy.schism_yaml.dump(data, stream=None, Dumper=<class 'yaml.dumper.Dumper'>, **kwds)

Serialize a Python object into a YAML stream. If stream is None, return the produced string instead.

schimpy.schism_yaml.load(stream)

Load a schism YAML

schimpy.separate_species module

Separation of tidal data into species The key function in this module is separate_species, which decomposes tides into subtidal, diurnal, semidiurnal and noise components. A demo function is also provided that reads tide series (6min intervl) from input files, seperates the species, writes results and optionally plots an example

schimpy.separate_species.create_arg_parser()
schimpy.separate_species.main()
schimpy.separate_species.plot_result(ts, ts_semi, ts_diurnal, ts_sub_tide, station)
schimpy.separate_species.run_example()

This is the data for the example. Note that you want the data to be at least 4 days longer than the desired output

schimpy.separate_species.separate_species(ts, noise_thresh_min=40)

Separate species into subtidal, diurnal, semidiurnal and noise components

Input:

ts: timeseries to be decomposed into species, assumed to be at six minute intervals. The filters used have long lenghts, so avoid missing data and allow for four extra days worth of data on each end.

Output:

four regular time series, representing subtidal, diurnal, semi-diurnal and noise

schimpy.separate_species.write_th(filename, ts_output)

This works fine for fairly big series

schimpy.simulation_timing module

schimpy.simulation_timing.create_arg_parser()
schimpy.simulation_timing.schism_timing(workdir, start=1, end=None, block_days=1.0)

schimpy.small_areas module

schimpy.sms2gr3 module

Manage conversion from SMS 2dm format to gr3. Some material borrowed @author: snegusse

class schimpy.sms2gr3.Boundary(name, btype, nodestring)

Bases: object

schimpy.sms2gr3.addnode(list)
schimpy.sms2gr3.convert_2dm(file, outfile=None, elev2depth=False, logger=None)
schimpy.sms2gr3.create_arg_parser()

schimpy.split_quad module

schimpy.stacked_dem_fill module

Routines to fill elevation (or other scalar) values at points from a prioritized list of rasters

schimpy.stacked_dem_fill.ParseType(type)
schimpy.stacked_dem_fill.Usage()
schimpy.stacked_dem_fill.bilinear(points, gt, raster)

Bilinear interpolated point using data on raster points: npoint x 3 array of (x,y,z points) gt: geotransform information from gdal raster: the data

schimpy.stacked_dem_fill.create_arg_parser()
schimpy.stacked_dem_fill.filelist_main(demlistfile, pointlistfile, sep='')

higher level driver routine that parses the names of the DEMs from demfilelist points ( x,y or x,y,z ) from pointlistfile

schimpy.stacked_dem_fill.fill_2dm(infile, outfile, files, na_fill=2.0)
schimpy.stacked_dem_fill.fill_gr3(infile, outfile, files, elev2depth=True, na_fill=2.0)
schimpy.stacked_dem_fill.main()
schimpy.stacked_dem_fill.stacked_dem_fill(files, points, values=None, negate=False, require_all=True, na_fill=None)

Fill values at an array of points using bilinear interpolation from a prioritized stack of dems. This routine controls prioritization of the dems, gradually filling points that are still marked nan

Parameters:
files: list[str]

list of files. Existence is checked and ValueError for bad file

points: np.ndarray

this is a numpy array of points, nrow = num of points and ncol = 2 (x,y).

values: np.ndarray

values at each point – this is an output, but this gives an opportunity to use an existing data structure to receive

negate: bool

if True, values will be inverted (from elevation to depth)

require_all: bool

if True, a ValueError is raised if the list of DEMs does not cover all the points. In either case (True/False) a file is created or overwritten (dem_misses.txt) that will show all the misses.

na_fill: float

value to substitute at the end for values that are NA after all DEMs are processed. If require_all = True na_fill must be None

Returns:
valuesnp.ndarray

Values at the nodes

schimpy.stacked_dem_fill.test_main()

schimpy.station module

schimpy.subset_schism_output module

Created on Wed Oct 27 11:41:00 2021

@author: babban

schimpy.subset_schism_output.create_arg_parser()

Create an argument parser return: argparse.ArgumentParser

schimpy.subset_schism_output.create_partition(mesh, polygons, enforce_exact=False)

Takes a mesh and list of polygons and partitions according to where the centroids (mesh.centroids in schimpy) fall. Parameters ———— mesh : schimpy.SchismMesh The mesh to partition

polygons : Polygons (parsed from shape file or yaml into SCHIMPY

enforce_exact: bool Requires a unique, complete partition. Initially not implemented for True

Produces meshes and dicitonary(?) maps of local_to_global and global_to_local. (tuple or class)

schimpy.subset_schism_output.partition_schout(in_Schout_Files, partition_shp, combined=True, exclude=[], transform={'salt_depth_ave': ('depth_ave', 'salt')})

Partitions schout binary output files (start with combined) into a set of smaller schout files corresponding to each partition.

Initially implementation will be nodal variables but ultimately native centered (edge centered velocity, prism centered tracers).

Transform is an opportunity to generate new variables that are well determined with the data from one time step, but not based on time-stenciled operations.

Exclude would be an opportunity to prune variables not desired by dropping variables, although certain variables that are required for well-formedness (zcor, wet-dry) and visualization would not be “excludable” so exclude = “all_data” could be used to exclude all but the non-excludable. No output, but side effect is production of files. p0000/schout_1.nc.

schimpy.subset_schism_output.partition_scribeio(partition_shp, variables=['out2d', 'zCoordinates', 'salinity', 'horizontalVelX', 'horizontalVelY', 'verticalVelocity'])

Partitioning scribio format output files into a set of smaller files corresponding to each partitions. This function will loop all the schism scribeIO output files that contains varaibles defined by the input variables, and result subset outputs will be saved to a subset subdirectory.

Parameters:
partition_shparcgis shape file
shape files contains polygons where subset of output desried
variableslist of str
Output variables to be subsetted
schimpy.subset_schism_output.records(file)
schimpy.subset_schism_output.subset_schism_output()
schimpy.subset_schism_output.subset_schism_scribeIO_output(partition_shp)
schimpy.subset_schism_output.write_global_local_maps(dest, global_local, local_global)

writes maps out in the schism + visit format. Note that the global owner of a shared node is the lowest rank that contains it.

schimpy.three_point_linear_norm module

class schimpy.three_point_linear_norm.ThreePointLinearNorm(linthresh, vmin=None, vmax=None, clip=False)

Bases: Normalize

Attributes:
clip
vmax
vmin

Methods

__call__(value[, clip])

Normalize the data and return the normalized data.

autoscale(A)

Set vmin, vmax to min, max of A.

autoscale_None(A)

autoscale only None-valued vmin or vmax

inverse(value)

Maps the normalized value (i.e., index in the colormap) back to image data value.

process_value(value)

Homogenize the input value for easy and efficient normalization.

scaled()

return true if vmin and vmax set

autoscale(A)

Set vmin, vmax to min, max of A.

autoscale_None(A)

autoscale only None-valued vmin or vmax

inverse(value)

Maps the normalized value (i.e., index in the colormap) back to image data value.

Parameters:
value

Normalized value.

scaled()

return true if vmin and vmax set

schimpy.trimesh module

schimpy.triquadmesh module

schimpy.unit_conversions module

schimpy.vgrid_opt2 module

Package for optimising vgrid smoothness, shape and completeness

schimpy.vgrid_opt2.example()
schimpy.vgrid_opt2.fix_depth(zcor, zcornew, x)
schimpy.vgrid_opt2.gradient_matrix(mesh, sidedist2, sidemasked)
schimpy.vgrid_opt2.hess_base(xvar, zcorig, mesh, nlayer, ndx, eta, depth, gradmat, sidelen2, nodemasked, sidemasked, ata, dx2fac, curvewgt, foldwgt, foldfrac)
schimpy.vgrid_opt2.incr_grad(grad, i, k, val, ndx)
schimpy.vgrid_opt2.index_interior(mat, nodemasked, nlevel=None)
schimpy.vgrid_opt2.laplace2(mesh, nodemasked, sidemasked)

produces a 2d matrix

schimpy.vgrid_opt2.mesh_opt(zcor, mesh, nlayer, ndx, eta, depth, gradmat, sidelen2, nodemasked, sidemasked, ata, dx2fac, curvewgt, foldwgt, foldfrac, href_hess, grad_hess, laplace_hess, maxiter=8000)
schimpy.vgrid_opt2.meshessp(xvar, p, zcorig, mesh, nlayer, ndx, eta, depth, gradmat, sidelen2, nodemasked, sidemasked, ata, dx2fac, curvewgt, foldwgt, foldfrac, href_hess, grad_hess, laplace_hess)
schimpy.vgrid_opt2.meshgrad(xvar, zcorig, mesh, nlayer, ndx, eta, depth, gradmat, sidelen2, nodemasked, sidemasked, ata, dx2fac, curvewgt, foldwgt, foldfrac, href_hess, grad_hess, laplace_hess)
schimpy.vgrid_opt2.meshobj(xvar, zcorig, mesh, nlayer, ndx, eta, depth, gradmat, sidelen2, nodemasked, sidemasked, ata, dx2fac, curvewgt, foldwgt, foldfrac, href_hess, grad_hess, laplace_hess)
schimpy.vgrid_opt2.smooth_heights(zcor, x, wgt=0.2)
schimpy.vgrid_opt2.targeth2inv(zbar, eta)
schimpy.vgrid_opt2.test_gradients()
schimpy.vgrid_opt2.test_vgrid_spacing(zcor, zcorig, nodemasked, foldfrac)
schimpy.vgrid_opt2.triweight(n)

schimpy.write_ts module

schimpy.write_ts.cdec_header(fname, ts, tz, var=None, unit=None)

Helper function to create a cdec-like header Requres some metadata like time zone, variable name and unit which will be pulled from series if omitted from input.

Parameters:
fname: str

Output file name or path

ts: :class:`~vtools.data.timeseries.TimeSeries`

The time series to be stored

tz: string

Time zone of data

var: string

Variable name

unit: string

Unit of the time series

Returns:
head: string

CDEC-style header

schimpy.write_ts.write_ts(ts, fname, dateformat='%Y-%m-%d %H:%M', fmt='%.2f', header=None, sep=',')

Estimate missing values within a time series by interpolation.

Parameters:
ts: :class:`~vtools.data.timeseries.TimeSeries`

The time series to be stored

fname: string

Output file name or path

dateformat: string

Date format compatible with datetime.datetime.strftime

fmt: string

Value format compatible withy numpy.savetxt

header: string

Header to add to top of file

sep: string

Delimieter for fields, often a space or comma

Returns:

Examples

Writing csv format with date format 2009-03-15 21:00 and space separated values

>>> write_ts(ts,"test.csv","%Y-%m-%d %H:%M","%.2f,%.2f","Datetime,u,v",",")

Write vtide format with same format and space separated values, this time taking advantage of defaults

>>> write_ts(ts,"test_vtide.dat",sep = " ")

Writing cdec format, with csv values and date and time separated. The header is generated with the cdec_header helper function

>>> head = cdec_header("practice.csv",ts,"PST","Wind Vel","m/s")
>>> write_ts(ts,"test_cdec.csv",CDECDATEFMT,"%.2f",header=head)

Module contents

Top-level package for schimpy.