windkit.io.wasp.read_map#

windkit.io.wasp.read_map(filepath, encoding='infer')[source]#

Read a WAsP .map file and return parsed data.

Any line ending is accepted: CRLF as WAsP writes it, and the LF or CR a file picks up from version control or a text editor.

Parameters:
  • filepath (str or Path) – Path to the .map file.

  • encoding (str, optional) – File encoding. If "infer" (default), the encoding is detected automatically.

Returns:

Dictionary with keys:

  • "points" : list of ndarray, shape (n_pts, 2), one per line

  • "elev" : ndarray, shape (n_lines,), nan where the line carries no elevation

  • "z0_left" : ndarray, shape (n_lines,), nan where the line carries no roughness change

  • "z0_right" : ndarray, same as z0_left

  • "header" : dict with "description" (the first line, verbatim), "epsg" (int or None), "fixed_points" (ndarray, shape (2, 4)), "z_scale" and "z_offset"

Return type:

dict

Raises:

WindkitFileFormatError – If the file is empty or its four header lines are malformed; if a line header does not hold 1 to 4 fields; if a line header declares a displacement height; if a point count is not a non-negative integer; if a coordinate line holds an odd number of values; if a line supplies more points than it declares; or if the file ends inside a line.

Notes

Only over-supply is detected. A line’s coordinates may wrap across any number of physical lines, so a header declaring more points than its coordinates carry cannot be told from one whose coordinates wrap. Such a file yields corrupted geometry, and raises only if the field counts of what follows happen not to line up.

Examples

>>> data = read_map("site.map")
>>> is_elevation = ~np.isnan(data["elev"])