Giter Site home page Giter Site logo

Comments (3)

AndreasAlbert avatar AndreasAlbert commented on July 29, 2024

Exists here: https://github.com/clelange/hepdata_lib/blob/master/hepdata_lib/__init__.py#L413-L416

from hepdata_lib.

clelange avatar clelange commented on July 29, 2024

Excellent! I just realised it's actually reading the TGraph from a .C file - will rename the issue.

Here is some code:

rx = readGraph(infile,"Graph0_fx1")
ry = readGraph(infile,"Graph0_fy1")
d1 = makeDict(rx,ry)
predown,preup,x = makeLists(d1)

which uses:

def readGraph(infile,graphname):
    f = open(infile,"r")
    r=[]
    start=0
    for line in f.readlines():
        if '#' in line: continue
        if (graphname in line) and ("{" in line):
            start=1
            continue
        if "}" in line:
            if start==1: r.append(float(line.split("}")[0]) )
            start=0
        if start==1:
            r.append(float(line.split(",")[0]) )
    return r
  
def getErrors(down,up,nominal):
    i=0
    errup =[]
    errdown=[]
    for n in nominal:
        errdown.append(down[i]-n)
        errup.append(up[i]-n)
        print(str(n) + " +- "+ str(errup[-1])+" "+str(errdown[-1]))
        i+=1
    return errdown,errup
         
def makeDict(x,y):
    d ={}
    ati=0
    for i in x:
        d[i]=[]
    for i in range(0,len(x)):    
        d[x[i]].append(y[i])
    return d
        
def makeLists(dic):
    up=[]
    down=[]
    keys = sorted(dic.keys())
    for k in keys:
        for i in range(0,len(dic[k])):
            if i ==0:
                up.append(dic[k][0])
            if i ==1:
                down.append(dic[k][1])
    return up,down,keys

from hepdata_lib.

clelange avatar clelange commented on July 29, 2024

Closed by #135

from hepdata_lib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.