From 122e4e95e3ff5ad7bbada31a28c241d6b498eba8 Mon Sep 17 00:00:00 2001 From: frievoe97 Date: Wed, 18 Dec 2024 11:17:03 +0100 Subject: [PATCH] added estimatedReportedAndUnreportedCases --- src/views/v2/V2RunViewer.vue | 29 ++++++++++++++++++++ src/views/v2/WeeklyInfectionsPlot.vue | 38 ++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/views/v2/V2RunViewer.vue b/src/views/v2/V2RunViewer.vue index 0650004c..f6ac058a 100644 --- a/src/views/v2/V2RunViewer.vue +++ b/src/views/v2/V2RunViewer.vue @@ -208,6 +208,7 @@ :seedComparison="seedComparison" :showSeedComparison="showSeedComparison" :city="city" + :estimatedReportedAndUnreportedCases="estimatedReportedAndUnreportedCases" ) //- ---------- VIRUS STRAINS ------- @@ -673,6 +674,7 @@ export default defineComponent({ unreportedIncidence: [] as any[], unreportedIncidenceNRW: [] as any[], + estimatedReportedAndUnreportedCases: [] as any[], currentSituation: {} as any, loadedSeriesData: {} as any, @@ -1139,6 +1141,7 @@ export default defineComponent({ cityCap() { this.loadUnreportedIncidence() this.loadUnreportedIncidenceNRW() + this.loadEstimatedReportedAndUnreportedCases() }, async '$store.state.isWideMode'() { @@ -1842,6 +1845,32 @@ export default defineComponent({ } }, + async loadEstimatedReportedAndUnreportedCases() { + if (this.cityCap == 'Cologne') { + const url = + 'https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/episim/original-data/Fallzahlen/MaxvonKleist/EstimatedCasesMaxvonKleist.csv' + + try { + const response = await fetch(url) + const csvContents = await response.text() + this.estimatedReportedAndUnreportedCases = Papa.parse(csvContents, { + header: true, + dynamicTyping: true, + skipEmptyLines: true, + }).data + + this.estimatedReportedAndUnreportedCases = this.estimatedReportedAndUnreportedCases.map( + element => ({ + min_n_true: element.min_n_true, + date: element.date, + }) + ) + } catch (e) { + console.warn(e) + } + } + }, + async loadUnreportedIncidence() { if (this.cityCap == 'Cologne') { const url = diff --git a/src/views/v2/WeeklyInfectionsPlot.vue b/src/views/v2/WeeklyInfectionsPlot.vue index 3cd07fef..bd4379f7 100644 --- a/src/views/v2/WeeklyInfectionsPlot.vue +++ b/src/views/v2/WeeklyInfectionsPlot.vue @@ -27,6 +27,7 @@ export default defineComponent({ seedComparison: { type: Array as PropType, required: true }, unreportedIncidence: { type: Array as PropType, required: true }, unreportedIncidenceNRW: { type: Array as PropType, required: true }, + estimatedReportedAndUnreportedCases: { type: Array as PropType, required: true }, rkiDetectionData: { type: Object as PropType<{ x?: any[] @@ -438,6 +439,41 @@ export default defineComponent({ this.calculateUnreportedNRW() }, + addEstimatedReportedAndUnreportedCases() { + const totalPopulation = 82000000 + const incidencePer100k = 100000 + + if (!this.estimatedReportedAndUnreportedCases.length) return + + const estimatedReportedAndUnreportedCases: any = { + type: 'scatter', + mode: 'markers', + marker: { size: 4, color: '#ff0000' }, + x: [] as any, + y: [] as any, + } + + let sumMinNTrue = 0 + + for (let i = 3; i + 3 < this.estimatedReportedAndUnreportedCases.length; i = i + 7) { + for (let j = i - 3; j < i + 4; j++) { + sumMinNTrue += this.estimatedReportedAndUnreportedCases[j].min_n_true + } + + estimatedReportedAndUnreportedCases.x.push(this.estimatedReportedAndUnreportedCases[i].date) + estimatedReportedAndUnreportedCases.y.push( + sumMinNTrue / (totalPopulation / incidencePer100k) + ) + sumMinNTrue = 0 + } + + estimatedReportedAndUnreportedCases.name = + 'Estimated Reported and Unreported Cases (Germany, XX et al.)' + estimatedReportedAndUnreportedCases.visible = true + + this.dataLines.push(estimatedReportedAndUnreportedCases) + }, + calculateSeedComparison(factor100k: number) { if (this.seedComparison.length == 0) return @@ -652,8 +688,8 @@ export default defineComponent({ if (this.rkiDetectionData.x) this.dataLines.push(this.rkiDetectionData) this.calculateSeedComparison(factor100k) - this.calculateObserved(factor100k) + this.addEstimatedReportedAndUnreportedCases() }, reformatDate(day: string) {