Skip to content

Object-based interface to sounding diagnostics #2925

@sgdecker

Description

@sgdecker

What should we add?

I wasn't sure if the overloading proposed below was Pythonic, but I see xarray does it frequently (e.g. date_range).

Here's my specification:

  1. All existing code works as is (i.e., no tests break)
  2. Code like the following does not produce errors, but generates the results described:
# Set up code omitted

results = mpcalc.parcel_profile(p, T, Td)
# Equivalent to:
results = mpcalc.parcel_profile(p, T[0], Td[0])

results = mpcalc.parcel_profile(p, T, Td, with_lcl=True)
# Equivalent to:
results = mpcalc.parcel_profile_with_lcl(p, T, Td)

results = mpcalc.parcel_profile(p, T, Td, with_lcl=True, as_dataset=True)
# Equivalent to:
results = mpcalc.parcel_profile_with_lcl_as_dataset(p, T, Td)

results = mpcalc.parcel_profile(p, T, Td, as_dataset=True)
# No equivalent, but akin to previous example with LCL omitted
  1. An additional optional argument start_index is allowed. It defaults to 0, but allows the user to lift a parcel not at the first index. (It is an error to specify anything other than 0 if the input temperature and dewpoint profiles are not arrays as in the current implementation on parcel_profile.) Not an error, but means to generate the profile with the given temperature and dewpoint, but starting at pressure[start_index]. The general rule is the returned array(s) contain(s) np.nans at the levels below the starting point.

  2. An additional optional argument start_pressure is allowed. It defaults to pressure[0], but allows the user to lift the parcel at pressure start_pressure. (The showalter_index implements a special case of this functionality.) An error is raised if start_pressure is not in the interval [min(pressure), max(pressure)]. It is an error to specify both start_pressure and start_index.

  3. (Bonus) The restriction that the array(s) are in order of decreasing order of pressure is relaxed to a restriction that the array(s) are monotonic with respect to pressure. If the inputs are in increasing order, the default start_index is -1, and the default start_pressure is pressure[-1].

Reference

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions