def Execute(self, device, rect):
     if device.has_radial_gradient:
         self.execute_radial(device, rect)
         return
     steps = device.gradient_steps
     cx, cy = self.center
     cx = cx * rect.right + (1 - cx) * rect.left
     cy = cy * rect.top + (1 - cy) * rect.bottom
     radius = max(
         hypot(rect.left - cx, rect.top - cy),
         hypot(rect.right - cx, rect.top - cy),
         hypot(rect.right - cx, rect.bottom - cy),
         hypot(rect.left - cx, rect.bottom - cy),
     )
     color = self.gradient.ColorAt
     SetFillColor = device.SetFillColor
     FillCircle = device.FillCircle
     SetFillColor(color(0))
     apply(device.FillRectangle, tuple(rect))
     radius = radius * (1.0 - self.border)
     dr = radius / steps
     device.PushTrafo()
     device.Translate(cx, cy)
     center = NullPoint
     for i in range(steps):
         SetFillColor(color(float(i) / (steps - 1)))
         FillCircle(center, radius)
         radius = radius - dr
     device.PopTrafo()
Beispiel #2
0
def main():
    """Image Plane"""
    WIDTH = 320
    HEIGHT = 200
    xMax = 1
    image_centre = vec3d(0, 0, 0)
    image_plane = ImagePlane(image_centre, xMax, WIDTH, HEIGHT)
    image_plane = image_plane.create_an_image_plane()
    """Camera"""
    camera_pos = vec3d(0, 0, -1)
    camera = Camera(camera_pos)
    """Colours"""
    red = color(255, 0, 0)
    yello = color(255, 255, 0)
    green = color(0, 255, 0)
    """Objects"""
    ball_pos = vec3d(0, 0, 0)
    ball_r = 0.5
    ball_material = Material(0.3, 0.9, 5)
    ball1 = Ball(ball_pos, ball_r, red, ball_material)
    balls = [ball1]
    """Lights"""
    lightSource = vec3d(5, 5, -3)
    lightDirection = vec3d(1, 1, -1).get_unit_vec()
    point_light = Light(lightSource, lightDirection)
    """Set Up Stage"""
    IMG = image(WIDTH, HEIGHT)
    stage = Stage(balls, camera, image_plane, point_light)
    stage.rayTracing()
    stage.obtain_depth()
    stage.rendering(IMG)
    IMG.saveImage("ball2.ppm")
Beispiel #3
0
 def Execute(self, device, rect):
     if device.has_radial_gradient:
         self.execute_radial(device, rect)
         return
     steps = device.gradient_steps
     cx, cy = self.center
     cx = cx * rect.right + (1 - cx) * rect.left
     cy = cy * rect.top + (1 - cy) * rect.bottom
     radius = max(hypot(rect.left - cx, rect.top - cy),
                  hypot(rect.right - cx, rect.top - cy),
                  hypot(rect.right - cx, rect.bottom - cy),
                  hypot(rect.left - cx, rect.bottom - cy))
     color = self.gradient.ColorAt
     SetFillColor = device.SetFillColor
     FillCircle = device.FillCircle
     SetFillColor(color(0))
     apply(device.FillRectangle, tuple(rect))
     radius = radius * (1.0 - self.border)
     dr = radius / steps
     device.PushTrafo()
     device.Translate(cx, cy)
     center = NullPoint
     for i in range(steps):
         SetFillColor(color(float(i) / (steps - 1)))
         FillCircle(center, radius)
         radius = radius - dr
     device.PopTrafo()
Beispiel #4
0
def create_data_file(starting_value, button_pin, sensor_pin, led_pin, blue,
                     red, green, counter):
    button = machine.Pin(button_pin, machine.Pin.IN)  #define button pin
    adc33 = ADC(machine.Pin(sensor_pin))  #define sensor pin
    adc33.atten(ADC.ATTN_6DB)  #define adc
    dac26 = DAC(machine.Pin(led_pin))  #define DAC
    dac26.write(starting_value)  #adjust the intensity of the LED
    data = []
    i = 0
    f = open('data' + str(counter), 'w')
    while True:
        time.sleep(1)
        #Take the average of the measurments every 1,2 seconds
        sum = 0
        for i in range(12000):
            if button.value() == 1:
                break
            sum = sum + adc33.read()
            time.sleep(0.01)
        average = sum / 12000
        data.append(average)
        f.write("%s\n" % average)
        print("\n")
        print(average)
        if button.value() == 1:  #button is pressed again
            color("blue", blue, red, green)
            time.sleep(1)
            break
        i = i + 1
    f.close()
def main():
    WIDTH = 200
    HEIGHT = 100
    IMG = image(WIDTH, HEIGHT)
    a = color(100, 100, 255)
    b = color(200, 100, 255)
    color_range = gradient(a, b, HEIGHT)

    for j in range(HEIGHT):
        for i in range(WIDTH):
            IMG.setColor(color_range[j], i, j)
    IMG.saveImage("gradient_result.ppm")
Beispiel #6
0
    def DrawObsArea(self):
        # add points to observed to close area
        # this will disappear
        self.OBS['nominal'].SetPoint(self.OBS['nominal'].GetN(), 1300,-1300)
        self.OBS['nominal'].SetPoint(self.OBS['nominal'].GetN(), -1300,-1300)
        # observed

        trasparentColor = rt.gROOT.GetColor(color(self.OBS['colorArea']))
        trasparentColor.SetAlpha(0.5)
        self.OBS['nominal'].SetFillColor(color(self.OBS['colorArea']))
        self.OBS['nominal'].SetLineStyle(1)
        # DRAW AREAS
        self.OBS['nominal'].Draw("FSAME")
Beispiel #7
0
    def DrawObsArea(self):
        # add points to observed to close area
        # this will disappear
        self.OBS['nominal'].SetPoint(self.OBS['nominal'].GetN(), 1300, -1300)
        self.OBS['nominal'].SetPoint(self.OBS['nominal'].GetN(), -1300, -1300)
        # observed

        trasparentColor = rt.gROOT.GetColor(color(self.OBS['colorArea']))
        #trasparentColor.SetAlpha(0.5)
        self.OBS['nominal'].SetFillColor(color(self.OBS['colorArea']))
        self.OBS['nominal'].SetLineStyle(1)
        # DRAW AREAS
        self.OBS['nominal'].Draw("FSAME")
Beispiel #8
0
def main():
    WIDTH = 320
    HEIGHT = 200

    AspectRatio = aspect(WIDTH, HEIGHT)
    xMax = 1
    xMin = -xMax
    yMax = xMax / AspectRatio
    yMin = -yMax

    camera_pos = vec3d(0, 0, -1)
    ball_pos = vec3d(0, 0, 0)
    ball_r = 0.5
    ball_material = Material(0.2, 0.9, 10)

    point_light = Light(vec3d(5, 5, -1 / 2), vec3d(-1, -1, 1).get_unit_vec())

    red = color(255, 0, 0)
    yello = color(255, 255, 0)
    green = color(0, 255, 0)

    ball1 = Ball(ball_pos, ball_r, red, ball_material)

    image_plane = Plane(ball_pos, xMin, xMax, yMin, yMax, WIDTH, HEIGHT)
    ray_tracing1 = RayTracer(camera_pos, ball1, image_plane)

    IMG = image(WIDTH, HEIGHT)
    for j in range(HEIGHT):
        for i in range(WIDTH):
            single_point = None
            ray_tracing1.ray_direction(i, j)
            ray_tracing1.sphere_to_ray()
            ray_tracing1.ray_sphere_intersection()
            ray_tracing1.hit_pos()
            single_point1 = ray_tracing1.getHit()

            if single_point1 is not None:
                single_point = single_point1

            if single_point is not None:
                if single_point == single_point1:
                    color_point = ball1.getColor(camera_pos,
                                                 single_point,
                                                 point_light.direction,
                                                 k_a=(1 / 3),
                                                 k_d=(1 / 2),
                                                 k_s=(1 / 6))
            else:
                color_point = color(0, 0, 0)
            IMG.setColor(color_point, i, j)
    IMG.saveImage("ball.ppm")
Beispiel #9
0
def raytracing(world, r, depth):
    if (depth <= 0): return color((0, 0, 0))

    hitp, n, obj = world.hit(r)

    if (hitp != None):
        scattered_ray = obj.material.scatter(r, hitp, n)
        if (scattered_ray != None):
            c = raytracing(world, scattered_ray, depth - 1)
        else:
            return color((0, 0, 0))
        attenuation = obj.material.attenuate(hitp)
        return c.mul_colors(attenuation)
    return world.get_background_color(r)
Beispiel #10
0
def experiment(starting_value, button_pin, sensor_pin, led_pin, blue, red,
               green):
    button = machine.Pin(button_pin, machine.Pin.IN)  #define button pin
    adc33 = ADC(machine.Pin(sensor_pin))  #define sensor pin
    adc33.atten(ADC.ATTN_6DB)  #define adc
    dac26 = DAC(machine.Pin(led_pin))  #define DAC
    dac26.write(starting_value)  #adjust the intensity of the LED
    data = []
    i = 0
    counter = 0
    while not count_time(button_pin):
        print("here!!")
        if button.value() == 1:
            color("green", blue, red,
                  green)  #if the experiment runs neopixel gives green color
            if counter < 5:
                create_data_file(starting_value, button_pin, sensor_pin,
                                 led_pin, blue, red, green,
                                 counter)  #create new data file
                counter += 1
            color("purple", blue, red, green)

    color("white", blue, red, green)
    time.sleep(5)
    color("no", blue, red, green)
    #Take the of the measurments every 1,2 seconds
    sum = 0
    for i in range(120):
        if button.value() == 1:
            break
        sum = sum + adc33.read()
        time.sleep(0.01)
    average = sum / 12000
    def DrawLines(self):
        # observed
        self.OBS['nominal'].SetLineColor(color(self.OBS['colorLine']))
        self.OBS['nominal'].SetLineStyle(1)
        self.OBS['nominal'].SetLineWidth(4)
        # observed + 1sigma
        self.OBS['plus'].SetLineColor(color(self.OBS['colorLine']))
        self.OBS['plus'].SetLineStyle(7)
        self.OBS['plus'].SetLineWidth(4)        
        # observed - 1sigma
        self.OBS['minus'].SetLineColor(color(self.OBS['colorLine']))
        self.OBS['minus'].SetLineStyle(7)
        self.OBS['minus'].SetLineWidth(4)        
        # expected + 2sigma
        self.EXP2['plus2'].SetLineColor(color(self.EXP2['colorLine']))
        self.EXP2['plus2'].SetLineStyle(7)
        self.EXP2['plus2'].SetLineWidth(2)                
        # expected + 1sigma
        self.EXP['plus'].SetLineColor(color(self.EXP['colorLine']))
        self.EXP['plus'].SetLineStyle(7)
        self.EXP['plus'].SetLineWidth(4)                
        # expected
        self.EXP['nominal'].SetLineColor(color(self.EXP['colorLine']))
        self.EXP['nominal'].SetLineStyle(1)
        self.EXP['nominal'].SetLineWidth(4)        
        # expected - 2sigma
        self.EXP2['minus2'].SetLineColor(color(self.EXP2['colorLine']))
        self.EXP2['minus2'].SetLineStyle(7)
        self.EXP2['minus2'].SetLineWidth(2)          
        # expected - 1sigma
        self.EXP['minus'].SetLineColor(color(self.EXP['colorLine']))
        self.EXP['minus'].SetLineStyle(7)
        self.EXP['minus'].SetLineWidth(4)                      
        # DRAW LINES
        #self.EXP['nominal'].Draw("LSAME")
        #self.EXP2['plus2'].Draw("LSAME")
        #self.EXP2['minus2'].Draw("LSAME")

        #self.OBS['plus'].Draw("LSAME")
        #self.OBS['minus'].Draw("LSAME")    
        #self.EXP['plus'].Draw("LSAME")
        #self.EXP['minus'].Draw("LSAME")
        #self.OBS['nominal'].Draw("LSAME")
        #self.OBS['plus'].Draw("LSAME")
        #self.OBS['minus'].Draw("LSAME")
        #self.EXP['plus'].Draw("LSAME")
        #self.EXP['nominal'].Draw("LSAME")
        #self.OBS['plus'].Draw("LSAME")
        #self.EXP['plus'].Draw("LSAME")
        #self.OBS['plus'].Draw("LSAME")
        #self.OBS['nominal'].Draw("LSAME") 

        self.EXP['minus'].Draw("LSAME")
        self.EXP['nominal'].SetMarkerStyle(20);
        self.EXP['nominal'].Draw("lSAME")
        self.EXP['plus'].Draw("LSAME")
    
        self.OBS['minus'].Draw("LSAME")
        self.OBS['nominal'].Draw("LSAME")
        self.OBS['plus'].Draw("LSAME")
Beispiel #12
0
 def DrawLines(self):
     ## observed
     #self.OBS['nominal'].SetLineColor(color(self.OBS['colorLine']))
     #self.OBS['nominal'].SetLineStyle(1)
     #self.OBS['nominal'].SetLineWidth(0)
     ## observed + 1sigma
     #self.OBS['plus'].SetLineColor(color(self.OBS['colorLine']))
     #self.OBS['plus'].SetLineStyle(1)
     #self.OBS['plus'].SetLineWidth(0)
     ## observed - 1sigma
     #self.OBS['minus'].SetLineColor(color(self.OBS['colorLine']))
     #self.OBS['minus'].SetLineStyle(1)
     #self.OBS['minus'].SetLineWidth(0)
     ## expected + 1sigma
     #self.EXP['plus'].SetLineColor(color(self.EXP['colorLine']))
     #self.EXP['plus'].SetLineStyle(7)
     #self.EXP['plus'].SetLineWidth(2)
     ## expected
     self.EXP['nominal'].SetLineColor(color(self.EXP['colorLine']))
     self.EXP['nominal'].SetLineStyle(7)
     self.EXP['nominal'].SetLineWidth(4)
     ## expected - 1sigma
     #self.EXP['minus'].SetLineColor(color(self.EXP['colorLine']))
     #self.EXP['minus'].SetLineStyle(7)
     #self.EXP['minus'].SetLineWidth(2)
     ## DRAW LINES
     self.EXP['nominal'].Draw("LSAME")
 def DrawLines(self):
     # sig1
     self.SIG1['nominal'].SetLineColor(color(self.SIG1['colorLine']))
     self.SIG1['nominal'].SetLineStyle(1)
     self.SIG1['nominal'].SetLineWidth(3)
     # sig2
     self.SIG2['nominal'].SetLineColor(color(self.SIG2['colorLine']))
     self.SIG2['nominal'].SetLineStyle(1)
     self.SIG2['nominal'].SetLineWidth(3)
     # sig3
     self.SIG3['nominal'].SetLineColor(color(self.SIG3['colorLine']))
     self.SIG3['nominal'].SetLineStyle(1)
     self.SIG3['nominal'].SetLineWidth(3)
     # DRAW LINES
     self.SIG3['nominal'].Draw("LSAME")
     self.SIG2['nominal'].Draw("LSAME")
     self.SIG1['nominal'].Draw("LSAME")
