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

LCL unpacked representation #619

Closed
jrleeman opened this issue Nov 20, 2017 · 0 comments
Closed

LCL unpacked representation #619

jrleeman opened this issue Nov 20, 2017 · 0 comments
Labels
Area: Units Pertains to unit information Type: Bug Something is not working like it should
Milestone

Comments

@jrleeman
Copy link
Contributor

Interesting behavior found when making a MetPy Monday. Unpacking the LCL values then printing them throws an error (but prints) while LFC does not.

from datetime import datetime
from siphon.simplewebservice.wyoming import WyomingUpperAir

df = WyomingUpperAir.request_data(datetime(2012, 4, 14, 12), 'OUN')

from metpy.units import units
p = df['pressure'].values * units(df.units['pressure'])
T = df['temperature'].values * units(df.units['temperature'])
Td = df['dewpoint'].values * units(df.units['dewpoint'])

import metpy.calc as mpcalc

lfc_pressure, lfc_temperature = mpcalc.lfc(p, T, Td)
lcl_pressure, lcl_temperature = mpcalc.lcl(p[0], T[0], Td[0])

lfc_pressure
907.416511244143 hectopascal
lcl_pressure
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/miniconda3/envs/metpydev/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
    343             method = get_real_method(obj, self.print_method)
    344             if method is not None:
--> 345                 return method()
    346             return None
    347         else:

~/miniconda3/envs/metpydev/lib/python3.6/site-packages/pint/quantity.py in _repr_html_(self)
    213     # IPython related code
    214     def _repr_html_(self):
--> 215         return self.__format__('H')
    216 
    217     def _repr_latex_(self):

~/miniconda3/envs/metpydev/lib/python3.6/site-packages/pint/quantity.py in __format__(self, spec)
    177                 # this is required to have the magnitude and unit in the same line
    178                 allf = r'\[{0} {1}\]'
--> 179                 parts = ndarray_to_latex_parts(obj.magnitude, mspec)
    180 
    181                 if len(parts) > 1:

~/miniconda3/envs/metpydev/lib/python3.6/site-packages/pint/formatting.py in ndarray_to_latex_parts(ndarr, fmtfun, dim)
    304                 ret += [header % elno + ' = ' + matrix_to_latex(el, fmtfun)]
    305         else:
--> 306             for elno, el in enumerate(ndarr):
    307                 ret += ndarray_to_latex_parts(el, fmtfun, dim + (elno, ))
    308 

TypeError: iteration over a 0-d array

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/miniconda3/envs/metpydev/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
    343             method = get_real_method(obj, self.print_method)
    344             if method is not None:
--> 345                 return method()
    346             return None
    347         else:

~/miniconda3/envs/metpydev/lib/python3.6/site-packages/pint/quantity.py in _repr_latex_(self)
    216 
    217     def _repr_latex_(self):
--> 218         return "$" + self.__format__('L') + "$"
    219 
    220     @property

~/miniconda3/envs/metpydev/lib/python3.6/site-packages/pint/quantity.py in __format__(self, spec)
    173         if isinstance(self.magnitude, ndarray):
    174             if 'L' in spec:
--> 175                 mstr = ndarray_to_latex(obj.magnitude, mspec)
    176             elif 'H' in spec:
    177                 # this is required to have the magnitude and unit in the same line

~/miniconda3/envs/metpydev/lib/python3.6/site-packages/pint/formatting.py in ndarray_to_latex(ndarr, fmtfun, dim)
    311 
    312 def ndarray_to_latex(ndarr, fmtfun=lambda x: format(x, '.2f'), dim=()):
--> 313         return '\n'.join(ndarray_to_latex_parts(ndarr, fmtfun, dim))

~/miniconda3/envs/metpydev/lib/python3.6/site-packages/pint/formatting.py in ndarray_to_latex_parts(ndarr, fmtfun, dim)
    304                 ret += [header % elno + ' = ' + matrix_to_latex(el, fmtfun)]
    305         else:
--> 306             for elno, el in enumerate(ndarr):
    307                 ret += ndarray_to_latex_parts(el, fmtfun, dim + (elno, ))
    308 

TypeError: iteration over a 0-d array

Out[27]:
<Quantity(929.7098864382868, 'hectopascal')>
@dopplershift dopplershift added Area: Units Pertains to unit information Type: Bug Something is not working like it should labels Nov 29, 2017
@jrleeman jrleeman added this to the 0.7 milestone Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Units Pertains to unit information Type: Bug Something is not working like it should
Projects
None yet
Development

No branches or pull requests

2 participants