-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DataMet backend for Italian Radar data (#175)
* ADD: datamet backend for italian C-band data * ADD: add unit test for datamet backend * ENH: support for .gz files in DataMet reader * [ENH] black style formatting * remove version.py * make DataMetBackend discoverable * fix tests * fix entrypoint * ENH: add tests for datamet xarray backend * FIX: remove version.py * ENH: added more tests for datamet format * ENH: black fix * FIX: fix E721 in type comparison (ruff) * DOC: edited history.md * FIX: changed xradar.io.backends.DataMetBackendEntrypoint to 'datamet' * FIX: black formatting --------- Co-authored-by: Kai Mühlbauer <[email protected]> Co-authored-by: Kai Mühlbauer <[email protected]>
- Loading branch information
1 parent
89d9a3e
commit 2d266bb
Showing
8 changed files
with
681 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import tarfile | ||
|
||
import pytest | ||
|
||
from xradar.io.backends import datamet | ||
from xradar.util import _get_data_file | ||
|
||
|
||
@pytest.fixture | ||
def data(datamet_file): | ||
with _get_data_file(datamet_file, "file") as datametfile: | ||
print(datametfile) | ||
data = datamet.DataMetFile(datametfile) | ||
assert data.filename == datametfile | ||
print(data.scan_metadata) | ||
data.get_sweep(0) | ||
return data | ||
|
||
|
||
def test_file_types(data): | ||
assert isinstance(data, datamet.DataMetFile) | ||
assert isinstance(data.tarfile, tarfile.TarFile) | ||
|
||
|
||
def test_basic_content(data): | ||
assert data.moments == ["UZ", "CZ", "V", "W", "ZDR", "PHIDP", "RHOHV", "KDP"] | ||
assert len(data.data[0]) == len(data.moments) | ||
assert data.first_dimension == "azimuth" | ||
assert data.scan_metadata["origin"] == "ILMONTE" | ||
assert data.scan_metadata["orig_lat"] == 41.9394 | ||
assert data.scan_metadata["orig_lon"] == 14.6208 | ||
assert data.scan_metadata["orig_alt"] == 710 | ||
|
||
|
||
def test_moment_metadata(data): | ||
mom_metadata = data.get_mom_metadata("UZ", 0) | ||
print(mom_metadata) | ||
assert mom_metadata["Rangeoff"] == 0.0 | ||
assert mom_metadata["Eloff"] == 16.05 | ||
assert mom_metadata["nlines"] == 360 | ||
assert mom_metadata["ncols"] == 493 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"moment, expected_value", | ||
[ | ||
("UZ", -3.5), | ||
("CZ", -3.5), | ||
("V", 2.3344999999999985), | ||
("W", 16.0), | ||
("ZDR", 0.6859999999999999), | ||
("PHIDP", 94.06648), | ||
("RHOHV", 1.9243000000000001), | ||
("KDP", 0.5190000000000001), | ||
], | ||
) | ||
def test_moment_data(data, moment, expected_value): | ||
assert data.data[0][moment][(4, 107)] == expected_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.