[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[python #DCS-251943]: MetPy time series plots



Greetings!

We appreciate the feedback. We really want that code map to be able to handle 
everything and so I consider it a bug that it fails for that--but I do think 
it's valuable that it fails since that led you to let us know it's broken. :)

Fortunately, you can already get the behavior you're looking for. `wx_code_map` 
is a regular python dictionary, so you can us it's built-in `get` method:

  https://docs.python.org/3/library/stdtypes.html#dict.get

like this:

    wxcode_num = wx_code_map.get(wxcodes.split()[0], 0)

Hope this helps,

Ryan

> One last thing about MetPy . . .
> 
> If a bad weather code is fed to your 'wx_code_map' method, it crashes.
> 
> Traceback (most recent call last):
> File "./ASOS_plot_data_for_archive_hourly_ISU.py", line 437, in <module>
> plot_station_data(date,site,sitetitle,df)
> File "./ASOS_plot_data_for_archive_hourly_ISU.py", line 375, in
> plot_station_data
> wxcode_num = wx_code_map[wxcodes.split()[0]]
> KeyError: '-FZRAGR'
> 
> Might be nice to have a more graceful exit (like returning 0) when that
> happens.


Ticket Details
===================
Ticket ID: DCS-251943
Department: Support Python
Priority: Low
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.