- Timestamp:
- Mar 16, 2016 11:22:41 AM (9 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, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- e5ea2d0
- Parents:
- 50a77df
- Location:
- src/sas/sasgui/perspectives/fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/fitpanel.py
rd85c194 rf66d9d1 120 120 """ 121 121 """ 122 temp = self.menu_mng.p ulgins_reset()122 temp = self.menu_mng.plugins_reset() 123 123 if len(temp): 124 124 self.model_list_box = temp -
src/sas/sasgui/perspectives/fitting/models.py
r50a77df rf66d9d1 13 13 import py_compile 14 14 import shutil 15 from sas. guiframe.events import StatusEvent15 from sas.sasgui.guiframe.events import StatusEvent 16 16 # Explicitly import from the pluginmodel module so that py2exe 17 17 # places it in the distribution. The Model1DPlugin class is used … … 20 20 from sas.models.BaseComponent import BaseComponent 21 21 from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 22 23 22 from sasmodels.sasview_model import make_class 24 23 import sasmodels.core 24 25 25 26 PLUGIN_DIR = 'plugin_models' 26 27 … … 256 257 ## dictionary of structure factor models 257 258 struct_factor_dict = {} 258 ##list of shape models -- this is superseded by categories259 # shape_list = []260 ## shape independent model list-- this is superseded by categories261 # shape_indep_list = []262 259 ##list of structure factors 263 260 struct_list = [] … … 299 296 """ 300 297 301 ## NOTE: as of April 26, 2014, as part of first pass on fixing categories,302 ## all the appends to shape_list or shape_independent_list are303 ## commented out. They should be possible to remove. They are in304 ## fact a "category" of model whereas the other list are actually305 ## "attributes" of a model. In other words is it a structure factor306 ## that can be used against a form factor, is it a form factor that is307 ## knows how to be multiplied by a structure factor, does it have user308 ## defined number of parameters, etc.309 ##310 ## We hope this whole list will be superseded by the new C models311 ## structure where each model will provide a method to interrogate it312 ## about its "attributes" -- then this long list becomes a loop reading313 ## each model in the category list to populate the "attribute"lists.314 ## We should also refactor the whole category vs attribute list315 ## structure when doing this as now the attribute lists think they are316 ## also category lists.317 ##318 ## -PDB April 26, 2014319 320 298 # regular model names only 299 base_message = "Unable to load model {0}" 321 300 self.model_name_list = [] 322 301 323 302 #Build list automagically from sasmodels package 324 import pkgutil 325 from importlib import import_module 326 import sasmodels.models 327 for importer,modname,ispkg in pkgutil.iter_modules(sasmodels.models.__path__): 328 if not ispkg: 329 module = import_module('.'+modname,'sasmodels.models') 330 self.model_dictionary[module.oldname] = make_class(module, dtype='single',namestyle='oldname') 331 self.model_name_list.append(module.oldname) 332 333 334 ### NASTY HACK - Comment out most of these lines as models are added to sasmodels. 335 ### Still need the lines that put models into multiplication etc 336 337 try: 338 # # from sas.models.SphereModel import SphereModel 339 # from sasmodels.models import sphere 340 # SphereModel = make_class(sphere, dtype='single',namestyle='oldname') 341 # self.model_dictionary[SphereModel.__name__] = SphereModel 342 # # self.shape_list.append(SphereModel) 343 self.multiplication_factor.append(SphereModel) 344 # self.model_name_list.append(SphereModel.__name__) 345 except: 346 pass 347 348 try: 349 from sas.models.BinaryHSModel import BinaryHSModel 350 self.model_dictionary[BinaryHSModel.__name__] = BinaryHSModel 351 # self.shape_list.append(BinaryHSModel) 352 self.model_name_list.append(BinaryHSModel.__name__) 353 except: 354 logging.error(base_message.format(BinaryHSModel.__name__)) 355 356 try: 357 from sas.models.FuzzySphereModel import FuzzySphereModel 358 self.model_dictionary[FuzzySphereModel.__name__] = FuzzySphereModel 359 # self.shape_list.append(FuzzySphereModel) 360 self.multiplication_factor.append(FuzzySphereModel) 361 self.model_name_list.append(FuzzySphereModel.__name__) 362 except: 363 logging.error(base_message.format(FuzzySphereModel.__name__)) 364 365 try: 366 from sas.models.RaspBerryModel import RaspBerryModel 367 self.model_dictionary[RaspBerryModel.__name__] = RaspBerryModel 368 # self.shape_list.append(RaspBerryModel) 369 self.model_name_list.append(RaspBerryModel.__name__) 370 except: 371 logging.error(base_message.format(RaspBerryModel.__name__)) 372 373 try: 374 from sas.models.CoreShellModel import CoreShellModel 375 376 self.model_dictionary[CoreShellModel.__name__] = CoreShellModel 377 # self.shape_list.append(CoreShellModel) 378 self.multiplication_factor.append(CoreShellModel) 379 self.model_name_list.append(CoreShellModel.__name__) 380 except: 381 logging.error(base_message.format(CoreShellModel.__name__)) 382 383 try: 384 from sas.models.Core2ndMomentModel import Core2ndMomentModel 385 self.model_dictionary[Core2ndMomentModel.__name__] = Core2ndMomentModel 386 # self.shape_list.append(Core2ndMomentModel) 387 self.model_name_list.append(Core2ndMomentModel.__name__) 388 except: 389 logging.error(base_message.format(Core2ndMomentModel.__name__)) 390 391 try: 392 from sas.models.CoreMultiShellModel import CoreMultiShellModel 393 self.model_dictionary[CoreMultiShellModel.__name__] = CoreMultiShellModel 394 # self.shape_list.append(CoreMultiShellModel) 395 self.multiplication_factor.append(CoreMultiShellModel) 396 self.multi_func_list.append(CoreMultiShellModel) 397 except: 398 logging.error(base_message.format(CoreMultiShellModel.__name__)) 399 400 try: 401 from sas.models.VesicleModel import VesicleModel 402 self.model_dictionary[VesicleModel.__name__] = VesicleModel 403 # self.shape_list.append(VesicleModel) 404 self.multiplication_factor.append(VesicleModel) 405 self.model_name_list.append(VesicleModel.__name__) 406 except: 407 logging.error(base_message.format(VesicleModel.__name__)) 408 409 try: 410 from sas.models.MultiShellModel import MultiShellModel 411 self.model_dictionary[MultiShellModel.__name__] = MultiShellModel 412 # self.shape_list.append(MultiShellModel) 413 self.multiplication_factor.append(MultiShellModel) 414 self.model_name_list.append(MultiShellModel.__name__) 415 except: 416 logging.error(base_message.format(MultiShellModel.__name__)) 417 418 try: 419 from sas.models.OnionExpShellModel import OnionExpShellModel 420 self.model_dictionary[OnionExpShellModel.__name__] = OnionExpShellModel 421 # self.shape_list.append(OnionExpShellModel) 422 self.multiplication_factor.append(OnionExpShellModel) 423 self.multi_func_list.append(OnionExpShellModel) 424 except: 425 logging.error(base_message.format(OnionExpShellModel.__name__)) 426 427 try: 428 from sas.models.SphericalSLDModel import SphericalSLDModel 429 430 self.model_dictionary[SphericalSLDModel.__name__] = SphericalSLDModel 431 # self.shape_list.append(SphericalSLDModel) 432 self.multiplication_factor.append(SphericalSLDModel) 433 self.multi_func_list.append(SphericalSLDModel) 434 except: 435 logging.error(base_message.format(SphericalSLDModel.__name__)) 436 437 try: 438 from sas.models.LinearPearlsModel import LinearPearlsModel 439 440 self.model_dictionary[LinearPearlsModel.__name__] = LinearPearlsModel 441 # self.shape_list.append(LinearPearlsModel) 442 self.model_name_list.append(LinearPearlsModel.__name__) 443 except: 444 logging.error(base_message.format(LinearPearlsModel.__name__)) 445 446 try: 447 from sas.models.PearlNecklaceModel import PearlNecklaceModel 448 449 self.model_dictionary[PearlNecklaceModel.__name__] = PearlNecklaceModel 450 # self.shape_list.append(PearlNecklaceModel) 451 self.model_name_list.append(PearlNecklaceModel.__name__) 452 except: 453 logging.error(base_message.format(PearlNecklaceModel.__name__)) 454 455 try: 456 from sas.models.CylinderModel import CylinderModel 457 458 self.model_dictionary[CylinderModel.__name__] = CylinderModel 459 # self.shape_list.append(CylinderModel) 460 self.multiplication_factor.append(CylinderModel) 461 self.model_name_list.append(CylinderModel.__name__) 462 except: 463 logging.error(base_message.format(CylinderModel.__name__)) 464 465 try: 466 from sas.models.CoreShellCylinderModel import CoreShellCylinderModel 467 468 self.model_dictionary[CoreShellCylinderModel.__name__] = CoreShellCylinderModel 469 # self.shape_list.append(CoreShellCylinderModel) 470 self.multiplication_factor.append(CoreShellCylinderModel) 471 self.model_name_list.append(CoreShellCylinderModel.__name__) 472 except: 473 logging.error(base_message.format(CoreShellCylinderModel.__name__)) 474 475 try: 476 from sas.models.CoreShellBicelleModel import CoreShellBicelleModel 477 478 self.model_dictionary[CoreShellBicelleModel.__name__] = CoreShellBicelleModel 479 # self.shape_list.append(CoreShellBicelleModel) 480 self.multiplication_factor.append(CoreShellBicelleModel) 481 self.model_name_list.append(CoreShellBicelleModel.__name__) 482 except: 483 logging.error(base_message.format(CoreShellBicelleModel.__name__)) 484 485 try: 486 from sas.models.HollowCylinderModel import HollowCylinderModel 487 488 self.model_dictionary[HollowCylinderModel.__name__] = HollowCylinderModel 489 # self.shape_list.append(HollowCylinderModel) 490 self.multiplication_factor.append(HollowCylinderModel) 491 self.model_name_list.append(HollowCylinderModel.__name__) 492 except: 493 logging.error(base_message.format(HollowCylinderModel.__name__)) 494 495 try: 496 from sas.models.FlexibleCylinderModel import FlexibleCylinderModel 497 498 self.model_dictionary[FlexibleCylinderModel.__name__] = FlexibleCylinderModel 499 # self.shape_list.append(FlexibleCylinderModel) 500 self.model_name_list.append(FlexibleCylinderModel.__name__) 501 except: 502 logging.error(base_message.format(FlexibleCylinderModel.__name__)) 503 504 try: 505 from sas.models.FlexCylEllipXModel import FlexCylEllipXModel 506 507 self.model_dictionary[FlexCylEllipXModel.__name__] = FlexCylEllipXModel 508 # self.shape_list.append(FlexCylEllipXModel) 509 self.model_name_list.append(FlexCylEllipXModel.__name__) 510 except: 511 logging.error(base_message.format(FlexCylEllipXModel.__name__)) 512 513 try: 514 from sas.models.StackedDisksModel import StackedDisksModel 515 516 self.model_dictionary[StackedDisksModel.__name__] = StackedDisksModel 517 # self.shape_list.append(StackedDisksModel) 518 self.multiplication_factor.append(StackedDisksModel) 519 self.model_name_list.append(StackedDisksModel.__name__) 520 except: 521 logging.error(base_message.format(StackedDisksModel.__name__)) 522 523 try: 524 from sas.models.ParallelepipedModel import ParallelepipedModel 525 526 self.model_dictionary[ParallelepipedModel.__name__] = ParallelepipedModel 527 # self.shape_list.append(ParallelepipedModel) 528 self.multiplication_factor.append(ParallelepipedModel) 529 self.model_name_list.append(ParallelepipedModel.__name__) 530 except: 531 logging.error(base_message.format(ParallelepipedModel.__name__)) 532 533 try: 534 from sas.models.CSParallelepipedModel import CSParallelepipedModel 535 536 self.model_dictionary[CSParallelepipedModel.__name__] = CSParallelepipedModel 537 # self.shape_list.append(CSParallelepipedModel) 538 self.multiplication_factor.append(CSParallelepipedModel) 539 self.model_name_list.append(CSParallelepipedModel.__name__) 540 except: 541 logging.error(base_message.format(CSParallelepipedModel.__name__)) 542 543 try: 544 from sas.models.EllipticalCylinderModel import EllipticalCylinderModel 545 546 self.model_dictionary[EllipticalCylinderModel.__name__] = EllipticalCylinderModel 547 # self.shape_list.append(EllipticalCylinderModel) 548 self.multiplication_factor.append(EllipticalCylinderModel) 549 self.model_name_list.append(EllipticalCylinderModel.__name__) 550 except: 551 logging.error(base_message.format(EllipticalCylinderModel.__name__)) 552 553 try: 554 from sas.models.BarBellModel import BarBellModel 555 556 self.model_dictionary[BarBellModel.__name__] = BarBellModel 557 # self.shape_list.append(BarBellModel) 558 self.model_name_list.append(BarBellModel.__name__) 559 except: 560 logging.error(base_message.format(BarBellModel.__name__)) 561 562 try: 563 from sas.models.CappedCylinderModel import CappedCylinderModel 564 565 self.model_dictionary[CappedCylinderModel.__name__] = CappedCylinderModel 566 # self.shape_list.append(CappedCylinderModel) 567 self.model_name_list.append(CappedCylinderModel.__name__) 568 except: 569 logging.error(base_message.format(CappedCylinderModel.__name__)) 570 571 try: 572 from sas.models.EllipsoidModel import EllipsoidModel 573 574 self.model_dictionary[EllipsoidModel.__name__] = EllipsoidModel 575 # self.shape_list.append(EllipsoidModel) 576 self.multiplication_factor.append(EllipsoidModel) 577 self.model_name_list.append(EllipsoidModel.__name__) 578 except: 579 logging.error(base_message.format(EllipsoidModel.__name__)) 580 581 try: 582 from sas.models.CoreShellEllipsoidModel import CoreShellEllipsoidModel 583 584 self.model_dictionary[CoreShellEllipsoidModel.__name__] = CoreShellEllipsoidModel 585 # self.shape_list.append(CoreShellEllipsoidModel) 586 self.multiplication_factor.append(CoreShellEllipsoidModel) 587 self.model_name_list.append(CoreShellEllipsoidModel.__name__) 588 except: 589 logging.error(base_message.format(CoreShellEllipsoidModel.__name__)) 590 591 try: 592 from sas.models.CoreShellEllipsoidXTModel import CoreShellEllipsoidXTModel 593 594 self.model_dictionary[CoreShellEllipsoidXTModel.__name__] = CoreShellEllipsoidXTModel 595 # self.shape_list.append(CoreShellEllipsoidXTModel) 596 self.multiplication_factor.append(CoreShellEllipsoidXTModel) 597 self.model_name_list.append(CoreShellEllipsoidXTModel.__name__) 598 except: 599 logging.error(base_message.format(CoreShellEllipsoidXTModel.__name__)) 600 601 try: 602 from sas.models.TriaxialEllipsoidModel import TriaxialEllipsoidModel 603 604 self.model_dictionary[TriaxialEllipsoidModel.__name__] = TriaxialEllipsoidModel 605 # self.shape_list.append(TriaxialEllipsoidModel) 606 self.multiplication_factor.append(TriaxialEllipsoidModel) 607 self.model_name_list.append(TriaxialEllipsoidModel.__name__) 608 except: 609 logging.error(base_message.format(TriaxialEllipsoidModel.__name__)) 610 611 try: 612 from sas.models.LamellarModel import LamellarModel 613 614 self.model_dictionary[LamellarModel.__name__] = LamellarModel 615 # self.shape_list.append(LamellarModel) 616 self.model_name_list.append(LamellarModel.__name__) 617 except: 618 logging.error(base_message.format(LamellarModel.__name__)) 619 620 try: 621 from sas.models.LamellarFFHGModel import LamellarFFHGModel 622 623 self.model_dictionary[LamellarFFHGModel.__name__] = LamellarFFHGModel 624 # self.shape_list.append(LamellarFFHGModel) 625 self.model_name_list.append(LamellarFFHGModel.__name__) 626 except: 627 logging.error(base_message.format(LamellarFFHGModel.__name__)) 628 629 try: 630 from sas.models.LamellarPSModel import LamellarPSModel 631 632 self.model_dictionary[LamellarPSModel.__name__] = LamellarPSModel 633 # self.shape_list.append(LamellarPSModel) 634 self.model_name_list.append(LamellarPSModel.__name__) 635 except: 636 logging.error(base_message.format(LamellarPSModel.__name__)) 637 638 try: 639 from sas.models.LamellarPSHGModel import LamellarPSHGModel 640 641 self.model_dictionary[LamellarPSHGModel.__name__] = LamellarPSHGModel 642 # self.shape_list.append(LamellarPSHGModel) 643 self.model_name_list.append(LamellarPSHGModel.__name__) 644 except: 645 logging.error(base_message.format(LamellarPSHGModel.__name__)) 646 647 try: 648 from sas.models.LamellarPCrystalModel import LamellarPCrystalModel 649 650 self.model_dictionary[LamellarPCrystalModel.__name__] = LamellarPCrystalModel 651 # self.shape_list.append(LamellarPCrystalModel) 652 self.model_name_list.append(LamellarPCrystalModel.__name__) 653 except: 654 logging.error(base_message.format(LamellarPCrystalModel.__name__)) 655 656 try: 657 from sas.models.SCCrystalModel import SCCrystalModel 658 659 self.model_dictionary[SCCrystalModel.__name__] = SCCrystalModel 660 # self.shape_list.append(SCCrystalModel) 661 self.model_name_list.append(SCCrystalModel.__name__) 662 except: 663 logging.error(base_message.format(SCCrystalModel.__name__)) 664 665 try: 666 from sas.models.FCCrystalModel import FCCrystalModel 667 668 self.model_dictionary[FCCrystalModel.__name__] = FCCrystalModel 669 # self.shape_list.append(FCCrystalModel) 670 self.model_name_list.append(FCCrystalModel.__name__) 671 except: 672 logging.error(base_message.format(FCCrystalModel.__name__)) 673 674 try: 675 from sas.models.BCCrystalModel import BCCrystalModel 676 677 self.model_dictionary[BCCrystalModel.__name__] = BCCrystalModel 678 # self.shape_list.append(BCCrystalModel) 679 self.model_name_list.append(BCCrystalModel.__name__) 680 except: 681 logging.error(base_message.format(BCCrystalModel.__name__)) 682 683 684 ## Structure factor 685 try: 686 from sas.models.SquareWellStructure import SquareWellStructure 687 688 self.model_dictionary[SquareWellStructure.__name__] = SquareWellStructure 689 self.struct_list.append(SquareWellStructure) 690 self.model_name_list.append(SquareWellStructure.__name__) 691 except: 692 logging.error(base_message.format(SquareWellStructure.__name__)) 693 694 try: 695 from sas.models.HardsphereStructure import HardsphereStructure 696 697 self.model_dictionary[HardsphereStructure.__name__] = HardsphereStructure 698 self.struct_list.append(HardsphereStructure) 699 self.model_name_list.append(HardsphereStructure.__name__) 700 except: 701 logging.error(base_message.format(HardsphereStructure.__name__)) 702 703 try: 704 from sas.models.StickyHSStructure import StickyHSStructure 705 706 self.model_dictionary[StickyHSStructure.__name__] = StickyHSStructure 707 self.struct_list.append(StickyHSStructure) 708 self.model_name_list.append(StickyHSStructure.__name__) 709 except: 710 logging.error(base_message.format(StickyHSStructure.__name__)) 711 712 try: 713 from sas.models.HayterMSAStructure import HayterMSAStructure 714 715 self.model_dictionary[HayterMSAStructure.__name__] = HayterMSAStructure 716 self.struct_list.append(HayterMSAStructure) 717 self.model_name_list.append(HayterMSAStructure.__name__) 718 except: 719 logging.error(base_message.format(HayterMSAStructure.__name__)) 720 721 722 723 ##shape-independent models 724 try: 725 from sas.models.PowerLawAbsModel import PowerLawAbsModel 726 727 self.model_dictionary[PowerLawAbsModel.__name__] = PowerLawAbsModel 728 # self.shape_indep_list.append(PowerLawAbsModel) 729 self.model_name_list.append(PowerLawAbsModel.__name__) 730 except: 731 logging.error(base_message.format(PowerLawAbsModel.__name__)) 732 733 try: 734 from sas.models.BEPolyelectrolyte import BEPolyelectrolyte 735 736 self.model_dictionary[BEPolyelectrolyte.__name__] = BEPolyelectrolyte 737 # self.shape_indep_list.append(BEPolyelectrolyte) 738 self.model_name_list.append(BEPolyelectrolyte.__name__) 739 self.form_factor_dict[str(wx.NewId())] = [SphereModel] 740 except: 741 logging.error(base_message.format(BEPolyelectrolyte.__name__)) 742 743 try: 744 from sas.models.BroadPeakModel import BroadPeakModel 745 746 self.model_dictionary[BroadPeakModel.__name__] = BroadPeakModel 747 # self.shape_indep_list.append(BroadPeakModel) 748 self.model_name_list.append(BroadPeakModel.__name__) 749 except: 750 logging.error(base_message.format(BroadPeakModel.__name__)) 751 752 try: 753 from sas.models.CorrLengthModel import CorrLengthModel 754 755 self.model_dictionary[CorrLengthModel.__name__] = CorrLengthModel 756 # self.shape_indep_list.append(CorrLengthModel) 757 self.model_name_list.append(CorrLengthModel.__name__) 758 except: 759 logging.error(base_message.format(CorrLengthModel.__name__)) 760 761 try: 762 from sas.models.DABModel import DABModel 763 764 self.model_dictionary[DABModel.__name__] = DABModel 765 # self.shape_indep_list.append(DABModel) 766 self.model_name_list.append(DABModel.__name__) 767 except: 768 logging.error(base_message.format(DABModel.__name__)) 769 770 try: 771 from sas.models.DebyeModel import DebyeModel 772 773 self.model_dictionary[DebyeModel.__name__] = DebyeModel 774 # self.shape_indep_list.append(DebyeModel) 775 self.model_name_list.append(DebyeModel.__name__) 776 except: 777 logging.error(base_message.format(DebyeModel.__name__)) 778 779 try: 780 from sas.models.FractalModel import FractalModel 781 782 self.model_dictionary[FractalModel.__name__] = FractalModel 783 # self.shape_indep_list.append(FractalModel) 784 self.model_name_list.append(FractalModel.__name__) 785 except: 786 logging.error(base_message.format(FractalModel.__name__)) 787 788 try: 789 from sas.models.FractalCoreShellModel import FractalCoreShellModel 790 791 self.model_dictionary[FractalCoreShellModel.__name__] = FractalCoreShellModel 792 # self.shape_indep_list.append(FractalCoreShellModel) 793 self.model_name_list.append(FractalCoreShellModel.__name__) 794 except: 795 logging.error(base_message.format(FractalCoreShellModel.__name__)) 796 797 try: 798 from sas.models.GaussLorentzGelModel import GaussLorentzGelModel 799 800 self.model_dictionary[GaussLorentzGelModel.__name__] = GaussLorentzGelModel 801 # self.shape_indep_list.append(GaussLorentzGelModel) 802 self.model_name_list.append(GaussLorentzGelModel.__name__) 803 except: 804 logging.error(base_message.format(GaussLorentzGelModel.__name__)) 805 806 try: 807 from sas.models.GuinierModel import GuinierModel 808 809 self.model_dictionary[GuinierModel.__name__] = GuinierModel 810 # self.shape_indep_list.append(GuinierModel) 811 self.model_name_list.append(GuinierModel.__name__) 812 except: 813 logging.error(base_message.format(GuinierModel.__name__)) 814 815 try: 816 from sas.models.GuinierPorodModel import GuinierPorodModel 817 818 self.model_dictionary[GuinierPorodModel.__name__] = GuinierPorodModel 819 # self.shape_indep_list.append(GuinierPorodModel) 820 self.model_name_list.append(GuinierPorodModel.__name__) 821 except: 822 logging.error(base_message.format(GuinierPorodModel.__name__)) 823 824 try: 825 from sas.models.LorentzModel import LorentzModel 826 827 self.model_dictionary[LorentzModel.__name__] = LorentzModel 828 # self.shape_indep_list.append(LorentzModel) 829 self.model_name_list.append(LorentzModel.__name__) 830 except: 831 logging.error(base_message.format(LorentzModel.__name__)) 832 833 try: 834 from sas.models.MassFractalModel import MassFractalModel 835 836 self.model_dictionary[MassFractalModel.__name__] = MassFractalModel 837 # self.shape_indep_list.append(MassFractalModel) 838 self.model_name_list.append(MassFractalModel.__name__) 839 except: 840 logging.error(base_message.format(MassFractalModel.__name__)) 841 842 try: 843 from sas.models.MassSurfaceFractal import MassSurfaceFractal 844 845 self.model_dictionary[MassSurfaceFractal.__name__] = MassSurfaceFractal 846 # self.shape_indep_list.append(MassSurfaceFractal) 847 self.model_name_list.append(MassSurfaceFractal.__name__) 848 except: 849 logging.error(base_message.format(MassSurfaceFractal.__name__)) 850 851 try: 852 from sas.models.PeakGaussModel import PeakGaussModel 853 854 self.model_dictionary[PeakGaussModel.__name__] = PeakGaussModel 855 # self.shape_indep_list.append(PeakGaussModel) 856 self.model_name_list.append(PeakGaussModel.__name__) 857 except: 858 logging.error(base_message.format(PeakGaussModel.__name__)) 859 860 try: 861 from sas.models.PeakLorentzModel import PeakLorentzModel 862 863 self.model_dictionary[PeakLorentzModel.__name__] = PeakLorentzModel 864 # self.shape_indep_list.append(PeakLorentzModel) 865 self.model_name_list.append(PeakLorentzModel.__name__) 866 except: 867 logging.error(base_message.format(PeakLorentzModel.__name__)) 868 869 try: 870 from sas.models.Poly_GaussCoil import Poly_GaussCoil 871 872 self.model_dictionary[Poly_GaussCoil.__name__] = Poly_GaussCoil 873 # self.shape_indep_list.append(Poly_GaussCoil) 874 self.model_name_list.append(Poly_GaussCoil.__name__) 875 except: 876 logging.error(base_message.format(Poly_GaussCoil.__name__)) 877 878 try: 879 from sas.models.PolymerExclVolume import PolymerExclVolume 880 881 self.model_dictionary[PolymerExclVolume.__name__] = PolymerExclVolume 882 # self.shape_indep_list.append(PolymerExclVolume) 883 self.model_name_list.append(PolymerExclVolume.__name__) 884 except: 885 logging.error(base_message.format(PolymerExclVolume.__name__)) 886 887 try: 888 from sas.models.PorodModel import PorodModel 889 890 self.model_dictionary[PorodModel.__name__] = PorodModel 891 # self.shape_indep_list.append(PorodModel) 892 self.model_name_list.append(PorodModel.__name__) 893 except: 894 logging.error(base_message.format(PorodModel.__name__)) 895 896 try: 897 from sas.models.RPA10Model import RPA10Model 898 899 self.model_dictionary[RPA10Model.__name__] = RPA10Model 900 # self.shape_indep_list.append(RPA10Model) 901 self.multi_func_list.append(RPA10Model) 902 except: 903 logging.error(base_message.format(RPA10Model.__name__)) 904 905 try: 906 from sas.models.StarPolymer import StarPolymer 907 908 self.model_dictionary[StarPolymer.__name__] = StarPolymer 909 # self.shape_indep_list.append(StarPolymer) 910 self.model_name_list.append(StarPolymer.__name__) 911 except: 912 logging.error(base_message.format(StarPolymer.__name__)) 913 914 try: 915 from sas.models.SurfaceFractalModel import SurfaceFractalModel 916 917 self.model_dictionary[SurfaceFractalModel.__name__] = SurfaceFractalModel 918 # self.shape_indep_list.append(SurfaceFractalModel) 919 self.model_name_list.append(SurfaceFractalModel.__name__) 920 except: 921 logging.error(base_message.format(SurfaceFractalModel.__name__)) 922 923 try: 924 from sas.models.TeubnerStreyModel import TeubnerStreyModel 925 926 self.model_dictionary[TeubnerStreyModel.__name__] = TeubnerStreyModel 927 # self.shape_indep_list.append(TeubnerStreyModel) 928 self.model_name_list.append(TeubnerStreyModel.__name__) 929 except: 930 logging.error(base_message.format(TeubnerStreyModel.__name__)) 931 932 try: 933 from sas.models.TwoLorentzianModel import TwoLorentzianModel 934 935 self.model_dictionary[TwoLorentzianModel.__name__] = TwoLorentzianModel 936 # self.shape_indep_list.append(TwoLorentzianModel) 937 self.model_name_list.append(TwoLorentzianModel.__name__) 938 except: 939 logging.error(base_message.format(TwoLorentzianModel.__name__)) 940 941 try: 942 from sas.models.TwoPowerLawModel import TwoPowerLawModel 943 944 self.model_dictionary[TwoPowerLawModel.__name__] = TwoPowerLawModel 945 # self.shape_indep_list.append(TwoPowerLawModel) 946 self.model_name_list.append(TwoPowerLawModel.__name__) 947 except: 948 logging.error(base_message.format(TwoPowerLawModel.__name__)) 949 950 try: 951 from sas.models.UnifiedPowerRgModel import UnifiedPowerRgModel 952 953 self.model_dictionary[UnifiedPowerRgModel.__name__] = UnifiedPowerRgModel 954 # self.shape_indep_list.append(UnifiedPowerRgModel) 955 self.multi_func_list.append(UnifiedPowerRgModel) 956 except: 957 logging.error(base_message.format(UnifiedPowerRgModel.__name__)) 958 959 try: 960 from sas.models.LineModel import LineModel 961 962 self.model_dictionary[LineModel.__name__] = LineModel 963 # self.shape_indep_list.append(LineModel) 964 self.model_name_list.append(LineModel.__name__) 965 except: 966 logging.error(base_message.format(LineModel.__name__)) 967 968 try: 969 from sas.models.ReflectivityModel import ReflectivityModel 970 971 self.model_dictionary[ReflectivityModel.__name__] = ReflectivityModel 972 # self.shape_indep_list.append(ReflectivityModel) 973 self.multi_func_list.append(ReflectivityModel) 974 except: 975 logging.error(base_message.format(ReflectivityModel.__name__)) 976 977 try: 978 from sas.models.ReflectivityIIModel import ReflectivityIIModel 979 980 self.model_dictionary[ReflectivityIIModel.__name__] = ReflectivityIIModel 981 # self.shape_indep_list.append(ReflectivityIIModel) 982 self.multi_func_list.append(ReflectivityIIModel) 983 except: 984 logging.error(base_message.format(ReflectivityIIModel.__name__)) 985 986 try: 987 from sas.models.GelFitModel import GelFitModel 988 989 self.model_dictionary[GelFitModel.__name__] = GelFitModel 990 # self.shape_indep_list.append(GelFitModel) 991 self.model_name_list.append(GelFitModel.__name__) 992 except: 993 logging.error(base_message.format(GelFitModel.__name__)) 994 995 try: 996 from sas.models.PringlesModel import PringlesModel 997 998 self.model_dictionary[PringlesModel.__name__] = PringlesModel 999 # self.shape_indep_list.append(PringlesModel) 1000 self.model_name_list.append(PringlesModel.__name__) 1001 except: 1002 logging.error(base_message.format(PringlesModel.__name__)) 1003 1004 try: 1005 from sas.models.RectangularPrismModel import RectangularPrismModel 1006 1007 self.model_dictionary[RectangularPrismModel.__name__] = RectangularPrismModel 1008 # self.shape_list.append(RectangularPrismModel) 1009 self.multiplication_factor.append(RectangularPrismModel) 1010 self.model_name_list.append(RectangularPrismModel.__name__) 1011 except: 1012 logging.error(base_message.format(RectangularPrismModel.__name__)) 1013 1014 try: 1015 from sas.models.RectangularHollowPrismInfThinWallsModel import RectangularHollowPrismInfThinWallsModel 1016 1017 self.model_dictionary[RectangularHollowPrismInfThinWallsModel.__name__] = RectangularHollowPrismInfThinWallsModel 1018 # self.shape_list.append(RectangularHollowPrismInfThinWallsModel) 1019 self.multiplication_factor.append(RectangularHollowPrismInfThinWallsModel) 1020 self.model_name_list.append(RectangularHollowPrismInfThinWallsModel.__name__) 1021 except: 1022 logging.error(base_message.format(RectangularHollowPrismInfThinWallsModel.__name__)) 1023 1024 try: 1025 from sas.models.RectangularHollowPrismModel import RectangularHollowPrismModel 1026 1027 self.model_dictionary[RectangularHollowPrismModel.__name__] = RectangularHollowPrismModel 1028 # self.shape_list.append(RectangularHollowPrismModel) 1029 self.multiplication_factor.append(RectangularHollowPrismModel) 1030 self.model_name_list.append(RectangularHollowPrismModel.__name__) 1031 except: 1032 logging.error(base_message.format(RectangularHollowPrismModel.__name__)) 1033 1034 try: 1035 from sas.models.MicelleSphCoreModel import MicelleSphCoreModel 1036 1037 self.model_dictionary[MicelleSphCoreModel.__name__] = MicelleSphCoreModel 1038 # self.shape_list.append(MicelleSphCoreModel) 1039 self.multiplication_factor.append(MicelleSphCoreModel) 1040 self.model_name_list.append(MicelleSphCoreModel.__name__) 1041 except: 1042 logging.error(base_message.format(MicelleSphCoreModel.__name__)) 1043 1044 1045 1046 #from sas.models.FractalO_Z import FractalO_Z 1047 #self.model_dictionary[FractalO_Z.__name__] = FractalO_Z 1048 #self.shape_indep_list.append(FractalO_Z) 1049 #self.model_name_list.append(FractalO_Z.__name__) 303 for mod_name in sasmodels.core.list_models(): 304 mod_def = sasmodels.core.load_model_info(mod_name) 305 self.model_dictionary[mod_def['oldname']] = make_class(mod_def,dtype=None,namestyle='oldname') 306 self.model_name_list.append(mod_def['oldname']) 307 if mod_def['structure_factor'] == True: 308 self.struct_list.append(self.model_dictionary[mod_def['oldname']]) 309 if mod_def['variant_info'] is not None: 310 self.multi_func_list.append(self.model_dictionary[mod_def['oldname']]) 311 if mod_def['ER'] is not None: 312 self.multiplication_factor.append(self.model_dictionary[mod_def['oldname']]) 1050 313 1051 314 #Looking for plugins … … 1091 354 return {} 1092 355 1093 def p ulgins_reset(self):356 def plugins_reset(self): 1094 357 """ 1095 358 return a dictionary of model … … 1110 373 return self.model_combobox.get_list() 1111 374 1112 ## I believe the next four methods are for the old form factor GUI1113 ## where the dropdown showed a list of categories which then rolled out1114 ## in a second dropdown to the side. Some testing shows they indeed no longer1115 ## seem to be called. If no problems are found during testing of release we1116 ## can remove this huge chunck of stuff.1117 ##1118 ## -PDB April 26, 20141119 1120 # def populate_menu(self, modelmenu, event_owner):1121 # """1122 # Populate a menu with our models1123 #1124 # :param id: first menu event ID to use when binding the menu events1125 # :param modelmenu: wx.Menu object to populate1126 # :param event_owner: wx object to bind the menu events to1127 #1128 # :return: the next free event ID following the new menu events1129 #1130 # """1131 #1132 ## Fill model lists1133 # self._getModelList()1134 ## store reference to model menu of guiframe1135 # self.modelmenu = modelmenu1136 ## guiframe reference1137 # self.event_owner = event_owner1138 1139 # shape_submenu = wx.Menu()1140 # shape_indep_submenu = wx.Menu()1141 # structure_factor = wx.Menu()1142 # added_models = wx.Menu()1143 # multip_models = wx.Menu()1144 ## create menu with shape1145 # self._fill_simple_menu(menuinfo=["Shapes",1146 # shape_submenu,1147 # " simple shape"],1148 # list1=self.shape_list)1149 1150 # self._fill_simple_menu(menuinfo=["Shape-Independent",1151 # shape_indep_submenu,1152 # "List of shape-independent models"],1153 # list1=self.shape_indep_list)1154 1155 # self._fill_simple_menu(menuinfo=["Structure Factors",1156 # structure_factor,1157 # "List of Structure factors models"],1158 # list1=self.struct_list)1159 1160 # self._fill_plugin_menu(menuinfo=["Customized Models", added_models,1161 # "List of additional models"],1162 # list1=self.plugins)1163 1164 # self._fill_menu(menuinfo=["P(Q)*S(Q)", multip_models,1165 # "mulplication of 2 models"],1166 # list1=self.multiplication_factor,1167 # list2=self.struct_list)1168 # return 01169 1170 # def _fill_plugin_menu(self, menuinfo, list1):1171 # """1172 # fill the plugin menu with costumized models1173 # """1174 # print ("got to fill plugin menu")1175 # if len(list1) == 0:1176 # id = wx.NewId()1177 # msg = "No model available check plugins.log for errors to fix problem"1178 # menuinfo[1].Append(int(id), "Empty", msg)1179 # self._fill_simple_menu(menuinfo, list1)1180 1181 # def _fill_simple_menu(self, menuinfo, list1):1182 # """1183 # Fill the menu with list item1184 #1185 # :param modelmenu: the menu to fill1186 # :param menuinfo: submenu item for the first column of this modelmenu1187 # with info.Should be a list :1188 # [name(string) , menu(wx.menu), help(string)]1189 # :param list1: contains item (form factor )to fill modelmenu second column1190 #1191 # """1192 # if len(list1) > 0:1193 # self.model_combobox.set_list(menuinfo[0], list1)1194 1195 # for item in list1:1196 # try:1197 # id = wx.NewId()1198 # struct_factor = item()1199 # struct_name = struct_factor.__class__.__name__1200 # if hasattr(struct_factor, "name"):1201 # struct_name = struct_factor.name1202 #1203 # menuinfo[1].Append(int(id), struct_name, struct_name)1204 # if not item in self.struct_factor_dict.itervalues():1205 # self.struct_factor_dict[str(id)] = item1206 # wx.EVT_MENU(self.event_owner, int(id), self._on_model)1207 # except:1208 # msg = "Error Occured: %s" % sys.exc_value1209 # wx.PostEvent(self.event_owner, StatusEvent(status=msg))1210 #1211 # id = wx.NewId()1212 # self.modelmenu.AppendMenu(id, menuinfo[0], menuinfo[1], menuinfo[2])1213 #1214 # def _fill_menu(self, menuinfo, list1, list2):1215 # """1216 # Fill the menu with list item1217 #1218 # :param menuinfo: submenu item for the first column of this modelmenu1219 # with info.Should be a list :1220 # [name(string) , menu(wx.menu), help(string)]1221 # :param list1: contains item (form factor )to fill modelmenu second column1222 # :param list2: contains item (Structure factor )to fill modelmenu1223 # third column1224 #1225 # """1226 # if len(list1) > 0:1227 # self.model_combobox.set_list(menuinfo[0], list1)1228 #1229 # for item in list1:1230 # form_factor = item()1231 # form_name = form_factor.__class__.__name__1232 # if hasattr(form_factor, "name"):1233 # form_name = form_factor.name1234 # ### store form factor to return to other users1235 # newmenu = wx.Menu()1236 # if len(list2) > 0:1237 # for model in list2:1238 # id = wx.NewId()1239 # struct_factor = model()1240 # name = struct_factor.__class__.__name__1241 # if hasattr(struct_factor, "name"):1242 # name = struct_factor.name1243 # newmenu.Append(id, name, name)1244 # wx.EVT_MENU(self.event_owner, int(id), self._on_model)1245 # ## save form_fact and struct_fact1246 # self.form_factor_dict[int(id)] = [form_factor,1247 # struct_factor]1248 #1249 # form_id = wx.NewId()1250 # menuinfo[1].AppendMenu(int(form_id), form_name,1251 # newmenu, menuinfo[2])1252 # id = wx.NewId()1253 # self.modelmenu.AppendMenu(id, menuinfo[0], menuinfo[1], menuinfo[2])1254 1255 375 def _on_model(self, evt): 1256 376 """ … … 1268 388 model = self.struct_factor_dict[str(evt.GetId())]() 1269 389 1270 #TODO: investigate why the following two lines were left in the code1271 # even though the ModelEvent class doesn't exist1272 #evt = ModelEvent(model=model)1273 #wx.PostEvent(self.event_owner, evt)1274 390 1275 391 def _get_multifunc_models(self): … … 1345 461 return self.__modelmanager.update() 1346 462 1347 def p ulgins_reset(self):1348 return self.__modelmanager.p ulgins_reset()463 def plugins_reset(self): 464 return self.__modelmanager.plugins_reset() 1349 465 1350 466 def populate_menu(self, modelmenu, event_owner):
Note: See TracChangeset
for help on using the changeset viewer.