コード例 #1
0
Dx = 20
Dy = 20
xmin = 0 + rmax
xmax = Dx - rmax
ymin = 0 + rmax
ymax = Dx - rmax

print(P_ThomasPP)

#%%
print(P_ThomasPP_center)
#%%
P_ThomasPP_center = sswdistsim.xyroi_idx(P_ThomasPP, xmin, xmax, ymin, ymax)
#%%
# P_ThomasPP_center = sswdistsim.xyroi(P_ThomasPP, 0, 20, 0, 20)
P_ThomasPP_density = sswdistsim.xydensity(P_ThomasPP, Dx = Dx) [0]
print(P_ThomasPP_density)

#%%
start = time.time()
K_r, L_r, H_r, RList, densitylist = spatialpattern.spest(input_array_ref = P_ThomasPP_center, 
                        input_array_all = P_ThomasPP,
                        function = 'all', 
                        density = P_ThomasPP_density, 
                        rstart = 0, rend = 5, rstep = 0.01)
end = time.time()
print(end - start)

print(RList)
print(K_r)
print(L_r)
コード例 #2
0
Dx = 20
P_parent = sswdistsim.PoissonPP(rt=rate, Dx=Dx, seed=seed)

# creating children points
sigma = 0.3
mu = 50
P_children = sswdistsim.ThomasPP(rt=rate, Dx=Dx, sigma=sigma, mu=mu, seed=seed)
# reduce data to region of interest
xmin = 0
xmax = Dx
ymin = 0
ymax = Dx

# crop data and calculate density
P_ThomasPP = sswdistsim.xyroi(P_children, xmin, xmax, ymin, ymax)
P_ThomasPP_density = sswdistsim.xydensity(P_ThomasPP)

# print(P_ThomasPP.shape[0])
# print(P_ThomasPP_density)

# save to csv
filename = 'P_ThomasPP_20'
outputpath = os.path.join(path, outputfolder, outputsubfolder_csv,
                          filename + '.csv')
df = pd.DataFrame(P_ThomasPP, columns=['x', 'y'])
df.to_csv(outputpath, index=False)

# save metadata
outputpath = os.path.join(path, outputfolder, outputsubfolder_csv,
                          filename + '.txt')
with open(outputpath, 'w') as file:
コード例 #3
0
P_ThomasPP = pd.read_csv(inputpath)
P_ThomasPP = np.array(P_ThomasPP)

# %%
# spest: Ripley's function
# ----------------------------------
import spatialstatWUCCI.spatialpattern as sp
imp.reload(sp)

import spatialstatWUCCI.distribution_simulator as sswdistsim
imp.reload(sswdistsim)

# ThomasPP test --------------------------------------
P_ThomasPP_center = sswdistsim.xyroi(P_ThomasPP, 5, 15, 5, 15)
# P_ThomasPP_center = sswdistsim.xyroi(P_ThomasPP, 0, 20, 0, 20)
P_ThomasPP_density, count, area = sswdistsim.xydensity(P_ThomasPP, Dx=20)
print('Density: {}'.format(P_ThomasPP_density))
print('Count: {}'.format(count))
print('Area: {}'.format(area))

# %%
start = time.time()
K_r, L_r, H_r, RList, densitylist = sp.spest(input_array_ref=P_ThomasPP_center,
                                             input_array_all=P_ThomasPP,
                                             function='all',
                                             density=P_ThomasPP_density,
                                             rstart=0,
                                             rend=5,
                                             rstep=0.01)
end = time.time()
print('processing time: {}'.format(end - start))
コード例 #4
0
'''

outputfolder = 'output'
# %%
# ripleyk_v2
# Ripley's K-function ----------------------------------
import spatialstatWUCCI.ripleyk_v2 as ripleyk_v2
imp.reload(ripleyk_v2)

import spatialstatWUCCI.distribution_simulator as sswdistsim
imp.reload(sswdistsim)

# 1. ThomasPP test --------------------------------------
P_ThomasPP_center = sswdistsim.xyroi_idx(P_ThomasPP, 5, 15, 5, 15)
# P_ThomasPP_center = sswdistsim.xyroi(P_ThomasPP, 0, 20, 0, 20)
P_ThomasPP_density = sswdistsim.xydensity(P_ThomasPP, Dx=20)

start = time.time()
K_r, L_r, H_r, RList, densitylist = ripleyk_v2.ripleyk(
    xyarray_ref=P_ThomasPP_center,
    xyarray_all=P_ThomasPP,
    function='all',
    density=P_ThomasPP_density,
    rstart=0,
    rend=5,
    rstep=0.01)
end = time.time()
print('processing time: {}'.format(end - start))

filenames.append('P_ThomasPP_20')
version_list.append('ripleyk_v2')