From 6cb02ae2ee6bdcb699025196c9000da65a484e24 Mon Sep 17 00:00:00 2001
From: simondreutter <simon.dreutter@awi.de>
Date: Mon, 14 Mar 2022 22:22:01 +0100
Subject: [PATCH] tiny improvements

---
 process/2_process_gimp.py          |  7 +++--
 process/4_process_gebco.py         | 19 ++++++++------
 process/5_create_shading_layers.py | 11 +++-----
 process/config.py                  | 41 ++++++++++--------------------
 4 files changed, 33 insertions(+), 45 deletions(-)

diff --git a/process/2_process_gimp.py b/process/2_process_gimp.py
index d258d64..05b4ca3 100644
--- a/process/2_process_gimp.py
+++ b/process/2_process_gimp.py
@@ -40,6 +40,9 @@ from config import *
 #    PROCESS
 #=============================================================================
 
+# resolution for GIMP_RASTER
+gimp_res = RESOLUTION_DEG / 2
+
 # layer names
 gimp_name = os.path.splitext(os.path.basename(GIMP))[0]
 
@@ -48,11 +51,11 @@ print()
 print('====================================================================')
 print(f'{"GREENLAND ICE MAPPING PROJECT / GIMP":^68}')
 
-msg = 'Reprojecting and downsampling GIMP raster...'
+msg = 'Reprojecting and resampling GIMP raster...'
 cmd = (f'gdalwarp'
        f' -t_srs {EPSG_WORLD}'
        f' -dstnodata 0.0'
-       f' -tr {GIMP_RESOLUTION} {GIMP_RESOLUTION}'
+       f' -tr {gimp_res} {gimp_res}'
        f' -r near'
        f' -of GTiff'
        f' {GIMP_IN} {GIMP_RASTER}')
diff --git a/process/4_process_gebco.py b/process/4_process_gebco.py
index 167b6dc..edb9f7a 100644
--- a/process/4_process_gebco.py
+++ b/process/4_process_gebco.py
@@ -16,6 +16,15 @@ Antarctic extent, reprojected (warped) to the Arctic and Antarctic
 projections (EPSG_ARCTIC and EPSG_ANTARCTIC), and downsampled to the
 target resolution (RESOLUTION_M).
 
+Due to ice shelfs there is a very steep drop in the DEM from shelf
+ice edge down to the seabed, which creates hillshade artifacts. To
+avoid these, the GEBCO grid for World and Antarctic outputs will be
+processed twice, once the ice surface DEM and once the sub ice
+topography DEM. The main hillshade is created from the sub ice DEM.
+Then all data above sea level is extracted from the ice surface DEM,
+a hillshade is created for these areas and the sub ice hillshade is
+replaced in these areas.
+
 """
 
 
@@ -102,6 +111,7 @@ cmd = (f'gdalwarp'
        f' {GEBCO_SUBICE_IN} {GEBCO_WORLD_SUBICE}')
 run(msg,cmd)
 
+
 # Arctic
 msg = 'Clipping GEBCO for the Arctic...'
 cmd = (f'gdal_translate'
@@ -133,15 +143,8 @@ cmd = (f'gdalwarp'
        f' {GEBCO_ARCTIC_FULL_VRT} {GEBCO_ARCTIC}')
 run(msg,cmd)
 
-# Antarctic
-# Due to ice shelfs there is a very steep drop in the DEM from shelf ice edge
-# down to the seabed, which creates hillshade artifacts. To avoid these, the
-# Antarctic GEBCO grid will processed twice, once the ice surface DEM and once
-# the sub ice topography DEM. The main hillshade is created from the sub ice
-# DEM. Then all data above sea level is extracted from the ice surface DEM, a
-# hillshade is created for these areas and the sub ice hillshade is replaced
-# in these areas.
 
+# Antarctic
 # ice surface
 msg = 'Clipping GEBCO ice surface for the Antarctic...'
 cmd = (f'gdal_translate'
diff --git a/process/5_create_shading_layers.py b/process/5_create_shading_layers.py
index 8fd6fe2..78156e0 100644
--- a/process/5_create_shading_layers.py
+++ b/process/5_create_shading_layers.py
@@ -12,7 +12,7 @@ This scipt computes the hillshade layers for the World, the Arctic
 and the Antarctic basemap. The hillshades are computed with a
 synthetic light source from 315° Azimuth and 45° Altitude and with
 and exaggeration / z factor of 10 (Z_FACTOR in config). The combined
-shading is used to get Simon's magical relief visualization, which
+shading is used to get "Simon's magical relief visualization", which
 combines shading by synthetic illumination and shading by slope
 inclination.
 
@@ -101,6 +101,7 @@ cmd = (f'gdal_merge'
        f' {GEBCO_WORLD_SUBICE_HILLSHADE} {GEBCO_WORLD_ICESURFACE_HILLSHADE}')
 run(msg,cmd)
 
+
 # Arctic
 msg = 'Creating Arctic Hillshade...'
 cmd = (f'gdaldem'
@@ -117,14 +118,8 @@ cmd = (f'gdaldem'
        f' {GEBCO_ARCTIC} {GEBCO_ARCTIC_HILLSHADE}')
 run(msg,cmd)
 
+
 # Antarctic
-# Due to ice shelfs there is a very steep drop in the DEM from shelf ice edge
-# down to the seabed, which creates hillshade artifacts. To avoid these, the
-# Antarctic GEBCO grid will processed twice, once the ice surface DEM and once
-# the sub ice topography DEM. The main hillshade is created from the sub ice
-# DEM. Then all data above sea level is extracted from the ice surface DEM, a
-# hillshade is created for these areas and the sub ice hillshade is replaced
-# in these areas.
 msg = 'Creating Antarctic ice surface Hillshade...'
 cmd = (f'gdaldem'
        f' hillshade'
diff --git a/process/config.py b/process/config.py
index 834d38e..05df106 100644
--- a/process/config.py
+++ b/process/config.py
@@ -159,23 +159,12 @@ GLIMS_IN = os.path.join(PATH_GLIMS,'glims_polygons.shp')
 # latitudes.
 
 # Final AWI Basemap (World) resolution
-# 15 arc seconds (original GEBCO resolution)
-#RESOLUTION_DEG = 0.004166666666666666
-# 30 arc seconds
-RESOLUTION_DEG = 0.008333333333333333
+#RESOLUTION_DEG = 0.004166666666666666 # 15 arc seconds (original GEBCO resolution)
+RESOLUTION_DEG = 0.008333333333333333 # 30 arc seconds
 
 # Final AWI Basemap (Arctic and Antarctic) resolution
-# pendant to 15 arc seconds
-#RESOLUTION_M = 500.0
-# pendant to 30 arc seconds
-RESOLUTION_M = 1000.0
-
-# GIMP Resolution
-# half the grid resolution
-GIMP_RESOLUTION = RESOLUTION_DEG / 2
-
-# Hillshade z factor / vertical exaggeration
-Z_FACTOR = 10.0
+#RESOLUTION_M = 500.0 # approximate pendant to 15 arc seconds
+RESOLUTION_M = 1000.0 # approximate pendant to 30 arc seconds
 
 # Arctic extent down to X degree latitude (positive)
 ARCTIC_EXTENT_LAT = 30.0
@@ -183,6 +172,9 @@ ARCTIC_EXTENT_LAT = 30.0
 # Antarctic extent up to X degree latitude (negative)
 ANTARCTIC_EXTENT_LAT= -30.0
 
+# Hillshade z factor / vertical exaggeration
+Z_FACTOR = 10.0
+
 
 #=============================================================================
 #    TEMPORARY FILES
@@ -227,12 +219,14 @@ GEBCO_WORLD_SUBICE_HILLSHADE = os.path.join(PATH_GEBCO,'GEBCO_world_subice_hills
 GEBCO_WORLD = os.path.join(PATH_GEBCO,'GEBCO_world.tif')
 GEBCO_WORLD_HILLSHADE = os.path.join(PATH_GEBCO,'GEBCO_world_hillshade.tif')
 
+
 # GEBCO Arctic
 GEBCO_ARCTIC_CLIP_VRT = os.path.join(PATH_GEBCO,'GEBCO_arctic_clip.vrt')
 GEBCO_ARCTIC_FULL_VRT = os.path.join(PATH_GEBCO,'GEBCO_arctic_full.vrt')
 GEBCO_ARCTIC = os.path.join(PATH_GEBCO,'GEBCO_arctic.tif')
 GEBCO_ARCTIC_HILLSHADE = os.path.join(PATH_GEBCO,'GEBCO_arctic_hillshade.tif')
 
+
 # GEBCO Antarctic ice surface
 GEBCO_ANTARCTIC_ICESURFACE_CLIP_VRT = os.path.join(PATH_GEBCO,'GEBCO_antarctic_icesurface_clip.vrt')
 GEBCO_ANTARCTIC_ICESURFACE_FULL_VRT = os.path.join(PATH_GEBCO,'GEBCO_antarctic_icesurface_full.vrt')
@@ -310,6 +304,7 @@ CP_GREY = os.path.abspath(os.path.join('..','styles','color_palettes','basemap_g
 
 #=============================================================================
 
+# map combinations to be compiled at the end
 MAPS = [
     {'name'          : 'AWI Basemap World blue',
      'grid'          : GEBCO_WORLD,
@@ -382,18 +377,10 @@ METADATA_FILE = os.path.join(PATH_RESULT,'AWI_Basemap_Metadata.txt')
 #    OPERATIONAL PARAMETERS
 #=============================================================================
 
-# The following settings are operational parameters for the process. If, e.g.
-# your Python (v3.x) installation has a different executable, like "python3"
-# as it comes with the OSGeo4W Python installation, some scripts need to know
-# that and the command needs to be changed here.
-# And if the temporary GeoTIFFs created by GDAL shall be created with
-# different create options, they can be adjusted below. The create options for
-# the final results, however, are specified in the last python script.
-
-# Python executable
-#PYTHON = 'python'
-#PYTHON = 'python3'
-PYTHON = sys.executable
+# The following settings are operational parameters for the process. If the
+# temporary GeoTIFFs created by GDAL shall be created with different create
+# options, they can be adjusted below. The create options for the final
+# results, however, are specified in the last python script.
 
 # GDAL creation options
 GDAL_CREATE_OPTIONS = '-co COMPRESS=NONE -co BIGTIFF=IF_NEEDED'
-- 
GitLab