Skip to content

Instantly share code, notes, and snippets.

@Gro-Tsen
Created December 6, 2022 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gro-Tsen/0bd41ae24fc69282ff309d6b8d4abb75 to your computer and use it in GitHub Desktop.
Save Gro-Tsen/0bd41ae24fc69282ff309d6b8d4abb75 to your computer and use it in GitHub Desktop.
## Get data from https://odre.opendatasoft.com/explore/dataset/eco2mix-national-cons-def/information/
## assumed stored in /tmp/eco2mix-national-cons-def.csv
perl -F';' -ne 'next unless $F[2] ge "2017-06-01" && $F[2] lt "2022-06-01"; next unless $F[5]; print "$F[4]\t$F[5]\t$F[11]\n"' /tmp/eco2mix-national-cons-def.csv | sort -n -k 1 | sort -r -n -k 2 > /tmp/cons-nuclear.dat
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/cons-nuclear.png"' ; echo 'stats "/tmp/cons-nuclear.dat" using ($2/1000):($3/1000) name "st"' ; echo 'w(x)=st_intercept+st_slope*x' ; echo 'set title "Distribution de puissance électrique en France {/*0.5 (juin 2017 à mai 2022)}"' ; echo 'set xlabel "Puissance P consommée (GW)"' ; echo 'set ylabel "Production nucléaire (GW)"' ; echo 'set key top left' ; echo 'regrtitle=sprintf("%s%.2fGW+%.4f×P [r=%.3f]", (st_intercept<0?"−":""), abs(st_intercept), st_slope, st_correlation)' ; echo 'meantitle=sprintf("(%.2fGW, %.2fGW)", st_mean_x, st_mean_y)' ; echo 'plot [0:st_max_x] [0:st_max_y] "/tmp/cons-nuclear.dat" using ($2/1000):($3/1000) pt 7 lc rgb "#000080" ps 0.1 notitle, [x=st_min_x:st_max_x] w(x) lc rgb "#ff0000" title regrtitle, "" using (st_mean_x):(st_mean_y) pt 1 lc rgb "#ff0000" title meantitle') | gnuplot
perl -F';' -ne 'next unless $F[2] ge "2017-06-01" && $F[2] lt "2022-06-01"; next unless $F[5]; $v=$F[8]+$F[9]+$F[10]; print "$F[4]\t$F[5]\t$v\n"' /tmp/eco2mix-national-cons-def.csv | sort -n -k 1 | sort -r -n -k 2 > /tmp/cons-fossilfuels.dat
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/cons-fossilfuels.png"' ; echo 'stats "/tmp/cons-fossilfuels.dat" using ($2/1000):($3/1000) name "st"' ; echo 'w(x)=st_intercept+st_slope*x' ; echo 'set title "Distribution de puissance électrique en France {/*0.5 (juin 2017 à mai 2022)}"' ; echo 'set xlabel "Puissance P consommée (GW)"' ; echo 'set ylabel "Production thermique fossile (GW)"' ; echo 'set key top left' ; echo 'regrtitle=sprintf("%s%.2fGW+%.4f×P [r=%.3f]", (st_intercept<0?"−":""), abs(st_intercept), st_slope, st_correlation)' ; echo 'meantitle=sprintf("(%.2fGW, %.2fGW)", st_mean_x, st_mean_y)' ; echo 'plot [0:st_max_x] [0:st_max_y] "/tmp/cons-fossilfuels.dat" using ($2/1000):($3/1000) pt 7 lc rgb "#000080" ps 0.1 notitle, [x=st_min_x:st_max_x] w(x) lc rgb "#ff0000" title regrtitle, "" using (st_mean_x):(st_mean_y) pt 1 lc rgb "#ff0000" title meantitle') | gnuplot
perl -F';' -ne 'next unless $F[2] ge "2017-06-01" && $F[2] lt "2022-06-01"; next unless $F[5]; print "$F[4]\t$F[5]\t$F[14]\n"' /tmp/eco2mix-national-cons-def.csv | sort -n -k 1 | sort -r -n -k 2 > /tmp/cons-hydraulic.dat
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/cons-hydraulic.png"' ; echo 'stats "/tmp/cons-hydraulic.dat" using ($2/1000):($3/1000) name "st"' ; echo 'w(x)=st_intercept+st_slope*x' ; echo 'set title "Distribution de puissance électrique en France {/*0.5 (juin 2017 à mai 2022)}"' ; echo 'set xlabel "Puissance P consommée (GW)"' ; echo 'set ylabel "Production hydroélectrique (GW)"' ; echo 'set key top left' ; echo 'regrtitle=sprintf("%s%.2fGW+%.4f×P [r=%.3f]", (st_intercept<0?"−":""), abs(st_intercept), st_slope, st_correlation)' ; echo 'meantitle=sprintf("(%.2fGW, %.2fGW)", st_mean_x, st_mean_y)' ; echo 'plot [0:st_max_x] [0:st_max_y] "/tmp/cons-hydraulic.dat" using ($2/1000):($3/1000) pt 7 lc rgb "#000080" ps 0.1 notitle, [x=st_min_x:st_max_x] w(x) lc rgb "#ff0000" title regrtitle, "" using (st_mean_x):(st_mean_y) pt 1 lc rgb "#ff0000" title meantitle') | gnuplot
perl -F';' -ne 'next unless $F[2] ge "2017-06-01" && $F[2] lt "2022-06-01"; next unless $F[5]; print "$F[4]\t$F[5]\t$F[12]\n"' /tmp/eco2mix-national-cons-def.csv | sort -n -k 1 | sort -r -n -k 2 > /tmp/cons-windpower.dat
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/cons-windpower.png"' ; echo 'stats "/tmp/cons-windpower.dat" using ($2/1000):($3/1000) name "st"' ; echo 'w(x)=st_intercept+st_slope*x' ; echo 'set title "Distribution de puissance électrique en France {/*0.5 (juin 2017 à mai 2022)}"' ; echo 'set xlabel "Puissance P consommée (GW)"' ; echo 'set ylabel "Production éolienne (GW)"' ; echo 'set key top left' ; echo 'regrtitle=sprintf("%s%.2fGW+%.4f×P [r=%.3f]", (st_intercept<0?"−":""), abs(st_intercept), st_slope, st_correlation)' ; echo 'meantitle=sprintf("(%.2fGW, %.2fGW)", st_mean_x, st_mean_y)' ; echo 'plot [0:st_max_x] [0:st_max_y] "/tmp/cons-windpower.dat" using ($2/1000):($3/1000) pt 7 lc rgb "#000080" ps 0.1 notitle, [x=st_min_x:st_max_x] w(x) lc rgb "#ff0000" title regrtitle, "" using (st_mean_x):(st_mean_y) pt 1 lc rgb "#ff0000" title meantitle') | gnuplot
perl -F';' -ne 'next unless $F[2] ge "2017-06-01" && $F[2] lt "2022-06-01"; next unless $F[5]; print "$F[4]\t$F[5]\t$F[13]\n"' /tmp/eco2mix-national-cons-def.csv | sort -n -k 1 | sort -r -n -k 2 > /tmp/cons-solarpower.dat
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/cons-solarpower.png"' ; echo 'stats "/tmp/cons-solarpower.dat" using ($2/1000):($3/1000) name "st"' ; echo 'w(x)=st_intercept+st_slope*x' ; echo 'set title "Distribution de puissance électrique en France {/*0.5 (juin 2017 à mai 2022)}"' ; echo 'set xlabel "Puissance P consommée (GW)"' ; echo 'set ylabel "Production solaire (GW)"' ; echo 'set key top left' ; echo 'regrtitle=sprintf("%s%.2fGW%s%.4f×P [r=%s%.3f]", (st_intercept<0?"−":""), abs(st_intercept), (st_slope<0?"−":"+"), abs(st_slope), (st_correlation<0?"−":""), abs(st_correlation))' ; echo 'meantitle=sprintf("(%.2fGW, %.2fGW)", st_mean_x, st_mean_y)' ; echo 'plot [0:st_max_x] [0:st_max_y] "/tmp/cons-solarpower.dat" using ($2/1000):($3/1000) pt 7 lc rgb "#000080" ps 0.1 notitle, [x=st_min_x:st_max_x] w(x) lc rgb "#ff0000" title regrtitle, "" using (st_mean_x):(st_mean_y) pt 1 lc rgb "#ff0000" title meantitle') | gnuplot
perl -F';' -ne 'next unless $F[2] ge "2017-06-01" && $F[2] lt "2022-06-01"; next unless $F[5]; print "$F[4]\t$F[5]\t$F[23]\n"' /tmp/eco2mix-national-cons-def.csv | sort -n -k 1 | sort -r -n -k 2 > /tmp/cons-germanybelgium.dat
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/cons-germanybelgium.png"' ; echo 'stats "/tmp/cons-germanybelgium.dat" using ($2/1000):($3/1000) name "st"' ; echo 'w(x)=st_intercept+st_slope*x' ; echo 'set title "Distribution de puissance électrique en France {/*0.5 (juin 2017 à mai 2022)}"' ; echo 'set xlabel "Puissance P consommée (GW)"' ; echo 'set ylabel "Échanges Allemagne+Belgique ↔ France (GW)"' ; echo 'set key top left' ; echo 'regrtitle=sprintf("%s%.2fGW+%.4f×P [r=%.3f]", (st_intercept<0?"−":""), abs(st_intercept), st_slope, st_correlation)' ; echo 'meantitle=sprintf("(%.2fGW, %s%.2fGW)", st_mean_x, (st_mean_y<0?"−":""), abs(st_mean_y))' ; echo 'plot [0:st_max_x] [st_min_y:st_max_y] "/tmp/cons-germanybelgium.dat" using ($2/1000):($3/1000) pt 7 lc rgb "#000080" ps 0.1 notitle, [x=st_min_x:st_max_x] w(x) lc rgb "#ff0000" title regrtitle, "" using (st_mean_x):(st_mean_y) pt 1 lc rgb "#ff0000" title meantitle') | gnuplot
perl -F';' -ne 'next unless $F[2] ge "2017-06-01" && $F[2] lt "2022-06-01"; next unless $F[5]; print "$F[4]\t$F[5]\t$F[21]\n"' /tmp/eco2mix-national-cons-def.csv | sort -n -k 1 | sort -r -n -k 2 > /tmp/cons-italy.dat
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/cons-italy.png"' ; echo 'stats "/tmp/cons-italy.dat" using ($2/1000):($3/1000) name "st"' ; echo 'w(x)=st_intercept+st_slope*x' ; echo 'set title "Distribution de puissance électrique en France {/*0.5 (juin 2017 à mai 2022)}"' ; echo 'set xlabel "Puissance P consommée (GW)"' ; echo 'set ylabel "Échanges Italie ↔ France (GW)"' ; echo 'set key top left' ; echo 'regrtitle=sprintf("%s%.2fGW+%.4f×P [r=%.3f]", (st_intercept<0?"−":""), abs(st_intercept), st_slope, st_correlation)' ; echo 'meantitle=sprintf("(%.2fGW, %s%.2fGW)", st_mean_x, (st_mean_y<0?"−":""), abs(st_mean_y))' ; echo 'plot [0:st_max_x] [st_min_y:st_max_y] "/tmp/cons-italy.dat" using ($2/1000):($3/1000) pt 7 lc rgb "#000080" ps 0.1 notitle, [x=st_min_x:st_max_x] w(x) lc rgb "#ff0000" title regrtitle, "" using (st_mean_x):(st_mean_y) pt 1 lc rgb "#ff0000" title meantitle') | gnuplot
perl -F';' -ne 'next unless $F[2] ge "2017-06-01" && $F[2] lt "2022-06-01"; next unless $F[5]; print "$F[4]\t$F[5]\t$F[19]\n"' /tmp/eco2mix-national-cons-def.csv | sort -n -k 1 | sort -r -n -k 2 > /tmp/cons-greatbritain.dat
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/cons-greatbritain.png"' ; echo 'stats "/tmp/cons-greatbritain.dat" using ($2/1000):($3/1000) name "st"' ; echo 'w(x)=st_intercept+st_slope*x' ; echo 'set title "Distribution de puissance électrique en France {/*0.5 (juin 2017 à mai 2022)}"' ; echo 'set xlabel "Puissance P consommée (GW)"' ; echo 'set ylabel "Échanges Grande-Bretagne ↔ France (GW)"' ; echo 'set key top left' ; echo 'regrtitle=sprintf("%s%.2fGW+%.4f×P [r=%.3f]", (st_intercept<0?"−":""), abs(st_intercept), st_slope, st_correlation)' ; echo 'meantitle=sprintf("(%.2fGW, %s%.2fGW)", st_mean_x, (st_mean_y<0?"−":""), abs(st_mean_y))' ; echo 'plot [0:st_max_x] [st_min_y:st_max_y] "/tmp/cons-greatbritain.dat" using ($2/1000):($3/1000) pt 7 lc rgb "#000080" ps 0.1 notitle, [x=st_min_x:st_max_x] w(x) lc rgb "#ff0000" title regrtitle, "" using (st_mean_x):(st_mean_y) pt 1 lc rgb "#ff0000" title meantitle') | gnuplot
perl -F';' -ne 'next unless $F[2] ge "2017-06-01" && $F[2] lt "2022-06-01"; next unless $F[5]; print "$F[4]\t$F[5]\t$F[20]\n"' /tmp/eco2mix-national-cons-def.csv | sort -n -k 1 | sort -r -n -k 2 > /tmp/cons-spain.dat
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/cons-spain.png"' ; echo 'stats "/tmp/cons-spain.dat" using ($2/1000):($3/1000) name "st"' ; echo 'w(x)=st_intercept+st_slope*x' ; echo 'set title "Distribution de puissance électrique en France {/*0.5 (juin 2017 à mai 2022)}"' ; echo 'set xlabel "Puissance P consommée (GW)"' ; echo 'set ylabel "Échanges Espagne ↔ France (GW)"' ; echo 'set key top left' ; echo 'regrtitle=sprintf("%s%.2fGW+%.4f×P [r=%.3f]", (st_intercept<0?"−":""), abs(st_intercept), st_slope, st_correlation)' ; echo 'meantitle=sprintf("(%.2fGW, %s%.2fGW)", st_mean_x, (st_mean_y<0?"−":""), abs(st_mean_y))' ; echo 'plot [0:st_max_x] [st_min_y:st_max_y] "/tmp/cons-spain.dat" using ($2/1000):($3/1000) pt 7 lc rgb "#000080" ps 0.1 notitle, [x=st_min_x:st_max_x] w(x) lc rgb "#ff0000" title regrtitle, "" using (st_mean_x):(st_mean_y) pt 1 lc rgb "#ff0000" title meantitle') | gnuplot
perl -F';' -ne 'next unless $F[2] ge "2017-06-01" && $F[2] lt "2022-06-01"; next unless $F[5]; print "$F[4]\t$F[5]\t$F[22]\n"' /tmp/eco2mix-national-cons-def.csv | sort -n -k 1 | sort -r -n -k 2 > /tmp/cons-switzerland.dat
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/cons-switzerland.png"' ; echo 'stats "/tmp/cons-switzerland.dat" using ($2/1000):($3/1000) name "st"' ; echo 'w(x)=st_intercept+st_slope*x' ; echo 'set title "Distribution de puissance électrique en France {/*0.5 (juin 2017 à mai 2022)}"' ; echo 'set xlabel "Puissance P consommée (GW)"' ; echo 'set ylabel "Échanges Suisse ↔ France (GW)"' ; echo 'set key top left' ; echo 'regrtitle=sprintf("%s%.2fGW+%.4f×P [r=%.3f]", (st_intercept<0?"−":""), abs(st_intercept), st_slope, st_correlation)' ; echo 'meantitle=sprintf("(%.2fGW, %s%.2fGW)", st_mean_x, (st_mean_y<0?"−":""), abs(st_mean_y))' ; echo 'plot [0:st_max_x] [st_min_y:st_max_y] "/tmp/cons-switzerland.dat" using ($2/1000):($3/1000) pt 7 lc rgb "#000080" ps 0.1 notitle, [x=st_min_x:st_max_x] w(x) lc rgb "#ff0000" title regrtitle, "" using (st_mean_x):(st_mean_y) pt 1 lc rgb "#ff0000" title meantitle') | gnuplot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment