Skip to main content

No project description provided

Project description

xarray backend for Selafin formats

Supports lazy loading by default.

Dev guide

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

pip install xarray-selafin

Read Selafin

import xarray as xr
ds = xr.open_dataset("tests/data/r3d_tidal_flats.slf", engine="selafin")
ds = xr.open_dataset("tests/data/r3d_tidal_flats.slf", lang="fr", engine="selafin")  # if variables are in French
<xarray.Dataset>
Dimensions:  (time: 17, node: 648, plan: 21)
Coordinates:
    x        (node) float32 ...
    y        (node) float32 ...
  * time     (time) datetime64[ns] 1900-01-01 ... 1900-01-02T20:26:40
Dimensions without coordinates: node, plan
Data variables:
    Z        (time, node, plan) <class 'numpy.float64'> ...
    U        (time, node, plan) <class 'numpy.float64'> ...
    V        (time, node, plan) <class 'numpy.float64'> ...
    W        (time, node, plan) <class 'numpy.float64'> ...
    MUD      (time, node, plan) <class 'numpy.float64'> ...
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`

Write Selafin

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

DataSet content

Dimensions

  • time
  • node
  • plan (only in 3D)

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 "" (empty string)
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)

Project details


Download files

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

Source Distribution

xarray_selafin-0.1.8.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

xarray_selafin-0.1.8-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file xarray_selafin-0.1.8.tar.gz.

File metadata

  • Download URL: xarray_selafin-0.1.8.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.6 Linux/6.5.0-35-generic

File hashes

Hashes for xarray_selafin-0.1.8.tar.gz
Algorithm Hash digest
SHA256 7e1e952cd4f3c4dcfc5063508e528bec0d7bea0c208e005e3952d29a23e264a2
MD5 ddbf853e717f6329b6ab07ae55d5671d
BLAKE2b-256 94f73262f06f47a82f027a79221c0614ffb083a6ecfbd85e41116ebfc2230028

See more details on using hashes here.

Provenance

File details

Details for the file xarray_selafin-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: xarray_selafin-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.6 Linux/6.5.0-35-generic

File hashes

Hashes for xarray_selafin-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f9cd5c3c68bca14f770303ab61c3db91e09e622276f5fe54a686b2426f88d3c4
MD5 cfac6102e2ffcda0f8778550ab11c736
BLAKE2b-256 f1c66313d1308e08838785cab0eff91e425ca04202f9e7a402833a9c44d87fff

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page