-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pysteps.io with xarray #219
Merged
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
cdc4e66
Add xarray dependency
dnerini 2071000
MCH importer returns an xarray Dataset
dnerini 718763b
Remove plot lines
dnerini 10629f4
Remove import
dnerini b7158b8
Adapt readers to xarray format
dnerini 32b5c5f
Rewrite as more general decorator
dnerini bdfeaa2
Add missing metadata
dnerini 2c3c613
Adapt io tests
dnerini 6578c88
Mrms bounding box (#222)
dnerini a929307
Import xarray DataArray
dnerini 8bda822
Black
dnerini 25cb4c9
Do not hardcode metadata
dnerini 2866be8
Address review comments by ruben
dnerini 00bce15
Add a legacy option to the io functions
aperezhortal ca891aa
Fix compatibility problems with tests
aperezhortal 92e07f5
Update dependencies
dnerini 15d5b5b
Ignore plugins test
aperezhortal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ dependencies: | |
- pillow | ||
- pyproj | ||
- scipy | ||
- xarray |
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 |
---|---|---|
|
@@ -30,3 +30,4 @@ dependencies: | |
- cartopy>=0.18 | ||
- scikit-image | ||
- pandas | ||
- xarray |
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
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,35 @@ | ||
from datetime import datetime | ||
|
||
import pytest | ||
|
||
import pysteps | ||
|
||
|
||
def test_find_by_date_mch(): | ||
|
||
pytest.importorskip("PIL") | ||
|
||
date = datetime.strptime("201505151630", "%Y%m%d%H%M") | ||
data_source = pysteps.rcparams.data_sources["mch"] | ||
root_path = data_source["root_path"] | ||
path_fmt = data_source["path_fmt"] | ||
fn_pattern = data_source["fn_pattern"] | ||
fn_ext = data_source["fn_ext"] | ||
timestep = data_source["timestep"] | ||
|
||
fns = pysteps.io.archive.find_by_date( | ||
date, | ||
root_path, | ||
path_fmt, | ||
fn_pattern, | ||
fn_ext, | ||
timestep=timestep, | ||
num_prev_files=1, | ||
num_next_files=1, | ||
) | ||
|
||
assert len(fns) == 2 | ||
assert len(fns[0]) == 3 | ||
assert len(fns[1]) == 3 | ||
assert isinstance(fns[0][0], str) | ||
assert isinstance(fns[1][0], datetime) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives the same result as the commented line in line 293, right? Well, we could remove one of the options in that case. :)
In addition, just to check, this line is meant to point to the cell centers? (in that case everything is fine!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we should stay with DataArray for the moment for the core rutines. Said that however, xarray opens netCDF as Datasets so eventually user may need to select the variable from a dataset to run our core routines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About 'projection', CF conventtions stat that "A grid mapping variable may be referenced by a data variable in order to explicitly declare the coordinate reference system (CRS) used for the horizontal spatial coordinate values"
https://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#grid-mappings-and-projections
so if outputs are to be netCDF, it would be useful to have Datasets with both the variable and the 'grid mapping variable' (aka projection)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should, but at the moment the commented lines do not work because some importers wrongly report the x1, x2, y1, y2 coordinates as the coordinates of the corner pixels instead of the corners themselves... but we should use the commented code (it's safer), which is why I would prefer to leave them there for the time being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's stick to DataArrays for now, but we can easily switch to dataset at any moment before realising V2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly very important for the netcdf exporters, perhaps less internally to the code itself?