access¶
Isolation status, nearest-facility times, 2SFCA and Hansen accessibility.
quakecascade.access
¶
Place-based accessibility and post-event isolation.
Decay functions, Hansen potential and the two-step floating catchment area
(2SFCA) are ported from the PlanX engine (engine/accessibility.py, same
author); the cost-matrix layout of the public wrappers follows
quakecascade.network.RoadNetwork.travel_time_matrix: rows are demand
units (origins), columns are facilities.
- Cumulative opportunities (Wachs & Kumagai 1973).
- Gravity potential (Hansen 1959): \(A_i = \sum_j S_j f(c_{ij})\).
- 2SFCA (Radke & Mu 2000; Luo & Wang 2003) with a decayed catchment (Luo & Qi 2009): \(R_j = S_j / \sum_k P_k f(c_{kj})\), \(A_i = \sum_j R_j f(c_{ij})\).
The isolation status compares access before and after an event (closed roads) for each unit: newly cut off, worse, same, improved or always cut off.
Decay kinds (c cost, T threshold/cutoff, p the kind's parameter):
============== ===================================== ============================= cumulative 1 if c <= T Wachs & Kumagai 1973 linear max(0, 1 - c/T) cone (Luo & Qi 2009) exponential exp(-p c) p = beta per cost unit gaussian (exp(-c^2/(2T^2)) - e^-1/2)/(1-e^-1/2) Dai 2010, Eq. 2; no p gaussian_sigma exp(-c^2 / (2 p^2)) p = sigma (Kwan 1998) power min(1, c^-p) p = beta; c < 1 reads as 1 logistic 1 / (1 + exp((c - p) 4/p)) p = half-weight cost ============== ===================================== =============================
Every kind is exactly zero beyond T and for non-finite costs.
DECAY_KINDS
module-attribute
¶
DECAY_KINDS = (
"cumulative",
"linear",
"exponential",
"gaussian",
"gaussian_sigma",
"power",
"logistic",
)
Distance-decay functions accepted by the 2SFCA and Hansen measures.
NEWLY_CUT_OFF
module-attribute
¶
Reachable before the event, not after.
WORSE
module-attribute
¶
Reachable before and after, slower by more than the tolerance.
SAME
module-attribute
¶
Reachable before and after, with a change within the tolerance.
IMPROVED
module-attribute
¶
Reachable only after the event, or faster by more than the tolerance.
ALWAYS_CUT_OFF
module-attribute
¶
Reachable neither before nor after the event: not a loss caused by the event.
ISOLATION_CATEGORIES
module-attribute
¶
The categories of isolation_status. A unit with an unknown travel time gets
no_pre_time or no_post_time instead.
NO_TRAVEL_TIME
module-attribute
¶
Status of a value that needs a travel time that is not known.
AccessAccumulator
¶
Chunk-wise Hansen and 2SFCA sums over destination-by-origin blocks.
The caller feeds blocks of destinations (add_block), each with its
costs to every origin; the sums are complete when the last block is in.
2SFCA can be built this way because each facility's ratio R_j needs
only its own column. Costs must be finite or inf; NaN handling is done
by two_step_fca.
add_block
¶
Costs shaped (block, n_origins) and the block's supply weights.
gaussian_decay
¶
Threshold-normalised Gaussian weight of Dai (2010).
and 0 beyond T; 1 at c = 0 and 0 at c = T.
Source: Dai, D. (2010). Black residential segregation, disparities in spatial access to health care facilities, and late-stage breast cancer diagnosis in metropolitan Detroit. Health & Place 16(5), 1038-1052, Eq. 2. doi:10.1016/j.healthplace.2010.06.012
decay
¶
Weight in [0, 1] for travel costs cost.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cost
|
array_like
|
Travel costs (any unit consistent with |
required |
kind
|
str
|
One of |
required |
param
|
float or None
|
The kind's own parameter; required (positive) for exponential, gaussian_sigma, power and logistic, ignored otherwise. |
required |
cutoff
|
float
|
Threshold |
required |
half_weight_time
¶
Cost at which the decay first reaches 0.5 (None if it never does).
two_step_fca
¶
two_step_fca(
cost,
supply,
demand,
threshold,
decay="cumulative",
param=None,
return_ratio=False,
)
Two-step floating catchment area accessibility.
(Radke & Mu 2000; Luo & Wang 2003; decayed catchment: Luo & Qi 2009; Gaussian: Dai 2010). Population-weighted access sums to the supply of every facility that someone can reach: \(\sum_i P_i A_i = \sum_{j:\,D_j>0} S_j\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cost
|
(n_demand, n_facility) array
|
Travel cost from each demand unit to each facility; |
required |
supply
|
(n_facility,) array
|
Facility capacity (beds, places). NaN = unknown; the facility is left
out and every unit that reaches it is marked |
required |
demand
|
(n_demand,) array
|
Population per unit. NaN = unknown; the unit adds nobody to any
catchment, so the ratios it touches are upper bounds ( |
required |
threshold
|
float
|
Catchment size |
required |
decay
|
str
|
A |
'cumulative'
|
param
|
float
|
Parameter of the decay kind when it needs one. |
None
|
return_ratio
|
bool
|
Also return the facility table. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame (and facility DataFrame when ``return_ratio``)
|
Per demand unit: |
hansen
¶
Hansen (1959) potential \(A_i = \sum_j S_j f(c_{ij})\) per demand unit.
cost is (n_demand, n_facility). A unit whose whole cost row is NaN
gets NaN; NaN entries elsewhere count as unreachable (the value is then a
lower bound). Facilities with NaN supply are skipped, which also makes the
value a lower bound; a unit that reaches only facilities of unknown
supply gets NaN, not 0.
nearest_time
¶
Cost to the nearest facility per row of a cost matrix.
Returns nearest_time (inf when no facility is reachable),
nearest_index (column, -1 when none) and nearest_status:
computed; partial when some entries were unknown (the value is an
upper bound); no_travel_time when the known entries reach nothing and
some are unknown, or the whole row is unknown (value NaN).
isolation_status
¶
Compare access before and after an event, unit by unit.
A unit is reachable when its time is finite (and not above limit_s
when a limit is given). With d = post - pre:
================ ============================================ newly_cut_off reachable before, not after always_cut_off reachable neither before nor after improved not reachable before, reachable after; or d < -tol worse d > tol same |d| <= tol ================ ============================================
A NaN (unknown) time gives no_pre_time / no_post_time and no
category. The categories follow the pre/post comparison of network
accessibility-loss studies (e.g. Sohn 2006, doi:10.1016/j.tra.2005.08.006);
the tolerance is the caller's.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pre
|
array_like
|
Times per unit ( |
required |
post
|
array_like
|
Times per unit ( |
required |
limit_s
|
float
|
Times above it count as unreachable. |
None
|
worse_tol_s
|
float
|
Change smaller than or equal to this is |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
population_by_status
¶
People and units per isolation category.
Returns one row per category (the five of ISOLATION_CATEGORIES
always, plus any missing-data code present) with n_units,
population (sum; NaN when every unit in the category lacks a
population) and n_population_missing.