Skip to main content

Python package wrapper of MetopDatasets.jl Julia package for reading products from the METOP satellites.

Project description

MetopPy

Load native METOP products in Python. It's a Python wrapper around MetopDatasets.jl making it easy to install and use the package with Python.

MetopDatasets.jl is a package for reading products from the METOP satellites using the native binary format specified for each product. The METOP satellites are part of the EUMETSAT-POLAR-SYSTEM (EPS) and have produced near real-time, global weather and climate observation since 2007. Learn more METOP and the data access on EUMETSATs user-portal.

Status

MetopPy is under development and is not ready for use yet.

Copyright and License

This code is licensed under MIT license. See file LICENSE for details on the usage and distribution terms.

Authors

  • Simon Kok Lupemba - Maintainer - EUMETSAT
  • Francesco Murdaca- Contributor - EUMETSAT

Installation

(This still have to be implemented)

pip install metoppy

Dependencies

Dependency Version License Home URL
juliacall >=0.9.14 MIT License https://juliapy.github.io/PythonCall.jl/stable/
juliapkg >=0.1.22 MIT License https://pypi.org/project/juliapkg/

Build/Edit/Test Dependencies

The following dependencies are only required for building/editing/testing the software, they are not distributed with it:

Dependency Version License Home URL
pytest 8.4.1 MIT License (MIT) https://docs.pytest.org/en/latest
pytest-cov 7.0 MIT License (MIT) https://pytest-cov.readthedocs.io/en/latest
pytest-html 4.1.1 MIT License (MIT) https://github.com/pytest-dev/pytest-html
pytest-mock 3.14.1 MIT License (MIT) https://github.com/pytest-dev/pytest-mock
pre-commit 4.3.0 MIT License (MIT) https://github.com/pre-commit/pre-commit
numpy 2.3.4 BSD License (BSD) https://numpy.org/

Example

  1. Get test file
from pathlib import Path
from metoppy.metopreader import MetopReader

metop_reader = MetopReader()
reduced_data_folder = metop_reader.get_test_data_artifact()
# ensure it's a Path object
reduced_data_folder = Path(reduced_data_folder)
reduced_data_files = [f for f in reduced_data_folder.iterdir() if f.is_file()]

test_file_name = next((s for s in reduced_data_files if s.name.startswith("ASCA_SZO")))
test_file_path = reduced_data_folder / test_file_name
ds = metop_reader.open_dataset(file_path=str(test_file_path), maskingvalue = float("nan"))
  1. Check keys
keys = metop_reader.get_keys(ds)
print(list(keys))
Output of the print
['record_start_time', 'record_stop_time', 'degraded_inst_mdr', 'degraded_proc_mdr', 'utc_line_nodes', 'abs_line_number', 'sat_track_azi', 'as_des_pass', 'swath_indicator', 'latitude', 'longitude', 'sigma0_trip', 'kp', 'inc_angle_trip', 'azi_angle_trip', 'num_val_trip', 'f_kp', 'f_usable', 'f_land', 'lcr', 'flagfield']
  1. Display variable information
print(ds['latitude'])
Output of the print
latitude (42 × 10)
  Datatype:    Float64 (Int32)
  Dimensions:  xtrack × atrack
  Attributes:
   description          = Latitude (-90 to 90 deg)
   missing_value        = Int32[-2147483648]
   scale_factor         = 1.0e-6
  1. Read variable as neasted Python list
# Load CFVariable as a full Julia Array
latitude_julia = metop_reader.as_array(ds['latitude']) # preserves the 2D shape
latitude_shape = metop_reader.shape(latitude_julia)

# Convert to nested Python list
latitude_list = [
  [latitude_julia[i, j] for j in range(latitude_shape[1])]
  for i in range(latitude_shape[0])
]

# Print first 5x5 elements
for row in latitude_list[:5]:
    print(row[:5])
Output of the print
[71.101406, 70.99323199999999, 70.88307999999999, 70.770985, 70.65697999999999]
[71.298254, 71.18898999999999, 71.077743, 70.964546, 70.849434]
[71.494503, 71.384132, 71.271771, 71.157454, 71.041217]
[71.690134, 71.578638, 71.465144, 71.349689, 71.23231]
[71.885128, 71.772486, 71.65784099999999, 71.541231, 71.422691]
  1. Read a slice of the variable (This is a good way to limit memory use for large variables)
longitude_slice = metop_reader.as_array(ds['longitude'][10:14,0:2])
print(metop_reader.shape(longitude_slice))
Output of the print
(4, 2)
  1. View the julia array as numpy (requires that numpy is also installed)
import numpy as np
# View the julia array as a numpy array
longitude_slice_np = np.array(longitude_slice, copy = None)
print(longitude_slice_np)
Output of the print
[[233.685948 233.033544]
 [233.276564 232.620004]
 [232.858097 232.197423]
 [232.430274 231.765534]]
  1. Close dataset and free file lock
metop_reader.close_dataset(ds)

Development

Pre-requisite: Install podman or docker in your machine.

  1. Fork this repository and move into it
git clone XXX && cd XXX
  1. Start container mounting the content
podman run -v ./:/usr/local/bin/metoppy -it python:3.12 /bin/bash

or

docker run -v ./:/usr/local/bin/metoppy -it python:3.12 /bin/bash
  1. Move to the repository and install the package for testing
cd /usr/local/bin/metoppy && pip install -e .[test]
  1. Modify the local code and test in the container.
pytest metoppy/tests
  1. When you are happy, push code to your fork and open a PR (Github)

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

metoppy-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

metoppy-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file metoppy-0.1.0.tar.gz.

File metadata

  • Download URL: metoppy-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for metoppy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 612aea648640f6318ae387dc81dfc1d2620ab64368536d94e40a0aa2529cbb7f
MD5 06cb2e3bee18de248797441acaab7df9
BLAKE2b-256 aa2e1e77ca20cd6c8ccac158521c3cdc1e3749bd84b97ad03a96210268e557dc

See more details on using hashes here.

File details

Details for the file metoppy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: metoppy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for metoppy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec00131d0007f9858e6967afd17a06876066591a6ad0c915ab75504f71bff092
MD5 8ce4daaf9268898ce74893c3d630961f
BLAKE2b-256 3b169e9f654df0e9493168e4032eaa043a4ef9daa012564a42767f6c2e4ae2e2

See more details on using hashes here.

Supported by

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