[cig-commits] [commit] devel: Add binary version of topography file. (dba0bc5)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Sun Jul 6 16:19:46 PDT 2014


Repository : https://github.com/geodynamics/specfem3d_globe

On branch  : devel
Link       : https://github.com/geodynamics/specfem3d_globe/compare/22de8b703acf8a3a86cf834288fe19378f9a8187...741ee6773bfcdb5273c3a4e28a7d340ec0e28070

>---------------------------------------------------------------

commit dba0bc5c6887f84a33c31fdf23fc675b4669304f
Author: Elliott Sales de Andrade <esalesde at physics.utoronto.ca>
Date:   Sun Jul 6 18:35:46 2014 -0400

    Add binary version of topography file.
    
    Also add Python script to produce it.


>---------------------------------------------------------------

dba0bc5c6887f84a33c31fdf23fc675b4669304f
 DATA/topo_bathy/ascii2bin.py                       |  34 +++++++++++++++++++++
 .../topo_bathy_etopo4_smoothed_window_7.bin        | Bin 25158686 -> 29160002 bytes
 2 files changed, 34 insertions(+)

diff --git a/DATA/topo_bathy/ascii2bin.py b/DATA/topo_bathy/ascii2bin.py
new file mode 100755
index 0000000..e3f4b6a
--- /dev/null
+++ b/DATA/topo_bathy/ascii2bin.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+import sys
+
+try:
+    import numpy as np
+except ImportError:
+    print('This script requires NumPy.')
+    sys.exit()
+
+if '--help' in sys.argv or '-h' in sys.argv or len(sys.argv) != 3:
+    print('Usage: %s <input> <output>' % (sys.argv[0],))
+    sys.exit()
+
+# Read input file
+print('Reading input file %s ...' % (sys.argv[1],))
+data = np.genfromtxt(sys.argv[1])
+
+# Convert to 16-bit integers
+data2 = data.astype(np.int16)
+if any(data != data2):
+    print('Warning: Data set does not fit in signed 16-bit integers!')
+
+# Add a byte-order mark
+byteorder = np.array([0x1234], dtype=np.int16)
+data2 = np.concatenate((byteorder, data2))
+
+# Save output file
+print('Writing output to file %s ...' % (sys.argv[2],))
+data2.tofile(sys.argv[2])
+
+print('Done!')
+
diff --git a/utils/Roland_Sylvain_gravity/saved_observation_grid_real_x_y_z_used_by_the_code.txt.bz2 b/DATA/topo_bathy/topo_bathy_etopo4_smoothed_window_7.bin
similarity index 65%
copy from utils/Roland_Sylvain_gravity/saved_observation_grid_real_x_y_z_used_by_the_code.txt.bz2
copy to DATA/topo_bathy/topo_bathy_etopo4_smoothed_window_7.bin
index b21b621..a4c573d 100644
Binary files a/utils/Roland_Sylvain_gravity/saved_observation_grid_real_x_y_z_used_by_the_code.txt.bz2 and b/DATA/topo_bathy/topo_bathy_etopo4_smoothed_window_7.bin differ



More information about the CIG-COMMITS mailing list