Skip to content

Instantly share code, notes, and snippets.

@raphaeldussin
Created December 16, 2018 23:20
Show Gist options
  • Select an option

  • Save raphaeldussin/3d9c5adf5e4acbb78000dfef2a67dca1 to your computer and use it in GitHub Desktop.

Select an option

Save raphaeldussin/3d9c5adf5e4acbb78000dfef2a67dca1 to your computer and use it in GitHub Desktop.
#!/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