Changeset f1181977 in sasview for prview/perspectives/pr
- Timestamp:
- Aug 8, 2008 9:00:56 AM (16 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:
- 0eb801a
- Parents:
- 08b9e586
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
prview/perspectives/pr/pr.py
rea5551f rf1181977 12 12 from sans.pr.invertor import Invertor 13 13 14 PR_FIT_LABEL = "P_{fit}(r)"15 PR_LOADED_LABEL = "P_{loaded}(r)"16 IQ_DATA_LABEL = "I_{obs}(q)"17 IQ_FIT_LABEL = "I_{fit}(q)"18 IQ_SMEARED_LABEL = "I_{smeared}(q)"14 PR_FIT_LABEL = r"$P_{fit}(r)$" 15 PR_LOADED_LABEL = r"$P_{loaded}(r)$" 16 IQ_DATA_LABEL = r"$I_{obs}(q)$" 17 IQ_FIT_LABEL = r"$I_{fit}(q)$" 18 IQ_SMEARED_LABEL = r"$I_{smeared}(q)$" 19 19 20 20 import wx.lib … … 80 80 self._scale_output_unity = False 81 81 82 ## List of added P(r) plots 83 self._added_plots = {} 84 self._default_Iq = {} 85 82 86 # Log startup 83 87 logging.info("Pr(r) plug-in started") … … 318 322 else: 319 323 new_plot = Data1D(x, y, dy=dy) 320 new_plot.name = "P_{fit}(r)"324 new_plot.name = PR_FIT_LABEL 321 325 new_plot.xaxis("\\rm{r}", 'A') 322 326 new_plot.yaxis("\\rm{P(r)} ","cm^{-3}") … … 516 520 self.show_pr(self._last_out, self._last_pr, self._last_cov) 517 521 522 # Now replot the original added data 523 for plot in self._added_plots: 524 self._added_plots[plot].y = numpy.copy(self._default_Iq[plot]) 525 wx.PostEvent(self.parent, NewPlotEvent(plot=self._added_plots[plot], 526 title=self._added_plots[plot].name, 527 update=True)) 528 529 # Need the update flag in the NewPlotEvent to protect against 530 # the plot no longer being there... 531 518 532 def _on_normalize(self, evt): 519 533 """ 520 Switch normalization ON/OFF 534 Normalize the area under the P(r) curve to 1. 535 This operation is done for all displayed plots. 536 521 537 @param evt: Menu event 522 538 """ … … 526 542 self.show_pr(self._last_out, self._last_pr, self._last_cov) 527 543 544 # Now scale the added plots too 545 for plot in self._added_plots: 546 sum = numpy.sum(self._added_plots[plot].y) 547 npts = len(self._added_plots[plot].x) 548 sum *= self._added_plots[plot].x[npts-1]/npts 549 y = self._added_plots[plot].y/sum 550 551 new_plot = Theory1D(self._added_plots[plot].x, y) 552 new_plot.name = self._added_plots[plot].name 553 new_plot.xaxis("\\rm{r}", 'A') 554 new_plot.yaxis("\\rm{P(r)} ","cm^{-3}") 555 556 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, update=True, 557 title=self._added_plots[plot].name)) 558 559 560 528 561 def _on_scale_unity(self, evt): 529 562 """ 530 Switch normalization ON/OFF 563 Scale the maximum P(r) value on each displayed plot to 1. 564 531 565 @param evt: Menu event 532 566 """ … … 535 569 536 570 self.show_pr(self._last_out, self._last_pr, self._last_cov) 571 572 # Now scale the added plots too 573 for plot in self._added_plots: 574 _max = 0 575 for y in self._added_plots[plot].y: 576 if y>_max: 577 _max = y 578 y = self._added_plots[plot].y/_max 579 580 new_plot = Theory1D(self._added_plots[plot].x, y) 581 new_plot.name = self._added_plots[plot].name 582 new_plot.xaxis("\\rm{r}", 'A') 583 new_plot.yaxis("\\rm{P(r)} ","cm^{-3}") 584 585 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, update=True, 586 title=self._added_plots[plot].name)) 587 537 588 538 589 def _on_add_data(self, evt): … … 547 598 x, y, err = self.parent.load_ascii_1D(path) 548 599 600 filename = os.path.basename(path) 601 549 602 #new_plot = Data1D(x, y, dy=err) 550 603 new_plot = Theory1D(x, y) 551 new_plot.name = "P_{loaded}(r)"604 new_plot.name = filename 552 605 new_plot.xaxis("\\rm{r}", 'A') 553 606 new_plot.yaxis("\\rm{P(r)} ","cm^{-3}") 554 607 555 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="P(r) fit")) 608 # Store a ref to the plottable for later use 609 self._added_plots[filename] = new_plot 610 self._default_Iq[filename] = numpy.copy(y) 611 612 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=filename)) 556 613 557 614 … … 653 710 # Make a plot of I(q) data 654 711 new_plot = Data1D(self.pr.x, self.pr.y, dy=self.pr.err) 655 new_plot.name = "I_{obs}(q)"712 new_plot.name = IQ_DATA_LABEL 656 713 new_plot.xaxis("\\rm{Q}", 'A^{-1}') 657 714 new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") … … 689 746 else: 690 747 new_plot = Data1D(self.pr.x, self.pr.y, dy=self.pr.err) 691 new_plot.name = "I_{obs}(q)"748 new_plot.name = IQ_DATA_LABEL 692 749 new_plot.xaxis("\\rm{Q}", 'A^{-1}') 693 750 new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
Note: See TracChangeset
for help on using the changeset viewer.