diff msnc_tools.py @ 41:ef5c2f7b49ec draft

"planemo upload for repository https://github.com/rolfverberg/galaxytools commit 0d207c80e38a6019595ebe178f5678372b75f3e7"
author rv43
date Thu, 21 Apr 2022 14:21:38 +0000
parents 845270a96464
children
line wrap: on
line diff
--- a/msnc_tools.py	Tue Apr 19 19:11:59 2022 +0000
+++ b/msnc_tools.py	Thu Apr 21 14:21:38 2022 +0000
@@ -266,6 +266,7 @@
             illegal_value('files[0]', files[0], 'loadImageStack')
             return img_stack
         t0 = time()
+        logging.info(f'Loading {files[0]}')
         with h5py.File(files[0], 'r') as f:
             shape = f['entry/instrument/detector/data'].shape
             if len(shape) != 3:
@@ -290,6 +291,13 @@
         illegal_value('filetype', filetype, 'findImageRange')
     return img_stack
 
+def combine_tiffs_in_h5(files, num_imgs, h5_filename):
+    img_stack = loadImageStack(files, 'tif', 0, num_imgs)
+    with h5py.File(h5_filename, 'w') as f:
+        f.create_dataset('entry/instrument/detector/data', data=img_stack)
+    del img_stack
+    return [h5_filename]
+
 def clearFig(title):
     if not isinstance(title, str):
         illegal_value('title', title, 'clearFig')
@@ -337,6 +345,8 @@
         if show_grid:
             ax = plt.gca()
             ax.grid(color=grid_color, linewidth=grid_linewidth)
+        if title != 'quick_imshow':
+            plt.title = title
         plt.savefig(path)
         plt.close(fig=title)
         #plt.imsave(f'{title}.png', a, **kwargs)
@@ -347,6 +357,8 @@
         if show_grid:
             ax = plt.gca()
             ax.grid(color=grid_color, linewidth=grid_linewidth)
+        if title != 'quick_imshow':
+            plt.title = title
         if save_fig:
             plt.savefig(path)
         plt.pause(1)
@@ -394,6 +406,8 @@
         if show_grid:
             ax = plt.gca()
             ax.grid(color='k')#, linewidth=1)
+        if title != 'quick_plot':
+            plt.title = title
         plt.savefig(path)
         plt.close(fig=title)
     else:
@@ -407,6 +421,8 @@
         if show_grid:
             ax = plt.gca()
             ax.grid(color='k')#, linewidth=1)
+        if title != 'quick_plot':
+            plt.title = title
         if save_fig:
             plt.savefig(path)
         plt.pause(1)
@@ -588,7 +604,7 @@
         mod = RectangleModel(form=form)
     pars = mod.guess(y, x=x)
     out  = mod.fit(y, pars, x=x)
-    #print(out.fit_report())
+    #print(f'fit_report:\n{out.fit_report()}')
     #quickPlot((x,y),(x,out.best_fit))
     return out.best_values