Changeset 1c6bad0 in sasview for src/sas/sasgui/perspectives
- Timestamp:
- Dec 5, 2016 10:30:29 AM (8 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 7ede832
- Parents:
- 6fb6592
- Location:
- src/sas/sasgui/perspectives/fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
r0b1d7d3 r1c6bad0 1160 1160 category_pos = int(state.categorycombobox) 1161 1161 except: 1162 if state.formfactorcombobox is not None \ 1163 and not state._is_sasmodels(): 1162 if not state._is_sasmodels(): 1164 1163 state._convert_to_sasmodels() 1165 1164 state.categorycombobox = unicode(state.categorycombobox) -
src/sas/sasgui/perspectives/fitting/pagestate.py
r0b1d7d3 r1c6bad0 362 362 :return: None 363 363 """ 364 if self.formfactorcombobox == '': 365 if self.categorycombobox == '' and len(self.parameters) == 3: 366 self.categorycombobox = "Shape-Independent" 367 self.formfactorcombobox = 'PowerLawAbsModel' 368 elif self.categorycombobox == '' and len(self.parameters) == 9: 369 self.categorycombobox = 'Cylinder' 370 self.formfactorcombobox = 'barbell' 371 elif self.categorycombobox == 'Shapes': 372 self.formfactorcombobox = 'BCCrystalModel' 373 elif self.categorycombobox == 'Uncategorized': 374 self.formfactorcombobox = 'LineModel' 375 elif self.categorycombobox == 'StructureFactor': 376 self.structurecombobox = 'HardsphereStructure' 377 elif self.categorycombobox == 'Customized Models': 378 self.formfactorcombobox = 'MySumFunction' 379 elif self.categorycombobox == 'Ellipsoid': 380 self.formfactorcombobox = 'core_shell_ellipsoid' 381 elif self.categorycombobox == 'Lamellae': 382 self.formfactorcombobox = 'lamellar' 383 elif self.categorycombobox == 'Paracrystal': 384 self.formfactorcombobox = 'bcc_paracrystal' 385 elif self.categorycombobox == 'Parallelepiped': 386 self.formfactorcombobox = 'core_shell_parallelepiped' 387 elif self.categorycombobox == 'Shape Independent': 388 self.formfactorcombobox = 'be_polyelectrolyte' 389 elif self.categorycombobox == 'Sphere': 390 self.formfactorcombobox = 'adsorbed_layer' 391 elif self.categorycombobox == 'Structure Factor': 392 self.formfactorcombobox = 'hardsphere' 364 393 newname = convert._conversion_target(self.formfactorcombobox) 365 394 if newname == None: … … 368 397 return False 369 398 370 def _convert_to_sasmodels(self):371 """ 372 Convert parameters to a form usable by sasmodels converter373 374 : return: None375 """376 # Create conversion dictionary to send to sasmodels399 def param_remap_to_sasmodels_convert(self, params): 400 """ 401 Remaps the parameters for sasmodels conversion 402 403 :param params: list of parameters (likely self.parameters) 404 :return: remapped dictionary of parameters 405 """ 377 406 p = dict() 378 for fittable, name, value, _, uncert, lower, upper, units in \ 379 self.parameters: 407 for fittable, name, value, _, uncert, lower, upper, units in params: 380 408 if not value: 381 409 value = numpy.nan … … 395 423 p[name + ".lower"] = float(lower[1]) 396 424 p[name + ".units"] = units 397 425 return p 426 427 def param_remap_from_sasmodels_convert(self, params): 428 """ 429 Converts {name : value} map back to [] param list 430 :param params: parameter map returned from sasmodels 431 :return: None 432 """ 433 p_map = [] 434 for name, info in params.iteritems(): 435 if ".fittable" in name or ".std" in name or ".upper" in name or \ 436 ".lower" in name or ".units" in name: 437 pass 438 else: 439 fittable = params.get(name + ".fittable", True) 440 std = params.get(name + ".std", '0.0') 441 upper = params.get(name + ".upper", 'inf') 442 lower = params.get(name + ".lower", '-inf') 443 units = params.get(name + ".units") 444 if std is not None and std is not numpy.nan: 445 std = [True, str(std)] 446 else: 447 std = [False, ''] 448 if lower is not None and lower is not numpy.nan: 449 lower = [True, str(lower)] 450 else: 451 lower = [True, '-inf'] 452 if upper is not None and upper is not numpy.nan: 453 upper = [True, str(upper)] 454 else: 455 upper = [True, 'inf'] 456 param_list = [bool(fittable), str(name), str(info), 457 "+/-", std, lower, upper, str(units)] 458 p_map.append(param_list) 459 return p_map 460 461 def _convert_to_sasmodels(self): 462 """ 463 Convert parameters to a form usable by sasmodels converter 464 465 :return: None 466 """ 467 # Create conversion dictionary to send to sasmodels 468 p = self.param_remap_to_sasmodels_convert(self.parameters) 398 469 structurefactor, params = \ 399 470 convert.convert_model(self.structurecombobox, p) 400 471 formfactor, params = \ 401 472 convert.convert_model(self.formfactorcombobox, params) 402 # if len(self.str_parameters) > 0: 403 # formfactor, str_params = \ 404 # convert.convert_model(formfactor, self.str_parameters) 473 if len(self.str_parameters) > 0: 474 str_p = self.param_remap_to_sasmodels_convert(self.str_parameters) 475 formfactor, str_params = convert.convert_model(formfactor, str_p) 476 else: 477 str_params = None 405 478 406 479 # Only convert if old != new, otherwise all the same … … 410 483 self.structurecombobox = structurefactor 411 484 self.parameters = [] 412 for name, info in params.iteritems(): 413 if ".fittable" in name or ".std" in name or ".upper" in name or\ 414 ".lower" in name or ".units" in name: 415 pass 416 else: 417 fittable = params.get(name + ".fittable", True) 418 std = params.get(name + ".std", '0.0') 419 upper = params.get(name + ".upper", 'inf') 420 lower = params.get(name + ".lower", '-inf') 421 units = params.get(name + ".units") 422 if std is not None and std is not numpy.nan: 423 std = [True, str(std)] 424 else: 425 std = [False, ''] 426 if lower is not None and lower is not numpy.nan: 427 lower = [True, str(lower)] 428 else: 429 lower = [True, '-inf'] 430 if upper is not None and upper is not numpy.nan: 431 upper = [True, str(upper)] 432 else: 433 upper = [True, 'inf'] 434 param_list = [bool(fittable), str(name), str(info), 435 "+/-", std, lower, upper, str(units)] 436 self.parameters.append(param_list) 437 485 self.parameters = self.param_remap_from_sasmodels_convert(params) 486 if str_params: 487 self.str_parameters = \ 488 self.param_remap_from_sasmodels_convert(str_params) 438 489 439 490 def _repr_helper(self, list, rep):
Note: See TracChangeset
for help on using the changeset viewer.