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

io.sh 1.7 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
  1. #!/usr/bin/env bash
  2. #
  3. # Test that the -i, -o, -bi and bo works OK.
  4. # 0. create the file with correct answers:
  5. cat << EOF > io_answer.txt
  6. 0 0 0
  7. 0 0 0
  8. 0 0
  9. 0 0
  10. EOF
  11. # 1. Prepare input files with 8 columns, both ASCII and binary
  12. cat << EOF > ascii_i.txt
  13. 0 4.1 0 0 4.1 0 41 1
  14. 3 4.3 9 3 1.3 90 13 91
  15. 4.67 4 6 4.67 4 60 4 61
  16. 0.69 3.33 4 0.69 3.33 40 33 41
  17. 2 3.3 5 2 3.3 50 33 51
  18. 5 3.35 8 5 3.35 80 35 81
  19. 0.25 2.25 3 0.25 2.25 30 25 31
  20. 3 2 7 3 2 70 2 71
  21. 1.33 1.8 2 1.33 1.8 20 18 21
  22. 0.65 0.7 1 0.65 0.7 10 7 11
  23. EOF
  24. gmt convert ascii_i.txt -bo8d > bin_i.b
  25. # 2. do basic gmt blockmean ASCII/bin i/o with no -i/-o
  26. gmt blockmean -R0/5/0/5 -I1 -r ascii_i.txt > ascii_o.txt
  27. gmt blockmean -R0/5/0/5 -I1 -r bin_i.b -bi8d -bo3d | gmt convert -bi3d > bin_o.txt
  28. gmt math -T -Sl ascii_o.txt bin_o.txt SUB SUM = io_result.txt
  29. # 3. Same as 2, but with selecting cols 3:5 via -i
  30. gmt blockmean -R0/5/0/5 -I1 -r ascii_i.txt -i3:5 > ascii_o.txt
  31. gmt blockmean -R0/5/0/5 -I1 -r bin_i.b -bi8d -i3:5 -bo3d | gmt convert -bi3d > bin_o.txt
  32. gmt math -T -Sl ascii_o.txt bin_o.txt SUB SUM = >> io_result.txt
  33. # 4. Same 2-3, but just output cols 2,0 via -o
  34. gmt blockmean -R0/5/0/5 -I1 -r ascii_i.txt -o2,0 > ascii_o.txt
  35. gmt blockmean -R0/5/0/5 -I1 -r bin_i.b -bi8d -o2,0 -bo2d | gmt convert -bi2d > bin_o.txt
  36. gmt math -T -Sl ascii_o.txt bin_o.txt SUB SUM = >> io_result.txt
  37. # 5. Same 5, but with selecting cols 3:5 via -i and output cols 2,0 via -o
  38. gmt blockmean -R0/5/0/5 -I1 -r ascii_i.txt -i3:5 -o2,0 > ascii_o.txt
  39. gmt blockmean -R0/5/0/5 -I1 -r bin_i.b -bi8d -i3:5 -o2,0 -bo2d | gmt convert -bi2d > bin_o.txt
  40. gmt math -T -Sl ascii_o.txt bin_o.txt SUB SUM = >> io_result.txt
  41. diff io_result.txt io_answer.txt --strip-trailing-cr > fail
  42. #rm -f ascii_i.txt ascii_o.txt bin_o.txt bin_i.b
Tip!

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

Comments

Loading...