Example Root plot with two HEPData submissions

Example Root plot with two HEPData submissions

In [1]:
from math import *
import re
from pprint import pprint
import urllib.request
from requests.utils import requote_uri
import numpy as np
import json
import yaml
import itertools
import ROOT
from ROOT import TCanvas, TFile, TProfile, TNtuple, TH1F, TH2F, TLegend
from ROOT import TGraph, TGraphErrors, TGraphAsymmErrors
from ROOT import gROOT, gBenchmark, gRandom, gSystem, gStyle, gPad
Welcome to JupyROOT 6.24/06
In [2]:
##
## iterator generator using outer product of two lists
## - first list is inner and second one is outer
## - also able to return nth elements of iterator
## - iterator never ends but folds
##
class iterprod2:
  def __init__(self, arr1, arr2):
    self.arr1, self.arr2 = arr1, arr2
  def __iter__(self):
    self.i1 = 0
    self.i2 = 0
    return self
  def __next__(self):
    rc1, rc2 = self.arr1[self.i1], self.arr2[self.i2]
    self.i1 = (self.i1 + 1) % len(self.arr1)
    if (self.i1 == 0):
      self.i2 = (self.i2 + 1) % len(self.arr2)
    return rc1, rc2
  def elem(self, n):
    ielem1 = n % len(self.arr1)
    ielem2 = (n // len(self.arr1)) % len(self.arr2)
    return self.arr1[ielem1], self.arr2[ielem2]
  def elem1(self, n):
    return self.elem(n)[0]
  def elem2(self, n):
    return self.elem(n)[1]
In [3]:
##
## iterator generator using two lists with simultaneous advancement
## - also able to return nth elements of iterator
## - iterator never ends but folds
##
class iterzip2:
  def __init__(self, arr1, arr2):
    self.arr1, self.arr2 = arr1, arr2
  def __iter__(self):
    self.i1 = 0
    self.i2 = 0
    return self
  def __next__(self):
    rc1, rc2 = self.arr1[self.i1], self.arr2[self.i2]
    self.i1 = (self.i1 + 1) % len(self.arr1)
    self.i2 = (self.i2 + 1) % len(self.arr2)
    return rc1, rc2
  def elem(self, n):
    ielem1 = n % len(self.arr1)
    ielem2 = n % len(self.arr2)
    return self.arr1[ielem1], self.arr2[ielem2]
  def elem1(self, n):
    return self.elem(n)[0]
  def elem2(self, n):
    return self.elem(n)[1]
In [4]:
##---Root colors in Rtypes.h
from ROOT import kWhite, kBlack, kGray, kRed, kGreen, kBlue, kYellow, kMagenta
from ROOT import kCyan, kOrange, kSpring, kTeal, kAzure, kViolet, kPink

##--- Root line styles
from ROOT import kSolid, kDashed, kDotted, kDashDotted

##--- Root marker styles
from ROOT import kFullCircle, kFullSquare, kFullTriangleUp, kFullTriangleDown, kFullStar, kFullDiamond
from ROOT import kFullCross, kFullThreeTriangles, kFullFourTrianglesX, kFullDoubleDiamond
from ROOT import kFullFourTrianglesPlus, kFullCrossX, kFourSquaresX, kFourSquaresPlus

##
## Root colors that are closest to R v4+ colors
##
R_v4_colors = [   1,  46,   8, 982, 428, 617, 1174,  15]
mpl_colors = [ 941,  95, 414, 895, 872,  28, 224,  14, 218, 998]
root_base_colors = [ kBlue, kOrange-3, kGreen, kRed, kMagenta, kCyan, kBlack, kGray]
chosen_colors = root_base_colors

my_linestyles = [kSolid, kDashed, kDotted, kDashDotted]
my_markerstyles = [
  kFullCircle, kFullSquare, kFullTriangleUp, kFullTriangleDown, kFullStar, kFullDiamond,
  kFullCross, kFullThreeTriangles, kFullFourTrianglesX, kFullDoubleDiamond,
  kFullFourTrianglesPlus, kFullCrossX
]

##--- iterator to plot different measurements of same quantity on same plot
col_lstyle_gen = iterprod2(chosen_colors, my_linestyles)
col_lstyle_iter = iter(col_lstyle_gen)

##--- iterator to plot different measurements of same quantity on same plot
mstyle_col_gen = iterzip2(my_markerstyles, chosen_colors)
mstyle_col_iter = iter(mstyle_col_gen)
In [5]:
##
## functions and defs
##
In [6]:
def json_load_url(url):
  return json.load(urllib.request.urlopen(url))

def yaml_load_url(url):
  return yaml.safe_load(urllib.request.urlopen(url))
In [7]:
##
## get symmetric unc
## if multiple unc are present, get quadratic sum
## handle case when unc is specified as percent of value
##
def get_symm_unc(uncvec, yval=0):
  vvar = 0
  for cunc in uncvec:
    vunc = cunc["symerror"]
    if (type(vunc) in (int, float)):
      vvar += cunc["symerror"]**2
    else:
      ##--- handle syst unc defined as percent of yval
      ## rc = re.match(r"^([^%]*)%$", vunc)
      rc = get_symm_unc.re_percunc.match(vunc)
      if (rc != None):
        vunc = float(rc.groups()[0])
        vvar += (vunc/100 * yval)**2
  return sqrt(vvar)
##--- precompile regexp
get_symm_unc.re_percunc = re.compile(r"^([^%]*)%$")
In [8]:
##
## code
##
In [9]:
canvas = TCanvas("canvas", "canvas", 800, 600)
gPad.SetTopMargin(0.10)
gPad.SetBottomMargin(0.10)
gPad.SetLeftMargin(0.10)
gPad.SetRightMargin(0.10)
In [10]:
##
## get BES-III measurement
##
ins1385603_entry = json_load_url("https://www.hepdata.net/record/ins1385603?format=json")
print("Last updated: ", ins1385603_entry["record"]["last_updated"])
pprint(ins1385603_entry)
Last updated:  Wed, 13 Jan 2021 13:34:51 GMT
{'access_count': {'sum': 1883},
 'additional_resources': True,
 'breadcrumb_text': 'Ablikim, M. et al.',
 'coordinator': 1146,
 'data_tables': [{'data': {'csv': 'https://www.hepdata.net/download/table/ins1385603/Bare '
                                  'Cross Section/csv',
                           'json': 'https://www.hepdata.net/download/table/ins1385603/Bare '
                                   'Cross Section/json',
                           'root': 'https://www.hepdata.net/download/table/ins1385603/Bare '
                                   'Cross Section/root',
                           'yaml': 'https://www.hepdata.net/download/table/ins1385603/Bare '
                                   'Cross Section/yaml',
                           'yoda': 'https://www.hepdata.net/download/table/ins1385603/Bare '
                                   'Cross Section/yoda'},
                  'description': 'Bare cross section '
                                 '$\\sigma^\\mathrm{bare}(e^+e^-\\to\\pi^+\\pi^-(\\gamma_\\mathrm{FSR}))$ '
                                 'of the process $e^+e^-\\to\\pi^+\\pi^-$ '
                                 'measured using the initial state radiation '
                                 'method. The data is corrected concerning...',
                  'doi': '10.17182/hepdata.73898.v4/t1',
                  'id': 811578,
                  'location': None,
                  'messages': False,
                  'name': 'Bare Cross Section',
                  'processed_name': 'BareCrossSection'},
                 {'data': {'csv': 'https://www.hepdata.net/download/table/ins1385603/Covariance '
                                  'Matrix of the Bare Cross Section/csv',
                           'json': 'https://www.hepdata.net/download/table/ins1385603/Covariance '
                                   'Matrix of the Bare Cross Section/json',
                           'root': 'https://www.hepdata.net/download/table/ins1385603/Covariance '
                                   'Matrix of the Bare Cross Section/root',
                           'yaml': 'https://www.hepdata.net/download/table/ins1385603/Covariance '
                                   'Matrix of the Bare Cross Section/yaml',
                           'yoda': 'https://www.hepdata.net/download/table/ins1385603/Covariance '
                                   'Matrix of the Bare Cross Section/yoda'},
                  'description': 'Statistical covariance matrix of the bare '
                                 'cross section '
                                 '$\\sigma^\\mathrm{bare}(e^+e^-\\to\\pi^+\\pi^-(\\gamma_\\mathrm{FSR}))$.',
                  'doi': '10.17182/hepdata.73898.v4/t2',
                  'id': 811579,
                  'location': None,
                  'messages': False,
                  'name': 'Covariance Matrix of the Bare Cross Section',
                  'processed_name': 'CovarianceMatrixoftheBareCrossSection'},
                 {'data': {'csv': 'https://www.hepdata.net/download/table/ins1385603/Pion '
                                  'Form Factor/csv',
                           'json': 'https://www.hepdata.net/download/table/ins1385603/Pion '
                                   'Form Factor/json',
                           'root': 'https://www.hepdata.net/download/table/ins1385603/Pion '
                                   'Form Factor/root',
                           'yaml': 'https://www.hepdata.net/download/table/ins1385603/Pion '
                                   'Form Factor/yaml',
                           'yoda': 'https://www.hepdata.net/download/table/ins1385603/Pion '
                                   'Form Factor/yoda'},
                  'description': 'Pion form factor $|F_\\pi|^2$ measured using '
                                 'the initial state radiation method. The data '
                                 'is corrected concerning vacuum polarization '
                                 'effects.',
                  'doi': '10.17182/hepdata.73898.v4/t3',
                  'id': 811580,
                  'location': None,
                  'messages': False,
                  'name': 'Pion Form Factor',
                  'processed_name': 'PionFormFactor'},
                 {'data': {'csv': 'https://www.hepdata.net/download/table/ins1385603/Covariance '
                                  'Matrix of the Pion Form Factor/csv',
                           'json': 'https://www.hepdata.net/download/table/ins1385603/Covariance '
                                   'Matrix of the Pion Form Factor/json',
                           'root': 'https://www.hepdata.net/download/table/ins1385603/Covariance '
                                   'Matrix of the Pion Form Factor/root',
                           'yaml': 'https://www.hepdata.net/download/table/ins1385603/Covariance '
                                   'Matrix of the Pion Form Factor/yaml',
                           'yoda': 'https://www.hepdata.net/download/table/ins1385603/Covariance '
                                   'Matrix of the Pion Form Factor/yoda'},
                  'description': 'Statistical covariance matrix of the pion '
                                 'form factor $|F_\\pi|^2$.',
                  'doi': '10.17182/hepdata.73898.v4/t4',
                  'id': 811581,
                  'location': None,
                  'messages': True,
                  'name': 'Covariance Matrix of the Pion Form Factor',
                  'processed_name': 'CovarianceMatrixofthePionFormFactor'}],
 'mode': 'record',
 'participant_count': 0,
 'recid': 73898,
 'record': {'abstract': 'In Phys. Lett. B 753, 629-638 (2016) '
                        '[arXiv:1507.08188] the BESIII collaboration published '
                        'a cross section measurement of the process '
                        '$e^+e^-\\to \\pi^+ \\pi^-$ in the energy range '
                        'between 600 and 900 MeV. In this erratum we report a '
                        'corrected evaluation of the statistical errors in '
                        'terms of a fully propagated covariance matrix. The '
                        'correction also yields a reduced statistical '
                        'uncertainty for the hadronic vacuum polarization '
                        'contribution to the anomalous magnetic moment of the '
                        'muon, which now reads as $a_\\mu^{\\pi\\pi\\mathrm{, '
                        'LO}}(600 - 900\\,\\mathrm{MeV}) = (368.2 \\pm '
                        '1.5_{\\rm stat} \\pm 3.3_{\\rm syst})\\times '
                        '10^{-10}$. The central values of the cross section '
                        'measurement and of $a_\\mu^{\\pi\\pi\\mathrm{, LO}}$, '
                        'as well as the systematic uncertainties remain '
                        'unchanged.',
            'access_urls': {'links': {'csv': 'https://www.hepdata.net/download/submission/ins1385603/4/csv',
                                      'json': 'https://www.hepdata.net/download/submission/ins1385603/4/json',
                                      'root': 'https://www.hepdata.net/download/submission/ins1385603/4/root',
                                      'yaml': 'https://www.hepdata.net/download/submission/ins1385603/4/yaml',
                                      'yoda': 'https://www.hepdata.net/download/submission/ins1385603/4/yoda'}},
            'analyses': [{'analysis': 'http://rivet.hepforge.org/analyses/BESIII_2016_I1385603',
                          'type': 'rivet'}],
            'arxiv_id': 'arXiv:2009.05011',
            'collaborations': ['BESIII'],
            'control_number': '73898',
            'creation_date': '2015-07-29',
            'data_abstract': None,
            'doc_type': 'publication',
            'doi': '10.1016/j.physletb.2015.11.043',
            'first_author': {'affiliation': 'Beijing, Inst. High Energy Phys.',
                             'full_name': 'Ablikim, M.'},
            'hepdata_doi': '10.17182/hepdata.73898.v4',
            'id': 73898,
            'inspire_id': 1385603,
            'journal_info': 'Phys.Lett.B 753 (2016) 629-638',
            'keywords': [{'source': 'author',
                          'value': 'Hadronic cross section'},
                         {'source': 'author', 'value': 'Muon anomaly'},
                         {'source': 'author',
                          'value': 'Initial state radiation'},
                         {'source': 'author', 'value': 'Pion form factor'},
                         {'source': 'author', 'value': 'BESIII'},
                         {'schema': 'INSPIRE',
                          'value': 'electron positron: annihilation'},
                         {'schema': 'INSPIRE',
                          'value': 'cross section: measured'},
                         {'schema': 'INSPIRE', 'value': 'pi: pair production'},
                         {'schema': 'INSPIRE', 'value': 'pi: form factor'},
                         {'schema': 'INSPIRE',
                          'value': 'vacuum polarization: hadronic'},
                         {'schema': 'INSPIRE', 'value': 'initial state'},
                         {'schema': 'INSPIRE', 'value': 'magnetic moment'},
                         {'schema': 'INSPIRE', 'value': 'Beijing Stor'},
                         {'schema': 'INSPIRE', 'value': 'BES'},
                         {'schema': 'INSPIRE',
                          'value': 'electron positron --> pi+ pi-'},
                         {'schema': 'INSPIRE', 'value': '3.773 GeV-cms'}],
            'last_updated': 'Wed, 13 Jan 2021 13:34:51 GMT',
            'parent_child_join': {'name': 'parent_publication'},
            'publication_date': '2016-07-28T00:00:00',
            'recid': 73898,
            'subject_area': ['hep-ex'],
            'summary_authors': [{'affiliation': 'Beijing, Inst. High Energy '
                                                'Phys.',
                                 'full_name': 'Ablikim, M.'},
                                {'affiliation': 'Novosibirsk, IYF',
                                 'full_name': 'Achasov, M.N.'},
                                {'affiliation': '',
                                 'full_name': 'Adlarson, P.'},
                                {'affiliation': 'Beijing, Inst. High Energy '
                                                'Phys.',
                                 'full_name': 'Ai, X.C.'},
                                {'affiliation': 'Carnegie Mellon U.',
                                 'full_name': 'Albayrak, O.'},
                                {'affiliation': '', 'full_name': 'Ahmed, S.'},
                                {'affiliation': 'Ruhr U., Bochum',
                                 'full_name': 'Albrecht, M.'},
                                {'affiliation': 'Rochester U.',
                                 'full_name': 'Ambrose, D.J.'},
                                {'affiliation': '',
                                 'full_name': 'Aliberti, R.'},
                                {'affiliation': 'Turin U.',
                                 'full_name': 'Amoroso, A.'}],
            'title': 'Measurement of the $e^+ e^− \\to \\pi^+ \\pi^−$ cross '
                     'section between 600 and 900 MeV using initial state '
                     'radiation',
            'type': ['article'],
            'uuid': '412140ab-0985-44ee-a129-a4c8697b254b',
            'version': 4,
            'year': '2016'},
 'record_type': 'publication',
 'resources_with_doi': [],
 'reviewers_notified': False,
 'revision_message': {'message': 'fix some entries ', 'version': 4},
 'site_url': 'https://www.hepdata.net',
 'status': 'finished',
 'table_id_to_show': 811578,
 'table_name_to_show': 'Bare Cross Section',
 'version': 4,
 'version_count': 4,
 'watched': False}
In [11]:
##
## get CMD-2 measurement
##
ins728302_entry = json_load_url("https://www.hepdata.net/record/ins728302?format=json")
print("Last updated: ", ins728302_entry["record"]["last_updated"])
pprint(ins728302_entry)
Last updated:  Tue, 10 Oct 2006 00:00:00 GMT
{'access_count': {'sum': 1340},
 'additional_resources': True,
 'breadcrumb_text': 'Akhmetshin, R.R. et al.',
 'coordinator': 1,
 'data_tables': [{'data': {'csv': 'https://www.hepdata.net/download/table/ins728302/Table '
                                  '1/csv',
                           'json': 'https://www.hepdata.net/download/table/ins728302/Table '
                                   '1/json',
                           'root': 'https://www.hepdata.net/download/table/ins728302/Table '
                                   '1/root',
                           'yaml': 'https://www.hepdata.net/download/table/ins728302/Table '
                                   '1/yaml',
                           'yoda': 'https://www.hepdata.net/download/table/ins728302/Table '
                                   '1/yoda'},
                  'description': 'Measured values of the pion form factor. The '
                                 'errors are statistical only.',
                  'doi': '10.17182/hepdata.41782.v1/t1',
                  'id': 35960,
                  'location': 'Data from T 2,F 9',
                  'messages': False,
                  'name': 'Table 1',
                  'processed_name': 'Table1'},
                 {'data': {'csv': 'https://www.hepdata.net/download/table/ins728302/Table '
                                  '2/csv',
                           'json': 'https://www.hepdata.net/download/table/ins728302/Table '
                                   '2/json',
                           'root': 'https://www.hepdata.net/download/table/ins728302/Table '
                                   '2/root',
                           'yaml': 'https://www.hepdata.net/download/table/ins728302/Table '
                                   '2/yaml',
                           'yoda': 'https://www.hepdata.net/download/table/ins728302/Table '
                                   '2/yoda'},
                  'description': 'Measured value of the bare PI+ PI- cross '
                                 'section including corrections for radiative '
                                 'effects but excluding corrections for vacuum '
                                 'polarization...',
                  'doi': '10.17182/hepdata.41782.v1/t2',
                  'id': 35961,
                  'location': 'Data from T 2',
                  'messages': False,
                  'name': 'Table 2',
                  'processed_name': 'Table2'}],
 'mode': 'record',
 'participant_count': 0,
 'recid': 41782,
 'record': {'abstract': 'We present a measurement of the pion form factor '
                        'based on e+e- annihilation data from the CMD-2 '
                        'detector in the energy range 0.6<sqrt(s)<1.0 '
                        'GeV with a systematic uncertainty of 0.8%. A data '
                        'sample is five times larger than that used in our '
                        'previous measurement.',
            'access_urls': {'links': {'csv': 'https://www.hepdata.net/download/submission/ins728302/1/csv',
                                      'json': 'https://www.hepdata.net/download/submission/ins728302/1/json',
                                      'root': 'https://www.hepdata.net/download/submission/ins728302/1/root',
                                      'yaml': 'https://www.hepdata.net/download/submission/ins728302/1/yaml',
                                      'yoda': 'https://www.hepdata.net/download/submission/ins728302/1/yoda'}},
            'analyses': [{'analysis': 'http://rivet.hepforge.org/analyses/CMD2_2007_I728302',
                          'type': 'rivet'}],
            'arxiv_id': 'arXiv:hep-ex/0610021',
            'collaborations': ['CMD-2'],
            'control_number': '41782',
            'creation_date': '2006-10-01',
            'data_abstract': 'Novosibirsk-Vepp-2. Measurement of the cross '
                             'section and pion form factor from the process E+ '
                             'E- --& gt; PI+ PI- in the centre of mass '
                             'energy range 600 to 970 MeV. The data come from '
                             'the 1998 running.',
            'doc_type': 'publication',
            'doi': '10.1016/j.physletb.2007.01.073',
            'first_author': {'affiliation': '',
                             'full_name': 'Akhmetshin, R.R.'},
            'hepdata_doi': '10.17182/hepdata.41782',
            'id': 41782,
            'inspire_id': 728302,
            'journal_info': 'Phys.Lett.B 648 (2007) 28-38',
            'keywords': [{'schema': 'PDG', 'source': 'PDG', 'value': 'M009W0'},
                         {'schema': 'PDG',
                          'source': 'PDG',
                          'value': 'M009:Desig=4'},
                         {'schema': 'PDG', 'source': 'PDG', 'value': 'M009M0'},
                         {'schema': 'PDG',
                          'source': 'PDG',
                          'value': 'M001:Desig=2'},
                         {'schema': 'INSPIRE',
                          'value': 'electron positron: colliding beams'},
                         {'schema': 'INSPIRE',
                          'value': 'electron positron: annihilation'},
                         {'schema': 'INSPIRE', 'value': 'pi: pair production'},
                         {'schema': 'INSPIRE', 'value': 'pi: form factor'},
                         {'schema': 'INSPIRE',
                          'value': 'channel cross section'},
                         {'schema': 'INSPIRE', 'value': 'energy dependence'},
                         {'schema': 'INSPIRE', 'value': 'parametrization'},
                         {'schema': 'INSPIRE', 'value': 'rho(770): mass'},
                         {'schema': 'INSPIRE', 'value': 'rho(770): width'},
                         {'schema': 'INSPIRE',
                          'value': 'omega(783): branching ratio'},
                         {'schema': 'INSPIRE', 'value': 'CMD'},
                         {'schema': 'INSPIRE', 'value': 'experimental results'},
                         {'schema': 'INSPIRE', 'value': 'Novosibirsk Stor2'},
                         {'schema': 'INSPIRE',
                          'value': 'electron positron --> pi+ pi-'},
                         {'schema': 'INSPIRE', 'value': '0.60-0.98 GeV-cms'}],
            'last_updated': 'Tue, 10 Oct 2006 00:00:00 GMT',
            'parent_child_join': {'name': 'parent_publication'},
            'publication_date': '2007-09-08T00:00:00',
            'recid': 41782,
            'subject_area': ['hep-ex'],
            'summary_authors': [{'affiliation': '',
                                 'full_name': 'Akhmetshin, R.R.'},
                                {'affiliation': '',
                                 'full_name': 'Aulchenko, V.M.'},
                                {'affiliation': '',
                                 'full_name': 'Banzarov, V.Sh.'},
                                {'affiliation': '',
                                 'full_name': 'Barkov, L.M.'},
                                {'affiliation': '',
                                 'full_name': 'Bashtovoy, N.S.'},
                                {'affiliation': '',
                                 'full_name': 'Bondar, A.E.'},
                                {'affiliation': '',
                                 'full_name': 'Bondarev, D.V.'},
                                {'affiliation': '',
                                 'full_name': 'Bragin, A.V.'},
                                {'affiliation': '',
                                 'full_name': 'Dhawan, S.K.'},
                                {'affiliation': '',
                                 'full_name': 'Eidelman, S.I.'}],
            'title': 'High-statistics measurement of the pion form factor in '
                     'the rho-meson energy range with the CMD-2 detector',
            'type': ['article'],
            'uuid': '60936b90-0f83-4d4e-9f5b-77c00dea711d',
            'version': 1,
            'year': '2007'},
 'record_type': 'publication',
 'resources_with_doi': [],
 'reviewers_notified': False,
 'site_url': 'https://www.hepdata.net',
 'status': 'finished',
 'table_id_to_show': 35960,
 'table_name_to_show': 'Table 1',
 'version': 1,
 'version_count': 1,
 'watched': False}
In [12]:
gStyle.SetOptStat(0)
if "basehist" in globals():
  basehist.Delete()
basehist = TH1F("basehist", "|F_{#pi}|^{2}", 100, 0.5, 1)
basehist.SetMinimum(0)
basehist.SetMaximum(55)
basehist.GetXaxis().SetTitle("#sqrt{s} [GeV]")
basehist.GetYaxis().SetTitle("|F_{#pi}|^{2}")

basehist.Draw("")
## canvas.Draw()
In [13]:
##
## get YAML of first item of the submission
## get Pion Form Factor, 10.17182/hepdata.73898.v4/t3
##
ins1385603_Table3 = yaml_load_url(requote_uri(ins1385603_entry["data_tables"][2]["data"]["yaml"]))
In [14]:
xval = np.asarray([
  (delem["low"]+delem["high"])/2
  for delem in ins1385603_Table3["independent_variables"][0]["values"]
])

yval = np.asarray([
  delem["value"]
  for delem in ins1385603_Table3["dependent_variables"][0]["values"]
])

yunc = np.asarray([
  get_symm_unc(delem["errors"], delem["value"])
  for delem in ins1385603_Table3["dependent_variables"][0]["values"]
])
In [15]:
##
## TGraphErrors
##
ins1385603_gr = TGraphErrors(len(xval), xval, yval, 0, yunc)
title = "-".join(ins1385603_entry["record"]["collaborations"])
title += " " + ins1385603_entry["record"]["year"]
ins1385603_gr.SetTitle(title)
mstyle, col = next(mstyle_col_iter)
ins1385603_gr.SetMarkerStyle( mstyle )
ins1385603_gr.SetLineColor( col )
ins1385603_gr.SetMarkerColor( col )

ins1385603_gr.Draw("epsame")
## canvas.Draw()
In [16]:
##
## get YAML of first item of the submission
##
ins728302_Table1 = yaml_load_url(requote_uri(ins728302_entry["data_tables"][0]["data"]["yaml"]))
In [17]:
xval = np.asarray([
  delem["value"]/1000
  for delem in ins728302_Table1["independent_variables"][0]["values"]
])

yval = np.asarray([
  delem["value"]
  for delem in ins728302_Table1["dependent_variables"][0]["values"]
])

yunc = np.asarray([
  get_symm_unc(delem["errors"], delem["value"])
  for delem in ins728302_Table1["dependent_variables"][0]["values"]
])
In [18]:
##
## TGraphErrors
##
ins728302_gr = TGraphErrors(len(xval), xval, yval, 0, yunc)
title = "-".join(ins728302_entry["record"]["collaborations"])
title += " " + ins728302_entry["record"]["year"]
ins728302_gr.SetTitle(title)
mstyle, col = next(mstyle_col_iter)
ins728302_gr.SetMarkerStyle( mstyle )
ins728302_gr.SetLineColor( col )
ins728302_gr.SetMarkerColor( col )

ins728302_gr.Draw("epsame")
## canvas.Draw()
In [19]:
leg = TLegend(0.65, 0.80, 0.90, 0.90)
leg.SetTextSize(0.035)
leg.AddEntry(ins1385603_gr, ins1385603_gr.GetTitle(), "LP")
leg.AddEntry(ins728302_gr, ins728302_gr.GetTitle(), "LP")
leg.Draw()
canvas.Draw()
In [20]:
rfile = TFile("precsm-resp-plot-example.root", "recreate")
canvas.Write("F_pip_pim")
rfile.Close()
In [ ]: