Skip to content

MW3000/pharowarmingstripes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Exploring warming stripes with Pharo and Roassal

In the wake of the Global Climate Strike 2019, I tried to create Warming Stripes for Germany using Pharo and Roassal. It's only a few lines of code:

| rawData cleanData neoCSVReader parsedData averageTemperatures view min max normalizer shape elements |

"Obtaining & cleaning data"
rawData := 'https://opendata.dwd.de/climate_environment/CDC/regional_averages_DE/annual/air_temperature_mean/regional_averages_tm_year.txt' asUrl retrieveContents.
cleanData := Character cr join: ((rawData lines) allButFirst: 2).
neoCSVReader := NeoCSVReader new separator: $;.
parsedData := (neoCSVReader on: (ReadStream on: cleanData)) upToEnd.
averageTemperatures := parsedData collect: [ :each | (each at: 19) trim asNumber ].

"Visualization"
view := RTView new.
min := averageTemperatures min.
max := averageTemperatures max.
normalizer := RTMultiLinearColor new.
normalizer colors: ((RTCPDiverging new) scheme:'RdBu').
normalizer command: [ :temperature | 1-((temperature-min)/(max-min))].
shape := RTBox new width: 2; height: 150; color: normalizer.
elements := shape elementsOn: averageTemperatures.
view addAll: elements.
RTHorizontalLineLayout new gapSize: 0; on: elements.
view

Use Pharo 7, Roassal 2 and NeoCSV. Copy the code above to a Playground and inspect it to open the view.
Data for averages temperatures in Germany comes from DWD.

Pharo Screenshot

About

Exploring warming stripes with Pharo and Roassal

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published