Beispiel #14
0
def main():
    """Image Plane"""
    WIDTH = 320
    HEIGHT = 200
    xMax = 1
    image_centre = vec3d(0, 0, -1 / 4)
    image_plane = ImagePlane(image_centre, xMax, WIDTH, HEIGHT)
    image_plane = image_plane.create_an_image_plane()
    """Camera"""
    camera_pos = vec3d(0, 0, -1)
    camera = Camera(camera_pos)
    """Colours"""
    red = color(255, 0, 0)
    yello = color(50, 50, 0)
    green = color(0, 255, 0)
    blue = color(0, 0, 255)
    """Objects"""
    balls = []
    ball_r = 0.6
    ball_material = Material(1, 0, 0)
    blue_ball = Ball(vec3d(0.25, 0.1, 1), ball_r, blue, ball_material)
    # pink_ball = Ball(vec3d(-0.75, 0.1, 2.25), ball_r, red, ball_material)
    # ground = Ball(vec3d(0, -10002, 1), 10000.0, yello, ball_material)
    balls.append(blue_ball)
    # balls.append(pink_ball)
    # balls.append(ground)
    """Lights"""
    lightSource1 = vec3d(5, 5, -3)
    lightDirection1 = vec3d(1.5, -0.5, -10.0).get_unit_vec()
    # point_light1 = Light(lightSource, lightDirection)
    lightSource2 = vec3d(5, 5, -3)
    lightDirection2 = vec3d(-0.5, -10.5, 0.0).get_unit_vec()
    # point_light2 = Light(lightSource, lightDirection)
    total_light = Light((lightSource1 + lightSource2),
                        (lightDirection1 + lightDirection2))
    """Set Up Stage"""
    IMG = image(WIDTH, HEIGHT)
    stage = Stage(balls, camera, image_plane, total_light)
    stage.rayTracing()
    stage.obtain_depth()
    stage.rendering(IMG)
    IMG.saveImage("standard.ppm")
Beispiel #15
0
 def DrawLines(self):
     # observed
     self.OBS["nominal"].SetLineColor(color(self.OBS["colorLine"]))
     self.OBS["nominal"].SetLineStyle(1)
     self.OBS["nominal"].SetLineWidth(4)
     # observed + 1sigma
     self.OBS["plus"].SetLineColor(color(self.OBS["colorLine"]))
     self.OBS["plus"].SetLineStyle(1)
     self.OBS["plus"].SetLineWidth(2)
     # observed - 1sigma
     self.OBS["minus"].SetLineColor(color(self.OBS["colorLine"]))
     self.OBS["minus"].SetLineStyle(1)
     self.OBS["minus"].SetLineWidth(2)
     # expected + 1sigma
     self.EXP["plus"].SetLineColor(color(self.EXP["colorLine"]))
     self.EXP["plus"].SetLineStyle(7)
     self.EXP["plus"].SetLineWidth(2)
     # expected
     self.EXP["nominal"].SetLineColor(color(self.EXP["colorLine"]))
     self.EXP["nominal"].SetLineStyle(7)
     self.EXP["nominal"].SetLineWidth(4)
     # expected - 1sigma
     self.EXP["minus"].SetLineColor(color(self.EXP["colorLine"]))
     self.EXP["minus"].SetLineStyle(7)
     self.EXP["minus"].SetLineWidth(2)
     # DRAW LINES
     self.EXP["nominal"].Draw("LSAME")
     self.EXP["plus"].Draw("LSAME")
     self.EXP["minus"].Draw("LSAME")
     self.OBS["nominal"].Draw("LSAME")
     self.OBS["plus"].Draw("LSAME")
     self.OBS["minus"].Draw("LSAME")
Beispiel #16
0
 def DrawLines(self):
     # observed
     self.OBS['nominal'].SetLineColor(color(self.OBS['colorLine']))
     self.OBS['nominal'].SetLineStyle(1)
     self.OBS['nominal'].SetLineWidth(4)
     # observed + 1sigma
     self.OBS['plus'].SetLineColor(color(self.OBS['colorLine']))
     self.OBS['plus'].SetLineStyle(1)
     self.OBS['plus'].SetLineWidth(2)        
     # observed - 1sigma
     self.OBS['minus'].SetLineColor(color(self.OBS['colorLine']))
     self.OBS['minus'].SetLineStyle(1)
     self.OBS['minus'].SetLineWidth(2)        
     # expected + 1sigma
     self.EXP['plus'].SetLineColor(color(self.EXP['colorLine']))
     self.EXP['plus'].SetLineStyle(2)
     self.EXP['plus'].SetLineWidth(2)                
     # expected
     self.EXP['nominal'].SetLineColor(color(self.EXP['colorLine']))
     self.EXP['nominal'].SetLineStyle(2)
     self.EXP['nominal'].SetLineWidth(4)        
     # expected - 1sigma
     self.EXP['minus'].SetLineColor(color(self.EXP['colorLine']))
     self.EXP['minus'].SetLineStyle(2)
     self.EXP['minus'].SetLineWidth(2)                        
     # DRAW LINES
     self.EXP['nominal'].Draw("LSAME")
     self.EXP['plus'].Draw("LSAME")
     self.EXP['minus'].Draw("LSAME")
     self.OBS['nominal'].Draw("LSAME")
     self.OBS['plus'].Draw("LSAME")
     self.OBS['minus'].Draw("LSAME")        
    def DrawLines(self):
        # observed
        self.OBS['nominal'].SetLineColor(1)
        self.OBS['nominal'].SetLineStyle(1)
        self.OBS['nominal'].SetLineWidth(4)
        # observed + 1sigma
        self.OBS['plus'].SetLineColor(1)
        self.OBS['plus'].SetLineWidth(2)
        self.OBS['plus'].SetLineStyle(1)
        # observed - 1sigma
        self.OBS['minus'].SetLineColor(1)
        self.OBS['minus'].SetLineWidth(2)
        self.OBS['minus'].SetLineStyle(1)
        # expected
        self.EXP['nominal'].SetLineColor(1)
        self.EXP['nominal'].SetLineWidth(4)
        self.EXP['nominal'].SetLineStyle(2)
        # build one graph summing the + and - 1 sigma
        nP = self.EXP['plus'].GetN()
        nM = self.EXP['minus'].GetN()
        sigmaBandX = []
        sigmaBandY = []
        for i in range(0, nP):
            sigmaBandX.append(rt.Double(0.))
            sigmaBandY.append(rt.Double(0.))
            self.EXP['plus'].GetPoint(i, sigmaBandX[i], sigmaBandY[i])
        for i in range(0, nM):
            sigmaBandX.append(rt.Double(0.))
            sigmaBandY.append(rt.Double(0.))
            #self.EXP['minus'].GetPoint(i, sigmaBandX[i+nP], sigmaBandY[i+nP])
        for i in range(0, nM):
            self.EXP['minus'].GetPoint(i, sigmaBandX[nP + nM - i - 1],
                                       sigmaBandY[nP + nM - i - 1])
        sigmaBand = rt.TGraph(nP + nM, array('d', sigmaBandX),
                              array('d', sigmaBandY))
        #sigmaBand.SetFillStyle(3001)
        sigmaBand.SetFillColor(color(self.EXP['colorArea']))
        sigmaBand.Draw("FSAME")
        self.c.sigmaBand = sigmaBand

        # expected + 1sigma
        self.EXP['plus'].SetLineColor(1)
        self.EXP['plus'].SetLineStyle(3)
        # expected - 1sigma
        self.EXP['minus'].SetLineColor(1)
        self.EXP['minus'].SetLineStyle(3)
        # DRAW LINES
        self.OBS['nominal'].Draw("LSAME")
        self.OBS['plus'].Draw("LSAME")
        self.OBS['minus'].Draw("LSAME")
        self.EXP['nominal'].Draw("LSAME")
Beispiel #18
0
 def rendering(self, final_image):
     for j in range(final_image.height):
         for i in range(final_image.width):
             color_point = color(0, 0, 0)
             local_depth = self.z_buffer.getValue(i, j)
             for k in range(len(self.ray_tracer)):
                 self.ray_tracer[k].ray_direction(i, j)
                 self.ray_tracer[k].sphere_to_ray()
                 self.ray_tracer[k].ray_sphere_intersection()
                 self.ray_tracer[k].hit_pos()
                 hit_point = self.ray_tracer[k].getHit()
                 if local_depth is not None and hit_point is not None:
                     if hit_point.z == local_depth.z:
                         color_point = self.objects[k].getColor(
                             self.camera.getPos(),
                             hit_point,
                             self.lights.direction,
                             k_a=(1 / 12),
                             k_d=(1 / 3),
                             k_s=(7 / 12))
                 else:
                     color_point = color(0, 0, 0)
             final_image.setColor(color_point, i, j)
Beispiel #19
0
    def DrawLines(self):
        # observed
        self.OBS["nominal"].SetLineColor(1)
        self.OBS["nominal"].SetLineStyle(1)
        self.OBS["nominal"].SetLineWidth(4)
        # observed + 1sigma
        self.OBS["plus"].SetLineColor(1)
        self.OBS["plus"].SetLineWidth(2)
        self.OBS["plus"].SetLineStyle(1)
        # observed - 1sigma
        self.OBS["minus"].SetLineColor(1)
        self.OBS["minus"].SetLineWidth(2)
        self.OBS["minus"].SetLineStyle(1)
        # expected
        self.EXP["nominal"].SetLineColor(1)
        self.EXP["nominal"].SetLineWidth(4)
        self.EXP["nominal"].SetLineStyle(2)
        # build one graph summing the + and - 1 sigma
        nP = self.EXP["plus"].GetN()
        nM = self.EXP["minus"].GetN()
        sigmaBandX = []
        sigmaBandY = []
        for i in range(0, nP):
            sigmaBandX.append(rt.Double(0.0))
            sigmaBandY.append(rt.Double(0.0))
            self.EXP["plus"].GetPoint(i, sigmaBandX[i], sigmaBandY[i])
        for i in range(0, nM):
            sigmaBandX.append(rt.Double(0.0))
            sigmaBandY.append(rt.Double(0.0))
            # self.EXP['minus'].GetPoint(i, sigmaBandX[i+nP], sigmaBandY[i+nP])
        for i in range(0, nM):
            self.EXP["minus"].GetPoint(i, sigmaBandX[nP + nM - i - 1], sigmaBandY[nP + nM - i - 1])
        sigmaBand = rt.TGraph(nP + nM, array("d", sigmaBandX), array("d", sigmaBandY))
        # sigmaBand.SetFillStyle(3001)
        sigmaBand.SetFillColor(color(self.EXP["colorArea"]))
        sigmaBand.Draw("FSAME")
        self.c.sigmaBand = sigmaBand

        # expected + 1sigma
        self.EXP["plus"].SetLineColor(1)
        self.EXP["plus"].SetLineStyle(3)
        # expected - 1sigma
        self.EXP["minus"].SetLineColor(1)
        self.EXP["minus"].SetLineStyle(3)
        # DRAW LINES
        self.OBS["nominal"].Draw("LSAME")
        self.OBS["plus"].Draw("LSAME")
        self.OBS["minus"].Draw("LSAME")
        self.EXP["nominal"].Draw("LSAME")
Beispiel #20
0
    def DrawLines(self):
        # observed
        self.OBS['nominal'].SetLineColor(color(self.OBS['colorLine']))
        self.OBS['nominal'].SetLineStyle(1)
        self.OBS['nominal'].SetLineWidth(4)
        # observed + 1sigma
        self.OBS['plus'].SetLineColor(color(self.OBS['colorLine']))
        self.OBS['plus'].SetLineStyle(1)
        self.OBS['plus'].SetLineWidth(2)
        # observed - 1sigma
        self.OBS['minus'].SetLineColor(color(self.OBS['colorLine']))
        self.OBS['minus'].SetLineStyle(1)
        self.OBS['minus'].SetLineWidth(2)
        # expected + 1sigma
        self.EXP['plus'].SetLineColor(color(self.EXP['colorLine']))
        self.EXP['plus'].SetLineStyle(7)
        self.EXP['plus'].SetLineWidth(2)
        # expected
        self.EXP['nominal'].SetLineColor(color(self.EXP['colorLine']))
        self.EXP['nominal'].SetLineStyle(7)
        self.EXP['nominal'].SetLineWidth(4)
        # expected - 1sigma
        self.EXP['minus'].SetLineColor(color(self.EXP['colorLine']))
        self.EXP['minus'].SetLineStyle(7)
        self.EXP['minus'].SetLineWidth(2)

        do2sigma = "exp2sigma" in self.model.__dict__ and self.model.exp2sigma
        if do2sigma:
            self.EXP['plus2'].SetLineColor(color(self.EXP['colorLine']))
            self.EXP['plus2'].SetLineStyle(3)
            self.EXP['plus2'].SetLineWidth(2)
            self.EXP['minus2'].SetLineColor(color(self.EXP['colorLine']))
            self.EXP['minus2'].SetLineStyle(3)
            self.EXP['minus2'].SetLineWidth(2)

        # DRAW LINES
        self.EXP['nominal'].Draw("LSAME")
        self.EXP['plus'].Draw("LSAME")
        self.EXP['minus'].Draw("LSAME")
        if do2sigma:
            self.EXP['plus2'].Draw("LSAME")
            self.EXP['minus2'].Draw("LSAME")
        self.OBS['nominal'].Draw("LSAME")
        self.OBS['plus'].Draw("LSAME")
        self.OBS['minus'].Draw("LSAME")
Beispiel #21
0
def parseText(text):
    text = text.lower(); #lower case it to avoid issues with capitalisation
    sentence = nltk.word_tokenize(text);  #split the input into a list of words for processing.
    red = 0.0;
    blue = 0.0;
    green = 0.0;
    colorfound = 0;
        #find if any of our words match a color
    for word in sentence:
        for bcolor in baseColors: 
            if word == bcolor[0]:
                colorfound += 1;
                if (colorfound > 1): #if multiple colors match, we sorta average between them.
                    red = (red+bcolor[1])/colorfound;
                    green = (green+bcolor[2])/colorfound;
                    blue = (blue+bcolor[3])/colorfound;
                else:
                    red = bcolor[1];
                    green = bcolor[2];
                    blue = bcolor[3];
                
        #if any words match a brightness word    
    for word in sentence:
        for adj in brightnessAdjectives:
            if word == adj[0]:
                red = max(min(red+adj[1], 1.0), 0.0) #clamp between 0.0 and 1.0
                green = max(min(green+adj[1], 1.0), 0.0)
                blue = max(min(blue+adj[1], 1.0), 0.0)
                
        #if any words match a saturation word...
    for word in sentence:
        for adj in saturationAdjectives:
            if word == adj[0]: 
                red = max(min(red*adj[1], 1.0), 0.0) #clamp between 0.0 and 1.0
                green = max(min(green*adj[1], 1.0), 0.0)
                blue = max(min(blue*adj[1], 1.0), 0.0)
                

    if (colorfound == 0):
        raise NameError('ColorNotFound');
                
    return color(red, green, blue);
