generated from dataforgoodfr/d4g-project-template
-
Notifications
You must be signed in to change notification settings - Fork 51
Analyst/lounes tous polluants udi dernier #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1b4e62d
feat: creation de la branche (à continuer)
LounesAbd 5cf172a
Merge remote-tracking branch 'upstream' into analyst/lounes_tous-poll…
LounesAbd 8f78a1b
Merge remote-tracking branch 'upstream' into analyst/lounes_tous-poll…
LounesAbd 210bfbe
feat : create files and first SQL model iteration
LounesAbd 1faa608
feat : add yaml profile
LounesAbd 8d9fd74
fix : syntaxe de la clause FROM
LounesAbd 4f2b0b7
fix : changement syntaxe CASE WHEN et valeurs acceptées dbt colonne '…
LounesAbd 3193880
Merge remote-tracking branch 'upstream' into analyst/lounes_tous-poll…
LounesAbd 1af078e
Merge remote-tracking branch 'upstream' into analyst/lounes_tous-poll…
LounesAbd 5f082c7
fix : simplified model and added dbt test file
LounesAbd dedaf94
Merge remote-tracking branch 'upstream' into analyst/lounes_tous-poll…
LounesAbd 94931eb
Merge branch 'main' into analyst/lounes_tous-polluants_udi_dernier
jereze 373d54b
fix: little changes to match the results better
LounesAbd f377c17
fix: changed results name in pfas test file and in tous polluants udi…
LounesAbd fb3c66f
Merge remote-tracking branch 'upstream' into analyst/lounes_tous-poll…
LounesAbd 7ac258d
Merge branch 'upstream' into analyst/lounes_tous-polluants_udi_dernie…
LounesAbd 919a9e1
fix: add test dernier_prel_datetime
LounesAbd 0c34cd1
Revert "fix: little changes to match the results better"
jereze 961f3f5
fix the revert
jereze 0861751
update dat model
jereze bf2c8bc
rename "tous_polluants" to "tous"
jereze 9f834b4
add "tous" category to website
jereze File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
347 changes: 347 additions & 0 deletions
347
analytics/notebooks/resultats_tous-polluants_udi_dernier.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,347 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "89d3136e", | ||
"metadata": {}, | ||
"source": [ | ||
"## Derniers résultats en date - tous polluants confondus\n", | ||
"\n", | ||
"---\n", | ||
"\n", | ||
"#### 3 situations:\n", | ||
"\n", | ||
"VERTE: tous les paramètres sont en dessous des limites réglementaires ou recommandations.\n", | ||
"\n", | ||
"- Toutes les substances actives et métabolites pertinents < 0,1 µg/L et la somme des s.a + métabolites pertinents et pertinents par défaut < 0,5 µg/L et tous les métabolites non pertinents < 0,9 µg/L\n", | ||
"- ET Nitrates < 50 mg/L et nitrites < 0,5 mg/L et nitrate/50 + nitrites/3 < 1 mg/L (eau conforme)\n", | ||
"- ET somme des 20 PFAS < 0,1 µg/L et la sommes des 4 PFAS < 0,02 µg/L\n", | ||
"- ET CVM < 0.5 µg/L\n", | ||
"- ET Plomb < 0.5 µg/L\n", | ||
"- ET Arsenic < 10 µg/L\n", | ||
"- ET perchlorate < 4 µg/L\n", | ||
"- ET 1,4-dioxane < 0.35 µg/L\n", | ||
"\n", | ||
"ORANGE: au moins un paramètre est au dessus de la limite réglementaire ou des recommandations.\n", | ||
"\n", | ||
"- Au moins 1 s.a ou métabolite pertinent ≥ 0,1 µg/L et/ou la somme des s.a + métabolites pertinents et pertinents par défaut ≥ 0,5 µg/L et/ou au moins 1 métabolite non pertinent ≥ 0,9 µg/L\n", | ||
"- ET/OU Nitrates ≥ 50 mg/L et/ou nitrites ≥ 0,5 mg/L et/ou nitrate/50 + nitrites/3 ≥ 1 mg/L\n", | ||
"- ET/OU somme des 4 PFAS (PFOA, PFOS, PFNA, PFHxS) ≥ 0.02 µg/L et/ou somme des 20 PFAS ≥ 0.1 µg/L\n", | ||
"- ET/OU Plomb ≥ 0.5 µg/L\n", | ||
"- ET/OU Arsenic ≥ 10 µg/L\n", | ||
"\n", | ||
"ROUGE: au moins un paramètres est au dessus d’une limite sanitaire indiquant un potentiel risque pour la santé (dans ces cas la consommation d’eau est déconseillée).\n", | ||
"\n", | ||
"- Au moins 1 substance active ou 1 métabolite > limite sanitaire\n", | ||
"- Au moins 1 PFAS > limite sanitaire\n", | ||
"- ET/OU CVM ≥ 0.5 µg/L\n", | ||
"- ET/OU Plomb ≥ xx µg/L\n", | ||
"- ET/OU Arsenic ≥ xx µg/L\n", | ||
"- ET/OU perchlorate ≥ 4 µg/L\n", | ||
"- ET/OU 1,4-dioxane ≥ 0.35 µg/L\n", | ||
"\n", | ||
"---\n", | ||
"\n", | ||
"Réalisation du modèle seulement poru CVM et PFAS pour le moment\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "b4cf0c0d", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<span style=\"None\">The 'toml' package isn't installed. To load settings from pyproject.toml or ~/.jupysql/config, install with: pip install toml</span>" | ||
], | ||
"text/plain": [ | ||
"The 'toml' package isn't installed. To load settings from pyproject.toml or ~/.jupysql/config, install with: pip install toml" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<span style=\"None\">Connecting to 'duckdb:///../../database/data.duckdb'</span>" | ||
], | ||
"text/plain": [ | ||
"Connecting to 'duckdb:///../../database/data.duckdb'" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"%load_ext sql\n", | ||
"%sql duckdb:///../../database/data.duckdb\n", | ||
"%config SqlMagic.displaylimit = 20" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"id": "2abe764d", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<span style=\"None\">Running query in 'duckdb:///../../database/data.duckdb'</span>" | ||
], | ||
"text/plain": [ | ||
"Running query in 'duckdb:///../../database/data.duckdb'" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "d1c0358c72074c44a37efd6f64139f6b", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"FloatProgress(value=0.0, layout=Layout(width='auto'), style=ProgressStyle(bar_color='black'))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<table>\n", | ||
" <thead>\n", | ||
" <tr>\n", | ||
" <th>categorie</th>\n", | ||
" <th>resultat</th>\n", | ||
" </tr>\n", | ||
" </thead>\n", | ||
" <tbody>\n", | ||
" <tr>\n", | ||
" <td>cvm</td>\n", | ||
" <td>inf_0_5</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>cvm</td>\n", | ||
" <td>non_quantifie</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>cvm</td>\n", | ||
" <td>sup_0_5</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>pfas</td>\n", | ||
" <td>aucun_parametre_quantifie</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>pfas</td>\n", | ||
" <td>somme_20pfas_inf_0_1_et_4pfas_inf_0_02</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>pfas</td>\n", | ||
" <td>somme_20pfas_sup_0_1</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>pfas</td>\n", | ||
" <td>somme_20pfas_inf_0_1_et_4pfas_sup_0_02</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>pfas</td>\n", | ||
" <td>un_pfas_sup_valeur_sanitaire</td>\n", | ||
" </tr>\n", | ||
" </tbody>\n", | ||
"</table>" | ||
], | ||
"text/plain": [ | ||
"+-----------+----------------------------------------+\n", | ||
"| categorie | resultat |\n", | ||
"+-----------+----------------------------------------+\n", | ||
"| cvm | inf_0_5 |\n", | ||
"| cvm | non_quantifie |\n", | ||
"| cvm | sup_0_5 |\n", | ||
"| pfas | aucun_parametre_quantifie |\n", | ||
"| pfas | somme_20pfas_inf_0_1_et_4pfas_inf_0_02 |\n", | ||
"| pfas | somme_20pfas_sup_0_1 |\n", | ||
"| pfas | somme_20pfas_inf_0_1_et_4pfas_sup_0_02 |\n", | ||
"| pfas | un_pfas_sup_valeur_sanitaire |\n", | ||
"+-----------+----------------------------------------+" | ||
] | ||
}, | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"%%sql\n", | ||
"\n", | ||
"SELECT DISTINCT categorie, resultat\n", | ||
"FROM int__union_resultats_udi\n", | ||
"WHERE periode = 'dernier_prel'\n", | ||
" AND categorie IN ('pfas', 'cvm')\n", | ||
"ORDER BY categorie" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3b316845", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<span style=\"None\">Running query in 'duckdb:///../../database/data.duckdb'</span>" | ||
], | ||
"text/plain": [ | ||
"Running query in 'duckdb:///../../database/data.duckdb'" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "0bfaa1d8fcf74f0b845c50e0044b0658", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"FloatProgress(value=0.0, layout=Layout(width='auto'), style=ProgressStyle(bar_color='black'))" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<table>\n", | ||
" <thead>\n", | ||
" <tr>\n", | ||
" <th>cdreseau</th>\n", | ||
" <th>periode</th>\n", | ||
" <th>categorie</th>\n", | ||
" <th>resultat</th>\n", | ||
" <th>ratio</th>\n", | ||
" <th>dernier_prel_datetime</th>\n", | ||
" <th>dernier_prel_valeur</th>\n", | ||
" <th>nb_parametres</th>\n", | ||
" </tr>\n", | ||
" </thead>\n", | ||
" <tbody>\n", | ||
" <tr>\n", | ||
" <td>083001148</td>\n", | ||
" <td>dernier_prel</td>\n", | ||
" <td>pfas</td>\n", | ||
" <td>somme_20pfas_inf_0_1_et_4pfas_inf_0_02</td>\n", | ||
" <td>None</td>\n", | ||
" <td>2025-02-28 09:19:00</td>\n", | ||
" <td>None</td>\n", | ||
" <td>21</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <td>083001148</td>\n", | ||
" <td>dernier_prel</td>\n", | ||
" <td>cvm</td>\n", | ||
" <td>non_quantifie</td>\n", | ||
" <td>None</td>\n", | ||
" <td>2025-01-31 08:50:00</td>\n", | ||
" <td>0.000</td>\n", | ||
" <td>1</td>\n", | ||
" </tr>\n", | ||
" </tbody>\n", | ||
"</table>" | ||
], | ||
"text/plain": [ | ||
"+-----------+--------------+-----------+----------------------------------------+-------+-----------------------+---------------------+---------------+\n", | ||
"| cdreseau | periode | categorie | resultat | ratio | dernier_prel_datetime | dernier_prel_valeur | nb_parametres |\n", | ||
"+-----------+--------------+-----------+----------------------------------------+-------+-----------------------+---------------------+---------------+\n", | ||
"| 083001148 | dernier_prel | pfas | somme_20pfas_inf_0_1_et_4pfas_inf_0_02 | None | 2025-02-28 09:19:00 | None | 21 |\n", | ||
"| 083001148 | dernier_prel | cvm | non_quantifie | None | 2025-01-31 08:50:00 | 0.000 | 1 |\n", | ||
"+-----------+--------------+-----------+----------------------------------------+-------+-----------------------+---------------------+---------------+" | ||
] | ||
}, | ||
"execution_count": 15, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
}, | ||
{ | ||
"ename": "", | ||
"evalue": "", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[1;31mThe Kernel crashed while executing code in the current cell or a previous cell. \n", | ||
"\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n", | ||
"\u001b[1;31mClick <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. \n", | ||
"\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details." | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%%sql\n", | ||
"\n", | ||
"SELECT *\n", | ||
"FROM int__union_resultats_udi\n", | ||
"WHERE periode = 'dernier_prel'\n", | ||
" AND categorie IN ('pfas', 'cvm')\n", | ||
" AND cdreseau = '083001148'\n", | ||
"LIMIT 10" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "67977db8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%sql\n", | ||
"\n", | ||
"SELECT DISTINCT\n", | ||
" cdreseau,\n", | ||
" periode,\n", | ||
" (CASE\n", | ||
" WHEN categorie = 'cvm' AND resultat = 'inf_0_5'\n", | ||
" OR \n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"FROM int__union_resultats_udi\n", | ||
"WHERE\n", | ||
" periode = 'dernier_prel'\n", | ||
" AND categorie IN ('cvm', 'pfas')" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
35 changes: 35 additions & 0 deletions
35
dbt_/models/intermediate/tous_polluants/_int__tous_polluants_models.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
version: 1 | ||
|
||
models: | ||
- name: int__resultats_tous_polluants_udi_dernier | ||
description: "Résultats des derniers prélèvements pour tous les polluants par UDI. Ce modèle sélectionne le dernier prélèvement pour chaque paramètre et agrège les résultats pour identifier les dépassements des seuils sanitaires et/ou règlementaires." | ||
columns: | ||
- name: cdreseau | ||
description: "Code de l'installation (UDI)." | ||
LounesAbd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tests: | ||
- not_null | ||
- unique | ||
|
||
- name: dernier_prel_datetime | ||
description: "Date et heure du dernier prélèvement pris en compte dans l'analyse." | ||
type: TIMESTAMP | ||
tests: | ||
- not_null | ||
LounesAbd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: resultat_all | ||
description: "Interprétation du résultat en fonction des seuils sanitaires et règlementaires." | ||
type: VARCHAR | ||
tests: | ||
- accepted_values: | ||
values: | ||
- "inf_limites" | ||
- "min_1_parametre_sup_limite_reg" | ||
- "min_1_parametre_sup_limite_sanitaire" | ||
- "erreur" | ||
LounesAbd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
- name: periode | ||
description: "Période d'analyse des prélèvements (ici, toujours 'dernier_prel')." | ||
type: VARCHAR | ||
tests: | ||
- accepted_values: | ||
values: ["dernier_prel"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.