Created
December 16, 2018 23:20
-
-
Save raphaeldussin/3d9c5adf5e4acbb78000dfef2a67dca1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import numpy as np | |
| import struct | |
| def write_new_data(data,fileout): | |
| fid = open(fileout, "wb") | |
| flatdata = data.flatten() | |
| for kk in np.arange(len(flatdata)): | |
| tmp = struct.pack('>d',flatdata[kk]) | |
| fid.write(tmp) | |
| fid.close() | |
| return None | |
| def convert_to_real8(filein, fileout): | |
| # read the original data in real4 | |
| data = np.fromfile(filein,dtype='>f') | |
| # write file in real8 | |
| write_new_data(data,fileout) | |
| return None | |
| # usage | |
| # convert_to_real8(indir+filein,outdir+fileout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment