|
|
# header
|
|
|
# open a binary file and read header
|
|
|
|
|
|
file = "/home/marie/LPJmL/lpjmlinput_resolution5/MarocN.cowreg.5200p_h43.bin"
|
|
|
file = open(file, "rb")
|
|
|
´´´
|
|
|
#header
|
|
|
#file.read(43)
|
|
|
file_type = file.read(7)
|
|
|
print("file type:",file_type)
|
|
|
version = struct.unpack('i',file.read(4))[0]
|
|
|
print("version number:",version)
|
|
|
data_order = struct.unpack('i',file.read(4))[0]
|
|
|
print("order of data:",data_order)
|
|
|
first_year = struct.unpack('i',file.read(4))[0]
|
|
|
print("first year of data:",first_year)
|
|
|
nyear = struct.unpack('i',file.read(4))[0]
|
|
|
print("nyear:",nyear)
|
|
|
firstcell = struct.unpack('i',file.read(4))[0]
|
|
|
print("firstcell:",firstcell)
|
|
|
ncell = struct.unpack('i',file.read(4))[0]
|
|
|
print("ncell:",ncell)
|
|
|
nband = struct.unpack('i',file.read(4))[0]
|
|
|
print("nbands:",nband)
|
|
|
cellsize = struct.unpack('f',file.read(4))[0]
|
|
|
print("cellsize:",cellsize)
|
|
|
scalar = round(struct.unpack('f',file.read(4))[0],4)
|
|
|
print("scalar:",scalar)
|
|
|
´´´
|
|
|
|