Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 4 files changed
  • 0 comments
  • 1 contributor
53 model_data/bags/process.py
@@ -2,6 +2,8 @@
2 2 import os
3 3 import os.path
4 4 import optparse
  5 +import models
  6 +REGISTERED_MODELS = models.models
5 7
6 8 def compare_chi2(first_fit, second_fit):
7 9 diff = first_fit[0]*1e10 - second_fit[0]*1e10
@@ -34,29 +36,38 @@ def approx_equal(x, y, tol=1e-18, rel=1e-7):
34 36
35 37 fit_list = []
36 38
37   -params = ['chi2', 'length', 'radius', 'sldCyl', 'sldSolv', 'background', 'scale']
38   -
39 39 for file in os.listdir(directory):
40   - fit = []
41   - parsed = ET.parse(os.path.join(directory, file))
42   - modules = parsed.getroot().find('module').find('module').findall('module')
43   - properties = modules[1].find('propertyList').findall('property')
44   - # properties = parsed.getroot().iterfind('property')
45   -
46   - prop_indices = []
47   - for property in properties:
48   - prop_indices.append(property.get('dictRef'))
49   -
50   - if 'chi2' in prop_indices:
51   - for param in params:
52   - i = prop_indices.index(param)
53   - prop = properties[i]
  40 + if file[len(file)-3:len(file)] == 'xml':
  41 +
  42 + fit = []
  43 + parsed = ET.parse(os.path.join(directory, file))
  44 +
  45 + modules = parsed.getroot().find('module').find('module').findall('module')
  46 + parameters = modules[0].find('parameterList').findall('parameter')
  47 + properties = modules[1].find('propertyList').findall('property')
  48 +
  49 + parameter_indices = []
  50 + for parameter in parameters:
  51 + parameter_indices.append(parameter.get('dictRef'))
  52 +
  53 + model = parameters[parameter_indices.index('model')][0].text
  54 + params = [p['paramname'] for p in REGISTERED_MODELS[model]['exp_vals']]
  55 + params.insert(0, 'chi2')
  56 +
  57 + prop_indices = []
  58 + for property in properties:
  59 + prop_indices.append(property.get('dictRef'))
  60 +
  61 + if 'chi2' in prop_indices:
  62 + for param in params:
  63 + i = prop_indices.index(param)
  64 + prop = properties[i]
54 65
55   - param_value = prop[0].text
56   - param_value = float(param_value)
57   - fit.append(param_value)
58   - fit.append(file)
59   - fit_list.append(fit)
  66 + param_value = prop[0].text
  67 + param_value = float(param_value)
  68 + fit.append(param_value)
  69 + fit.append(file)
  70 + fit_list.append(fit)
60 71
61 72 fit_list.sort(compare_chi2)
62 73 print params
4 pybiosas/modelling.py
@@ -285,6 +285,10 @@ def write_cml(self, path, filename):
285 285
286 286 # Setup the input parameter list and populate it
287 287 in_param_list=[]
  288 +
  289 + in_param_list.append({'value' : self.model,
  290 + 'attrib' : { 'dictRef' : 'model',
  291 + 'units' : 'N/A'}})
288 292 if self.command == 'fit':
289 293 for parameter in self.parameters_in:
290 294 in_param_list.append({'value' : parameter['value'],
2  pybiosas/version.py
... ... @@ -1 +1 @@
1   -VERSION = "0.2.0"
  1 +VERSION = "0.2.1"
3  setup.py
@@ -16,7 +16,8 @@
16 16 install_requires = [
17 17 'numpy',
18 18 'scipy',
19   - 'pycml'
  19 + 'pycml',
  20 + 'contrail_sansmodels'
20 21 ],
21 22 test_suite='test'
22 23 )

No commit comments for this range

Something went wrong with that request. Please try again.