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

delta_pressure clarification question #635

Open
kafitzgerald opened this issue Jul 30, 2024 · 3 comments
Open

delta_pressure clarification question #635

kafitzgerald opened this issue Jul 30, 2024 · 3 comments
Assignees
Labels
support Support request opened by outside user/collaborator

Comments

@kafitzgerald
Copy link
Contributor

kafitzgerald commented Jul 30, 2024

Hello I am confuse, does computing thickness between two pressure level here based on hypsometric equation or its jjust simple difference between two pressure level. As in the shared result above , the 3rd value why it is 2500 if its the difference between 85000-80000, similarly for the 16th value why its 3750 and so on. Could you kindly please clarify this. I am completely confuse.

Originally posted by @bnepal22 in #538 (comment)

@anissa111 anissa111 added the support Support request opened by outside user/collaborator label Jul 30, 2024
@kafitzgerald kafitzgerald self-assigned this Jul 30, 2024
@kafitzgerald
Copy link
Contributor Author

Hi @bnepal22, thanks for your question!

I went ahead and moved your comment to a new issue. For new clarification and usage questions about geocat-comp functions we recommend starting a discussion post or creating a new issue and linking to any relevant content rather than commenting on an existing one. For the most part you shouldn't need to worry about mentioning "@" people either unless there's a particular person you'd like to notify.

As for your question about delta_pressure, you can find a bit more detailed information in the NCL documentation of the function this replicates. It's computing the thickness (roughly a simple difference) with some exceptions for handling the top of the atmosphere and the surface. Let me know if you need further clarification on this.

This is probably something we could make a bit more clear in the documentation.

@bnepal22
Copy link

I'm sorry for not getting back to you sooner. Further clarification would be appreciated.

@kafitzgerald
Copy link
Contributor Author

Sure, let us know if there's anything in particular that would be helpful.

You can see here how delta_pressure is calculated in geocat-comp. It's just altering the calculations to use a specified top and surface pressure.

def _delta_pressure1D(pressure_lev, surface_pressure):
"""Helper function for `delta_pressure`. Calculates the pressure layer
thickness (delta pressure) of a one-dimensional pressure level array.
Returns an array of length matching `pressure_lev`.
Parameters
----------
pressure_lev : :class:`numpy.ndarray`
The pressure level array. May be in ascending or descending order.
Must have the same units as `surface_pressure`.
surface_pressure : :class:`float`
The scalar surface pressure. Must have the same units as
`pressure_lev`.
Returns
-------
delta_pressure : :class:`numpy.ndarray`
The pressure layer thickness array. Shares dimensions and units of
`pressure_lev`.
"""
# Leaving this here to lay groundwork for including it as a separate argument
pressure_top = min(pressure_lev)
# Safety checks
if pressure_top < 0:
raise ValueError(
"`pressure_lev` values must all be greater than or equal to 0.")
if pressure_top > surface_pressure:
raise ValueError(
"`surface_pressure` must be greater than minimum `pressure_lev` value."
)
# Sort so pressure increases (array goes from top of atmosphere to bottom)
is_pressuredecreasing = pressure_lev[1] < pressure_lev[0]
if is_pressuredecreasing:
pressure_lev = np.flip(pressure_lev)
# Calculate delta pressure
delta_pressure = np.full_like(pressure_lev, np.nan)
[indices] = np.nonzero(np.array(pressure_lev) <= surface_pressure)
start_level = min(indices)
end_level = max(indices)
delta_pressure[start_level] = (pressure_lev[start_level] + pressure_lev[
start_level + 1]) / 2 - pressure_top # top level
delta_pressure[start_level + 1:end_level] = [
(a - b) / 2
for a, b in zip(pressure_lev[start_level + 2:end_level +
1], pressure_lev[start_level:end_level])
]
delta_pressure[end_level] = surface_pressure - (
pressure_lev[end_level] +
pressure_lev[end_level - 1]) / 2 # bottom level
# Return delta_pressure to original order
if is_pressuredecreasing:
delta_pressure = np.flip(delta_pressure)
return delta_pressure

We'll work on getting this updated in the documentation so it's more clear and I'll leave this issue open until that's been addressed. It may take a moment to get to this though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Support request opened by outside user/collaborator
Projects
None yet
Development

No branches or pull requests

3 participants