From 5065868f69a4df4143f1ec2cfcf2eece719e8783 Mon Sep 17 00:00:00 2001 From: Yannick Ulrich <yannick.ulrich@psi.ch> Date: Sun, 16 Feb 2020 11:44:21 +0100 Subject: [PATCH] 2: added bare exportvegas with defaults towards #12 --- pymule/__init__.py | 4 ++-- pymule/vegas.py | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/pymule/__init__.py b/pymule/__init__.py index 9bd4667..acac217 100644 --- a/pymule/__init__.py +++ b/pymule/__init__.py @@ -15,14 +15,14 @@ __all__ = [ 'addsets', 'scaleset', 'errorband', 'kplot', 'watermark', 'pi', 'alpha', 'GF', 'conv', 'Mmu', 'Mel', 'Mtau', - 'importvegas', 'mulify' + 'importvegas', 'exportvegas', 'mulify' ] import numpy as np import matplotlib.pyplot as plt -from vegas import importvegas +from vegas import importvegas, exportvegas from errortools import mergenumbers, plusnumbers, dividenumbers, timesnumbers,\ mergeplots, addplots, divideplots, scaleplot, \ combineplots, combineNplots, \ diff --git a/pymule/vegas.py b/pymule/vegas.py index 4df798c..aa2b41f 100644 --- a/pymule/vegas.py +++ b/pymule/vegas.py @@ -133,3 +133,28 @@ def importvegas(filename="", fp=None, inttype='i'): fp.close() return dic + + +def exportvegas(dic, filename="", fp=None): + if not fp and filename: + fp = open(filename, 'wb') + + fp.write("\t\000\000\000 McMule \t\000\000\000") + + if 'SHA' not in dic: + dic['SHA'] = '00000' + if 'iteration' not in dic: + dic['iteration'] = 2 + if 'ndo' not in dic: + dic['ndo'] = -1 + if 'xi' not in dic: + dic['xi'] = -np.ones(17*50) + if 'randy' not in dic: + dic['randy'] = -1 + + while type(dic['chi2a']) == list: + dic['chi2a'] = dic['chi2a'][0] + + plots = sorted(list(set(dic.keys()) - { + 'SHA','chi2a','iteration','msg','value','time','ndo','randy','xi' + })) -- GitLab