Beispiel #22
0
 def DrawLines(self):
     # observed
     try:
         self.OBS['nominal'].SetLineColor(color(self.OBS['colorLine']))
         self.OBS['nominal'].SetLineStyle(1)
         self.OBS['nominal'].SetLineWidth(4)
         # observed + 1sigma
         self.OBS['plus'].SetLineColor(color(self.OBS['colorLine']))
         self.OBS['plus'].SetLineStyle(1)
         self.OBS['plus'].SetLineWidth(2)
         # observed - 1sigma
         self.OBS['minus'].SetLineColor(color(self.OBS['colorLine']))
         self.OBS['minus'].SetLineStyle(1)
         self.OBS['minus'].SetLineWidth(2)
     except TypeError:  # if no observed limit
         pass
     # expected + 2sigma
     #self.EXP2['plus2'].SetLineColor(color(self.EXP2['colorLine']))
     #self.EXP2['plus2'].SetLineStyle(7)
     #self.EXP2['plus2'].SetLineWidth(2)
     # expected + 1sigma
     self.EXP['plus'].SetLineColor(color(self.EXP['colorLine']))
     self.EXP['plus'].SetLineStyle(7)
     self.EXP['plus'].SetLineWidth(2)
     # expected
     self.EXP['nominal'].SetLineColor(color(self.EXP['colorLine']))
     self.EXP['nominal'].SetLineStyle(7)
     self.EXP['nominal'].SetLineWidth(4)
     # expected - 2sigma
     #self.EXP2['minus2'].SetLineColor(color(self.EXP2['colorLine']))
     #self.EXP2['minus2'].SetLineStyle(7)
     #self.EXP2['minus2'].SetLineWidth(2)
     # expected - 1sigma
     self.EXP['minus'].SetLineColor(color(self.EXP['colorLine']))
     self.EXP['minus'].SetLineStyle(7)
     self.EXP['minus'].SetLineWidth(2)
     # DRAW LINES
     self.EXP['nominal'].Draw("LSAME")
     #self.EXP2['plus2'].Draw("LSAME")
     #self.EXP2['minus2'].Draw("LSAME")
     self.EXP['plus'].Draw("LSAME")
     self.EXP['minus'].Draw("LSAME")
     try:
         self.OBS['nominal'].Draw("LSAME")
         self.OBS['plus'].Draw("LSAME")
         self.OBS['minus'].Draw("LSAME")
     except TypeError:  # if no observed limit
         pass
Beispiel #23
0
 def DrawLines(self):
     # observed
     for obs in self.OBS['nominal']:
         obs.SetLineColor(color(self.OBS['colorLine']))
         obs.SetLineStyle(1)
         obs.SetLineWidth(4)
     # observed + 1sigma
     for obs in self.OBS['plus']:
         obs.SetLineColor(color(self.OBS['colorLine']))
         obs.SetLineStyle(1)
         obs.SetLineWidth(2)
     # observed - 1sigma
     for obs in self.OBS['minus']:
         obs.SetLineColor(color(self.OBS['colorLine']))
         obs.SetLineStyle(1)
         obs.SetLineWidth(2)
     # expected + 1sigma
     for exp in self.EXP['plus']:
         exp.SetLineColor(color(self.EXP['colorLine']))
         exp.SetLineStyle(7)
         exp.SetLineWidth(2)
     # expected
     for exp in self.EXP['nominal']:
         exp.SetLineColor(color(self.EXP['colorLine']))
         exp.SetLineStyle(7)
         exp.SetLineWidth(4)
     # expected - 1sigma
     for exp in self.EXP['minus']:
         exp.SetLineColor(color(self.EXP['colorLine']))
         exp.SetLineStyle(7)
         exp.SetLineWidth(2)
     # DRAW LINES
     for exp in self.EXP['nominal']:
         exp.Draw("LSAME")
     for exp in self.EXP['plus']:
         exp.Draw("LSAME")
     for exp in self.EXP['minus']:
         exp.Draw("LSAME")
     for obs in self.OBS['nominal']:
         obs.Draw("LSAME")
     for obs in self.OBS['plus']:
         obs.Draw("LSAME")
     for obs in self.OBS['minus']:
         obs.Draw("LSAME")
Beispiel #24
0
def printDictList(d, color = lambda x : x, lvl = 0):
	"Auxiliar for printing complex structures like list and dictionaries"
	ret = []
	lvl_string = '  '
	if type(d) is dict:
		ret.append('%s{' % (lvl*lvl_string))
		for i in d.iteritems():
			ret.append('%s%s : %s' % ((lvl+1)*lvl_string, green(i[0]), printDictList(i[1], color, lvl + 1)))
		ret.append('%s}' % (lvl*lvl_string))
		return '\n'.join(ret)
	elif type(d) is list:
		ret.append('%s[' % (lvl*lvl_string))
		for l in [printDictList(i, color, lvl + 1) for i in d]:
			ret.append('%s%s' % ((lvl+1)*lvl_string, l))
		ret.append('%s]' % (lvl*lvl_string))
		return '\n'.join(ret)
	elif type(d) is tuple:
		ret.append('%s(' % (lvl*lvl_string))
		for l in [printDictList(i, color, lvl + 1) for i in d]:
			ret.append('%s%s' % ((lvl+1)*lvl_string, l))
		ret.append('%s)' % (lvl*lvl_string))
		return '\n'.join(ret)
	else:
		return color(str(d))
Beispiel #25
0
 def DrawLines(self):
     # observed
     if self.OBS:
        doOBS = True
        if 'nominal_base' in self.OBS:
           doOBS = False
           self.OBS['nominal_base'].SetLineColor(color(self.OBS['colorLine']))
           self.OBS['nominal_base'].SetLineStyle(1)
           self.OBS['nominal_base'].SetLineWidth(4)
        if 'nominal_extra' in self.OBS:
           doOBS = False
           self.OBS['nominal_extra'].SetLineColor(color(self.OBS['colorLine']))
           self.OBS['nominal_extra'].SetLineStyle(1)
           self.OBS['nominal_extra'].SetLineWidth(4)
        if doOBS and 'nominal' in self.OBS:
           self.OBS['nominal'].SetLineColor(color(self.OBS['colorLine']))
           self.OBS['nominal'].SetLineStyle(1)
           self.OBS['nominal'].SetLineWidth(4)
        # observed + 1sigma
        doOBSplus = True
        if 'plus_base' in self.OBS:
           doOBSplus = False
           self.OBS['plus_base'].SetLineColor(color(self.OBS['colorLine']))
           self.OBS['plus_base'].SetLineStyle(1)
           self.OBS['plus_base'].SetLineWidth(2)        
        if 'plus_extra' in self.OBS:
           doOBSplus = False
           self.OBS['plus_extra'].SetLineColor(color(self.OBS['colorLine']))
           self.OBS['plus_extra'].SetLineStyle(1)
           self.OBS['plus_extra'].SetLineWidth(2)        
        if doOBSplus and 'plus' in self.OBS:
           self.OBS['plus'].SetLineColor(color(self.OBS['colorLine']))
           self.OBS['plus'].SetLineStyle(1)
           self.OBS['plus'].SetLineWidth(2)        
        # observed - 1sigma
        doOBSminus = True
        if 'minus_base' in self.OBS:
           doOBSminus = False
           self.OBS['minus_base'].SetLineColor(color(self.OBS['colorLine']))
           self.OBS['minus_base'].SetLineStyle(1)
           self.OBS['minus_base'].SetLineWidth(2)        
        if 'minus_extra' in self.OBS:
           doOBSminus = False
           self.OBS['minus_extra'].SetLineColor(color(self.OBS['colorLine']))
           self.OBS['minus_extra'].SetLineStyle(1)
           self.OBS['minus_extra'].SetLineWidth(2)        
        if doOBSminus and 'minus' in self.OBS:
           self.OBS['minus'].SetLineColor(color(self.OBS['colorLine']))
           self.OBS['minus'].SetLineStyle(1)
           self.OBS['minus'].SetLineWidth(2)        
     if self.EXP:
        # expected + 1sigma
        doEXPplus = True
        if 'plus_base' in self.EXP:
           doEXPplus = False
           self.EXP['plus_base'].SetLineColor(color(self.EXP['colorLine']))
           self.EXP['plus_base'].SetLineStyle(7)
           self.EXP['plus_base'].SetLineWidth(2)
        if 'plus_extra' in self.EXP:
           doEXPplus = False
           self.EXP['plus_extra'].SetLineColor(color(self.EXP['colorLine']))
           self.EXP['plus_extra'].SetLineStyle(7)
           self.EXP['plus_extra'].SetLineWidth(2)
        if doEXPplus and 'plus' in self.EXP:  
           self.EXP['plus'].SetLineColor(color(self.EXP['colorLine']))
           self.EXP['plus'].SetLineStyle(7)
           self.EXP['plus'].SetLineWidth(2)                
        # expected
        doEXP = True
        if 'nominal_base' in self.EXP:
           doEXP = False
           self.EXP['nominal_base'].SetLineColor(color(self.EXP['colorLine']))
           self.EXP['nominal_base'].SetLineStyle(7)
           self.EXP['nominal_base'].SetLineWidth(4)
        if 'nominal_extra' in self.EXP:
           doEXP = False
           self.EXP['nominal_extra'].SetLineColor(color(self.EXP['colorLine']))
           self.EXP['nominal_extra'].SetLineStyle(7)
           self.EXP['nominal_extra'].SetLineWidth(4)
        if doEXP and 'nominal' in self.EXP:
           self.EXP['nominal'].SetLineColor(color(self.EXP['colorLine']))
           self.EXP['nominal'].SetLineStyle(7)
           self.EXP['nominal'].SetLineWidth(4)
        # expected - 1sigma
        doEXPminus = True
        if 'minus_base' in self.EXP:
           doEXPminus = False
           self.EXP['minus_base'].SetLineColor(color(self.EXP['colorLine']))
           self.EXP['minus_base'].SetLineStyle(7)
           self.EXP['minus_base'].SetLineWidth(2)
        if 'minus_extra' in self.EXP:
           doEXPminus = False
           self.EXP['minus_extra'].SetLineColor(color(self.EXP['colorLine']))
           self.EXP['minus_extra'].SetLineStyle(7)
           self.EXP['minus_extra'].SetLineWidth(2)
        if doEXPminus and 'minus' in self.EXP:  
           self.EXP['minus'].SetLineColor(color(self.EXP['colorLine']))
           self.EXP['minus'].SetLineStyle(7)
           self.EXP['minus'].SetLineWidth(2)                
     # DRAW LINES
     if self.OBS:
        if 'nominal_base' in self.OBS: self.OBS['nominal_base'].Draw("LSAME")
        if 'nominal_extra' in self.OBS: self.OBS['nominal_extra'].Draw("LSAME")
        if doOBS and 'nominal' in self.OBS: self.OBS['nominal'].Draw("LSAME")
        
        if 'plus_base' in self.OBS: self.OBS['plus_base'].Draw("LSAME")
        if 'plus_extra' in self.OBS: self.OBS['plus_extra'].Draw("LSAME")
        if doOBSplus and 'plus' in self.OBS: self.OBS['plus'].Draw("LSAME")
        
        if 'minus_base' in self.OBS: self.OBS['minus_base'].Draw("LSAME")
        if 'minus_extra' in self.OBS: self.OBS['minus_extra'].Draw("LSAME")
        if doOBSminus and 'minus' in self.OBS: self.OBS['minus'].Draw("LSAME")
     
     if self.EXP:   
        if 'nominal_base' in self.EXP: self.EXP['nominal_base'].Draw("LSAME")
        if 'nominal_extra' in self.EXP: self.EXP['nominal_extra'].Draw("LSAME")
        if doEXP and 'nominal' in self.EXP: self.EXP['nominal'].Draw("LSAME")
        
        if 'plus_base' in self.EXP: self.EXP['plus_base'].Draw("LSAME")
        if 'plus_extra' in self.EXP: self.EXP['plus_extra'].Draw("LSAME")
        if doEXPplus and 'plus' in self.EXP: self.EXP['plus'].Draw("LSAME")
        
        if 'minus_base' in self.EXP: self.EXP['minus_base'].Draw("LSAME")
        if 'minus_extra' in self.EXP: self.EXP['minus_extra'].Draw("LSAME")
        if doEXPminus and 'minus' in self.EXP: self.EXP['minus'].Draw("LSAME")
Beispiel #26
0
    def DrawLegend(self):
        if(self.model.label2 == ""):
            offset = 0
        else:
            offset = -25
        xRange = self.model.Xmax-self.model.Xmin
        yRange = self.model.Ymax-self.model.Ymin
        
        LObs = rt.TGraph(2)
        LObs.SetName("LObs")
        LObs.SetTitle("LObs")
        if self.OBS: LObs.SetLineColor(color(self.OBS['colorLine']))
        LObs.SetLineStyle(1)
        LObs.SetLineWidth(4)
        LObs.SetMarkerStyle(20)
        LObs.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.35*yRange/100*10+offset)
        LObs.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.35*yRange/100*10+offset)

        LObsP = rt.TGraph(2)
        LObsP.SetName("LObsP")
        LObsP.SetTitle("LObsP")
        if self.OBS: LObsP.SetLineColor(color(self.OBS['colorLine']))
        LObsP.SetLineStyle(1)
        LObsP.SetLineWidth(2)
        LObsP.SetMarkerStyle(20)
        LObsP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.20*yRange/100*10+offset)
        LObsP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.20*yRange/100*10+offset)

        LObsM = rt.TGraph(2)
        LObsM.SetName("LObsM")
        LObsM.SetTitle("LObsM")
        if self.OBS: LObsM.SetLineColor(color(self.OBS['colorLine']))
        LObsM.SetLineStyle(1)
        LObsM.SetLineWidth(2)
        LObsM.SetMarkerStyle(20)
        LObsM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset)
        LObsM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset)

        textObs = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset, "Observed #pm 1 #sigma_{theory}")
        textObs.SetTextFont(42)
        textObs.SetTextSize(0.040)
        textObs.Draw()
        self.c.textObs = textObs

        if self.model.label2 == "T2tb":
           extraModelLabel1 = rt.TLatex(self.model.Xmin+65*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset, "m_{#tilde{#chi}^{#pm}_{1}} - m_{#tilde{#chi}^{0}_{1}} = 5 GeV")
           extraModelLabel1.SetTextFont(42)
           extraModelLabel1.SetTextSize(0.030)
           extraModelLabel1.Draw()
           self.c.extraModelLabel1 = extraModelLabel1

        LExpP = rt.TGraph(2)
        LExpP.SetName("LExpP")
        LExpP.SetTitle("LExpP")
        if self.EXP: LExpP.SetLineColor(color(self.EXP['colorLine']))
        LExpP.SetLineStyle(7)
        LExpP.SetLineWidth(2)  
        LExpP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.85*yRange/100*10+offset)
        LExpP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.85*yRange/100*10+offset)

        LExp = rt.TGraph(2)
        LExp.SetName("LExp")
        LExp.SetTitle("LExp")
        if self.EXP: LExp.SetLineColor(color(self.EXP['colorLine']))
        LExp.SetLineStyle(7)
        LExp.SetLineWidth(4)
        LExp.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-2.00*yRange/100*10+offset)
        LExp.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-2.00*yRange/100*10+offset)
        
        LExpM = rt.TGraph(2)
        LExpM.SetName("LExpM")
        LExpM.SetTitle("LExpM")
        if self.EXP: LExpM.SetLineColor(color(self.EXP['colorLine']))
        LExpM.SetLineStyle(7)
        LExpM.SetLineWidth(2)  
        LExpM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-2.15*yRange/100*10+offset)
        LExpM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-2.15*yRange/100*10+offset)

        textExp = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-2.15*yRange/100*10+offset, "Expected #pm 1 #sigma_{experiment}")
        textExp.SetTextFont(42)
        textExp.SetTextSize(0.040)
        textExp.Draw()
        self.c.textExp = textExp

        if self.model.label2 == "T2tb":
           extraModelLabel2 = rt.TLatex(self.model.Xmin+65*xRange/100, self.model.Ymax-2.15*yRange/100*10+offset, "BR(#tilde{t} #rightarrow t #tilde{#chi}^{0}_{1}) = 50%")
           extraModelLabel2.SetTextFont(42)
           extraModelLabel2.SetTextSize(0.030)
           extraModelLabel2.Draw()
           self.c.extraModelLabel2 = extraModelLabel2

        LObs.Draw("LSAME")
        LObsM.Draw("LSAME")
        LObsP.Draw("LSAME")
        LExp.Draw("LSAME")
        LExpM.Draw("LSAME")
        LExpP.Draw("LSAME")
        
        self.c.LObs = LObs
        self.c.LObsM = LObsM
        self.c.LObsP = LObsP
        self.c.LExp = LExp
        self.c.LExpM = LExpM
        self.c.LExpP = LExpP
