Changeset 4097 for trunk/G2shapes.py


Ignore:
Timestamp:
Aug 16, 2019 1:10:33 PM (2 years ago)
Author:
vondreele
Message:

implement a fast version of set_box in G2shapes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/G2shapes.py

    r4095 r4097  
    379379        return;
    380380   
    381     # Establish a volume
     381     # Evaluate local bead densities and point density on a notional grid - fast version
     382   
     383    def set_box_fast(aList_beads_x,aList_beads_y,aList_beads_z,\
     384                aList_box_x_all,aList_box_y_all,aList_box_z_all,\
     385                aList_box_score,box_step,dmax,rsearch):
     386   
     387        dmax_over2 = dmax/2.0
     388        num_box = int(dmax/box_step)+1
     389       
     390        box_grid = np.zeros((num_box,num_box,num_box),dtype=int)
     391        aList_beads_xyz_loc = np.array([(np.array(aList_beads_x)+dmax_over2)/box_step,
     392            (np.array(aList_beads_y)+dmax_over2)/box_step,
     393            (np.array(aList_beads_z)+dmax_over2)/box_step],dtype=int)
     394   
     395        for ix,iy,iz in aList_beads_xyz_loc.T:
     396            box_grid[ix,iy,iz] += 1
     397           
     398        non_zero = np.argwhere(box_grid)
     399        for ix,iy,iz in non_zero:
     400            aList_box_x_all.append((ix*box_step)-dmax_over2)
     401            aList_box_y_all.append((iy*box_step)-dmax_over2)
     402            aList_box_z_all.append((iz*box_step)-dmax_over2)
     403            aList_box_score.append(box_grid[ix,iy,iz])
     404   
     405        return;
     406   
     407   # Establish a volume
    382408   
    383409    def set_vol(aList_box_x_all,aList_box_y_all,aList_box_z_all,aList_box_score,\
     
    14891515                # rsearch_use = (2.0 - scale)*rsearch
    14901516   
    1491                 set_box(aList_beads_x,aList_beads_y,aList_beads_z,\
     1517                set_box_fast(aList_beads_x,aList_beads_y,aList_beads_z,\
    14921518                        aList_box_x_all,aList_box_y_all,aList_box_z_all,\
    14931519                        aList_box_score,box_step,dmax,rsearch)
     
    17951821        aList_box_score = []
    17961822   
    1797         set_box(aList_beads_x,aList_beads_y,aList_beads_z,\
     1823        set_box_fast(aList_beads_x,aList_beads_y,aList_beads_z,\
    17981824                aList_box_x_all,aList_box_y_all,aList_box_z_all,\
    17991825                aList_box_score,box_step,dmax,rsearch)
Note: See TracChangeset for help on using the changeset viewer.