Index: .gitignore
===================================================================
--- .gitignore	(revision 2a55a6f2f24f911b7394865b206431a89f96ead0)
+++ .gitignore	(revision 8a5f0216970a47f3e897a508054840132bd87909)
@@ -20,2 +20,4 @@
 /.idea
 /sasmodels.egg-info/
+/example/Fit_*/
+/example/batch_fit.csv
Index: example/093191_201.dat
===================================================================
--- example/093191_201.dat	(revision 93d0ea782dc75cafd87251f5b4cd8bac876628ef)
+++ example/093191_201.dat	(revision 93d0ea782dc75cafd87251f5b4cd8bac876628ef)
@@ -0,0 +1,137 @@
+GRASP V.7.11CD    Instrument:  ILL_d22 
+  
+***** Sample, Backgrounds and Transmissions Data: ***** 
+Subtitle:  CM 10% SDS  
+Start: 01-Sep-16   12:23:13   End: 01-Sep-16   12:23:18 
+  
+Foreground:  93191 , Loaded: 92991:93230 
+Background:  91098 , Loaded: 91098 
+Cadmium:  90990 , Loaded: 90990 
+Det: 1 : Applying Deadtime Correction per (vertical) Tube: 1/[1-tau/detector_rate], tau = 1e-06 (seconds) 
+Data Normalisation: Standard Monitor (10000000) counts 
+Attenuator: 0 is In.  Attenuation factor 1 
+Attenuator: 0 is In. Up-scaling data by 1 
+Attenuator2: is Out 
+Attenuator2: Up-scaling data by 1 
+  
+Beam Centre1 :  Cx = 27.1492  Cy = 127.3257       Cm Translation :  Tx = 0  Ty = 0 [mm] 
+Transmissions:  Ts = 0.97203 +/- 0.010336  Te = 1 +/- 0.0013531 
+Transmissions Thickness Correction is:  on 
+Applying standard SANS data reduction:  I_corr = 1/[Ts Te] [I_s - I_cd]  - 1/[Te] [I_bck - I_cd] 
+  
+***** Calibrations: ***** 
+Data: Corrected for D22 Detector Paralax 
+Data: Corrected for Detector Efficiency (doesn't change magnitude but contains curvature correction) 
+Data: Divided by Volume 0.025 cm3 
+Solid Angle Correction: 
+Divide data by empty beam flux, I0, from worksheet: I0 Beam Intensity 1 202 
+Applying Default Instrument Mask 
+Applying User Defined Mask 
+Applying NanInf Mask 
+Intensity units are:  cm-1 \\ \Delta\Omega  
+  
+***** Analysis ***** 
+Averaging I vs. Q.  Bin size:  1 [Pixel(s)] 
+ 
+ 
+Mod_Q   	I       	Err_I   	Sigma_Q
+
+ 
+ 
+0.0399306	0.455087	0.0263041	0.00471442
+0.0461801	0.594146	0.0176702	0.00480794
+0.0519658	0.721063	0.0154168	0.00490303
+0.0578791	0.975489	0.0151415	0.00500984
+0.0639094	1.32481	0.01666	0.00512844
+0.0698138	1.91231	0.0190375	0.00525617
+0.0757907	2.70255	0.0212271	0.00539353
+0.0818611	3.45201	0.022998	0.00553989
+0.0878521	3.84812	0.0236703	0.00569104
+0.0937984	3.67201	0.0223657	0.00584668
+0.0997329	3.08463	0.0199299	0.00603593
+0.105788	2.44287	0.0169271	0.00623212
+0.111814	1.8944	0.0149048	0.00640109
+0.117765	1.48387	0.0128443	0.00662702
+0.123807	1.19565	0.0112736	0.00668684
+0.129841	1.0071	0.0102806	0.00680967
+0.135846	0.836246	0.00923172	0.00712461
+0.141859	0.716454	0.00849073	0.00743994
+0.14784	0.628444	0.00788484	0.00755558
+0.153823	0.534797	0.00722617	0.0076497
+0.159753	0.456498	0.00677101	0.00780975
+0.165751	0.378987	0.00646111	0.00810292
+0.171732	0.33881	0.00616212	0.00839535
+0.177739	0.289236	0.00584175	0.00868898
+0.18374	0.238016	0.00546703	0.00866381
+0.189736	0.203079	0.00520056	0.00894656
+0.195698	0.171069	0.00495042	0.00899438
+0.201668	0.153949	0.00475784	0.0092688
+0.207677	0.131067	0.00454288	0.00954494
+0.213601	0.118889	0.00446381	0.00981725
+0.219565	0.110022	0.00427412	0.0100913
+0.225593	0.10747	0.00424177	0.0103684
+0.231541	0.100865	0.00417778	0.0106418
+0.237547	0.093447	0.00402577	0.0107734
+0.243603	0.0937223	0.00400622	0.0108222
+0.249624	0.0948064	0.00399285	0.0110897
+0.255615	0.0949532	0.00397902	0.0111138
+0.26162	0.0915976	0.00390164	0.0113749
+0.267619	0.0927151	0.00391519	0.0116357
+0.27357	0.0966561	0.00392083	0.0118944
+0.279514	0.0896038	0.00382976	0.0121528
+0.285494	0.0909465	0.00379672	0.0124129
+0.291495	0.090641	0.00376077	0.0126738
+0.297457	0.0845533	0.00370577	0.012933
+0.303394	0.0834418	0.00366612	0.0131911
+0.309405	0.0815794	0.00358735	0.0134525
+0.315461	0.086537	0.00360475	0.0137158
+0.321501	0.0814197	0.00354806	0.0139784
+0.32749	0.0811975	0.00354551	0.0142388
+0.333458	0.0788328	0.0035047	0.0144983
+0.339368	0.0757621	0.00352639	0.0146465
+0.345351	0.0783668	0.00365607	0.0149047
+0.351315	0.074696	0.00367733	0.0151621
+0.357265	0.0746856	0.00376074	0.0154189
+0.363299	0.0723696	0.00397781	0.015444
+0.369344	0.077648	0.00413299	0.015701
+0.375347	0.0715659	0.00424208	0.0159562
+0.381274	0.0715309	0.00430186	0.0159573
+0.387269	0.0752993	0.00438052	0.0162082
+0.393257	0.0707649	0.00435293	0.0164588
+0.399251	0.0695322	0.00433681	0.0167097
+0.405282	0.0735785	0.00439895	0.0169621
+0.411261	0.0783315	0.00450466	0.0172124
+0.417164	0.0625388	0.00439646	0.0174594
+0.423179	0.0749592	0.00443032	0.0177111
+0.429234	0.0774125	0.0045065	0.0179645
+0.435236	0.0671526	0.00443888	0.0182158
+0.441167	0.0664527	0.0044592	0.018464
+0.447074	0.0670769	0.0044726	0.0187112
+0.453098	0.067893	0.00436489	0.0189633
+0.459189	0.0706633	0.00447217	0.0192182
+0.465129	0.072765	0.00456344	0.019312
+0.471073	0.0676428	0.00447517	0.0195588
+0.477118	0.0679994	0.0043968	0.0198098
+0.483165	0.0744563	0.00455855	0.0200609
+0.489079	0.0696971	0.00455032	0.0203064
+0.495076	0.0666634	0.00441788	0.0205555
+0.50109	0.0650749	0.00446766	0.0208051
+0.507012	0.0716745	0.00456643	0.021051
+0.513065	0.0612866	0.00433361	0.0213024
+0.519078	0.0751487	0.0046292	0.021552
+0.52495	0.0708117	0.00459551	0.0217958
+0.53097	0.0665376	0.00439133	0.0220457
+0.536987	0.0647267	0.00448903	0.0222956
+0.54287	0.0680348	0.0045584	0.0225398
+0.54886	0.0682137	0.00516347	0.0227885
+0.554866	0.0600309	0.00549151	0.0230379
+0.560915	0.0708694	0.00609187	0.023289
+0.566896	0.0802486	0.00686271	0.0235374
+0.572844	0.0586832	0.00697213	0.0237843
+0.578801	0.0556705	0.00770313	0.0240317
+0.584749	0.0647072	0.00866416	0.0242786
+0.590751	0.0690938	0.0100902	0.0245279
+0.596726	0.0968634	0.0126976	0.0247759
+0.602559	0.0547113	0.0150671	0.0250181
+0.608118	0.0874406	0.0258455	0.0252489
+0.612818	0.0787903	0.0650848	0.025444
Index: example/093192_202.dat
===================================================================
--- example/093192_202.dat	(revision 93d0ea782dc75cafd87251f5b4cd8bac876628ef)
+++ example/093192_202.dat	(revision 93d0ea782dc75cafd87251f5b4cd8bac876628ef)
@@ -0,0 +1,137 @@
+GRASP V.7.11CD    Instrument:  ILL_d22 
+  
+***** Sample, Backgrounds and Transmissions Data: ***** 
+Subtitle:  CM 10% SDS  
+Start: 01-Sep-16   12:23:18   End: 01-Sep-16   12:23:23 
+  
+Foreground:  93192 , Loaded: 92991:93230 
+Background:  91098 , Loaded: 91098 
+Cadmium:  90990 , Loaded: 90990 
+Det: 1 : Applying Deadtime Correction per (vertical) Tube: 1/[1-tau/detector_rate], tau = 1e-06 (seconds) 
+Data Normalisation: Standard Monitor (10000000) counts 
+Attenuator: 0 is In.  Attenuation factor 1 
+Attenuator: 0 is In. Up-scaling data by 1 
+Attenuator2: is Out 
+Attenuator2: Up-scaling data by 1 
+  
+Beam Centre1 :  Cx = 27.1492  Cy = 127.3257       Cm Translation :  Tx = 0  Ty = 0 [mm] 
+Transmissions:  Ts = 0.95963 +/- 0.010298  Te = 1 +/- 0.0013531 
+Transmissions Thickness Correction is:  on 
+Applying standard SANS data reduction:  I_corr = 1/[Ts Te] [I_s - I_cd]  - 1/[Te] [I_bck - I_cd] 
+  
+***** Calibrations: ***** 
+Data: Corrected for D22 Detector Paralax 
+Data: Corrected for Detector Efficiency (doesn't change magnitude but contains curvature correction) 
+Data: Divided by Volume 0.025 cm3 
+Solid Angle Correction: 
+Divide data by empty beam flux, I0, from worksheet: I0 Beam Intensity 1 203 
+Applying Default Instrument Mask 
+Applying User Defined Mask 
+Applying NanInf Mask 
+Intensity units are:  cm-1 \\ \Delta\Omega  
+  
+***** Analysis ***** 
+Averaging I vs. Q.  Bin size:  1 [Pixel(s)] 
+ 
+ 
+Mod_Q   	I       	Err_I   	Sigma_Q
+
+ 
+ 
+0.0399306	0.484524	0.0271684	0.00471442
+0.0461801	0.594996	0.0178507	0.00480794
+0.0519658	0.730496	0.0156366	0.00490303
+0.0578791	1.00187	0.0154585	0.00500984
+0.0639094	1.35416	0.0169834	0.00512844
+0.0698138	1.91442	0.0192206	0.00525617
+0.0757907	2.68891	0.0213667	0.00539353
+0.0818611	3.45548	0.0232154	0.00553989
+0.0878521	3.85579	0.0239084	0.00569104
+0.0937984	3.69584	0.022639	0.00584668
+0.0997329	3.12137	0.0202279	0.00603593
+0.105788	2.46918	0.0171693	0.00623212
+0.111814	1.90968	0.0150973	0.00640109
+0.117765	1.50895	0.0130624	0.00662702
+0.123807	1.2042	0.011413	0.00668684
+0.129841	1.0052	0.0103669	0.00680967
+0.135846	0.84513	0.00935813	0.00712461
+0.141859	0.745097	0.00870867	0.00743994
+0.14784	0.619771	0.0079119	0.00755558
+0.153823	0.545628	0.00735026	0.0076497
+0.159753	0.469773	0.00690822	0.00780975
+0.165751	0.39789	0.00663573	0.00810292
+0.171732	0.344666	0.00625624	0.00839535
+0.177739	0.289757	0.00589957	0.00868898
+0.18374	0.243658	0.0055577	0.00866381
+0.189736	0.204502	0.00525853	0.00894656
+0.195698	0.177732	0.00504693	0.00899438
+0.201668	0.161376	0.00485917	0.0092688
+0.207677	0.140901	0.00466235	0.00954494
+0.213601	0.116779	0.00448765	0.00981725
+0.219565	0.108012	0.00429575	0.0100913
+0.225593	0.105651	0.00426709	0.0103684
+0.231541	0.108815	0.00428088	0.0106418
+0.237547	0.104933	0.00415698	0.0107734
+0.243603	0.10269	0.0041176	0.0108222
+0.249624	0.0983913	0.00405778	0.0110897
+0.255615	0.0926162	0.00399698	0.0111138
+0.26162	0.0942346	0.00395998	0.0113749
+0.267619	0.0986561	0.00399839	0.0116357
+0.27357	0.0974708	0.00396438	0.0118944
+0.279514	0.0957027	0.00391356	0.0121528
+0.285494	0.0970072	0.00387898	0.0124129
+0.291495	0.092289	0.00380932	0.0126738
+0.297457	0.0898679	0.00378133	0.012933
+0.303394	0.0882783	0.00373755	0.0131911
+0.309405	0.0922752	0.00370292	0.0134525
+0.315461	0.0869441	0.00364175	0.0137158
+0.321501	0.0867414	0.00362166	0.0139784
+0.32749	0.0807703	0.00357567	0.0142388
+0.333458	0.0823189	0.00356429	0.0144983
+0.339368	0.0859734	0.00363776	0.0146465
+0.345351	0.0829471	0.00372685	0.0149047
+0.351315	0.0796431	0.00375202	0.0151621
+0.357265	0.0792661	0.0038347	0.0154189
+0.363299	0.0804573	0.00408503	0.015444
+0.369344	0.0831659	0.00422201	0.015701
+0.375347	0.083887	0.00440021	0.0159562
+0.381274	0.0890297	0.00450772	0.0159573
+0.387269	0.0795644	0.00446113	0.0162082
+0.393257	0.0778211	0.00446221	0.0164588
+0.399251	0.078519	0.00446464	0.0167097
+0.405282	0.0767774	0.00447109	0.0169621
+0.411261	0.0845619	0.0046061	0.0172124
+0.417164	0.0749804	0.00456088	0.0174594
+0.423179	0.0762522	0.0044868	0.0177111
+0.429234	0.0765675	0.0045413	0.0179645
+0.435236	0.0765194	0.00457536	0.0182158
+0.441167	0.0817731	0.00466033	0.018464
+0.447074	0.076038	0.00460756	0.0187112
+0.453098	0.0777802	0.00450266	0.0189633
+0.459189	0.0683179	0.0044881	0.0192182
+0.465129	0.0662169	0.00453781	0.019312
+0.471073	0.076984	0.00461281	0.0195588
+0.477118	0.0748958	0.00450974	0.0198098
+0.483165	0.0740049	0.00459912	0.0200609
+0.489079	0.0787219	0.00468859	0.0203064
+0.495076	0.0728938	0.00452338	0.0205555
+0.50109	0.0715359	0.00457776	0.0208051
+0.507012	0.0732779	0.00462998	0.021051
+0.513065	0.0748961	0.00451626	0.0213024
+0.519078	0.074125	0.00466235	0.021552
+0.52495	0.0761913	0.00469557	0.0217958
+0.53097	0.0716355	0.0044864	0.0220457
+0.536987	0.0636286	0.00452076	0.0222956
+0.54287	0.0717819	0.00464118	0.0225398
+0.54886	0.0683446	0.00521545	0.0227885
+0.554866	0.0775007	0.0057825	0.0230379
+0.560915	0.0815907	0.00630456	0.023289
+0.566896	0.0698167	0.00676361	0.0235374
+0.572844	0.0725108	0.0072808	0.0237843
+0.578801	0.0840276	0.00832073	0.0240317
+0.584749	0.07777	0.00901832	0.0242786
+0.590751	0.0675557	0.0101481	0.0245279
+0.596726	0.0813093	0.01239	0.0247759
+0.602559	0.0988252	0.0168487	0.0250181
+0.608118	0.078733	0.0256719	0.0252489
+0.612818	0.160083	0.0767117	0.025444
Index: example/093193_203.dat
===================================================================
--- example/093193_203.dat	(revision 93d0ea782dc75cafd87251f5b4cd8bac876628ef)
+++ example/093193_203.dat	(revision 93d0ea782dc75cafd87251f5b4cd8bac876628ef)
@@ -0,0 +1,137 @@
+GRASP V.7.11CD    Instrument:  ILL_d22 
+  
+***** Sample, Backgrounds and Transmissions Data: ***** 
+Subtitle:  CM 10% SDS  
+Start: 01-Sep-16   12:23:24   End: 01-Sep-16   12:23:29 
+  
+Foreground:  93193 , Loaded: 92991:93230 
+Background:  91098 , Loaded: 91098 
+Cadmium:  90990 , Loaded: 90990 
+Det: 1 : Applying Deadtime Correction per (vertical) Tube: 1/[1-tau/detector_rate], tau = 1e-06 (seconds) 
+Data Normalisation: Standard Monitor (10000000) counts 
+Attenuator: 0 is In.  Attenuation factor 1 
+Attenuator: 0 is In. Up-scaling data by 1 
+Attenuator2: is Out 
+Attenuator2: Up-scaling data by 1 
+  
+Beam Centre1 :  Cx = 27.1492  Cy = 127.3257       Cm Translation :  Tx = 0  Ty = 0 [mm] 
+Transmissions:  Ts = 0.95103 +/- 0.010242  Te = 1 +/- 0.0013531 
+Transmissions Thickness Correction is:  on 
+Applying standard SANS data reduction:  I_corr = 1/[Ts Te] [I_s - I_cd]  - 1/[Te] [I_bck - I_cd] 
+  
+***** Calibrations: ***** 
+Data: Corrected for D22 Detector Paralax 
+Data: Corrected for Detector Efficiency (doesn't change magnitude but contains curvature correction) 
+Data: Divided by Volume 0.025 cm3 
+Solid Angle Correction: 
+Divide data by empty beam flux, I0, from worksheet: I0 Beam Intensity 1 204 
+Applying Default Instrument Mask 
+Applying User Defined Mask 
+Applying NanInf Mask 
+Intensity units are:  cm-1 \\ \Delta\Omega  
+  
+***** Analysis ***** 
+Averaging I vs. Q.  Bin size:  1 [Pixel(s)] 
+ 
+ 
+Mod_Q   	I       	Err_I   	Sigma_Q
+
+ 
+ 
+0.0399306	0.495938	0.0275034	0.00471442
+0.0461801	0.601823	0.0179981	0.00480794
+0.0519658	0.724525	0.0156418	0.00490303
+0.0578791	0.980613	0.0153714	0.00500984
+0.0639094	1.38067	0.0171931	0.00512844
+0.0698138	1.89566	0.0191999	0.00525617
+0.0757907	2.69453	0.0214643	0.00539353
+0.0818611	3.42839	0.023208	0.00553989
+0.0878521	3.81292	0.0238587	0.00569104
+0.0937984	3.69338	0.0227111	0.00584668
+0.0997329	3.10662	0.0202519	0.00603593
+0.105788	2.4271	0.0170886	0.00623212
+0.111814	1.87299	0.0150134	0.00640109
+0.117765	1.5083	0.0131054	0.00662702
+0.123807	1.21221	0.011489	0.00668684
+0.129841	0.991507	0.0103408	0.00680967
+0.135846	0.860723	0.00946518	0.00712461
+0.141859	0.733918	0.00868659	0.00743994
+0.14784	0.629451	0.00799138	0.00755558
+0.153823	0.544322	0.00736919	0.0076497
+0.159753	0.463544	0.00689812	0.00780975
+0.165751	0.413464	0.00675448	0.00810292
+0.171732	0.338734	0.00624157	0.00839535
+0.177739	0.285851	0.0058941	0.00868898
+0.18374	0.243791	0.00557873	0.00866381
+0.189736	0.220321	0.00539338	0.00894656
+0.195698	0.18442	0.00511573	0.00899438
+0.201668	0.155093	0.00482891	0.0092688
+0.207677	0.1391	0.00466528	0.00954494
+0.213601	0.128787	0.00460373	0.00981725
+0.219565	0.11741	0.00438863	0.0100913
+0.225593	0.115272	0.00436179	0.0103684
+0.231541	0.105303	0.00426966	0.0106418
+0.237547	0.106812	0.00418721	0.0107734
+0.243603	0.0982932	0.00409581	0.0108222
+0.249624	0.102512	0.00410734	0.0110897
+0.255615	0.0961243	0.00404035	0.0111138
+0.26162	0.0980531	0.00400386	0.0113749
+0.267619	0.102665	0.00404536	0.0116357
+0.27357	0.0967108	0.0039728	0.0118944
+0.279514	0.102396	0.00398178	0.0121528
+0.285494	0.0972778	0.00389677	0.0124129
+0.291495	0.0898605	0.00380484	0.0126738
+0.297457	0.0935951	0.00382522	0.012933
+0.303394	0.0924456	0.00378427	0.0131911
+0.309405	0.0972294	0.00375406	0.0134525
+0.315461	0.0952473	0.00371873	0.0137158
+0.321501	0.096294	0.00370852	0.0139784
+0.32749	0.0896537	0.00365717	0.0142388
+0.333458	0.0860209	0.00360525	0.0144983
+0.339368	0.0773078	0.00358456	0.0146465
+0.345351	0.0822065	0.00373419	0.0149047
+0.351315	0.0857103	0.00381483	0.0151621
+0.357265	0.0868788	0.00391161	0.0154189
+0.363299	0.0816303	0.00411025	0.015444
+0.369344	0.0819393	0.00422615	0.015701
+0.375347	0.0764023	0.00434456	0.0159562
+0.381274	0.0811661	0.00445112	0.0159573
+0.387269	0.0821627	0.00450403	0.0162082
+0.393257	0.075463	0.00445474	0.0164588
+0.399251	0.0817594	0.00450946	0.0167097
+0.405282	0.0854387	0.00457192	0.0169621
+0.411261	0.07179	0.00450057	0.0172124
+0.417164	0.0804081	0.0046335	0.0174594
+0.423179	0.0885202	0.00462155	0.0177111
+0.429234	0.0728288	0.00452054	0.0179645
+0.435236	0.0814508	0.00463972	0.0182158
+0.441167	0.0796521	0.00465222	0.018464
+0.447074	0.0790708	0.00465467	0.0187112
+0.453098	0.071086	0.0044525	0.0189633
+0.459189	0.0752127	0.0045771	0.0192182
+0.465129	0.0706262	0.0046021	0.019312
+0.471073	0.0769092	0.00463158	0.0195588
+0.477118	0.0835313	0.00461136	0.0198098
+0.483165	0.0796931	0.00467501	0.0200609
+0.489079	0.0715977	0.00463389	0.0203064
+0.495076	0.0812292	0.00462664	0.0205555
+0.50109	0.0837694	0.00472155	0.0208051
+0.507012	0.0779764	0.00469672	0.021051
+0.513065	0.0723371	0.00450816	0.0213024
+0.519078	0.0745829	0.0046842	0.021552
+0.52495	0.0743663	0.00469591	0.0217958
+0.53097	0.074376	0.00452946	0.0220457
+0.536987	0.0650931	0.00455474	0.0222956
+0.54287	0.0786313	0.00473417	0.0225398
+0.54886	0.0751977	0.00532033	0.0227885
+0.554866	0.0662734	0.00564964	0.0230379
+0.560915	0.0812682	0.00632581	0.023289
+0.566896	0.0710208	0.0068095	0.0235374
+0.572844	0.0728956	0.00731545	0.0237843
+0.578801	0.0737664	0.00816212	0.0240317
+0.584749	0.0633562	0.0087569	0.0242786
+0.590751	0.0879515	0.0106728	0.0245279
+0.596726	0.0708406	0.012151	0.0247759
+0.602559	0.0477549	0.0149817	0.0250181
+0.608118	0.101107	0.0270189	0.0252489
+0.612818	0.0467677	0.0611547	0.025444
Index: example/093194_204.dat
===================================================================
--- example/093194_204.dat	(revision 93d0ea782dc75cafd87251f5b4cd8bac876628ef)
+++ example/093194_204.dat	(revision 93d0ea782dc75cafd87251f5b4cd8bac876628ef)
@@ -0,0 +1,137 @@
+GRASP V.7.11CD    Instrument:  ILL_d22 
+  
+***** Sample, Backgrounds and Transmissions Data: ***** 
+Subtitle:  CM 10% SDS  
+Start: 01-Sep-16   12:23:29   End: 01-Sep-16   12:23:34 
+  
+Foreground:  93194 , Loaded: 92991:93230 
+Background:  91098 , Loaded: 91098 
+Cadmium:  90990 , Loaded: 90990 
+Det: 1 : Applying Deadtime Correction per (vertical) Tube: 1/[1-tau/detector_rate], tau = 1e-06 (seconds) 
+Data Normalisation: Standard Monitor (10000000) counts 
+Attenuator: 0 is In.  Attenuation factor 1 
+Attenuator: 0 is In. Up-scaling data by 1 
+Attenuator2: is Out 
+Attenuator2: Up-scaling data by 1 
+  
+Beam Centre1 :  Cx = 27.1492  Cy = 127.3257       Cm Translation :  Tx = 0  Ty = 0 [mm] 
+Transmissions:  Ts = 0.96022 +/- 0.010227  Te = 1 +/- 0.0013531 
+Transmissions Thickness Correction is:  on 
+Applying standard SANS data reduction:  I_corr = 1/[Ts Te] [I_s - I_cd]  - 1/[Te] [I_bck - I_cd] 
+  
+***** Calibrations: ***** 
+Data: Corrected for D22 Detector Paralax 
+Data: Corrected for Detector Efficiency (doesn't change magnitude but contains curvature correction) 
+Data: Divided by Volume 0.025 cm3 
+Solid Angle Correction: 
+Divide data by empty beam flux, I0, from worksheet: I0 Beam Intensity 1 205 
+Applying Default Instrument Mask 
+Applying User Defined Mask 
+Applying NanInf Mask 
+Intensity units are:  cm-1 \\ \Delta\Omega  
+  
+***** Analysis ***** 
+Averaging I vs. Q.  Bin size:  1 [Pixel(s)] 
+ 
+ 
+Mod_Q   	I       	Err_I   	Sigma_Q
+
+ 
+ 
+0.0399175	0.471058	0.0266748	0.00471288
+0.046165	0.576589	0.0174928	0.00480637
+0.0519488	0.71904	0.0154209	0.00490143
+0.0578602	0.927986	0.0148414	0.0050082
+0.0638884	1.32896	0.0167105	0.00512676
+0.0697909	1.8431	0.0187387	0.00525444
+0.0757659	2.58508	0.0208064	0.00539176
+0.0818342	3.32141	0.022596	0.00553808
+0.0878233	3.68322	0.0231948	0.00568917
+0.0937677	3.53375	0.0219737	0.00584476
+0.0997002	3.0083	0.0197174	0.00603395
+0.105754	2.37782	0.0167331	0.00623008
+0.111778	1.84213	0.0147327	0.00639899
+0.117726	1.45092	0.012731	0.00662485
+0.123767	1.14484	0.0110731	0.00668465
+0.129799	0.951807	0.0100444	0.00680744
+0.135802	0.819769	0.00916691	0.00712228
+0.141812	0.704706	0.00844574	0.0074375
+0.147792	0.599611	0.00774907	0.00755311
+0.153773	0.521806	0.00716789	0.00764719
+0.159701	0.452553	0.00675946	0.00780719
+0.165696	0.390936	0.00654406	0.00810027
+0.171676	0.328922	0.00610994	0.0083926
+0.177681	0.294845	0.00588789	0.00868613
+0.183679	0.23574	0.00545964	0.00866097
+0.189674	0.208864	0.00525115	0.00894363
+0.195633	0.173635	0.00497907	0.00899143
+0.201602	0.155039	0.00477409	0.00926576
+0.207609	0.140246	0.00462245	0.00954182
+0.213531	0.119084	0.00447232	0.00981403
+0.219493	0.11173	0.00429336	0.010088
+0.225519	0.104093	0.00422193	0.010365
+0.231466	0.100481	0.00418214	0.0106383
+0.237469	0.0986928	0.00407487	0.0107699
+0.243524	0.0942099	0.00401796	0.0108187
+0.249542	0.101311	0.00405086	0.0110861
+0.255532	0.0991859	0.00401921	0.0111101
+0.261534	0.0956783	0.00394138	0.0113711
+0.267531	0.0946782	0.00393705	0.0116319
+0.27348	0.0906428	0.00388121	0.0118905
+0.279422	0.0939746	0.00387148	0.0121489
+0.285401	0.0961223	0.00384262	0.0124088
+0.2914	0.0944448	0.00379616	0.0126696
+0.29736	0.0962848	0.00380263	0.0129288
+0.303295	0.0940587	0.00375432	0.0131868
+0.309303	0.0903236	0.00365978	0.0134481
+0.315358	0.0870279	0.00361541	0.0137113
+0.321395	0.0900569	0.00362022	0.0139738
+0.327382	0.0874209	0.00359856	0.0142341
+0.333349	0.0828309	0.00354106	0.0144935
+0.339256	0.0847999	0.00360403	0.0146417
+0.345238	0.084163	0.00370823	0.0148999
+0.351199	0.0815621	0.0037399	0.0151572
+0.357148	0.0794801	0.00380682	0.0154139
+0.36318	0.0785705	0.00403853	0.0154389
+0.369223	0.0791844	0.00415378	0.0156958
+0.375224	0.078256	0.00431415	0.0159509
+0.381149	0.0772376	0.00436409	0.0159521
+0.387142	0.081226	0.00444308	0.0162029
+0.393128	0.0836948	0.00448589	0.0164534
+0.39912	0.0815196	0.00446108	0.0167042
+0.405149	0.0735893	0.00440571	0.0169566
+0.411127	0.0793413	0.00452438	0.0172067
+0.417027	0.0748747	0.00452475	0.0174537
+0.42304	0.0685565	0.00437642	0.0177053
+0.429093	0.0755925	0.00449926	0.0179587
+0.435094	0.0736297	0.00450945	0.0182098
+0.441023	0.0786116	0.00459063	0.0184579
+0.446927	0.0837909	0.00464979	0.0187051
+0.452949	0.0755838	0.00444829	0.0189571
+0.459038	0.0808321	0.00458164	0.0192119
+0.464976	0.0742662	0.00458748	0.0193057
+0.470918	0.0703225	0.00451224	0.0195524
+0.476961	0.076295	0.00448762	0.0198033
+0.483007	0.0718289	0.00454376	0.0200543
+0.488918	0.0758532	0.00462283	0.0202998
+0.494914	0.0783118	0.0045446	0.0205487
+0.500925	0.0691467	0.00451832	0.0207983
+0.506846	0.0769886	0.00463229	0.0210441
+0.512897	0.0821134	0.00455466	0.0212954
+0.518908	0.0719557	0.00460379	0.0215449
+0.524778	0.0687123	0.0045819	0.0217887
+0.530796	0.0708023	0.00444184	0.0220385
+0.536811	0.074286	0.00460118	0.0222883
+0.542692	0.0726345	0.00461701	0.0225325
+0.54868	0.0705264	0.00520306	0.0227811
+0.554685	0.0734241	0.00568432	0.0230304
+0.560731	0.0621278	0.00597761	0.0232814
+0.56671	0.0739735	0.00677612	0.0235297
+0.572656	0.0782782	0.00732562	0.0237765
+0.578611	0.0679018	0.0079548	0.0240238
+0.584557	0.0693557	0.00878294	0.0242707
+0.590558	0.0742426	0.0102329	0.0245198
+0.59653	0.0734785	0.012085	0.0247678
+0.602361	0.0736304	0.0158355	0.0250099
+0.607919	0.0949249	0.0263514	0.0252407
+0.612617	0.155113	0.0754692	0.0254357
Index: example/093195_205.dat
===================================================================
--- example/093195_205.dat	(revision 93d0ea782dc75cafd87251f5b4cd8bac876628ef)
+++ example/093195_205.dat	(revision 93d0ea782dc75cafd87251f5b4cd8bac876628ef)
@@ -0,0 +1,137 @@
+GRASP V.7.11CD    Instrument:  ILL_d22 
+  
+***** Sample, Backgrounds and Transmissions Data: ***** 
+Subtitle:  CM 10% SDS  
+Start: 01-Sep-16   12:23:34   End: 01-Sep-16   12:23:39 
+  
+Foreground:  93195 , Loaded: 92991:93230 
+Background:  91098 , Loaded: 91098 
+Cadmium:  90990 , Loaded: 90990 
+Det: 1 : Applying Deadtime Correction per (vertical) Tube: 1/[1-tau/detector_rate], tau = 1e-06 (seconds) 
+Data Normalisation: Standard Monitor (10000000) counts 
+Attenuator: 0 is In.  Attenuation factor 1 
+Attenuator: 0 is In. Up-scaling data by 1 
+Attenuator2: is Out 
+Attenuator2: Up-scaling data by 1 
+  
+Beam Centre1 :  Cx = 27.1492  Cy = 127.3257       Cm Translation :  Tx = 0  Ty = 0 [mm] 
+Transmissions:  Ts = 0.96543 +/- 0.010298  Te = 1 +/- 0.0013531 
+Transmissions Thickness Correction is:  on 
+Applying standard SANS data reduction:  I_corr = 1/[Ts Te] [I_s - I_cd]  - 1/[Te] [I_bck - I_cd] 
+  
+***** Calibrations: ***** 
+Data: Corrected for D22 Detector Paralax 
+Data: Corrected for Detector Efficiency (doesn't change magnitude but contains curvature correction) 
+Data: Divided by Volume 0.025 cm3 
+Solid Angle Correction: 
+Divide data by empty beam flux, I0, from worksheet: I0 Beam Intensity 1 206 
+Applying Default Instrument Mask 
+Applying User Defined Mask 
+Applying NanInf Mask 
+Intensity units are:  cm-1 \\ \Delta\Omega  
+  
+***** Analysis ***** 
+Averaging I vs. Q.  Bin size:  1 [Pixel(s)] 
+ 
+ 
+Mod_Q   	I       	Err_I   	Sigma_Q
+
+ 
+ 
+0.0399175	0.454685	0.0263803	0.00471288
+0.046165	0.54033	0.0170784	0.00480637
+0.0519488	0.686058	0.0151455	0.00490143
+0.0578602	0.956229	0.0150577	0.0050082
+0.0638884	1.28432	0.0164806	0.00512676
+0.0697909	1.83596	0.0187358	0.00525444
+0.0757659	2.59976	0.0208935	0.00539176
+0.0818342	3.32344	0.0226376	0.00553808
+0.0878233	3.70728	0.0233043	0.00568917
+0.0937677	3.52462	0.0219777	0.00584476
+0.0997002	3.01737	0.0197748	0.00603395
+0.105754	2.3606	0.0166997	0.00623008
+0.111778	1.83617	0.0147322	0.00639899
+0.117726	1.44657	0.0127324	0.00662485
+0.123767	1.17843	0.0112351	0.00668465
+0.129799	0.971195	0.0101489	0.00680744
+0.135802	0.808751	0.00912863	0.00712228
+0.141812	0.695295	0.00841192	0.0074375
+0.147792	0.611707	0.00782318	0.00755311
+0.153773	0.514606	0.00713969	0.00764719
+0.159701	0.455647	0.00678823	0.00780719
+0.165696	0.390866	0.00655396	0.00810027
+0.171676	0.337981	0.00617689	0.0083926
+0.177681	0.283662	0.0058224	0.00868613
+0.183679	0.239591	0.00549489	0.00866097
+0.189674	0.211676	0.00527928	0.00894363
+0.195633	0.177007	0.00501071	0.00899143
+0.201602	0.161051	0.00482808	0.00926576
+0.207609	0.143571	0.00465575	0.00954182
+0.213531	0.125864	0.00453518	0.00981403
+0.219493	0.116092	0.00433525	0.010088
+0.225519	0.109724	0.00427441	0.010365
+0.231466	0.108851	0.00425662	0.0106383
+0.237469	0.101727	0.00410579	0.0107699
+0.243524	0.102131	0.00408791	0.0108187
+0.249542	0.0997446	0.0040449	0.0110861
+0.255532	0.0927389	0.0039732	0.0111101
+0.261534	0.103002	0.00400466	0.0113711
+0.267531	0.10003	0.00398518	0.0116319
+0.27348	0.100144	0.00396155	0.0118905
+0.279422	0.0995745	0.00392113	0.0121489
+0.285401	0.0928955	0.00382341	0.0124088
+0.2914	0.0872261	0.0037467	0.0126696
+0.29736	0.09212	0.00377657	0.0129288
+0.303295	0.0911748	0.00373771	0.0131868
+0.309303	0.0905502	0.00366701	0.0134481
+0.315358	0.0929903	0.00366412	0.0137113
+0.321395	0.0879994	0.00361011	0.0139738
+0.327382	0.0886275	0.0036135	0.0142341
+0.333349	0.0867201	0.00357475	0.0144935
+0.339256	0.0869623	0.0036239	0.0146417
+0.345238	0.0879116	0.00374222	0.0148999
+0.351199	0.0778909	0.00371481	0.0151572
+0.357148	0.0813806	0.00382721	0.0154139
+0.36318	0.0870579	0.0041159	0.0154389
+0.369223	0.0760877	0.00413387	0.0156958
+0.375224	0.0829192	0.00436183	0.0159509
+0.381149	0.0791121	0.00438626	0.0159521
+0.387142	0.0790671	0.00442998	0.0162029
+0.393128	0.0785376	0.00444171	0.0164534
+0.39912	0.0778773	0.00443032	0.0167042
+0.405149	0.076962	0.00444453	0.0169566
+0.411127	0.0788684	0.0045264	0.0172067
+0.417027	0.074275	0.00452624	0.0174537
+0.42304	0.0690467	0.00438781	0.0177053
+0.429093	0.0790999	0.00453941	0.0179587
+0.435094	0.0736514	0.00451706	0.0182098
+0.441023	0.0793386	0.00460714	0.0184579
+0.446927	0.0753389	0.00457345	0.0187051
+0.452949	0.0788231	0.00448784	0.0189571
+0.459038	0.0776624	0.00455368	0.0192119
+0.464976	0.0724525	0.0045734	0.0193057
+0.470918	0.073843	0.00455383	0.0195524
+0.476961	0.0777559	0.00450935	0.0198033
+0.483007	0.0687115	0.00451409	0.0200543
+0.488918	0.0712384	0.0045823	0.0202998
+0.494914	0.0735856	0.00450228	0.0205487
+0.500925	0.0720495	0.00455525	0.0207983
+0.506846	0.0705638	0.00457418	0.0210441
+0.512897	0.0779725	0.0045197	0.0212954
+0.518908	0.069571	0.0045849	0.0215449
+0.524778	0.0796979	0.00470227	0.0217887
+0.530796	0.0716872	0.00445713	0.0220385
+0.536811	0.0697334	0.00455695	0.0222883
+0.542692	0.0831477	0.00473303	0.0225325
+0.54868	0.0688021	0.00518882	0.0227811
+0.554685	0.0679115	0.00561555	0.0230304
+0.560731	0.079065	0.00623042	0.0232814
+0.56671	0.0741232	0.00678759	0.0235297
+0.572656	0.073377	0.00725125	0.0237765
+0.578611	0.0700584	0.008008	0.0240238
+0.584557	0.0777813	0.00895742	0.0242707
+0.590558	0.0803857	0.010397	0.0245198
+0.59653	0.0913776	0.0125859	0.0247678
+0.602361	0.0646907	0.0155185	0.0250099
+0.607919	0.0612197	0.0244838	0.0252407
+0.612617	0.00502697	0.0536103	0.0254357
Index: example/batch_fit.py
===================================================================
--- example/batch_fit.py	(revision 8a5f0216970a47f3e897a508054840132bd87909)
+++ example/batch_fit.py	(revision 8a5f0216970a47f3e897a508054840132bd87909)
@@ -0,0 +1,140 @@
+#!/usr/bin/env python
+"""
+Script to run a batch fit in a series of files and plot the fitted parameters.
+
+Usage syntax::
+
+    python batch_fit.py model.py sample1.dat sample2.dat ... other_sample.dat
+    (files named sample1.dat, sample2.dat, ..., other_sample.dat)
+
+or if the file names are numbers (and the extension is .dat)::
+
+    python batch_fit.py model.py 93190 93210
+    (files named 093190.dat, 093191.dat, ..., 093210.dat)
+
+or for Grasp-like naming::
+
+    python batch_fit.py model.py 93190 93210 200
+    (files named 093190_200.dat, 093191_201.dat, ..., 093210_220.dat)
+
+The script reads a series of files and fits the model defined by model.py.
+For example model_ellipsoid_hayter_msa.py fits a model consisting in an
+ellipsoid form factor multiplied by a Hayter MSA structure factor.
+
+The file *model.py* must load the data using::
+
+    data = load_data(sys.argv[1])
+
+Include options to bumps (minimizer, steps, etc.) as desired.  For example::
+
+    python batch_fit.py model.py 93190 93210 200 --fit=lm --steps=200 --ftol=1.5e-8 --xtol=1.5e-8
+
+Fit options can come before or after the model and files.
+
+For each file a directory named Fit_filename is created. There the file
+model.par contains the fitted parameters.  These are gathered together into
+batch_fit.csv in the current directory.
+
+Finally the fitted parameters are plotted for the full series.
+
+Example::
+
+    python batch_fit.py model_ellipsoid_hayter_msa.py 93191 93195 201
+
+Note:
+
+    If sasmodels, sasview or bumps are not in the path, use the PYTHONPATH
+    environment variable to set them.
+"""
+from __future__ import print_function
+
+import sys
+import os
+
+import numpy as np
+import matplotlib.pyplot as plt
+from bumps.dream.views import tile_axes  # make a grid of plots
+
+# GET INPUT AND ENSURE MODEL AND DATA FILES ARE DEFINED
+
+fit_opts = [v for v in sys.argv[1:] if v.startswith('--')]
+args = [v for v in sys.argv[1:] if not v.startswith('--')]
+
+nargs = len(args)
+if nargs < 2:
+    print ("Error in the list of arguments! \n")
+    sys.exit()
+
+model_file = args[0]
+if not model_file.endswith('.py'):
+    print("Expected model.py as the first argument")
+    sys.exit(1)
+
+if '.' in args[1]:
+    data_files = args[1:]
+else:
+    first = int(args[1])
+    last = int(args[2])
+    count = last-first+1
+    data_files = []
+    if nargs == 3:
+        data_files = ['%06d.dat'%(first+i) for i in range(count)]
+    elif nargs == 4:
+        ext = int(args[3])
+        data_files = ['%06d_%d.dat'%(first+i, ext+i) for i in range(count)]
+    else:
+        print("Unexpected arguments: " + " ".join(args[4:]))
+        sys.exit(1)
+
+# CHECK THAT DATA FILES EXIST
+missing = [filename for filename in data_files if not os.path.isfile(filename)]
+if missing:
+    print("Missing data files: %s" % ", ".join(missing))
+    sys.exit(1)
+
+# STORE DIRECTORY FOR BUMPS FITS
+def fit_dir(filename):
+    "Return the store directory name for the given file"
+    return "Fit_" + os.path.splitext(filename)[0]
+
+# LOOP OVER FILES AND CALL TO BUMPS FOR EACH OF THEM
+bumps_cmd = "python -m bumps.cli --batch"
+fit_opts = " ".join(fit_opts)
+for data_file in data_files:
+    store_opts = "--store=" + fit_dir(data_file)
+    cmd = " ".join((bumps_cmd, fit_opts, store_opts, model_file, data_file))
+    os.system(cmd)
+
+# GATHER RESULTS
+results = {}
+par_file = os.path.splitext(model_file)[0] + '.par'
+for data_file in data_files:
+    with open(os.path.join(fit_dir(data_file), par_file), 'r') as fid:
+        for line in fid:
+            parameter, value = line.split()
+            results.setdefault(parameter, []).append(float(value))
+
+# SAVE RESULTS INTO FILE
+with open('batch_fit.csv', 'w') as fid:
+    parameters = list(sorted(results.keys()))
+    values_by_file = zip(*(v for k, v in sorted(results.items())))
+    fid.write(','.join(['filename'] + parameters) + '\n')
+    for filename, values in zip(data_files, values_by_file):
+        fid.write(','.join([filename] + [str(v) for v in values]) + '\n')
+
+# SHOW FITTED PARAMETERS
+nh, nw = tile_axes(len(results))
+ticks = np.arange(1, len(data_files)+1)
+labels = [os.path.splitext(filename)[0] for filename in data_files]
+for k, (parameter, values) in enumerate(sorted(results.items())):
+    plt.subplot(nh, nw, k+1)
+    plt.plot(ticks, values)
+    plt.xlim(ticks[0]-0.5, ticks[-1]+0.5)
+    if k%nh == nh-1:
+        #plt.xlabel('Dataset #')
+        plt.xticks(ticks, labels, rotation=30)
+    else:
+        plt.xticks(ticks, [' ']*len(labels))
+    plt.ylabel(parameter)
+plt.suptitle("Fit " + args[0])
+plt.show()
Index: example/model_ellipsoid_hayter_msa.py
===================================================================
--- example/model_ellipsoid_hayter_msa.py	(revision 8a5f0216970a47f3e897a508054840132bd87909)
+++ example/model_ellipsoid_hayter_msa.py	(revision 8a5f0216970a47f3e897a508054840132bd87909)
@@ -0,0 +1,41 @@
+import sys
+#sys.path.append('path_to_sasmodels')
+
+import numpy as np
+
+from bumps.names import *
+from sasmodels.core import load_model
+from sasmodels.bumps_model import Model, Experiment
+from sasmodels.data import load_data, plot_data
+
+# IMPORT THE DATA USED
+data = load_data(sys.argv[1])
+
+#setattr(data, 'qmin', 0.0)
+#setattr(data, 'qmax', 10.0)
+
+# DEFINE THE MODEL
+kernel = load_model('ellipsoid*hayter_msa')
+
+pars = dict(scale=6.4, background=0.06, sld=0.33, sld_solvent=2.15, radius_polar=14.0,
+            radius_equatorial=24.0, volfraction=0.075, charge=66.373, temperature=298.0,
+            concentration_salt=0.001, dielectconst=71.0)
+
+model = Model(kernel, **pars)
+
+# PARAMETER RANGES (ONLY THOSE PARAMETERS ARE FITTED)
+model.scale.range(0, inf)
+model.background.range(-inf, inf)
+#model.sld.range(-inf, inf)
+model.sld_solvent.range(-inf, inf)
+#model.radius_polar.range(0, inf)
+#model.radius_equatorial.range(0, inf)
+#model.volfraction.range(0,0.74)
+#model.charge.range(0, inf)
+#model.temperature.range(0,1000)
+#model.concentration_salt.range(0, 1)
+#model.dielectconst.range(0,inf)
+
+M = Experiment(data=data, model=model)
+
+problem = FitProblem(M)