def main():
    # Initialize pygame, with the default parameters
    pygame.init()

    # Define the size/resolution of our window
    res_x = 640
    res_y = 480

    # Create a window and a display surface
    screen = pygame.display.set_mode((res_x, res_y))

    # Create a scene
    scene = Scene("TestScene")
    scene.camera = Camera(False, res_x, res_y)

    # Moves the camera back 2 units
    scene.camera.position -= vector3(0,0,2)

    # Create a cube and place it in a scene, at position (0,0,0)
    # This cube has 1 unit of side, and is red
    obj1 = Object3d("TestObject")
    obj1.scale = vector3(1, 1, 1)
    obj1.position = vector3(0, -1, 0)
    obj1.mesh = Mesh.create_cube((1, 1, 1))
    obj1.material = Material(color(1,0,0,1), "TestMaterial1")
    scene.add_object(obj1)

    # Create a second object, and add it as a child of the first object
    # When the first object rotates, this one will also mimic the transform
    obj2 = Object3d("ChildObject")
    obj2.position += vector3(0, 0.75, 0)
    obj2.mesh = Mesh.create_cube((0.5, 0.5, 0.5))
    obj2.material = Material(color(0,1,0,1), "TestMaterial2")
    obj1.add_child(obj2)

    # Specify the rotation of the object. It will rotate 15 degrees around the axis given, 
    # every second
    angle = 15
    axis = vector3(1,0.7,0.2)
    axis.normalize()

    # Timer
    delta_time = 0
    prev_time = time.time()

    pygame.mouse.set_visible(False)
    pygame.event.set_grab(True)

    # Game loop, runs forever
    while (True):
        # Process OS events
        for event in pygame.event.get():
            # Checks if the user closed the window
            if (event.type == pygame.QUIT):
                # Exits the application immediately
                return
            elif (event.type == pygame.KEYDOWN):
                if (event.key == pygame.K_ESCAPE):
                    return

        # Clears the screen with a very dark blue (0, 0, 20)
        screen.fill((0,0,0))

        # Rotates the object, considering the time passed (not linked to frame rate)
        q = from_rotation_vector((axis * math.radians(angle) * delta_time).to_np3())
        obj1.rotation = q * obj1.rotation

        scene.render(screen)

        # Swaps the back and front buffer, effectively displaying what we rendered
        pygame.display.flip()

        # Updates the timer, so we we know how long has it been since the last frame
        delta_time = time.time() - prev_time
        prev_time = time.time()
Beispiel #28
0
                if self.view_zoomfactor - 1 > 0:
                    self.view_zoomfactor -= 1
            if key == keys.PAGE_DOWN:
                if self.view_zoomfactor < width:
                    self.view_zoomfactor += 1
            if key == keys.SPACE:  # starts Maze
                self.state = 0
                self.power_up()
                self.obstacle()
                self.bomb()
        self.review_point()
        self.display()

    def review_point(self):
        if self.hero_finder is None:
            return
        view_left = self.hero_finder.current_x() - (self.view_zoomfactor)
        view_right = self.hero_finder.current_x() + self.view_zoomfactor
        view_bottom = self.hero_finder.current_y() - (self.view_zoomfactor)
        view_up = self.hero_finder.current_y() + self.view_zoomfactor

        self.projection = glm.ortho(view_left, view_right, view_bottom, view_up)

    @classmethod
    def run(cls):
        moderngl_window.run_window_config(cls)


background = color(.0, .0, .0)
game.run()
Beispiel #29
0
def main():
    # Initialize pygame, with the default parameters
    pygame.init()

    # Define the size/resolution of our window
    res_x = 640
    res_y = 480

    # Create a window and a display surface
    screen = pygame.display.set_mode((res_x, res_y))

    # Create a scene
    scene = Scene("FPSScene")
    scene.camera = Camera(False, res_x, res_y)

    # creates a light
    scene.light = Light("sun")
    scene.light.position = vector3(1, 5, 1)

    # Moves the camera back 2 units
    scene.camera.position -= vector3(0, 0, 2)

    obj6 = Object3d("TestObjectpol")
    obj6.scale = vector3(0.5, 0.5, 0.5)
    obj6.position = vector3(1, -0.3, -0.5)
    obj6.mesh = Mesh.create_pol((2, 1, 2))
    obj6.material = Material(color(1, 0, 0.60, 1), "TestMaterial1")
    scene.add_object(obj6)

    obj5 = Object3d("TestObjectpyramid")
    obj5.scale = vector3(0.5, 0.5, 1)
    obj5.position = vector3(2, 2, 3)
    obj5.mesh = Mesh.create_pyramid((1, 2, 1))
    obj5.material = Material(color(0, 1, 1, 1), "TestMaterial1")
    scene.add_object(obj5)

    obj4 = Object3d("TestObjectcube2")
    obj4.scale = vector3(0.5, 0.5, 1)
    obj4.position = vector3(-1, 0, 1)
    obj4.mesh = Mesh.create_cube((1, 1, 1))
    obj4.material = Material(color(1, 1, 1, 1), "TestMaterial1")
    scene.add_object(obj4)

    obj3 = Object3d("TestObjectcube")
    obj3.scale = vector3(0.5, 0.5, 1)
    obj3.position = vector3(1, 0, 0.5)
    obj3.mesh = Mesh.create_cube((1, 1, 1))
    obj3.material = Material(color(1, 0, 1, 1), "TestMaterial1")
    scene.add_object(obj3)

    # Create a reed polygon
    obj2 = Object3d("TestObjectpol")
    obj2.scale = vector3(0.5, 0.5, 0.5)
    obj2.position = vector3(0, 0, 1.5)
    obj2.mesh = Mesh.create_pol((1, 1, 1))
    obj2.material = Material(color(1, 0, 0, 1), "TestMaterial1")
    scene.add_object(obj2)

    # Create a green pyremid as a
    obj1 = Object3d("testObjectplayer")
    obj1.position += vector3(0, 0.75, 0)
    obj1.mesh = Mesh.create_pyramid((0.5, 0.5, 1))
    obj1.material = Material(color(0, 0.75, 0, 1), "TestMaterial2")
    scene.add_object(obj1)

    # Specify the rotation of the object. It will rotate when the arrow keys are pressed down
    angle = 15
    axisY = vector3(0, 1, 0)
    axisY.normalize()
    axisX = vector3(1, 0, 0)
    axisX.normalize()
    axisZ = vector3(0, 0, 1)
    axisZ.normalize()

    mov = 0.2

    pygame.mouse.set_visible(False)
    pygame.event.set_grab(True)

    # Game loop, runs forever
    while (True):
        # Process OS events
        for event in pygame.event.get():
            # Checks if the user closed the window
            if (event.type == pygame.QUIT):
                # Exits the application immediately
                return
            elif (event.type == pygame.KEYDOWN):
                if (event.key == pygame.K_ESCAPE):
                    return
                #rotação
                elif (event.key == pygame.K_LEFT):
                    q = from_rotation_vector(
                        (axisY * math.radians(-(angle))).to_np3())
                    obj1.rotation = q * obj1.rotation
                elif (event.key == pygame.K_RIGHT):
                    q = from_rotation_vector(
                        (axisY * math.radians(angle)).to_np3())
                    obj1.rotation = q * obj1.rotation
                elif (event.key == pygame.K_DOWN):
                    q = from_rotation_vector(
                        (axisX * math.radians(angle)).to_np3())
                    obj1.rotation = q * obj1.rotation
                elif (event.key == pygame.K_UP):
                    q = from_rotation_vector(
                        (axisX * math.radians(-(angle))).to_np3())
                    obj1.rotation = q * obj1.rotation
                elif (event.key == pygame.K_KP_PLUS):
                    q = from_rotation_vector(
                        (axisZ * math.radians(-(angle))).to_np3())
                    obj1.rotation = q * obj1.rotation
                elif (event.key == pygame.K_KP_MINUS):
                    q = from_rotation_vector(
                        (axisZ * math.radians(angle)).to_np3())
                    obj1.rotation = q * obj1.rotation
                #posicão
                elif (event.key == pygame.K_LSHIFT):
                    obj1.position += vector3(0, -mov, 0)
                elif (event.key == pygame.K_SPACE):
                    obj1.position += vector3(0, mov, 0)
                elif (event.key == pygame.K_a):
                    obj1.position += vector3(-mov, 0, 0)
                elif (event.key == pygame.K_d):
                    obj1.position += vector3(mov, 0, 0)
                elif (event.key == pygame.K_s):
                    obj1.position += vector3(0, 0, -mov)
                elif (event.key == pygame.K_w):
                    obj1.position += vector3(0, 0, mov)
                elif (event.key == pygame.K_t):
                    for i in obj1.mesh.origins:
                        print(i)
                        print(obj1.position.z + i.z)
                        print(scene.camera.position.z)
                        print("/")

        scene.camera.position = obj1.position - vector3(0, -0.5, 2.5)

        # Clears the screen with a very dark blue (0, 0, 20)
        screen.fill((0, 0, 0))

        scene.render(screen)

        # Swaps the back and front buffer, effectively displaying what we rendered
        pygame.display.flip()
Beispiel #30
0
 def DrawLines(self):
     # syst0
     self.SYST0['nominal'].SetLineColor(color(self.SYST0['colorLine']))
     self.SYST0['nominal'].SetLineStyle(7)
     self.SYST0['nominal'].SetLineWidth(3)
     # syst0 + 1sigma
     self.SYST0['plus'].SetLineColor(color(self.SYST0['colorLine']))
     self.SYST0['plus'].SetLineStyle(1)
     self.SYST0['plus'].SetLineWidth(2)
     # syst0 - 1sigma
     self.SYST0['minus'].SetLineColor(color(self.SYST0['colorLine']))
     self.SYST0['minus'].SetLineStyle(1)
     self.SYST0['minus'].SetLineWidth(2)
     # syst1
     self.SYST1['nominal'].SetLineColor(color(self.SYST1['colorLine']))
     self.SYST1['nominal'].SetLineStyle(1)
     self.SYST1['nominal'].SetLineWidth(3)
     # syst1 + 1sigma
     self.SYST1['plus'].SetLineColor(color(self.SYST1['colorLine']))
     self.SYST1['plus'].SetLineStyle(1)
     self.SYST1['plus'].SetLineWidth(2)
     # syst1 - 1sigma
     self.SYST1['minus'].SetLineColor(color(self.SYST1['colorLine']))
     self.SYST1['minus'].SetLineStyle(1)
     self.SYST1['minus'].SetLineWidth(2)
     # syst2
     self.SYST2['nominal'].SetLineColor(color(self.SYST2['colorLine']))
     self.SYST2['nominal'].SetLineStyle(1)
     self.SYST2['nominal'].SetLineWidth(3)
     # syst2 + 1sigma
     self.SYST2['plus'].SetLineColor(color(self.SYST2['colorLine']))
     self.SYST2['plus'].SetLineStyle(1)
     self.SYST2['plus'].SetLineWidth(2)
     # syst2 - 1sigma
     self.SYST2['minus'].SetLineColor(color(self.SYST2['colorLine']))
     self.SYST2['minus'].SetLineStyle(1)
     self.SYST2['minus'].SetLineWidth(2)
     # syst3
     self.SYST3['nominal'].SetLineColor(color(self.SYST3['colorLine']))
     self.SYST3['nominal'].SetLineStyle(1)
     self.SYST3['nominal'].SetLineWidth(3)
     # syst3 + 1sigma
     self.SYST3['plus'].SetLineColor(color(self.SYST3['colorLine']))
     self.SYST3['plus'].SetLineStyle(1)
     self.SYST3['plus'].SetLineWidth(2)
     # syst3 - 1sigma
     self.SYST3['minus'].SetLineColor(color(self.SYST3['colorLine']))
     self.SYST3['minus'].SetLineStyle(1)
     self.SYST3['minus'].SetLineWidth(2)
     # syst4
     self.SYST4['nominal'].SetLineColor(color(self.SYST4['colorLine']))
     self.SYST4['nominal'].SetLineStyle(7)
     self.SYST4['nominal'].SetLineWidth(4)
     # syst4 + 1sigma
     self.SYST4['plus'].SetLineColor(color(self.SYST4['colorLine']))
     self.SYST4['plus'].SetLineStyle(1)
     self.SYST4['plus'].SetLineWidth(2)
     # syst4 - 1sigma
     self.SYST4['minus'].SetLineColor(color(self.SYST4['colorLine']))
     self.SYST4['minus'].SetLineStyle(1)
     self.SYST4['minus'].SetLineWidth(2)
     # DRAW LINES
     self.SYST4['nominal'].Draw("LSAME")
     #self.SYST4['plus'].Draw("LSAME")
     #self.SYST4['minus'].Draw("LSAME")
     self.SYST3['nominal'].Draw("LSAME")
     #self.SYST3['plus'].Draw("LSAME")
     #self.SYST3['minus'].Draw("LSAME")
     self.SYST2['nominal'].Draw("LSAME")
     #self.SYST2['plus'].Draw("LSAME")
     #self.SYST2['minus'].Draw("LSAME")
     self.SYST1['nominal'].Draw("LSAME")
     #self.SYST1['plus'].Draw("LSAME")
     #self.SYST1['minus'].Draw("LSAME")
     self.SYST0['nominal'].Draw("LSAME")
Beispiel #31
0
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d.axes3d import Axes3D
from pylab import *
import numpy as np
from matplotlib import cm
from refcolors import *
from color import *

fig = plt.figure()
ax = fig.gca(projection='3d')

X,Y,Z = [],[],[]

for x in range(len(baseColors)):
  for y in range(len(colorSets[x])):
    setC = color(colorSets[x][y]).hsv("h")
    if setC > 180:
      setC -= 360
    X += [ color(colorSets[x][y]).hsv("h") ]

    Y += [ enumeration[y]  ]
    
    specC = color(baseColors[x]).hsv("h")
    if specC > 180:
      specC -= 360
    Z += [ specC - setC ]
p = ax.scatter(X,Y,Z,c="r")
plt.show()

A = np.array(zip(X, Y, Z))
area = 3.1415 * r * r
print(area)
print("{:.2f}".format(area))

# 同切圆绘制
import turtle
turtle.pensize(2)
turtle.circle(10)
turtle.circle(40)
turtle.circle(80)
turtle.circle(160)

# 五角星绘制
import color as color
from turtle import *
color('red', 'red')
begin_fill()
for i in range(5):
    fd(200)
    rt(144)
end_fill()

# 温度转换 摄氏度-华氏度
TempStr = input("请输入带有符号的温度值:")
if TempStr[-1] in ['F', 'f']:
    C = (eval(TempStr[0:-1]) - 32) / 1.8
    print("转换后的温度是{:.2f}C".format(C))
elif TempStr[-1] in ['C', 'c']:
    F = 1.8 * eval(TempStr[0:-1]) + 32
    print("转换后的温度是{:.2f}F".format(F))
