Adding constants for front end to display booleans (#1348)

Added constants for the threshold categories and socioeconomic indicators for front end.
This commit is contained in:
Emma Nechamkin 2022-03-02 17:12:28 -05:00 committed by GitHub
parent aea49cbb5a
commit 1f5633ef74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 118 additions and 16 deletions

View file

@ -187,8 +187,6 @@ TILES_SCORE_COLUMNS = {
field_names.POVERTY_LOW_HS_LOW_HIGHER_ED_FIELD: "PLHSE",
field_names.LOW_MEDIAN_INCOME_LOW_HS_LOW_HIGHER_ED_FIELD: "LMILHSE",
field_names.UNEMPLOYMENT_LOW_HS_LOW_HIGHER_ED_FIELD: "ULHSE",
field_names.LOW_HS_EDUCATION_LOW_HIGHER_ED_FIELD: "LHE",
field_names.FPL_200_AND_COLLEGE_ATTENDANCE_SERIES: "FPL200S",
field_names.THRESHOLD_COUNT: "TC",
field_names.ISLAND_AREAS_UNEMPLOYMENT_LOW_HS_EDUCATION_FIELD: "IAULHSE",
field_names.ISLAND_AREAS_POVERTY_LOW_HS_EDUCATION_FIELD: "IAPLHSE",
@ -203,10 +201,26 @@ TILES_SCORE_COLUMNS = {
field_names.CENSUS_DECENNIAL_UNEMPLOYMENT_FIELD_2009
+ field_names.ISLAND_AREAS_PERCENTILE_ADJUSTMENT_FIELD
+ field_names.PERCENTILE_FIELD_SUFFIX: "IAULHSE_PFS",
field_names.LOW_HS_EDUCATION_LOW_HIGHER_ED_FIELD: "LHE",
# Percentage of HS Degree completion for Islands
field_names.CENSUS_DECENNIAL_HIGH_SCHOOL_ED_FIELD_2009: "IAHSEF",
field_names.COLLEGE_ATTENDANCE_FIELD: "CA",
field_names.COLLEGE_ATTENDANCE_LESS_THAN_20_FIELD: "CA_LT20",
field_names.LOW_INCOME_THRESHOLD: "FPL200S",
# Booleans for the front end about the types of thresholds exceeded
field_names.CLIMATE_THRESHOLD_EXCEEDED: "M_CLT_EOMI",
field_names.ENERGY_THRESHOLD_EXCEEDED: "M_ENY_EOMI",
field_names.TRAFFIC_THRESHOLD_EXCEEDED: "M_TRN_EOMI",
field_names.HOUSING_THREHSOLD_EXCEEDED: "M_HSG_EOMI",
field_names.POLLUTION_THRESHOLD_EXCEEDED: "M_PLN_EOMI",
field_names.WATER_THRESHOLD_EXCEEDED: "M_WTR_EOMI",
field_names.HEALTH_THRESHOLD_EXCEEDED: "M_HLTH_EOMI",
field_names.WORKFORCE_THRESHOLD_EXCEEDED: "M_WKFC_EOMI",
# These are the booleans for socioeconomic indicators
## Low high school and low higher ed for t&wd
field_names.WORKFORCE_SOCIO_INDICATORS_EXCEEDED: "M_WKFC_EBSI",
## FPL 200 and low higher ed for all others
field_names.FPL_200_AND_COLLEGE_ATTENDANCE_SERIES: "M_EBSI",
}
# columns to round floats to 2 decimals

File diff suppressed because one or more lines are too long

View file

@ -59,6 +59,38 @@ M_NON_WORKFORCE = "Any Non-Workforce Factor (Definition M)"
PERCENTILE = 90
MEDIAN_HOUSE_VALUE_PERCENTILE = 90
# Boolean fields
CLIMATE_THRESHOLD_EXCEEDED = "At least one climate threshold exceeded"
ENERGY_THRESHOLD_EXCEEDED = "At least one energy threshold exceeded"
TRAFFIC_THRESHOLD_EXCEEDED = "At least one traffic threshold exceeded"
HOUSING_THREHSOLD_EXCEEDED = "At least one housing threshold exceeded"
POLLUTION_THRESHOLD_EXCEEDED = "At least one pollution threshold exceeded"
WATER_THRESHOLD_EXCEEDED = "At least one water threshold exceeded"
HEALTH_THRESHOLD_EXCEEDED = "At least one health threshold exceeded"
WORKFORCE_THRESHOLD_EXCEEDED = "At least one workforce threshold exceeded"
WORKFORCE_SOCIO_INDICATORS_EXCEEDED = (
"Both workforce socioeconomic indicators exceeded"
)
# For now, these are not used. Will delete after following up with Vim.
POLLUTION_SOCIO_INDICATORS_EXCEEDED = (
"Both pollution socioeconomic indicators exceeded"
)
CLIMATE_SOCIO_INDICATORS_EXCEEDED = (
"Both climate socioeconomic indicators exceeded"
)
ENERGY_SOCIO_INDICATORS_EXCEEDED = (
"Both energy socioeconomic indicators exceeded"
)
HOUSING_SOCIO_INDICATORS_EXCEEDED = (
"Both housing socioeconomic indicators exceeded"
)
WATER_SOCIO_INDICATORS_EXCEEDED = "Both water socioeconomic indicators exceeded"
HEALTH_SOCIO_INDICATORS_EXCEEDED = (
"Both health socioeconomic indicators exceeded"
)
# Poverty / Income
POVERTY_FIELD = "Poverty (Less than 200% of federal poverty line)"
POVERTY_LESS_THAN_200_FPL_FIELD = (
@ -113,6 +145,8 @@ NPL_FIELD = "Proximity to NPL sites"
AIR_TOXICS_CANCER_RISK_FIELD = "Air toxics cancer risk"
RESPIRATORY_HAZARD_FIELD = "Respiratory hazard index"
LOW_INCOME_THRESHOLD = "Exceeds FPL200 threshold"
# Housing
HOUSING_BURDEN_FIELD = "Housing burden (percent)"
HT_INDEX_FIELD = (

View file

@ -94,15 +94,7 @@ class ScoreM(Score):
is at or more than some established threshold
"""
return (
(
df[
field_names.POVERTY_LESS_THAN_200_FPL_FIELD
+ field_names.PERCENTILE_FIELD_SUFFIX
]
>= self.LOW_INCOME_THRESHOLD
)
) & (
return (df[field_names.LOW_INCOME_THRESHOLD]) & (
df[field_names.COLLEGE_ATTENDANCE_LESS_THAN_20_FIELD]
| (
# If college attendance data is null for this tract, just rely on the
@ -174,6 +166,12 @@ class ScoreM(Score):
>= self.ENVIRONMENTAL_BURDEN_THRESHOLD
)
self.df[field_names.CLIMATE_THRESHOLD_EXCEEDED] = (
expected_population_loss_threshold
| expected_agriculture_loss_threshold
| expected_building_loss_threshold
)
self.df[
field_names.EXPECTED_POPULATION_LOSS_RATE_LOW_INCOME_LOW_HIGHER_ED_FIELD
] = (
@ -230,6 +228,10 @@ class ScoreM(Score):
>= self.ENVIRONMENTAL_BURDEN_THRESHOLD
)
self.df[field_names.ENERGY_THRESHOLD_EXCEEDED] = (
energy_burden_threshold | pm25_threshold
)
self.df[field_names.PM25_EXPOSURE_LOW_INCOME_LOW_HIGHER_ED_FIELD] = (
pm25_threshold
& self.df[field_names.FPL_200_AND_COLLEGE_ATTENDANCE_SERIES]
@ -278,6 +280,10 @@ class ScoreM(Score):
>= self.ENVIRONMENTAL_BURDEN_THRESHOLD
)
self.df[field_names.TRAFFIC_THRESHOLD_EXCEEDED] = (
traffic_threshold | diesel_threshold
)
self.df[
field_names.DIESEL_PARTICULATE_MATTER_LOW_INCOME_LOW_HIGHER_ED_FIELD
] = (
@ -341,6 +347,10 @@ class ScoreM(Score):
>= self.ENVIRONMENTAL_BURDEN_THRESHOLD
)
self.df[field_names.HOUSING_THREHSOLD_EXCEEDED] = (
lead_paint_median_home_value_threshold | housing_burden_threshold
)
# series by series indicators
self.df[
field_names.LEAD_PAINT_MEDIAN_HOUSE_VALUE_LOW_INCOME_LOW_HIGHER_ED_FIELD
@ -392,6 +402,10 @@ class ScoreM(Score):
>= self.ENVIRONMENTAL_BURDEN_THRESHOLD
)
self.df[field_names.POLLUTION_THRESHOLD_EXCEEDED] = (
rmp_sites_threshold | npl_sites_threshold
) | tsdf_sites_threshold
# individual series-by-series
self.df[field_names.RMP_LOW_INCOME_LOW_HIGHER_ED_FIELD] = (
rmp_sites_threshold
@ -421,7 +435,7 @@ class ScoreM(Score):
# poverty level and has a low percent of higher ed students
# Source: Census's American Community Survey
wastewater_threshold = (
self.df[field_names.WATER_THRESHOLD_EXCEEDED] = (
self.df[
field_names.WASTEWATER_FIELD
+ field_names.PERCENTILE_FIELD_SUFFIX
@ -432,7 +446,7 @@ class ScoreM(Score):
self.df[
field_names.WASTEWATER_DISCHARGE_LOW_INCOME_LOW_HIGHER_ED_FIELD
] = (
wastewater_threshold
self.df[field_names.WATER_THRESHOLD_EXCEEDED]
& self.df[field_names.FPL_200_AND_COLLEGE_ATTENDANCE_SERIES]
)
@ -496,6 +510,10 @@ class ScoreM(Score):
>= self.ENVIRONMENTAL_BURDEN_THRESHOLD
)
self.df[field_names.HEALTH_THRESHOLD_EXCEEDED] = (
(diabetes_threshold | asthma_threshold) | heart_disease_threshold
) | low_life_expectancy_threshold
self.df[field_names.DIABETES_LOW_INCOME_LOW_HIGHER_ED_FIELD] = (
diabetes_threshold
& self.df[field_names.FPL_200_AND_COLLEGE_ATTENDANCE_SERIES]
@ -726,6 +744,34 @@ class ScoreM(Score):
f"in the column) have a value of TRUE."
)
# Because these criteria are calculated differently for the islands, we also calculate the
# thresholds to pass to the FE slightly differently
self.df[field_names.WORKFORCE_THRESHOLD_EXCEEDED] = (
## First we calculate for the non-island areas
(
(poverty_threshold | linguistic_isolation_threshold)
| low_median_income_threshold
)
| unemployment_threshold
) | (
## then we calculate just for the island areas
(
self.df[island_areas_unemployment_criteria_field_name]
| self.df[island_areas_poverty_criteria_field_name]
)
| self.df[
island_areas_low_median_income_as_a_percent_of_ami_criteria_field_name
]
)
# Because of the island complications, we also have to separately calculate the threshold for
# socioeconomic thresholds
self.df[field_names.WORKFORCE_SOCIO_INDICATORS_EXCEEDED] = (
self.df[field_names.ISLAND_AREAS_LOW_HS_EDUCATION_FIELD]
| self.df[field_names.LOW_HS_EDUCATION_LOW_HIGHER_ED_FIELD]
)
# A tract is included if it meets either the states tract criteria or the
# island areas tract criteria.
return (
@ -743,6 +789,14 @@ class ScoreM(Score):
# and change the return signature of that method.
# Create a standalone field that captures the college attendance boolean
# threshold.
self.df[field_names.LOW_INCOME_THRESHOLD] = (
self.df[
field_names.POVERTY_LESS_THAN_200_FPL_FIELD
+ field_names.PERCENTILE_FIELD_SUFFIX
]
>= self.LOW_INCOME_THRESHOLD
)
self.df[field_names.COLLEGE_ATTENDANCE_LESS_THAN_20_FIELD] = (
self.df[field_names.COLLEGE_ATTENDANCE_FIELD]
<= self.MAX_COLLEGE_ATTENDANCE_THRESHOLD