Skip to content

Commit f7958b4

Browse files
author
sfwang
committed
Temporarily roll-back to old get_source function.
1 parent 2682513 commit f7958b4

File tree

1 file changed

+48
-39
lines changed

1 file changed

+48
-39
lines changed

lib/utils/utils.py

+48-39
Original file line numberDiff line numberDiff line change
@@ -131,45 +131,54 @@ def get_mesh(x_mesh, y_mesh):
131131
mesh = np.array([Xsim,Ysim,np.zeros(d)]);
132132
return mesh
133133

134-
def get_source(n_sources=[40, 60],
135-
p_n_sources=[.5, .5],
136-
depth=[.1],
137-
p_depth=[1],
138-
amplitude=[-1,1],
139-
p_amplitude=[.5,.5]):
140-
"""
141-
Parameters:
142-
-----------
143-
n_sources: numpy array (int)
144-
the number of sources in the plane
145-
146-
p_n_sources: numpy array
147-
The probabily distribution over the number of sources.
148-
149-
depth: numpy array
150-
the depth of sources
151-
152-
p_depth: numpy array
153-
The probabily distribution over the depth of sources.
154-
155-
amplitude: numpy array
156-
amplitude of sources.
157-
158-
p_amplitude: numpy array
159-
The probabily distribution over the amplitude of sources.
160-
161-
Returns:
162-
-------
163-
sources: numpy array of shape (4, n)
164-
the bio information of sources.
165-
"""
166-
167-
number_of_sources = np.random.choice(a=n_sources, size=1, p=p_n_sources)[0]
168-
sources = np.zeros(4, number_of_sources);
169-
d = np.expand_dims(np.random.choice(a=depth, size=number_of_sources, p=p_depth),0)
170-
loc = np.random.rand(2, number_of_sources)
171-
amp = np.expand_dims(np.random.choice(a=amplitude, size=number_of_sources, p=p_amplitude),0)
172-
sources = np.append(np.append(amp, loc, 0), d,0)
134+
# def get_source(n_sources=[40, 60],
135+
# p_n_sources=[.5, .5],
136+
# depth=[.1],
137+
# p_depth=[1],
138+
# amplitude=[-1,1],
139+
# p_amplitude=[.5,.5]):
140+
# """
141+
# Parameters:
142+
# -----------
143+
# n_sources: numpy array (int)
144+
# the number of sources in the plane
145+
#
146+
# p_n_sources: numpy array
147+
# The probabily distribution over the number of sources.
148+
#
149+
# depth: numpy array
150+
# the depth of sources
151+
#
152+
# p_depth: numpy array
153+
# The probabily distribution over the depth of sources.
154+
#
155+
# amplitude: numpy array
156+
# amplitude of sources.
157+
#
158+
# p_amplitude: numpy array
159+
# The probabily distribution over the amplitude of sources.
160+
#
161+
# Returns:
162+
# -------
163+
# sources: numpy array of shape (4, n)
164+
# the bio information of sources.
165+
# """
166+
#
167+
# number_of_sources = np.random.choice(a=n_sources, size=1, p=p_n_sources)[0]
168+
# sources = np.zeros(4, number_of_sources);
169+
# d = np.expand_dims(np.random.choice(a=depth, size=number_of_sources, p=p_depth),0)
170+
# loc = np.random.rand(2, number_of_sources)
171+
# amp = np.expand_dims(np.random.choice(a=amplitude, size=number_of_sources, p=p_amplitude),0)
172+
# sources = np.append(np.append(amp, loc, 0), d,0)
173+
# return sources
174+
175+
def get_source(depth, n_sources, var_noise):
176+
177+
sources = np.random.rand(4, n_sources);
178+
sources[3, :] = depth
179+
sources[0, :] = 2*np.floor(2*sources[0, :])-1;
180+
# image = evalpotential(mesh, sources);
181+
# image = image.reshape((y_mesh, x_mesh)) + var_noise*np.random.randn(y_mesh, x_mesh)
173182
return sources
174183

175184
def generate_heatmaps(keypoints, im_height, im_width):

0 commit comments

Comments
 (0)