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

nn.sh 1.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
  1. #!/usr/bin/env bash
  2. # Testing gmt spatial nearest neighbor options
  3. #
  4. # Input was made this way.
  5. #gmt math -T0/9/1 -o1 0 10 RAND = x
  6. #gmt math -T0/9/1 -o1 0 10 RAND = y
  7. #gmt math -T0/9/1 -o1 0 100 RAND = z
  8. #paste x y z > points.txt
  9. ps=nn.ps
  10. DATA=$(gmt which -G @nn_points.txt)
  11. # NN analysis
  12. gmt spatial -Aa0k -fg $DATA > results.txt
  13. gmt set MAP_FRAME_TYPE plain
  14. gmt psxy -R-0.5/10.5/-0.5/10.5 -JM4.5i -P -Bag1 -BWSne $DATA -Sc0.1i -Gred -K -Xc > $ps
  15. awk '{print $1, $2, NR-1}' $DATA | gmt pstext -R -J -O -K -F+f12+jCB -Dj0.1i >> $ps
  16. rm -f tmp
  17. # Draw links of nearest neighbors
  18. while read x y z w d A B; do
  19. echo "> $A to $B" >> tmp
  20. let A=A+1
  21. let B=B+1
  22. sed -n ${A}p $DATA >> tmp
  23. sed -n ${B}p $DATA >> tmp
  24. done < results.txt
  25. gmt psxy -R -J -O -K -W1p,green tmp >> $ps
  26. # NN averaging
  27. gmt spatial -Aa75k -fg $DATA > results.txt
  28. gmt psxy -R -J -O -K -Bag1 -BWsne $DATA -Sc0.1i -Glightgray -Y4.75i $DATA >> $ps
  29. awk '{print $1, $2, 0, 150, 150}' results.txt | gmt psxy -R -J -O -K -SE -W0.5p,blue >> $ps
  30. gmt psxy -R -J -O results.txt -Sc0.1i -Gred >> $ps
Tip!

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

Comments

Loading...