From 1fb5a40c5947fa198133f87efe13b738bbbd49c0 Mon Sep 17 00:00:00 2001 From: Arnaud Fournier Date: Wed, 22 Jul 2026 23:25:31 +0200 Subject: [PATCH 1/5] Update config.json and sync popups --- backend/configs/all4trees_config.json | 36 ++++++++++--------- .../indicators/bio-inventory/format-data.ts | 6 ++-- .../use-bioinventory-indicator-elements.tsx | 4 +-- .../features/indicators/soil/format-data.ts | 7 ++-- webapp/src/features/indicators/soil/types.ts | 3 +- .../bio-inventory/popup-bio-inventory.tsx | 10 ++++-- .../src/features/popup/bio-inventory/types.ts | 10 +++--- .../popup-forest-inventory.tsx | 4 +-- .../features/popup/forest-inventory/types.ts | 7 ++-- 9 files changed, 50 insertions(+), 37 deletions(-) diff --git a/backend/configs/all4trees_config.json b/backend/configs/all4trees_config.json index 035acbab..fa5bebde 100644 --- a/backend/configs/all4trees_config.json +++ b/backend/configs/all4trees_config.json @@ -49,33 +49,36 @@ "columns": { "id": "_id", "geom": "gps.merge().centroid()", - "for": "int(loc2)", - "cod": "cod", - "isPublic": "int(conf)", + "code": "cod", + "type": "typ", + "cohort": "coh", + "loc1": "int(loc1)", + "loc2": "int(loc2)", "ecos": "int(ecos)", - "plot_size": "20^2*pi()/10000", + "plot_size": "for_samp.adu_samp", "project": "proj", "tree_pop": "count(1 if adu.cond = 1)", - "biomass_volume": "adu.sum(0.0673 * (for_sp.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 1) / (20^2 * pi() / 10000) / 1000", - "tree_density": "count(1 if adu.cond = 1) / (20^2 * pi() / 10000)", + "biomass_volume": "adu.sum(0.0673 * (for_sp.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 1) / (for_samp.adu_samp) / for_samp.adu_tot_max", + "tree_density": "count(1 if adu.cond = 1) / (for_samp.adu_samp)", "richness": "count(unique(adu.adu_sp))", "relative_abundance": "histogram(adu.adu_sp)", "deadwoord": "adu.count(1 if cond=2 or cond=3)", - "bio_idx_tree_density": "count(1 if adu.cond = 1) / (20^2 * pi() / 10000) / 100", - "bio_idx_deadWood": "((adu.sum(0.0673 * (for_dw.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 2) + adu.sum(pi() / 3 * ((meas_b / 2)^2 + ((meas_e / 2)^2 + meas_b / 2 + meas_e / 2) * lght * for_dw.dens) if cond = 3)) / adu.sum(0.0673 * (for_sp.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 1)) / 30 * 10", - "bio_idx_tree_diversity": "shannon(adu.adu_sp) / 5 * 10", + "bio_idx_tree_density": "count(1 if adu.cond = 1) / (for_samp.adu_samp) / 100", + "bio_idx_deadWood": "((adu.sum(0.0673 * (for_dw.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 2) + adu.sum(pi() / 3 * ((meas_b / 2)^2 + ((meas_e / 2)^2 + meas_b / 2 + meas_e / 2) * lght * for_dw.dens) if cond = 3)) / adu.sum(0.0673 * (for_sp.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 1)) / for_samp.tnc_agb_max * 10", + "bio_idx_tree_diversity": "shannon(adu.adu_sp) / for_samp.shan_max * 10", "test_gini": "adu.gini(int(area) if cond = 1) * 10", "bio_idx_spatial_distribution": "gini_arr(list_concat(list(adu.count(1 if cond=1 and area=1)), list(adu.count(1 if cond=1 and area=2)), list(adu.count(1 if cond=1 and area=3)), list(adu.count(1 if cond=1 and area=4)))) * 10", "bio_idx_diametric_distribution": "adu.gini(meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10) * 10", "bio_idx_vertical_distribution": "gini(adu.hgt_perp) * 10", - "bio_idx_dominant_height": "adu.avg(hgt_perp if hgt_perp >= percentile(hgt_perp, 80)) * 10 / 40", + "bio_idx_dominant_height": "adu.avg(hgt_perp if hgt_perp >= percentile(hgt_perp, 80)) * 10 / for_samp.hgt_dom_max", "bio_idx_microhabitats": "adu.list(trem).flatten().filter( x -> x != 'None').list_unique() * 10 / trem_group_max", "soil_structure_idx": "(thk1*float(not1) + thk2*float(not2) + thk3*float(not3) + thk4*float(not4) + thk5*float(not5)) / (thk1 + thk2 + thk3 + thk4 + thk5)", - "soil_eros_rainfall_and_wind": "for_weath.concat_ws('-', rain, wind)", + "soil_eros_rainfall": "for_weath.rain", + "soil_eros_wind": "for_weath.wind", "soil_eros_slope": "int(10 - slop if slop < 10 else 0)", "soil_eros_cover": "veg", "soil_eros_stability": "((int(slak1) + int(slak2) + int(slak3) ) / 3 if slak1 != '' )", - "soil_eros_water_infiltration": "600 * 300 / ( (epoch(interval(beer1)) + ( epoch(interval(beer2)) if beer2!='' ) + ( epoch(interval(beer3)) if beer3!='' ) + ( epoch(interval(beer4)) if beer4!='' ) + ( epoch(interval(beer5)) if beer5!='' ) + ( epoch(interval(beer6)) if beer6!='' ) + ( epoch(interval(beer7)) if beer7!='' ) + ( epoch(interval(beer8)) if beer8!='' ) + ( epoch(interval(beer9)) if beer9!='' ) + ( epoch(interval(beer10)) if beer10!='' ) ) / non_null_count(beer1, beer2, beer3, beer4, beer5, beer6, beer7, beer8, beer9, beer10) * pi() * 9^2) if beer1 != ''", + "soil_eros_water_infiltration": "600 * for_samp.beer_vol / ( (epoch(interval(beer1)) + ( epoch(interval(beer2)) if beer2!='' ) + ( epoch(interval(beer3)) if beer3!='' ) + ( epoch(interval(beer4)) if beer4!='' ) + ( epoch(interval(beer5)) if beer5!='' ) + ( epoch(interval(beer6)) if beer6!='' ) + ( epoch(interval(beer7)) if beer7!='' ) + ( epoch(interval(beer8)) if beer8!='' ) + ( epoch(interval(beer9)) if beer9!='' ) + ( epoch(interval(beer10)) if beer10!='' ) ) / non_null_count(beer1, beer2, beer3, beer4, beer5, beer6, beer7, beer8, beer9, beer10) * pi() * for_samp.beer_r^2) if beer1 != ''", "soil_fauna_density": "sum(tsbf_001.tsbf_no) / tsbf_samp", "soil_fauna_diversity": "count(tsbf_001.tsbf_tax1)", "soil_fauna_abundance": "list_aggregate(list(nullif(tsbf_001.concat_ws('-', tsbf_tax1, tsbf_tax2, tsbf_tax3), '')), 'histogram')", @@ -106,11 +109,10 @@ "columns": { "geom": "start_point.merge().centroid()", "id": "_id", - "conf": "conf", - "proj": "proj", - "ecos": "ecos", - "region": "loc1", - "forest": "loc2", + "project": "proj", + "ecos": "int(ecos)", + "loc1": "int(loc1)", + "loc2": "int(loc2)", "start_date": "coh", "taxon": "tax", "type": "meth", diff --git a/webapp/src/features/indicators/bio-inventory/format-data.ts b/webapp/src/features/indicators/bio-inventory/format-data.ts index 679dcade..fe4e80f9 100644 --- a/webapp/src/features/indicators/bio-inventory/format-data.ts +++ b/webapp/src/features/indicators/bio-inventory/format-data.ts @@ -47,7 +47,7 @@ export const useFormatBioInventoryData = ( area: `${safeData.samp_area} ${ findLabel( metadata, - data.proj, + data.project, lang, "unit", Number(safeData.samp_unit), @@ -57,12 +57,12 @@ export const useFormatBioInventoryData = ( relative_abundance: taxons_relative_abundance, richness: formatWithUnit(safeData.richness, UNITS.speciesInventoried), taxon: - findLabel(metadata, data.proj, lang, "tax", Number(safeData.taxon)) || + findLabel(metadata, data.project, lang, "tax", Number(safeData.taxon)) || t("dataManagement.noUnit") || safeData.taxon, total_population: safeData.taxons_total_pop, type: - findLabel(metadata, data.proj, lang, "meth", Number(safeData.type)) || + findLabel(metadata, data.project, lang, "meth", Number(safeData.type)) || safeData.type, }; }; diff --git a/webapp/src/features/indicators/bio-inventory/use-bioinventory-indicator-elements.tsx b/webapp/src/features/indicators/bio-inventory/use-bioinventory-indicator-elements.tsx index 6cd90fec..793ec3af 100644 --- a/webapp/src/features/indicators/bio-inventory/use-bioinventory-indicator-elements.tsx +++ b/webapp/src/features/indicators/bio-inventory/use-bioinventory-indicator-elements.tsx @@ -52,12 +52,12 @@ export const useBioInventoryIndicatorElements = ( ), diff --git a/webapp/src/features/indicators/soil/format-data.ts b/webapp/src/features/indicators/soil/format-data.ts index d4e3ba5f..9afee444 100644 --- a/webapp/src/features/indicators/soil/format-data.ts +++ b/webapp/src/features/indicators/soil/format-data.ts @@ -35,7 +35,8 @@ export const useFormatSoilData = (data: ForestInventoryData) => { soil_fauna_density, soil_surface_fauna_diversity, soil_surface_fauna_density, - soil_eros_rainfall_and_wind, + soil_eros_rainfall, + soil_eros_wind, soil_eros_stability, soil_eros_water_infiltration, ...safeData @@ -74,13 +75,13 @@ export const useFormatSoilData = (data: ForestInventoryData) => { return { ...safeData, - soil_eros_rainfall: Number(soil_eros_rainfall_and_wind.split("-")[0]), + soil_eros_rainfall: soil_eros_rainfall, soil_eros_stability: soil_eros_stability, soil_eros_water_infiltration: String(soil_eros_water_infiltration) === t("dataManagement.noData") ? soil_eros_water_infiltration : computeScore(soil_eros_water_infiltration), - soil_eros_wind: Number(soil_eros_rainfall_and_wind.split("-")[1]), + soil_eros_wind: soil_eros_wind, soil_fauna_abundance: safeData.soil_fauna_abundance, soil_fauna_density: formatWithUnit( soil_fauna_density, diff --git a/webapp/src/features/indicators/soil/types.ts b/webapp/src/features/indicators/soil/types.ts index 4e9d0899..317d132a 100644 --- a/webapp/src/features/indicators/soil/types.ts +++ b/webapp/src/features/indicators/soil/types.ts @@ -4,7 +4,8 @@ export type SoilData = { soil_structure_idx: number; - soil_eros_rainfall_and_wind: string; + soil_eros_rainfall: number; + soil_eros_wind: number; soil_eros_cover: number; soil_eros_slope: number; soil_eros_stability: number; diff --git a/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx b/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx index 003ec52b..21051407 100644 --- a/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx +++ b/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx @@ -36,6 +36,11 @@ export const BioInventoryPopupContent: FC = ({ ns: "all4trees", }); + const ecos = `${t("all4trees:popup.forestInventory.ecos")}: ${ + findLabel(externalData.bio_label, data.project, lang, "ecos", data.ecos) || + t("dataManagement.undefined", { ns: "common" }) + }`; + return (
= ({ subtitle={ findLabel( externalData.bio_label, - data.proj, + data.project, lang, "loc2", - Number(data.forest), + Number(data.loc2), ) || t("dataManagement.undefined", { ns: "common" }) } + ecos={ecos} title={title} {...headerProps} /> diff --git a/webapp/src/features/popup/bio-inventory/types.ts b/webapp/src/features/popup/bio-inventory/types.ts index a43b0ce2..1aaf7455 100644 --- a/webapp/src/features/popup/bio-inventory/types.ts +++ b/webapp/src/features/popup/bio-inventory/types.ts @@ -1,13 +1,13 @@ export type BioInventoryData = { id: number; - conf: boolean; - proj: string; + loc1: number; + loc2: number; + type: number; + cohort: number; + project: string; ecos: number; - region: number; - forest: number; start_date: Date; taxon: string; - type: number; samp_area: number; samp_unit: number; density: number; diff --git a/webapp/src/features/popup/forest-inventory/popup-forest-inventory.tsx b/webapp/src/features/popup/forest-inventory/popup-forest-inventory.tsx index f8b96abe..af03985c 100644 --- a/webapp/src/features/popup/forest-inventory/popup-forest-inventory.tsx +++ b/webapp/src/features/popup/forest-inventory/popup-forest-inventory.tsx @@ -52,12 +52,12 @@ export const ForestInventoryPopupContent: FC< }; const title = t("popup.forestInventory.title", { - id: data.cod, + id: data.code, ns: "all4trees", }); const subtitle = - findLabel(labelData, data.project, lang, "loc2", data.for) || + findLabel(labelData, data.project, lang, "loc2", data.loc2) || t("common:dataManagement.undefined"); const ecos = `${t("all4trees:popup.forestInventory.ecos")}: ${ diff --git a/webapp/src/features/popup/forest-inventory/types.ts b/webapp/src/features/popup/forest-inventory/types.ts index 3073b3e9..8d7e90bd 100644 --- a/webapp/src/features/popup/forest-inventory/types.ts +++ b/webapp/src/features/popup/forest-inventory/types.ts @@ -3,8 +3,11 @@ import type { SoilData } from "@features/indicators/soil/types"; export type ForestInventoryData = { id: string; - for: number; - cod: number; + code: number; + type: number; + cohort: number; + loc1: number; + loc2: number; project: string; isPublic: boolean; ecos: number; From 7109caa0112261b876585a881d7142526fd560b0 Mon Sep 17 00:00:00 2001 From: Arnaud Fournier Date: Wed, 22 Jul 2026 23:31:01 +0200 Subject: [PATCH 2/5] Apply feedback on some labels --- .../popup/bio-inventory/popup-bio-inventory.tsx | 4 ++-- .../forest-inventory/popup-forest-inventory.tsx | 4 ++-- .../features/popup/socio-eco/popup-socio-eco.tsx | 2 +- .../src/shared/i18n/translations/en/all4trees.json | 14 +++++++------- .../src/shared/i18n/translations/fr/all4trees.json | 14 +++++++------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx b/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx index 21051407..7280d918 100644 --- a/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx +++ b/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx @@ -36,7 +36,7 @@ export const BioInventoryPopupContent: FC = ({ ns: "all4trees", }); - const ecos = `${t("all4trees:popup.forestInventory.ecos")}: ${ + const ecos = `${t("all4trees:popup.common.ecos")}: ${ findLabel(externalData.bio_label, data.project, lang, "ecos", data.ecos) || t("dataManagement.undefined", { ns: "common" }) }`; @@ -44,7 +44,7 @@ export const BioInventoryPopupContent: FC = ({ return (
= ({ return (
} subtitle={t("popup.socioEco.subtitleCount", { count: data.household_nb, diff --git a/webapp/src/shared/i18n/translations/en/all4trees.json b/webapp/src/shared/i18n/translations/en/all4trees.json index c33a3dd1..1e8473db 100644 --- a/webapp/src/shared/i18n/translations/en/all4trees.json +++ b/webapp/src/shared/i18n/translations/en/all4trees.json @@ -68,9 +68,9 @@ }, "bioinventory": { "sampArea": "Sampling area", - "status_abundance": "Relative abundance by extinction threat", + "status_abundance": "Relative abundance by UICN status", "taxon": "Target taxon", - "title": "Fauna inventory", + "title": "Biodiversity inventory", "type": "Measures type" }, "common": { @@ -223,17 +223,17 @@ "villages": "Villages" }, "popup": { + "common": { + "date": "Site survey date : {{ date }}", + "ecos": "Ecosystem" + }, "bioInventory": { - "date": "Survey date: {{ date }}", - "title": "Plot n°{{ id }}" + "title": "Site n°{{ id }}" }, "forestInventory": { - "date": "Site survey date : {{ date }}", - "ecos": "Ecosystem", "title": "Plot n°{{ id }}" }, "socioEco": { - "date": "Survey date: {{ date }}", "subtitleCount": "", "subtitleCount_one": "{{ count }} household surveyed", "subtitleCount_other": "{{ count }} households surveyed", diff --git a/webapp/src/shared/i18n/translations/fr/all4trees.json b/webapp/src/shared/i18n/translations/fr/all4trees.json index 762165d8..b34ab9ad 100644 --- a/webapp/src/shared/i18n/translations/fr/all4trees.json +++ b/webapp/src/shared/i18n/translations/fr/all4trees.json @@ -67,9 +67,9 @@ }, "bioinventory": { "sampArea": "Effort d'échantillonnage", - "status_abundance": "Abondance relative par menace d'extinction", + "status_abundance": "Abondance relative par statut UICN", "taxon": "Taxon cible", - "title": "Inventaire de faune", + "title": "Inventaire biologique", "type": "Type de dispositif" }, "common": { @@ -226,17 +226,17 @@ "villages": "Villages" }, "popup": { - "bioInventory": { + "common": { "date": "Date relevé: {{ date }}", - "title": "Placette n°{{ id }}" + "ecos": "Ecosystème" + }, + "bioInventory": { + "title": "Site n°{{ id }}" }, "forestInventory": { - "date": "Date relevé: {{ date }}", - "ecos": "Ecosystème", "title": "Placette n°{{ id }}" }, "socioEco": { - "date": "Date relevé: {{ date }}", "subtitleCount": "", "subtitleCount_one": "{{ count }} ménage enquêté", "subtitleCount_other": "{{ count }} ménages enquêtés", From 7a6bc7f32f7118ba8e8b7533d15aee4737daf324 Mon Sep 17 00:00:00 2001 From: Arnaud Fournier Date: Wed, 22 Jul 2026 23:31:26 +0200 Subject: [PATCH 3/5] Fix lint --- .../features/popup/bio-inventory/popup-bio-inventory.tsx | 2 +- webapp/src/shared/i18n/translations/en/all4trees.json | 6 +++--- webapp/src/shared/i18n/translations/fr/all4trees.json | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx b/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx index 7280d918..2b004928 100644 --- a/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx +++ b/webapp/src/features/popup/bio-inventory/popup-bio-inventory.tsx @@ -48,6 +48,7 @@ export const BioInventoryPopupContent: FC = ({ date: formatDate(new Date()), ns: "all4trees", })} + ecos={ecos} icon={} subtitle={ findLabel( @@ -58,7 +59,6 @@ export const BioInventoryPopupContent: FC = ({ Number(data.loc2), ) || t("dataManagement.undefined", { ns: "common" }) } - ecos={ecos} title={title} {...headerProps} /> diff --git a/webapp/src/shared/i18n/translations/en/all4trees.json b/webapp/src/shared/i18n/translations/en/all4trees.json index 1e8473db..ba0abcf7 100644 --- a/webapp/src/shared/i18n/translations/en/all4trees.json +++ b/webapp/src/shared/i18n/translations/en/all4trees.json @@ -223,13 +223,13 @@ "villages": "Villages" }, "popup": { + "bioInventory": { + "title": "Site n°{{ id }}" + }, "common": { "date": "Site survey date : {{ date }}", "ecos": "Ecosystem" }, - "bioInventory": { - "title": "Site n°{{ id }}" - }, "forestInventory": { "title": "Plot n°{{ id }}" }, diff --git a/webapp/src/shared/i18n/translations/fr/all4trees.json b/webapp/src/shared/i18n/translations/fr/all4trees.json index b34ab9ad..11aae3dd 100644 --- a/webapp/src/shared/i18n/translations/fr/all4trees.json +++ b/webapp/src/shared/i18n/translations/fr/all4trees.json @@ -226,13 +226,13 @@ "villages": "Villages" }, "popup": { + "bioInventory": { + "title": "Site n°{{ id }}" + }, "common": { "date": "Date relevé: {{ date }}", "ecos": "Ecosystème" }, - "bioInventory": { - "title": "Site n°{{ id }}" - }, "forestInventory": { "title": "Placette n°{{ id }}" }, From de8c09e9b7418e212ac0e30c9bc7525fcec5d13a Mon Sep 17 00:00:00 2001 From: Arnaud Fournier Date: Fri, 24 Jul 2026 02:43:42 +0200 Subject: [PATCH 4/5] Fix tree indicators --- backend/configs/all4trees_config.json | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/backend/configs/all4trees_config.json b/backend/configs/all4trees_config.json index fa5bebde..8a4fecc9 100644 --- a/backend/configs/all4trees_config.json +++ b/backend/configs/all4trees_config.json @@ -55,22 +55,19 @@ "loc1": "int(loc1)", "loc2": "int(loc2)", "ecos": "int(ecos)", - "plot_size": "for_samp.adu_samp", "project": "proj", "tree_pop": "count(1 if adu.cond = 1)", - "biomass_volume": "adu.sum(0.0673 * (for_sp.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 1) / (for_samp.adu_samp) / for_samp.adu_tot_max", - "tree_density": "count(1 if adu.cond = 1) / (for_samp.adu_samp)", + "biomass_volume": "adu.sum(0.0673 * (for_sp.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 1) / double(for_samp.adu_samp) / for_samp.adu_tot_max", + "tree_density": "count(1 if adu.cond = 1) / double(for_samp.adu_samp)", "richness": "count(unique(adu.adu_sp))", "relative_abundance": "histogram(adu.adu_sp)", - "deadwoord": "adu.count(1 if cond=2 or cond=3)", - "bio_idx_tree_density": "count(1 if adu.cond = 1) / (for_samp.adu_samp) / 100", + "bio_idx_tree_density": "count(1 if adu.cond = 1) / (double(for_samp.adu_samp) * 100)", "bio_idx_deadWood": "((adu.sum(0.0673 * (for_dw.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 2) + adu.sum(pi() / 3 * ((meas_b / 2)^2 + ((meas_e / 2)^2 + meas_b / 2 + meas_e / 2) * lght * for_dw.dens) if cond = 3)) / adu.sum(0.0673 * (for_sp.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 1)) / for_samp.tnc_agb_max * 10", "bio_idx_tree_diversity": "shannon(adu.adu_sp) / for_samp.shan_max * 10", - "test_gini": "adu.gini(int(area) if cond = 1) * 10", "bio_idx_spatial_distribution": "gini_arr(list_concat(list(adu.count(1 if cond=1 and area=1)), list(adu.count(1 if cond=1 and area=2)), list(adu.count(1 if cond=1 and area=3)), list(adu.count(1 if cond=1 and area=4)))) * 10", "bio_idx_diametric_distribution": "adu.gini(meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10) * 10", "bio_idx_vertical_distribution": "gini(adu.hgt_perp) * 10", - "bio_idx_dominant_height": "adu.avg(hgt_perp if hgt_perp >= percentile(hgt_perp, 80)) * 10 / for_samp.hgt_dom_max", + "bio_idx_dominant_height": "avg(adu.hgt_perp if adu.hgt_perp >= int(percentile(adu.hgt_perp, 80))) * 10 / for_samp.hgt_dom_max", "bio_idx_microhabitats": "adu.list(trem).flatten().filter( x -> x != 'None').list_unique() * 10 / trem_group_max", "soil_structure_idx": "(thk1*float(not1) + thk2*float(not2) + thk3*float(not3) + thk4*float(not4) + thk5*float(not5)) / (thk1 + thk2 + thk3 + thk4 + thk5)", "soil_eros_rainfall": "for_weath.rain", From 116b54138b1ac3f6ced4450fb4e81a245f538165 Mon Sep 17 00:00:00 2001 From: Arnaud Fournier Date: Sat, 25 Jul 2026 10:48:18 +0200 Subject: [PATCH 5/5] Add condition on tree formulas --- backend/configs/all4trees_config.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/configs/all4trees_config.json b/backend/configs/all4trees_config.json index 8a4fecc9..9ed40596 100644 --- a/backend/configs/all4trees_config.json +++ b/backend/configs/all4trees_config.json @@ -56,18 +56,18 @@ "loc2": "int(loc2)", "ecos": "int(ecos)", "project": "proj", - "tree_pop": "count(1 if adu.cond = 1)", + "tree_pop": "count(1 if adu.cond = 1 and adu.adu_sp != '0')", "biomass_volume": "adu.sum(0.0673 * (for_sp.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 1) / double(for_samp.adu_samp) / for_samp.adu_tot_max", - "tree_density": "count(1 if adu.cond = 1) / double(for_samp.adu_samp)", - "richness": "count(unique(adu.adu_sp))", + "tree_density": "count(1 if adu.cond = 1 and adu.adu_sp != '0') / double(for_samp.adu_samp)", + "richness": "count(unique(adu.adu_sp if adu.adu_sp != '0'))", "relative_abundance": "histogram(adu.adu_sp)", - "bio_idx_tree_density": "count(1 if adu.cond = 1) / (double(for_samp.adu_samp) * 100)", - "bio_idx_deadWood": "((adu.sum(0.0673 * (for_dw.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 2) + adu.sum(pi() / 3 * ((meas_b / 2)^2 + ((meas_e / 2)^2 + meas_b / 2 + meas_e / 2) * lght * for_dw.dens) if cond = 3)) / adu.sum(0.0673 * (for_sp.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 1)) / for_samp.tnc_agb_max * 10", - "bio_idx_tree_diversity": "shannon(adu.adu_sp) / for_samp.shan_max * 10", - "bio_idx_spatial_distribution": "gini_arr(list_concat(list(adu.count(1 if cond=1 and area=1)), list(adu.count(1 if cond=1 and area=2)), list(adu.count(1 if cond=1 and area=3)), list(adu.count(1 if cond=1 and area=4)))) * 10", + "bio_idx_tree_density": "count(1 if adu.cond = 1 and adu.adu_sp != '0') / (double(for_samp.adu_samp) * 100)", + "bio_idx_deadWood": "((adu.sum(0.0673 * (for_dw.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 2 and adu_sp != '0') + adu.sum(pi() / 3 * ((meas_b / 2)^2 + ((meas_e / 2)^2 + meas_b / 2 + meas_e / 2) * lght * for_dw.dens) if cond = 3 and adu_sp != '0')) / adu.sum(0.0673 * (for_sp.dens * (meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10)^2 * hgt_perp)^0.976 if cond = 1 and adu_sp != '0')) / for_samp.tnc_agb_max * 10", + "bio_idx_tree_diversity": "shannon(adu.adu_sp if adu.adu_sp != '0') / for_samp.shan_max * 10", + "bio_idx_spatial_distribution": "gini_arr(list_concat(list(adu.count(1 if cond=1 and area=1 and adu_sp != '0')), list(adu.count(1 if cond=1 and area=2 and adu_sp != '0')), list(adu.count(1 if cond=1 and area=3 and adu_sp != '0')), list(adu.count(1 if cond=1 and area=4 and adu_sp != '0')))) * 10", "bio_idx_diametric_distribution": "adu.gini(meas1 + meas2 + meas3 + meas4 + meas5 + meas6 + meas7 + meas8 + meas9 + meas10) * 10", - "bio_idx_vertical_distribution": "gini(adu.hgt_perp) * 10", - "bio_idx_dominant_height": "avg(adu.hgt_perp if adu.hgt_perp >= int(percentile(adu.hgt_perp, 80))) * 10 / for_samp.hgt_dom_max", + "bio_idx_vertical_distribution": "gini(adu.hgt_perp if adu.adu_sp != '0') * 10", + "bio_idx_dominant_height": "avg(adu.hgt_perp if adu.hgt_perp >= int(percentile(adu.hgt_perp, 80)) and adu.adu_sp != '0') * 10 / for_samp.hgt_dom_max", "bio_idx_microhabitats": "adu.list(trem).flatten().filter( x -> x != 'None').list_unique() * 10 / trem_group_max", "soil_structure_idx": "(thk1*float(not1) + thk2*float(not2) + thk3*float(not3) + thk4*float(not4) + thk5*float(not5)) / (thk1 + thk2 + thk3 + thk4 + thk5)", "soil_eros_rainfall": "for_weath.rain",