Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ It's a Python wrapper around [MetopDatasets.jl](https://github.com/eumetsat/Meto
[MetopDatasets.jl](https://github.com/eumetsat/MetopDatasets.jl) is a package for reading products from the [METOP satellites](https://www.eumetsat.int/our-satellites/metop-series) 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](https://user.eumetsat.int/dashboard).

## Status
MetopPy is under development and is not ready for use yet.
MetopPy is still in an early development phase. Some features from MetopDatasets.jl are not yet implemented, and the public API may undergo breaking changes in the near future. That said, the package is already useful in its current immature state, and we appreciate curious users trying it out and providing feedback through GitHub issues.

## Copyright and License
This code is licensed under MIT license. See file LICENSE for details on the usage and distribution terms.
Expand All @@ -15,11 +15,14 @@ This code is licensed under MIT license. See file LICENSE for details on the usa
* Francesco Murdaca- *Contributor* - [EUMETSAT](http://www.eumetsat.int)

## Installation
(This still have to be implemented)
```bash
pip install metoppy
```

## Documentaion
MetopPy does not yet have its own dedicated documentation page. The best resource for now is the Examples section later in this README.

Another useful resource is the [MetopDatasets.jl documentaion page](https://eumetsat.github.io/MetopDatasets.jl/dev/), which provides concrete examples of how to use the Julia version of the package, supported data formats, and additional information.

## Dependencies

Expand Down Expand Up @@ -193,13 +196,13 @@ docker run -v ./:/usr/local/bin/metoppy -it python:3.12 /bin/bash
```

3. Move to the repository and install the package for testing
```
```bash
cd /usr/local/bin/metoppy && pip install -e .[test]
```

4. Modify the local code and test in the container.

```
```bash
pytest metoppy/tests
```

Expand Down
14 changes: 9 additions & 5 deletions metoppy/metopreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def shape(self, variable_or_j_array):
"""
return Main.size(variable_or_j_array)

def open_dataset(self, file_path: str, maskingvalue = Main.missing):
def open_dataset(self, file_path: str, **kwargs):
"""
Open a dataset from a record path using MetopDatasets.MetopDataset.

Expand All @@ -85,17 +85,21 @@ def open_dataset(self, file_path: str, maskingvalue = Main.missing):
file_path : str
Path to the dataset record.

maskingvalue
The masking values are used to replace missing observations. Defaults to Julia Missing type.
A recommended alternative is float("nan") which increasse performance for float data.

**kwargs
Keyword arguments forwarded to MetopDatasets.MetopDataset constructor.

maskingvalue
The masking values are used to replace missing observations. Defaults to Julia Missing type.
A recommended alternative is float("nan") which increasse performance for float data.

Returns
-------
Julia object
A MetopDataset object opened from the provided path.
"""
try:
return self._open_dataset(file_path, maskingvalue = maskingvalue)
return self._open_dataset(file_path, **kwargs)
except Exception as e:
raise RuntimeError(f"Failed to open dataset: {file_path}") from e

Expand Down
23 changes: 23 additions & 0 deletions metoppy/tests/test_basic_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,28 @@ def test_different_file_types(metop_reader, test_file):
assert ds is not None
assert "record_start_time" in metop_reader.get_keys(ds)

# clean
metop_reader.close_dataset(ds)


@pytest.mark.parametrize("test_file", ["IASI_xxx"], indirect=True)
def test_no_auto_convert(metop_reader, test_file):
"""
Test the auto_convert=False. This should retun varibles in the data type
used to store them on disk.
"""
# arrange
from juliacall import Main as jl
ds = metop_reader.open_dataset(file_path=str(test_file), auto_convert=False)

# act
start_time = ds["record_start_time"][2]

# assert
assert jl.isa(start_time, jl.MetopDatasets.ShortCdsTime)
# ShortCdsTime stores the date as days and milliseconds since 00:00 1/1-2000
assert start_time.day == 9034
assert start_time.millisecond == 73275381

# clean
metop_reader.close_dataset(ds)