Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
benhammondmusic committed Apr 25, 2024
2 parents ed7fd14 + 20fbab9 commit a8c6ecc
Show file tree
Hide file tree
Showing 34 changed files with 15,211 additions and 85 deletions.
6 changes: 4 additions & 2 deletions .github/linters/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[FORMAT]
max-line-length=120
[MESSAGES CONTROL]
disable=C0114,E0401,C0201,C0115,R1714,C0411,W0511,R1705,C0116,C0103,R0201,W0104
disable=C0114,E0401,C0201,C0115,R1714,C0411,W0511,R1705,C0116,C0103,R0201,W0104,W0105,R0801

; C0114 (missing-module-docstring): Missing module docstring.
; E0401 (import-error): Unable to import a module.
Expand All @@ -14,4 +14,6 @@ disable=C0114,E0401,C0201,C0115,R1714,C0411,W0511,R1705,C0116,C0103,R0201,W0104
; C0116 (missing-function-docstring): Missing function or method docstring.
; C0103 (invalid-name): Naming convention is not followed.
; R0201 (no-self-use): Method could be a function.
; W0104 (pointless): Pointless statement.
; W0104 (pointless): Pointless statement.
; W0105 (pointless-string-statement): Pointless string statement.
; R0801 similarities: Similar lines in 2 files
96 changes: 96 additions & 0 deletions airflow/dags/cdc_wisqars_black_men.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
from airflow import DAG # type: ignore
from airflow.utils.dates import days_ago # type: ignore
import util

_CDC_WISQARS_BLACK_MEN_WORKFLOW_ID = "CDC_WISQARS_BLACK_MEN_DATA"
_CDC_WISQARS_BLACK_MEN_DATASET_NAME = "cdc_wisqars_black_men_data"

default_args = {
'start_date': days_ago(0),
}

data_ingestion_dag = DAG(
'cdc_wisqars_black_men_ingestion_dag',
default_args=default_args,
schedule_interval=None,
description='Ingestion configuration for CDC_WISQARS Black Men',
)

# URBANICITY NATIONAL
cdc_wisqars_black_men_bq_payload_urbanicity_national = util.generate_bq_payload(
_CDC_WISQARS_BLACK_MEN_WORKFLOW_ID,
_CDC_WISQARS_BLACK_MEN_DATASET_NAME,
demographic='urbanicity',
geographic='national',
)
cdc_wisqars_black_men_bq_operator_urbanicity_national = util.create_bq_ingest_operator(
'cdc_wisqars_black_men_to_bq_urbanicity_national',
cdc_wisqars_black_men_bq_payload_urbanicity_national,
data_ingestion_dag,
)

# URBANICITY STATE
cdc_wisqars_black_men_bq_payload_urbanicity_state = util.generate_bq_payload(
_CDC_WISQARS_BLACK_MEN_WORKFLOW_ID,
_CDC_WISQARS_BLACK_MEN_DATASET_NAME,
demographic='urbanicity',
geographic='state',
)
cdc_wisqars_black_men_bq_operator_urbanicity_state = util.create_bq_ingest_operator(
'cdc_wisqars_black_men_to_bq_urbanicity_state',
cdc_wisqars_black_men_bq_payload_urbanicity_state,
data_ingestion_dag,
)

# AGE NATIONAL
cdc_wisqars_black_men_bq_payload_age_national = util.generate_bq_payload(
_CDC_WISQARS_BLACK_MEN_WORKFLOW_ID,
_CDC_WISQARS_BLACK_MEN_DATASET_NAME,
demographic='age',
geographic='national',
)
cdc_wisqars_black_men_bq_operator_age_national = util.create_bq_ingest_operator(
'cdc_wisqars_black_men_to_bq_age_national',
cdc_wisqars_black_men_bq_payload_age_national,
data_ingestion_dag,
)

# AGE STATE
cdc_wisqars_black_men_bq_payload_age_state = util.generate_bq_payload(
_CDC_WISQARS_BLACK_MEN_WORKFLOW_ID,
_CDC_WISQARS_BLACK_MEN_DATASET_NAME,
demographic='age',
geographic='state',
)
cdc_wisqars_black_men_bq_operator_age_state = util.create_bq_ingest_operator(
'cdc_wisqars_black_men_to_bq_age_state',
cdc_wisqars_black_men_bq_payload_age_state,
data_ingestion_dag,
)

# Exporters
payload_urbanicity = {
'dataset_name': _CDC_WISQARS_BLACK_MEN_DATASET_NAME,
'demographic': "urbanicity",
}
cdc_wisqars_black_men_exporter_operator_urbanicity = util.create_exporter_operator(
'cdc_wisqars_black_men_exporter_urbanicity', payload_urbanicity, data_ingestion_dag
)

payload_age = {
'dataset_name': _CDC_WISQARS_BLACK_MEN_DATASET_NAME,
'demographic': "age",
}
cdc_wisqars_black_men_exporter_operator_age = util.create_exporter_operator(
'cdc_wisqars_black_men_exporter_age', payload_age, data_ingestion_dag
)

