spatial.GeometryFMLineSpectrum(
self ,
node_coordinates,
element_table,
codes= None ,
projection= 'LONG/LAT' ,
dfsu_type= None ,
element_ids= None ,
node_ids= None ,
validate= True ,
frequencies= None ,
directions= None ,
reindex= False ,
)
Methods
contains
spatial.GeometryFMLineSpectrum.contains(points)
Test if a list of points are contained by mesh.
Parameters
points
array-like n-by-2
x,y-coordinates of n points to be tested
required
Returns
bool array
True for points inside, False otherwise
find_index
spatial.GeometryFMLineSpectrum.find_index(
x= None ,
y= None ,
coords= None ,
area= None ,
)
Find a set of element indicies for a number of points or within an area.
The returned indices returned are the unique, unordered set of element indices that contain the points or area.
This method will return elements containing the argument points/area, which is not necessarily the same as the nearest.
Typically not called directly, but by Dataset/DataArray’s sel() method.
Parameters
x
float | np.ndarray | None
X coordinate(s) (easting or longitude)
None
y
float | np.ndarray | None
Y coordinate(s) (northing or latitude)
None
coords
np.array(float, float)
As an alternative to specifying x, and y individually, the argument coords can be used instead. (x,y)-coordinates of points to be found, by default None
None
area
(float, float, float, float)
Bounding box of coordinates (left lower and right upper) to be selected, by default None
None
Returns
np.array
indicies of containing elements
Raises
ValueError
if any point is outside the domain
Examples
>>> g = dfs.geometry
>>> id = dfs.find_index(x= 3.1 , y= 4.3 )
See Also
isel : get subset geometry for specific indicies find_nearest_elements : find nearest instead of containing elements
find_nearest_elements
spatial.GeometryFMLineSpectrum.find_nearest_elements(
x,
y= None ,
n_nearest= 1 ,
return_distances= False ,
)
Find index of nearest elements (optionally for a list).
Parameters
x
float | np.ndarray
X coordinate(s) (easting or longitude)
required
y
float | np.ndarray | None
Y coordinate(s) (northing or latitude)
None
n_nearest
int
return this many (horizontally) nearest points for each coordinate set, default=1
1
return_distances
bool
should the horizontal distances to each point be returned? default=False
False
Returns
np.array
element ids of nearest element(s)
(np.array, optional)
horizontal distances
Examples
>>> g = dfs.geometry
>>> id = g.find_nearest_elements(3 , 4 )
>>> ids = g.find_nearest_elements([3 , 8 ], [4 , 6 ])
>>> ids = g.find_nearest_elements(xy)
>>> ids = g.find_nearest_elements(3 , 4 , n_nearest= 4 )
>>> ids, d = g.find_nearest_elements(xy, return_distances= True )
See Also
find_index : find element indicies for points or an area
get_2d_interpolant
spatial.GeometryFMLineSpectrum.get_2d_interpolant(
xy,
n_nearest= 5 ,
extrapolate= False ,
p= 2 ,
radius= None ,
)
IDW interpolant for list of coordinates.
Parameters
xy
array - like
x,y coordinates of new points
required
n_nearest
int
number of nearest elements used for IDW, by default 5
5
extrapolate
bool
allow extrapolation, by default False
False
p
float
power of inverse distance weighting, default=2
2
radius
float | None
an alternative to extrapolate=False, only include elements within radius
None
Returns
(np.array, np.array)
element ids and weights
get_element_area
spatial.GeometryFMLineSpectrum.get_element_area()
Calculate the horizontal area of each element.
Returns
np.array(float)
areas in m2
get_node_centered_data
spatial.GeometryFMLineSpectrum.get_node_centered_data(data, extrapolate= True )
Convert cell-centered data to node-centered by pseudo-laplacian method.
Parameters
data
np.array(float)
cell-centered data
required
extrapolate
bool
allow the method to extrapolate, default:True
True
Returns
np.array(float)
node-centered data
get_overset_grid
spatial.GeometryFMLineSpectrum.get_overset_grid(
dx= None ,
dy= None ,
nx= None ,
ny= None ,
buffer = 0.0 ,
)
Get a 2d grid that covers the domain by specifying spacing or shape.
Parameters
dx
float or (float, float)
grid resolution in x-direction (or in x- and y-direction)
None
dy
float
grid resolution in y-direction
None
nx
int
number of points in x-direction, by default None, (the value will be inferred)
None
ny
int
number of points in y-direction, by default None, (the value will be inferred)
None
buffer
float
positive to make the area larger, default=0 can be set to a small negative value to avoid NaN values all around the domain.
0.0
interp2d
spatial.GeometryFMLineSpectrum.interp2d(
data,
elem_ids,
weights= None ,
shape= None ,
)
Interpolate spatially in data (2d only).
Parameters
data
ndarray or list(ndarray)
dfsu data
required
elem_ids
ndarray(int)
n sized array of 1 or more element ids used for interpolation
required
weights
ndarray(float)
weights with same size as elem_ids used for interpolation
None
shape
tuple[int, …] | None
reshape output
None
Returns
ndarray or list(ndarray)
spatially interped data
Examples
>>> ds = dfsu.read()
>>> g = dfs.get_overset_grid(shape= (50 ,40 ))
>>> elem_ids, weights = dfs.get_2d_interpolant(g.xy)
>>> dsi = dfs.interp2d(ds, elem_ids, weights)
to_mesh
spatial.GeometryFMLineSpectrum.to_mesh(outfilename)
Export geometry to new mesh file.
Parameters
outfilename
str
path to file to be written
required
to_shapely
spatial.GeometryFMLineSpectrum.to_shapely()
Export mesh as shapely MultiPolygon.
Returns
shapely.geometry.MultiPolygon
polygons with mesh elements