diff --git a/pymule/__init__.py b/pymule/__init__.py index 9bd46672f073d0d711787cdfb776097c7b451c83..acac217c6a22e626caad8e373396817acd40864a 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 4df798c9a5e1e9b12d573f7cbdf1fff4d36b1cd6..aa2b41f93379e92fd428bd3afeef5342930987da 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' + }))