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

gmtconvert.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
31
32
33
34
35
  1. #!/usr/bin/env bash
  2. #
  3. # test byteswapping with gmt convert
  4. # increase number of output digits
  5. gmt set FORMAT_FLOAT_OUT %.20g
  6. # generate text file
  7. gmt convert -V0 << EOF > numbers.txt
  8. # u c H h I i f L l d
  9. 171 -85 43981 -21555 3735928559 -559038737 \
  10. -6.259853398707798016e+18 1.6045690981116495872e+19 \
  11. -2.401053092593056256e+18 -1.1885953980619317e+148
  12. EOF
  13. # read big endian file
  14. gmt convert -bi1u1c1H1h1I1i1f1L1l1d+B "${src:-.}"/binary.be > numbers_from_be.txt
  15. # read little endian file
  16. gmt convert -bi1u1c1H1h1I1i1f1L1l1d+L "${src:-.}"/binary.le > numbers_from_le.txt
  17. # compare result with text file
  18. diff -q numbers.txt numbers_from_be.txt
  19. diff -q numbers.txt numbers_from_le.txt
  20. # write big endian file
  21. gmt convert -bo1u1c1H1h1I1i1f1L1l1d+B numbers_from_be.txt > bin_from_num.be
  22. # write little endian file
  23. gmt convert -bo1u1c1H1h1I1i1f1L1l1d+L numbers_from_le.txt > bin_from_num.le
  24. # compare binary output with original binary files
  25. diff -q "${src:-.}"/binary.be bin_from_num.be
  26. diff -q "${src:-.}"/binary.le bin_from_num.le
Tip!

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

Comments

Loading...