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.3 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  1. #!/bin/sh
  2. # $Id$
  3. # Testing grdfilter's weights at a given point for a given
  4. # filter diameter. Specify which output you want (a|c|r|w).
  5. # Change args below to pick another filter.
  6. . ../functions.sh
  7. header "Test grdfilter for filter weights (-DDEBUG only)"
  8. grep DEBUG ../../src/config.mk > tmp
  9. if [ ! -s tmp ]; then
  10. echo "[N/A]"
  11. rm -f tmp
  12. exit
  13. fi
  14. FILT=g # Gaussian filter
  15. INC=1 # 1x1 degree output
  16. DATA=../genper/etopo10.nc # Test on ETOP10 data
  17. ps=filtertest.ps
  18. pdf=`basename $ps ".ps"`.pdf
  19. if [ $# -ne 4 ]; then
  20. lon=150
  21. lat=-80
  22. D=5000
  23. mode=c
  24. no_U=1
  25. else
  26. lon=$1
  27. lat=$2
  28. D=$3
  29. mode=$4
  30. U="-U/-0.5i/-0.25i/$0 $*"
  31. no_U=
  32. fi
  33. # Set contour limits so we just draw the filter radius
  34. lo=`gmtmath -Q $D 2 DIV 0.5 SUB =`
  35. hi=`gmtmath -Q $D 2 DIV 0.5 ADD =`
  36. # Run grdfilter as specified
  37. grdfilter -A${mode}${lon}/$lat -D4 -F${FILT}$D -I$INC $DATA -Gt.nc -fg
  38. n_conv=`cat n_conv.txt`
  39. if [ $lat -lt 0 ]; then # S hemisphere view
  40. plat=-90
  41. range=-90/0
  42. else # N hemisphere view
  43. plat=90
  44. range=0/90
  45. fi
  46. if [ $mode = r ]; then # Set a different cpt for radius in km
  47. grdmath t.nc 0 NAN = t.nc
  48. grd2cpt -Crainbow t.nc -E20 -N -Z > t.cpt
  49. t=500
  50. else # Just normalize the output to 0-1 and make a cpt to fit
  51. grdmath t.nc DUP UPPER DIV 0 NAN = t.nc
  52. makecpt -Crainbow -T0/1/0.02 -N -Z > t.cpt
  53. t=0.1
  54. fi
  55. echo "N white" >> t.cpt # White is NaN
  56. # Compute radial distances from our point
  57. grdmath -fg -R0/360/-90/90 -I1 $lon $lat SDIST DEG2KM = r.nc
  58. # Plot polar map of result
  59. if [ $no_U -eq 1 ]; then
  60. grdimage t.nc -JA0/$plat/7i -P -B30g10 -Ct.cpt -R0/360/$range -K -X0.75i -Y0.5i > $ps
  61. else
  62. grdimage t.nc -JA0/$plat/7i -P -B30g10 -Ct.cpt -R0/360/$range -K -X0.75i -Y0.5i "$U" > $ps
  63. fi
  64. # Plot location of our test point
  65. echo ${lon} $lat | psxy -R -J -O -K -Sx0.1 -W1p >> $ps
  66. # Draw filter boundary
  67. grdcontour r.nc -J -O -K -C1 -L$lo/$hi -W1p -R0/360/$range >> $ps
  68. # Repeat plots in rectangular projection
  69. grdimage t.nc -JQ00/7i -B30g10:."$D km Gaussian at ($lon, $lat)":WsNe -Ct.cpt -O -K -Y7.8i -R0/360/$range --FONT_TITLE=18p >> $ps
  70. echo ${lon} $lat | psxy -R -J -O -K -Sx0.1 -W1p >> $ps
  71. grdcontour -R0/360/$range r.nc -J -O -K -C1 -L$lo/$hi -W1p >> $ps
  72. psscale -Ct.cpt -D3.5i/-0.15i/6i/0.05ih -O -K -B$t/:"${mode} [$n_conv]": >> $ps
  73. psxy -R -J -O -T >> $ps
  74. if [ $# -eq 4 ]; then
  75. ps2raster $ps -Tf
  76. open $pdf
  77. fi
  78. rm -f t.nc r.nc t.cpt n_conv.txt tmp
  79. pscmp
Tip!

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

Comments

Loading...