-
Notifications
You must be signed in to change notification settings - Fork 16
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
Improve the sgrid variable API #76
Comments
@kwilcox thanks for the sci-wms references above. The first and last should be included in Here is a prototype API where the center averaging function became a method of the Note that rotation is not a good candidate to become an sgrid variable method, because it dependeds on 3 (or 4) variables: |
I'm working on the cell tree grid searching and interpolation routines, and refactoring them now to deal with the API changes. I've got two questions relating to the staggered grids and what the current momentum is:
|
I would like to suggest that the grid coordinates NOT be lazy loaded, and stored as numpy arrays (either raw or wrapped in a SGridVariable. I don't think they're large enough or infrequently used enough to warrant the data transfer/memory usage saved by lazy loading. If they still must be lazy loaded, then upon first use (data retrieval) they should be fully loaded for the rest of the life of the object. |
Cool. Can you point us to a repo/branch where you are working in this?
Be aware that
Not sure what you are calling Note that center will be renamed. (See #73).
The (@ayan-usgs can probably say more about this.) I don't know about valid space because one can average on the faces or on the edges depending on the application. (Although with high resolution models this does not really matter.) Usually, the faces are preferred because then all variables are in the same grid. (In ROMS language that is
👎 We do have applications where sub-setting before downloading is highly desired. The numpy-like lazy object is not defined yet, but it should not be a problem to any application you have in mind.
That is how a good lazy object should work 😄 Again this is not a blocker to any application that needs eager loading. All you have to do is to trigger the loading and keep doing your thing. Sorry I could not help more. I need to get back to |
Thanks a lot Filipe. https://github.com/jay-hennen/pysgrid I don't have an example notebook up yet...the lazy loading of grids issue is the block at the moment. A lot of this interpolation depends on the grids being not only loaded, but use numpy-style advanced indexing. The grids should also persist between interpolation calls, if you want any semblance of efficiency.
It's a little tougher than that, because it's the sgrid functions that need eager loading. I'm working from a ROMS C-grid perspective where there are 4 distinct grids you can work on. Most data is on the 'rho' grid (cell centers + 1 value on all edges; this is like the faces+padding:both option?) but the u,v components of velocity have their own grids on the edges of the cell. I asked about the names because my variables are currently a hybrid mess of ROMS and SGrid.
It was big this time because nodes was split into nodes_lon and nodes_lat. As long as paradigm shifts like that is over it should be okay :)
When I say valid space I mean whichever grid is meant to define the physical boundary of the grid. The way I understand it that's the psi grid, so that when you place the variables on the rho/u/v grids you can get nice boundary conditions because they are all slightly larger. |
Hi, Just a few random comments on the issues you raise. I haven't had time to The sgrid conventions have indeed been inspired by the ugrid conventions. The idea was thata quantity defined at face-dimension in first direction Regards, Bert
|
Definitely not taking that approach. Our use case is interpolating a variable to arbitrary points on the psi grid. The variable is on a completely different grid (rho, u, v), which necessitates either additional point location calls (slow) or index translation (faster) so you can get the right values to interpolate with. If edge1_coordinates is going to become edge1_lon and edge1_lat etc, I can work fine with that (since they would contain the staggered Arakawa C grids, right? Just have to keep which one is u and which is v straight. |
@hrajagers, Bert, good to see you here! |
Hi Rich, Delft3D 4 writes out files NetCDF files following SGRID conventions (set I have started to implemented to support UGRID in the MATLAB code of Cheers, Bert On Tue, Feb 2, 2016 at 6:48 PM, Rich Signell [email protected]
|
OK, your psi grid is the grid of corner points. On Tue, Feb 2, 2016 at 6:44 PM, jay-hennen [email protected] wrote:
|
Not sure what you mean by that. It's also still possible to do index translation if you think about them as separate grids, you just have to check that your point is within the new index and search the alternatives if it's wrong. As for the ROMS names...I don't know. I'll probably convert the ones I have been using to what sgrid is using so it won't be an issue. |
Not totally sure what you mean by checking whether a point is inside an
|
It's a bit tough to think about. Drawing a picture is helpful but it can also get cluttered fast! The gist of the problem is that if you pick a random point in a psi cell, that point could be in one of 4 different rho cells. If the point is in psi cell [0, 0], then it could be in rho cell [0, 0], [0, 1], [1, 0], or [1, 1] and you have to find out which. In the rectilinear case this can be done with simple less-than/greater-than comparisons, but it gets more complicated in the curvilinear case. If you only work with rectangular grids you might also think that a point in a psi cell could be in one of two u or v cells, but that's not true in the curvilinear case either. It's actually six; two are very likely, but if the difference in grid shape could put it in one of the other four. The whole point of finding the cell, btw, is to find the correct 4 values to use for interpolation. |
This discussion is good, but it is drifting away from the @jay-hennen I don't understand your worries about lazy loading. Maybe I will once I see the code/implementation of your ideas. (I checked your Note that the lazy loading is virtually the same thing you would get by loading your data with I will be back working on this soon. Stay tuned... @hrajagers Thanks for the clarifications and the links! I will put together a notebook example for PS: I could not see the code from https://svn.oss.deltares.nl/repos/delft3d/trunk/src/tools_lgpl/matlab/quickplot/progsrc. I got a login dialog. |
Most of the changes are in here Filipe: After I slice a netCDF variable, how long does that information persist? If I make subsequent calls will the previous calls remain? self.node_lon[:] Would that translate into three lazy loads or just two? If we skip the middle line, is it two or one? Or does it work like I think it does, where you have to explicitly save the array you get back from the call, otherwise it doesn't persist? EDIT: Nevermind, I figured it out. It works fine. I just have to be careful to slice it ASAP On an API note, are edge1_lon/lat and edge2_lon/lat expected to be introduced? If so I can update everything to use them. |
I see you committed d31bacf yesterday, thanks! Feel free to send it as a PR so @ayan-usgs and @kwilcox can comment too.
Yep. That is what I meant be load it with
I will defer that question to @ayan-usgs and I am still reading the code and getting familiar with his work. |
@kwilcox mentioned in #72
sci-wms needs to know too much information about what an sgrid is:
Anything that closes the implementation gap between pysgrid and potential users. I'd love it if sci-wms never had:
Basically, all data access should assume the user wants it back on the centers and pad/slice/rotate as needed. If a user wants the raw data they can just use
netCDF4
.The text was updated successfully, but these errors were encountered: