I have a dataset containing values in a 200x200x38 3D space. The data is centered at [100,100,z] where z is height, and the first two values are horizontal x and y coordinates. I am trying to create a visualization of a cross section that averages the values in the dataset along a radial and at each height (making a height-radius average).
Most efficient way to calculate radial profile This post describes how to do a radial average for a 2D dataset,̶b̶u̶t̶ ̶I̶ ̶d̶o̶n̶'̶t̶ ̶q̶u̶i̶t̶e̶ ̶u̶n̶d̶e̶r̶s̶t̶a̶n̶d̶ ̶h̶o̶w̶ ̶t̶h̶e̶y̶ ̶d̶i̶d̶ ̶t̶h̶e̶y̶ ̶b̶i̶n̶n̶e̶d̶ ̶t̶h̶e̶i̶r̶ ̶d̶a̶t̶a̶ ̶i̶n̶t̶o̶ ̶d̶i̶f̶f̶e̶r̶e̶n̶t̶ ̶r̶a̶d̶i̶i̶ ̶e̶i̶t̶h̶e̶r̶ ̶s̶i̶n̶c̶e̶.̶ ̶ ̶I̶'̶v̶e̶ ̶d̶e̶f̶i̶n̶e̶d̶ ̶f̶u̶n̶c̶t̶i̶o̶n̶s̶ ̶f̶o̶r̶ ̶r̶a̶d̶i̶i̶ ̶a̶n̶d̶ ̶a̶n̶g̶l̶e̶ ̶f̶r̶o̶m̶ ̶c̶e̶n̶t̶e̶r̶,̶ ̶b̶u̶t̶ ̶d̶o̶n̶'̶t̶ ̶k̶n̶o̶w̶ ̶h̶o̶w̶ ̶t̶o̶ ̶c̶o̶n̶v̶e̶r̶t̶ ̶m̶y̶ ̶C̶a̶r̶t̶e̶s̶i̶a̶n̶ ̶d̶a̶t̶a̶ ̶i̶n̶t̶o̶ ̶a̶ ̶c̶y̶l̶i̶n̶d̶r̶i̶c̶a̶l̶ ̶c̶o̶o̶r̶d̶i̶n̶a̶t̶e̶ ̶s̶h̶a̶p̶e̶.̶
def radial_profile(data, center):
y, x = np.indices((data.shape))
r = np.sqrt((x - center[0])**2 + (y - center[1])**2)
r = r.astype(np.int)
tbin = np.bincount(r.ravel(), data.ravel())
nr = np.bincount(r.ravel())
radialprofile = tbin / nr
return radialprofile
Cent=[100,100]
Rav=[]
for i in range(37):
B=ref[:,:,i,0]
if B == -999.9:
B=np.nan
RRR=radial_profile(B,Cent)
Rav.append(RRR)
plt.imshow(Rav, vmin=-15, vmax=70)
plt.colorbar();
plt.show()
Using this I've been able to plot it, but have to figure out a way to remove the -999.9 values from the average. I have tried to assign it as null, but to no success. The plot otherwise works.