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

GMT_encoding.sh 1.4 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
  1. #!/usr/bin/env bash
  2. #
  3. #
  4. # This plots the given encoding vector to stdout
  5. #
  6. # e.g., GMT_encoding.sh ISO-8859-1 | gv -
  7. # Dimensions are in inches.
  8. if [ $# -eq 0 ]; then
  9. exit
  10. fi
  11. cat << EOF > tt.awk
  12. # This awk script creates the tt.chart table of which entries are defined
  13. {
  14. printf "%d\t", NR-1
  15. for (i = 1; i < 8; i++)
  16. {
  17. if (\$i != "/.notdef") printf "%d", i-1
  18. printf "\t"
  19. }
  20. if (\$8 != "/.notdef") printf "7"
  21. printf "\n"
  22. }
  23. EOF
  24. # Need access to PS source files for this plot
  25. GMT_SHAREDIR=$(gmt --show-sharedir)
  26. egrep -v '\[|\]' "${GMT_SHAREDIR}"/share/postscriptlight/$1.ps | $AWK -f tt.awk > tt.chart
  27. cat << EOF > tt.awk
  28. # This awk script creates a file for gmt plot to plot a rectangle for undefined entries
  29. {
  30. for (i = 1; i <= 8; i++)
  31. {
  32. if (\$i == "/.notdef") printf "%g %g 0.345 0.21\n", i + 0.5, NR-0.5
  33. }
  34. }
  35. EOF
  36. egrep -v '\[|\]' "${GMT_SHAREDIR}"/share/postscriptlight/$1.ps | $AWK -f tt.awk > tt.empty
  37. cat << EOF > tt.awk
  38. BEGIN {
  39. printf "0.5 -0.5 octal\n"
  40. for (i = 0; i < 8; i++)
  41. {
  42. printf "%g -0.5 %d\n", i + 1.5, i
  43. }
  44. }
  45. {
  46. printf "0.5 %g \\\\\\\%02ox\n", \$1+0.5, \$1
  47. for (i = 2; i <= NF; i++)
  48. {
  49. printf "%g %g \\\\%02o%o\n", \$i+1.5, \$1+0.5, \$1, \$i
  50. }
  51. }
  52. EOF
  53. gmt begin GMT_encoding
  54. gmt set GMT_THEME cookbook
  55. gmt set PS_CHAR_ENCODING $1
  56. gmt plot -R0/9/-1/32 -Jx0.345i/-0.21i -Bg1 -B+t"Octal codes for $1" -Ggray -X3i -Sri tt.empty
  57. $AWK -f tt.awk tt.chart | gmt text -F+f10p,Times-Roman
  58. gmt plot -Wthick << EOF
  59. >
  60. 0 0
  61. 9 0
  62. >
  63. 1 0
  64. 1 32
  65. EOF
  66. gmt end show
Tip!

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

Comments

Loading...