Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
region-estimators
Make estimations for geographic regions, based on actual data (e.g. from sensors)
Readme
region-estimators is a Python library to calculate regional estimations of scalar quantities, based on some known scalar quantities at specific locations. For example, estimating the NO2 (pollution) level of a postcode/zip region, based on site data nearby. This first version of the package is initialised with 2 estimation methods:
The sections below are:
The region_estimators
directory contains the python modules used by the tools.
The sample_input_files
directory contains examples of the input files required to test installation.
Operational scripts are stored within the scripts
directory.
A set of python unittest test files can be found in the test
directory.
.
├── region_estimators
├── sample_input_files
├── scripts
│ └── outputs
├── test
Use the package manager pip to install region-estimators.
pip install shapely
pip install pandas
pip install geopandas
pip install region-estimators
An example python script that uses the region-estimators package can be found in the scripts
directory.
The required parts are highlighted in the following shortened excerpt:
from shapely import wkt
import pandas as pd
from region_estimators import RegionEstimatorFactory, EstimationData
if __name__ == '__main__':
# obtain inputs arguments
#... [See scripts for obtaining via commandline arguments (argparse)]
# Prepare input files (For sample input files, see the 'sample_input_files' folder)
df_regions = pd.read_csv(regions_filespec, index_col='region_id')
df_sites = pd.read_csv(sites_filespec, index_col='site_id')
df_actuals = pd.read_csv(actuals_filespec)
# Convert the regions geometry column from string to wkt format using wkt
df_regions['geometry'] = df_regions.apply(lambda row: wkt.loads(row.geometry), axis=1)
# Create estimator, the first parameter is the estimation method.
estimation_data = EstimationData(df_sites, df_regions, df_actuals)
estimator = RegionEstimatorFactory.region_estimator(method, estimation_data, verbose, max_processors)
# Make estimations
if method == 'concentric-regions':
estimator.max_ring_count = max_rings
df_estimates = estimator.get_estimations(measurement, region_id, timestamp)
print(df_estimates)
# Convert dataframe result to (for example) a csv file:
if args.save_to_csv:
df_estimates.to_csv(os.path.join(outdir_name, 'estimates_{}.csv'.format(outfile_suffix)))
├── Constructor
│ ├── 3 pandas.Dataframe objects:
│ │ └── regions (metadata)
│ │ │ └── required columns
│ │ │ │ └── 'region_id' (INDEX): identifier for region (must be unique to each region)
│ │ │ │ └── 'geometry' (shapely.wkt/geom.wkt): Multi-polygon representing regions location and shape.
│ │ └── sites (metadata)
│ │ │ └── required columns
│ │ │ │ └── 'site_id' (INDEX): identifier for site (must be unique to each site)
│ │ │ │ └── 'latitude' (numeric): latitude of site location
│ │ │ │ └── 'longitude' (numeric): longitude of site location
│ │ │ └── optional columns
│ │ │ │ └── 'name' (string): Human readable name of site
│ │ └── actuals (data)
│ │ │ └── required columns
│ │ │ │ └── 'timestamp' (string): timestamp of actual reading
│ │ │ │ └── 'site_id': (string) ID of site which took actua in sites (in value and type))
│ │ │ │ └── [one or more value columns] (float): value of actual measurement readings.
├── Returns
│ ├── Initialised instance of EstimationData class
├── Required inputs
│ ├── method_name (string): The estimation method to be uesed
In the first version the options are 'concentric-regions' or 'distance-simple'
│ ├── estimation_data (EstimationData instance - see above): data required to make estimations
├── Optional inputs
│ ├── verbose: (int) Verbosity of output level. zero or less => No debug output. Default=0
│ ├── max_processors (int) Maximum number of processors to use. Default=1
│ (Maximum: Number of processor available)
├── Returns
│ ├── Initialised instance of subclass of RegionEstimator class
├── Required inputs
│ ├── measurement: which measurement to be estimated (e.g. 'urtica')
├── Optional inputs
│ ├── region_id: region identifier (string (or None to get all regions))
│ ├── timestamp: timestamp identifier (string (or None to get all timestamps))
│ ├── ignore_site_ids: (list of str) Site IDs to be ignored. Default=[]
├── Returns
│ ├── pandas dataframe, with columns:
│ │ └── measurement
│ │ └── region_id
│ │ └── timestamp
│ │ └── value: (float or empty) The estimated value
│ │ └── extra_data: (dict string) Extra info about the estimation calculation
WARNING! - estimator.get_estimates('urtica', None, None) will calculate every region at every timestamp.
A set of python unittest test files can be found in the test
directory, and can be run from the shell
(once the necessary requirements are installed) with the command:
python -m unittest
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
with further method classes:
available_methods = {'concentric-regions': ConcentricRegionsEstimator,
'distance-simple': DistanceSimpleEstimator}
This software has been developed by the Research IT group at the University of Manchester for an Alan Turing Institute project.
(c) 2019-2021 University of Manchester. Licensed under the MIT license (https://opensource.org/licenses/MIT)
FAQs
Make estimations for geographic regions, based on actual data (e.g. from sensors)
We found that region-estimators demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.