else:
Beispiel #33
0
    def DrawLegend(self):
        if(self.model.label2 == ""):
            offset = 0
        else:
            offset = -100
        xRange = self.model.Xmax-self.model.Xmin
        yRange = self.model.Ymax-self.model.Ymin
        
        LObs = rt.TGraph(2)
        LObs.SetName("LObs")
        LObs.SetTitle("LObs")
        LObs.SetLineColor(color(self.OBS['colorLine']))
        LObs.SetLineStyle(1)
        LObs.SetLineWidth(4)
        LObs.SetMarkerStyle(20)
        LObs.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.35*yRange/100*10+offset)
        LObs.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.35*yRange/100*10+offset)

        LObsP = rt.TGraph(2)
        LObsP.SetName("LObsP")
        LObsP.SetTitle("LObsP")
        LObsP.SetLineColor(color(self.OBS['colorLine']))
        LObsP.SetLineStyle(1)
        LObsP.SetLineWidth(2)
        LObsP.SetMarkerStyle(20)
        LObsP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.20*yRange/100*10+offset)
        LObsP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.20*yRange/100*10+offset)

        LObsM = rt.TGraph(2)
        LObsM.SetName("LObsM")
        LObsM.SetTitle("LObsM")
        LObsM.SetLineColor(color(self.OBS['colorLine']))
        LObsM.SetLineStyle(1)
        LObsM.SetLineWidth(2)
        LObsM.SetMarkerStyle(20)
        LObsM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset)
        LObsM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset)

        textObs = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset, 
                            "Observed #pm 1 #sigma_{theory}")
        textObs.SetTextFont(42)
        textObs.SetTextSize(0.040)
        textObs.Draw()
        self.c.textObs = textObs

        LExpP = rt.TGraph(2)
        LExpP.SetName("LExpP")
        LExpP.SetTitle("LExpP")
        LExpP.SetLineColor(color(self.EXP['colorLine']))
        LExpP.SetLineStyle(7)
        LExpP.SetLineWidth(2)  
        LExpP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.85*yRange/100*10+offset)
        LExpP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.85*yRange/100*10+offset)

        LExp = rt.TGraph(2)
        LExp.SetName("LExp")
        LExp.SetTitle("LExp")
        LExp.SetLineColor(color(self.EXP['colorLine']))
        LExp.SetLineStyle(7)
        LExp.SetLineWidth(4)
        LExp.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-2.00*yRange/100*10+offset)
        LExp.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-2.00*yRange/100*10+offset)
        
        LExpM = rt.TGraph(2)
        LExpM.SetName("LExpM")
        LExpM.SetTitle("LExpM")
        LExpM.SetLineColor(color(self.EXP['colorLine']))
        LExpM.SetLineStyle(7)
        LExpM.SetLineWidth(2)  
        LExpM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-2.15*yRange/100*10+offset)
        LExpM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-2.15*yRange/100*10+offset)

        if 'plus2' in self.EXP:
            LExpP2 = rt.TGraph(2)
            LExpP2.SetName("LExpP2")
            LExpP2.SetTitle("LExpP2")
            LExpP2.SetLineColor(color(self.EXP['colorLine']))
            LExpP2.SetLineStyle(3)
            LExpP2.SetLineWidth(2)  
            LExpP2.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.70*yRange/100*10+offset)
            LExpP2.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.70*yRange/100*10+offset)
        if 'minus2' in self.EXP:
            LExpM2 = rt.TGraph(2)
            LExpM2.SetName("LExpP2")
            LExpM2.SetTitle("LExpP2")
            LExpM2.SetLineColor(color(self.EXP['colorLine']))
            LExpM2.SetLineStyle(3)
            LExpM2.SetLineWidth(2)  
            LExpM2.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-2.3*yRange/100*10+offset)
            LExpM2.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-2.3*yRange/100*10+offset)


        if 'plus2' in self.EXP:
            textExp = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-2.15*yRange/100*10+offset,\
                                "Expected #pm 1 and 2 #sigma_{experiment}")
        else:
            textExp = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-2.15*yRange/100*10+offset,\
                    "Expected #pm 1 #sigma_{experiment}")

        textExp.SetTextFont(42)
        textExp.SetTextSize(0.040)
        textExp.Draw()
        self.c.textExp = textExp

        LObs.Draw("LSAME")
        LObsM.Draw("LSAME")
        LObsP.Draw("LSAME")
        LExp.Draw("LSAME")
        LExpM.Draw("LSAME")
        LExpP.Draw("LSAME")
        if 'plus2' in self.EXP:
            LExpP2.Draw("LSAME")
            self.c.LExpP2 = LExpP2
        if 'minus2' in self.EXP:
            LExpM2.Draw("LSAME")
            self.c.LExpM2 = LExpM2
        
        self.c.LObs = LObs
        self.c.LObsM = LObsM
        self.c.LObsP = LObsP
        self.c.LExp = LExp
        self.c.LExpM = LExpM
        self.c.LExpP = LExpP
Beispiel #34
0
    def DrawLegend(self):
        if(self.model.label2 == ""):
            offset = 0
        else:
            offset = -100
        xRange = self.model.Xmax-self.model.Xmin
        yRange = self.model.Ymax-self.model.Ymin

        LObs = rt.TGraph(2)
        LObs.SetName("LObs")
        LObs.SetTitle("LObs")
        LObs.SetLineColor(color(self.OBS['colorLine']))
        LObs.SetLineStyle(1)
        LObs.SetLineWidth(4)
        LObs.SetMarkerStyle(20)
        LObs.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.35*yRange/100*10+offset)
        LObs.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.35*yRange/100*10+offset)

        LObsP = rt.TGraph(2)
        LObsP.SetName("LObsP")
        LObsP.SetTitle("LObsP")
        LObsP.SetLineColor(color(self.OBS['colorLine']))
        LObsP.SetLineStyle(1)
        LObsP.SetLineWidth(2)
        LObsP.SetMarkerStyle(20)
        LObsP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.20*yRange/100*10+offset)
        LObsP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.20*yRange/100*10+offset)

        LObsM = rt.TGraph(2)
        LObsM.SetName("LObsM")
        LObsM.SetTitle("LObsM")
        LObsM.SetLineColor(color(self.OBS['colorLine']))
        LObsM.SetLineStyle(1)
        LObsM.SetLineWidth(2)
        LObsM.SetMarkerStyle(20)
        LObsM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset)
        LObsM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset)

        textObs = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset,
                            "Observed #pm 1 #sigma_{theory}")
        textObs.SetTextFont(42)
        textObs.SetTextSize(0.040)
        #textObs.Draw()
        self.c.textObs = textObs

        LExpP = rt.TGraph(2)
        LExpP.SetName("LExpP")
        LExpP.SetTitle("LExpP")
        LExpP.SetLineColor(color(self.EXP['colorLine']))
        LExpP.SetLineStyle(7)
        LExpP.SetLineWidth(2)
        LExpP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.0*yRange/100*10+offset)
        LExpP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.0*yRange/100*10+offset)

        LExp = rt.TGraph(2)
        LExp.SetName("LExp")
        LExp.SetTitle("LExp")
        LExp.SetLineColor(color(self.EXP['colorLine']))
        LExp.SetLineStyle(7)
        LExp.SetLineWidth(4)
        LExp.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.15*yRange/100*10+offset)
        LExp.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.15*yRange/100*10+offset)

        LExpM = rt.TGraph(2)
        LExpM.SetName("LExpM")
        LExpM.SetTitle("LExpM")
        LExpM.SetLineColor(color(self.EXP['colorLine']))
        LExpM.SetLineStyle(7)
        LExpM.SetLineWidth(2)
        LExpM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.3*yRange/100*10+offset)
        LExpM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.3*yRange/100*10+offset)

        textExp = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-1.3*yRange/100*10+offset,
                            #"Expected #pm 1 #sigma_{statistical}")
                            "Expected")
        textExp.SetTextFont(42)
        textExp.SetTextSize(0.040)
        textExp.Draw()
        self.c.textExp = textExp

        #LObs.Draw("LSAME")
        #LObsM.Draw("LSAME")
        #LObsP.Draw("LSAME")
        LExp.Draw("LSAME")
        #LExpM.Draw("LSAME")
        #LExpP.Draw("LSAME")

        self.c.LObs = LObs
        self.c.LObsM = LObsM
        self.c.LObsP = LObsP
        self.c.LExp = LExp
        self.c.LExpM = LExpM
        self.c.LExpP = LExpP
Beispiel #35
0
    def DrawLegend(self):
        if (self.model.label2 == ""):
            offset = 0
        else:
            # offset = -100
            offset = -20 if "T5qqqq" in self.model.modelname else -10
        xRange = self.model.Xmax - self.model.Xmin
        yRange = self.model.Ymax - self.model.Ymin

        LObs = rt.TGraph(2)
        LObs.SetName("LObs")
        LObs.SetTitle("LObs")
        LObs.SetLineColor(color(self.OBS['colorLine']))
        LObs.SetLineStyle(1)
        LObs.SetLineWidth(4)
        LObs.SetMarkerStyle(20)
        LObs.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                      self.model.Ymax - 1.35 * yRange / 100 * 10 + offset)
        LObs.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                      self.model.Ymax - 1.35 * yRange / 100 * 10 + offset)

        LObsP = rt.TGraph(2)
        LObsP.SetName("LObsP")
        LObsP.SetTitle("LObsP")
        LObsP.SetLineColor(color(self.OBS['colorLine']))
        LObsP.SetLineStyle(1)
        LObsP.SetLineWidth(2)
        LObsP.SetMarkerStyle(20)
        LObsP.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                       self.model.Ymax - 1.20 * yRange / 100 * 10 + offset)
        LObsP.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                       self.model.Ymax - 1.20 * yRange / 100 * 10 + offset)

        LObsM = rt.TGraph(2)
        LObsM.SetName("LObsM")
        LObsM.SetTitle("LObsM")
        LObsM.SetLineColor(color(self.OBS['colorLine']))
        LObsM.SetLineStyle(1)
        LObsM.SetLineWidth(2)
        LObsM.SetMarkerStyle(20)
        LObsM.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                       self.model.Ymax - 1.50 * yRange / 100 * 10 + offset)
        LObsM.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                       self.model.Ymax - 1.50 * yRange / 100 * 10 + offset)

        textObs = rt.TLatex(
            self.model.Xmin + 11 * xRange / 100,
            self.model.Ymax - 1.50 * yRange / 100 * 10 + offset,
            "Observed #pm 1 #sigma_{theory}")
        textObs.SetTextFont(42)
        textObs.SetTextSize(0.040 if self.model.label2 == "" else 0.035)
        textObs.Draw()
        self.c.textObs = textObs

        do2sigma = "exp2sigma" in self.model.__dict__ and self.model.exp2sigma
        dy = 0.09 if do2sigma else 0.136

        LExpP = rt.TGraph(2)
        LExpP.SetName("LExpP")
        LExpP.SetTitle("LExpP")
        LExpP.SetLineColor(color(self.EXP['colorLine']))
        LExpP.SetLineStyle(7)
        LExpP.SetLineWidth(2)
        LExpP.SetPoint(
            0, self.model.Xmin + 3 * xRange / 100,
            self.model.Ymax - (2.0 - 1.1 * dy) * yRange / 100 * 10 + offset)
        LExpP.SetPoint(
            1, self.model.Xmin + 10 * xRange / 100,
            self.model.Ymax - (2.0 - 1.1 * dy) * yRange / 100 * 10 + offset)

        LExp = rt.TGraph(2)
        LExp.SetName("LExp")
        LExp.SetTitle("LExp")
        LExp.SetLineColor(color(self.EXP['colorLine']))
        LExp.SetLineStyle(7)
        LExp.SetLineWidth(4)
        LExp.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                      self.model.Ymax - 2.00 * yRange / 100 * 10 + offset)
        LExp.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                      self.model.Ymax - 2.00 * yRange / 100 * 10 + offset)

        LExpM = rt.TGraph(2)
        LExpM.SetName("LExpM")
        LExpM.SetTitle("LExpM")
        LExpM.SetLineColor(color(self.EXP['colorLine']))
        LExpM.SetLineStyle(7)
        LExpM.SetLineWidth(2)
        LExpM.SetPoint(
            0, self.model.Xmin + 3 * xRange / 100,
            self.model.Ymax - (2.0 + 1.1 * dy) * yRange / 100 * 10 + offset)
        LExpM.SetPoint(
            1, self.model.Xmin + 10 * xRange / 100,
            self.model.Ymax - (2.0 + 1.1 * dy) * yRange / 100 * 10 + offset)

        if do2sigma:
            LExpP2 = rt.TGraph(2)
            LExpP2.SetName("LExpP2")
            LExpP2.SetTitle("LExpP2")
            LExpP2.SetLineColor(color(self.EXP['colorLine']))
            LExpP2.SetLineStyle(3)
            LExpP2.SetLineWidth(2)
            LExpP2.SetPoint(
                0, self.model.Xmin + 3 * xRange / 100,
                self.model.Ymax - (2.0 - 2 * dy) * yRange / 100 * 10 + offset)
            LExpP2.SetPoint(
                1, self.model.Xmin + 10 * xRange / 100,
                self.model.Ymax - (2.0 - 2 * dy) * yRange / 100 * 10 + offset)

            LExpM2 = rt.TGraph(2)
            LExpM2.SetName("LExpM2")
            LExpM2.SetTitle("LExpM2")
            LExpM2.SetLineColor(color(self.EXP['colorLine']))
            LExpM2.SetLineStyle(3)
            LExpM2.SetLineWidth(2)
            LExpM2.SetPoint(
                0, self.model.Xmin + 3 * xRange / 100,
                self.model.Ymax - (2.0 + 2 * dy) * yRange / 100 * 10 + offset)
            LExpM2.SetPoint(
                1, self.model.Xmin + 10 * xRange / 100,
                self.model.Ymax - (2.0 + 2 * dy) * yRange / 100 * 10 + offset)

        textExp = rt.TLatex(
            self.model.Xmin + 11 * xRange / 100,
            self.model.Ymax - 2.15 * yRange / 100 * 10 + offset,
            "Expected #pm {0} #sigma_{{experiment}}".format(
                "1" if not do2sigma else "1, 2"))
        textExp.SetTextFont(42)
        textExp.SetTextSize(0.040 if self.model.label2 == "" else 0.035)
        textExp.Draw()
        self.c.textExp = textExp

        LObs.Draw("LSAME")
        LObsM.Draw("LSAME")
        LObsP.Draw("LSAME")
        LExp.Draw("LSAME")
        LExpM.Draw("LSAME")
        LExpP.Draw("LSAME")
        if do2sigma:
            LExpP2.Draw("LSAME")
            LExpM2.Draw("LSAME")

        self.c.LObs = LObs
        self.c.LObsM = LObsM
        self.c.LObsP = LObsP
        self.c.LExp = LExp
        self.c.LExpM = LExpM
        self.c.LExpP = LExpP
        if do2sigma:
            self.c.LExpP2 = LExpP2
            self.c.LExpM2 = LExpM2