# Ingestion DAG
(
cdc_wisqars_black_men_bq_operator_urbanicity_national
>> cdc_wisqars_black_men_bq_operator_urbanicity_state
>> cdc_wisqars_black_men_bq_operator_age_national
>> cdc_wisqars_black_men_bq_operator_age_state
>> cdc_wisqars_black_men_exporter_operator_urbanicity
>> cdc_wisqars_black_men_exporter_operator_age
)
7 changes: 7 additions & 0 deletions config/data_sources/cdc_wisqars_black_men_data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Resources and routines for CDC WISQARS Black Men Data ingestion.

# Create a BigQuery dataset for CDC WISQARS Black Men data.
resource "google_bigquery_dataset" "cdc_wisqars_black_men" {
dataset_id = "cdc_wisqars_black_men_data"
location = "US"
}
1 change: 1 addition & 0 deletions cspell.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@
"unsentenced",
"unstripped",
"untyped",
"URBANICITY",
"usa",
"utf",
"utils",
Expand Down
89 changes: 89 additions & 0 deletions data/cdc_wisqars/gun_homicides_black_men-national_age.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
"Year","Age Group","Deaths","Population","Crude Rate","Age-Adjusted Rate","Years of Potential Life Lost"
"2021","0 to 4","29","1,334,343","2.17","--","1,819"
"2021","5 to 9","32","1,407,555","2.27","--","1,852"
"2021","10 to 14","114","1,506,253","7.57","--","5,906"
"2021","15 to 19","1,544","1,481,523","104.22","--","73,208"
"2021","20 to 24","2,181","1,526,119","142.91","--","93,908"
"2021","25 to 29","2,111","1,645,986","128.25","--","80,075"
"2021","30 to 34","1,726","1,617,641","106.70","--","57,278"
"2021","35 to 39","1,165","1,389,062","83.87","--","32,743"
"2021","40 to 44","817","1,292,454","63.21","--","18,926"
"2021","45 to 49","521","1,180,757","44.12","--","9,368"
"2021","50 to 54","324","1,217,518","26.61","--","4,253"
"2021","55 to 59","249","1,225,274","20.32","--","2,037"
"2021","60 to 64","176","1,127,301","15.61","--","562"
"2021","65 to 69","67","860,401","7.79","--","0"
"2021","70 to 74","38","614,962","6.18","--","0"
"2021","75 to 79","12**","344,967","3.48**","--","0"
"2021","80 to 84","--","200,559","--","--","--"
"2021","85+","--","148,429","--","--","--"
"2020","0 to 4","27","1,354,596","1.99","--","1,694"
"2020","5 to 9","28","1,415,876","1.98","--","1,621"
"2020","10 to 14","98","1,518,806","6.45","--","5,077"
"2020","15 to 19","1,413","1,486,354","95.07","--","66,874"
"2020","20 to 24","2,200","1,524,907","144.27","--","94,712"
"2020","25 to 29","2,130","1,695,469","125.63","--","80,931"
"2020","30 to 34","1,613","1,557,958","103.53","--","53,532"
"2020","35 to 39","1,057","1,375,640","76.84","--","29,709"
"2020","40 to 44","697","1,261,970","55.23","--","16,145"
"2020","45 to 49","469","1,213,882","38.64","--","8,409"
"2020","50 to 54","293","1,215,479","24.11","--","3,844"
"2020","55 to 59","218","1,240,535","17.57","--","1,781"
"2020","60 to 64","137","1,113,107","12.31","--","472"
"2020","65 to 69","63","831,295","7.58","--","0"
"2020","70 to 74","25","578,415","4.32","--","0"
"2020","75 to 79","14**","335,383","4.17**","--","0"
"2020","80 to 84","--","196,002","--","--","--"
"2020","85+","--","144,605","--","--","--"
"2019","0 to 4","16**","1,369,926","1.17**","--","1,007"
"2019","5 to 9","19**","1,406,618","1.35**","--","1,093"
"2019","10 to 14","60","1,448,453","4.14","--","3,117"
"2019","15 to 19","1,013","1,467,288","69.04","--","47,905"
"2019","20 to 24","1,574","1,550,041","101.55","--","67,760"
"2019","25 to 29","1,564","1,764,405","88.64","--","59,501"
"2019","30 to 34","1,119","1,487,155","75.24","--","37,198"
"2019","35 to 39","764","1,333,597","57.29","--","21,462"
"2019","40 to 44","524","1,196,128","43.81","--","12,154"
"2019","45 to 49","322","1,202,292","26.78","--","5,845"
"2019","50 to 54","195","1,187,330","16.42","--","2,528"
"2019","55 to 59","184","1,209,310","15.22","--","1,538"
"2019","60 to 64","99","1,060,287","9.34","--","326"
"2019","65 to 69","53","787,343","6.73","--","0"
"2019","70 to 74","27","541,055","4.99","--","0"
"2019","75 to 79","--","330,837","--","--","--"
"2019","80 to 84","--","197,705","--","--","--"
"2019","85+","--","155,280","--","--","--"
"2018","0 to 4","16**","1,379,055","1.16**","--","1,011"
"2018","5 to 9","12**","1,407,402","0.85**","--","695"
"2018","10 to 14","32","1,443,464","2.22","--","1,669"
"2018","15 to 19","906","1,482,802","61.10","--","42,843"
"2018","20 to 24","1,464","1,584,283","92.41","--","62,917"
"2018","25 to 29","1,479","1,746,586","84.68","--","56,347"
"2018","30 to 34","1,003","1,423,879","70.44","--","33,228"
"2018","35 to 39","730","1,320,305","55.29","--","20,521"
"2018","40 to 44","506","1,173,053","43.14","--","11,742"
"2018","45 to 49","295","1,215,047","24.28","--","5,392"
"2018","50 to 54","207","1,212,792","17.07","--","2,735"
"2018","55 to 59","180","1,207,664","14.91","--","1,467"
"2018","60 to 64","93","1,031,721","9.01","--","303"
"2018","65 to 69","44","761,360","5.78","--","0"
"2018","70 to 74","18**","507,138","3.55**","--","0"
"2018","75 to 79","--","316,918","--","--","--"
"2018","80 to 84","--","190,860","--","--","--"
"2018","85+","--","149,437","--","--","--"
"Total","","36,149","79,430,199","45.51","--","1,249,040"
"","","","","","",""
"Injury Outcome: Fatal","","","","","",""
"Injury Type: All Injury","","","","","",""
"Data Years: 2018 to 2021","","","","","",""
"Geography: United States","","","","","",""
"Intent: Homicide","","","","","",""
"Mechanism: Firearm","","","","","",""
"Age: All Ages","","","","","",""
"Sex: Males","","","","","",""
"Race: Black","","","","","",""
"Ethnicity: Non-Hispanic","","","","","",""
"Metro / Non-Metro Indicator: None Selected","","","","","",""
"YPLL Age: 65","","","","","",""
"Year and Race Options: 2018 - 2021 by Single Race","","","","","",""
"Produced by: National Center for Injury Prevention and Control, CDC.","","","","","",""
21 changes: 21 additions & 0 deletions data/cdc_wisqars/gun_homicides_black_men-national_all.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"Year","Deaths","Population","Crude Rate","Age-Adjusted Rate","Years of Potential Life Lost"
"2021","11,110","20,121,104","55.22","52.73","381,935"
"2020","10,493","20,060,279","52.31","49.64","364,801"
"2019","7,548","19,695,050","38.32","36.07","261,434"
"2018","6,998","19,553,766","35.79","33.65","240,870"
"Total","36,149","79,430,199","45.51","43.08","1,249,040"
"","","","","",""
"Injury Outcome: Fatal","","","","",""
"Injury Type: All Injury","","","","",""
"Data Years: 2018 to 2021","","","","",""
"Geography: United States","","","","",""
"Intent: Homicide","","","","",""
"Mechanism: Firearm","","","","",""
"Age: All Ages","","","","",""
"Sex: Males","","","","",""
"Race: Black","","","","",""
"Ethnicity: Non-Hispanic","","","","",""
"Metro / Non-Metro Indicator: None Selected","","","","",""
"YPLL Age: 65","","","","",""
"Year and Race Options: 2018 - 2021 by Single Race","","","","",""
"Produced by: National Center for Injury Prevention and Control, CDC.","","","","",""
25 changes: 25 additions & 0 deletions data/cdc_wisqars/gun_homicides_black_men-national_urbanicity.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"Year","Metro / Non-Metro","Deaths","Population","Crude Rate","Age-Adjusted Rate","Years of Potential Life Lost"
"2021","Metro","10,241","18,220,659","56.21","53.85","352,510"
"2021","Non-Metro","869","1,900,445","45.73","42.62","29,425"
"2020","Metro","9,676","18,165,102","53.27","50.73","337,032"
"2020","Non-Metro","817","1,895,177","43.11","39.65","27,769"
"2019","Metro","6,962","17,788,167","39.14","36.99","241,139"
"2019","Non-Metro","586","1,906,883","30.73","27.90","20,295"
"2018","Metro","6,472","17,640,912","36.69","34.59","223,075"
"2018","Non-Metro","526","1,912,854","27.50","25.31","17,795"
"Total","","36,149","79,430,199","45.51","43.08","1,249,040"
"","","","","","",""
"Injury Outcome: Fatal","","","","","",""
"Injury Type: All Injury","","","","","",""
"Data Years: 2018 to 2021","","","","","",""
"Geography: United States","","","","","",""
"Intent: Homicide","","","","","",""
"Mechanism: Firearm","","","","","",""
"Age: All Ages","","","","","",""
"Sex: Males","","","","","",""
"Race: Black","","","","","",""
"Ethnicity: Non-Hispanic","","","","","",""
"Metro / Non-Metro Indicator: None Selected","","","","","",""
"YPLL Age: 65","","","","","",""
"Year and Race Options: 2018 - 2021 by Single Race","","","","","",""
"Produced by: National Center for Injury Prevention and Control, CDC.","","","","","",""
Loading

0 comments on commit a8c6ecc

Please sign in to comment.