-
-
Save Gro-Tsen/a87fc776fcb49418c8f29145ae4a6b07 to your computer and use it in GitHub Desktop.
Compute temperature autocorrelation graphs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Get data from https://zenodo.org/record/6961511#.Y4-HhqIo9hE | |
## in era-nuts-t2m.zip we want era-nuts-t2m-nuts0-daily-singleindex.csv | |
perl -F',' -ne 'next if $F[0]=~m/time/; die unless $F[0]=~m/^\"([0-9]{4})\/([0-9]{2})\/([0-9]{2}) ([0-9]{2})\:([0-9]{2})\:([0-9]{2})\"$/; print "$1-$2-$3T$4:$5:$6Z\t$F[14]\n"' era-nuts-t2m-nuts0-daily-singleindex.csv > /tmp/temp-fr-daily.dat | |
: > /tmp/temp-fr-autocorrels.dat ; for i in $(seq 0 400) ; do | |
echo "$i days" | |
ifmt=$(printf %03d $i) | |
ip1=$((i+1)) | |
paste /tmp/temp-fr-daily.dat <(tail +$ip1 /tmp/temp-fr-daily.dat) > /tmp/temp-fr-shifted.dat | |
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/temp-fr-autocorrel-'"$ifmt"'days.png"' ; echo 'stats "/tmp/temp-fr-shifted.dat" using ($2):($4) name "st"' ; echo 'w(x)=st_intercept+st_slope*x' ; echo 'regrtitle=sprintf("[r=%s%.4f]", (st_correlation<0?"−":""), abs(st_correlation))' ; echo 'set title "Distribution de températures en France à '"$i"' jours d'\''écart {/*0.5 (1980–2021)}"' ; echo 'set xlabel "Température jour J"' ; echo 'set ylabel "Température jour J+'"$i"'"' ; echo 'set key bottom right' ; echo 'plot [st_min_x:st_max_x] [st_min_x:st_max_x] "/tmp/temp-fr-shifted.dat" using ($2):($4) pt 7 lc rgb "#000080" ps 0.1 notitle, [x=st_min_x:st_max_x] w(x) lc rgb "#ff0080" title regrtitle' ; echo 'set print "/tmp/temp-fr-autocorrels.dat" append' ; echo 'print sprintf("%d%c%.6f", '"$i"', 9, st_correlation)') | gnuplot | |
done | |
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/temp-fr-autocorrels.png"' ; echo 'set title "Autocorrélation de la température moyenne en France {/*0.5 (1980–2021)}"' ; echo 'set xlabel "Nombre de jours d'\''écart"' ; echo 'set ylabel "Coefficient de corrélation (r)"' ; echo 'set key bottom right' ; echo 'plot [0:400] "/tmp/temp-fr-autocorrels.dat" with lines title "autocorrélation"') | gnuplot | |
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/temp-fr-autocorrels-short.png"' ; echo 'set title "Autocorrélation de la température moyenne en France {/*0.5 (1980–2021)}"' ; echo 'set xlabel "Nombre de jours d'\''écart"' ; echo 'set ylabel "Coefficient de corrélation (r)"' ; echo 'set key bottom right' ; echo 'plot [0:20] "/tmp/temp-fr-autocorrels.dat" with lines title "autocorrélation"') | gnuplot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://twitter.com/gro_tsen/status/1603808798157709313 for context.