Unit label for Particulate Matter

54 views
Skip to first unread message

Paul McGeorge

unread,
Jan 18, 2020, 1:04:40 PM1/18/20
to weewx-user
I recently purchased an ECOWITT GW1000 along with an Ambient WS-2000, using Matts Interceptor driver I have gotten everything working including the Air quality Sensor.  I added the pm2_5 to the database schema and have the data archiving. 

My next step was to add a Group and Data label for the data.  I tried the code below but the last line causes weewx to fail on startup, the issue seems to be the chararters for micro (µ) and the superscript (³).  I feel like there must be a way to escape these characters and get them to work but I can't figure out this last step...  I was able to get it working by just using ug/m3, but i'd really like to see the µg/m³ instead.  Any ideas?

import weewx.units
weewx
.units.obs_group_dict['pm2_5'] = 'group_concentration'

weewx
.units.MetricUnits['group_concentration'] = 'microgram_per_meter_cubed'
weewx
.units.MetricWXUnits['group_concentration'] = 'microgram_per_meter_cubed'
weewx
.units.USUnits['group_concentration'] = 'microgram_per_meter_cubed'

weewx
.units.default_unit_format_dict['microgram_per_meter_cubed'] = '%.3f'
weewx
.units.default_unit_label_dict['microgram_per_meter_cubed'] = ' µg/m³'

Paul

John Kline

unread,
Jan 18, 2020, 1:36:56 PM1/18/20
to weewx...@googlegroups.com
If you are using Python 2, it could be blowing up for this reason:

SyntaxError: Non-ASCII character '\xc2' in file ./foo.py on line 13, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Try adding the following line to the top of the file:

# coding: utf-8

On Jan 18, 2020, at 10:04 AM, Paul McGeorge <pmcg...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/5c5b4f24-44cd-46f6-9948-041259c16f56%40googlegroups.com.

gjr80

unread,
Jan 18, 2020, 3:29:48 PM1/18/20
to weewx-user
Hi,

Try:

weewx.units.default_unit_label_dict['microgram_per_meter_cubed'] = ' \xc2\xb5g/m\xc2\xb3’

Gary

Paul McGeorge

unread,
Jan 18, 2020, 5:23:00 PM1/18/20
to weewx-user

Thanks John and Gary!  Both solutions work great and now I've learned something about UTF-8 encoding.


Paul
Reply all
Reply to author
Forward
0 new messages