Beispiel #1
0
def residual_cubic(param):
    '''Function which computes the residual (as sum of squares) comparing the
    ratio of expt to theoretical intensity ratio to the sensitivity  profile
    modelled as  a line, ( 1+ c1*x + c2*x**2 + c3*x**3 )

    param : T, c1, c2, c3

    '''
    TK = 298

    sosD2 = bp.sumofstate_D2(TK)
    sosHD = bp.sumofstate_HD(TK)

    computed_D2 = compute_series_para.spectra_D2(TK, OJ_D2, QJ_D2,
                                                 SJ_D2, sosD2)
    computed_HD = compute_series_para.spectra_HD(TK, OJ_HD, QJ_HD,
                                                 SJ_HD, sosHD)

    # ------ D2 ------
    trueR_D2 = gen_intensity_mat(computed_D2, 2)
    expt_D2 = gen_intensity_mat(dataD2, 0)
    I_D2 = np.divide(expt_D2, trueR_D2)
    #I_D2 = clean_mat(I_D2)
    # ----------------

    # ------ HD ------
    trueR_HD = gen_intensity_mat(computed_HD, 2)
    expt_HD = gen_intensity_mat(dataHD, 0)
    I_HD = np.divide(expt_HD, trueR_HD)
    #I_HD = clean_mat(I_HD)
    # ----------------

    # I_HD = clean_and_scale_elements(I_HD, index_HD, 2)
    # I_D2 = clean_and_scale_elements(I_D2, index_D2, 2)

    # generate the RHS : sensitivity factor
    sD2 = gen_s_cubic(computed_D2, param)
    sHD = gen_s_cubic(computed_HD, param)

    # residual matrix
    eD2 = I_D2 - sD2
    eHD = I_HD - sHD

    eD2 = np.multiply(wMat_D2, eD2)
    eHD = np.multiply(wMat_HD, eHD)

    eD2 = clean_mat(eD2)
    eHD = clean_mat(eHD)

    # E = np.sum(np.square(eD2)) + np.sum(np.square(eHD))

    eD2[indexD2] = 0
    eHD[indexHD] = 0

    #E = np.sum(np.abs(eD2)) + np.sum(np.abs(eHD))
    E = np.sum(np.square(eD2)) + np.sum(np.square(eHD))

    return(E)
Beispiel #2
0
def T_independent_HD_set_nan( array):
    '''
    elements in 'array' which correspond to frequencies not
    analyzed are set to nan, for HD
    '''
    TK = 298  #  --------------------------------

    sosHD = bp.sumofstate_HD(TK)
    computed_HD = compute_series_para.spectra_HD( TK, OJ_HD, QJ_HD,
                                                 SJ_HD, sosHD)

    calc_298_HD = gen_intensity_mat(computed_HD, 2)
    TK = 1000  #  -------------------------------
    sosHD = bp.sumofstate_HD(TK)
    computed_HD = compute_series_para.spectra_HD( TK, OJ_HD, QJ_HD,
                                                 SJ_HD, sosHD)

    calc_600_HD=gen_intensity_mat (computed_HD, 2)
    diff_HD = calc_298_HD - calc_600_HD
    cr_HD = clean_mat(diff_HD)

    return set_nan_if_foundzero(cr_HD, array)
Beispiel #3
0
def T_independent_index():

    TK = 298  #  --------------------------------
    sosD2 = bp.sumofstate_D2(TK)
    sosHD = bp.sumofstate_HD(TK)

    computed_D2 = compute_series_para.spectra_D2( TK, OJ_D2, QJ_D2,
                                                 SJ_D2, sosD2)
    computed_HD = compute_series_para.spectra_HD( TK, OJ_HD, QJ_HD,
                                                 SJ_HD, sosHD)

    calc_298_D2 = gen_intensity_mat(computed_D2, 2)
    calc_298_HD = gen_intensity_mat(computed_HD, 2)

    TK = 1000  #  -------------------------------
    sosD2 = bp.sumofstate_D2(TK)
    sosHD = bp.sumofstate_HD(TK)

    computed_D2 = compute_series_para.spectra_D2( TK, OJ_D2, QJ_D2,
                                                 SJ_D2, sosD2)
    computed_HD = compute_series_para.spectra_HD( TK, OJ_HD, QJ_HD,
                                                 SJ_HD, sosHD)

    calc_600_D2=gen_intensity_mat (computed_D2, 2)
    calc_600_HD=gen_intensity_mat (computed_HD, 2)

    diff_D2 = calc_298_D2 - calc_600_D2
    diff_HD = calc_298_HD - calc_600_HD

    cr_D2 = clean_mat(diff_D2)
    cr_HD = clean_mat(diff_HD)

    index_D2 = np.nonzero(np.abs(cr_D2) >1e-10)
    index_HD = np.nonzero(np.abs(cr_HD) >1e-10)

    return index_D2, index_HD
