summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorepapoutsellis <epapoutsellis@gmail.com>2019-05-23 17:20:28 +0100
committerepapoutsellis <epapoutsellis@gmail.com>2019-05-23 17:20:28 +0100
commite3c6ac5310480eecf94a087ec92823671ecaec8b (patch)
treec136d90b4b7aec97e00e6633ac44a6eeff1d7c96
parentfab42230c06ea7b213042e0dea358a2f6a0dcd48 (diff)
parent2bbfe99f828b780137ec854267e5f6d38a06fcab (diff)
downloadframework-e3c6ac5310480eecf94a087ec92823671ecaec8b.tar.gz
framework-e3c6ac5310480eecf94a087ec92823671ecaec8b.tar.bz2
framework-e3c6ac5310480eecf94a087ec92823671ecaec8b.tar.xz
framework-e3c6ac5310480eecf94a087ec92823671ecaec8b.zip
merge denoising demo
-rw-r--r--NOTICE.txt15
-rwxr-xr-xWrappers/Python/ccpi/optimisation/algorithms/Algorithm.py30
2 files changed, 41 insertions, 4 deletions
diff --git a/NOTICE.txt b/NOTICE.txt
new file mode 100644
index 0000000..c107329
--- /dev/null
+++ b/NOTICE.txt
@@ -0,0 +1,15 @@
+CCPi Core Imaging Library (CIL).
+Copyright 2017 Rutherford Appleton Laboratory STFC
+Copyright 2017 University of Manchester
+
+This software product is developed for the Collaborative Computational
+Project in Tomographic Imaging CCPi (http://www.ccpi.ac.uk/) at RAL STFC (http://www.stfc.ac.uk), University of Manchester
+and other contributing institutions.
+
+Main contributors in alphabetical order:
+Evelina Ametova (UoM)
+Jakob Jorgensen (UoM)
+Daniil Kazantsev (Diamond Light Source)
+Srikanth Nagella (STFC)
+Edoardo Pasca (STFC)
+Evangelos Papoutsellis (UoM)
diff --git a/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py b/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py
index a14378c..0ba2c55 100755
--- a/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py
+++ b/Wrappers/Python/ccpi/optimisation/algorithms/Algorithm.py
@@ -16,7 +16,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-import time
+import time, functools
from numbers import Integral
class Algorithm(object):
@@ -148,14 +148,36 @@ class Algorithm(object):
print ("Stop cryterion has been reached.")
i = 0
+ if verbose:
+ print ("{:>9} {:>10} {:>11} {:>20}".format('Iter',
+ 'Max Iter',
+ 's/Iter',
+ 'Objective Value'))
for _ in self:
if (self.iteration -1) % self.update_objective_interval == 0:
if verbose:
- print ("Iteration {}/{}, = {}".format(self.iteration-1,
- self.max_iteration, self.get_last_objective()) )
+ print (self.verbose_output())
if callback is not None:
callback(self.iteration -1, self.get_last_objective(), self.x)
i += 1
if i == iterations:
break
-
+
+ def verbose_output(self):
+ '''Creates a nice tabulated output'''
+ timing = self.timing[-self.update_objective_interval-1:-1]
+ if len (timing) == 0:
+ t = 0
+ else:
+ t = sum(timing)/len(timing)
+ el = [ self.iteration-1,
+ self.max_iteration,
+ "{:.3f} s/it".format(t),
+ self.get_last_objective() ]
+
+ if type(el[-1] ) == list:
+ string = functools.reduce(lambda x,y: x+' {:>15.5e}'.format(y), el[-1],'')
+ out = "{:>9} {:>10} {:>11} {}".format(*el[:-1] , string)
+ else:
+ out = "{:>9} {:>10} {:>11} {:>20.5e}".format(*el)
+ return out