Metadata-Version: 2.3
Name: pysurfex
Version: 0.1.2
Summary: Python API to SURFEX
License: MIT
Author: Trygve Aspelien
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Provides-Extra: faformat
Provides-Extra: linting
Provides-Extra: netcdf
Provides-Extra: plot
Provides-Extra: points
Provides-Extra: test
Provides-Extra: verification
Requires-Dist: black[jupyter] (>=23.10.0) ; extra == "linting"
Requires-Dist: cartopy ; extra == "faformat"
Requires-Dist: cfunits (>=3.3.5) ; extra == "netcdf"
Requires-Dist: eccodes (>1.5.1) ; extra == "points"
Requires-Dist: epygram (>=2.0.0) ; extra == "faformat"
Requires-Dist: f90nml (>=1.4.3)
Requires-Dist: falfilfa4py (>=1.0.0) ; extra == "faformat"
Requires-Dist: findlibs (>=0.0.5,<=1.0.0) ; (python_version < "3.10") and (extra == "points")
Requires-Dist: gridpp (>=0.7.1) ; extra == "points"
Requires-Dist: isort (>=5.12.0) ; extra == "linting"
Requires-Dist: matplotlib (>=3.7.1) ; extra == "plot"
Requires-Dist: netcdf4 (>=1.5.7) ; extra == "netcdf"
Requires-Dist: numpy (>=1.20.1)
Requires-Dist: pandas (>=2.0.0) ; extra == "verification"
Requires-Dist: poethepoet[poetry-plugin] (>=0.24.4) ; extra == "linting"
Requires-Dist: pydoclint (>00.3.8) ; extra == "linting"
Requires-Dist: pyproj (>=3.3.0)
Requires-Dist: pytest (>=7.2.2) ; extra == "test"
Requires-Dist: pytest-cov (>=4.0.0) ; extra == "test"
Requires-Dist: pytest-mock (>=3.7.0) ; extra == "test"
Requires-Dist: pytest-profiling (>=1.7.0) ; extra == "test"
Requires-Dist: pytest-timeout (>=2.1.0) ; extra == "test"
Requires-Dist: pytest-xdist (>=3.2.0) ; extra == "test"
Requires-Dist: pyyaml (>=6.0) ; extra == "points"
Requires-Dist: requests (>=2.32.3) ; extra == "points"
Requires-Dist: ruff (>=0.11.0) ; extra == "linting"
Requires-Dist: sphinx (>=7.0.0) ; extra == "test"
Requires-Dist: titanlib (>=0.3.4.dev3) ; extra == "points"
Requires-Dist: verif (>=1.2.3) ; extra == "verification"
Requires-Dist: xarray (>=2025.3.1) ; extra == "verification"
Description-Content-Type: text/x-rst



Python API to SURFEX (pysurfex)
=======================================================

An API in python to the external surface model SURFEX.
    - Prepare input and namelists to a SURFEX binary
    - Create atmospheric forcing for offline SURFEX runs
    - Read SURFEX output
    - Quality control of observations with titanlib
    - Optimal interpolation with gridpp
    - Monitor the observations usage

See online documentation in https://metno.github.io/pysurfex/

Installation of pregenerated packages from pypi (pip)
---------------------------------------------------------

All releases will trigger an autmomatic pre-built package on pypi which can be installed by pip

.. code-block:: bash

  pip3 install pysurfex

User installation:

.. code-block:: bash

  pip3 install pysurfex --user


Run pysurfex from pre-built container
-------------------------------------------

Releases also trigger an update of the pysurfex container in the github container registry. Below is an example to run pgd without any arguments.

.. code-block:: bash

  podman run -it ghcr.io/metno/pysurfex:latest pgd


Installation on debian based Linux system
--------------------------------------------

The following depencies are needed. Install the non-standard ones e.g. with pip or your system installation system.

General dependencies (from pypi)
---------------------------------

.. code-block:: bash

  numpy
  pyproj
  pyyaml
  f90nml

To read NetCDF files:

.. code-block:: bash

  NetCDF4
  cfunits

To read grib files:

.. code-block:: bash

  eccodes

from ECMWF https://software.ecmwf.int/wiki/display/ECC/Releases installed with ENABLE_PYTHON=ON

To read FA files:

.. code-block:: bash

  falfilfa4py
  epygram

To plot:

.. code-block:: bash

  matplotlib

To get observations from frost.met.no API:

.. code-block:: bash

  requests

For Quality control of observations

.. code-block:: bash

  titanlib

For optimal interpolation and observation operators

.. code-block:: bash

  gridpp

For testing:

.. code-block:: bash

  pytest


Install pysurfex
-------------------------------------------

An environment manager like miniconda or micromamba is recommended to ensure consistency between the packages.
After installing this you need to set it up for the current session or permanently add it to your shell.
Now it is easy to create a suitable environment for pysurfex. Below is a recipie for micromamba.


.. code-block:: bash

    # Install micromamba (linux, https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html)
    "${SHELL}" <(curl -L micro.mamba.pm/install.sh)

    # specify a installation location for micromamba and add it to your path afterwards. Default it will install in $HOME/.local/bin
    export PATH=$HOME/.local/bin:$PATH  # Use your PATH

    # initialize your shell (needed in all shells), e.g:
    eval "$(micromamba shell hook --shell bash)"

    micromamba create env pysurfex
    micromamba activate pysurfex
    micromamba install python==3.12 poetry

Download the source code, then install ``pysurfex`` by executing the following inside the extracted
folder:

.. code-block:: bash

  poetry install


If not already in a conda/manba environment, this will install ``pysurfex`` in a poetry environment and this environment can be activated interactively by:

.. code-block:: bash

  poetry shell

or

Run pysurfex client applications
-------------------------------------------

.. code-block:: bash

  poetry run [command]
  # e.g.
  poetry run python # will run python inside the pysurfex poetry environment



Examples
-----------------------

See https://metno.github.io/pysurfex/#examples

