# get the amount of voxels in the z directionvox_count=len(full_lattice[0][0])# initialize an adjacency matrixadj_mtrx=np.zeros((vox_count,vox_count))# set the connecting values of the adjacency matrix to 1foriinrange(vox_count):ifi==0:adj_mtrx[i,i+1]=1continueifi==vox_count-1:adj_mtrx[i,i-1]=1continueelse:adj_mtrx[i,i+1]=1adj_mtrx[i,i-1]=1
Turning into networkx datastructure and calculating distances
floor_dist=dist_mtrx_vertical[0-4]# specified floor levelmax_valid=np.ma.masked_invalid(floor_dist).max()# find max distancefloor_dist_mapped=1-(floor_dist/max_valid)# map values between 0 and 1 with max distance
floor_dist_mapped_full=[]height=len(floor_dist_mapped)# mapping the colomn of values to the full latticeforiinrange(len(full_lattice)*len(full_lattice[0])*len(full_lattice[0][0])):floor_dist_mapped_full.append(floor_dist_mapped[i%height])# turning it into an np arrayfloor_dist_mapped_full=np.array(floor_dist_mapped_full)# reshaping the arrayfloor_dist_lattice_full=floor_dist_mapped_full.reshape(full_lattice.shape)# forming the lattice to the solar envelopefloor_dist_lattice=floor_dist_lattice_full*full_lattice
floor_dist=floor_dist_lattice*envelope_lattice# save the lowres distance field to csvcsv_path=os.path.relpath('../data/ground_field_lowres.csv')floor_dist.to_csv(csv_path)
# Import the highres envelopehighres_lattice_path=os.path.relpath('../data/envelope_highres.csv')highres_lattice=tg.lattice_from_csv(highres_lattice_path)# Interpolate from lowres to highreshighres_ground_lattice=interpolate(floor_dist_lattice)# multiply by original highres_lattice to filter out the voxels outside the envelopehighres_ground=highres_ground_lattice*highres_lattice