-
Notifications
You must be signed in to change notification settings - Fork 0
/
TwoPtCorrelators.py
executable file
·8022 lines (7056 loc) · 365 KB
/
TwoPtCorrelators.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
#IMPORT THIS FIRST, put in base import file
# import matplotlib
# matplotlib.use('Agg') # Must be before importing matplotlib.pyplot or pylab!
# import matplotlib.pyplot as pl
##
from Params import nboot,defxlimAlpha,defxlimOp,datadir,cfgfmtdir,Debug_Mode,this_dir
from FileIO import ReadFuns,WriteFuns,Construct_File_Object
from Params import cfundir,defxlim,outputdir,TflowToPhys,Qeps,cfg_file_type,defSparam,Wipe_All_Fits
from MiscFuns import ODNested,mkdir_p,CheckClass,GetInfoList,RemoveAllBoots,fmt_file_type
from MiscFuns import Series_fix_key,CombineCfgs
from MiscFuns import CreateNameAndLL,GenSinkFun,flip_fun_2arg,Series_TO_ODict
from XmlFormatting import tstr,unxmlfitr,untstr,AvgStdToFormat,epsstr,unxmlfitr_int
from XmlFormatting import tflowTOLeg,tflowstr,tsinkTOLeg,untflowstr,tsumstr,KeyForamtting
# from XmlFormatting import MakeValAndErr
from PredefFitFuns import C2OneStateFitFunNoExp,C2OneStateFitFun,C2TwoStateFitFun,C2TwoStateFitFunNoExp,C2OSFAntiper
from PredefFitFuns import ConstantFitFun,Alpha_Prop_Fit_plin,C2OSFAntiperDer
from Autocorr import AutoCorrelate
from NullPlotData import null_series
from warnings import warn
import SetsOfFits as sff
# import traceback
import MomParams as mp
from ReadBinaryCfuns import R2CChromaXMLFileList,RC2Full
from BootStrapping import BootStrap
from FileIO import WriteXml,WritePickle,ReadPickleWrap,WriteExcel,ReadWithMeta,WriteWithMeta
from copy import deepcopy
# import cPickle as pickle
from TimeStuff import Timer
import numpy as np
import pandas as pa
import operator as op
import re,glob,os
import FitFunctions as ff
from functools import partial
import itertools
from collections import OrderedDict
from functools import partial
from FlowOpps import FlowOp,FlowOpFullSquared
"""
How to use:
TwoPointCorr(cfglist=[], Info={})
creates class using:
configuration list cfglist
Information Dictionary Info (See below for what can be in Info)
.LoadPickle()
Does everything basically.
Will ReadAndWrite() if pickle file is not found
i.e. will run analysis if not already done before.
NNQCorr class is below, (search for string! this is big file)
WARNING: only 1 stream is implemented now. only pass in config lists or have directories
with 1 steam (-a- for example)
"""
def GetInterpFlag(thisInterp):
if thisInterp == 'P4' or thisInterp == 'CPEven':
return '9'
elif thisInterp == 'g5P4' or thisInterp == 'CPOdd':
return '17'
elif thisInterp == 'g5' or thisInterp == 'g5div2':
return '1'
elif thisInterp == 'P4g5':
return '0'
elif thisInterp == 'Pion':
return '15'
else:
return thisInterp
class TwoPointCorr(object):
""" C2(p,t) uses bootstrap class
p = momentum
t = time
"""
def Construct_2pt_File(this_file):
return Construct_File_Object(this_file,TwoPointCorr)
## Info is a dictionary containing information for the correlator:
## see comments below to see what is required.
## missing elements just ignores that field
## TODO: create variational flag and interface with this function.
## array of all classes that inherit this class. Append this when adding new classes please!
parentlist = ['SetOfCorrs.SetOfTwoPt','TwoPtCorrelators.NNQCorr','TwoPtCorrelators.NNQFullCorr','VarMethod.VariationalTwoPt']
def __init__(self, thisnboot=nboot, cfglist={},Info={},thissym='Not Set',thiscol='Not Set',thisshift=0.0,name='',
man_load_cfgs=False):
## these class elemnts are checked when loading in pickled file
self.thischecklist = ['nboot','nt','ProjStr','ism','jsm','tsrc','kud','ks']
self.latparams = mp.LatticeParameters(Info=Info)
self.latparams.LoadPickle()
# self.checkmomlist = self.latparams.momstrlistAvg
self.nt = self.latparams.nt
self.nxyz = self.latparams.nxyz
self.current = 0
## Initialising plotting parameters
self.thisshift = thisshift
self.thiscol = thiscol
self.thissym = thissym
## the actual shift ammount needs to be scaled by the x axis size
## see GetShift
self.thisshiftscale = 'Not Set'
#self.C2 = [ ip , it , ,istream , iconf ]
# self.C2 = np.array([])
self.C2_cfgs = pa.DataFrame()
'''
self.C2_cfgs DataFrame:
columns = config_numbers , Op[ip, it]
rows = stream , configuration
'''
self.C2_Col_Names = ['momentum','source_sink_separation']
self.C2_Stats = pa.DataFrame()
'''
self.C2_Stats DataFrame:
columns = boot, Avg, Std
EffM, EffMAvg, EffMStd
rows = momenta, time separation
'''
# # C2boot [ ip , it ] bs
# self.C2boot = ODNested()
# self.C2Avg = ODNested()
# self.C2Std = ODNested()
#
# # EffM [ ip , it ] bs
# self.EffM = ODNested()
# self.EffMAvg = ODNested()
# self.EffMStd = ODNested()
self.C2_Fit_Col_Names = ['states','momentum']
self.C2_Fit_Stats = pa.DataFrame()
'''
self.C2_Fit_Stats DataFrame:
columns = boot
rows = states fitted to, momenta
boot is SetOfFits object
Avg/Std elements are pa.Series instances with:
index = fit parameters
values = Avg/Std values
'''
# # FitDict = [ States_Fitted_To, ip, Fit_range ] fitting class
# self.FitDict = ODNested()
# # FitDictAvg/Std [ States_Fitted_To , ip , Fit_range , Fit_Parameter ] bs
# self.FitDictAvg = ODNested()
# self.FitDictStd = ODNested()
self.nboot = thisnboot
## toggle to show exact configurations and sources used in xml outputfiles
if 'show_cfgs' in list(Info.keys()): self.show_cfgs = Info['show_cfgs']
else: self.show_cfgs = False
## used to pick out different configuraiton/source lists.
## for example, if there are less flowed operators than 2 point correlators, passing 'TopCharge' will read that result
if 'fo_for_cfgs' in list(Info.keys()): self.fo_for_cfgs = Info['fo_for_cfgs']
else: self.fo_for_cfgs = False
## Info can contain fit ranges to be calculated
## must bein form Info['Fits'] = [ ('state#' , 'fit#-#' ) , ...]
if 'Fits' in list(Info.keys()): self.PredefFits = Info['Fits']
else: self.PredefFits = []
## Info can contain projector used (or type of meson in psibar Gamma psi)
if 'Interp' in list(Info.keys()):
try:
self.ProjStr = 'P'+str(int(Info['Interp']))
except Exception as err:
self.ProjStr = Info['Interp']
self.Interp = GetInterpFlag(Info['Interp'])
else:
self.ProjStr = 'CPEven'
self.Interp = GetInterpFlag('CPEven') ## default to regular CP Even projector
if self.ProjStr == 'g5':
self.ProjStr = 'g5div2'
## Info can contain projector used (or type of meson in psibar Gamma psi)
if 'MesOrBar' in list(Info.keys()): self.MesOrBar = Info['MesOrBar']
else: self.MesOrBar = 'Baryon' ## Default to baryon
if 'cfg_file_type' in list(Info.keys()): self.cfg_file_type = Info['cfg_file_type']
else: self.cfg_file_type = cfg_file_type
## Info can contain initial guess for fits, make sure it array of correct length
if 'iGuess' in list(Info.keys()): self.iGuess = np.array(Info['iGuess'])
else: self.iGuess = 'None' ## Defaults to value set for function in FitFunctions.py
## Source Smearing ism value ( in integer form)
if 'ism' in list(Info.keys()): self.ism = 'ism'+str(Info['ism'])
else: self.ism = ''
## Sink Smearing jsm value ( in integer form)
if 'jsm' in list(Info.keys()): self.jsm = 'jsm'+str(Info['jsm'])
else: self.jsm = ''
## t_source location ( in integer form)
if 'tsrc' in list(Info.keys()): self.tsrc = 'tsrc'+str(Info['tsrc'])
else: self.tsrc = ''
if 'Sparam' in list(Info.keys()): self.Sparam = Info['Sparam']
else: self.Sparam = defSparam
## will attempt to find all replica streams in directory.
## set self.nstream to number of streams you want to find.
if 'stream_list' in list(Info.keys()):
if isinstance(Info['stream_list'],str):
if Info['stream_list'].lower() != 'all':
self.stream_list = [Info['stream_list']]
else:
self.stream_list = 'all'
else:
self.stream_list = [iinfo.lower() for iinfo in Info['stream_list']]
else:
self.stream_list = 'all'
# ## x_source list has been pushed to cfglist, this is depriciated
# if 'xsrc' in Info.keys(): self.xsrc = ['xsrc'+str(isrc) for isrc in Info['xsrc']]
# else: self.xsrc = ['xsrc1']
## momentum ( in form of [px py pz] )
if 'pmom' in list(Info.keys()):
if 'All' in Info['pmom']:
self.pmom = self.latparams.GetMomList(list_type='str_Avg').tolist() ## aparenlty ReadBinary likes lists, not numpy arrays
else:
self.pmom = list(map(self.latparams.GetAvgmomstr,Info['pmom']))
else: self.pmom = self.latparams.GetMomList(list_type='str_Avg').tolist()
self.pmom = self.latparams.RemoveDup(self.pmom)
self.checkmomlist = self.pmom
self.pform = ['p'+ip.replace(' ','') for ip in self.pmom]
## kappa up down (in integer form)
if 'kud' in list(Info.keys()): self.kud = 'kud'+str(Info['kud'])
else: self.kud = ''
## kappa strange (in integer form)
if 'ks' in list(Info.keys()): self.ks = 'ks'+str(Info['ks'])
else: self.ks = ''
## kappa strange (in integer form)
if 'Csw' in list(Info.keys()): self.Csw = 'C'+str(Info['Csw'])
else: self.Csw = 'C1715'
## kappa strange (in integer form)
if 'Beta' in list(Info.keys()): self.Beta = 'B'+str(Info['Beta'])
else: self.Beta = 'B1900'
fileism = self.ism.replace('ism','sm')
filejsm = self.jsm.replace('jsm','si')
self.kappafolder = 'Kud0'+self.kud.replace('kud','')+'Ks0'+self.ks.replace('ks','')
self.kappafolder2 = 'Kud0'+self.kud.replace('kud','')[:-2]+'Ks0'+self.ks.replace('ks','')[:-2]
self.dim_label = 'RC'+str(self.nxyz)+'x'+str(self.nt)
self.dim_ll = str(self.nxyz)+r'^{3}\times ' + str(self.nt)
self.readfilename = [self.dim_label+'_'+self.Beta+self.kappafolder+self.Csw,'_',
'_k'+self.kud.replace('kud','')+'_'+self.tsrc+fileism+filejsm+'_nucleon.2cf.xml']
self.readfilename2 = [self.dim_label+'_'+self.Beta+self.kappafolder2+self.Csw,'_',
'_k1382500_k1370000_'+self.tsrc+fileism+filejsm+'_nucleon.2cf.xml']
self.readfilename3 = [self.dim_label+'_'+self.Beta+self.kappafolder2+self.Csw,'_',
'_k1370000_k1364000_'+self.tsrc+fileism+filejsm+'_nucleon.2cf.xml']
if os.path.isdir(cfundir+self.dim_label+'_'+self.kappafolder+'_AY'):
self.filedir = cfundir+self.dim_label+'_'+self.kappafolder+'_AY/twoptRandT/twopt'+fileism+filejsm+'/'
elif os.path.isdir(cfundir+self.dim_label+'_'+self.kappafolder):
self.filedir = cfundir+self.dim_label+'_'+self.kappafolder+'/twoptRandT/twopt'+fileism+filejsm+'/'
else:
self.filedir = cfundir+self.kappafolder+'/twoptRandT/twopt'+fileism+filejsm+'/'
## cfglist { configuration : [ x-source numbers ] }
self.Info = Info
self.SetCustomName(name)
self.LogScale = 1.0
if not man_load_cfgs:
self.LoadCfgs(cfglist,name)
def LoadCfgs(self,cfglist,name=''):
if len(cfglist) == 0:
self.GetCfgList()
else:
self.ImportCfgList(cfglist)
self.SetCustomName(name)
def GetFuns(self):
if self.C2_Fit_Stats is not None and 'boot' in self.C2_Fit_Stats.columns:
for ival in self.C2_Fit_Stats['boot'].values:
ival.GetFuns()
def RemoveFuns(self):
if self.C2_Fit_Stats is not None and 'boot' in self.C2_Fit_Stats.columns:
for ival in self.C2_Fit_Stats['boot'].values:
ival.RemoveFuns()
# ## thisInfo must contain correct information for combining the correlators (the smearings, the eigenvectors, etc...)
# def GetCombCorr(self,thisInfo):
# from SetsOfTwoPtCorrs import SetOfTwoPt
# sinklab,jsmcoeffs,sm2ptList,InfoList = GetInfoList(thisInfo)
# C2Set = SetOfTwoPt(cfglist=self.NNQ_cfgs[['configs','xsrc_list']],InfoDict = InfoList)
# C2Set.LoadPickle(CheckCfgs=CheckCfgs)
# thisname,thisleglab,jsmlab = CreateNameAndLL(C2Set.SetC2,sinklab)
# thisfun = GenSinkFun(jsmcoeffs)
# thisfile = self.filename.replace(self.jsm,sinklab)
# thisLL = self.LegLab.replace(self.jsm,sinklab)
# # self.SetCustomName(thisfile,thisLL)
# # self.jsm = jsmlab
# return C2Set.CombineCorrs(thisfun,filename=thisfile,LegLab=thisLL,jsmlab=jsmlab)
def GetCfgList(self,name=''):
def SplitCfgSrc(ifile):
isrc = re.findall('_xsrc.*_k',ifile)
icfg = re.findall('-.-00.*_xsrc',ifile)
istream = re.findall('-.-',ifile)
if len(isrc) == 0 or len(icfg) == 0:
print()
print('WARNING: file does not have xsrc or -.-####### (source or cfg number)')
print(ifile)
print()
return '','',0,0
isrc = isrc[0].split('_')[1]
icfg = icfg[0].replace('_xsrc','')[5:]
istream = istream[0]
# return istream,isrc,icfg,int(icfg),int(isrc.replace('xsrc',''))
return istream,isrc,icfg
cfg_dict = ODNested()
this_check = isinstance(self.stream_list,str) and self.stream_list == 'all'
for ifile in glob.glob(self.filedir+'/*'):
istream,ixsrc,icfg = SplitCfgSrc(ifile)
if this_check or istream in self.stream_list:
if istream not in list(cfg_dict.keys()) or icfg not in list(cfg_dict[istream].keys()):
cfg_dict[istream][icfg] = [ixsrc]
else:
cfg_dict[istream][icfg].append(ixsrc)
if len(list(cfg_dict.keys())) == 0:
print('no configs found in ')
print(self.filedir)
cfglist,xsrclist,ilist = [],[],[]
this_lambda = lambda ix : int(ix.replace('xsrc',''))
for istream,stream_dict in cfg_dict.items():
for icfg,(the_cfg,ixsrc_list) in enumerate(stream_dict.items()):
ilist.append((istream,icfg))
cfglist.append(the_cfg)
## sorting xsrc list with respect to its INTEGER value (not string sort!)
ixsrc_int_list = list(map(this_lambda,ixsrc_list))
xsrclist.append([ix for _,ix in sorted(zip(ixsrc_int_list,ixsrc_list))])
## finds cfgs and xsrcs conbinations that are in all streams.
##MAKE SURE TO ORDER CFG AND SRC
if len(ilist) == 0:
# raise EnvironmentError('No configs found for \n'+name)
print('Warning, No configs found for \n',name)
else:
indicies = pa.MultiIndex.from_tuples(ilist,names=['stream','config_number'])
cfg_df = pa.DataFrame(cfglist,columns=['configs'],index=indicies)
cfg_df.loc[:,'xsrc_list'] = pa.Series(xsrclist,index=indicies)
cfg_df.loc[:,'int_configs'] = pa.Series(list(map(int,cfglist)),index=indicies)
cfg_df = cfg_df.sort_values('int_configs').sort_index(level='stream',sort_remaining=False)
del cfg_df['int_configs']
self.ImportCfgList(cfg_df)
# def MakeOutputFile(self):
# self.name = '_'.join([self.tsrc,self.ism,self.jsm])
# self.HumanFile = '/'+self.kappafolder+'/G2/'+self.name+'.xml'
# self.PickleFile = '/'+self.kappafolder+'/G2/Pickle/'+self.name+'.py3p'
## Routines for Plotting ###############################################
def ImportPlotParams(self,thiscol,thissym,thisshift):
self.CheckCol(thiscol)
self.CheckSym(thissym)
self.thisshift = thisshift
def CheckCol(self,thiscol):
if 'PreDefine' == thiscol :
if 'Not Set' == self.thiscol:
raise IOError('Pass in color to initialize it')
else:
self.thiscol = thiscol
def CheckSym(self,thissym):
if 'PreDefine' == thissym :
if 'Not Set' == self.thissym:
raise IOError('Pass in symbol to initialize it')
else:
self.thissym = thissym
def GetShift(self,xlims,thisshift):
if thisshift != 'PreDefine': self.thisshift = thisshift
# if self.thisshiftscale == 'Not Set':
xlen = np.abs(xlims[1]-xlims[0])
self.thisshiftscale = self.thisshift*xlen
return self.thisshiftscale
# else:
# return self.thisshiftscale
## make sure all xlims are the same, because this sets the window of xlim (needed for calculating shifts)
def LogPlot(self,plot_class,xlims='All',momlist=['p000'],
thiscol='PreDefine',thissym='PreDefine',thisshift='PreDefine',norm=False):
self.CheckCol(thiscol)
self.CheckSym(thissym)
self.thisshiftscale = 'Not Set'
if xlims == 'All':
xlims = range(self.nt+1)
thisshift = self.GetShift(xlims,thisshift)
if len(momlist) == 0:
momlist = self.C2_Stats.index.get_level_values('momentum')
for ip in momlist:
if 'All' in ip: ip = 'p000'
if ip not in self.C2_Stats.index.get_level_values('momentum'):
print(ip, ' not found in effective mass list')
continue
pdata = self.C2_Stats['boot'].xs(ip, level='momentum')
tlist,databoot = pdata.index,pdata.values
dataavg,dataerr = [],[]
if norm:
scale = databoot[xlims[0]].Log()
scale.Stats()
scale = scale.Avg
else:
scale = 1.0
for idata in databoot[xlims[0]:xlims[1]]:
logdata = idata.Log().__div__(scale)
logdata.Stats()
dataavg.append(logdata.Avg)
dataerr.append(logdata.Std)
tlist = tlist[xlims[0]:xlims[1]]
hold_series = pa.Series()
hold_series['x_data'] = np.array(list(map(untstr,tlist)))
hold_series['y_data'] = dataavg
hold_series['yerr_data'] = dataerr
hold_series['xerr_data'] = None
hold_series['type'] = 'error_bar'
hold_series['fit_class'] = None
hold_series['label'] = self.LegLab
hold_series['symbol'] = self.thissym
hold_series['color'] = self.thiscol
hold_series['shift'] = thisshift
hold_series['xdatarange'] = xlims
hold_series['scale'] = self.LogScale
hold_series['Phys'] = None
hold_series['fmt_class'] = KeyForamtting(self.latparams)
plot_class.AppendData(hold_series)
self.LogScale=scale
return plot_class
# plot_class.get_xlim(*xlims)
## make sure all xlims are the same, because this sets the window of xlim (needed for calculating shifts)
def Plot( self,plot_class,momlist=['p000'],
thiscol='PreDefine',thissym='PreDefine',thisshift='PreDefine',norm=False,log=False):
self.CheckCol(thiscol)
self.CheckSym(thissym)
## resets thisshiftscale so that you can plot EffMass and Log plot next to eachother,
self.thisshiftscale = 'Not Set'
# thisshift = self.GetShift(xlims,thisshift)
if len(momlist) == 0:
momlist = self.pform
# m_getattr = lambda x, y: getattr(y,x)
ip = momlist[0]
if 'All' in ip: ip = 'p000'
if ip not in self.pform:
print(ip, ' not found in effective mass list')
return plot_class
# pdata = self.C2_Stats['EffM'].xs(ip, level='momentum')
pdata = self.C2_Stats['boot']
if log:
pdata = pdata.apply(lambda x : x.Log())
pdata.apply(lambda x : x.Stats())
dataavg = pdata.apply(lambda x : x.Avg)
dataerr = pdata.apply(lambda x : x.Std)
# tlist = pdata.index[xlims[0]:xlims[1]]
# dataavg = dataavg.iloc[xlims[0]:xlims[1]]
# dataerr = dataerr.iloc[xlims[0]:xlims[1]]
## np.abs makes negative effective masses coming from G2^-1 be positive.
hold_series = pa.Series()
hold_series['x_data'] = 'from_keys'
# hold_series['x_data'] = np.array(map(untstr,tlist))
hold_series['y_data'] = dataavg
hold_series['key_select'] = (ip,slice(None))
hold_series['yerr_data'] = dataerr
hold_series['xerr_data'] = None
hold_series['type'] = 'error_bar_vary'
hold_series['fit_class'] = None
hold_series['label'] = self.LegLab
hold_series['symbol'] = self.thissym
hold_series['color'] = self.thiscol
hold_series['shift'] = thisshift
# hold_series['xdatarange'] = xlims
hold_series['fmt_class'] = KeyForamtting(self.latparams)
plot_class.AppendData(hold_series)
return plot_class
# plot_class.get_xlim(*xlims)
## make sure all xlims are the same, because this sets the window of xlim (needed for calculating shifts)
def EffMassPlot(self,plot_class,xlims = defxlim,momlist=['p000'],
thiscol='PreDefine',thissym='PreDefine',thisshift='PreDefine',Phys=True):
def DoPhys(value):
thisval = value*self.latparams.hbarcdivlat
thisval.Stats()
return thisval
self.CheckCol(thiscol)
self.CheckSym(thissym)
## resets thisshiftscale so that you can plot EffMass and Log plot next to eachother,
self.thisshiftscale = 'Not Set'
thisshift = self.GetShift(xlims,thisshift)
if len(momlist) == 0:
momlist = self.pform
# m_getattr = lambda x, y: getattr(y,x)
ip = momlist[0]
if 'All' in ip: ip = 'p000'
if ip not in self.pform:
print(ip, ' not found in effective mass list')
return plot_class
# pdata = self.C2_Stats['EffM'].xs(ip, level='momentum')
pdata = self.C2_Stats['EffM']
if Phys: pdata = pdata.apply(DoPhys)
dataavg = pdata.apply(lambda x : x.Avg)
dataerr = pdata.apply(lambda x : x.Std)
# tlist = pdata.index[xlims[0]:xlims[1]]
# dataavg = dataavg.iloc[xlims[0]:xlims[1]]
# dataerr = dataerr.iloc[xlims[0]:xlims[1]]
## np.abs makes negative effective masses coming from G2^-1 be positive.
hold_series = pa.Series()
hold_series['x_data'] = 'from_keys'
# hold_series['x_data'] = np.array(map(untstr,tlist))
hold_series['y_data'] = dataavg
hold_series['key_select'] = (ip,slice(None))
hold_series['yerr_data'] = dataerr
hold_series['xerr_data'] = None
hold_series['type'] = 'error_bar_vary'
hold_series['fit_class'] = None
hold_series['label'] = self.LegLab
hold_series['symbol'] = self.thissym
hold_series['color'] = self.thiscol
hold_series['shift'] = thisshift
hold_series['xdatarange'] = xlims
hold_series['Phys'] = Phys
hold_series['fmt_class'] = KeyForamtting(self.latparams)
plot_class.AppendData(hold_series)
return plot_class
# plot_class.get_xlim(*xlims)
## state is 1 or 2 state fit
## fitr is fit range e.g. fitr5-10
## fit range of 'Data' is just the original fit range
## make sure to plot this after LogPlot or the xlims wont work properly
def LogFitPlot( self,plot_class,state,fitr,
xlims = 'Data',momlist=['p000'],thiscol='PreDefine',thisshift='PreDefine'):
return self.EffMassFitPlot( plot_class,state,fitr,
xlims = xlims,momlist=momlist,thiscol=thiscol,thisshift=thisshift,
plot_type='logplot')
## state is 1 or 2 state fit
## fitr is fit range e.g. fitr5-10
## fit range of 'Data' is just the original fit range
## make sure to plot this after EffMassPlot or the xlims wont work properly
def EffMassFitPlot( self,plot_class,state,fitr,
xlims = 'Data',momlist=['p000'],thiscol='PreDefine',thisshift='PreDefine',
Phys=True,plot_type='effmass'):
self.CheckCol(thiscol)
thisshift = self.GetShift(plot_class.get_xlim(),thisshift)
if isinstance(momlist,(list,tuple,np.ndarray)):
print('momlist is not needed anymore, picking p000')
momlist = 'p000'
if isinstance(state,int): state = 'state'+str(state)
if 'boot' not in self.C2_Fit_Stats.columns:
print('no fits done, starting')
self.Fit(int(state.replace('state','')),fitr)
fit_data = sff.PullSOFSeries(self.C2_Fit_Stats['boot'],fmted=True)
if len(fit_data) == 0: return plot_class
# fit_data = Series_fix_key(fit_data,4,'fittwor','tsumfitr')
this_fun = fit_data.index[0][2]
this_key = (state,momlist,this_fun,fitr)
if this_key not in fit_data.index:
print(this_key, ' not found in FitDict, performing fit now')
print(fit_data)
self.Fit(int(state.replace('state','')),fitr)
hold_series = null_series
if 'effmass' in plot_type.lower():
hold_series['type'] = 'effm_fit_vary'
elif 'log' in plot_type.lower():
hold_series['type'] = 'log_fit_vary'
hold_series['fit_class'] = fit_data
hold_series['key_select'] = this_key
hold_series['label'] = 'Exp Fit'
hold_series['symbol'] = self.thissym
hold_series['color'] = self.thiscol
hold_series['Phys'] = Phys
hold_series['shift'] = thisshift
hold_series['xdatarange'] = xlims
hold_series['fmt_class'] = KeyForamtting(self.latparams)
plot_class.AppendData(hold_series)
return plot_class
## ##################### ###############################################
## state is 1 or 2 state fit
## fitr is fit range e.g. fitr5-10
## fit range of 'Data' is just the original fit range
## make sure to plot this after EffMassPlot or the xlims wont work properly
## TODO, fix this
def RecRelPlot(self,plot_class,state,fitr,thiscol='PreDefine',thisshift='PreDefine',thissym='PreDef',Phys=True):
print('RecRelPlot Not implemeted for ImpSOF, ON THE TODO LIST')
return plot_class
# def DoPhys(value):
# thisval = value*self.latparams.hbarcdivlat
# thisval.Stats()
# return thisval
#
# self.CheckCol(thiscol)
# self.CheckSym(thissym)
# if isinstance(state,int): state = 'state'+str(state)
# # fitr_params = self.FitDict[state][fitr]
# for imom in self.pform:
# if (state,imom,fitr) not in self.C2_Fit_Stats.index:
# print state,imom,fitr , ' has not been done, performing fit now'
# self.Fit(int(state.replace('state','')),[fitr])
# this_fit = self.C2_Fit_Stats['boot']
# varl,errl,indexl,bootl = [],[],[],[]
# for (istate,imom,ifitr),ifit in this_fit.iteritems():
# for ipar,parval in ifit.fit_data['Params'].iteritems():
# indexl.append((istate,imom,ifitr,ipar))
# if ipar == 'Energy' and Phys:
# parval = parval*self.latparams.hbarcdivlat
# parval.Stats()
# bootl.append(parval)
# varl.append(parval.Avg)
# errl.append(parval.Std)
# if len(indexl) > 0:
# indicies = pa.MultiIndex.from_tuples(indexl,names=list(self.C2_Fit_Stats.index.names) + ['Parameter'])
# fit_boot = pa.Series(bootl,index=indicies)
# fit_data = pa.Series(varl,index=indicies)
# fiterr_data = pa.Series(errl,index=indicies)
#
#
# xboot = [self.latparams.EnergyFromRecRel(imom,zboot) for imom,zboot in fit_boot.loc[(istate,slice(None),ifitr,ipar)].iteritems()]
# ploty = fit_data.loc[(istate,slice(None),ifitr,ipar)].values
# plotx = map(lambda x : x.Avg,xboot)
# plotxerr = map(lambda x : x.Std,xboot)
# thisshift = self.GetShift((min(plotx),max(plotx)),thisshift)
# hold_series = pa.Series()
# hold_series['x_data'] = np.array(plotx)
# hold_series['y_data'] = fit_data
# hold_series['xerr_data'] = plotxerr
# hold_series['yerr_data'] = fiterr_data
# hold_series['type'] = 'error_bar_vary'
# hold_series['key_select'] = (istate,slice(None),ifitr,ipar)
# hold_series['fit_class'] = None
# hold_series['label'] = self.LegLab
# hold_series['symbol'] = self.thissym
# hold_series['color'] = self.thiscol
# hold_series['shift'] = thisshift
# plot_class.AppendData(hold_series)
# return plot_class,max([max(ploty),max(plotx)]),min([min(ploty),min(plotx)])
def SetCustomName(self,string='',stringLL='',fo_for_cfgs='PreDef'):
if not hasattr(self,'stream_name'):
self.stream_name = '-def-'
if string == '':
self.name = '_'.join([self.dim_label,self.kappafolder,self.stream_name,self.MesOrBar,self.ProjStr,self.tsrc,self.ism,self.jsm])
self.filename = '_'.join([self.MesOrBar,self.stream_name,self.ProjStr,self.tsrc,self.ism,self.jsm])
# self.filename = self.name
else:
self.filename = self.name = string
if stringLL == '':
self.LegLab = '$'+'\ '.join([self.dim_ll,self.latparams.GetPionMassLab(),self.stream_name,self.MesOrBar,self.ProjStr,self.ism,self.jsm])+'$' ## customise this how you like
else:
self.LegLab = stringLL
if isinstance(fo_for_cfgs,str):
if fo_for_cfgs == 'PreDef':
fo_for_cfgs = self.fo_for_cfgs
if isinstance(fo_for_cfgs,str):
self.G2dir = outputdir + '/'+self.dim_label+self.kappafolder+'/G2/'+fo_for_cfgs+'/'
self.G2Cfgsdir = cfgfmtdir + '/'+self.dim_label+self.kappafolder+'/G2/'+fo_for_cfgs+'/'
else:
self.G2dir = outputdir + '/'+self.dim_label+self.kappafolder+'/G2/'
self.G2Cfgsdir = cfgfmtdir + '/'+self.dim_label+self.kappafolder+'/G2/'
mkdir_p(self.G2dir+'/Pickle/')
mkdir_p(self.G2dir+'/Excel/')
mkdir_p(self.G2Cfgsdir+'/')
self.HumanFile = self.G2dir+self.filename+'.xml'
self.ExcelFile = self.G2dir+'/Excel/'+self.filename+'.xlsx'
self.PickleFile = self.G2dir+'/Pickle/'+self.filename+'.py3p'
self.CfgFile = self.G2Cfgsdir+'/'+self.filename+'.cfgs'
def ImportCfgList(self,cfgsrclist,stream_list = 'PreDefine'):
if not isinstance(cfgsrclist,pa.DataFrame):
if not isinstance(stream_list,str):
self.stream_list = stream_list
## cfgsrclist is [cfglist , xsrclist]
## cfglist must be 2-d array, first dimension is stream, second dimension is configuraiton number
## xsrclist is 3-d array, first dimension is stream, second dimension is cfg number, third is xsrc number
## xsrclist must have values 'xsrc##' with no zero pre buffering
ilist = []
xsrc_list = []
for istream,(is_cfg,is_xsrc) in enumerate(zip(cfgsrclist[0],cfgsrclist[1])):
for icf in range(is_cfg):
xsrc_list.append(is_xsrc)
ilist.append((istream,is_cfg))
indicies = pa.MultiIndex.from_tuples(ilist,names=['stream','config_number'])
cfg_df = pa.DataFrame(np.array(cfgsrclist[0]).flatten(),columns=['configs'],index=indicies)
cfg_df.loc[:,'xsrc_list'] = pa.Series(xsrc_list,index=indicies)
self.C2_cfgs = cfg_df
else:
self.C2_cfgs = cfgsrclist
if 'configs' in self.C2_cfgs.columns:
self.C2_cfgs.loc[:,'stream_cfgs'] = pa.Series(['00'.join((istream,icfg)) for (istream,iccfg),icfg in self.C2_cfgs['configs'].items()],index=self.C2_cfgs.index)
# print
# print 'DEBUG importing cfgs'
# print self.C2_cfgs
self.Update_Stream_List()
self.ncfg_list = [icfg.size for istream,icfg in self.C2_cfgs['configs'].groupby(level='stream')]
self.xsrcAvg = np.mean(list(map(len,self.C2_cfgs['xsrc_list'].values)))
self.nMeas = self.xsrcAvg*sum(self.ncfg_list)
## filecfglist [ istream , icfg , isrc ]
def Update_Stream_List(self):
if 'configs' in self.C2_cfgs:
self.stream_list = self.C2_cfgs.index.levels[0]
self.nstream = len(self.stream_list)
if hasattr(self,'stream_name'):
old_sn = self.stream_name
self.stream_name = '-'+''.join([istr.replace('-','') for istr in self.stream_list])+'-'
if hasattr(self,'filename'):
self.filename = self.filename.replace(old_sn,self.stream_name)
if hasattr(self,'name'):
self.name = self.name.replace(old_sn,self.stream_name)
if hasattr(self,'LegLab'):
self.LegLab = self.LegLab.replace(old_sn,self.stream_name)
else:
self.stream_name = '-'+''.join([istr.replace('-','') for istr in self.stream_list])+'-'
def Stats(self):
if 'boot' not in self.C2_Stats: return
lAvg,lStd = [],[]
for (ip,it),iC2 in self.items():
iC2.Stats()
lAvg.append(iC2.Avg)
lStd.append(iC2.Std)
indicies = pa.MultiIndex.from_tuples(self.C2_Stats.index,names=self.C2_Col_Names)
self.C2_Stats.loc[:,'Avg'] = pa.Series(lAvg,index=indicies)
self.C2_Stats.loc[:,'Std'] = pa.Series(lStd,index=indicies)
self.EffMass()
def RemoveVals(self):
if 'C2' in self.C2_cfgs: del self.C2_cfgs['C2']
#self.C3 = [ igamma , ip , it , iconf ]
def WriteCfgsToFile(self,thisdir,show_timer=True):
thisoutdir = thisdir + '/'+self.dim_label+'_'+self.kappafolder+'/'+self.ProjStr+'_'.join([self.ism,self.jsm])+'/'
# for igamma,gammadata in zip(self.gammalist,self.C3_cfgs['C3']):
mkdir_p(thisoutdir)
if show_timer: thistimer = Timer(linklist=self.C2_cfgs['configs'].values,name='Writing 2-ptCorrs ')
for ((istream,iccfg),cfgdata),icfg in zip(iter(self.C2_cfgs['C2'].items()),self.C2_cfgs['configs'].values):
cfgstr = 'C2'+istream+'cfg'+str(icfg).zfill(5)
thisfile = thisoutdir + '/'+cfgstr+'.xml'
dictout = ODNested()
for ip,qdata in zip(self.pform,cfgdata):
for it,tdata in enumerate(qdata):
itstr = tstr(it+1)
dictout[ip][itstr] = tdata
WriteXml(thisfile,{'Results':dictout})
if show_timer: thistimer.Lap()
#self.C3 = [ igamma , ip , it , iconf ]
def WriteBootToFile(self,thisdir,show_timer=True):
thisoutdir = thisdir + '/'+self.dim_label+'_'+self.kappafolder+'/'+self.ProjStr+'_'.join([self.ism,self.jsm])+'/'
# for igamma,gammadata in zip(self.gammalist,self.C3_cfgs['C3']):
mkdir_p(thisoutdir)
if show_timer: thistimer = Timer(linklist=list(range(1,self.nboot+1)),name='Writing booted 2-ptCorrs ')
this_nboot = self.C2_Stats.loc[:,'boot'].iloc[0].bootvals.index
for iboot in this_nboot:
boot_val = self.C2_Stats.loc[:,'boot'].apply(lambda ival : ival.bootvals.loc[iboot])
cfgstr = 'C2_iboot'+str(iboot).zfill(5)
thisfile = thisoutdir + '/'+cfgstr+'.xml'
dictout = ODNested()
for (ip,it),ival in boot_val.items():
dictout[ip][it] = ival
WriteXml(thisfile,{'Results':dictout})
if show_timer: thistimer.Lap()
## self.C2 = [ ip, it , iconf ]
def Read(self,show_timer=True,Full=False,file_type='PreDef'):
## making interpolator number more human readable
if Full:
self.CfgFile = self.CfgFile.replace('.cfgs','_Full.cfgs')
if self.Read_Cfgs(file_type=file_type,show_timer=show_timer):
return
thisdata = []
prop_src = []
# if len(self.filename.split('_')) > 5:
# raise IOError('Do not read after combining correlators, please recreate the correlator')
thistfix = False
# if self.nt == 40 and self.nxyz == 20: thistfix = True
if show_timer: thistimer = Timer(linklist=self.C2_cfgs['stream_cfgs'].values,name='Read '+self.name)
for i_stream_cfg,ixsrc_list in zip(self.C2_cfgs['stream_cfgs'].values,self.C2_cfgs['xsrc_list'].values):
thisxsrclist = [self.filedir+ self.readfilename[0]+i_stream_cfg+self.readfilename[1]+ixsrc+self.readfilename[2] for ixsrc in ixsrc_list]
if not os.path.isfile(thisxsrclist[0]):
thisxsrclist = [self.filedir+ self.readfilename2[0]+i_stream_cfg+self.readfilename2[1]+ixsrc+self.readfilename2[2] for ixsrc in ixsrc_list]
if not os.path.isfile(thisxsrclist[0]):
thisxsrclist = [self.filedir+ self.readfilename3[0]+i_stream_cfg+self.readfilename3[1]+ixsrc+self.readfilename3[2] for ixsrc in ixsrc_list]
if Full:
idata = RC2Full(thisxsrclist,self.pmom,InterpNumb=self.Interp,MesOrBar=self.MesOrBar)
else:
idata = R2CChromaXMLFileList(thisxsrclist,self.pmom,InterpNumb=self.Interp,MesOrBar=self.MesOrBar,tfix=thistfix)
thisdata.append(idata.data)
prop_src.append(idata.tshiftlist)
if show_timer: thistimer.Lap()
if Full: self.C2_cfgs.loc[:,'tsrc_list'] = pa.Series(prop_src,index=self.C2_cfgs.index)
self.C2_cfgs.loc[:,'C2'] = pa.Series(thisdata,index=self.C2_cfgs.index)
if self.Interp == '1':
self.C2_cfgs.loc[:,'C2'] = self.C2_cfgs.loc[:,'C2'].apply(lambda x : (np.array(x)/2.).tolist())
self.Write_Cfgs(show_timer=show_timer,file_type=file_type)
# self.C2_cfgs.to_csv('./Debug2pt_cfgs.csv')
# pa.Series(self.Info).to_csv('./Debug2pt_Info.csv')
# print 'DEBUG mean'
# for ival in range(self.nt):
# print 't'+str(ival),self.C2_cfgs.loc[:,'C2'].apply(lambda x : x[0][ival]).mean()
# # print self.C2_cfgs.loc[:,'C2'].apply(lambda x : x[0][ival]).to_csv('./Debug2pt_C2.csv')
# print
#
# print 'DEBUG t1 in stream -2-'
# for ikey,ival in self.C2_cfgs.loc[:,'C2'].iteritems():
# print ikey,ival[0][0]
# # self.C2_cfgs.loc[:,'stream_cfgs'].to_csv('./Debug2pt_cfgs.csv')
# # print self.C2_cfgs.loc[:,'C2'].apply(lambda x : x[0][ival]).to_csv('./Debug2pt_C2.csv')
# print
def Bootstrap(self,WipeData=True):
if 'C2' not in self.C2_cfgs:
self.Read()
lC2,lC2Avg,lC2Std = [],[],[]
lCA2,lCA2Avg,lCA2Std = [],[],[]
ilist = []
rlist = None
# print 'DEBUG',self.name
for icp,ip in enumerate(self.pform):
for it in range(self.latparams.nt):
strit = tstr(it+1)
ilist.append((ip,strit))
this_lambda = lambda x : x[icp][it]
tdata = self.C2_cfgs['C2'].apply(this_lambda)
thisboot = BootStrap(self.nboot, name='G_{2}('+ip+','+strit+')',cfgvals=tdata,rand_list=rlist)
rlist = thisboot.Get_Rand_List()
# print ip,it,'bootval=',thisboot.Avg,'bootstd',thisboot.Std,'diff=', np.abs(thisboot.Avg-np.mean(tdata))/np.mean(tdata)
lC2.append(thisboot)
lC2Avg.append(thisboot.Avg)
lC2Std.append(thisboot.Std)
def eye_fun(*x):
return x[0]
def one_fun(*x):
return [x[0]/x[0]]
tdata = tdata.to_frame('C2')
thisAuto = AutoCorrelate( Fun=(eye_fun,one_fun),Sparam=self.Sparam,
name=self.name + ip+' $t='+str(it)+'$',data=tdata)
lCA2.append(thisAuto)
lCA2Avg.append(thisAuto.Avg)
lCA2Std.append(thisAuto.Std)
if len(ilist) > 0:
indicies = pa.MultiIndex.from_tuples(ilist,names=self.C2_Col_Names)
self.C2_Stats.loc[:,'boot'] = pa.Series(lC2,index=indicies)
self.C2_Stats.loc[:,'Avg'] = pa.Series(lC2Avg,index=indicies)
self.C2_Stats.loc[:,'Std'] = pa.Series(lC2Std,index=indicies)
self.C2_Stats.loc[:,'Auto'] = pa.Series(lCA2,index=indicies)
self.C2_Stats.loc[:,'AutoAvg'] = pa.Series(lCA2Avg,index=indicies)
self.C2_Stats.loc[:,'AutoStd'] = pa.Series(lCA2Std,index=indicies)
if WipeData: self.RemoveVals()
# def ReadAndBoot(self):
# self.Read()
# self.Bootstrap()
def ImportFitRanges(self,fit_range):
if fit_range == 'PreDef':
self.fit_range = self.PredefFits[0][1]
else:
self.fit_range = fit_range
if isinstance(self.fit_range,(list,tuple,np.ndarray)):
print('SetsOfFits implementation only takes 1 fit range to vary over, choosing first')
self.fit_range = self.fit_range[0]
## Fitting the correlator
## fit_range is either list of fit ranges to fit the correlator to, or a single fit range
## formatted as fitr#-# where # are the min and max fit values.
## states correspond to how many states to fit to (currenlty only working for states = 1 or 2)
## NB, iGuess here is not implemented yet, needs to be passed into the function
def Fit(self,state='PreDef',fit_range='PreDef',iGuess='PreDef',EstDir=False,Ratio=False,WipeFit=False):
if iGuess != 'PreDef': self.iGuess = iGuess
self.ImportFitRanges(fit_range)
if state == 'PreDef':
state = self.PredefFits[0][0]
if isinstance(state,str):
if 'state' in state:
state = state.replace('state','')
state = int(state)
if self.MesOrBar == 'Baryon':
if state == 1:
this_fun = [C2OneStateFitFunNoExp,2]
elif state == 2:
this_fun =[C2TwoStateFitFunNoExp,4]
elif state > 2:
raise IOError('fitting state for Bayrons is only implemented up to 2 state so far. Cannot do '+str(state))
this_fit_info = {'Funs':this_fun}
elif self.MesOrBar == 'Meson':
if state == 1:
def C2atT(t,p):
return C2OSFAntiper(t,p,self.latparams.nt+1)
C2atT.file_name = 'C2atT'+str(self.latparams.nt+1)
this_fun = [C2atT,2]
def C2DeratT(t,p):
return C2OSFAntiperDer(t,p,self.latparams.nt+1)
C2DeratT.file_name = 'C2DeratT'+str(self.latparams.nt+1)
elif state > 1:
raise IOError('fitting state for Mesons is only implemented up to 1 state so far. Cannot do '+str(state))
this_fit_info = {'Funs':this_fun,'FunDer':C2DeratT}