-
Couldn't load subscription status.
- Fork 10
Adds a mixed layer depth diagnostic #182
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
Conversation
|
Nice! I'm okay with the name, although I think it should be density criterion, and not criteria (single it's one, singular, criterion, no?). Another alternative is to create an object called Also, I see you're using a |
|
(Also github asked for explicit approval to run the tests and docs. I have no idea why, but we should figure out how to disable that!) |
Ah yes you are right, I have changed now.
I've done this now, I'm not sure which is better but you can have a look and I can roll back the commit if you prefer the first way.
This is a good question, it seems to work for 2D objects by specifying a nothing location like |
I think this is the default behaviour for first-time contributors to a repo incase the CI has some kind of cost associated with it |
|
@jagoosw Sorry, I realize I didn't check this PR after your latest pushes. Conflicts aside (I can resolve them for you), is this PR close/ready to merge? |
|
No problem, I forgot all about this too! I think its all ready if you're happy with it apart from the conflicts |
Nice! Good to hear. I'll work on the conflicts today and take a closer look. If all is good, I'll approve and then you're free to merge. I invited you to become a collaborator here if you want, that way you can merge your own PRs. |
|
Ah, I just realized you're using your own fork to implement this so I can't modify it! I think all you need to do is to move the test from |
|
@jagoosw if you'd like me to fix things you can make me a collaborator on your fork I guess? Not sure if there's a better way since this PR is already created based on it. |
|
I'll add you to my fork and try and clean these suggestions up |
|
You should not use a density criteria as it is not general. A buoyancy criteria is better. |
|
The way I understand the code, different criteria can be plugged into MixedLayerDepth, no? Having a density criterion doesn't preclude having a buoyancy criterion. That said, can you elaborate why density criteria are less general than buoyancy criteria? |
Gravitational forces enters a Boussinesq model via buoyancy. One can simulate buoyancy directly, leading to the formation of "mixed layers". But density is not defined in such a model, so density-based criteria cannot be used. More generally, often mixed layer depth criterion actually use some potential density rather than in-situ density, because they do not want to incorporate the dynamically irrelevant part of density due to compressibility. Using buoyancy is simpler and avoids those issues; by design, the buoyancy field can be computed from any model that has gravitational forces. It's nice to have different criteria but I would discourage developing any criteria other than ones based on the buoyancy profile. |
|
@jagoosw I moved the test to its proper place, but it's failing with some version of Can you please take a look? |
|
I've added a buoyancy criterion now, and it makes sense that we should prefer that since it will work in all models, whereas the density one only worked with The test also passes locally for me now, but I have no idea what made it work again. I added a test for the buoyancy criterion and made it the default also. I think it would be nice to keep the density criterion for comparison to observational work but am not attached to the idea. |
src/FlowDiagnostics.jl
Outdated
| struct DensityAnomalyCriterion{FT} <: AbstractAnomalyCriterion | ||
| pertubation :: FT | ||
| end |
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.
The density anomaly can be expressed in terms of a buoyancy anomaly, where you require additional information about 1) the gravitational acceleration used in the model and 2) the reference density. For example:
struct DensityAnomalyCriterion
buoyancy_anomaly
reference_density
gravitational_acceleration
endYou can then build a constructor that uses some default values for the parameters.
This will help users understand how the parameters they are using affect their results leading to higher-quality science.
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.
I like this more
src/FlowDiagnostics.jl
Outdated
| specifies a constant salinity or temperature). | ||
| """ | ||
| @kwdef struct BuoyancyAnomalyCriterion{FT} <: AbstractAnomalyCriterion | ||
| pertubation :: FT = - 1/8 * 1020 / g_Earth |
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.
| pertubation :: FT = - 1/8 * 1020 / g_Earth | |
| anomaly :: FT = - 1/8 * 1020 / g_Earth |
It seems like the errors are still there! I wonder why you can't reproduce these errors locally. |
|
hmm when I run the whole file it does fail too now, it looks like its the stretched grid cases, I will investigate now |
|
Ah its because the stretched grid doesn't have z=0 at the top |
|
I like the science part here. However, I'm a little confused by the implementation. Oceanostics.jl/src/FlowDiagnostics.jl Lines 467 to 473 in f9ac0e1
Which actually returns a If so, that feels a bit confusing/convoluted to me. Is there a way to make this more straightforward? @glwagner I think this overlaps with our discussion in #194, so maybe some points are still not connecting in my head... |
Hi @tomchor,
This PR adds a simple mixed layer depth diagnostic using a simple density anomaly criteria.
I don't think there is a convenient way to generally write a mixed layer depth computation, so I have called it
DensityCriteriaMixedLayerDepth.