Beispiel #4
0
def residual_linear(param):
    '''Function which computes the residual (as sum of squares) comparing the
    ratio of expt to theoretical intensity ratio to the sensitivity  profile
    modelled as  a line, ( 1+ c1*x )

    param : T, c1

    '''

    TK = 298

    sosD2 = bp.sumofstate_D2(TK)
    sosHD = bp.sumofstate_HD(TK)

    computed_D2 = compute_series_para.spectra_D2(TK, OJ_D2, QJ_D2,
                                                 SJ_D2, sosD2)
    computed_HD = compute_series_para.spectra_HD(TK, OJ_HD, QJ_HD,
                                                 SJ_HD, sosHD)

    # ------ D2 ------
    trueR_D2 = gen_intensity_mat(computed_D2, 2)
    expt_D2 = gen_intensity_mat(dataD2, 0)
    I_D2 = np.divide(expt_D2, trueR_D2)
    #I_D2 = clean_mat(I_D2)
    # ----------------

    # ------ HD ------
    trueR_HD = gen_intensity_mat(computed_HD, 2)
    expt_HD = gen_intensity_mat(dataHD, 0)
    I_HD = np.divide(expt_HD, trueR_HD)
    #I_HD = clean_mat(I_HD)
    # ----------------

    #I_D2[indexD2] = 0
    #I_HD[indexHD] = 0

    # generate the RHS : sensitivity factor
    sD2 = gen_s_linear(computed_D2, param)
    sHD = gen_s_linear(computed_HD, param)

    # weight
    #errD2 = gen_weight(expt_D2)
    #errHD = gen_weight(expt_HD)
    #errD2 = clean_mat(errD2)
    #errD2[indexD2] = 0
    #np.savetxt("error_test", errD2, fmt='%3.3f')

    # residual matrix
    eD2 = I_D2 - sD2
    eHD = I_HD - sHD

    eD2 = np.multiply(wMat_D2, eD2)
    eHD = np.multiply(wMat_HD, eHD)

    eD2 = clean_mat(eD2)
    eHD = clean_mat(eHD)

    # E = np.sum(np.square(eD2)) + np.sum(np.square(eHD))

    eD2[indexD2] = 0
    eHD[indexHD] = 0
    np.savetxt("errD2_test", eD2, fmt='%3.3f')
    np.savetxt("errHD_test", eHD, fmt='%3.3f')

    #E = np.sum(np.abs(eD2)) + np.sum(np.abs(eHD))
    E = np.sum(np.square(eD2)) + np.sum(np.square(eHD))

    return(E)
Beispiel #5
0
# ------------------------------------------------

wMat_D2 = 1
wMat_HD = 1.2
wMat_H2 = 1

# checks for input done here

# generate calculated data for the entered J values
TK=299
sosD2 = bp.sumofstate_D2(TK)
sosHD = bp.sumofstate_HD(TK)
sosH2 = bp.sumofstate_H2(TK)

computed_D2 = compute_series_para.spectra_D2(TK, OJ_D2, QJ_D2, SJ_D2, sosD2)
computed_HD = compute_series_para.spectra_HD(TK, OJ_HD, QJ_HD, SJ_HD, sosHD)
computed_H2 = compute_series_para.spectra_H2_c(TK, OJ_H2, QJ_H2, sosH2)

# checks for dimension match done here
if (computed_D2.shape[0] != dataD2.shape[0]):
    print('D2 : Dimension of input data does not match with the calculated\
           spectra. Check input expt data or the J-indices entered.')
    sys.exit("\tError: Quitting.")

if (computed_HD.shape[0] != dataHD.shape[0]):
    print('H2 : Dimension of input data does not match with the calculated\
           spectra. Check input expt data or the J-indices entered.')
    sys.exit("\tError: Quitting.")

if (computed_H2.shape[0] != dataH2.shape[0]):
    print('H2 : Dimension of input data does not match with the calculated\