Hi , I want to open .dlb extension file using Julia and extract some data on it. I have .dlb file in my laptop. This data.6000.dlb file is in this tar. See Python code below
def load_data(directory, N_r, N_theta, mu):
"""Loads data from .dbl files, returns numpy arrays."""
# initialize arrays
num_of_files = 0
for file in glob.iglob(directory + "*.dbl"):
num_of_files += 1
print ("Number of files: %d" % num_of_files)
# rho,vr,vtheta, vphi,br,btheta, bphi, prs, tracer
var = np.zeros((9, num_of_files, N_r, N_theta))
N_points = N_r * N_theta
count = 0
for file in sorted(glob.iglob(directory+'*.dbl')):
f = open(file, 'rb')
data = np.fromfile(file, dtype='d')
for j in range(0, 9):
temp = np.zeros(N_points)
for i in range(0, N_points):
temp[i] = data[i + j*N_points]
temp = temp.reshape(N_theta, N_r).T
var[j, count] = temp
del temp
count += 1
f.close()
# add dipole field to B field because PLUTO outputs change from dipole field
#ccm100217--and multiply by np.sqrt(4.*np.pi) as PLUTO normalizes to it.
for i in range(0, N_theta):
var[4, :, :, i] += 2. * mu * np.cos(theta[i]) / (r*r*r)
var[4, :, :, i] *= np.sqrt(4.0*np.pi)
var[5, :, :, i] += mu * np.sin(theta[i]) / (r*r*r)
var[5, :, :, i] *= np.sqrt(4.0*np.pi)
return var[0],var[1],var[2],var[3],var[4],var[5],var[6],var[7],var[8]
I want to convert this Python code to Julia.