Operations on P1D data
Code: "p1d_operation.py". Programming language: Python DMelt Version 1. Last modified: 12/08/2015. License: Pro
https://datamelt.org/code/cache/p1d_operation_4577.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



from java.awt import Color,Font
from java.util import Random
from jhplot  import *
from math  import sqrt

c1 = HPlot("Canvas",600,400,2, 1)
c1.visible(1)
c1.setAutoRange()

c1.setGTitle("Operations with data", Color.blue) #put title
c1.viewHisto(0) # make sure starts from 0

# fill first data set
p1= P1D("data1")
p1.add(10,100,5,5)
p1.add(20,50,5,5)
p1.add(30,80,5,5)
c1.draw(p1)

# fill second data set
p2= P1D("data2")
p2.add(10,40,5,5)
p2.add(20,40,5,5)
p2.add(30,40,5,5)
c1.draw(p2)

# add with 50% correlations
corr=P1D("correlation coefficients")
corr.add(0,0,0.5,0.5)
corr.add(0,0,0.5,0.5)
corr.add(0,0,0.5,0.5)
# add them. Do not do anything with X
p3=p1.oper(p2,"added with 50% corr.","+","Y",corr)
p3.setColor(Color.blue)
c1.draw(p3)




# show points with statistical errors in  y
c1.cd(2,1)
c1.setAutoRange()
# move to sqrt (only Y)
p1=p1.move("sqrt","Y")
c1.draw(p1)
print p3.size()
# p4.toTable()

You see the box below because you did not login.