-
Notifications
You must be signed in to change notification settings - Fork 416
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
Divergence equation in different coordinates? And derivative documentation is limited access, could someone add the finite differentiation scheme formulation or provide a different document? #3477
Comments
I assume this is related to this Stack Overflow question (if so it would be really helpful to focus asking questions in a single venue rather than posting in multiple places--we the developers watch both). As noted in that question, I don't think Bowen 2005 is truly relevant here; that article describes 3-point first and second derivative estimates using finite differencing that is appropriate for grids with non-uniform spacing. You can certainly take a look at the article. The formulation is: Which, bluntly, I did not feel like encoding into mathtext--and isn't exhaustive since you also need to add the forward/backward difference equations for the edges of the domain. PRs welcome to do so. As far as the divergence appropriate to spherical (and projected) coordinates, you can see extensive discussion in #893. We've implemented similar to GEMPAK's implementation. Rather than explicit terms around spherical coordinates, we rely on map factors from PyProj, which gives us |
Thank you for getting back to me! You're correct, as I was digging through and skimming documentation related to Divergence, I realize I misread the documentation for the Also, thank you, I was trying to figure out where It would be a bit much to ask you to sit there and derive all of this out for me, so are there any resources you could point me to that could help me catch up on all of this? Also, if you think these resources are at all useful for me, would it be something you could provide a link to in the documentation to help users working with data gridded in different coordinate schemes? And for future reference, is the vorticity computed by Metpy now computed using the equation provided in the thread you linked me? If so, could you provide that as well for the vorticity documentation? If not, then just ignore this. |
Actually, your answer on stackexchange might have provided a good place to start HERE. So all of this comes from tensor analysis I'm assuming. I'll need to look more into it. Unless you have anything you'd like to add, you can probably close this and thank you for your time! |
Yes, the vorticity computed by MetPy use the equation from that thread. The reference we were working from was the GEMPAK Appendix B2, which has the equation at the end. We were able to replicate GEMPAK results using meridional_scale for my and parallel_scale for mx. Here are some useful spots in the PROJ source code for those factors: To be honest, I never got to a point where I could derive this generally from first principles. We are relying heavily on our ability to reproduce results from GEMPAK for multiple model fields. I think this Wikipedia article should provide the math, but I never got there. |
Let me respond to these 1-by-1 Got it! So it doesn't look exactly like For the code: thankfully the first code snippet is near the start, though I will admit it's been a while since I've used C (though this is C++). I'm guessing PJ_COORD and PJ_LP are defined somewhere in the header files this file imports from at the top. lp is some kind of parameter passed into pj_factors (which is the function we care about) and lp gets brought up frequently. Not quite sure what
but, from here x_p and x_l are derivatives of x for lambda and phi so I'm guessing I might need to keep looking into this for a while, but this looks like the equation for a delta along a surface and I remember seeing this used heavily in line integration. Thank you for finding this! For the wikipedia article on orthogonal vectors, I'll gladly look more into this from here. I myself need to get as accurate of a calculation as I can get for divergence so that I can use it to solve for other important dynamical features like velocity potential. Unless there is anything else you wanted to add, we can close it here. Thank you for your help! |
We can close I think. I'll say that our goal is to have as accurate a calculation as we can reliably do here, which is why the momentous amount of work that was discussed in #893 was something we embarked on. If you find there to be any errors or shortcomings in the current implementation, please do let us know. Regarding the docs, since you're in the best place to know what you'd like to see, we'd be happy to see a PR adding additional information. We're always happy to have submissions and contributions from the community. |
What can be better?
The del operator is actually quite a fickle and annoying thing when moving between coordinate schemes it isn't just as simple as converting x and y distances to degrees/radians (which I'm suspecting might be the case), so the user being aware that this is known and accounted for in different coordinate schemes would be great for ease of mind for a user trying to verify the results.
Additionally, the formula using the finite differentiation would be a good addition to include for this and all different formulations because the documentation for Bowens 2005 is set to limited access, which also makes it difficult for users to verify the results for themselves. Either that or have the documentation all link back to the first_derivative and other differentiation functions used in the calc library and adding the finite differentiation formulae there, so we can see exactly how they work. Thank you!
The text was updated successfully, but these errors were encountered: