-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Final version of updates for 6.5: grdimage, colorbar, grdmix (#8251)
* Update grdimage.c Moving parts over from old branch * More brought over and still no failures * Update grdimage.c * Update grdimage.c * More copying with no failures * More OK updates * Update grdimage.c * Add test grid_transp.sh * Handle -Q+i for image * Add transp_mix test and PS * Update grdimage.c Did not test OpenMP so missed some new variables. * Update transp_mix.sh * Update grdimage.dvc * Fix OpenMP issue * Add image_vartrans.sh test and PS to DVC * Update grdimage.c * Update image_vartrans.sh * polish * Add test grdimage_Q_effects.sh and PS to DVC * indents * Update grdimage.c * Be more careful on memory layout for iimages This PR does now write a blank space after TRB, but places a there only if the images has transparency. * Fill in missing variables in OPENMP pragmas Especially in grdmix * Add gmt_setrgb and remove OPENMP loop when PSL memory is required * Update grdimage.c * Update grdimage.c * Fix opacity issue * Update psscale.c Finalize the -Li|I positioning and frame dimensions and not break previous tests. * Add new test and in DVC * alpha_count instead of alpha, which is unclear. --------- Co-authored-by: Joaquim <jluis@ualg.pt>
- Loading branch information
1 parent
104bcdb
commit e8c8817
Showing
16 changed files
with
511 additions
and
83 deletions.
There are no files selected for viewing
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
outs: | ||
- md5: d1c15fadf2e09ad118cc77c53bbbff92.dir | ||
nfiles: 31 | ||
- md5: 226f00f8bb56bfda27786069c3ecfa19.dir | ||
nfiles: 35 | ||
path: grdimage | ||
hash: md5 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
outs: | ||
- md5: 4aa0bfc2018d514b2b1e7af6231f457f.dir | ||
size: 2345366 | ||
- md5: 6549edda1e5c0c5ac5f3917baf574a83.dir | ||
nfiles: 2 | ||
path: grdmix | ||
hash: md5 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
outs: | ||
- md5: 452ffd60491b33499fed19555a0bb535.dir | ||
size: 1400714 | ||
nfiles: 25 | ||
- md5: 6e77da8a8cb4a2816e41162fe275360d.dir | ||
size: 1431120 | ||
nfiles: 26 | ||
path: psscale | ||
hash: md5 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Testing a simple grid with -Q options for transparency based on | ||
# a computed color (via grid z-value and CPT) or a specific color. | ||
|
||
gmt begin grdimage_Q_effects | ||
gmt set FONT_TAG 12p PS_MEDIA letter | ||
gmt grdmath -R0/100/0/50 -I1 -rp X 10 DIV FLOOR = stripes.nc | ||
gmt grdmath -Rstripes.nc X 100 DIV Y 50 DIV MUL 2 MUL 1 SUB = intensity.nc | ||
gmt makecpt -Chot -T0/10/1 | ||
gmt subplot begin 4x1 -R0/100/0/50 -Fs15c/5c -JX15c/5c -Scb -Srl -A+gwhite+p0.25p -Bafg10 -X3c -Y3c | ||
# 1. Just plot the stripes grid with no other effects | ||
gmt subplot set 0 -A"PLAIN GRID and CPT [NO -Q]" | ||
gmt basemap | ||
echo 50 20 BACKGROUND | gmt text -F+f32p,1+a45 | ||
gmt grdimage stripes.nc | ||
# 2. Plot stripes with intensity variations | ||
gmt subplot set 1 -A"SAME PLUS LINEAR INTENSITY FROM LL (-1) TO UR (+1) [No -Q]" | ||
gmt basemap | ||
echo 50 20 BACKGROUND | gmt text -F+f32p,1+a45 | ||
gmt grdimage stripes.nc -Iintensity.nc | ||
# 3. Plot stripes but set z = 5 to be transparent | ||
gmt subplot set 2 -A"PLAIN GRID WITH TRANSPARENCY FOR Z = 5 [-Q+z5]" | ||
gmt basemap | ||
echo 50 20 BACKGROUND | gmt text -F+f32p,1+a45 | ||
gmt grdimage stripes.nc -Q+z5 | ||
# 4. Plot stripes but set color equal yellow (z = 7-8) to be transparent | ||
gmt subplot set 3 -A"PLAIN GRID WITH TRANSPARENCY AT COLOR = yellow (z = 7-8) [-Qyellow]" | ||
gmt basemap | ||
echo 70 25 BACKGROUND | gmt text -F+f32p,1+a45 | ||
gmt grdimage stripes.nc -Qyellow | ||
gmt subplot end | ||
# Place the colorbar beneath the subplot */ | ||
gmt colorbar -DJBC | ||
gmt end show |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Testing various grids and transparency in grdimage | ||
# Top row is a topo relief grid (image via CPT) and the same grid with fake NaNs to be transparent | ||
|
||
gmt begin grid_transp | ||
gmt set FONT_TAG 12p PS_MEDIA letter | ||
# Make two grids: one a 0|1 multiply grid setting a region to zero and one making NaNs over Africa and 1 elsewhere | ||
gmt grdmath -Rd -I01d -rp -fg 1 X -40 SUB ABS 40 LT Y -20 SUB ABS 20 LT MUL SUB = zero.nc | ||
gmt grdmath -Rzero.nc 0 0 SDIST 4000 GT 0 NAN = nan.nc | ||
gmt subplot begin 4x1 -Rd -Fs12c/6c -JQ12c -Scb -Srl -A+gwhite+p0.25p -Bafg10 -X5c -Y1c | ||
# 1. Plot 01d relief grid on top of grid lines (which will be invisible) | ||
gmt subplot set 0 -A"TOPOGRAPHY GRID WITH NO NANS" | ||
gmt basemap | ||
echo 0 0 BACKGROUND | gmt text -F+f32p,1+a45 | ||
gmt grdimage @earth_relief_01d_p | ||
# 2. Plot 01d relief grid after setting a R=4000 chunk around (0,0) to NaNs | ||
gmt subplot set 1 -A"TOPOGRAPHY GRID WITH NANS AS MISSING DATA" | ||
gmt grdmath nan.nc @earth_relief_01d_p MUL = hurt.nc | ||
gmt basemap | ||
echo 0 0 BACKGROUND | gmt text -F+f32p,1+a45 | ||
gmt grdimage hurt.nc -Cgeo | ||
# 3. Plot the same grid but now say NaNs should be transparent | ||
gmt subplot set 2 -A"TOPO WITH NANS INDICATING FULL TRANSPARENCY" | ||
gmt basemap | ||
echo 0 0 BACKGROUND | gmt text -F+f32p,1+a45 | ||
gmt grdimage hurt.nc -Cgeo -Q | ||
# 4. Plot 01d relief grid after setting a big chunk to zero and say zero is transparent | ||
gmt grdmath zero.nc @earth_relief_01d_p MUL = hurt.nc | ||
gmt subplot set 3 -A"TOPO WITH ZEROS INDICATING FULL TRANSPARENCY" | ||
gmt basemap | ||
echo 0 0 BACKGROUND | gmt text -F+f32p,1+a45 | ||
gmt grdimage hurt.nc -Cgeo -Q+z0 | ||
gmt subplot end | ||
gmt end show |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
# For variable transparency TIF we plot pixels as squares with individual transparency | ||
# Must add -Q to revert to original opaque blended image (color match the transparent | ||
# colors but the pixels remain opaque). | ||
|
||
gmt begin image_vartrans | ||
gmt set FONT_TAG 9p PS_MEDIA letter | ||
gmt subplot begin 4x1 -Rd -Fs12c/6c -JQ12c -Scb -Srl -A+gwhite+p0.25p -Bafg10 -X5c -Y1c | ||
# 1. Create and plot a continuously varying transparency grid (0-1) | ||
gmt grdmath -Rd -I01d -r Y 180 DIV 0.5 ADD = transparency.nc | ||
gmt subplot set 0 -A"FAKE VARIABLE TRANSPARENCIES" | ||
gmt grdcontour transparency.nc -C0.05 -A0.1 | ||
# 2. Plot original day image | ||
gmt subplot set 1 -A"RGB IMAGE WITH NO TRANSPARENCY (OPAQUE)" | ||
gmt basemap | ||
echo 0 0 BACKGROUND | gmt text -F+f32p,1+a45 | ||
gmt grdimage @earth_day_01d | ||
# 3. Achieve variable transparency via transparent squares as pixels | ||
gmt subplot set 2 -A"RGBA IMAGE WITH VARIABLE TRANSPARENCY AS SQUARES" | ||
gmt basemap | ||
echo 0 0 BACKGROUND | gmt text -F+f32p,1+a45 | ||
# Plot 01d day image grid after adding variable transparency | ||
gmt grdmix @earth_day_01d -Atransparency.nc -C -Grgba.tif | ||
gmt grdimage rgba.tif | ||
# 4. Do variable transparency via image blending instead (opaque) | ||
gmt subplot set 3 -A"RGBA IMAGE WITH VARIABLE TRANSPARENCY AS OPAQUE BLEND" | ||
gmt basemap | ||
echo 0 0 BACKGROUND | gmt text -F+f32p,1+a45 | ||
gmt grdimage rgba.tif -Q | ||
gmt subplot end | ||
gmt end show |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Testing gmt grdmix on adding A to RGB image and plot via grdimage | ||
|
||
gmt begin transp_mix ps | ||
gmt set MAP_GRID_PEN 2p FONT_TAG 9p PS_MEDIA letter PS_PAGE_ORIENTATION portrait | ||
gmt grdmath -Rd -I01d -rp X 360 DIV 0.5 ADD Y 180 DIV 0.5 ADD MUL = transparency.nc | ||
gmt subplot begin 3x2 -Rd -Fs9c/4.5c -JQ9c -Scb -Srl -A+gwhite+p0.25p -Bafg30 -X2c | ||
# 1. Plot 01d day image on top of grid lines (which will be invisible) | ||
gmt subplot set 0 -A"JUST IMAGE (OPAQUE)" | ||
gmt basemap | ||
gmt grdimage @earth_day_01d_p | ||
# 2. Plot the fake transparencies | ||
gmt subplot set 1 -A"FAKE TRANSPARENCY (OPAQUE)" | ||
gmt basemap | ||
gmt grdimage transparency.nc -Chot | ||
# 3. Ignore transparencies when making the tif and plot the image on top of grid lines (which will be invisible) | ||
gmt grdmix @earth_day_01d_p -C -Grgba.tif -A0.7 | ||
gmt subplot set 2 -A"IMAGE FIXED 0.7 TRANSPARENCY (TRUE TRANSPARENCY)" | ||
gmt basemap | ||
gmt grdimage rgba.tif | ||
# 4. Mix transparencies into the tif and plot the image on top of grid lines (which will be invisible) | ||
gmt grdmix @earth_day_01d_p -Atransparency.nc+o -C -Grgba.tif | ||
gmt subplot set 3 -A"BLENDED TRANSPARENT IMAGE (OPAQUE)" | ||
gmt basemap | ||
gmt grdimage rgba.tif -Q | ||
# 5. Plot image using -Q+i to invert opacity to transparency on top of grid lines (which will be invisible) | ||
gmt subplot set 4 -A"BLENDED OPACITY IMAGE (OPAQUE)" | ||
gmt basemap | ||
gmt grdimage rgba.tif -Q | ||
# 6. Plot image using defaults on top of grid lines (which will visible through the squares) | ||
gmt subplot set 5 -A"DEFAULT IMAGE VIA SQUARES (TRUE TRANSPARENCY)" | ||
gmt basemap | ||
gmt grdimage rgba.tif | ||
gmt subplot end | ||
gmt end show |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Testing categorical colorbars with default panels and interval annotations | ||
# E.g., https://forum.generic-mapping-tools.org/t/colorbar-box-and-annotation/4548 | ||
|
||
ps=interval-panel.ps | ||
|
||
cat << EOF > t.cpt | ||
# COLOR_MODEL = RGB | ||
0 247/251/255 10 247/251/255 | ||
10 222/235/247 20 222/235/247 | ||
20 198/219/239 50 198/219/239 | ||
50 158/202/225 100 158/202/225 | ||
100 107/174/214 150 107/174/214 | ||
150 066/146/198 200 066/146/198 | ||
200 033/113/181 300 033/113/181 | ||
300 008/081/156 500 008/081/156 | ||
500 008/048/107 600 008/048/107 | ||
EOF | ||
# Vertical colorbars | ||
gmt psscale -Ct.cpt -Dx0c/13c+w12c+v -Li3p -F+p2p -P -K > ${ps} | ||
gmt psscale -Ct.cpt -Dx5c/13c+w12c+v -LI3p -F+p2p -O -K >> ${ps} | ||
gmt psscale -Ct.cpt -Dx10c/13c+w12c+v -Li3p -O -K >> ${ps} | ||
gmt psscale -Ct.cpt -Dx15c/13c+w12c+v -LI3p -O -K >> ${ps} | ||
# Horizontal colorbars | ||
gmt psscale -Ct.cpt -Dx0c/1c+w18c+h -Li3p -F+p2p -O -K -X-1c >> ${ps} | ||
gmt psscale -Ct.cpt -Dx0c/4c+w18c+h -LI3p -F+p2p -O -K >> ${ps} | ||
gmt psscale -Ct.cpt -Dx0c/7c+w18c+h -Li3p -O -K >> ${ps} | ||
gmt psscale -Ct.cpt -Dx0c/10c+w18c+h -LI3p -O >> ${ps} |