Skip to content

Commit 1ab2f0a

Browse files
authored
[feat] Forward keyword arguments from open_dataset to MetopDataset (#16)
* Update readme after Pypi release. * Add keyword arguments to open_dataset
1 parent 5512db1 commit 1ab2f0a

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ It's a Python wrapper around [MetopDatasets.jl](https://github.com/eumetsat/Meto
55
[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).
66

77
## Status
8-
MetopPy is under development and is not ready for use yet.
8+
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.
99

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

1717
## Installation
18-
(This still have to be implemented)
1918
```bash
2019
pip install metoppy
2120
```
2221

22+
## Documentaion
23+
MetopPy does not yet have its own dedicated documentation page. The best resource for now is the Examples section later in this README.
24+
25+
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.
2326

2427
## Dependencies
2528

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

195198
3. Move to the repository and install the package for testing
196-
```
199+
```bash
197200
cd /usr/local/bin/metoppy && pip install -e .[test]
198201
```
199202

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

202-
```
205+
```bash
203206
pytest metoppy/tests
204207
```
205208

metoppy/metopreader.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def shape(self, variable_or_j_array):
7676
"""
7777
return Main.size(variable_or_j_array)
7878

79-
def open_dataset(self, file_path: str, maskingvalue = Main.missing):
79+
def open_dataset(self, file_path: str, **kwargs):
8080
"""
8181
Open a dataset from a record path using MetopDatasets.MetopDataset.
8282
@@ -85,17 +85,21 @@ def open_dataset(self, file_path: str, maskingvalue = Main.missing):
8585
file_path : str
8686
Path to the dataset record.
8787
88-
maskingvalue
89-
The masking values are used to replace missing observations. Defaults to Julia Missing type.
90-
A recommended alternative is float("nan") which increasse performance for float data.
88+
89+
**kwargs
90+
Keyword arguments forwarded to MetopDatasets.MetopDataset constructor.
91+
92+
maskingvalue
93+
The masking values are used to replace missing observations. Defaults to Julia Missing type.
94+
A recommended alternative is float("nan") which increasse performance for float data.
9195
9296
Returns
9397
-------
9498
Julia object
9599
A MetopDataset object opened from the provided path.
96100
"""
97101
try:
98-
return self._open_dataset(file_path, maskingvalue = maskingvalue)
102+
return self._open_dataset(file_path, **kwargs)
99103
except Exception as e:
100104
raise RuntimeError(f"Failed to open dataset: {file_path}") from e
101105

metoppy/tests/test_basic_interface.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,28 @@ def test_different_file_types(metop_reader, test_file):
192192
assert ds is not None
193193
assert "record_start_time" in metop_reader.get_keys(ds)
194194

195+
# clean
196+
metop_reader.close_dataset(ds)
197+
198+
199+
@pytest.mark.parametrize("test_file", ["IASI_xxx"], indirect=True)
200+
def test_no_auto_convert(metop_reader, test_file):
201+
"""
202+
Test the auto_convert=False. This should retun varibles in the data type
203+
used to store them on disk.
204+
"""
205+
# arrange
206+
from juliacall import Main as jl
207+
ds = metop_reader.open_dataset(file_path=str(test_file), auto_convert=False)
208+
209+
# act
210+
start_time = ds["record_start_time"][2]
211+
212+
# assert
213+
assert jl.isa(start_time, jl.MetopDatasets.ShortCdsTime)
214+
# ShortCdsTime stores the date as days and milliseconds since 00:00 1/1-2000
215+
assert start_time.day == 9034
216+
assert start_time.millisecond == 73275381
217+
195218
# clean
196219
metop_reader.close_dataset(ds)

0 commit comments

Comments
 (0)