Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #48 from ReagentX/develop
Browse files Browse the repository at this point in the history
Release/1.1.2
  • Loading branch information
ReagentX authored Sep 18, 2020
2 parents c6ee87a + 679fbfb commit d996281
Show file tree
Hide file tree
Showing 12 changed files with 485 additions and 221 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ cache.sqlite
# Dev env
venv/*
.vscode/*

# Coverage generated files
.coverage
.coveragerc
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Purple Air API

A Python 3.x API Class to turn data from the PurpleAir/ThingSpeak API into a Pandas DataFrame with several utility methods.
A Python 3.x module to turn data from the PurpleAir/ThingSpeak API into a Pandas DataFrame safely, with many utility methods.

![Global Sensor Map with Celsius Scale](maps/sensor_map.png)

Expand Down Expand Up @@ -39,7 +39,7 @@ print(len(p.useful_sensors)) # 10047, List of sensors with no defects

```python
from purpleair.sensor import Sensor
s = Sensor('2890', parse_location=True)
s = Sensor(2890, parse_location=True)
print(s) # Sensor 2891 at 10834, Canyon Road, Omaha, Douglas County, Nebraska, 68112, USA
```

Expand Down Expand Up @@ -67,7 +67,7 @@ id

```python
from purpleair.sensor import Sensor
se = Sensor('2890')
se = Sensor(2890)
df = se.parent.get_historical(weeks_to_get=1,
thingspeak_field='secondary')
print(df.head())
Expand All @@ -89,9 +89,9 @@ entry_id

```python
from purpleair.sensor import Sensor
se = Sensor('2890')
se = Sensor(2890)
df = se.child.get_historical(weeks_to_get=1,
thingspeak_field='secondary')
thingspeak_field='secondary')
print(df.head())
```

Expand Down
151 changes: 105 additions & 46 deletions docs/api/sensor_methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ Return a dictionary representation of a sensor. The data is shaped like this:
{
'parent': {
'meta': {
'id': identifier,
'id': a.identifier,
'parent': None,
'lat': a.lat,
'lon': a.lon,
'name': a.name,
Expand All @@ -129,16 +130,35 @@ Return a dictionary representation of a sensor. The data is shaped like this:
'temp_f': a.current_temp_f,
'temp_c': a.current_temp_c,
'humidity': a.current_humidity,
'pressure': a.current_pressure
'pressure': a.current_pressure,
'p_0_3_um': a.current_p_0_3_um,
'p_0_5_um': a.current_p_0_5_um,
'p_1_0_um': a.current_p_1_0_um,
'p_2_5_um': a.current_p_2_5_um,
'p_5_0_um': a.current_p_5_0_um,
'p_10_0_um': a.current_p_10_0_um,
'pm1_0_cf_1': a.current_pm1_0_cf_1,
'pm2_5_cf_1': a.current_pm2_5_cf_1,
'pm10_0_cf_1': a.current_pm10_0_cf_1,
'pm1_0_atm': a.current_pm1_0_atm,
'pm2_5_atm': a.current_pm2_5_atm,
'pm10_0_atm': a.current_pm10_0_atm
},
'diagnostic': {
'last_seen': a.last_seen,
'model': a.model,
'hidden': a.hidden,
'flagged': a.flagged,
'downgraded': a.downgraded,
'age': a.age
}
'age': a.age,
'brightness': a.brightness,
'hardware': a.hardware,
'version': a.version,
'last_update_check': a.last_update_check,
'created': a.created,
'uptime': a.uptime,
'is_owner': a.is_owner
},
'statistics': {
'10min_avg': a.m10avg,
'30min_avg': a.m30avg,
Expand All @@ -149,33 +169,53 @@ Return a dictionary representation of a sensor. The data is shaped like this:
},
'child':{
'meta': {
'id': identifier,
'lat': b.lat,
'lon': b.lon,
'name': b.name,
'location_type': b.location_type,
'id': a.identifier,
'parent': None,
'lat': a.lat,
'lon': a.lon,
'name': a.name,
'location_type': a.location_type
},
'data': {
'pm_2.5': b.current_pm2_5,
'temp_f': b.current_temp_f,
'temp_c': b.current_temp_c,
'humidity': b.current_humidity,
'pressure': b.current_pressure,
'pm_2.5': a.current_pm2_5,
'temp_f': a.current_temp_f,
'temp_c': a.current_temp_c,
'humidity': a.current_humidity,
'pressure': a.current_pressure,
'p_0_3_um': a.current_p_0_3_um,
'p_0_5_um': a.current_p_0_5_um,
'p_1_0_um': a.current_p_1_0_um,
'p_2_5_um': a.current_p_2_5_um,
'p_5_0_um': a.current_p_5_0_um,
'p_10_0_um': a.current_p_10_0_um,
'pm1_0_cf_1': a.current_pm1_0_cf_1,
'pm2_5_cf_1': a.current_pm2_5_cf_1,
'pm10_0_cf_1': a.current_pm10_0_cf_1,
'pm1_0_atm': a.current_pm1_0_atm,
'pm2_5_atm': a.current_pm2_5_atm,
'pm10_0_atm': a.current_pm10_0_atm
},
'diagnostic': {
'last_seen': b.last_seen,
'model': b.model,
'hidden': b.hidden,
'flagged': b.flagged,
'downgraded': b.downgraded,
'age': b.age
}
'last_seen': a.last_seen,
'model': a.model,
'hidden': a.hidden,
'flagged': a.flagged,
'downgraded': a.downgraded,
'age': a.age,
'brightness': a.brightness,
'hardware': a.hardware,
'version': a.version,
'last_update_check': a.last_update_check,
'created': a.created,
'uptime': a.uptime,
'is_owner': a.is_owner
},
'statistics': {
'10min_avg': b.m10avg,
'30min_avg': b.m30avg,
'1hour_avg': b.h1ravg,
'6hour_avg': b.h6ravg,
'1week_avg': b.w1avg
'10min_avg': a.m10avg,
'30min_avg': a.m30avg,
'1hour_avg': a.h1ravg,
'6hour_avg': a.h6ravg,
'1week_avg': a.w1avg
}
}
}
Expand All @@ -191,26 +231,45 @@ The data is shaped like this:

```python
{
'id': 14633,
'lat': 37.275561,
'lon': -121.964134,
'name': 'Hazelwood canary',
'location_type': 'outside',
'pm_2.5': 92.25,
'temp_f': 73.0,
'temp_c': 22.77777777777778,
'humidity': 0.53,
'pressure': '1007.15',
'last_seen': datetime.datetime(2020, 9, 13, 15, 16, 52),
'model': 'PMS5003+PMS5003+BME280',
'hidden': False,
'flagged': False,
'downgraded': False,
'parent': 0,
'lat': 0,
'lon': 0,
'name': 0,
'location_type': 0,
'pm_2.5': 0,
'temp_f': 0,
'temp_c': 0,
'humidity': 0,
'pressure': 0,
'p_0_3_um': 0,
'p_0_5_um': 0,
'p_1_0_um': 0,
'p_2_5_um': 0,
'p_5_0_um': 0,
'p_10_0_um': 0,
'pm1_0_cf_1': 0,
'pm2_5_cf_1': 0,
'pm10_0_cf_1': 0,
'pm1_0_atm': 0,
'pm2_5_atm': 0,
'pm10_0_atm': 0,
'last_seen': 0,
'model': 0,
'hidden': 0,
'flagged': 0,
'downgraded': 0,
'age': 0,
'10min_avg': 93.13,
'30min_avg': 93.67,
'1hour_avg': 93.93,
'6hour_avg': 98.92,
'1week_avg': 41.49
'brightness': 0,
'hardware': 0,
'version': 0,
'last_update_check': 0,
'created': 0,
'uptime': 0,
'is_owner': 0,
'10min_avg': 0,
'30min_avg': 0,
'1hour_avg': 0,
'6hour_avg': 0,
'1week_avg': 0
}
```
38 changes: 38 additions & 0 deletions docs/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,30 @@ Representation of a sensor channel, either `a` or `b`. For channel `b` (child) s
* Current humidity expressed as decimal (i.e., 0.1 = 10%)
* `current_pressure`
* Current atmospheric pressure
* `p_0_3_um`
* Current pm0.3 / um
* `p_0_5_um`
* Current pm0.5 / um
* `p_1_0_um`
* Current pm1.0 / um
* `p_2_5_um`
* Current pm2.5 / um
* `p_5_0_um`
* Current pm5.0 / um
* `p_10_0_um`
* Current pm10.0 / um
* `pm1_0_cf_1`
* Current pm1.0 / um secondary reading
* `pm2_5_cf_1`
* Current pm2.5 / um secondary reading
* `pm10_0_cf_1`
* Current pm10.0 / um secondary reading
* `pm1_0_atm`
* Current pm1.0 / atm
* `pm2_5_atm`
* Current pm2.5 / atm
* `pm10_0_atm`
* Current pm10.0 / atm
* `m10avg`
* Average pm2.5 value for the most recent 10 minutes
* `m30avg`
Expand Down Expand Up @@ -132,5 +156,19 @@ Representation of a sensor channel, either `a` or `b`. For channel `b` (child) s
* Whether a sensor has previously been flagged for bad data
* `age`
* Number of minutes old the data returned by the sensor is
* `brightness`
* Ambient brightness
* `hardware`
* Hardware model IDs
* `version`
* Software version
* `last_update_check`
* Last software update check
* `created`
* Date first seen
* `uptime`
* Time since boot in seconds
* `is_owner`
* Unknown

See [api/channel_methods.md](api/channel_methods.md) for method documentation.
Binary file modified maps/sensor_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d996281

Please sign in to comment.