Skip to main content

abja_utils

A collection of reusable Python utilities for MIKE, FUNWAVE-TVD, and GIS workflows — the tools I reach for across projects, packaged so they install the same way on every machine.

Installation

pip install abja_utils

Optional extras:

pip install "abja_utils[basemap]"   # web-tile basemaps for wind-vector plots
pip install "abja_utils[dev]"       # test dependencies

ArcPy-based helpers (abja_utils.gis.arcpro) require a licensed ArcGIS install; see ArcPy setup below.

What's inside

Subpackage Highlights
abja_utils.mike dfs2/mesh → shapefile, wind-vector plots, MIKE setup packaging
abja_utils.gis concave hulls, bounding-box & snap rasters, NONNA-10 parsing, ArcPy bridge
abja_utils.funwave FUNWAVE-TVD grid generation, depth-file ↔ GeoTIFF
abja_utils.downloader (work in progress) Copernicus / HYCOM downloaders
top level use_style, Colors, subplots — matplotlib styling helpers

Subpackages import lazily, so import abja_utils stays fast; access them as abja_utils.mike, abja_utils.gis, etc.

Quick start

MIKE — dfs2 to shapefile

Export one item at one timestep to a polygon shapefile (with x_index / y_index columns). The item can be given by name or index, and the timestep by index or timestamp string:

import abja_utils as au

au.mike.dfs2_to_shapefile(
    "model.dfs2", "surface.shp",
    item="Surface elevation",     # or an integer index
    timestep="2018-01-01 01:00",  # or an integer index
)

# Or work with the GeoDataFrame directly:
gdf = au.mike.dfs2_to_geodataframe("model.dfs2", item=0, timestep=0)

Convert a mesh to element polygons, or plot true-north wind vectors:

au.mike.mesh2poly("domain.mesh", "domain.shp")
au.mike.plot_wind_vectors("wind.dfs2", u_item=0, v_item=1, timestep=0)

Package a MIKE setup and every linked input into a self-contained zip:

report = au.mike.package_mike_setup("model.m21fm")
print(report.summary())

FUNWAVE — build a grid from a raster

import abja_utils as au

result = au.funwave.generate_grid(
    xmin=-127.0, xmax=-126.0, ymin=48.1, ymax=48.5,
    dphi=30/3600, dtheta=30/3600,
    raster_path="dem.tif", out_txt_path="depth.txt",
    export_shapefile=True, export_clipped_raster=True,
)
au.funwave.txt2tif("depth.txt", "depth.tif", result["Mglob"], result["Nglob"],
                   result["dphi"], result["dtheta"])

GIS

import abja_utils as au

au.gis.bbox2shp(-127, -126, 48, 49, "bbox.shp", epsg=4326)
au.gis.make_snap_raster(-127, -126, 48, 49, epsg=4326, res=0.01,
                        output_fname="snap.tif")
hull = au.gis.concave_hull(points, alpha=2.0, plot=True)

from abja_utils.gis.nonna import parse_file
gdf = parse_file("nonna10.txt")

Plotting style

Importing the package applies its matplotlib style globally — Times New Roman, inward ticks, and a curated colour cycle — so every figure shares one look, including the plots produced by mike.plot_wind_vectors, mike.contourf, and gis.concave_hull. Use subplots for figures sized in centimetres:

import abja_utils as au
fig, ax = au.subplots(figwidth=16, figheight=12)  # sizes in centimetres
ax.plot(x, y, color=au.Colors.blue2)

au.use_style(font_family="Arial")   # re-apply / customise the style if needed

ArcPy (optional)

abja_utils.gis.arcpro bridges to a licensed ArcGIS Pro install from a standalone Python (matching major.minor version). Install the bridge with:

from abja_utils.gis import install_arcpy
install_arcpy()   # Windows only

See src/abja_utils/data/README.md for details.

Development

pip install -e ".[dev]"
pytest

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

abja_utils-1.0.5.tar.gz (51.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

abja_utils-1.0.5-py3-none-any.whl (52.3 kB view details)

Uploaded Python 3

File details

Details for the file abja_utils-1.0.5.tar.gz.

File metadata

  • Download URL: abja_utils-1.0.5.tar.gz
  • Upload date:
  • Size: 51.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for abja_utils-1.0.5.tar.gz
Algorithm Hash digest
SHA256 7a125a5a6444256b20c6b91be6b348c2411a8ca8a21e9b1ffc4be6de7b2d6e2b
MD5 f7970cea337514fb8cdc686af4b98e87
BLAKE2b-256 7cc063f4d3f88d0137e2f2c86e202eac9c865776d92a5f23421e2aa3f5fb3a26

See more details on using hashes here.

File details

Details for the file abja_utils-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: abja_utils-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 52.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for abja_utils-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 eef8411d64fb083f9ed191c22abb84531f0eb64c3d9474765f0361fafef48158
MD5 6b6b04b7ac7e63e070b991064d89299c
BLAKE2b-256 7479fdad07b50f15f33b85ce61d5d5bdbe01493bb255e19314a4af5156121b21

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.6

2 files

This release

1.0.5 This release

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.2.1

2 files

0.1.26

2 files

0.1.25

2 files

0.1.24

2 files

0.1.23

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page