Skip to content

Commit

Permalink
fractionationSlide also stores the time offset of the signals for usa…
Browse files Browse the repository at this point in the history
…ge in graphing

graphing fractionation now writes out the time offset and if the signal is early or late
fixed a problem related to the tutorials
Separated generating graphs + 2D from 3D graphs in the command line interface so the default for --generate_graphs is no longer to also generate 3D graphs
  • Loading branch information
Immudzen committed Feb 10, 2020
1 parent ba79369 commit fc7a0c5
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CADETMatch.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: CADETMatch
Version: 0.5.22
Version: 0.5.23
Summary: CADETMatch is a parameter estimation and error modeling library for CADET
Home-page: https://github.com/modsim/CADET-Match
Author: William Heymann
Expand Down
2 changes: 1 addition & 1 deletion CADETMatch/CADETMatch.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<IsWindowsApplication>False</IsWindowsApplication>
<InterpreterId>CondaEnv|CondaEnv|CADETMatch</InterpreterId>
<LaunchProvider>Standard Python launcher</LaunchProvider>
<CommandLineArguments>"C:\Users\kosh_000\Documents\Visual Studio 2017\Projects\CADETMatch\Examples\Example1\Dextran\NSGA3_dextran.json" 6</CommandLineArguments>
<CommandLineArguments>"F:\temp\TestDatasets\NSGA3_binding_PTD_mass_space.json" 1</CommandLineArguments>
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
<InterpreterArguments>
</InterpreterArguments>
Expand Down
8 changes: 7 additions & 1 deletion CADETMatch/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def makeParser():
action='store_true')

parser.add_argument('--generate_graphs',
help="Generate general graphs",
help="Generate general graphs excluding 3D",
action='store_true')

parser.add_argument('--generate_graphs_all',
help="Generate general graphs including 3D",
action='store_true')

