emod_api.demographics.Node module#

class emod_api.demographics.Node.Node(lat, lon, pop, name: str | None = None, area: float | None = None, forced_id: int | None = None, individual_attributes: IndividualAttributes | None = None, individual_properties: IndividualProperties | None = None, node_attributes: NodeAttributes | None = None, meta: dict | None = None)[source]#

Bases: Updateable

default_population = 1000#
res_in_degrees = 0.041666666666666664#
property name#
has_individual_property(property_key: str) bool[source]#
get_individual_property(property_key: str) IndividualProperty[source]#
to_dict() dict[source]#

Translate node structure to a dictionary for EMOD

to_tuple()[source]#

Returns a tuple of (latitude, longitude, and initial population)

property id#

Returns the node ID

classmethod init_resolution_from_file(fn)[source]#
classmethod from_data(data: dict)[source]#

Function used to create the node object from data (most likely coming from a demographics file)

Parameters:

data (dict) – Contains the node definitions

Returns:

A emod_api.Demographics.Node.Node

property pop#

initial population

property lon#

longitude

property lat#

latitude

property birth_rate#

birth rate in births per person per day

class emod_api.demographics.Node.OverlayNode(node_id, latitude=None, longitude=None, initial_population=None, **kwargs)[source]#

Bases: Node

Node that only requires an ID. Use to overlay a Node.

emod_api.demographics.Node.get_xpix_ypix(nodeid)[source]#

Get pixel position from nodid. Inverse of nodeid_from_lat_lon()

emod_api.demographics.Node.lat_lon_from_nodeid(nodeid, res_in_deg=0.041666666666666664)[source]#

Inverse of nodeid_from_lat_lon()

emod_api.demographics.Node.xpix_ypix_from_lat_lon(lat, lon, res_in_deg=0.041666666666666664)[source]#

Pixel position (origin is -90°N and -180°E). No modular arithmentic is done.

emod_api.demographics.Node.nodeid_from_lat_lon(lat, lon, res_in_deg=0.041666666666666664)[source]#

Generate unique identifier from lat, lon. Inverse of lat_lon_from_nodeid()

emod_api.demographics.Node.nodes_for_DTK(filename, nodes)[source]#

Write nodes to a file in JSON format for EMOD

Parameters:
  • filename (str) – Name of output file

  • nodes (list) – List of emod_api.Demographics.Node.Node

emod_api.demographics.Node.basicNode(lat: float = 0, lon: float = 0, pop: int = 1000000, name: str = 'node_name', forced_id: int = 1)[source]#

A single node with population 1 million