Beispiel #36
0
    def DrawLegend(self):
        if(self.model.label2 == ""):
            offset = 0
        else:
            #offset = -100
            offset = -40
        xRange = self.model.Xmax-self.model.Xmin
        yRange = self.model.Ymax-self.model.Ymin
        
        LObs = rt.TGraph(2)
        LObs.SetName("LObs")
        LObs.SetTitle("LObs")
        LObs.SetLineColor(color(self.OBS['colorLine']))
        LObs.SetLineStyle(1)
        LObs.SetLineWidth(4)
        LObs.SetMarkerStyle(20)
        LObs.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.35*yRange/100*10+offset)
        LObs.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.35*yRange/100*10+offset)

        LObsP = rt.TGraph(2)
        LObsP.SetName("LObsP")
        LObsP.SetTitle("LObsP")
        LObsP.SetLineColor(color(self.OBS['colorLine']))
        LObsP.SetLineStyle(1)
        LObsP.SetLineWidth(2)
        LObsP.SetMarkerStyle(20)
        LObsP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.20*yRange/100*10+offset)
        LObsP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.20*yRange/100*10+offset)

        LObsM = rt.TGraph(2)
        LObsM.SetName("LObsM")
        LObsM.SetTitle("LObsM")
        LObsM.SetLineColor(color(self.OBS['colorLine']))
        LObsM.SetLineStyle(1)
        LObsM.SetLineWidth(2)
        LObsM.SetMarkerStyle(20)
        LObsM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset)
        LObsM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset)

        if (self.model.modelname=="T2bW" or self.model.modelname=="TChipmSlepSnu" or self.model.modelname=="TSlepSlep"):
          textObs = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset,
                            "Observed #pm 1 #sigma_{theory}     " + "NLO-NLL excl.")
        else:	
          textObs = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-1.50*yRange/100*10+offset, 
                            "Observed #pm 1 #sigma_{theory}")
        textObs.SetTextFont(42)
        textObs.SetTextSize(0.040)
        textObs.Draw()
        self.c.textObs = textObs

        LExpP = rt.TGraph(2)
        LExpP.SetName("LExpP")
        LExpP.SetTitle("LExpP")
        LExpP.SetLineColor(color(self.EXP['colorLine']))
        LExpP.SetLineStyle(7)
        LExpP.SetLineWidth(2)  
        LExpP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.85*yRange/100*10+offset)
        LExpP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.85*yRange/100*10+offset)

        LExp = rt.TGraph(2)
        LExp.SetName("LExp")
        LExp.SetTitle("LExp")
        LExp.SetLineColor(color(self.EXP['colorLine']))
        LExp.SetLineStyle(7)
        LExp.SetLineWidth(4)
        LExp.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-2.00*yRange/100*10+offset)
        LExp.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-2.00*yRange/100*10+offset)
        
        LExpM = rt.TGraph(2)
        LExpM.SetName("LExpM")
        LExpM.SetTitle("LExpM")
        LExpM.SetLineColor(color(self.EXP['colorLine']))
        LExpM.SetLineStyle(7)
        LExpM.SetLineWidth(2)  
        LExpM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-2.15*yRange/100*10+offset)
        LExpM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-2.15*yRange/100*10+offset)

        textExp = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-2.15*yRange/100*10+offset, 
                            "Expected #pm 1 #sigma_{experiment}")
        textExp.SetTextFont(42)
        textExp.SetTextSize(0.040)
        textExp.Draw()
        self.c.textExp = textExp

        LObs.Draw("LSAME")
        LObsM.Draw("LSAME")
        LObsP.Draw("LSAME")
        LExp.Draw("LSAME")
        LExpM.Draw("LSAME")
        LExpP.Draw("LSAME")
        
        self.c.LObs = LObs
        self.c.LObsM = LObsM
        self.c.LObsP = LObsP
        self.c.LExp = LExp
        self.c.LExpM = LExpM
        self.c.LExpP = LExpP
Beispiel #37
0
    def DrawLegend(self):
        self.obs = 1.5      #default 1.5, bigger 2.05
        self.exp = self.obs+0.65
        
        xRange = self.model.Xmax-self.model.Xmin
        yRange = self.model.Ymax-self.model.Ymin
        
        LObs = rt.TGraph(2)
        LObs.SetName("LObs")
        LObs.SetTitle("LObs")
        LObs.SetLineColor(color(self.OBS['colorLine']))
        LObs.SetLineStyle(1)
        LObs.SetLineWidth(4)
        LObs.SetMarkerStyle(20)
        LObs.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-(self.obs-0.15)*yRange/100*10)
        LObs.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-(self.obs-0.15)*yRange/100*10)

        LObsP = rt.TGraph(2)
        LObsP.SetName("LObsP")
        LObsP.SetTitle("LObsP")
        LObsP.SetLineColor(color(self.OBS['colorLine']))
        LObsP.SetLineStyle(1)
        LObsP.SetLineWidth(2)
        LObsP.SetMarkerStyle(20)
        LObsP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-(self.obs-0.3)*yRange/100*10)
        LObsP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-(self.obs-0.3)*yRange/100*10)

        LObsM = rt.TGraph(2)
        LObsM.SetName("LObsM")
        LObsM.SetTitle("LObsM")
        LObsM.SetLineColor(color(self.OBS['colorLine']))
        LObsM.SetLineStyle(1)
        LObsM.SetLineWidth(2)
        LObsM.SetMarkerStyle(20)
        LObsM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-(self.obs)*yRange/100*10)
        LObsM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-(self.obs)*yRange/100*10)

        textObs = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-self.obs*yRange/100*10, "Observed #pm 1 #sigma_{theory}")
        textObs.SetTextFont(42)
        textObs.SetTextSize(0.040)
        textObs.Draw()
        self.c.textObs = textObs

        LExpP = rt.TGraph(2)
        LExpP.SetName("LExpP")
        LExpP.SetTitle("LExpP")
        LExpP.SetLineColor(color(self.EXP['colorLine']))
        LExpP.SetLineStyle(7)
        LExpP.SetLineWidth(2)  
        LExpP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-(self.exp-0.3)*yRange/100*10)
        LExpP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-(self.exp-0.3)*yRange/100*10)

        LExp = rt.TGraph(2)
        LExp.SetName("LExp")
        LExp.SetTitle("LExp")
        LExp.SetLineColor(color(self.EXP['colorLine']))
        LExp.SetLineStyle(7)
        LExp.SetLineWidth(4)
        LExp.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-(self.exp-0.15)*yRange/100*10)
        LExp.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-(self.exp-0.15)*yRange/100*10)
        
        LExpM = rt.TGraph(2)
        LExpM.SetName("LExpM")
        LExpM.SetTitle("LExpM")
        LExpM.SetLineColor(color(self.EXP['colorLine']))
        LExpM.SetLineStyle(7)
        LExpM.SetLineWidth(2)  
        LExpM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-(self.exp)*yRange/100*10)
        LExpM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-(self.exp)*yRange/100*10)

        textExp = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-self.exp*yRange/100*10, "Expected #pm 1 #sigma_{experiment}")
        textExp.SetTextFont(42)
        textExp.SetTextSize(0.040)
        textExp.Draw()
        self.c.textExp = textExp

        LObs.Draw("LSAME")
        LObsM.Draw("LSAME")
        LObsP.Draw("LSAME")
        LExp.Draw("LSAME")
        LExpM.Draw("LSAME")
        LExpP.Draw("LSAME")
        
        self.c.LObs = LObs
        self.c.LObsM = LObsM
        self.c.LObsP = LObsP
        self.c.LExp = LExp
        self.c.LExpM = LExpM
        self.c.LExpP = LExpP
Beispiel #38
0
    def DrawLegend(self):
        xRange = self.model.Xmax - self.model.Xmin
        yRange = self.model.Ymax - self.model.Ymin

        LSyst0 = rt.TGraph(2)
        LSyst0.SetName("LSyst0")
        LSyst0.SetTitle("LSyst0")
        LSyst0.SetLineColor(color(self.SYST0['colorLine']))
        LSyst0.SetLineStyle(7)
        LSyst0.SetLineWidth(3)
        LSyst0.SetMarkerStyle(20)
        LSyst0.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                        self.model.Ymax - 0.70 * yRange / 100 * 10)
        LSyst0.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                        self.model.Ymax - 0.70 * yRange / 100 * 10)

        LSyst0P = rt.TGraph(2)
        LSyst0P.SetName("LSyst0P")
        LSyst0P.SetTitle("LSyst0P")
        LSyst0P.SetLineColor(color(self.SYST0['colorLine']))
        LSyst0P.SetLineStyle(1)
        LSyst0P.SetLineWidth(2)
        LSyst0P.SetMarkerStyle(20)
        LSyst0P.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                         self.model.Ymax - 0.55 * yRange / 100 * 10)
        LSyst0P.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                         self.model.Ymax - 0.55 * yRange / 100 * 10)

        LSyst0M = rt.TGraph(2)
        LSyst0M.SetName("LSyst0M")
        LSyst0M.SetTitle("LSyst0M")
        LSyst0M.SetLineColor(color(self.SYST0['colorLine']))
        LSyst0M.SetLineStyle(1)
        LSyst0M.SetLineWidth(2)
        LSyst0M.SetMarkerStyle(20)
        LSyst0M.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                         self.model.Ymax - 0.85 * yRange / 100 * 10)
        LSyst0M.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                         self.model.Ymax - 0.85 * yRange / 100 * 10)

        textSyst0 = rt.TLatex(self.model.Xmin + 11 * xRange / 100,
                              self.model.Ymax - 0.85 * yRange / 100 * 10,
                              "Run 2 limit @ 35.9 fb^{-1}")
        textSyst0.SetTextFont(42)
        textSyst0.SetTextSize(0.032)
        textSyst0.Draw()
        self.c.textSyst0 = textSyst0

        LSyst1 = rt.TGraph(2)
        LSyst1.SetName("LSyst1")
        LSyst1.SetTitle("LSyst1")
        LSyst1.SetLineColor(color(self.SYST1['colorLine']))
        LSyst1.SetLineStyle(1)
        LSyst1.SetLineWidth(3)
        LSyst1.SetMarkerStyle(20)
        LSyst1.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                        self.model.Ymax - 1.35 * yRange / 100 * 10)
        LSyst1.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                        self.model.Ymax - 1.35 * yRange / 100 * 10)

        LSyst1P = rt.TGraph(2)
        LSyst1P.SetName("LSyst1P")
        LSyst1P.SetTitle("LSyst1P")
        LSyst1P.SetLineColor(color(self.SYST1['colorLine']))
        LSyst1P.SetLineStyle(1)
        LSyst1P.SetLineWidth(2)
        LSyst1P.SetMarkerStyle(20)
        LSyst1P.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                         self.model.Ymax - 1.20 * yRange / 100 * 10)
        LSyst1P.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                         self.model.Ymax - 1.20 * yRange / 100 * 10)

        LSyst1M = rt.TGraph(2)
        LSyst1M.SetName("LSyst1M")
        LSyst1M.SetTitle("LSyst1M")
        LSyst1M.SetLineColor(color(self.SYST1['colorLine']))
        LSyst1M.SetLineStyle(1)
        LSyst1M.SetLineWidth(2)
        LSyst1M.SetMarkerStyle(20)
        LSyst1M.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                         self.model.Ymax - 1.50 * yRange / 100 * 10)
        LSyst1M.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                         self.model.Ymax - 1.50 * yRange / 100 * 10)

        textSyst1 = rt.TLatex(self.model.Xmin + 11 * xRange / 100,
                              self.model.Ymax - 1.50 * yRange / 100 * 10,
                              "with Run 2 syst. uncert.")
        textSyst1.SetTextFont(42)
        textSyst1.SetTextSize(0.032)
        textSyst1.Draw()
        self.c.textSyst1 = textSyst1

        LSyst2P = rt.TGraph(2)
        LSyst2P.SetName("LSyst2P")
        LSyst2P.SetTitle("LSyst2P")
        LSyst2P.SetLineColor(color(self.SYST2['colorLine']))
        LSyst2P.SetLineStyle(1)
        LSyst2P.SetLineWidth(2)
        LSyst2P.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                         self.model.Ymax - 1.85 * yRange / 100 * 10)
        LSyst2P.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                         self.model.Ymax - 1.85 * yRange / 100 * 10)

        LSyst2 = rt.TGraph(2)
        LSyst2.SetName("LSyst2")
        LSyst2.SetTitle("LSyst2")
        LSyst2.SetLineColor(color(self.SYST2['colorLine']))
        LSyst2.SetLineStyle(1)
        LSyst2.SetLineWidth(3)
        LSyst2.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                        self.model.Ymax - 2.00 * yRange / 100 * 10)
        LSyst2.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                        self.model.Ymax - 2.00 * yRange / 100 * 10)

        LSyst2M = rt.TGraph(2)
        LSyst2M.SetName("LSyst2M")
        LSyst2M.SetTitle("LSyst2M")
        LSyst2M.SetLineColor(color(self.SYST2['colorLine']))
        LSyst2M.SetLineStyle(1)
        LSyst2M.SetLineWidth(2)
        LSyst2M.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                         self.model.Ymax - 2.15 * yRange / 100 * 10)
        LSyst2M.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                         self.model.Ymax - 2.15 * yRange / 100 * 10)

        textSyst2 = rt.TLatex(self.model.Xmin + 11 * xRange / 100,
                              self.model.Ymax - 2.15 * yRange / 100 * 10,
                              "with YR18 syst. uncert.")
        textSyst2.SetTextFont(42)
        textSyst2.SetTextSize(0.032)
        textSyst2.Draw()
        self.c.textSyst2 = textSyst2

        LSyst3P = rt.TGraph(2)
        LSyst3P.SetName("LSyst3P")
        LSyst3P.SetTitle("LSyst3P")
        LSyst3P.SetLineColor(color(self.SYST3['colorLine']))
        LSyst3P.SetLineStyle(1)
        LSyst3P.SetLineWidth(2)
        LSyst3P.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                         self.model.Ymax - 2.50 * yRange / 100 * 10)
        LSyst3P.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                         self.model.Ymax - 2.50 * yRange / 100 * 10)

        LSyst3 = rt.TGraph(2)
        LSyst3.SetName("LSyst3")
        LSyst3.SetTitle("LSyst3")
        LSyst3.SetLineColor(color(self.SYST3['colorLine']))
        LSyst3.SetLineStyle(1)
        LSyst3.SetLineWidth(3)
        LSyst3.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                        self.model.Ymax - 2.65 * yRange / 100 * 10)
        LSyst3.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                        self.model.Ymax - 2.65 * yRange / 100 * 10)

        LSyst3M = rt.TGraph(2)
        LSyst3M.SetName("LSyst3M")
        LSyst3M.SetTitle("LSyst3M")
        LSyst3M.SetLineColor(color(self.SYST3['colorLine']))
        LSyst3M.SetLineStyle(1)
        LSyst3M.SetLineWidth(2)
        LSyst3M.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                         self.model.Ymax - 2.80 * yRange / 100 * 10)
        LSyst3M.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                         self.model.Ymax - 2.80 * yRange / 100 * 10)

        textSyst3 = rt.TLatex(self.model.Xmin + 11 * xRange / 100,
                              self.model.Ymax - 2.80 * yRange / 100 * 10,
                              "with Stat. uncert. only")
        textSyst3.SetTextFont(42)
        textSyst3.SetTextSize(0.032)
        textSyst3.Draw()
        self.c.textSyst3 = textSyst3

        LSyst4P = rt.TGraph(2)
        LSyst4P.SetName("LSyst4P")
        LSyst4P.SetTitle("LSyst4P")
        LSyst4P.SetLineColor(color(self.SYST4['colorLine']))
        LSyst4P.SetLineStyle(1)
        LSyst4P.SetLineWidth(2)
        LSyst4P.SetPoint(0, self.model.Xmin + 63 * xRange / 100,
                         self.model.Ymax - 1.20 * yRange / 100 * 10)
        LSyst4P.SetPoint(1, self.model.Xmin + 70 * xRange / 100,
                         self.model.Ymax - 1.20 * yRange / 100 * 10)

        LSyst4 = rt.TGraph(2)
        LSyst4.SetName("LSyst4")
        LSyst4.SetTitle("LSyst4")
        LSyst4.SetLineColor(color(self.SYST4['colorLine']))
        LSyst4.SetLineStyle(7)
        LSyst4.SetLineWidth(3)
        LSyst4.SetPoint(0, self.model.Xmin + 63 * xRange / 100,
                        self.model.Ymax - 1.35 * yRange / 100 * 10)
        LSyst4.SetPoint(1, self.model.Xmin + 70 * xRange / 100,
                        self.model.Ymax - 1.35 * yRange / 100 * 10)

        LSyst4M = rt.TGraph(2)
        LSyst4M.SetName("LSyst4M")
        LSyst4M.SetTitle("LSyst4M")
        LSyst4M.SetLineColor(color(self.SYST4['colorLine']))
        LSyst4M.SetLineStyle(1)
        LSyst4M.SetLineWidth(2)
        LSyst4M.SetPoint(0, self.model.Xmin + 63 * xRange / 100,
                         self.model.Ymax - 1.50 * yRange / 100 * 10)
        LSyst4M.SetPoint(1, self.model.Xmin + 70 * xRange / 100,
                         self.model.Ymax - 1.50 * yRange / 100 * 10)

        textSyst4 = rt.TLatex(self.model.Xmin + 71 * xRange / 100,
                              self.model.Ymax - 1.50 * yRange / 100 * 10,
                              "@ 300 fb^{-1}")
        textSyst4.SetTextFont(42)
        textSyst4.SetTextSize(0.032)
        textSyst4.Draw()
        self.c.textSyst4 = textSyst4

        LSyst0.Draw("LSAME")
        #LSyst0M.Draw("LSAME")
        #LSyst0P.Draw("LSAME")
        LSyst1.Draw("LSAME")
        #LSyst1M.Draw("LSAME")
        #LSyst1P.Draw("LSAME")
        LSyst2.Draw("LSAME")
        #LSyst2M.Draw("LSAME")
        #LSyst2P.Draw("LSAME")
        LSyst3.Draw("LSAME")
        #LSyst3M.Draw("LSAME")
        #LSyst3P.Draw("LSAME")
        LSyst4.Draw("LSAME")
        #LSyst4M.Draw("LSAME")
        #LSyst4P.Draw("LSAME")

        self.c.LSyst0 = LSyst0
        self.c.LSyst0M = LSyst0M
        self.c.LSyst0P = LSyst0P
        self.c.LSyst1 = LSyst1
        self.c.LSyst1M = LSyst1M
        self.c.LSyst1P = LSyst1P
        self.c.LSyst2 = LSyst2
        self.c.LSyst2M = LSyst2M
        self.c.LSyst2P = LSyst2P
        self.c.LSyst3 = LSyst3
        self.c.LSyst3M = LSyst3M
        self.c.LSyst3P = LSyst3P
        self.c.LSyst4 = LSyst4
        self.c.LSyst4M = LSyst4M
        self.c.LSyst4P = LSyst4
