Upload weather data to Citizen Weather Observer Program.

The Citizen Weather Observer Program (CWOP) is a north American public-private partnership to gather weather data. This module uploads data to it from pywws. You can upload “logged” or “live” data (or both). The module ensures there is at least 5 minutes between each reading as required by the API.

Note that the latitude and longitude must be in “LORAN” format and leading zeros are required. See question 3 in the CWOP FAQ for more information.

Licensed radio hams use their callsign as the designator and need a passcode. Other users should leave the passcode at its default value of -1.

The CWOP/APRS uploader is based on code by Marco Trevisan <>.


ToService(context[, check_params])
class pywws.service.cwop.ToService(context, check_params=True)[source]

Bases: pywws.service.LiveDataService

config = {'designator': ('', True, 'designator'), 'latitude': ('', True, 'latitude'), 'longitude': ('', True, 'longitude'), 'passcode': ('-1', True, 'passcode')}
fixed_data = {'version': '19.7.2'}
interval = datetime.timedelta(seconds=290)
logger = <Logger pywws.service.cwop (WARNING)>
service_name = 'cwop'
template = '\n#live#\n\'idx\' : #idx "\'%d%H%M\',"#\n\'wind_dir\' : #wind_dir "\'%03.0f\'," "\'...\'," "winddir_degrees(x)"#\n\'wind_ave\' : #wind_ave "\'%03.0f\'," "\'...\'," "wind_mph(x)"#\n\'wind_gust\' : #wind_gust "\'%03.0f\'," "\'...\'," "wind_mph(x)"#\n\'temp_out\' : #temp_out "\'%03.0f\'," "\'...\'," "temp_f(x)"#\n\'hum_out\' : #hum_out "\'%02d\'," "\'..\'," "x % 100"#\n\'rel_pressure\' : #rel_pressure "\'%05.0f\'," "\'.....\'," "x * 10.0"#\n\'rain_hour\' : #calc "100.0*rain_inch(rain_hour(data))" "\'%03.0f\'," "\'...\',"#\n\'rain_24hr\' : #calc "100.0*rain_inch(rain_24hr(data))" "\'%03.0f\'," "\'...\',"#\n'

Context manager factory function for a batch of one or more uploads.

This makes it easy to ensure any resources such as an internet connection are properly closed after a batch of uploads. Use the contextlib.contextmanager() decorator when you implement this method.

For a typical example, see the source code of the pywws.service.openweathermap module. If your upload can’t benefit from a session object yield None, as in pywws.service.copy.

upload_data(session, prepared_data={})[source]

Upload one data set to the service.

Every data service class must implement this method.

  • session (object) – the object created by session(). This is typically used to communicate with the server and is automatically closed when a batch of uploads has finished.
  • prepared_data (dict) – a set of key: value pairs to upload. The keys and values must all be text strings.

Comments or questions? Please subscribe to the pywws mailing list and let us know.