Changeset aadf0af1 in sasview for src/sas/qtgui/GuiUtils.py
- Timestamp:
- Jan 4, 2017 2:35:08 AM (7 years ago)
- Branches:
- 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
- Children:
- 570a58f9
- Parents:
- 257bd57
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/GuiUtils.py
r27313b7 raadf0af1 28 28 from periodictable import formula as Formula 29 29 30 from sas.sasgui.plottools import transform 31 from sas.sasgui.plottools.convert_units import convert_unit 30 32 from sas.sasgui.guiframe.dataFitting import Data1D 31 33 from sas.sasgui.guiframe.dataFitting import Data2D … … 584 586 pass 585 587 588 def xyTransform(data, xLabel="", yLabel=""): 589 """ 590 Transforms x and y in View and set the scale 591 """ 592 # Changing the scale might be incompatible with 593 # currently displayed data (for instance, going 594 # from ln to log when all plotted values have 595 # negative natural logs). 596 # Go linear and only change the scale at the end. 597 xscale = 'linear' 598 yscale = 'linear' 599 # Local data is either 1D or 2D 600 if data.id == 'fit': 601 return 602 603 # control axis labels from the panel itself 604 yname, yunits = data.get_yaxis() 605 xname, xunits = data.get_xaxis() 606 607 # Goes through all possible scales 608 # self.x_label is already wrapped with Latex "$", so using the argument 609 610 # X 611 if xLabel == "x": 612 data.transformX(transform.toX, transform.errToX) 613 xLabel = "%s(%s)" % (xname, xunits) 614 if xLabel == "x^(2)": 615 data.transformX(transform.toX2, transform.errToX2) 616 xunits = convert_unit(2, xunits) 617 xLabel = "%s^{2}(%s)" % (xname, xunits) 618 if xLabel == "x^(4)": 619 data.transformX(transform.toX4, transform.errToX4) 620 xunits = convert_unit(4, xunits) 621 xLabel = "%s^{4}(%s)" % (xname, xunits) 622 if xLabel == "ln(x)": 623 data.transformX(transform.toLogX, transform.errToLogX) 624 xLabel = "\ln{(%s)}(%s)" % (xname, xunits) 625 if xLabel == "log10(x)": 626 data.transformX(transform.toX_pos, transform.errToX_pos) 627 xscale = 'log' 628 xLabel = "%s(%s)" % (xname, xunits) 629 if xLabel == "log10(x^(4))": 630 data.transformX(transform.toX4, transform.errToX4) 631 xunits = convert_unit(4, xunits) 632 xLabel = "%s^{4}(%s)" % (xname, xunits) 633 xscale = 'log' 634 635 # Y 636 if yLabel == "ln(y)": 637 data.transformY(transform.toLogX, transform.errToLogX) 638 yLabel = "\ln{(%s)}(%s)" % (yname, yunits) 639 if yLabel == "y": 640 data.transformY(transform.toX, transform.errToX) 641 yLabel = "%s(%s)" % (yname, yunits) 642 if yLabel == "log10(y)": 643 data.transformY(transform.toX_pos, transform.errToX_pos) 644 yscale = 'log' 645 yLabel = "%s(%s)" % (yname, yunits) 646 if yLabel == "y^(2)": 647 data.transformY(transform.toX2, transform.errToX2) 648 yunits = convert_unit(2, yunits) 649 yLabel = "%s^{2}(%s)" % (yname, yunits) 650 if yLabel == "1/y": 651 data.transformY(transform.toOneOverX, transform.errOneOverX) 652 yunits = convert_unit(-1, yunits) 653 yLabel = "1/%s(%s)" % (yname, yunits) 654 if yLabel == "y*x^(2)": 655 data.transformY(transform.toYX2, transform.errToYX2) 656 xunits = convert_unit(2, xunits) 657 yLabel = "%s \ \ %s^{2}(%s%s)" % (yname, xname, yunits, xunits) 658 if yLabel == "y*x^(4)": 659 data.transformY(transform.toYX4, transform.errToYX4) 660 xunits = convert_unit(4, xunits) 661 yLabel = "%s \ \ %s^{4}(%s%s)" % (yname, xname, yunits, xunits) 662 if yLabel == "1/sqrt(y)": 663 data.transformY(transform.toOneOverSqrtX, 664 transform.errOneOverSqrtX) 665 yunits = convert_unit(-0.5, yunits) 666 yLabel = "1/\sqrt{%s}(%s)" % (yname, yunits) 667 if yLabel == "ln(y*x)": 668 data.transformY(transform.toLogXY, transform.errToLogXY) 669 yLabel = "\ln{(%s \ \ %s)}(%s%s)" % (yname, xname, yunits, xunits) 670 if yLabel == "ln(y*x^(2))": 671 data.transformY(transform.toLogYX2, transform.errToLogYX2) 672 xunits = convert_unit(2, xunits) 673 yLabel = "\ln (%s \ \ %s^{2})(%s%s)" % (yname, xname, yunits, xunits) 674 if yLabel == "ln(y*x^(4))": 675 data.transformY(transform.toLogYX4, transform.errToLogYX4) 676 xunits = convert_unit(4, xunits) 677 yLabel = "\ln (%s \ \ %s^{4})(%s%s)" % (yname, xname, yunits, xunits) 678 if yLabel == "log10(y*x^(4))": 679 data.transformY(transform.toYX4, transform.errToYX4) 680 xunits = convert_unit(4, xunits) 681 yscale = 'log' 682 yLabel = "%s \ \ %s^{4}(%s%s)" % (yname, xname, yunits, xunits) 683 684 # Perform the transformation of data in data1d->View 685 data.transformView() 686 687 return (xLabel, yLabel, xscale, yscale) 688 586 689 def dataFromItem(item): 587 690 """
Note: See TracChangeset
for help on using the changeset viewer.