From 021b48a088a09f5bf433b3da3f3a0ae3c3ecdbaf Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Wed, 14 Aug 2024 21:51:40 -0700 Subject: [PATCH 1/9] feat: add dowa data --- .../src/assets/summaries/{dowa.agr.csv => dowa_agr.csv} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/picsa-tools/climate-tool/src/assets/summaries/{dowa.agr.csv => dowa_agr.csv} (100%) diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/dowa.agr.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/dowa_agr.csv similarity index 100% rename from apps/picsa-tools/climate-tool/src/assets/summaries/dowa.agr.csv rename to apps/picsa-tools/climate-tool/src/assets/summaries/dowa_agr.csv From fceb3e9e0c9107abda006c39ee3891544c528e3f Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Wed, 14 Aug 2024 21:52:19 -0700 Subject: [PATCH 2/9] refactor: computed station lists --- .../pages/site-select/site-select.page.html | 2 +- .../app/pages/site-select/site-select.page.ts | 42 +++++++------------ .../app/pages/site-view/site-view.page.html | 2 +- .../src/app/pages/site-view/site-view.page.ts | 11 +++-- .../src/app/services/climate-data.service.ts | 28 +++++++++---- 5 files changed, 41 insertions(+), 44 deletions(-) diff --git a/apps/picsa-tools/climate-tool/src/app/pages/site-select/site-select.page.html b/apps/picsa-tools/climate-tool/src/app/pages/site-select/site-select.page.html index f10625ab4..94ba77990 100644 --- a/apps/picsa-tools/climate-tool/src/app/pages/site-select/site-select.page.html +++ b/apps/picsa-tools/climate-tool/src/app/pages/site-select/site-select.page.html @@ -4,7 +4,7 @@ (onMarkerClick)="onMarkerClick($event)" [mapOptions]="mapOptions" [basemapOptions]="basemapOptions" - [markers]="mapMarkers" + [markers]="mapMarkers()" #picsaMap > diff --git a/apps/picsa-tools/climate-tool/src/app/pages/site-select/site-select.page.ts b/apps/picsa-tools/climate-tool/src/app/pages/site-select/site-select.page.ts index e89826ce7..f3cbae854 100644 --- a/apps/picsa-tools/climate-tool/src/app/pages/site-select/site-select.page.ts +++ b/apps/picsa-tools/climate-tool/src/app/pages/site-select/site-select.page.ts @@ -1,10 +1,9 @@ -import { Component, NgZone, OnInit, ViewChild } from '@angular/core'; +import { Component, computed, NgZone, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; -import { ConfigurationService } from '@picsa/configuration'; import { IStationMeta } from '@picsa/models'; import { IBasemapOptions, IMapMarker, IMapOptions, PicsaMapComponent } from '@picsa/shared/features/map/map'; -import { HARDCODED_STATIONS } from '../../data'; +import { ClimateDataService } from '../../services/climate-data.service'; @Component({ selector: 'climate-site-select', @@ -21,17 +20,25 @@ export class SiteSelectPage implements OnInit { src: 'assets/mapTiles/raw/{z}/{x}/{y}.webp', maxNativeZoom: 8, }; - mapMarkers: IMapMarker[] = []; + public mapMarkers = computed(() => { + const stations = this.dataService.stations(); + const markers: IMapMarker[] = stations.map((station, _index) => ({ + latlng: [station.latitude, station.longitude], + data: station, + number: _index + 1, + _index, + })); + return markers; + }); constructor( private ngZone: NgZone, private router: Router, private route: ActivatedRoute, - private configurationService: ConfigurationService + private dataService: ClimateDataService ) {} ngOnInit() { - this.populateSites(); this.getUserLocationAndSelectClosestStation(); } @@ -56,27 +63,6 @@ export class SiteSelectPage implements OnInit { }); } - populateSites() { - let stations = HARDCODED_STATIONS; - const { climateTool, country_code } = this.configurationService.deploymentSettings(); - const filterFn = climateTool?.station_filter; - if (filterFn) { - stations = stations.filter((station) => filterFn(station)); - } else { - stations = stations.filter((station) => station.countryCode === country_code); - } - const markers: IMapMarker[] = stations.map((station, _index) => { - return { - latlng: [station.latitude, station.longitude], - data: station, - number: _index + 1, - _index, - }; - }); - this.mapMarkers = markers; - return { stations, markers }; - } - private getUserLocationAndSelectClosestStation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( @@ -97,7 +83,7 @@ export class SiteSelectPage implements OnInit { private selectClosestStation(userLat: number, userLng: number) { let minDistance = Number.MAX_VALUE; - const nearest = this.mapMarkers.reduce((previous, current) => { + const nearest = this.mapMarkers().reduce((previous, current) => { const stationLat = current.latlng[0]; const stationLng = current.latlng[1]; const distance = this.calculateDistance(userLat, userLng, stationLat, stationLng); diff --git a/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.html b/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.html index 76a1b44d4..6dc51c701 100644 --- a/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.html +++ b/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.html @@ -14,7 +14,7 @@ (selectionChange)="handleStationSelect(select.value)" [value]="chartService.station?.id" > - @for(option of stationSelectOptions; track option.value){ + @for(option of stationSelectOptions(); track option.value){ {{option.label}} } diff --git a/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.ts b/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.ts index 5d22274da..cce25c2c3 100644 --- a/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.ts +++ b/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.ts @@ -4,6 +4,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, + computed, effect, OnDestroy, TemplateRef, @@ -39,12 +40,10 @@ interface ISiteViewParams { export class ClimateSiteViewComponent implements OnDestroy, AfterViewInit { public showRotateAnimation = false; - public stationSelectOptions = Object.entries(this.dataService.dataByStation) - .map(([id, data]) => ({ - value: id, - label: data.name, - })) - .sort((a, b) => (a.label > b.label ? 1 : -1)); + public stationSelectOptions = computed(() => { + const stations = this.dataService.stations(); + return stations.map(({ id, name }) => ({ value: id, label: name })).sort((a, b) => (a.label > b.label ? 1 : -1)); + }); private viewId = toSignal(this.route.queryParams.pipe(map(({ view }: ISiteViewQueryParams) => view))); private siteId = toSignal(this.route.params.pipe(map(({ siteId }: ISiteViewParams) => siteId))); diff --git a/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts b/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts index 3b7691a8f..a945221b7 100644 --- a/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts +++ b/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts @@ -1,4 +1,5 @@ -import { Injectable } from '@angular/core'; +import { computed, Injectable } from '@angular/core'; +import { ConfigurationService } from '@picsa/configuration'; import { IChartMeta, IStationData, IStationMeta } from '@picsa/models'; import { arrayToHashmap, loadCSV } from '@picsa/utils'; @@ -9,14 +10,26 @@ export class ClimateDataService { public activeChart: IChartMeta; public yValues: number[]; - public dataByStation: { [name: string]: IStationMeta } = {}; + /** Store populated station data to in-memory cache for fast future retrieval*/ + private stationDataCache: { [name: string]: IStationMeta } = {}; - constructor() { - this.dataByStation = arrayToHashmap(DATA.HARDCODED_STATIONS, 'id'); + /** List of all stations for current */ + public stations = computed(() => { + const { climateTool, country_code } = this.configurationService.deploymentSettings(); + const filterFn = climateTool?.station_filter; + if (filterFn) { + return DATA.HARDCODED_STATIONS.filter((station) => filterFn(station)); + } else { + return DATA.HARDCODED_STATIONS.filter((station) => station.countryCode === country_code); + } + }); + + constructor(private configurationService: ConfigurationService) { + this.stationDataCache = arrayToHashmap(DATA.HARDCODED_STATIONS, 'id'); } public async getStationMeta(stationID: string): Promise { - const station = this.dataByStation[stationID]; + const station = this.stationDataCache[stationID]; if (!station) { console.error('No data for station'); return { data: [] as any[], name: 'Data not found' } as IStationMeta; @@ -24,13 +37,12 @@ export class ClimateDataService { if (!station.data) { console.log('[Climate] Load Data', stationID); const summaries = await this.loadStationSummaries(stationID); - this.dataByStation[stationID].data = summaries; + this.stationDataCache[stationID].data = summaries; } // HACK - ensure chart definitions don't persist across sites - return JSON.parse(JSON.stringify(this.dataByStation[stationID])); + return JSON.parse(JSON.stringify(this.stationDataCache[stationID])); } private async loadStationSummaries(stationID: string) { - // TODO - ensure still working return loadCSV(`assets/summaries/${stationID}.csv`, { download: true, dynamicTyping: true, From c500272a1d455510f7d6c09917c2c0779a286305 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Wed, 14 Aug 2024 21:52:37 -0700 Subject: [PATCH 3/9] chore: disable tj country data --- libs/data/deployments/countries.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libs/data/deployments/countries.ts b/libs/data/deployments/countries.ts index dc14e0b73..25862d210 100644 --- a/libs/data/deployments/countries.ts +++ b/libs/data/deployments/countries.ts @@ -15,11 +15,14 @@ const COUNTRIES_BASE: { [key in ICountryCode]: { label: string } } = { tj: { label: 'Tajikistan' }, }; -export const COUNTRIES_DATA = Object.entries(COUNTRIES_BASE).map(([id, { label }]) => ({ - id: id as ICountryCode, - label, - flag_path: `assets/images/flags/${id}.svg`, -})); +export const COUNTRIES_DATA = Object.entries(COUNTRIES_BASE) + .map(([id, { label }]) => ({ + id: id as ICountryCode, + label, + flag_path: `assets/images/flags/${id}.svg`, + })) + // HACK - remove Tajikistan data as not currently in use + .filter((c) => c.id !== 'tj'); export type ICountriesDataEntry = typeof COUNTRIES_DATA[0]; export const COUNTRIES_DATA_HASHMAP = arrayToHashmap(COUNTRIES_DATA, 'id') as { [code in ICountryCode]: ICountriesDataEntry; From 880fa38a3e242140f5365c27f960bf10ebd88bd7 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Wed, 14 Aug 2024 22:28:53 -0700 Subject: [PATCH 4/9] chore: clean missing values --- .../src/app/services/climate-data.service.ts | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts b/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts index a945221b7..7c5a187ea 100644 --- a/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts +++ b/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts @@ -37,16 +37,43 @@ export class ClimateDataService { if (!station.data) { console.log('[Climate] Load Data', stationID); const summaries = await this.loadStationSummaries(stationID); - this.stationDataCache[stationID].data = summaries; + const cleaned = this.hackCleanMissingValues(summaries); + this.stationDataCache[stationID].data = cleaned; } // HACK - ensure chart definitions don't persist across sites return JSON.parse(JSON.stringify(this.stationDataCache[stationID])); } + + /** + * Remove data entries where 1 of start, end, length or rainfall not defined + * This may be a null value, or 0 entry + */ + private hackCleanMissingValues(data: IStationData[]) { + return data.map((el) => { + const { Start, End, Rainfall, Length } = el; + const isMissingData = !Start || !End || !Rainfall || !Length; + if (isMissingData) { + el.Start = null as any; + el.End = null as any; + el.Length = null as any; + el.Rainfall = null as any; + } + return el; + }); + } + private async loadStationSummaries(stationID: string) { return loadCSV(`assets/summaries/${stationID}.csv`, { download: true, dynamicTyping: true, header: true, + transform: (v) => { + // Ensure null string parsed + if (v === 'null') return null; + // HACK - replace 0 with null value + if (v === '0') return null; + return v; + }, }); } } From 10e8ac4632dc9acd6fa5e2927d54f84b86d99aa0 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Wed, 14 Aug 2024 22:29:56 -0700 Subject: [PATCH 5/9] chore: remove null values --- .../src/assets/summaries/bunda.csv | 22 ++-- .../src/assets/summaries/chapananga.csv | 6 +- .../src/assets/summaries/chikwawa.csv | 12 +- .../src/assets/summaries/chipoka.csv | 34 +++--- .../src/assets/summaries/chiradzulu.csv | 4 +- .../src/assets/summaries/chitala.csv | 32 +++--- .../src/assets/summaries/chitedze.csv | 6 +- .../src/assets/summaries/dowa_agr.csv | 8 +- .../src/assets/summaries/golomoti.csv | 108 +++++++++--------- .../src/assets/summaries/kamuona.csv | 22 ++-- .../src/assets/summaries/kasinthula.csv | 8 +- .../src/assets/summaries/kasiya.csv | 2 +- .../climate-tool/src/assets/summaries/kia.csv | 6 +- .../src/assets/summaries/luwazi.csv | 22 ++-- .../src/assets/summaries/mponela.csv | 10 +- .../src/assets/summaries/mtakataka.csv | 66 +++++------ .../src/assets/summaries/mzandu.csv | 30 ++--- .../src/assets/summaries/nalunga.csv | 4 +- .../src/assets/summaries/ndakwera.csv | 2 +- .../src/assets/summaries/ngabu.csv | 4 +- .../src/assets/summaries/nkhatabay.csv | 10 +- .../src/assets/summaries/salima.csv | 4 +- 22 files changed, 211 insertions(+), 211 deletions(-) diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/bunda.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/bunda.csv index 578655d3d..86ec6df76 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/bunda.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/bunda.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1966,516.5,null,287,null +1966,516.5,,287, 1967,649.5,133,285,152 1968,1224.7,135,300,165 1969,619.5,156,253,97 @@ -21,7 +21,7 @@ Year,Rainfall,Start,End,Length 1985,1060.3,139,303,164 1986,764.9,181,276,95 1987,171.3,193,193,0 -1988,768.7,null,291,null +1988,768.7,,291, 1989,1030.4,134,304,170 1990,759.9,148,281,133 1991,805.1,149,271,122 @@ -31,8 +31,8 @@ Year,Rainfall,Start,End,Length 1995,750.4,164,285,121 1996,1099.2,156,280,124 1997,934,146,273,127 -1998,499.8,176,null,null -1999,601,null,285,null +1998,499.8,176,, +1999,601,,285, 2000,559.3,195,278,83 2001,482,172,238,66 2002,1002.6,164,275,111 @@ -43,10 +43,10 @@ Year,Rainfall,Start,End,Length 2007,937.7,173,285,112 2008,999.9,133,278,145 2009,766.1,183,259,76 -2010,933.6,159,null,null -2011,468.9,null,null,null -2012,970.9,null,294,null -2013,0,null,null,null -2014,651.3,null,290,null -2015,77.4,null,null,null -2016,333.7,null,275,null \ No newline at end of file +2010,933.6,159,, +2011,468.9,,, +2012,970.9,,294, +2013,0,,, +2014,651.3,,290, +2015,77.4,,, +2016,333.7,,275, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/chapananga.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/chapananga.csv index 04a217bf7..7484c9199 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/chapananga.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/chapananga.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1952,565.7,null,298,null +1952,565.7,,298, 1953,626.4,152,274,122 1954,913.6,161,303,142 1955,774.5,144,297,153 @@ -62,8 +62,8 @@ Year,Rainfall,Start,End,Length 2012,2313.3,162,285,123 2013,3684.9,166,288,122 2014,3213.5,163,263,100 -2015,449.2,null,266,null +2015,449.2,,266, 2016,836.6,149,268,119 2017,543.8,134,271,137 2018,951.4,146,259,113 -2019,180.1,null,184,null \ No newline at end of file +2019,180.1,,184, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/chikwawa.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/chikwawa.csv index d2a998c69..f5f724aa3 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/chikwawa.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/chikwawa.csv @@ -1,8 +1,8 @@ Year,Rainfall,Start,End,Length -1966,102.2,null,297,null -1967,0,null,null,null -1968,0,null,null,null -1969,0,null,null,null +1966,102.2,,297, +1967,0,,, +1968,0,,, +1969,0,,, 1970,836.1,168,303,135 1971,481.2,181,261,80 1972,611.3,129,291,162 @@ -43,7 +43,7 @@ Year,Rainfall,Start,End,Length 2007,717.7,163,261,98 2008,815.1,169,286,117 2009,404,144,299,155 -2010,663.3,null,284,null +2010,663.3,,284, 2011,684.5,169,287,118 2012,804.1,159,231,72 2013,750.6,166,281,115 @@ -55,4 +55,4 @@ Year,Rainfall,Start,End,Length 2019,817.8,146,240,94 2020,580.1,186,302,116 2021,1008.6,191,272,81 -2022,0,null,null,null \ No newline at end of file +2022,0,,, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/chipoka.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/chipoka.csv index 710600689..3b9847988 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/chipoka.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/chipoka.csv @@ -1,27 +1,27 @@ Year,Rainfall,Start,End,Length -1982,289.9,null,null,null -1983,645.1,null,251,null -1984,860.2,null,null,null -1985,821.7,null,null,null -1986,810,null,null,null -1987,860.8,null,279,null -1988,830.3,null,null,null -1989,623.4,null,282,null -1990,936.2,null,271,null +1982,289.9,,, +1983,645.1,,251, +1984,860.2,,, +1985,821.7,,, +1986,810,,, +1987,860.8,,279, +1988,830.3,,, +1989,623.4,,282, +1990,936.2,,271, 1991,623.5,163,297,134 -1992,888.3,null,294,null -1993,583.9,null,null,null -1994,702.1,null,null,null -1995,775.3,null,259,null +1992,888.3,,294, +1993,583.9,,, +1994,702.1,,, +1995,775.3,,259, 1996,731.3,166,285,119 -1997,854.1,null,null,null -1998,744.4,null,274,null -1999,738.6,null,290,null +1997,854.1,,, +1998,744.4,,274, +1999,738.6,,290, 2000,1107.4,142,279,137 2001,789.3,141,267,126 2002,1174.1,164,271,107 2003,688.8,153,293,140 -2004,856.2,139,null,null +2004,856.2,139,, 2005,1132.3,150,272,122 2006,875.5,141,304,163 2007,1054.1,160,247,87 diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/chiradzulu.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/chiradzulu.csv index 287b1c7e0..ec21af2b7 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/chiradzulu.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/chiradzulu.csv @@ -40,8 +40,8 @@ Year,Rainfall,Start,End,Length 1987,775.6,177,301,124 1988,682.7,171,276,105 1989,481.1,138,298,160 -1990,180.7,null,301,null -1991,0,null,null,null +1990,180.7,,301, +1991,0,,, 1992,654.7,166,288,122 1993,568.6,195,300,105 1994,838.9,156,269,113 diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/chitala.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/chitala.csv index 6620f1694..020d53f05 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/chitala.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/chitala.csv @@ -1,17 +1,17 @@ Year,Rainfall,Start,End,Length -1945,300.8,null,null,null -1946,974.5,null,280,null +1945,300.8,,, +1946,974.5,,280, 1947,879.1,155,288,133 1948,471.2,177,301,124 1949,1697.8,179,283,104 1950,746.7,152,276,124 1951,1028.6,153,293,140 1952,644.1,180,259,79 -1953,663.6,null,257,null +1953,663.6,,257, 1954,672.8,196,282,86 -1955,515.9,null,281,null -1956,0,null,null,null -1957,779.6,null,247,null +1955,515.9,,281, +1956,0,,, +1957,779.6,,247, 1958,867,172,254,82 1959,979.8,212,266,54 1960,742.7,166,296,130 @@ -46,24 +46,24 @@ Year,Rainfall,Start,End,Length 1989,899.1,153,278,125 1990,926.9,180,282,102 1991,619.4,153,268,115 -1992,957,null,295,null -1993,680.8,null,null,null -1994,530,null,null,null -1995,889.8,null,261,null +1992,957,,295, +1993,680.8,,, +1994,530,,, +1995,889.8,,261, 1996,713.6,172,283,111 -1997,824.5,null,null,null -1998,803.8,null,285,null +1997,824.5,,, +1998,803.8,,285, 1999,834.5,166,285,119 2000,993.3,148,276,128 2001,883.8,138,269,131 2002,1024.3,158,271,113 -2003,723,null,293,null -2004,748.7,147,null,null -2005,1069.5,null,272,null +2003,723,,293, +2004,748.7,147,, +2005,1069.5,,272, 2006,997,149,269,120 2007,787.4,160,261,101 2008,809.4,151,265,114 -2009,761.9,null,275,null +2009,761.9,,275, 2010,851.4,147,271,124 2011,1035.5,157,277,120 2012,731.8,165,262,97 diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/chitedze.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/chitedze.csv index 5f62e8a77..0c348536e 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/chitedze.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/chitedze.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1959,486.7,null,264,null +1959,486.7,,264, 1960,1055.5,146,303,157 1961,1029.9,140,291,151 1962,807.6,157,272,115 @@ -59,7 +59,7 @@ Year,Rainfall,Start,End,Length 2016,850.1,159,254,95 2017,935.4,149,283,134 2018,713,161,268,107 -2019,831.1,null,272,null +2019,831.1,,272, 2020,796.2,163,267,104 2021,735.4,192,282,90 -2022,null,null,null,null \ No newline at end of file +2022,,,, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/dowa_agr.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/dowa_agr.csv index 841fd6f56..fbe300f94 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/dowa_agr.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/dowa_agr.csv @@ -15,8 +15,8 @@ Year,Rainfall,Start,End,Length 1973,1114.4,171,278,107 1974,750.2,160,279,119 1975,951.8,166,287,121 -1976,0,null,null,null -1977,0,null,null,null +1976,0,,, +1977,0,,, 1978,809.8,145,272,127 1979,816,152,294,142 1980,812.3,156,268,112 @@ -60,5 +60,5 @@ Year,Rainfall,Start,End,Length 2018,1160.8,164,305,141 2019,900.2,152,258,106 2020,828,164,266,102 -2021,590.4,null,null,null -2022,0,null,null,null \ No newline at end of file +2021,590.4,,, +2022,0,,, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/golomoti.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/golomoti.csv index 91b2d4ac9..2e50600f4 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/golomoti.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/golomoti.csv @@ -1,30 +1,30 @@ Year,Rainfall,Start,End,Length -1926,0,null,null,null -1927,0,null,null,null -1928,0,null,null,null -1929,0,null,null,null -1930,0,null,null,null -1931,0,null,null,null -1932,0,null,null,null -1933,0,null,null,null -1934,702.7,null,298,null -1935,1193.5,null,290,null -1936,774.5,null,299,null -1937,1037.1,null,287,null -1938,1315.4,null,280,null +1926,0,,, +1927,0,,, +1928,0,,, +1929,0,,, +1930,0,,, +1931,0,,, +1932,0,,, +1933,0,,, +1934,702.7,,298, +1935,1193.5,,290, +1936,774.5,,299, +1937,1037.1,,287, +1938,1315.4,,280, 1939,1215.4,142,293,151 1940,727.4,106,281,175 -1941,690.3,null,302,null -1942,907.7,null,296,null -1943,514.8,null,null,null -1944,0,null,null,null -1945,0,null,null,null -1946,0,null,null,null -1947,683,null,304,null +1941,690.3,,302, +1942,907.7,,296, +1943,514.8,,, +1944,0,,, +1945,0,,, +1946,0,,, +1947,683,,304, 1948,411.2,217,267,50 1949,1291.8,160,284,124 1950,1015.3,163,261,98 -1951,1122.2,null,293,null +1951,1122.2,,293, 1952,720.6,151,273,122 1953,872.9,154,302,148 1954,1263.2,134,304,170 @@ -44,15 +44,15 @@ Year,Rainfall,Start,End,Length 1968,1011.9,164,299,135 1969,750.5,153,293,140 1970,839.5,149,256,107 -1971,706.8,null,289,null +1971,706.8,,289, 1972,883.4,157,284,127 1973,1078.4,159,276,117 1974,860.1,146,279,133 1975,1373.2,149,297,148 1976,1030.8,163,263,100 1977,1520.4,150,278,128 -1978,0,null,null,null -1979,0,null,null,null +1978,0,,, +1979,0,,, 1980,1087,157,255,98 1981,1005.5,183,295,112 1982,906.5,151,291,140 @@ -63,33 +63,33 @@ Year,Rainfall,Start,End,Length 1987,1061.6,151,287,136 1988,1385.1,104,275,171 1989,1129,137,299,162 -1990,0,null,null,null -1991,168.8,null,null,null -1992,509.4,null,294,null -1993,456.9,null,276,null -1994,429.6,null,280,null -1995,569.1,null,null,null -1996,465.4,null,null,null -1997,537.3,null,null,null -1998,579.1,null,null,null -1999,0,null,null,null -2000,789.7,null,null,null -2001,850.9,null,null,null -2002,0,null,null,null -2003,0,null,null,null -2004,0,null,null,null -2005,0,null,null,null -2006,0,null,null,null -2007,162.4,null,null,null -2008,523.9,null,null,null -2009,630.5,null,null,null -2010,129,null,null,null -2011,0,null,null,null -2012,0,null,null,null -2013,0,null,null,null -2014,0,null,null,null -2015,0,null,null,null -2016,0,null,null,null -2017,0,null,null,null -2018,0,null,null,null -2019,0,null,null,null \ No newline at end of file +1990,0,,, +1991,168.8,,, +1992,509.4,,294, +1993,456.9,,276, +1994,429.6,,280, +1995,569.1,,, +1996,465.4,,, +1997,537.3,,, +1998,579.1,,, +1999,0,,, +2000,789.7,,, +2001,850.9,,, +2002,0,,, +2003,0,,, +2004,0,,, +2005,0,,, +2006,0,,, +2007,162.4,,, +2008,523.9,,, +2009,630.5,,, +2010,129,,, +2011,0,,, +2012,0,,, +2013,0,,, +2014,0,,, +2015,0,,, +2016,0,,, +2017,0,,, +2018,0,,, +2019,0,,, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/kamuona.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/kamuona.csv index 32a416a74..1d545ccdd 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/kamuona.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/kamuona.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1980,1607.8,null,271,null +1980,1607.8,,271, 1981,807.7,166,296,130 1982,1048.8,135,282,147 1983,821.4,166,296,130 @@ -8,27 +8,27 @@ Year,Rainfall,Start,End,Length 1986,1107.7,185,284,99 1987,1241.1,152,303,151 1988,1289.5,183,292,109 -1989,815.2,null,299,null +1989,815.2,,299, 1990,968.1,173,279,106 1991,739.6,153,268,115 1992,1045.8,162,296,134 -1993,677.2,null,295,null -1994,523,null,null,null -1995,1279.3,null,281,null +1993,677.2,,295, +1994,523,,, +1995,1279.3,,281, 1996,850.5,159,283,124 -1997,879.1,null,null,null -1998,818.4,null,279,null -1999,737,null,268,null +1997,879.1,,, +1998,818.4,,279, +1999,737,,268, 2000,961.1,166,277,111 2001,923.7,141,269,128 2002,1120.7,158,273,115 2003,811.6,153,259,106 -2004,882,147,null,null -2005,991.4,null,277,null +2004,882,147,, +2005,991.4,,277, 2006,1009.3,148,269,121 2007,873.3,160,262,102 2008,1008.9,170,275,105 -2009,769.1,null,275,null +2009,769.1,,275, 2010,889.5,147,283,136 2011,987.9,172,277,105 2012,686.4,164,262,98 diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/kasinthula.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/kasinthula.csv index 5fa6e8fa9..ec68ac3d2 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/kasinthula.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/kasinthula.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1952,693.2,null,295,null +1952,693.2,,295, 1953,472.1,135,275,140 1954,921.7,133,304,171 1955,731.9,233,297,64 @@ -16,7 +16,7 @@ Year,Rainfall,Start,End,Length 1966,1063.9,208,298,90 1967,409.9,198,294,96 1968,802.7,134,283,149 -1969,0,null,null,null +1969,0,,, 1970,954.5,148,270,122 1971,554.1,154,285,131 1972,582.9,148,291,143 @@ -44,7 +44,7 @@ Year,Rainfall,Start,End,Length 1994,574.1,158,276,118 1995,1330,164,280,116 1996,1425.1,151,278,127 -1997,610.9,null,263,null +1997,610.9,,263, 1998,943.3,151,276,125 1999,665.9,189,264,75 2000,1108.4,119,281,162 @@ -58,7 +58,7 @@ Year,Rainfall,Start,End,Length 2008,744.5,165,276,111 2009,372.5,146,277,131 2010,873.1,147,279,132 -2011,661.9,null,276,null +2011,661.9,,276, 2012,714.1,158,247,89 2013,630,167,278,111 2014,960.3,162,269,107 diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/kasiya.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/kasiya.csv index 39cf94cb3..af6bda8fe 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/kasiya.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/kasiya.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1982,455.9,null,282,null +1982,455.9,,282, 1983,830.6,147,271,124 1984,1020.3,160,274,114 1985,1032.3,134,303,169 diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/kia.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/kia.csv index b8cb2095f..3d6c32527 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/kia.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/kia.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1960,611.4,null,303,null +1960,611.4,,303, 1961,900.4,140,282,142 1962,828.3,132,259,127 1963,658.4,171,269,98 @@ -60,5 +60,5 @@ Year,Rainfall,Start,End,Length 2018,902,164,285,121 2019,927.5,149,262,113 2020,793.4,153,273,120 -2021,450.3,null,null,null -2022,0,null,null,null \ No newline at end of file +2021,450.3,,, +2022,0,,, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/luwazi.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/luwazi.csv index 4e25bc8bf..63fc648c9 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/luwazi.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/luwazi.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1949,741.7,null,297,null +1949,741.7,,297, 1950,1384,177,302,125 1951,1629,151,300,149 1952,1135,187,304,117 @@ -7,17 +7,17 @@ Year,Rainfall,Start,End,Length 1954,1162.7,167,297,130 1955,1713,164,305,141 1956,1235.8,158,296,138 -1957,0,null,null,null +1957,0,,, 1958,1103.2,198,293,95 -1959,0,null,null,null -1960,0,null,null,null -1961,0,null,null,null -1962,0,null,null,null -1963,0,null,null,null -1964,0,null,null,null -1965,0,null,null,null -1966,0,null,null,null -1967,0,null,null,null +1959,0,,, +1960,0,,, +1961,0,,, +1962,0,,, +1963,0,,, +1964,0,,, +1965,0,,, +1966,0,,, +1967,0,,, 1968,1094.9,187,301,114 1969,1124.1,123,290,167 1970,1244.5,150,297,147 diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/mponela.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/mponela.csv index 7ade3b5b4..a373644c2 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/mponela.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/mponela.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1959,415.2,null,252,null +1959,415.2,,252, 1960,646.8,165,273,108 1961,799.1,161,270,109 1962,767.3,175,295,120 @@ -49,7 +49,7 @@ Year,Rainfall,Start,End,Length 2006,851.1,137,268,131 2007,1011.8,160,258,98 2008,777.4,163,264,101 -2009,962,null,286,null +2009,962,,286, 2010,632.5,158,260,102 2011,699.8,129,275,146 2012,667.9,165,271,106 @@ -57,9 +57,9 @@ Year,Rainfall,Start,End,Length 2014,624.1,183,280,97 2015,547.1,158,278,120 2016,793.2,154,268,114 -2017,574.2,null,278,null +2017,574.2,,278, 2018,776.5,155,269,114 2019,657.8,180,239,59 2020,681.7,185,269,84 -2021,568,null,261,null -2022,0,null,null,null \ No newline at end of file +2021,568,,261, +2022,0,,, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/mtakataka.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/mtakataka.csv index 1401235ee..effbd89c7 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/mtakataka.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/mtakataka.csv @@ -1,31 +1,31 @@ Year,Rainfall,Start,End,Length -1926,0,null,null,null -1927,0,null,null,null -1928,0,null,null,null -1929,0,null,null,null -1930,0,null,null,null -1931,0,null,null,null -1932,0,null,null,null -1933,0,null,null,null -1934,0,null,null,null -1935,0,null,null,null -1936,0,null,null,null -1937,0,null,null,null -1938,0,null,null,null -1939,0,null,null,null -1940,0,null,null,null -1941,0,null,null,null -1942,0,null,null,null -1943,0,null,null,null -1944,0,null,null,null -1945,0,null,null,null -1946,0,null,null,null -1947,683,null,304,null +1926,0,,, +1927,0,,, +1928,0,,, +1929,0,,, +1930,0,,, +1931,0,,, +1932,0,,, +1933,0,,, +1934,0,,, +1935,0,,, +1936,0,,, +1937,0,,, +1938,0,,, +1939,0,,, +1940,0,,, +1941,0,,, +1942,0,,, +1943,0,,, +1944,0,,, +1945,0,,, +1946,0,,, +1947,683,,304, 1948,414.5,178,260,82 1949,1186.6,161,276,115 1950,963.5,162,268,106 -1951,709.2,null,271,null -1952,626.1,null,295,null +1951,709.2,,271, +1952,626.1,,295, 1953,831.3,154,274,120 1954,891.6,139,256,117 1955,555.9,243,282,39 @@ -63,21 +63,21 @@ Year,Rainfall,Start,End,Length 1987,1180,157,287,130 1988,863.3,210,300,90 1989,922.3,154,275,121 -1990,689,null,282,null +1990,689,,282, 1991,223.8,188,210,22 1992,1086.2,168,289,121 -1993,639.5,null,275,null -1994,489,null,271,null -1995,1074.2,null,259,null +1993,639.5,,275, +1994,489,,271, +1995,1074.2,,259, 1996,1027,157,281,124 -1997,667.4,161,null,null -1998,925.5,null,286,null -1999,749.9,null,299,null +1997,667.4,161,, +1998,925.5,,286, +1999,749.9,,299, 2000,978.7,142,271,129 2001,987.1,170,267,97 2002,763.3,169,279,110 2003,661.4,173,293,120 -2004,893.5,139,null,null +2004,893.5,139,, 2005,1009.4,155,272,117 2006,709.3,149,270,121 2007,1272.5,172,268,96 @@ -92,4 +92,4 @@ Year,Rainfall,Start,End,Length 2016,935.5,145,270,125 2017,862.5,141,283,142 2018,1168.6,142,286,144 -2019,724.1,135,null,null \ No newline at end of file +2019,724.1,135,, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/mzandu.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/mzandu.csv index a788a3aaf..ef65c6c0d 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/mzandu.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/mzandu.csv @@ -1,34 +1,34 @@ Year,Rainfall,Start,End,Length -1980,1181.7,null,268,null -1981,304.2,null,null,null -1982,847.6,null,284,null +1980,1181.7,,268, +1981,304.2,,, +1982,847.6,,284, 1983,705.5,166,303,137 -1984,811.3,null,null,null -1985,1579.7,null,296,null +1984,811.3,,, +1985,1579.7,,296, 1986,874.3,161,278,117 1987,1192.9,151,292,141 1988,1564.3,154,292,138 -1989,1216.9,null,278,null +1989,1216.9,,278, 1990,988.4,179,282,103 1991,1196.2,145,273,128 1992,1033.6,166,290,124 -1993,979.2,null,295,null -1994,812.5,null,null,null -1995,1250.8,null,281,null +1993,979.2,,295, +1994,812.5,,, +1995,1250.8,,281, 1996,801,173,283,110 -1997,856.5,null,null,null -1998,1014.6,null,279,null -1999,692.3,null,292,null +1997,856.5,,, +1998,1014.6,,279, +1999,692.3,,292, 2000,1131.3,142,272,130 2001,1026.8,148,269,121 2002,1164.3,173,279,106 2003,781.7,153,259,106 -2004,904.1,147,null,null -2005,1044.5,null,274,null +2004,904.1,147,, +2005,1044.5,,274, 2006,1027.1,148,269,121 2007,836.1,160,261,101 2008,1120.6,149,265,116 -2009,831.7,null,263,null +2009,831.7,,263, 2010,946.6,147,271,124 2011,1011.5,184,286,102 2012,687.9,164,246,82 diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/nalunga.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/nalunga.csv index 3930772a2..ada1fe3d3 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/nalunga.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/nalunga.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1980,443.7,null,262,null +1980,443.7,,262, 1981,763.3,183,295,112 1982,655.4,163,255,92 1983,636.6,168,275,107 @@ -39,4 +39,4 @@ Year,Rainfall,Start,End,Length 2017,769.8,150,286,136 2018,808.1,164,271,107 2019,966.6,149,271,122 -2020,195.2,null,184,null \ No newline at end of file +2020,195.2,,184, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/ndakwera.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/ndakwera.csv index 4e378fb07..42e34bd16 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/ndakwera.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/ndakwera.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1967,470.7,null,265,null +1967,470.7,,265, 1968,646.4,162,282,120 1969,682.4,156,283,127 1970,683.5,141,257,116 diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/ngabu.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/ngabu.csv index c0a7eb936..0ad2c23aa 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/ngabu.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/ngabu.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1959,407.8,null,263,null +1959,407.8,,263, 1960,496.7,150,297,147 1961,736.7,168,303,135 1962,922.1,145,273,128 @@ -62,4 +62,4 @@ Year,Rainfall,Start,End,Length 2019,589.6,178,248,70 2020,566.3,159,271,112 2021,1042.3,188,302,114 -2022,0,null,null,null \ No newline at end of file +2022,0,,, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/nkhatabay.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/nkhatabay.csv index 15958a540..d72d5f3aa 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/nkhatabay.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/nkhatabay.csv @@ -1,13 +1,13 @@ Year,Rainfall,Start,End,Length -1959,1385.1,null,302,null +1959,1385.1,,302, 1960,1435.3,167,304,137 1961,2129.3,133,305,172 1962,1782.1,159,305,146 1963,1043.9,162,305,143 1964,1635.5,135,297,162 1965,1105.2,174,300,126 -1966,209,154,null,null -1967,1649.9,null,297,null +1966,209,154,, +1967,1649.9,,297, 1968,1697,135,300,165 1969,1379.2,164,287,123 1970,1108.7,144,297,153 @@ -61,5 +61,5 @@ Year,Rainfall,Start,End,Length 2018,867.6,146,305,159 2019,1589,147,294,147 2020,1307.9,184,295,111 -2021,1398.2,null,303,null -2022,null,null,null,null \ No newline at end of file +2021,1398.2,,303, +2022,,,, \ No newline at end of file diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/salima.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/salima.csv index 8375f1553..a27405233 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/salima.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/salima.csv @@ -1,5 +1,5 @@ Year,Rainfall,Start,End,Length -1953,783.9,null,258,null +1953,783.9,,258, 1954,1462.1,181,305,124 1955,1561.3,164,296,132 1956,1483.8,150,294,144 @@ -68,4 +68,4 @@ Year,Rainfall,Start,End,Length 2019,1046.1,149,269,120 2020,926.1,156,278,122 2021,1465.5,172,287,115 -2022,0,null,null,null \ No newline at end of file +2022,0,,, \ No newline at end of file From 3abc5aff263c4c9a8a8b4e101d83f14aa1d6a672 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Wed, 14 Aug 2024 22:31:05 -0700 Subject: [PATCH 6/9] chore: code tidying --- apps/picsa-server/scripts/climate-data-parser/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/picsa-server/scripts/climate-data-parser/src/index.ts b/apps/picsa-server/scripts/climate-data-parser/src/index.ts index ea9d0fc3e..ff0bed5d6 100644 --- a/apps/picsa-server/scripts/climate-data-parser/src/index.ts +++ b/apps/picsa-server/scripts/climate-data-parser/src/index.ts @@ -25,7 +25,7 @@ function main() { definitions: null, }); } - // TODO - QC checks (e.g. 0mm rainfall) + // TODO - QC checks (e.g. 0mm rainfall, null string) stationData[id].push({ Year: s_year, Rainfall: sum_Rain, Start: start_rain, End: end_rains, Length: length }); } From f313554c487f6e935cfb48f90e50259b73e52272 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Thu, 15 Aug 2024 08:41:12 -0700 Subject: [PATCH 7/9] chore: remove extreme events values --- .../rainfall-summary/rainfall-summary.ts | 2 +- .../src/assets/summaries/mansa.csv | 126 +++++++++--------- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/apps/picsa-apps/dashboard/src/app/modules/climate/pages/station-details/components/rainfall-summary/rainfall-summary.ts b/apps/picsa-apps/dashboard/src/app/modules/climate/pages/station-details/components/rainfall-summary/rainfall-summary.ts index 02b1aa867..a804f8735 100644 --- a/apps/picsa-apps/dashboard/src/app/modules/climate/pages/station-details/components/rainfall-summary/rainfall-summary.ts +++ b/apps/picsa-apps/dashboard/src/app/modules/climate/pages/station-details/components/rainfall-summary/rainfall-summary.ts @@ -114,7 +114,7 @@ export class RainfallSummaryComponent implements AfterViewInit { // HACK - use either end_rains or end_season depending on which has data populated // TODO - push for single value to be populated at api level End: el.end_rains_doy || el.end_season_doy, - Extreme_events: 0, + Extreme_events: null as any, Length: el.season_length, // HACK - replace 0mm with null value Rainfall: el.annual_rain || undefined, diff --git a/apps/picsa-tools/climate-tool/src/assets/summaries/mansa.csv b/apps/picsa-tools/climate-tool/src/assets/summaries/mansa.csv index 31074e2fc..b4202e5bf 100644 --- a/apps/picsa-tools/climate-tool/src/assets/summaries/mansa.csv +++ b/apps/picsa-tools/climate-tool/src/assets/summaries/mansa.csv @@ -1,64 +1,64 @@ Year,End,Extreme_events,Length,Rainfall,Start -1959,296,0,,, -1960,305,0,174,1293,131 -1961,309,0,178,1490,131 -1962,292,0,155,1136,137 -1963,285,0,157,1174,128 -1964,293,0,158,967,135 -1965,302,0,176,1435,126 -1966,308,0,176,1050,132 -1967,280,0,156,1157,124 -1968,298,0,163,1132,135 -1969,277,0,153,1052,124 -1970,289,0,161,1460,128 -1971,301,0,160,1032,141 -1972,302,0,172,1072,130 -1973,300,0,167,1128,133 -1974,289,0,162,1183,127 -1975,318,0,161,1250,157 -1976,291,0,159,1002,132 -1977,312,0,185,1171,127 -1978,317,0,183,1573,134 -1979,313,0,180,1357,133 -1980,292,0,152,1148,140 -1981,289,0,148,917,141 -1982,260,0,128,1224,132 -1983,295,0,160,1181,135 -1984,301,0,167,1258,134 -1985,313,0,184,1292,129 -1986,302,0,177,1175,125 -1987,298,0,148,814,150 -1988,301,0,172,1103,129 -1989,299,0,160,1246,139 -1990,302,0,148,1108,154 -1991,300,0,155,949,145 -1992,293,0,133,961,160 -1993,283,0,146,826,137 -1994,290,0,116,955,174 -1995,298,0,161,1233,137 -1996,303,0,161,934,142 -1997,287,0,148,,139 -1998,306,0,161,1376,145 -1999,,0,,,129 -2000,296,0,,1343, -2001,308,0,184,1337,124 -2002,272,0,124,1142,148 -2003,301,0,134,1008,167 -2004,284,0,140,1179,144 -2005,301,0,,, -2006,,0,,,135 -2007,288,0,160,1110,128 -2008,298,0,166,1446,132 -2009,292,0,161,971,131 -2010,299,0,157,1166,142 -2011,293,0,166,1200,127 -2012,287,0,146,,141 -2013,305,0,160,,145 -2014,311,0,168,1093,143 -2015,294,0,,, -2016,319,0,160,1104,159 -2017,,0,,,140 -2018,292,0,,, -2019,296,0,157,1258,139 -2020,293,0,159,,134 -2021,,0,,, \ No newline at end of file +1959,296,,,, +1960,305,,174,1293,131 +1961,309,,178,1490,131 +1962,292,,155,1136,137 +1963,285,,157,1174,128 +1964,293,,158,967,135 +1965,302,,176,1435,126 +1966,308,,176,1050,132 +1967,280,,156,1157,124 +1968,298,,163,1132,135 +1969,277,,153,1052,124 +1970,289,,161,1460,128 +1971,301,,160,1032,141 +1972,302,,172,1072,130 +1973,300,,167,1128,133 +1974,289,,162,1183,127 +1975,318,,161,1250,157 +1976,291,,159,1002,132 +1977,312,,185,1171,127 +1978,317,,183,1573,134 +1979,313,,180,1357,133 +1980,292,,152,1148,140 +1981,289,,148,917,141 +1982,260,,128,1224,132 +1983,295,,160,1181,135 +1984,301,,167,1258,134 +1985,313,,184,1292,129 +1986,302,,177,1175,125 +1987,298,,148,814,150 +1988,301,,172,1103,129 +1989,299,,160,1246,139 +1990,302,,148,1108,154 +1991,300,,155,949,145 +1992,293,,133,961,160 +1993,283,,146,826,137 +1994,290,,116,955,174 +1995,298,,161,1233,137 +1996,303,,161,934,142 +1997,287,,148,,139 +1998,306,,161,1376,145 +1999,,,,,129 +2000,296,,,1343, +2001,308,,184,1337,124 +2002,272,,124,1142,148 +2003,301,,134,1008,167 +2004,284,,140,1179,144 +2005,301,,,, +2006,,,,,135 +2007,288,,160,1110,128 +2008,298,,166,1446,132 +2009,292,,161,971,131 +2010,299,,157,1166,142 +2011,293,,166,1200,127 +2012,287,,146,,141 +2013,305,,160,,145 +2014,311,,168,1093,143 +2015,294,,,, +2016,319,,160,1104,159 +2017,,,,,140 +2018,292,,,, +2019,296,,157,1258,139 +2020,293,,159,,134 +2021,,,,, From d1f63cea26f7af73714a20e2bd6ea293f34305bf Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Thu, 15 Aug 2024 16:23:06 -0700 Subject: [PATCH 8/9] chore: remove tj climate data --- .../climate-tool/src/app/data/stations/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/picsa-tools/climate-tool/src/app/data/stations/index.ts b/apps/picsa-tools/climate-tool/src/app/data/stations/index.ts index d0f4b19fe..5f55f95ad 100644 --- a/apps/picsa-tools/climate-tool/src/app/data/stations/index.ts +++ b/apps/picsa-tools/climate-tool/src/app/data/stations/index.ts @@ -1,7 +1,11 @@ import type { IStationMeta } from '@picsa/models'; import MW_STATIONS from './mw'; -import TJ_STATIONS from './tj'; +// import TJ_STATIONS from './tj'; import ZM_STATIONS from './zm'; -export const HARDCODED_STATIONS = ([] as IStationMeta[]).concat(MW_STATIONS, TJ_STATIONS, ZM_STATIONS); +export const HARDCODED_STATIONS = ([] as IStationMeta[]).concat( + MW_STATIONS, + // TJ_STATIONS, + ZM_STATIONS +); From b0a55446c707ded2150ffd5cd87ac7a8ca27cb33 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Fri, 16 Aug 2024 14:15:54 -0700 Subject: [PATCH 9/9] feat: add support for draft stations --- .../climate-tool/src/app/data/stations/mw.ts | 18 ++++++++++++++++++ .../app/pages/site-view/site-view.page.html | 2 +- .../app/pages/site-view/site-view.page.scss | 3 +++ .../src/app/pages/site-view/site-view.page.ts | 4 +++- .../src/app/services/climate-data.service.ts | 2 +- libs/models/src/climate.models.ts | 5 +++++ 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/apps/picsa-tools/climate-tool/src/app/data/stations/mw.ts b/apps/picsa-tools/climate-tool/src/app/data/stations/mw.ts index bbaf6632a..5e3bb4e7e 100644 --- a/apps/picsa-tools/climate-tool/src/app/data/stations/mw.ts +++ b/apps/picsa-tools/climate-tool/src/app/data/stations/mw.ts @@ -1,5 +1,16 @@ import { CLIMATE_CHART_DEFINTIONS } from '@picsa/data/climate/chart_definitions'; import type { IStationMeta } from '@picsa/models'; +/** Draft Stations (pending data validation) + +Chiradzulu: remove the high value (2015-16) and keep +Luwazi: I would suggest we keep and start at 1968 as all the 0s are before that date +Kamuona: last year is very low and this is often as the data are incomplete. I think remove the last year please +Kasiya: there is a very high value 2015-16 that we should remove if possible please +Mtakataka: same as above but start from 1947-48 +Mzandu: I would remove the last year +Nalunga: I would remove the last year + + */ const stations: IStationMeta[] = [ // 2021-2023 legacy station data @@ -115,6 +126,7 @@ const stations: IStationMeta[] = [ longitude: 35.18, countryCode: 'mw', definitions: CLIMATE_CHART_DEFINTIONS.mw, + draft: true, }, { id: 'dowa_agr', @@ -139,6 +151,7 @@ const stations: IStationMeta[] = [ longitude: 33.53, countryCode: 'mw', definitions: CLIMATE_CHART_DEFINTIONS.mw, + draft: true, }, { id: 'kia', @@ -187,6 +200,7 @@ const stations: IStationMeta[] = [ longitude: 34.2, countryCode: 'mw', definitions: CLIMATE_CHART_DEFINTIONS.mw, + draft: true, }, { id: 'mtakataka', @@ -195,6 +209,7 @@ const stations: IStationMeta[] = [ longitude: 34.52, countryCode: 'mw', definitions: CLIMATE_CHART_DEFINTIONS.mw, + draft: true, }, { id: 'ndakwera', @@ -227,6 +242,7 @@ const stations: IStationMeta[] = [ longitude: 34.3, countryCode: 'mw', definitions: CLIMATE_CHART_DEFINTIONS.mw, + draft: true, }, { id: 'mzandu', @@ -235,6 +251,7 @@ const stations: IStationMeta[] = [ longitude: 34.5, countryCode: 'mw', definitions: CLIMATE_CHART_DEFINTIONS.mw, + draft: true, }, { id: 'nalunga', @@ -243,6 +260,7 @@ const stations: IStationMeta[] = [ longitude: 34.066, countryCode: 'mw', definitions: CLIMATE_CHART_DEFINTIONS.mw, + draft: true, }, { id: 'bunda', diff --git a/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.html b/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.html index 6dc51c701..3d8dcb1e2 100644 --- a/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.html +++ b/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.html @@ -15,7 +15,7 @@ [value]="chartService.station?.id" > @for(option of stationSelectOptions(); track option.value){ - {{option.label}} + {{option.label}} } diff --git a/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.scss b/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.scss index 93813e04a..5f7ce4dfc 100644 --- a/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.scss +++ b/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.scss @@ -46,3 +46,6 @@ mat-sidenav-content.page-content { mat-sidenav-container { margin-top: 0 !important; } +mat-option[data-draft='true'] { + opacity: 0.5; +} diff --git a/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.ts b/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.ts index cce25c2c3..989374c92 100644 --- a/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.ts +++ b/apps/picsa-tools/climate-tool/src/app/pages/site-view/site-view.page.ts @@ -42,7 +42,9 @@ export class ClimateSiteViewComponent implements OnDestroy, AfterViewInit { public stationSelectOptions = computed(() => { const stations = this.dataService.stations(); - return stations.map(({ id, name }) => ({ value: id, label: name })).sort((a, b) => (a.label > b.label ? 1 : -1)); + return stations + .map(({ id, name, draft }) => ({ value: id, label: name, draft })) + .sort((a, b) => (a.label > b.label ? 1 : -1)); }); private viewId = toSignal(this.route.queryParams.pipe(map(({ view }: ISiteViewQueryParams) => view))); diff --git a/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts b/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts index 7c5a187ea..0a50c5219 100644 --- a/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts +++ b/apps/picsa-tools/climate-tool/src/app/services/climate-data.service.ts @@ -20,7 +20,7 @@ export class ClimateDataService { if (filterFn) { return DATA.HARDCODED_STATIONS.filter((station) => filterFn(station)); } else { - return DATA.HARDCODED_STATIONS.filter((station) => station.countryCode === country_code); + return DATA.HARDCODED_STATIONS.filter((station) => station.countryCode === country_code && !station.draft); } }); diff --git a/libs/models/src/climate.models.ts b/libs/models/src/climate.models.ts index c1c8ff2c7..74d6cbcb7 100644 --- a/libs/models/src/climate.models.ts +++ b/libs/models/src/climate.models.ts @@ -21,6 +21,11 @@ export interface IStationMeta { data?: IStationData[]; /** Definitions for charts */ definitions: IChartDefinitions; + /** + * Mark station in draft state (e.g. pending data approval) + * Draft stations appear in global deployment but not country-specific + **/ + draft?: boolean; } export interface IStationData {