parser.add_argument('--generate_spearman',
Expand Down Expand Up @@ -73,6 +77,8 @@ def run_command(module, json, number_of_jobs, additional=None):
if args.generate_corner:
sys.exit(run_command('CADETMatch.generate_corner_graphs', args.json, args.n))
if args.generate_graphs:
sys.exit(run_command('CADETMatch.generate_graphs', args.json, args.n, ['1']))
if args.generate_graphs_all:
sys.exit(run_command('CADETMatch.generate_graphs', args.json, args.n, ['2']))
if args.generate_spearman:
sys.exit(run_command('CADETMatch.graph_spearman', args.json, args.n, ['end']))
Expand Down
45 changes: 29 additions & 16 deletions CADETMatch/generate_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def plotExperiments(args):
exp_time = target[experimentName]['time']
exp_value = target[experimentName]['value']

fig = figure.Figure(figsize=[15, 15*numPlots])
fig = figure.Figure(figsize=[24, 12*numPlots])
canvas = FigureCanvas(fig)

simulation = Cadet()
Expand Down Expand Up @@ -334,6 +334,7 @@ def plotExperiments(args):

graph_exp = results['graph_exp']
graph_sim = results['graph_sim']
graph_sim_offset = results.get('graph_sim_offset', {})

findMax = 0
max_comp = {}
Expand All @@ -359,7 +360,19 @@ def plotExperiments(args):
mult = findMax/(2 * max_comp[key])
values = values * mult
factors.append(mult)
graph.plot(time, values, '--', color=get_color(idx, len(graph_sim), cm_plot), label='Simulation Comp: %s Mult:%.2f' % (key, mult))

time_offset = graph_sim_offset.get(key, None)
if time_offset is not None:
if time_offset >0:
time_str = "time early (s): %.3g" % abs(time_offset)
else:
time_str = "time late (s): %.3g" % abs(time_offset)
else:
time_str = ""

label = 'Simulation Comp: %s Mult:%.2f %s' % (key, mult, time_str)

graph.plot(time, values, '--', color=get_color(idx, len(graph_sim), cm_plot), label=label)

for idx, (key, value) in enumerate(graph_exp.items()):
(time, values) = zip(*value)
Expand All @@ -369,7 +382,7 @@ def plotExperiments(args):
graph.plot(time, values, ':', color=get_color(idx, len(graph_sim), cm_plot), label='Experiment Comp: %s Mult:%.2f' % (key, mult))
graphIdx += 1
graph.legend()
fig.set_size_inches((12,6*numPlots))
fig.set_size_inches((24,12*numPlots))
fig.savefig(str(dst))

def graphSpace(fullGeneration, cache, map_function):
Expand Down Expand Up @@ -442,18 +455,18 @@ def plot_3d(arg):

scoreName = header3
if scoreName == 'SSE':
scores = -numpy.log(scores)
scoreName = '-log(%s)' % scoreName
scores = -numpy.log10(scores)
scoreName = '-log10(%s)' % scoreName

x = data1
y = data2

fig = figure.Figure()
canvas = FigureCanvas(fig)
ax = fig.add_subplot(111, projection='3d')
ax.scatter(numpy.log(x), numpy.log(y), scores, c=scores, cmap=my_cmap)
ax.set_xlabel('log(%s)' % header1)
ax.set_ylabel('log(%s)' % header2)
ax.scatter(numpy.log10(x), numpy.log10(y), scores, c=scores, cmap=my_cmap)
ax.set_xlabel('log10(%s)' % header1)
ax.set_ylabel('log10(%s)' % header2)
ax.set_zlabel(scoreName)
filename = "%s_%s_%s.png" % (header1, header2, scoreName)
filename = filename.replace(':', '_').replace('/', '_')
Expand All @@ -475,17 +488,17 @@ def plot_2d_single(directory_path, header_x, scoreName, data, scores):
#score_scale = numpy.max(scores)/numpy.min(scores)

if scoreName.startswith('1-'):
scores = numpy.log(scores)
scoreName = 'log(%s)' % scoreName
scores = numpy.log10(scores)
scoreName = 'log10(%s)' % scoreName

fig = figure.Figure(figsize=[10,10])
canvas = FigureCanvas(fig)
graph = fig.add_subplot(1, 1, 1)

format = '%s'
if numpy.max(data)/numpy.min(data) > 100.0:
data = numpy.log(data)
format = 'log(%s)'
data = numpy.log10(data)
format = 'log10(%s)'

graph.scatter(data, scores, c=scores, cmap=my_cmap)
graph.set_xlabel(format % header_x)
Expand Down Expand Up @@ -545,14 +558,14 @@ def singleGraphProgress(arg):

graph = fig.add_subplot(1, 1, 1)

graph.plot(df[i],numpy.log(1-df[j]))
graph.plot(df[i],numpy.log10(1-df[j]))
a = max(df[j])
#graph.set_ylim((0,1.1*max(df[j])))
graph.set_title('%s vs log(1-%s)' % (i,j))
graph.set_title('%s vs log10(1-%s)' % (i,j))
graph.set_xlabel(i)
graph.set_ylabel('log(1-%s)' % j)
graph.set_ylabel('log10(1-%s)' % j)

filename = "%s vs log(1-%s).png" % (i,j)
filename = "%s vs log10(1-%s).png" % (i,j)
file_path = output / filename
fig.savefig(str(file_path))

Expand Down
1 change: 1 addition & 0 deletions CADETMatch/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def __init__(self, json_path):
self.json_path = json_path
self.cache = Cache()
self.cache.setup_dir(json_path)
CADETMatch.match.createDirectories(self.cache, json_path)
self.cache.setup(json_path)

def start_sim(self):
Expand Down
3 changes: 3 additions & 0 deletions CADETMatch/scores/fractionationSlide.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def run(sim_data, feature):

graph_sim = {}
graph_exp = {}
graph_sim_offset = {}

searchIndexStart, searchIndexStop = searchRange(times, start, stop, CV_time)

Expand Down Expand Up @@ -106,9 +107,11 @@ def run(sim_data, feature):

graph_sim[component] = list(zip(time_center, fracOffset))
graph_exp[component] = list(zip(time_center, exp_values))
graph_sim_offset[component] = time_offset

sim_data['graph_exp'] = graph_exp
sim_data['graph_sim'] = graph_sim
sim_data['graph_sim_offset'] = graph_sim_offset

return (scores, util.sse(numpy.array(sim_values_sse), numpy.array(exp_values_sse)), len(sim_values_sse),
time_center, numpy.array(sim_values_sse), numpy.array(exp_values_sse), [1.0 - i for i in scores])
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="CADETMatch",
version="0.5.22",
version="0.5.23",
author="William Heymann",
author_email="[email protected]",
description="CADETMatch is a parameter estimation and error modeling library for CADET",
Expand Down

0 comments on commit fc7a0c5

Please sign in to comment.