How to open and modify forcing files in .ieeer8 file format?

Laura

Laura
New Member
I barely know this file format, except that it is probably a binary file, and I have no idea how to deal with it. Can Python/MATLAB/NCL... open it? What should I do if I want to modify the values in this files? Is it possible to transform .ieeer8 to .nc?

Any messages about it is appreciated. Thanks at advance.

Laura
 

emaroon

Elizabeth Maroon
New Member
Hi Laura,

I haven't opened the ieeer8 files with python, but I have opened ieeei4 files using numpy. Here's a quick python snippet that I use that might help:

Python:
import numpy as np
topog_fname ='topography_20161215.ieeei4'
kmt_flat = np.fromfile(topog_fname, dtype='>i4', count=-1) #flat array
kmt_reshaped = kmt_flat.reshape([384,320]).astype(np.int32) #2d array, hard-coded for 384x320 resolution

You should be able to modify the dtype for a float (r8); watch out for endianness. I probably figured this out by poking around the pop_tools package or the paleotools. More hints are probably available in those packages.

All the best,
Liz
 

michelle_dvorak

Michelle Dvorak
Member
Just as an alternative, you could use NCL for this -- specifically the fbindirread function (https://www.ncl.ucar.edu/Document/Functions/Built-in/fbindirread.shtml); example:

setfileoption ("bin", "ReadByteOrder", "BigEndian")
setfileoption ("bin", "WriteByteOrder","BigEndian")

kmt = fbindirread(binary_file, 0,(/384, 320/), "integer")

system("cp example_pop_netcdf_file_with_same_dimensions "+ncout)
f=addfile(ncout,"w")
f->kmt = (/kmt/)

Michelle
 
Back
Top