I have a numpy.ndarray named tas with shape (2928, 7, 9)
and I want to convert it to a binary .raw file. This goes fine.
Then, when I load this .raw file back into python it has the same shape as my initial tas (which is fine) but the numbers within this file are completely changed compared to the initial tas.
The following is what I've tried to do. If this is the wrong way of approaching this problem, does any one have other suggestions of how this could be done?
# Here I am loading a bunch of data
mask = np.load('Country_masks/DNK_mask.npy')
dates = np.load('date2000.npy')
temp = 'tas_EUR-44_ICHEC-EC-EARTH_historical_r3i1p1_DMI-HIRHAM5_v1_3hr_2000010100-2001010100.nc'
A = Dataset(temp, mode='r')
tas = A.variables['tas'][:,62:69,52:61]*mask[np.newaxis,62:69,52:61]
lat = B.variables['lat'][62:69,52:61]*mask[62:69,52:61]
# Here I am writing a .raw file
tas.tofile('tas_raw.raw')
# Here I am loading it again
array_shape = tuple([len(dates)]+list(lat.shape))
data = np.memmap('tas_raw.raw',mode="r",dtype=np.single,shape=array_shape);