Regarding parsing the BSDF

I was writing the python code to parse the BSDF. I read the btdf valuse from the xml file (Klems), then use the btdf values to multiply the solid angles, Finally I sum the values for all outgoing patches at each incident angles to get 145 hemisphere transimissions.

However, the derived hemiphere transimissions have some small deviations with the values displayed on BSDFViewer. I don’t know what caused these deviations, any insights?

I don’t confirm that the solid angles formula I used is corrected, below is my python code for calculating the solid angles.

def solidAngleCalc(patchnum):
    phiRange = [np.array([0,5]),np.array([5,15]),np.array([15,25]),
    subdivs = [1,8,16,20,24,24,24,16,12]
    sum = 0
    i = 0
    for i in range(len(subdivs)):
        sum += subdivs[i]
        if(sum >= patchnum):
    owega = 0
    Radtheta = math.radians(phiRange[i][0])
    Radtheta1 = math.radians(phiRange[i][1])
    owega = math.pi*(math.cos(Radtheta)**2-math.cos(Radtheta1)**2)/subdivs[i]
    return owega

Below is my code for reading the btdf and brdf values from xml file:

def PraseBSDF(file):
    DOMTree = xml.dom.minidom.parse(file)
    collection = DOMTree.documentElement
    waves = collection.getElementsByTagName("WavelengthData")
    btdf = None
    brdf = None
    for record in waves:
        wavelength = record.getElementsByTagName('Wavelength')[0]
        block = record.getElementsByTagName('WavelengthDataBlock')[0]
        scatterData = block.getElementsByTagName("ScatteringData")
        data = str.strip(scatterData[0].childNodes[0].data)        
        values = data.split(',')      
        elements = []
        for value in values:
            if value is not None and value !='':
        Type = record.getElementsByTagName("WavelengthDataDirection")
        if "Transmission Front" in Type[0].childNodes[0].data and wavelength=='Solar':
            btdf = np.array(elements)
            btdf = btdf.reshape(145,145)
        if "Reflection Front" in Type[0].childNodes[0].data and wavelength=='Solar':
            brdf = np.array(elements)
            brdf = brdf.reshape(145,145)
    return btdf, brdf

Below is for transmissions calculation:

def solidAngleVector():
    solidAngles = []
    for i in range(1,146):
    return np.array(solidAngles).reshape(1,-1)
solidAngles = solidAngleVector()  
Trans = np.multiply(solidAngles,btdf)
Refs = np.multiply(solidAngles,brdf)
hemisphereTrans= np.sum(Trans,axis = 0)
hemisphereRefls = np.sum(Refs, axis = 0)

Below is the result comparison: