Skip to content

Commit 5bcc3d6

Browse files
committed
Update image workflow and recipes
I think these images was partly done manually since the downloader_image script had lots of issues.
1 parent 83bf38c commit 5bcc3d6

6 files changed

+62
-18
lines changed

Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,17 @@ place-earth:
215215
place-earth-age:
216216
scripts/place_candidate.sh earth_age
217217

218+
# Uploads all Earth image datasets
219+
place-earth-images:
220+
make place-earth-day
221+
make place-earth-night
222+
223+
place-earth-day:
224+
scripts/place_candidate.sh earth_day
225+
226+
place-earth-night:
227+
scripts/place_candidate.sh earth_night
228+
218229
# Uploads all Earth gravity/geodesy datasets
219230
place-earth-grav:
220231
make place-earth-edefl

recipes/earth_day.recipe

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
# format.
88
#
99
# SRC_FILE=BlueMarble_30s.tif
10-
# SRC_TITLE=NASA_Blue_Marble_Earth_Day_View
10+
# SRC_TITLE=Blue_Marble_Earth_Day_View
1111
# SRC_RADIUS=6371.0087714
1212
# SRC_REG=p
13+
# SRC_REF="NASA"
1314
# SRC_TYPE=image
1415
#
1516
# Destination: Specify output node registration, file prefix, and image format

recipes/earth_night.recipe

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
# format.
88
#
99
# SRC_FILE=BlackMarble_30s.tif
10-
# SRC_TITLE=NASA_Black_Marble_Earth_Night_View
10+
# SRC_TITLE=Black_Marble_Earth_Night_View
1111
# SRC_RADIUS=6371.0087714
1212
# SRC_REG=p
13+
# SRC_REF="NASA"
1314
# SRC_TYPE=image
1415
#
1516
# Destination: Specify output node registration, file prefix, and image format

scripts/srv_downsampler.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash -e
1+
#!/usr/bin/env bash -e
22
# srv_downsampler.sh - Filter the highest resolution image or grids to lower resolution versions
33
#
44
# usage: srv_downsampler.sh <recipefile> [-n] [split].

scripts/srv_downsampler_image.sh

+45-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash -e
1+
#!/usr/bin/env bash
22
# srv_downsampler_image.sh - Filter the highest resolution image to lower resolution versions
33
#
44
# usage: srv_downsampler_image.sh recipe [-f] [-n] [-x]
@@ -19,6 +19,13 @@
1919

2020
source scripts/filter_width_from_output_spacing.sh
2121

22+
# Hardwired settings for images
23+
DST_OFFSET=0
24+
DST_SCALE=1
25+
DST_TILE_SIZE=0
26+
DST_CPT=-
27+
MARK=""
28+
2229
if [ $# -eq 0 ]; then
2330
cat <<- EOF >&2
2431
usage: srv_downsampler_image.sh <recipefile> [-f] [-n] [-x]"
@@ -64,13 +71,15 @@ mkdir -p ${TMP}
6471
grep SRC_FILE $RECIPE | awk '{print $2}' > ${TMP}/par.sh
6572
grep SRC_RADIUS $RECIPE | awk '{print $2}' >> ${TMP}/par.sh
6673
grep SRC_TITLE $RECIPE | awk '{print $2}' >> ${TMP}/par.sh
74+
grep SRC_REF $RECIPE | awk '{print $2}' >> ${TMP}/par.sh
6775
grep SRC_REG $RECIPE | awk '{print $2}' >> ${TMP}/par.sh
6876
grep DST_MODE $RECIPE | awk '{print $2}' >> ${TMP}/par.sh
6977
grep DST_PLANET $RECIPE | awk '{print $2}' >> ${TMP}/par.sh
7078
grep DST_PREFIX $RECIPE | awk '{print $2}' >> ${TMP}/par.sh
7179
grep DST_FORMAT $RECIPE | awk '{print $2}' >> ${TMP}/par.sh
7280
source ${TMP}/par.sh
73-
81+
CITE=$(echo ${SRC_REF} | tr '_' ' ')
82+
TITLE=$(echo ${SRC_TITLE} | tr '_' ' ')
7483
# 4. Get the file name of the source file and output modifiers
7584
SRC_BASENAME=$(basename ${SRC_FILE})
7685
SRC_ORIG=${SRC_BASENAME}
@@ -120,31 +129,41 @@ while [ ! "X$1" == "X" ]; do
120129
shift # So that $2 now is next arg or blank
121130
done
122131

132+
# 9.0 Set info file here since no image tiling yet
133+
INFOFILE=${DST_PLANET}/${DST_PREFIX}/${DST_PREFIX}_server.txt
134+
123135
# 9.1 Check if just reporting
124136

125-
if [ ${DST_BUILD} -eq 0 ]; then # Report variables
137+
if [ ${DST_BUILD} -eq 1 ]; then # Start building info file
138+
if [ -d ${DST_PLANET}/${DST_PREFIX} ]; then
139+
if [ ${DST_FORCE} -eq 1 ]; then
140+
rm -rf ${DST_PLANET}/${DST_PREFIX}
141+
else
142+
echo "Data set directory ${DST_PLANET}/${DST_PREFIX} already exists - aborting. Use -f to force removal instead."
143+
exit -1
144+
fi
145+
fi
146+
mkdir -p ${DST_PLANET}/${DST_PREFIX}
147+
cat <<- EOF > ${INFOFILE}
148+
#
149+
# ${TITLE}
150+
#
151+
EOF
152+
else # Just report parameters and tasks
126153
cat <<- EOF
127154
# Final parameters after processing ${RECIPE}:
128155
129156
SRC_ORIG ${SRC_ORIG}
130157
SRC_FILE ${SRC_FILE}
131158
SRC_REG ${SRC_REG}
132159
DST_SPLIT ${DST_SPLIT}
133-
TITLE ${SRC_TITLE}
160+
INFOFILE ${INFOFILE}
161+
TITLE ${TITLE}
162+
CITE ${CITE}
134163
135164
# Processing steps to be taken if -n was not given:
136165
137166
EOF
138-
else # Make files in given directory unless it exists and no -f
139-
if [ -d ${DST_PLANET}/${DST_PREFIX} ]; then
140-
if [ ${DST_FORCE} -eq 1 ]; then
141-
rm -rf ${DST_PLANET}/${DST_PREFIX}
142-
else
143-
echo "Data set directory ${DST_PLANET}/${DST_PREFIX} already exists - aborting. Use -f to force removal instead."
144-
exit -1
145-
fi
146-
fi
147-
mkdir -p ${DST_PLANET}/${DST_PREFIX}
148167
fi
149168

150169
# 9.2 Get the right projection ellipsoid/spheroid for this planetary body
@@ -154,6 +173,9 @@ else
154173
DST_SPHERE=${DST_PLANET}
155174
fi
156175

176+
# 9.4 Get creation date
177+
creation_date=$(date +%Y-%m-%d)
178+
157179
# 10. Loop over all the resolutions found
158180

159181
while read RES UNIT TILE MASTER; do
@@ -183,13 +205,19 @@ while read RES UNIT TILE MASTER; do
183205
echo "${DST_FILE} exist - skipping"
184206
elif [ "X${MASTER}" = "Xmaster" ]; then # Just make a copy of the master to a new output file
185207
echo "Convert ${SRC_FILE} to ${DST_FILE}"
208+
SIZE=$(ls -lh ${SRC_FILE} | awk '{print $5}')
209+
MSG="${TITLE} original at ${RES}x${RES} arc ${UNIT_NAME}"
186210
if [ ${DST_BUILD} -eq 1 ]; then
187211
cp ${SRC_FILE} ${DST_FILE}
212+
printf "%s/server/%s/%s/\t%s_%s_%s\t%s\t%s\t%s\t%s\t%4s\t%s\t%s\t-\t-\t\t%s [%s]\n" \
213+
"${MARK}" ${DST_PLANET} ${DST_PREFIX} ${DST_PREFIX} ${FTAG} ${SRC_REG} ${TAG} ${SRC_REG} ${DST_SCALE} ${DST_OFFSET} ${SIZE} ${DST_TILE_SIZE} ${creation_date} "${MSG}" "${CITE}" >> ${INFOFILE}
188214
fi
189215
else # Must down-sample to a lower resolution via spherical Gaussian filtering
190216
# Get suitable Gaussian full-width filter rounded to nearest 0.1 km after adding 50 meters for noise
191217
FILTER_WIDTH=$(filter_width_from_output_spacing ${INC})
192218
FWR_SEC=$(gmt math -Q 2 2 SQRT MUL ${INC} MUL 3600 MUL RINT =)
219+
FTAG="${IRES}${UNIT}"
220+
MSG="${TITLE} at ${RES}x${RES} arc ${UNIT_NAME} reduced by Gaussian ${DST_MODE} r/g/b filtering (${FILTER_WIDTH} km fullwidth)"
193221
if [ ${DST_BUILD} -eq 1 ]; then
194222
printf "Down-filter ${SRC_FILE} to ${DST_FILE} FW = ${FILTER_WIDTH} km [${FWR_SEC}s] via layers "
195223
gmt grdmix ${SRC_FILE} -D -G/tmp/tmp_%c.nc=ns
@@ -199,6 +227,9 @@ while read RES UNIT TILE MASTER; do
199227
done
200228
printf " > ${DST_FORMAT}\n"
201229
gmt grdmix -C /tmp/tmp_filt_r.nc /tmp/tmp_filt_g.nc /tmp/tmp_filt_b.nc -G${DST_FILE} -Ni
230+
SIZE=$(ls -lh ${DST_FILE} | awk '{print $5}')
231+
printf "%s/server/%s/%s/\t%s_%s_%s\t%s\t%s\t%s\t%s\t%4s\t%s\t%s\t-\t-\t\t%s [%s]\n" \
232+
"${MARK}" ${DST_PLANET} ${DST_PREFIX} ${DST_PREFIX} ${FTAG} ${SRC_REG} ${TAG} ${SRC_REG} ${DST_SCALE} ${DST_OFFSET} ${SIZE} ${DST_TILE_SIZE} ${creation_date} $"${MSG}" "${CITE}" >> ${INFOFILE}
202233
else
203234
echo "Down-filter ${SRC_FILE} to ${DST_FILE} via R, G, and B layers. FW = ${FILTER_WIDTH} km [${FWR_SEC}s]"
204235
fi

scripts/srv_tiler.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash -e
1+
#!/usr/bin/env bash -e
22
# srv_tiler.sh - Split a large grid into suitable square tiles
33
#
44
# usage: srv_tiler.sh recipe [-n].

0 commit comments

Comments
 (0)