Skip to main content

Available on pypi CI

xarray backend for Selafin formats

Supports lazy loading by default.

Install

To have the backend working in xarray, you need to follow these steps:

pip install xarray-selafin

or, if you are using conda/mamba:

conda install -c conda-forge xarray_selafin

Read Selafin

import xarray as xr

with xr.open_dataset("tests/data/r3d_tidal_flats.slf", engine="selafin") as ds:
    print(ds)  # do something with `ds`...
    # `ds.close()` not necessary

ds = xr.open_dataset("tests/data/r3d_tidal_flats.slf", lang="fr", engine="selafin")  # if variables are in French
print(ds)  # do something with `ds`...
ds.close()  # avoid a ResourceWarning (unclosed file)
<xarray.Dataset> Size: 5MB
Dimensions:  (time: 17, plan: 21, node: 648)
Coordinates:
    x        (node) float32 3kB ...
    y        (node) float32 3kB ...
  * time     (time) datetime64[ns] 136B 1900-01-01 ... 1900-01-02T20:26:40
Dimensions without coordinates: plan, node
Data variables:
    Z        (time, plan, node) float32 925kB ...
    U        (time, plan, node) float32 925kB ...
    V        (time, plan, node) float32 925kB ...
    W        (time, plan, node) float32 925kB ...
    MUD      (time, plan, node) float32 925kB ...
Attributes:
    title:       Sloped flume Rouse profile test
    language:    en
    float_size:  4
    endian:      >
    params:      (1, 0, 0, 0, 0, 0, 21, 5544, 0, 1)
    ipobo:       [   1  264  263 ... 5411 5412 5413]
    ikle2:       [[155 153 156]\n [310 307 305]\n [308 310 305]\n ...\n [537 ...
    ikle3:       [[  155   153   156   803   801   804]\n [  310   307   305 ...
    variables:   {'Z': ('ELEVATION Z', 'M'), 'U': ('VELOCITY U', 'M/S'), 'V':...
    date_start:  (1900, 1, 1, 0, 0, 0)

Indexing

ds_last = ds.isel(time=-1)  # last frame

Manipulate variables

ds = ds.assign(UTIMES100=lambda x: x.U * 100)  # Add a new variable
# ds.attrs["variables"]["UTIMES100"] = ("UTIMES100", "My/Unit")  # To provide variable name and unit (optional)
ds.drop_vars(["W"])  # Remove variable `VELOCITY W`

Extracting a specific layer from a 3D DataSet

ds_bottom = ds.selafin.get_dataset_as_2d(plan=0)  # bottom layer

Write Selafin

ds.selafin.write("output_file.slf")

DataSet content

Dimensions

In 2D:

  1. time
  2. node

in 3D:

  1. time
  2. plan
  3. node

Coordinates

Coordinate Description
x East mesh coordinates
y North mesh coordinates
time Datetime serie

Attributes

All attributes are optional except ikle2:

Attribute Description Default value
title Serafin title "Converted with array-serafin"
language Language for variable detection "en"
float_size Float size 4 (single precision)
endian File endianness ">"
params Table of integer parameters (can be rebuilt)
ikle2 Connectivity table in 2D (1-indexed) -
ikle3 Connectivity table in 3D (1-indexed, only in 3D, optional) (can be rebuilt from 2D)
variables Dictionary with variable names and units (key is variable abbreviation) -
date_start Starting date with integers (year to seconds) (from first time serie)

Metadata

Release files for xarray-selafin 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xarray-selafin 0.2.5
File Size Uploaded Provenance
xarray_selafin-0.2.5.tar.gz 29.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for xarray-selafin 0.2.5
File Interpreter ABI Platform
xarray_selafin-0.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 59.3 kB

Release files / xarray_selafin-0.2.5.tar.gz

Download URL xarray_selafin-0.2.5.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ff24e5f0f14e90ad9badab7a122d8c31ebc30a0cbc124567a00ff4a97717c253
BLAKE2b-256 checksum
How to use checksums
477945d2fb5d784fb50e83aaa7b43a2af3ec051df57a272b0599701213de5552
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.11.10 Linux/6.8.0-138-generic

Release files / xarray_selafin-0.2.5-py3-none-any.whl

Download URL xarray_selafin-0.2.5-py3-none-any.whl
Size 29.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0df172f00a3a2e42c1fe26ad38cefcb851be4ea54eed2722201a674fbf398e67
BLAKE2b-256 checksum
How to use checksums
0dac2ce25fdd37a6c956de918c2152ac229c96afaa13a5855e6c2a82b07c3222
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.11.10 Linux/6.8.0-138-generic

Security for xarray-selafin 0.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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