pywind.decc

Note

Following the July 2016 announcements of changes in the organisation of government departments, the future of the DECC website is uncertain. While the data provided is likely still be available the module may need adjusting to continue functioning.

pywind.decc.Report

The DECC publish monthly extracts of planning applications for renewable projects. This module aims to make accessing this report simpler.

https://www.gov.uk/government/publications/renewable-energy-planning-database-monthly-extract

class pywind.decc.extract.DeccRecord(app_info)[source]

Bases: object

Simple class to hold details of one DECC station.

BOOLEAN_FIELDS = ('chp_enabled', 'green_belt', 'national_park', 'aonb', 'heritage_coast', 'special_landscape_area', 'employment_use', 'natural_environment', 'other_land_use', 'built_heritage__archaeology', 'project_specific', 'chp')
DATE_FIELDS = ('record_last_updated_dd_mm_yyyy', 'planning_application_submitted', 'planning_application_withdrawn', 'planning_permission_refused', 'appeal_lodged', 'appeal_withdrawn', 'appeal_refused', 'appeal_granted', 'planning_permission_granted', 'planning_permission_granted', 'record_last_updated_dd_mm_yyyy', 'secretary_of_state___intervened', 'secretary_of_state___refusal', 'secretary_of_state___granted', 'planning_permission_expired', 'under_construction', 'operational')
FLOAT_FIELDS = ('installed_capacity_mwelec', 'ro_banding_roc_mwh', 'fit_tariff_p_kwh', 'cfd_capacity_mw', 'turbine_capacity_mw', 'height_of_turbines_m')
INT_FIELDS = ('ref_id', 'no._of_turbines', 'x-coordinate', 'y-coordinate')
fit_rate_mwh()[source]

Convert the FIT Tariff rate into GBP per MWh.

Return type:float
class pywind.decc.extract.MonthlyExtract(filename=None)[source]

Bases: object

The MonthlyExtract class allows the current monthly data to be easily retrieved and parsed.

Note

The CSV data returned does not declare an encoding, so latin1 is presently assumed.

BASE_URL = 'https://www.gov.uk'
URL = 'https://www.gov.uk/government/publications/renewable-energy-planning-database-monthly-extract'
get_data()[source]

Get the data from the DECC server and parse it into DECC records.

Returns:True or False
Return type:bool
rows()[source]

Generator that returns records

Returns:Dict of planning application information
Return type:dict
save_original(filename)[source]

Save the downloaded certificate data into the filename provided.

Parameters:filename – Filename to save the file to.
Returns:True or False
Return type:bool

pywind.decc.geo

The Ordnane Survey publishes a comprehensive document on their co-ordinate systems which is available at

https://www.ordnancesurvey.co.uk/docs/support/guide-coordinate-systems-great-britain.pdf

The conversion routines used in the Coord class are from blog posts by Hannah Fry and remain her copyright.

class pywind.decc.geo.Coord(e_or_lat, n_or_lon)[source]

Bases: object

Each instance of the Coord class represents a single co-ordinate, which can be craeted using either WGS84 or OSGB36. Conversions between the 2 systems are done as needed on demand.

__init__(e_or_lat, n_or_lon)[source]

Create the object with the initial point. Values should be supplied as float values, but integers can also be used. Providing anything else will result in a ValueError exception.

Parameters:
  • e_or_lat – Either the Easting or Latitude.
  • n_or_lon – Either the Northing or Longitude
Raises:

ValueError

as_osgb36(precision=None)[source]

Return the co-ordinate as OSGB36 Easting, Northing pair.

Parameters:precision – The number of decimal places to return. Defaults to 3.
Return type:float, float
as_wgs84(precision=None)[source]

Return the co-ordinate as WGS84 latitude, longitude pair.

Parameters:precision – The number of decimal places to return. Defaults to 4.
Return type:float, float

pywind.decc.utils

pywind.decc.utils.decimal_to_degrees(num, seps=None)[source]

Given a float value and an optional set of seperators, return a formatted string.

If the seperator has a precision value required that differs from the default of 2, then it should be prefixed with a colon, e.g. 3:$ would give a seperator of a $ character after a 3 digit number.

Parameters:
  • num – The float value to parse
  • seps – An optional list of seperators to use.
pywind.decc.utils.latlon_as_string(lat, lon)[source]

Given a numeric lat/lon, convert into “pretty strings”.

Parameters:
  • lat – Latitude
  • lon – Longitude
Return type:

str