-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move plotting to a separate file. Create a reference data learning fu…
…nction
- Loading branch information
Alexander James Wallar
committed
Jan 29, 2014
1 parent
84945c3
commit 0e3229f
Showing
10 changed files
with
257 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<!-- WARNING: Eclipse auto-generated file. | ||
Any modifications will be overwritten. | ||
To include a user specific buildfile here, simply create one in the same | ||
directory with the processing instruction <?eclipse.ant.import?> | ||
as the first entry and export the buildfile again. --> | ||
<project basedir="." default="build" name="Locabean"> | ||
<property environment="env"/> | ||
<property name="debuglevel" value="source,lines,vars"/> | ||
<property name="target" value="1.6"/> | ||
<property name="source" value="1.6"/> | ||
<path id="Android 4.2.2.libraryclasspath"> | ||
<pathelement location="../../../../Software/adt-bundle-mac-x86_64-20130514/sdk/platforms/android-17/android.jar"/> | ||
</path> | ||
<path id="Android Private Libraries.libraryclasspath"> | ||
<pathelement location="libs/android-support-v4.jar"/> | ||
<pathelement location="libs/gson-2.2.4.jar"/> | ||
<pathelement location="libs/musicg-1.4.2.0.jar"/> | ||
</path> | ||
<path id="Android Dependencies.libraryclasspath"/> | ||
<path id="Locabean.classpath"> | ||
<pathelement location="bin/classes"/> | ||
<path refid="Android 4.2.2.libraryclasspath"/> | ||
<path refid="Android Private Libraries.libraryclasspath"/> | ||
<path refid="Android Dependencies.libraryclasspath"/> | ||
<pathelement location="libs/musicg-1.4.2.0.jar"/> | ||
<pathelement location="libs/gson-2.2.4.jar"/> | ||
</path> | ||
<target name="init"> | ||
<mkdir dir="bin/classes"/> | ||
<copy includeemptydirs="false" todir="bin/classes"> | ||
<fileset dir="src"> | ||
<exclude name="**/*.java"/> | ||
</fileset> | ||
</copy> | ||
<copy includeemptydirs="false" todir="bin/classes"> | ||
<fileset dir="gen"> | ||
<exclude name="**/*.java"/> | ||
</fileset> | ||
</copy> | ||
</target> | ||
<target name="clean"> | ||
<delete dir="bin/classes"/> | ||
</target> | ||
<target depends="clean" name="cleanall"/> | ||
<target depends="build-subprojects,build-project" name="build"/> | ||
<target name="build-subprojects"/> | ||
<target depends="init" name="build-project"> | ||
<echo message="${ant.project.name}: ${ant.file}"/> | ||
<javac debug="true" debuglevel="${debuglevel}" destdir="bin/classes" includeantruntime="false" source="${source}" target="${target}"> | ||
<src path="src"/> | ||
<src path="gen"/> | ||
<classpath refid="Locabean.classpath"/> | ||
</javac> | ||
</target> | ||
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/> | ||
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler"> | ||
<copy todir="${ant.library.dir}"> | ||
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/> | ||
</copy> | ||
<unzip dest="${ant.library.dir}"> | ||
<patternset includes="jdtCompilerAdapter.jar"/> | ||
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/> | ||
</unzip> | ||
</target> | ||
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler"> | ||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> | ||
<antcall target="build"/> | ||
</target> | ||
</project> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
|
||
import triangulation as tri | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from matplotlib import cm | ||
from mpl_toolkits.mplot3d import Axes3D | ||
|
||
|
||
def determine_limits(*args): | ||
|
||
x_min = args[0][0].x | ||
x_max = args[0][0].x | ||
|
||
y_min = args[0][0].y | ||
y_max = args[0][0].y | ||
|
||
for coord_list in args: | ||
for coord in coord_list: | ||
if coord.x < x_min: | ||
x_min = coord.x | ||
elif coord.x > x_max: | ||
x_max = coord.x | ||
|
||
if coord.y < y_min: | ||
y_min = coord.y | ||
elif coord.y > y_max: | ||
y_max = coord.y | ||
|
||
if x_max - x_min > y_max - y_min: | ||
y_max = (x_max - x_min) + y_min | ||
else: | ||
x_max = (y_max - y_min) + x_min | ||
|
||
x_step = (x_max - x_min) / float(30) | ||
y_step = (y_max - y_min) / float(30) | ||
|
||
return ( | ||
x_min - 100 * x_step, x_max + 100 * x_step, | ||
y_min - 100 * y_step, y_max + 100 * y_step, | ||
x_step, y_step | ||
) | ||
|
||
|
||
def plot_detection_events(locations, r_ref, l_ref, d_events, filename): | ||
""" | ||
Plots the detection events and saves the figure in the given path. | ||
@param res The list of locations. Locations are named tuples with fields | ||
which are position which is a point and confidence which is a float | ||
@param rRef The reference distance at which the reference sound | ||
pressure level was recorded | ||
@param lRef The reference sound pressure level used to determine the | ||
distance from the newly measured sound pressure level | ||
@param nodeEvents The list ofassociated data when a node detects with some | ||
confidence that the sound has been identified | ||
@return The plt object of the saved figure | ||
""" | ||
|
||
fig = plt.figure("Locaudio") | ||
ax = fig.add_subplot(111) | ||
ax.set_xlabel("X Location") | ||
ax.set_ylabel("Y Location") | ||
|
||
# x_min = 56.3399 | ||
# x_max = 56.3400 | ||
# y_min = -2.80834 | ||
# y_max = -2.80824 | ||
|
||
( | ||
x_min, x_max, | ||
y_min, y_max, | ||
x_step, y_step | ||
) = determine_limits(locations, d_events) | ||
|
||
x = np.arange(x_min, x_max, x_step) | ||
y = np.arange(y_min, y_max, y_step) | ||
X, Y = np.meshgrid(x, y) | ||
|
||
zs = np.array( | ||
[ | ||
tri.position_probability(x, y, r_ref, l_ref, d_events) | ||
for x, y in zip(np.ravel(X), np.ravel(Y)) | ||
] | ||
) | ||
|
||
Z = zs.reshape(X.shape) | ||
ax.pcolormesh(X, Y, Z, cmap=cm.jet) | ||
ax.scatter( | ||
[p.position.x for p in locations], | ||
[p.position.y for p in locations], | ||
marker="+", | ||
linewidths=15, | ||
c="white" | ||
) | ||
ax.scatter( | ||
[d_event.x for d_event in d_events], | ||
[d_event.y for d_event in d_events], | ||
marker="o", | ||
linewidths=5, | ||
c="white", | ||
s=300 | ||
) | ||
|
||
ax.set_xlim(x_min, x_max) | ||
ax.set_ylim(y_min, y_max) | ||
|
||
plt.savefig(filename) | ||
return plt | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.