ZoningSystem#

class caf.base.data_structures.ZoningSystem(name, unique_zones, metadata)[source]#

Bases: object

Zoning definitions to provide common interface.

Parameters:
name[source]#

The name of the zoning system. This will be the same as the name in the definitions folder

col_name[source]#

The default naming that should be given to this zoning system if defined to a pandas.DataFrame

unique_zones[source]#

A sorted numpy array of unique zone names for this zoning system.

n_zones[source]#

The number of zones in this zoning system

Attributes

column_name

Expected name of columns in translations or DVectors.

desc_to_id

Return a lookup dict of zone description to zone id.

id_to_desc

Return a lookup dict of zone id to zone description.

id_to_external

Produce lookup to convert id to external.

id_to_internal

Produce lookup to convert id to internal.

id_to_name

Return a lookup dict of zone id to zone name.

name_to_id

Return a lookup dict of zone name to zone id.

subset_columns

Names of subset columns available.

zone_ids

Return a copy of the zone IDs array.

zones_data

Return a copy of the zones DataFrame.

Methods

__init__(name, unique_zones, metadata)

Build a ZoningSystem.

check_all_columns(input_columns)

Check zoning_system columns and return a lookup if appropriate.

copy()

Return a copy of this class.

external()

Getter for external column.

get_inverse_subset(name)

Get inverse of the name subset.

get_subset(name)

Get subset of zone IDs based on subset column name.

get_zoning(name[, search_dir])

Call load method to return zoning info based on a name.

internal()

Getter for internal column.

load(in_path, mode)

Create a ZoningSystem instance from path_or_instance_dict.

old_to_new_zoning(old_dir[, new_dir, mode])

Convert zoning info stored in the old format to the new format.

save(path[, mode])

Save zoning data as a dataframe and a yml file.

trans_df_to_dict(trans_df, from_col, to_col, ...)

Convert a translation dataframe to a dict.

translate(other[, cache_path, weighting])

Find, or generates, the zone_translation data from self to other.

translation_column_name(other)

Return expected name for zone_translation factors column in zone_translation data.

validate_translation_data(other, translation)

Validate zone_translation data, checking for missing zones and factors sum to 1.

zone_descriptions()

Describe zones, with the index as the zone ID.

zone_names()

Name of zones, with the index as the zone ID.

zoning_from_df_col(col)

Create a zoning system from the column of a df.

zoning_from_shapefile(name, shapefile, name_col)

Produce a ZoningSystem from a shapefile.

Attributes Documentation

column_name#

Expected name of columns in translations or DVectors.

desc_to_id#

Return a lookup dict of zone description to zone id.

id_to_desc#

Return a lookup dict of zone id to zone description.

id_to_external#

Produce lookup to convert id to external.

id_to_internal#

Produce lookup to convert id to internal.

id_to_name#

Return a lookup dict of zone id to zone name.

name_to_id#

Return a lookup dict of zone name to zone id.

subset_columns#

Names of subset columns available.

zone_ids#

Return a copy of the zone IDs array.

zones_data#

Return a copy of the zones DataFrame.

This contains zone ID as the index and some optional columns for names, descriptions and subset flags.