Skip to content
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

Module Design #7

Open
mgrover1 opened this issue Sep 1, 2022 · 10 comments
Open

Module Design #7

mgrover1 opened this issue Sep 1, 2022 · 10 comments

Comments

@mgrover1
Copy link
Collaborator

mgrover1 commented Sep 1, 2022

Let's think about the design!

We would like users to be able to use the following:

import xarray as xr
import xradar

ds = xr.open_dataset("some_radar_data.nc", engine="xradar")

This would return a datatree, with a tree which contains datasets.

We should use the xwrf package as an inspiration here - https://github.com/xarray-contrib/xwrf, which uses a similar approach and API design.

The general xradar reader here would contain the different formats within it (ex. ODIM_H5, CfRadial1, CfRadial2).

General API

One decision we need to make is whether we should make functionality:

  • Read + return an xradar object (ex. calculate_kdp(xradar) --> xradar)
  • Operate on the xradar dataset (ex. xradar.kdp())
@kmuehlbauer
Copy link
Collaborator

@mgrover1 The loading would not work as long as xarray does not adopt datatree unfortunately. Currently we would need to employ datatree functionality directly or to begin with just return a specific sweep.

@mgrover1
Copy link
Collaborator Author

mgrover1 commented Sep 12, 2022

@kmuehlbauer I think we can do this with the existing datatree API, so it might look like

import datatree as dt
import xradar

ds = dt.open_datatree("some_radar_data.nc", engine="xradar")

We would just need to make sure the backend API is configured to support this

@kmuehlbauer
Copy link
Collaborator

I'll try this, but there might be more involved with the Backend API. The thing is, the backend API is relying on getting back single groups from files by calling open_dataset multiple times . With cfradial1 there is only one call to open_dataset. Not sure, if it makes much sense to replicate the multiple open approach for cfradial1 files. Anyway, thanks for the suggestion, I''ll definitely have a look that way.

@kmuehlbauer
Copy link
Collaborator

@mgrover1 Ah, and we would need to make datatree work with other engines...

https://github.com/xarray-contrib/datatree/blob/main/datatree/io.py#L55-L60

@mgrover1
Copy link
Collaborator Author

@kmuehlbauer - what would you think if we redesigned the model module? Right now, it has a collection of helper functions, but each backend/tree needs to put together its own implementation of it; what if we created a main xradar object, that we used in each of the IO modules, as well as submodules?

This object would then have the other methods associated with it (ex. get_x_y_z

ex.

dt= Xradar()

This would also allow us to add special indexing functionality and such (allowing things like dt.isel(azimuth=0)) which is not currently possible since it is not one of our dimensions.

@kmuehlbauer
Copy link
Collaborator

You mean like a class wrapper around xr.Dataset? Hmm, how would we get a sweep dataset out of it? Or do you mean accessor based? I think I'm missing something.

@mgrover1
Copy link
Collaborator Author

I think a wrapper around the datatree...

@kmuehlbauer
Copy link
Collaborator

Ok, I can't imagine that right now, but we can try several things. Not bound to a single solution.

@mgrover1
Copy link
Collaborator Author

I can draft something up :)

@jfigui
Copy link

jfigui commented Sep 28, 2022

Hi,
Personally I favor kdp(xradar) as an approach. Less magic.
Cheers,

Jordi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants