Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

filtertest.sh 2.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  1. #!/usr/bin/env bash
  2. # Testing gmt grdfilter's weights at a given point for a given
  3. # filter diameter. Specify which output you want (a|c|r|w).
  4. # Change args below to pick another filter.
  5. if [ "$HAVE_GMT_DEBUG_SYMBOLS" != "TRUE" ]; then
  6. echo "grdfilter -A option is not available without -DDEBUG"
  7. exit
  8. fi
  9. ps=filtertest.ps
  10. if [[ ${HAVE_GLIB_GTHREAD} =~ TRUE|ON ]]; then
  11. _thread_opt=-x+a
  12. fi
  13. FILT=g # Gaussian filter
  14. INC=1 # 1x1 degree output
  15. DATA=@earth_relief_10m # Test on ETOP10 data
  16. lon=150
  17. lat=-80
  18. D=5000
  19. mode=c
  20. no_U=1
  21. gmt set PROJ_ELLIPSOID Sphere
  22. # Set contour limits so we just draw the filter radius
  23. lo=$(gmt math -Q $D 2 DIV 0.5 SUB =)
  24. hi=$(gmt math -Q $D 2 DIV 0.5 ADD =)
  25. # Run gmt grdfilter as specified
  26. gmt grdfilter -A${mode}${lon}/$lat -D4 -F${FILT}$D -I$INC $DATA -Gt.nc -fg ${_thread_opt}
  27. n_conv=$(cat n_conv.txt)
  28. if [ $lat -lt 0 ]; then # S hemisphere view
  29. plat=-90
  30. range=-90/0
  31. else # N hemisphere view
  32. plat=90
  33. range=0/90
  34. fi
  35. if [ $mode = r ]; then # Set a different cpt for radius in km
  36. gmt grdmath t.nc 0 NAN = t.nc
  37. gmt grd2cpt -Crainbow t.nc -E20 -N -Z > t.cpt
  38. t=500
  39. else # Just normalize the output to 0-1 and make a cpt to fit
  40. gmt grdmath t.nc DUP UPPER DIV 0 NAN = t.nc
  41. gmt makecpt -Crainbow -T0/1 -N > t.cpt
  42. t=0.1
  43. fi
  44. echo "N white" >> t.cpt # White is NaN
  45. # Compute radial distances from our point
  46. gmt grdmath -fg -R0/360/-90/90 -I1 $lon $lat SDIST = r.nc
  47. # Plot polar map of result
  48. if [ $no_U -eq 1 ]; then
  49. gmt grdimage t.nc -JA0/$plat/7i -P -B30g10 -Ct.cpt -R0/360/$range -K -X0.75i -Y0.5i > $ps
  50. else
  51. gmt grdimage t.nc -JA0/$plat/7i -P -B30g10 -Ct.cpt -R0/360/$range -K -X0.75i -Y0.5i "$U" > $ps
  52. fi
  53. # Plot location of our test point
  54. echo ${lon} $lat | gmt psxy -R -J -O -K -Sx0.1 -W1p >> $ps
  55. # Draw filter boundary
  56. gmt grdcontour r.nc -J -O -K -C1 -L$lo/$hi -W1p -R0/360/$range >> $ps
  57. # Repeat plots in rectangular gmt projection
  58. gmt grdimage t.nc -JQ0/7i -B30g10 -BWsNe+t"$D km Gaussian at ($lon, $lat)" -Ct.cpt -O -K -Y7.8i -R-180/180/$range --FONT_TITLE=18p >> $ps
  59. echo ${lon} $lat | gmt psxy -R -J -O -K -Sx0.1 -W1p >> $ps
  60. gmt grdcontour -R r.nc -J -O -K -C1 -L$lo/$hi -W1p >> $ps
  61. gmt psscale -Ct.cpt -Dx3.5i/-0.15i+w6i/0.05i+h+jTC -O -Bx$t -By+l"${mode} [$n_conv]" >> $ps
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...