-
Notifications
You must be signed in to change notification settings - Fork 52
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
transects on the native MPAS grid #586
Comments
Well, we could do model-only transects on the native grid, and still interpolate when we do a direct comparison with obs. Really it's just the bias plot that would have to go, we could even consider plotting the WOCE transect on its own z,x data alongside the model transect. |
@milenaveneziani , @xylar , after talking about this with Milena, I propose a workflow something like this: So I see a workflow like this:
@xylar , maybe you've already thought about this in more detail and have other ideas. |
Thanks @matthewhoffman, that all seems reasonable to me. @xylar, to give you a bit of contest: I was thinking of trying out a 'simple' script, outside of MPAS-Analysis, just to get a feel of how this would work. My vision is to use this mostly for model visualization purposes, not for model-data comparisons (we have already a task for that). We could plot the obs (or climatology or other reanalysis data) alongside it, but just for visual comparison, not quantitative. |
The most important sticking point is how efficient is kd-tree (I must admit I don't really understand how this k-dimensional tree is constructed). |
@xylar I don't have a clear sense of what advantage kd-tree offers in this context over the field "cellsOnCell" @milenaveneziani, I'd propose a modified version of @matthewhoffman's workflow: |
Thanks for these thoughts everyone! I've been working on this for awhile (off and on) and my approach is mostly similar to @matthewhoffman's suggestion. It is important to use edges rather than cell centers because there needs to be a way to not only find the nearest cell but also to determine if you are outside of the nearest cell. I believe that's where I ran into some difficulty but I'll have to refresh my memory. @cbegeman's approach runs into trouble when the transect intersects land, which is frequently the case for us unless transects are chosen very carefully (especially because land is different at different resolutions). It turns out to be exceedingly difficult in my experience to use |
@xylar, I see w.r.t. land difficulties. A potential issue I see is selecting too many cells near the transect (i.e., selected edges snake too much). It seems like we would need an additional cleaning step besides @matthewhoffman's (6) to make sure each cell shares at most 2 edges with other cells or some similar criterion. |
Yes, exactly! I vaguely recall that ended up really having to determine if a given edge intersects the transect, not just if its center is closest to the transect. That's obviously a bit trickier. I'll try to get back to the work I was doing later this week and see where I left things. Assuming the path forward isn't obvious, I'll ask for advice. |
@cbegeman, @matthewhoffman and @milenaveneziani, here is my progress so far. Steps:
Here is an image showing the trial transects I'm playing with on the EC60to30wLI grid (the old 100 vertical layer version): Here are some example temperature transects. Let me know what you think, keeping in mind this is still very much in prototype mode. |
@xylar If you use the adjacency matrix for the selected cells to identify and eliminate each cell that has 3 neighbors AND is a neighbor of a cell that also has 3 neighbors (updating the matrix after each removal) then you'll get rid of some of the zig-zagging. This still won't give you the straightest path possible though. |
I don't think we want to eliminate the zig zag. I think that's a realistic representation of a slice through an MPAS mesh with cellwise constant scalars. |
This looks pretty decent to me, @xylar. My only question is about the last bullet point: wouldn't it be better to leave T,S onto the cell centers (basically plot what you have on the small green dots)? |
And the white spaces in the upper water column in the first two figures are due to the transect going below a ice shelf, right? that's a pretty cool visual. |
Sorry for the confusion. I reworded the last bullet point to make clear that I'm interpolating interface locations, not tracers at cell centers.
Yes, that's correct. I'll probably add brown for land below and maybe slightly blue white for ice above. |
Just to clarify, I wasn't referring to all zig-zag, just cases where the "band" of cells identified is wide. I think this could help make the profiles look less discontinuous. That said, I think these profiles look good and this is a great plotting option to have. It could also be nice to have a couple coordinate labels along the x-axis especially if we're using this for very long transects. |
Ah, yeah, sorry. I was reading/responding on my phone before and didn't get the full picture. I've been careful to include all cells that a given transect intersects. The representation of the transect depicted shouldn't be thought of as going from cell center to cell center. Instead, it should be thought of as slicing through cells in a great-circle arc, but with constant scalar values in each cell. Perhaps that was already clear. Given the design, I don't think it's appropriate to eliminate any cells that a given transect passes through even when consecutive cell centers are far apart and far from the transect itself (some of the more egregious zig-zagging). Doing so would leave a gap in the transect that would need to be filled somehow (and not in a way that is consistent with the model).
Yep, something is needed for sure! I would add the same lat and lon coordinates that we have at the top axis of our current transects. I'll also indicate the start and end with red and green y axes, respectively. And there will be an inset showing the transect on a map as usual. |
@milenaveneziani, nice progress! I'd like to get back to this, too and this will help me get inspired. In the meantime, a few responses to your questions and comments:
Yes, this is the purpose of the collaboration with Charlie and Wenshan. In the meantime, you could use
Yes, for velocities,
That's a tricky one. I hope that helps some. |
Thanks @xylar, that's helpful.
good idea. Although I have printed
but
Is this because the z levels of the edges are on the cells interfaces (not at the same z level as the cell centers)? I realize I should know this, I guess I have never thought about it. |
Correct, it is the minimum of
If you didn't have |
ok, so, even though I will digest all this and try to come up with a decent mask for both land points and points on topography. For what I understand, since I am choosing all edges that have a positive edgeID, I am already considering only ocean edges: is that correct? |
@milenaveneziani, Are you converting all the Fortran indices to python by subtracting one? If so, you'd be getting -1 for the cell index for invalid cells, and that will just grab the last cell in the array (python uses negative indices for counting from the end of the array). So it will be an arbitrary value, and definitely not what you want. |
no no, I am basing the mask on cell number = 0 (I use the -1 only when I am retrieving the fields and need to take into account python indexing). |
indeed, I have already done the 'borrowing' in the other scripts that I have to do regional time series and T,S,density profiles :) |
An alternative to consider: If you want to have a velocity transect that more closely resembles the computed flux normal to the transect, I've been using |
@cbegeman, how does that work when you don't have the tangential component of the velocity at the edge? |
It doesn't, it only works for the normal component. |
So effectively you're taking the velocity component normal to an edge, multiplying it by the normal vector, and then dotting it into a vector normal to the transect, is that the correct idea? I don't think that is equivalent to the velocity normal to the transect so I would be careful about using that. |
@xylar You're right. I do use the approach you originally suggested for plotting and that seems like the right approach for Milena. Sorry for the diversion! |
I think perhaps, one way could be if we had, for each edge that makes up the MPAS-grid transect, an associated 'real' transect piece, which is part of a binned spherical distance between the two end points that define the transect, basically this bullet in the methodology outlined by @xylar a few months ago:
Then, we would simply rotate the normalVelocity with respect to that. Of course the script I have now doesn't do the initial transect binning, so I have no way of knowing about the piecewise 'real' transect. I think I will leave the plot as is now, at least it shows the actual model velocity across each edge. Maybe I'll consider some simple filtering, just for pleasing the eye, but I'll see. One last thing that would be nice to add is a few potential density contours overlapping these fields. |
The trouble is that we simply don't have both components of the velocity at edges. MPAS has a way of constructing the tangential component of velocity at edges, but it is only for the very specific purpose of computing the Coriolis force and I have it on good authority from @toddringler that this velocity should not be treated as appropriate for reconstructing a velocity vector at an edge. Instead, we use radial basis functions to reconstruct the velocity components (either 3D Cartesian or zonal/meridional) at cell centers and those are the only full vector velocities available from MPAS. It would be nice to have something else based more directly on normalVelocity but I do not believe that any such thing is available.
So I think that's where my approach and yours have slightly different purposes. I was never intending to follow model edges. Instead, I wanted to show model properties as if you were slicing through cells where scalar properties are constant within the polygonal prism of each cell. This could be done with velocity (dotted into the local normal to the transect) as well. I want to think about how to do smoother plotting if that's what we desire. I am not a fan of contourf, so I don't necessarily intend to take that route but I will try to make sure whatever approach I take could mimic that result even if it's produced with pcolormesh. I'm thinking about trying an approach similar to what I did in the horizontal here: MPAS-Dev/MPAS-Tools#281 (comment). The principle is essentially the same. |
I started writing this comment below, but then I saw yours and am not sure it's relevant any longer, but since I'm done writing it, here it goes :D: We haven't talked about the transect mask part, but I guess it will depend on whether we'll want to adopt this methodology to identify the transect or not.
I am personally fine either way, I chose to go this route only because it was simpler for me :) |
Do we have general script(s) to accept start and end coordinates (or similar) and return both: |
@cbegeman, the |
After working on this off and on for several weeks, I'm almost there, see: MPAS-Dev/MPAS-Tools#324. I believe I should have it all wrapped up in a few more days. |
2 weeks later, I have this almost wrapped up... |
I am frustrated with the interpolation in our transects, which I feel obscures both the complexity and the coarseness of the native grid and also gives a false sense of resolution.
I would at least like to support the option of transects on the native grid, meaning quadrilaterals that have corners at layer interfaces and edges, and a constant value corresponding to the field within the given cell. This would mean a truer representation of the ice draft and bathymetry to what is actually in the model as well.
To accomplish this, there would need to be an efficient way to find the nearest MPAS edge to a given point in a transect (possibly subdivided to make sure not to skip cells). A promising way to do this (used in COMPASS) is scipy's KDTree. A
KDTree
could be constructed withxEdge
,yEdge
andzEdge
, a corresponding set of(x, y, z)
vectors could constucted for points along the transect, andKDTree.query()
could be used to find the edge index closes to each of these points. Then, redundant points could be removed and the cells connecting adjacent edges (if any) could be discovered.It is fairly clear how this would be used to display model data. It is much less clear how to use this effectively to compare with WOCE or SOSE data, given that the data are sampled at different locations and at different spatial frequency. It may be appropriate to display each data set on its native grid and then use nearest neighbor, rather than linear, interpolation to a comparison grid for differencing. This will likely require some trial and error.
The text was updated successfully, but these errors were encountered: