Skip to content

Commit

Permalink
more clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jmason42 committed Jun 11, 2018
1 parent 53bfafa commit 13eb27d
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 217 deletions.
56 changes: 0 additions & 56 deletions TODO

This file was deleted.

123 changes: 0 additions & 123 deletions TODO 2018-2-26.txt

This file was deleted.

24 changes: 4 additions & 20 deletions figures/figure4_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,6 @@ def get_residuals_and_indexing(directory):
return residuals, indexing

def main(input_directory, output_directory):
# valid = np.load(os.path.join(input_directory, 'valid.npy'))

# pars = np.load(os.path.join(input_directory, 'pars.npy'))[
# :, valid
# ]

# abs_res, abs_ind = get_absolute_fit_residuals(pars)
# rel_res, rel_ind = get_relative_fit_residuals(pars)

# residuals = np.row_stack([abs_res, rel_res])
# indexing = np.concatenate([abs_ind, rel_ind])

# sorting = np.argsort(indexing)

# residuals = residuals[sorting, :]
# indexing = indexing[sorting]

# datatypes = indexing['datatype']

(residuals, indexing) = get_residuals_and_indexing(input_directory)

datatypes = indexing['datatype']
Expand All @@ -184,6 +165,9 @@ def main(input_directory, output_directory):

# make_clean_directory(output_directory)

if not os.path.exists(output_directory):
os.makedirs(output_directory)

n_unique = 0
n_within_2x_median = 0
n_within_10x_median = 0
Expand Down Expand Up @@ -239,5 +223,5 @@ def main(input_directory, output_directory):
if __name__ == '__main__':
main(
os.path.join('out', 'all_scaled'),
'figure5'
'figure4'
)
6 changes: 3 additions & 3 deletions figures/figure4_fit_alt.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

import os

import figure5
import figures.figure4_fit

inputs_and_outputs = tuple(
(
os.path.join('out', 'all_scaled_upper_sat_limits_{}'.format(penalty)),
os.path.join('figure5', 'saturation penalized', 'penalty_{}'.format(penalty))
os.path.join('figure4', 'saturation penalized', 'penalty_{}'.format(penalty))
)
for penalty in ('1e-1', '1e0', '1e1', '1e2')
)

for input_and_output in inputs_and_outputs:
figure5.main(*input_and_output)
figures.figure4_fit.main(*input_and_output)
print ''
2 changes: 1 addition & 1 deletion figures/figure5_dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,4 @@ def init_dg_dt(pars):
plt.subplot(len(sources), 2, i*2+2)
plot_prd(pars, i)

plt.savefig('figure4.pdf')
plt.savefig('figure5.pdf')
5 changes: 2 additions & 3 deletions figures/figure6_predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import structure
import constants

from figure5 import make_clean_directory

def main(input_directory, output_directory):
pars = np.load(os.path.join(input_directory, 'pars.npy'))[
:, np.load(os.path.join(input_directory, 'valid.npy'))
Expand Down Expand Up @@ -83,7 +81,8 @@ def main(input_directory, output_directory):

fig = utils.residuals.plot(residuals, indexing)

# make_clean_directory(output_directory)
if not os.path.exists(output_directory):
os.makedirs(output_directory)

fig.savefig(os.path.join(output_directory, 'specific_activity.pdf'), dpi = DPI)

Expand Down
4 changes: 2 additions & 2 deletions figures/figure6_predictions_alt.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import os

import figure6
import figures.figure6_predictions

inputs_and_outputs = tuple(
(
Expand All @@ -12,5 +12,5 @@
)

for input_and_output in inputs_and_outputs:
figure6.main(*input_and_output)
figures.figure6_predictions.main(*input_and_output)

17 changes: 8 additions & 9 deletions figures/figure6_shifted_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import numpy as np
import matplotlib.pyplot as plt

import figure5
from ks_test import ks_test
import figures.figure4_fit

import utils.residuals

Expand All @@ -18,15 +17,15 @@
if not os.path.exists(OUTPUT_DIRECTORY):
os.mkdir(OUTPUT_DIRECTORY)

(residuals_standard, indexing_standard) = figure5.get_residuals_and_indexing(
(residuals_standard, indexing_standard) = figures.figure4_fit.get_residuals_and_indexing(
os.path.join('out', 'all_scaled')
)

(residuals_small, indexing_small) = figure5.get_residuals_and_indexing(
(residuals_small, indexing_small) = figures.figure4_fit.get_residuals_and_indexing(
os.path.join('out', 'all_scaled_upper_sat_limits_1e-1')
)

(residuals_large, indexing_large) = figure5.get_residuals_and_indexing(
(residuals_large, indexing_large) = figures.figure4_fit.get_residuals_and_indexing(
os.path.join('out', 'all_scaled_upper_sat_limits_1e2')
)

Expand Down Expand Up @@ -61,14 +60,14 @@

fig = utils.residuals.plot(residuals[plotted], indexing[plotted])

fig.savefig(os.path.join(OUTPUT_DIRECTORY, '{}.pdf'.format(name)), dpi = figure5.DPI)
fig.savefig(os.path.join(OUTPUT_DIRECTORY, '{}.pdf'.format(name)), dpi = figures.figure4_fit.DPI)

plt.close(fig)

with open(os.path.join(OUTPUT_DIRECTORY, 'key.txt'), 'w') as f:
for uni in unique_values[shifted_large]:
f.write(':'.join([
figure5.DATATYPES_ORDERED[uni['datatype']] if uni['datatype'] >= 0 else '',
figure5.REACTIONS_ORDERED[uni['reaction']] if uni['reaction'] >= 0 else '',
figure5.COMPOUNDS_ORDERED[uni['compound']] if uni['compound'] >= 0 else '',
figures.figure4_fit.DATATYPES_ORDERED[uni['datatype']] if uni['datatype'] >= 0 else '',
figures.figure4_fit.REACTIONS_ORDERED[uni['reaction']] if uni['reaction'] >= 0 else '',
figures.figure4_fit.COMPOUNDS_ORDERED[uni['compound']] if uni['compound'] >= 0 else '',
])+'\n')

0 comments on commit 13eb27d

Please sign in to comment.