Beispiel #39
0
    def DrawLegend(self):
        xRange = self.model.Xmax - self.model.Xmin
        yRange = self.model.Ymax - self.model.Ymin

        LObs = rt.TGraph(2)
        LObs.SetName("LObs")
        LObs.SetTitle("LObs")
        LObs.SetLineColor(1)
        LObs.SetLineStyle(1)
        LObs.SetLineWidth(4)
        LObs.SetMarkerStyle(20)
        LObs.SetPoint(0, self.model.Xmin + 3 * xRange / 100, self.model.Ymax - 1.35 * yRange / 100 * 10)
        LObs.SetPoint(1, self.model.Xmin + 10 * xRange / 100, self.model.Ymax - 1.35 * yRange / 100 * 10)

        LObsP = rt.TGraph(2)
        LObsP.SetName("LObsP")
        LObsP.SetTitle("LObsP")
        LObsP.SetLineColor(1)
        LObsP.SetLineStyle(1)
        LObsP.SetLineWidth(2)
        LObsP.SetMarkerStyle(20)
        LObsP.SetPoint(0, self.model.Xmin + 3 * xRange / 100, self.model.Ymax - 1.20 * yRange / 100 * 10)
        LObsP.SetPoint(1, self.model.Xmin + 10 * xRange / 100, self.model.Ymax - 1.20 * yRange / 100 * 10)

        LObsM = rt.TGraph(2)
        LObsM.SetName("LObsM")
        LObsM.SetTitle("LObsM")
        LObsM.SetLineColor(1)
        LObsM.SetLineStyle(1)
        LObsM.SetLineWidth(2)
        LObsM.SetMarkerStyle(20)
        LObsM.SetPoint(0, self.model.Xmin + 3 * xRange / 100, self.model.Ymax - 1.50 * yRange / 100 * 10)
        LObsM.SetPoint(1, self.model.Xmin + 10 * xRange / 100, self.model.Ymax - 1.50 * yRange / 100 * 10)

        textObs = rt.TLatex(
            self.model.Xmin + 11 * xRange / 100,
            self.model.Ymax - 1.50 * yRange / 100 * 10,
            "Observed #pm 1 #sigma_{theory}",
        )
        textObs.SetTextFont(42)
        textObs.SetTextSize(0.040)
        textObs.Draw()
        self.c.textObs = textObs

        LExp = rt.TGraph(2)
        LExp.SetName("LExp")
        LExp.SetTitle("LExp")
        LExp.SetLineColor(1)
        LExp.SetLineWidth(4)
        LExp.SetLineStyle(2)
        LExp.SetPoint(0, self.model.Xmin + 3 * xRange / 100, self.model.Ymax - 2.00 * yRange / 100 * 10)
        LExp.SetPoint(1, self.model.Xmin + 10 * xRange / 100, self.model.Ymax - 2.00 * yRange / 100 * 10)

        LExpP = rt.TGraph(4)
        LExpP.SetName("LExpPM")
        LExpP.SetTitle("LExpPM")
        LExpP.SetFillColor(color(self.EXP["colorArea"]))
        LExpP.SetLineStyle(3)
        LExpP.SetPoint(0, self.model.Xmin + 10, 43)
        LExpP.SetPoint(1, self.model.Xmin + 80, 43)
        LExpP.SetPoint(2, self.model.Xmin + 80, 27)
        LExpP.SetPoint(3, self.model.Xmin + 10, 27)

        LExpP.SetPoint(0, self.model.Xmin + 3 * xRange / 100, self.model.Ymax - 2.15 * yRange / 100 * 10)
        LExpP.SetPoint(1, self.model.Xmin + 10 * xRange / 100, self.model.Ymax - 2.15 * yRange / 100 * 10)
        LExpP.SetPoint(2, self.model.Xmin + 10 * xRange / 100, self.model.Ymax - 1.85 * yRange / 100 * 10)
        LExpP.SetPoint(3, self.model.Xmin + 3 * xRange / 100, self.model.Ymax - 1.85 * yRange / 100 * 10)

        textExp = rt.TLatex(
            self.model.Xmin + 11 * xRange / 100,
            self.model.Ymax - 2.15 * yRange / 100 * 10,
            "Expected #pm 1 #sigma_{experiment}",
        )
        textExp.SetTextFont(42)
        textExp.SetTextSize(0.040)
        textExp.Draw()
        self.c.textExp = textExp

        LObs.Draw("LSAME")
        LObsM.Draw("LSAME")
        LObsP.Draw("LSAME")
        LExpP.Draw("FSAME")
        LExp.Draw("LSAME")

        self.c.LObs = LObs
        self.c.LObsM = LObsM
        self.c.LObsP = LObsP
        self.c.LExp = LExp
        self.c.LExpP = LExpP
Beispiel #40
0
def img_process(img, writer, path, label):

    start = float(time.clock())

    fea = {}
    fea_vec = [path, label]

    #lighting 2 features
    lgt_mean, lgt_var = lighting(img, None)
    fea['lighting_fea'] = [lgt_mean, lgt_var ]
    fea_vec += [lgt_mean, lgt_var]
    #colors
    [hue_mean, sat_mean, hue_std, sat_std, b_var, g_var, r_var, colorfulness, naturalness] = color(img, None)
    fea['color_fea'] = [hue_mean, sat_mean, hue_std, sat_std, b_var, g_var, r_var, colorfulness, naturalness]
    fea_vec += [hue_mean, sat_mean, hue_std, sat_std, b_var, g_var, r_var, colorfulness, naturalness]
    
    time1 = float(time.clock())
    print "Light Time:", time1 - start
    
    #sharpness blur
    sharpness = sharpness_blur(img)
    fea['sharpness_fea'] = sharpness
    fea_vec += [sharpness['Sh'], sharpness['Sh_std'], sharpness['blur']]

    time2 = float(time.clock())
    print "Sharpness:", time2 - time1

    #subject  quality
    [saliency_map, subject_region, sb_lgt_mean, sb_lgt_var, sb_hue_mean, sb_sat_mean, sb_hue_std, sb_sat_std, sb_bvar, sb_gvar, sb_rvar, sb_colorfulness, sb_naturalness, sb_sharpness] = subject(img)
    fea['subject_fea'] = [sb_lgt_mean, sb_lgt_var, sb_hue_mean, sb_sat_mean, sb_hue_std, sb_sat_std, sb_bvar, sb_gvar, sb_rvar, sb_colorfulness, sb_naturalness, sb_sharpness]
    fea_vec += [sb_lgt_mean, sb_lgt_var, sb_hue_mean, sb_sat_mean, sb_hue_std, sb_sat_std, sb_bvar, sb_gvar, sb_rvar, sb_colorfulness, sb_naturalness, sb_sharpness['Sh'], sb_sharpness['Sh_std'], sb_sharpness['blur']]
    #[saliency_map, subject_region] = subject(img)
    
    time3 = float(time.clock())
    print "Subject:", time3 - time2

    #rule of third
    rule3rd = rule_of_third(img, subject_region)
    fea['rule3rd_fea'] = rule3rd
    fea_vec += [rule3rd]
    time4 = float(time.clock())
    print "Rule of third:", time4 - time3

    #obtain the simplicity features
    [qimg, qimg3, qh, qh_sub] = get_simplicity(img, saliency_map, subject_region)
    fea['simplicity_fea'] = [qimg, qimg3, qh, qh_sub]
    fea_vec += [qimg, qimg3, qh, qh_sub]

    time5 = float(time.clock())
    print "Simplicity:", time5 - time4

    #to get the clarity contrast between subject region and original image
    fc = visual_weight(img, subject_region)
    fea['vis_weight_fea'] = [fc]
    fea_vec += [fc]
    time6 = float(time.clock())
    print "Visual wegiht:", time6 - time5

    #to get the ratio of number and length of static and dynamic lines
    ratio_num, ratio_len = get_dynamics(img)
    fea['dynamic_fea'] = [ratio_num, ratio_len]
    fea_vec += [ratio_num, ratio_len]
    #to obtain the color histogram for emotion
    hist = get_colemotion(img)
    print 'Hist finished:',hist
    fea['color_hist_fea'] = hist
    fea_vec += hist
    time7 = float(time.clock())
    print "Dynamic:", time7 - time6

    #print 'Natrual:', naturalness, 'sb natural:', sb_naturalness

    if naturalness == False or sb_naturalness == False:
	print 'Error in naturalness'
	return False
    if len(hist) == 1:
	print 'Error in color emotion'
	return False

    #output the saliency map and the attened area
    #saliency_map = saliency_map * 255
    #rectangle(saliency_map, (subject_region['y0'] - subject_region['H'] / 2, subject_region['x0'] - subject_region['W'] / 2), (subject_region['y0'] + subject_region['H'] / 2, subject_region['x0'] + subject_region['W'] / 2), (255,0,0))
    #imwrite(path+'.jpg',saliency_map) 
    
    writer.writerow(fea_vec)

    return fea
Beispiel #41
0
    def DrawLines(self):
        # observed
        self.OBS['nominal'].SetLineColor(color(self.OBS['colorLine']))
        self.OBS['nominal'].SetLineStyle(1)
        self.OBS['nominal'].SetLineWidth(4)
        # observed + 1sigma
        self.OBS['plus'].SetLineColor(color(self.OBS['colorLine']))
        self.OBS['plus'].SetLineStyle(7)
        self.OBS['plus'].SetLineWidth(2)        
        # observed - 1sigma
        self.OBS['minus'].SetLineColor(color(self.OBS['colorLine']))
        self.OBS['minus'].SetLineStyle(7)
        self.OBS['minus'].SetLineWidth(2)        
        # expected + 1sigma
        self.EXP['plus'].SetLineColor(color(self.EXP['colorLine']))
        self.EXP['plus'].SetLineStyle(7)
        self.EXP['plus'].SetLineWidth(2)                
        # expected
        self.EXP['nominal'].SetLineColor(color(self.EXP['colorLine']))
        self.EXP['nominal'].SetLineStyle(1) 
        self.EXP['nominal'].SetLineWidth(4)        
        # expected - 1sigma
        self.EXP['minus'].SetLineColor(color(self.EXP['colorLine']))
        self.EXP['minus'].SetLineStyle(7)
        self.EXP['minus'].SetLineWidth(2)                        


		# Comment this block in for T2tt
        #self.OBS['OffShellnominal'].SetLineColor(color(self.OBS['colorLine']))
        #self.OBS['OffShellnominal'].SetLineStyle(1)
        #self.OBS['OffShellnominal'].SetLineWidth(4)
        #self.OBS['OffShellplus'].SetLineColor(color(self.OBS['colorLine']))
        #self.OBS['OffShellplus'].SetLineStyle(7)
        #self.OBS['OffShellplus'].SetLineWidth(2)        
        #self.OBS['OffShellminus'].SetLineColor(color(self.OBS['colorLine']))
        #self.OBS['OffShellminus'].SetLineStyle(7)
        #self.OBS['OffShellminus'].SetLineWidth(2)        
        #self.EXP['OffShellnominal'].SetLineColor(color(self.EXP['colorLine']))
        #self.EXP['OffShellnominal'].SetLineStyle(1) 
        #self.EXP['OffShellnominal'].SetLineWidth(4)        
        #self.EXP['OffShellplus'].SetLineColor(color(self.EXP['colorLine']))
        #self.EXP['OffShellplus'].SetLineStyle(7)
        #self.EXP['OffShellplus'].SetLineWidth(2)                
        #self.EXP['OffShellminus'].SetLineColor(color(self.EXP['colorLine']))
        #self.EXP['OffShellminus'].SetLineStyle(7)
        #self.EXP['OffShellminus'].SetLineWidth(2)                        
        #self.EXP['OffShellnominal'].Draw("LSAME")
        #self.EXP['OffShellplus'].Draw("LSAME")
        #self.EXP['OffShellminus'].Draw("LSAME")
        #self.OBS['OffShellnominal'].Draw("LSAME")
        #self.OBS['OffShellplus'].Draw("LSAME")
        #self.OBS['OffShellminus'].Draw("LSAME")
		## Comment this block in for T2tt

		## Comment this block in for T2bw050
        #self.EXP['Islandnominal'].SetLineColor(color(self.EXP['colorLine']))
        #self.EXP['Islandnominal'].SetLineStyle(1) 
        #self.EXP['Islandnominal'].SetLineWidth(4)        
        #self.EXP['Islandnominal'].Draw("LSAME")
		## Comment this block in for T2bw050

        self.EXP['nominal'].Draw("LSAME")
        self.EXP['plus'].Draw("LSAME")
        self.EXP['minus'].Draw("LSAME")
        self.OBS['nominal'].Draw("LSAME")
        self.OBS['plus'].Draw("LSAME")
        self.OBS['minus'].Draw("LSAME")        
