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

Return input temperature units for LCL/LFC/EL temperature, disallow LFC if EL below LCL #1172

Merged
merged 2 commits into from Sep 26, 2019

Conversation

zbruick
Copy link
Contributor

@zbruick zbruick commented Sep 18, 2019

Description Of Changes

First, allows for return of LCL/LFC/EL temperature in the units of the input temperature. There may still be a bug in SkewT.plot that I need to investigate more, as I don't think things are getting auto-converted to the same units when you plot multiple things.

Second, this disallows a LFC below a LCL when an "EL" is also below the LCL. This bug was causing CAPE to calculate as the LFC was being adjusted to the LCL, and it didn't see an end to the profile (ending up in very large values of negative CAPE).

Checklist

@zbruick zbruick added Area: Calc Pertains to calculations Type: Bug Something is not working like it should labels Sep 20, 2019
@am-thyst
Copy link

these changes have caused the following error when calculating CAPE as mentioned in #1167:

Traceback (most recent call last):
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/sharedmem/sharedmem.py", line 294, in _slaveMain
    self.main(self, *self.args)
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/sharedmem/sharedmem.py", line 628, in _main
    r = realfunc(work)
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/sharedmem/sharedmem.py", line 703, in realfunc
    else: return func(i)
  File "/var/spool/torque/mom_priv/jobs/255664.rdf-xcat.SC", line 69, in cape_func
    cape, cin = most_unstable_cape_cin(vl_lst, prof_t, prof_td) # muCAPE calculation
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/metpy/xarray.py", line 487, in wrapper
    return func(*args, **kwargs)
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/metpy/units.py", line 312, in wrapper
    return func(*args, **kwargs)
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/metpy/calc/thermo.py", line 1797, in most_unstable_cape_cin
    return cape_cin(p, t, td, mu_profile)
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/metpy/xarray.py", line 487, in wrapper
    return func(*args, **kwargs)
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/metpy/units.py", line 312, in wrapper
    return func(*args, **kwargs)
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/metpy/calc/thermo.py", line 1431, in cape_cin
    parcel_temperature_profile=parcel_profile)
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/metpy/xarray.py", line 487, in wrapper
    return func(*args, **kwargs)
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/metpy/units.py", line 312, in wrapper
    return func(*args, **kwargs)
  File "/nerc/n02/n02/amethyst/minic/envs/newenv/lib/python3.6/site-packages/metpy/calc/thermo.py", line 451, in lfc
    if el_pres > this_lcl[0]:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"

@zbruick
Copy link
Contributor Author

zbruick commented Sep 23, 2019

Ah, thanks for checking that. I'll go back and fix the code to only check one value there.

Copy link
Member

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. LFC logic is getting a bit unwieldy, but at least we have a good test suite for some day refactoring it.

Ignoring Code Climate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Calc Pertains to calculations Type: Bug Something is not working like it should
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LCL/LFC/EL temperature always returns Celsius most_unstable_cape_cin throwing negative CAPE values
3 participants