From 539f783a7eba249f4221c4013032a05839ac3282 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 23 Mar 2020 09:55:58 +0100 Subject: nomads-cloud: init --- krebs/5pkgs/simple/nomads-cloud/default.nix | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 krebs/5pkgs/simple/nomads-cloud/default.nix (limited to 'krebs/5pkgs/simple/nomads-cloud') diff --git a/krebs/5pkgs/simple/nomads-cloud/default.nix b/krebs/5pkgs/simple/nomads-cloud/default.nix new file mode 100644 index 000000000..2af74dc44 --- /dev/null +++ b/krebs/5pkgs/simple/nomads-cloud/default.nix @@ -0,0 +1,43 @@ +{ writers, coreutils, grib2json, curl, jq, findutils, imagemagick }: +writers.writeDashBin "nomads-cloud" '' + prefix=$(mktemp -d) + grib_path=$prefix.grib + json_path=$prefix.json + pgm_path=$prefix.pgm + png_path="$1" + + mkdir -p "$prefix" + + date=$(${coreutils}/bin/date +%Y%m%d) + for hour in 18 12 06 00; do + url="https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p25_1hr.pl?file=gfs.t''${hour}z.pgrb2.0p25.anl&lev_entire_atmosphere_%5C%28considered_as_a_single_layer%5C%29=on&var_CWAT=on&leftlon=-180&rightlon=180&toplat=90&bottomlat=-90&dir=%2Fgfs.$date%2F$hour" + ${curl}/bin/curl -fsS "$url" > "$grib_path" + if [ "$?" -eq 0 ]; then + break + fi + done + ${grib2json}/bin/grib2json --data "$grib_path" > "$json_path" + + width=$(${jq}/bin/jq '.[0].header.nx' < "$json_path") + height=$(${jq}/bin/jq '.[0].header.ny' < "$json_path") + + # The maximum gray value. Must be bigger than 0 and less than 65536. + maxval=256 + + # pgm - Netpbm grayscale image format + # http://netpbm.sourceforge.net/doc/pgm.html + { + echo P2 + echo "$width $height" + echo "$maxval" + cat "$json_path" | + ${jq}/bin/jq --argjson maxval "$maxval" -c ' + .[0].data[] * $maxval | round + ' | + ${findutils}/bin/xargs -n "$width" + } > "$pgm_path" + + ${imagemagick}/bin/convert -roll +50% "$pgm_path" "$png_path" + + rm -r "$prefix" +'' -- cgit v1.2.3 From 119b56956c8bcb992c86ca8d0e854884e7c44695 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 23 Mar 2020 18:47:23 +0100 Subject: nomads-cloud: double sqrt for better clouds --- krebs/5pkgs/simple/nomads-cloud/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'krebs/5pkgs/simple/nomads-cloud') diff --git a/krebs/5pkgs/simple/nomads-cloud/default.nix b/krebs/5pkgs/simple/nomads-cloud/default.nix index 2af74dc44..9c39de891 100644 --- a/krebs/5pkgs/simple/nomads-cloud/default.nix +++ b/krebs/5pkgs/simple/nomads-cloud/default.nix @@ -22,7 +22,7 @@ writers.writeDashBin "nomads-cloud" '' height=$(${jq}/bin/jq '.[0].header.ny' < "$json_path") # The maximum gray value. Must be bigger than 0 and less than 65536. - maxval=256 + maxval=1000 # pgm - Netpbm grayscale image format # http://netpbm.sourceforge.net/doc/pgm.html @@ -32,7 +32,7 @@ writers.writeDashBin "nomads-cloud" '' echo "$maxval" cat "$json_path" | ${jq}/bin/jq --argjson maxval "$maxval" -c ' - .[0].data[] * $maxval | round + ((.[0].data[] | sqrt | sqrt) * $maxval | round) ' | ${findutils}/bin/xargs -n "$width" } > "$pgm_path" -- cgit v1.2.3 From e5cbe0cbe17a63854efc0271c1ae0d922a23572d Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 23 Mar 2020 20:28:29 +0100 Subject: realwallpaper: use cloud_gamme instead of sqrt hack --- krebs/5pkgs/simple/nomads-cloud/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'krebs/5pkgs/simple/nomads-cloud') diff --git a/krebs/5pkgs/simple/nomads-cloud/default.nix b/krebs/5pkgs/simple/nomads-cloud/default.nix index 9c39de891..6e4ace484 100644 --- a/krebs/5pkgs/simple/nomads-cloud/default.nix +++ b/krebs/5pkgs/simple/nomads-cloud/default.nix @@ -32,7 +32,7 @@ writers.writeDashBin "nomads-cloud" '' echo "$maxval" cat "$json_path" | ${jq}/bin/jq --argjson maxval "$maxval" -c ' - ((.[0].data[] | sqrt | sqrt) * $maxval | round) + ((.[0].data[]) * $maxval | round) ' | ${findutils}/bin/xargs -n "$width" } > "$pgm_path" -- cgit v1.2.3