Beispiel #42
0
def main():
    # Initialize pygame, with the default parameters
    pygame.init()

    # Define the size/resolution of our window
    res_x = 645
    res_y = 480

    # Create a window and a display surface
    screen = pygame.display.set_mode((res_x, res_y))

    # Create a scene
    scene = Scene("TestScene")
    scene.camera = Camera(False, res_x, res_y)

    # Moves the camera back 2 units
    scene.camera.position -= vector3(0,0,2)

    # Create a cube and place it in a scene, at position (0,0,0)
    # This cube has 1 unit of side, and is red
    obj1 = Object3d("TestObject")
    obj1.scale = vector3(1, 1, 1)
    obj1.position = vector3(0, -1, 0)
    obj1.mesh = Mesh.create_cube((1, 1, 1))
    obj1.material = Material(color(1,0,0,1), "TestMaterial1")
    scene.add_object(obj1)

    # Create a second object, and add it as a child of the first object
    # When the first object rotates, this one will also mimic the transform
    obj2 = Object3d("ChildObject")
    obj2.position += vector3(0, 0.75, 0)
    obj2.mesh = Mesh.create_cube((0.5, 0.5, 0.5))
    obj2.material = Material(color(0,1,0,1), "TestMaterial2")
    obj1.add_child(obj2)

    # Specify the rotation of the object. It will rotate 15 degrees around the axis given, 
    # every second
    angle = 0
    axis = vector3(1,0.7,0.2)
    axis.normalize()
    up, down, right, left,far, close,rot_up, rot_down, rot_right, rot_left, pag_down, pag_up = False, False, False, False, False, False,False,False,False,False,False,False

    # Timer
    delta_time = 0
    prev_time = time.time()

    pygame.mouse.set_visible(False)
    pygame.event.set_grab(True)

    # Game loop, runs forever6
    while (True):
        # Process OS events
        for event in pygame.event.get():
            # Checks if the user closed the window
            if (event.type == pygame.QUIT):
                # Exits the application immediately
                return
            elif (event.type == pygame.KEYDOWN):
                if (event.key == pygame.K_ESCAPE):
                    return
                if (event.key == pygame.K_UP):
                    rot_up = True
                if (event.key == pygame.K_LEFT):
                    rot_left = True
                if (event.key == pygame.K_DOWN):
                    rot_down = True
                if (event.key == pygame.K_RIGHT):
                    rot_right = True
                if (event.key == pygame.K_PAGEDOWN):
                    pag_down = True
                if (event.key == pygame.K_PAGEUP):
                    pag_up = True
                if (event.key == pygame.K_w):
                   up = True
                if (event.key == pygame.K_d):
                    right = True
                if (event.key == pygame.K_s):
                    down = True
                if (event.key == pygame.K_a):
                    left = True
                if (event.key == pygame.K_q):
                    far = True
                if (event.key == pygame.K_e):
                    close = True

            elif (event.type == pygame.KEYUP):
                if (event.key == pygame.K_UP):
                    rot_up = False
                if (event.key == pygame.K_LEFT):
                    rot_left = False
                if (event.key == pygame.K_DOWN):
                    rot_down = False
                if (event.key == pygame.K_RIGHT):
                    rot_right = False
                if (event.key == pygame.K_PAGEDOWN):
                    pag_down = False
                if (event.key == pygame.K_PAGEUP):
                    pag_up = False
                if (event.key == pygame.K_w):
                   up = False
                if (event.key == pygame.K_d):
                    right = False
                if (event.key == pygame.K_s):
                    down = False
                if (event.key == pygame.K_a):
                    left = False
                if (event.key == pygame.K_q):
                    far = False
                if (event.key == pygame.K_e):
                    close = False

        if up:
            obj1.position += vector3(0, 0.002, 0)

        if right:
            obj1.position += vector3(0.002, 0, 0)

        if down:
            obj1.position += vector3(0, -0.002, 0)

        if left:
            obj1.position += vector3(-0.002, 0, 0)

        if far:
            obj1.position += vector3(0.002, 0, 0)

        if close:
            obj1.position += vector3(-0.002, 0, 0)

        if rot_up:
            q = from_rotation_vector((vector3(1,0,0) * math.radians(- 45) * delta_time).to_np3())
            obj1.rotation = q * obj1.rotation

        if rot_down:
            q = from_rotation_vector((vector3(1,0,0) * math.radians(45) * delta_time).to_np3())
            obj1.rotation = q * obj1.rotation

        if rot_right:
            q = from_rotation_vector((vector3(0,1,0) * math.radians(45) * delta_time).to_np3())
            obj1.rotation = q * obj1.rotation

        if rot_left:
            q = from_rotation_vector((vector3(0,1,0) * math.radians(- 45) * delta_time).to_np3())
            obj1.rotation = q * obj1.rotation

        if pag_down:
            q = from_rotation_vector((vector3(0,0,1) * math.radians(- 45) * delta_time).to_np3())
            obj1.rotation = q * obj1.rotation

        if pag_up:
            q = from_rotation_vector((vector3(0,0,1) * math.radians(45) * delta_time).to_np3())
            obj1.rotation = q * obj1.rotation




        # Clears the screen with a very dark blue (0, 0, 20)
        screen.fill((0,0,0))

        scene.render(screen)

        # Swaps the back and front buffer, effectively displaying what we rendered
        pygame.display.flip()

        # Updates the timer, so we we know how long has it been since the last frame
        delta_time = time.time() - prev_time
        prev_time = time.time()
Beispiel #43
0
def subject(img):

    #gray_img = CvtColor(img, COLOR_BGR2GRAY)

    saliency_map = get_saliency(img)
    
    [x0, y0, W, H] = attend_view(saliency_map) #get the subject area

    saliency_map3 = np.zeros((saliency_map.shape[0], saliency_map.shape[1], 3))

    sb_lgt_mean, sb_lgt_var = lighting(img, saliency_map)
    [sb_hue_mean, sb_sat_mean, sb_hue_std, sb_sat_std, sb_bvar, sb_gvar, sb_rvar, sb_colorfulness, sb_naturalness] = color(img, saliency_map)
    sb_sharpness = sharpness_blur(img[int(x0 - H / 2):int(x0 + H / 2), int(y0 - W / 2):int(y0 + W / 2), :])

    return [saliency_map, {'x0':x0, 'y0':y0, 'W':W, 'H':H}, sb_lgt_mean, sb_lgt_var, sb_hue_mean, sb_sat_mean, sb_hue_std, sb_sat_std, sb_bvar, sb_gvar, sb_rvar, sb_colorfulness, sb_naturalness, sb_sharpness]
Beispiel #44
0
    def DrawLegend(self):
        xRange = self.model.Xmax-self.model.Xmin
        yRange = self.model.Ymax-self.model.Ymin
        
        LObs = rt.TGraph(2)
        LObs.SetName("LObs")
        LObs.SetTitle("LObs")
        LObs.SetLineColor(color(self.OBS['colorLine']))
        LObs.SetLineStyle(1)
        LObs.SetLineWidth(4)
        LObs.SetMarkerStyle(20)
        LObs.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.35*yRange/100*10)
        LObs.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.35*yRange/100*10)

        LObsP = rt.TGraph(2)
        LObsP.SetName("LObsP")
        LObsP.SetTitle("LObsP")
        LObsP.SetLineColor(color(self.OBS['colorLine']))
        LObsP.SetLineStyle(1)
        LObsP.SetLineWidth(2)
        LObsP.SetMarkerStyle(20)
        LObsP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.20*yRange/100*10)
        LObsP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.20*yRange/100*10)

        LObsM = rt.TGraph(2)
        LObsM.SetName("LObsM")
        LObsM.SetTitle("LObsM")
        LObsM.SetLineColor(color(self.OBS['colorLine']))
        LObsM.SetLineStyle(1)
        LObsM.SetLineWidth(2)
        LObsM.SetMarkerStyle(20)
        LObsM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.50*yRange/100*10)
        LObsM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.50*yRange/100*10)

        textObs = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-1.50*yRange/100*10, "Observed #pm 1 #sigma_{theory}")
        textObs.SetTextFont(42)
        textObs.SetTextSize(0.040)
        textObs.Draw()
        self.c.textObs = textObs

        LExpP = rt.TGraph(2)
        LExpP.SetName("LExpP")
        LExpP.SetTitle("LExpP")
        LExpP.SetLineColor(color(self.EXP['colorLine']))
        LExpP.SetLineStyle(7)
        LExpP.SetLineWidth(2)  
        LExpP.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.85*yRange/100*10)
        LExpP.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.85*yRange/100*10)
        
        LExp = rt.TGraph(2)
        LExp.SetName("LExp")
        LExp.SetTitle("LExp")
        LExp.SetLineColor(color(self.EXP['colorLine']))
        LExp.SetLineStyle(7)
        LExp.SetLineWidth(4)
        LExp.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-2.00*yRange/100*10)
        LExp.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-2.00*yRange/100*10)
        
        LExpM = rt.TGraph(2)
        LExpM.SetName("LExpM")
        LExpM.SetTitle("LExpM")
        LExpM.SetLineColor(color(self.EXP['colorLine']))
        LExpM.SetLineStyle(7)
        LExpM.SetLineWidth(2)  
        LExpM.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-2.15*yRange/100*10)
        LExpM.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-2.15*yRange/100*10)

        LExpP2 = rt.TGraph(2)
        LExpP2.SetName("LExpP2")
        LExpP2.SetTitle("LExpP2")
        LExpP2.SetLineColor(color(self.EXP2['colorLine']))
        LExpP2.SetLineStyle(7)
        LExpP2.SetLineWidth(2)  
        LExpP2.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-1.75*yRange/100*10)
        LExpP2.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-1.75*yRange/100*10)

        LExpM2 = rt.TGraph(2)
        LExpM2.SetName("LExpM")
        LExpM2.SetTitle("LExpM")
        LExpM2.SetLineColor(color(self.EXP2['colorLine']))
        LExpM2.SetLineStyle(7)
        LExpM2.SetLineWidth(2)  
        LExpM2.SetPoint(0,self.model.Xmin+3*xRange/100, self.model.Ymax-2.25*yRange/100*10)
        LExpM2.SetPoint(1,self.model.Xmin+10*xRange/100, self.model.Ymax-2.25*yRange/100*10)
        
        #textExp = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-2.15*yRange/100*10, "Expected #pm 1, #pm 2 #sigma_{experiment}")
        textExp = rt.TLatex(self.model.Xmin+11*xRange/100, self.model.Ymax-2.15*yRange/100*10, "Expected #pm 1 #sigma_{experiment}")
        textExp.SetTextFont(42)
        textExp.SetTextSize(0.040)
        textExp.Draw()
        self.c.textExp = textExp

        LObs.Draw("LSAME")
        LObsM.Draw("LSAME")
        LObsP.Draw("LSAME")
        LExp.Draw("LSAME")
        #LExpM2.Draw("LSAME")
        #LExpP2.Draw("LSAME")
        LExpM.Draw("LSAME")
        LExpP.Draw("LSAME")
        
        self.c.LObs = LObs
        self.c.LObsM = LObsM
        self.c.LObsP = LObsP
        self.c.LExp = LExp
        self.c.LExpM = LExpM
        self.c.LExpP = LExpP
        self.c.LExpM2 = LExpM2
        self.c.LExpP2 = LExpP2
Beispiel #45
0
    def DrawLegend(self):
        xRange = self.model.Xmax - self.model.Xmin
        yRange = self.model.Ymax - self.model.Ymin

        LObs = rt.TGraph(2)
        LObs.SetName("LObs")
        LObs.SetTitle("LObs")
        LObs.SetLineColor(color(self.OBS['colorLine']))
        LObs.SetLineStyle(1)
        LObs.SetLineWidth(4)
        LObs.SetMarkerStyle(20)
        LObs.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                      self.model.Ymax - 1.35 * yRange / 100 * 10)
        LObs.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                      self.model.Ymax - 1.35 * yRange / 100 * 10)

        LObsP = rt.TGraph(2)
        LObsP.SetName("LObsP")
        LObsP.SetTitle("LObsP")
        LObsP.SetLineColor(color(self.OBS['colorLine']))
        LObsP.SetLineStyle(1)
        LObsP.SetLineWidth(2)
        LObsP.SetMarkerStyle(20)
        LObsP.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                       self.model.Ymax - 1.20 * yRange / 100 * 10)
        LObsP.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                       self.model.Ymax - 1.20 * yRange / 100 * 10)

        LObsM = rt.TGraph(2)
        LObsM.SetName("LObsM")
        LObsM.SetTitle("LObsM")
        LObsM.SetLineColor(color(self.OBS['colorLine']))
        LObsM.SetLineStyle(1)
        LObsM.SetLineWidth(2)
        LObsM.SetMarkerStyle(20)
        LObsM.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                       self.model.Ymax - 1.50 * yRange / 100 * 10)
        LObsM.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                       self.model.Ymax - 1.50 * yRange / 100 * 10)

        textObs = rt.TLatex(self.model.Xmin + 11 * xRange / 100,
                            self.model.Ymax - 1.50 * yRange / 100 * 10,
                            "Observed #pm 1 #sigma_{theory}")
        textObs.SetTextFont(42)
        textObs.SetTextSize(0.040)
        textObs.Draw()
        self.c.textObs = textObs

        LExpP = rt.TGraph(2)
        LExpP.SetName("LExpP")
        LExpP.SetTitle("LExpP")
        LExpP.SetLineColor(color(self.EXP['colorLine']))
        LExpP.SetLineStyle(7)
        LExpP.SetLineWidth(2)
        LExpP.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                       self.model.Ymax - 1.85 * yRange / 100 * 10)
        LExpP.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                       self.model.Ymax - 1.85 * yRange / 100 * 10)

        LExp = rt.TGraph(2)
        LExp.SetName("LExp")
        LExp.SetTitle("LExp")
        LExp.SetLineColor(color(self.EXP['colorLine']))
        LExp.SetLineStyle(7)
        LExp.SetLineWidth(4)
        LExp.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                      self.model.Ymax - 2.00 * yRange / 100 * 10)
        LExp.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                      self.model.Ymax - 2.00 * yRange / 100 * 10)

        LExpM = rt.TGraph(2)
        LExpM.SetName("LExpM")
        LExpM.SetTitle("LExpM")
        LExpM.SetLineColor(color(self.EXP['colorLine']))
        LExpM.SetLineStyle(7)
        LExpM.SetLineWidth(2)
        LExpM.SetPoint(0, self.model.Xmin + 3 * xRange / 100,
                       self.model.Ymax - 2.15 * yRange / 100 * 10)
        LExpM.SetPoint(1, self.model.Xmin + 10 * xRange / 100,
                       self.model.Ymax - 2.15 * yRange / 100 * 10)

        textExp = rt.TLatex(self.model.Xmin + 11 * xRange / 100,
                            self.model.Ymax - 2.15 * yRange / 100 * 10,
                            "Expected #pm 1 #sigma_{experiment}")
        textExp.SetTextFont(42)
        textExp.SetTextSize(0.040)
        textExp.Draw()
        self.c.textExp = textExp

        LObs.Draw("LSAME")
        LObsM.Draw("LSAME")
        LObsP.Draw("LSAME")
        LExp.Draw("LSAME")
        LExpM.Draw("LSAME")
        LExpP.Draw("LSAME")

        self.c.LObs = LObs
        self.c.LObsM = LObsM
        self.c.LObsP = LObsP
        self.c.LExp = LExp
        self.c.LExpM = LExpM
        self.c.LExpP = LExpP
Beispiel #46
0
 def attenuate(self, p, u=0, v=0):
     return (color((225, 225, 225)))