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

measure.jl 1.3 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
  1. function measure(out_path::ASCIIString="")
  2. # OUT_PATH -> Path to where the PS file will be written. If not in input must be set via the "outPath" global var
  3. # PS -> Full name of the created postscript file (built from OUT_PATH)
  4. # PATH -> Path to where this file lives (useful for gmtest.m)
  5. #
  6. pato, fname = fileparts(@__FILE__)
  7. ps = out_path * fname * ".ps"
  8. path = pato * "/"
  9. area = [0 0; 1 0; 1 1; 0 1; 0 0];
  10. # Cartesian centroid and area
  11. #echo "0.5 0.5 1" > answer
  12. answer = [0.5 0.5 1]
  13. result = gmt("gmtspatial -Q", area)
  14. pass = (sum(abs(result - answer)) < 1e-12)
  15. if (!pass)
  16. fid = open(out_path * fname * "_fail1.dat", "w")
  17. @printf(fid, "Should be\n%f\t%f\t%f\n", answer[1], answer[2], answer[3])
  18. @printf(fid, "It is\n%f\t%f\t%f", result[1], result[2], result[3])
  19. close(fid)
  20. end
  21. # Geographic centroid and area
  22. answer = [0.5 0.5000195463076722 12225.940899448242]
  23. result = gmt("gmtspatial -Q -fg", area)
  24. pass2 = (sum(abs(result - answer)) < 1e-12)
  25. if (!pass2)
  26. fid = open(out_path * fname * "_fail2.dat", "w")
  27. @printf(fid, "Should be\n%f\t%f\t%f\n", answer[1], answer[2], answer[3])
  28. @printf(fid, "It is\n%f\t%f\t%f", result[1], result[2], result[3])
  29. close(fid)
  30. end
  31. pass = pass && pass2
  32. return pass, path
  33. end
  34. measure() = measure("")
Tip!

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

Comments

Loading...