Add --clean-cache option to velocity_dependant_scan.main().
authorW. Trevor King <wking@drexel.edu>
Wed, 20 Oct 2010 07:30:27 +0000 (03:30 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 20 Oct 2010 07:30:27 +0000 (03:30 -0400)
pysawsim/velocity_dependant_scan.py

index 787d5e2a40d2e89c75dc5647f73d412b3ced5104..caf3d3063deb5e4c069edecab3d01c541bbe4129 100644 (file)
@@ -61,7 +61,7 @@ class HistogramMatcher (object):
     """
     def __init__(self, velocity_stream, param_format_string, N=400,
                  manager=None, residual_type='jensen-shannon', plot=True,
-                 use_cache=False):
+                 use_cache=False, clean_cache=False):
         self.experiment_histograms = self.read_force_histograms(velocity_stream)
         self.param_format_string = param_format_string
         self.residual_type = residual_type
@@ -69,7 +69,7 @@ class HistogramMatcher (object):
         self._manager = manager
         self.plot = plot
         self.sawsim_histogram = sawsim_histogram.SawsimHistogram(
-            use_cache=self.use_cache)
+            use_cache=use_cache, clean_cach=clean_cache)
 
     def read_force_histograms(self, stream):
         """
@@ -243,9 +243,12 @@ def main():
                       help="Job manager name (one of %s) (%%default)."
                       % (', '.join(MANAGERS)),
                       default=MANAGERS[0])
-    parser.add_option("-C","--use_cache", dest="use_cache",
+    parser.add_option("-C","--use-cache", dest="use_cache",
                       help="Use cached simulations if they exist (vs. running new simulations) (%default)",
                       default=False, action="store_true")
+    parser.add_option("--clean-cache", dest="clean_cache",
+                      help="Remove previously cached simulations if they exist (%default)",
+                      default=False, action="store_true")
     parser.add_option("-d","--cache-dir", dest="cache_dir",
                       metavar="STRING",
                       help="Cache directory for sawsim unfolding forces (%default).",
@@ -277,7 +280,8 @@ def main():
     hm = HistogramMatcher(
         file(velocity_file, 'r'), param_format_string=options.param_format,
         N=options.N, manager=manager, residual_type=options.residual,
-        plot=options.plot_residuals, use_cache=options.use_cache)
+        plot=options.plot_residuals, use_cache=options.use_cache,
+        clean_cache=options.clean_cache)
     #hm.fit(initial_params)
     hm.plot(param_ranges, logx=options.logx, logy=options.logy,
             contour=options.contour_plot)