1#!/usr/bin/env bash 2# 3# Blending the NASA day and night views from the Blue and Black Marble mosaic 4# images using a day-night mask set for the summer solstice midnight in Hawaii 5# on June 20, 2020. In addition, we adjust the colors using the intensities derived 6# from the slopes of the earth relief grid. We spin around at 24 frames per second 7# where each frame advances the viewpoint 0.25 degrees of longitude. 8# 9# DEM: @earth_relief_02m 10# Images: @earth_day_02m @earth_night_02m from the GMT data server 11# 12# The finished movie is available in our YouTube channel as well: 13# https://youtu.be/nmxy9yb2cR8 14# The movie took ~2.75 hour to render on a 24-core MacPro 2013. 15 16# 1. Create background plot and data files needed in the loop 17cat << 'EOF' > pre.sh 18gmt begin 19 # Set view longitudes 0-360 with steps of 0.25 degree 20 gmt math -T-180/180/0.25 -o0 T = view.txt 21 # Make global grid with a smooth 2-degree day/night transition for the 2020 solstice. 22 gmt grdmath -Rd -I2m -rp $(gmt solar -C -o0:1 -I+d2020-06-20+z-10) 2 DAYNIGHT = daynight.grd 23 # We will create an intensity grid based on a DEM so that we can see structures in the oceans 24 gmt grdgradient @earth_relief_02m -Nt0.75 -A45 -Gintens.grd 25 # Make sure our remote files have been downloaded 26 gmt which -Ga @earth_day_02m @earth_night_02m 27gmt end 28EOF 29# 2. Set up main script 30cat << 'EOF' > main.sh 31gmt begin 32 # Let HSV minimum value go to zero and faint map border 33 gmt set COLOR_HSV_MIN_V 0 MAP_FRAME_PEN=faint 34 # Blend the day and night Earth images using the weights, so that when w is 1 35 # we get the daytime view, and then adjust colors based on the intensity. 36 gmt grdmix @earth_day_02m @earth_night_02m -Wdaynight.grd -Iintens.grd -Gview.tif 37 # Plot this image on an Earth with view from current longitude 38 gmt grdimage view.tif -JG${MOVIE_COL0}/30N/21.6c -Bafg -X0 -Y0 39gmt end 40EOF 41# 3. Run the movie, requesting a fade in/out via white 42gmt movie main.sh -Sbpre.sh -C21.6cx21.6cx50 -Tview.txt -Nanim11 -Lf -Ls"Midnight in Hawaii"+jBR -H8 -Pb+w1c -Fmp4 -V -W -Zs 43