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

hexbinning.sh 2.0 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
  1. #!/usr/bin/env bash
  2. # Test hexagon tile binning on counting values in gmtbinstats
  3. #
  4. # Hardwire some values to draw the bottom plot so we avoid lots of shell math
  5. # The commented stuff shows how the script and data were developed
  6. #e=5
  7. #n=3
  8. #dy=1
  9. #ny=$(gmt math -Q $n SUB $dy DIV =)
  10. #r=$(gmt math -Q $dy 0.5 MUL 30 COSD DIV =)
  11. #dx=$(gmt math -Q 3 $r MUL =)
  12. #nx=$(gmt math -Q $e $dx DIV RINT 1 ADD =)
  13. #e2=$(gmt math -Q 0 $nx 1 SUB $dx MUL ADD =)
  14. #r=$(gmt math -Q $dy 30 COSD DIV =)
  15. #echo "Revised: 0/$e2/0/$n -I$dx/$dy for a pseudo $nx by $ny grid with hexagon radius $r"
  16. #dx2=$(gmt math -Q $dx 2 DIV =)
  17. #dy2=$(gmt math -Q $dy 2 DIV =)
  18. #wb=$(gmt math -Q 0 $dx2 ADD =)
  19. #eb=$(gmt math -Q $e2 $dx2 SUB =)
  20. #sb=$(gmt math -Q 0 $dy2 ADD =)
  21. #nb=$(gmt math -Q $n $dy2 SUB =)
  22. #rh=$(gmt math -Q 4 30 COSD DIV =)
  23. #gmt math -T1/100/1 0 $e2 RAND = x
  24. #gmt math -T1/100/1 0 $n RAND = y
  25. #gmt math -T1/100/1 50 25 NRAND = z
  26. #gmt convert -A x y z -o1,3,5 > hex_data.txt
  27. # Create grids to find nodes of hexagons
  28. gmt grdmath -R0/5.19615242271/0/3 -I1.73205080757/1 0 = b.grd
  29. gmt grdmath -R0.866025403785/4.33012701893/0.5/2.5 -I1.73205080757/1 0 = r.grd
  30. gmt grdmath -R0/5.19615242271/0/3 -I0.866025403785/0.5 0 = t.grd
  31. gmt begin hexbinning ps
  32. gmt grd2xyz b.grd | gmt plot -Sh3.46410161514c -Glightblue@50 -W1p -N -R0/5.19615242271/0/3 -Jx3c -X3.2c
  33. gmt grd2xyz b.grd | gmt plot -Sh3.46410161514c -Glightblue -W1p
  34. gmt grd2xyz r.grd | gmt plot -Sh3.46410161514c -Glightred@50 -W1p -N
  35. gmt grd2xyz r.grd | gmt plot -Sh3.46410161514c -Glightred -W1p
  36. gmt grdmath -R0/5.19615242271/0/3 -I0.866025403785/0.5 0 = t.grd
  37. gmt grd2xyz t.grd | gmt plot -Sc0.2c -Gwhite -Wfaint -N
  38. gmt grd2xyz r.grd b.grd | gmt plot -Sc0.2c -Gblack -N
  39. gmt basemap -Bxafg0.866025403785 -Byafg0.5
  40. gmt plot hex_data.txt -Ss0.2c -Gyellow -Wfaint
  41. gmt binstats hex_data.txt -R0/5/0/3 -I1 -Th -Cn > bin.txt
  42. gmt makecpt -Cjet -T1/10/1 -A50
  43. gmt plot -Baf -Y12c bin.txt -C -Sh3.46410161514c -W1p -B+t"Hexagonal Binning"
  44. gmt text bin.txt -F+f14p,Helvetica-Bold -Gwhite -W0.25p -N
  45. gmt end show
Tip!

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

Comments

Loading...