Exemple #1
0
def alpha(freq, T, P, X, P_dict, other_dict, **kwargs):
    par = parameters.setpar(kwargs)

    P_h2 = P * X[P_dict['H2']]
    P_he = P * X[P_dict['HE']]
    P_ch4 = P * X[P_dict['CH4']]
    th = T0 / T
    alpha_h2 = []
    for f in freq:
        f2 = f**2
        if other_dict['h2state'] == 'e':
            pre = (T / 55.0)**2.7
            if pre > 1.0:
                pre = 1.0
            pre *= (T / 120.0)**0.55
            if pre > 1.0:
                pre = 1.0
        elif other_dict['h2state'] == 'n':
            pre = (T / 40.0)**2.5
            if pre > 1.0:
                pre = 1.0
        else:
            print('INVALID H2STATE')
            return 0.0
        cf = coef * f2 * P_h2 * pre
        a = cf * (P_h2 * pow(th, 3.12) + 1.382 * P_he * pow(th, 2.24) +
                  9.322 * P_ch4 * pow(th, 3.34))
        if par.units == 'dBperkm':
            a *= 434294.5
        alpha_h2.append(a)

    return alpha_h2
Exemple #2
0
def alpha(freq, T, P, X, P_dict, other_dict, **kwargs):

    # Read in data if needed
    par = parameters.setpar(kwargs)
    if len(f0) == 0:
        readInputFiles(par)

    P_h2 = P * X[P_dict['H2']]
    P_he = P * X[P_dict['HE']]
    P_h2o = P * X[P_dict['H2O']]
    n_int = 3.0 / 2.0
    rho = 1.0E12 * AMU_H2O * P_h2o / (R * T)
    Pa = 0.81 * P_h2 + 0.35 * P_he

    alpha_h2o = []
    for f in freq:
        f2 = f**2
        alpha = 0.0
        for i in range(nlin):
            gamma = pow((T0 / T), x_H2[i]) * GH2[i] * P_h2
            gamma += pow((T0 / T), x_He[i]) * GHe[i] * P_he
            gamma += pow((T0 / T), x_H2O[i]) * GH2O[i] * P_h2o
            g2 = gamma**2
            ITG = A[i] * math.exp(-Ei[i] / T)
            shape = gamma / ((f0[i]**2 - f2)**2 + 4.0 * f2 * g2)
            alpha += shape * ITG
        GR1971 = 1.08E-11 * rho * pow((T0 / T), 2.1) * Pa * f2
        a = 2.0 * f2 * rho * pow(
            (T0 / T), n_int) * alpha / 434294.5 + GR1971 / 434294.5
        if par.units == 'dBperkm':
            a *= 434294.5
        alpha_h2o.append(a)

    return alpha_h2o
Exemple #3
0
def alpha(freq, T, P, X, P_dict, other_dict, **kwargs):

    par = parameters.setpar(kwargs)
    # Read in data if needed
    global data
    if data is None:
        readInputFiles(par)

    P_h2 = P * X[P_dict['H2']]
    P_he = P * X[P_dict['HE']]
    P_nh3 = P * X[P_dict['NH3']]
    f0 = data['f0']
    I0 = data['I0']
    E = data['E']
    G0 = data['G0']
    nlin = len(f0)

    GH2 = 2.318
    GHe = 0.790
    GNH3 = 0.750
    ZH2 = 1.920
    ZHe = 0.300
    ZNH3 = 0.490
    # C = 1.0075 + (0.0308 + 0.552 * P_h2 / T) * P_h2 / T
    D = -0.45
    n_dvl = 2.0 / 3.0
    n_int = 3.0 / 2.0
    delta = D * P_nh3

    alpha_nh3 = []
    for f in freq:
        f2 = f**2
        alpha = 0.0
        for i in range(nlin):
            gamma = pow(
                (T0 / T),
                n_dvl) * (GH2 * P_h2 + GHe * P_he + G0[i] * GNH3 * P_nh3)
            g2 = gamma**2
            zeta = pow(
                (T0 / T),
                n_dvl) * (ZH2 * P_h2 + ZHe * P_he + G0[i] * ZNH3 * P_nh3)
            z2 = zeta**2
            ITG = I0[i] * math.exp(-((1.0 / T) - (1.0 / T0)) * E[i] * hck)
            num = (gamma - zeta) * f2 + (gamma + zeta) * (
                pow(f0[i] + delta, 2.0) + g2 - z2)
            den = pow(
                (f2 - pow(f0[i] + delta, 2.0) - g2 + z2), 2.0) + 4.0 * f2 * g2
            shape = GHz * 2.0 * pow(f / f0[i], 2.0) * num / (math.pi * den)
            alpha += shape * ITG

        a = coef * (P_nh3 / T0) * pow((T0 / T), n_int + 2) * alpha
        if par.units == 'dBperkm':
            a *= 434294.5
        alpha_nh3.append(a)

    return alpha_nh3
Exemple #4
0
def alpha(freq, T, P, cloud, cloud_dict, other_dict, **kwargs):
    """
    Adapted from Imke's code, but used Ulaby, Moore and Fung (see e.g. p310).
    'fraction' below scales the absorption cross-section relative to water.
    """
    alpha_cloud = []
    par = parameters.setpar(kwargs)
    for f in freq:
        alpha = 0.0
        k = (2.0 * np.pi * f / GHz)  # *other_dict['refr']  # in cm^-1
        if 'ice_p' in other_dict.keys() and other_dict['ice_p'] > 0.0:
            fraction = cloud[cloud_dict['H2O']] / 0.9   # g/cm^3 / g/cm^3
            e = water(f, T)
            alpha += acloud(k, fraction, e)
        if 'water_p' in other_dict.keys() and other_dict['water_p'] > 0.0:
            fraction = cloud[cloud_dict['SOLN']] / 1.0
            e = water(f, T)
            alpha += acloud(k, fraction, e)
        if 'nh4sh_p' in other_dict.keys() and other_dict['nh4sh_p'] > 0.0:
            fraction = cloud[cloud_dict['NH4SH']] / 1.2
            # nImke = 1.7 - 0.05j
            # nDeBoer = 1.74 - 0.001j
            n = 1.7 - 0.005j
            e = n**2
            alpha += acloud(k, fraction, e)
        if 'nh3ice_p' in other_dict.keys() and other_dict['nh3ice_p'] > 0.0:
            fraction = cloud[cloud_dict['NH3']] / 1.6
            # nImke = 1.3 - 0.05j
            # nDeBoer = 1.3 - 0.005j
            n = 1.3 - 0.0001j
            e = n**2
            alpha += acloud(k, fraction, e)
        if 'h2sice_p' in other_dict.keys() and other_dict['h2sice_p'] > 0.0:
            fraction = cloud[cloud_dict['H2S']] / 1.5
            # nImke = 1.3 - 0.01j
            # nDeBoer = 1.15 - 0.001j
            n = 1.15 - 0.0001j
            e = n**2
            alpha += acloud(k, fraction, e)
        if 'ch4' in other_dict.keys() and other_dict['ch4'] > 0.0:
            fraction = cloud[cloud_dict['CH4']] / 1.0
            n = 1.3 - 0.00001j
            e = n**2
            alpha += acloud(k, fraction, e)
        if alpha < 0.0:
            print("Warning:  cloud alpha<0.  Reset to 0")
            alpha = 0.0
        if par.units == 'dBperkm':
            alpha *= 434294.5
        alpha_cloud.append(alpha)
    if par.verbose:
        print('cloud absorption: ', alpha_cloud)
    return alpha_cloud
Exemple #5
0
def alpha(freq, T, P, X, P_dict, other_dict, **kwargs):
    """Computes absorption due to h2s"""

    par = parameters.setpar(kwargs)
    # Read in data if needed
    global data
    if data is None:
        readInputFiles(par)

    P_h2 = P * X[P_dict['H2']]
    P_he = P * X[P_dict['HE']]
    P_h2s = P * X[P_dict['H2S']]
    f0 = data['f0']
    I0 = data['I0']
    E = data['E']
    GH2S = data['GH2S']
    GH2 = 1.960
    GHe = 1.200
    # ZH2 = 0.000
    # ZHe = 0.000
    # ZH2S = 0.000
    # C = 1.0
    D = 1.28
    n_dvl = 0.7
    n_int = 3.0 / 2.0
    delta = D * P_h2s
    gamma = np.power(
        (T0 / T), n_dvl) * (GH2 * P_h2 + GHe * P_he + GH2S * P_h2s)
    g2 = gamma**2
    zeta = gamma
    z2 = zeta**2
    ITG = I0 * np.exp(-((1.0 / T) - (1.0 / T0)) * E * hck)

    alpha_h2s = []
    for f in freq:
        f2 = f**2
        num = (gamma - zeta) * f2 + (gamma + zeta) * (
            np.power(f0 + delta, 2.0) + g2 - z2)
        den = np.power(
            (f2 - np.power(f0 + delta, 2.0) - g2 + z2), 2.0) + 4.0 * f2 * g2
        shape = GHz * 2.0 * np.power(f / f0, 2.0) * num / (np.pi * den)
        alpha_h2s.append(np.sum(shape * ITG))

    alpha_h2s = coef * (P_h2s / T0) * pow(
        (T0 / T), n_int + 2) * np.array(alpha_h2s)
    if par.units == 'dBperkm':
        alpha_h2s *= 434294.5
    del num, den, shape

    return alpha_h2s
Exemple #6
0
def alpha(freq, T, P, X, P_dict, other_dict, **kwargs):
    """Computes the absorption due to ph3"""

    par = parameters.setpar(kwargs)
    # Read in data if needed
    if data is None:
        readInputFiles(par)

    P_h2 = P * X[P_dict['H2']]
    P_he = P * X[P_dict['HE']]
    P_ph3 = P * X[P_dict['PH3']]
    f0 = data['f0']
    I0 = data['I0']
    E = data['E']
    WgtI0 = data_wgt['WgtI0']
    WgtFGB = data_wgt['WgtFGB']
    WgtSB = data_wgt['WgtSB']

    # Line parameters
    GH2 = 3.2930
    GHe = 1.6803
    GPH3 = 4.2157
    n_dvl = 2.0 / 3.0
    n_int = 3.0 / 2.0
    zeta = 0.0
    z2 = zeta**2
    delta = 0.0
    gamma = np.power(
        (T0 / T), n_dvl) * (GH2 * P_h2 + GHe * P_he) * WgtFGB + np.power(
            (T0 / T), 1.0) * GPH3 * P_ph3 * WgtSB  # noqa
    g2 = gamma**2
    ITG = I0 * WgtI0 * np.exp(-((1.0 / T) - (1.0 / T0)) * E * hck)

    alpha_ph3 = []
    for f in freq:
        f2 = f**2
        num = (gamma - zeta) * f2 + (gamma + zeta) * (
            (f0 + delta)**2 + g2 - z2)
        den = (f2 - (f0 + delta)**2 - g2 + z2)**2 + 4.0 * f2 * g2
        shape = GHz * 2.0 * ((f / f0)**2) * num / (PI * den)
        alpha_ph3.append(np.sum(shape * ITG))

    alpha_ph3 = coef * (P_ph3 / T0) * np.power(
        (T0 / T), n_int + 2) * np.array(alpha_ph3)
    if par.units == 'dBperkm':
        alpha_ph3 *= 434294.5

    del num, den, shape
    return alpha_ph3
Exemple #7
0
def alpha(freq, T, P, X, P_dict, other_dict, **kwargs):
    """Wrapper to handle f_split"""
    alpha_nh3 = None

    par = parameters.setpar(kwargs)
    # Check lo range
    freq = np.array(freq)
    frq = freq[np.where([x <= f_split for x in freq])]
    if len(frq):
        alpha_nh3 = __alpha__(frq, T, P, X, P_dict, other_dict, par)
    # Check hi range
    frq = freq[np.where([x > f_split for x in freq])]
    if len(frq):
        a_hi = __alpha__(frq, T, P, X, P_dict, other_dict, par)
        if alpha_nh3 is None:
            alpha_nh3 = a_hi
        else:
            alpha_nh3 = np.concatenate((alpha_nh3, a_hi))
    return alpha_nh3
Exemple #8
0
def alpha(freq, T, P, X, P_dict, other_dict, **kwargs):

    par = parameters.setpar(kwargs)
    # Read in data if needed
    if len(f0) == 0:
        readInputFiles(par)

    P_h2 = P * X[P_dict['H2']]
    P_he = P * X[P_dict['HE']]
    P_co = P * X[P_dict['CO']]

    GH2 = 1.960
    GHe = 1.200
    GCO = 6.000
    n_dvl = 0.7
    n_int = 3.0 / 2.0
    gamma = pow((T0 / T), n_dvl) * (GH2 * P_h2 + GHe * P_he + GCO * P_co)
    g2 = gamma**2
    zeta = 0.0
    z2 = zeta**2
    delta = 0.0

    alpha_co = []
    for f in freq:
        f2 = f**2
        alpha = 0.0
        for i in range(nlin):
            ITG = I0[i] * math.exp(-((1.0 / T) - (1.0 / T0)) * E[i] * hck)
            num = (gamma - zeta) * f2 + (gamma + zeta) * (
                pow(f0[i] + delta, 2.0) + g2 - z2)
            den = pow(
                (f2 - pow(f0[i] + delta, 2.0) - g2 + z2), 2.0) + 4.0 * f2 * g2
            shape = GHz * 2.0 * pow(f / f0[i], 2.0) * num / (math.pi * den)
            alpha += shape * ITG

        a = coef * (P_co / T0) * pow((T0 / T), n_int + 2) * alpha
        if par.units == 'dBperkm':
            a *= 434294.5
        alpha_co.append(a)

    return alpha_co
Exemple #9
0
def alpha(freq, T, P, X, P_dict, other_dict, **kwargs):
    """function alphanh3=NH3_Consistent_Model(f,T,P,H2mr,Hemr,NH3mr)
    % The data files containing the frequency, line intensity and lower state
    % energy for the ammonia transitions as given in the latest JPL spectral
    % line catalog provided by Shanshan Yu and Brian Droiun  (personal
    % communication, 2010), and the self and foreign gas broadening
    % parameters for the various transitions as given by Devaraj 2011 are
    % loaded in the following steps. """
    global GHztoinv_cm, OpticaldepthstodB, torrperatm, bartoatm
    global GHztoMHz, hc, kB, No, R, To, dynesperbar, coef

    par = parameters.setpar(kwargs)
    global data
    if data is None:
        readInputFiles(par)

    fo = data['fo']
    Io = data['Io']
    Eo = data['Eo']
    gammaNH3o = data['gammaNH3o']
    # H2HeBroad = data['H2HeBroad']
    fo_rot = data['fo_rot']
    Io_rot = data['Io_rot']
    Eo_rot = data['Eo_rot']
    gNH3_rot = data['gNH3_rot']
    gH2_rot = data['gH2_rot']
    gHe_rot = data['gHe_rot']
    fo_v2 = data['fo_v2']
    Io_v2 = data['Io_v2']
    Eo_v2 = data['Eo_v2']

    print(P, type(P))
    P_h2 = P * np.array(X[P_dict['H2']])
    P_he = P * np.array(X[P_dict['HE']])
    P_nh3 = P * np.array(X[P_dict['NH3']])

    # %% Computing partial pressures, temperature factor, and coefficient for ammonia
    # % Compute the mixing ratios of  of H2, He, and NH2
    # H2mr = P_h2 / P
    # Hemr = P_he / P
    # NH3mr = P_nh3 / P
    # % Compute the temperature factor
    Tdiv = To / T
    # %  Coefficient for symmetric top molecule
    eta = 3.0 / 2.0

    # ###################INVERSION LINES
    # % Pressure Dependent Switch for the parameters of the inversion transitions
    # ddb 141218:  put in linear transition
    P_trans = 15.0
    dP_up = 5.0
    dP_down = 3.0
    if P > P_trans + dP_up:
        gnu_H2 = 1.6361;    gnu_He = 0.4555;    gnu_NH3 = 0.7298  # noqa
        GAMMA_H2 = 0.8;     GAMMA_He = 0.5;     GAMMA_NH3 = 1.0  # noqa
        zeta_H2 = 1.1313;   zeta_He = 0.1;      zeta_NH3 = 0.5152  # noqa
        Z_H2 = 0.6234;      Z_He = 0.5;         Z_NH3 = 2.0/3.0  # noqa
        d = 0.2
        Con = 1.3746
    elif P <= P_trans - dP_down:
        gnu_H2=1.7465;      gnu_He=0.9779;      gnu_NH3=0.7298  # noqa
        GAMMA_H2=0.8202;    GAMMA_He=1.0;       GAMMA_NH3=1.0  # noqa
        zeta_H2=1.2163;     zeta_He=0.0291;     zeta_NH3=0.5152  # noqa
        Z_H2=0.8873;        Z_He=0.8994;        Z_NH3=2.0/3.0  # noqa
        d = -0.0627
        Con = 0.9862
    else:  # in linear transition region
        gnu_H2 = 1.7465 + (1.7465 - 1.6361)*(15.0-dP_down - P)/(dP_up + dP_down)
        gnu_He = 0.9779 + (0.9779 - 0.4555)*(15.0-dP_down - P)/(dP_up + dP_down)
        gnu_NH3 = 0.7298
        GAMMA_H2 = 0.8202 + (0.8202 - 0.8)*(15.0-dP_down - P)/(dP_up + dP_down)
        GAMMA_He = 1.0 + (1. - 0.5)*(15.0-dP_down - P)/(dP_up + dP_down)
        GAMMA_NH3 = 1.0
        zeta_H2 = 1.2163 + (1.2163 - 1.1313)*(15.0-dP_down - P)/(dP_up + dP_down)
        zeta_He = 0.0291 + (0.0291 - 0.1)*(15.0-dP_down - P)/(dP_up + dP_down)
        zeta_NH3 = 0.5152
        Z_H2 = 0.8873 + (0.8873 - 0.6234)*(15.0-dP_down - P)/(dP_up + dP_down)
        Z_He = 0.8994 + (0.8994 - 0.5)*(15.0-dP_down - P)/(dP_up + dP_down)
        Z_NH3 = 2.0/3.0
        d = -0.0627 + (-0.0627 - 0.2)*(15.0-dP_down - P)/(dP_up + dP_down)
        Con = 0.9862 + (0.9862 - 1.3746)*(15.0-dP_down - P)/(dP_up + dP_down)

    gammaNH3omat = np.matrix(gammaNH3o)
    # % Individual broadening parameters
    gH2 = gnu_H2 * P_h2
    gHe = gnu_He * P_he
    gNH3 = gnu_NH3 * P_nh3 * gammaNH3omat
    # % Broadening parameter
    gamma = ((gH2) * ((Tdiv)**(GAMMA_H2)) + (gHe) * ((Tdiv)**(GAMMA_He)) + gNH3 * (295.0 / T)**(GAMMA_NH3))  # noqa
    # % Shift parameter
    delt = d * gamma
    # % Individual coupling parameters
    zH2 = zeta_H2 * P_h2
    zHe = zeta_He * P_he
    zNH3 = zeta_NH3 * P_nh3 * gammaNH3omat
    # % Coupling parameter
    zeta = (zH2) * ((Tdiv)**(Z_H2)) + (zHe) * ((Tdiv)**(Z_He)) + zNH3 * (295.0 / T)**(Z_NH3)

    # zetasize = np.size(fo)
    pst = delt      							# % answer in GHz
    # %Coupling element, pressure shift and dnu or gamma are in GHz, need to convert brlineshape
    # to inverse cm which is done below
    n = np.size(freq)
    m = np.size(fo)
    fmat = np.matrix(freq)
    fomat = np.transpose(np.matrix(fo))
    # % f1 f2 f3 f4 ....fn  n times where n is the number of frequency steps
    # % f1 f2 f3 f4 ....fn				in the observation range
    # % ...
    # % f1 f2 f3 f4 ....fn
    # % m times where m is the number of spectral lines

    nones = np.matrix(np.ones(n))
    mones = np.transpose(np.matrix(np.ones(m)))
    f_matrix = mones * fmat
    fo_matrix = fomat * nones

    # % The 10^6 allows use of P(bar) for P(dynes/cm^2)
    expo = []
    ST = []
    alpha_noshape = []
    for i, eo in enumerate(Eo):
        expo.append(-(1.0/T-1.0/To)*eo*hc/kB)
        ST.append(Io[i]*math.exp(expo[i]))	 # % S(T) =S(To)converted for temperature
        alpha_noshape.append(Con*coef*(P_nh3/To)*((To/T)**(eta+2.0))*ST[i])  # %0.9387
    # %Ben Reuven lineshape calculated by the brlineshape function gives the answer in GHz
    # %Here we change from GHz to inverse cm.

    dnu_matrix = np.transpose(gamma)*nones
    ce_matrix = np.transpose(zeta)*nones
    pst_matrix = np.transpose(pst)*nones
    Aa = (2.0/math.pi)*np.square(np.divide(f_matrix, fo_matrix))
    Bb = np.multiply((dnu_matrix-ce_matrix), np.square(f_matrix))
    Cc = dnu_matrix+ce_matrix
    Dd = np.square(fo_matrix+pst_matrix) + np.square(dnu_matrix)-np.square(ce_matrix)
    Ee = np.square(f_matrix)
    Jj = np.square(fo_matrix+pst_matrix)
    Gg = np.square(dnu_matrix)
    Hh = np.square(ce_matrix)
    Ii = 4.0*np.multiply(np.square(f_matrix), np.square(dnu_matrix))
    Ff = np.divide(np.multiply(Aa, Bb+np.multiply(Cc, Dd)), np.square(Ee-Jj-Gg+Hh) + Ii)
    Fbr = (1.0/GHztoinv_cm)*Ff
    alpha_noshapemat = np.transpose(np.matrix(alpha_noshape))
    alpha_noshape_matrix = alpha_noshapemat*nones
    alpha_inversion = np.multiply(alpha_noshape_matrix, Fbr)

    # ###################ROTATIONAL LINES
    ST_rot = []
    for i, eo in enumerate(Eo_rot):
        ST_rot.append(Io_rot[i]*(math.exp((1.0/To-1.0/T)*eo*hc/kB)))
    STmat_rot = np.transpose(np.matrix(ST_rot))
    # % Factor GAMMA:
    eta_H2 = 0.8730
    eta_He = 2.0/3.0
    eta_NH3 = 1.0
    # % Factor nu:
    gnu_H2 = 0.2984
    gnu_He = 0.75
    gnu_NH3 = 3.1789
    # % Factor Con
    Con = 2.4268
    # % Individual broadening
    gH2 = gnu_H2*P_h2*np.matrix(gH2_rot)
    gHe = gnu_He*P_he*np.matrix(gHe_rot)
    gNH3 = gnu_NH3*P_nh3*np.matrix(gNH3_rot)
    # % Total broadening
    gamma_rot = ((gH2)*((Tdiv)**(eta_H2))+(gHe)*((Tdiv)**(eta_He))+gNH3*(Tdiv)**(eta_NH3))
    n = np.size(freq)
    m = np.size(fo_rot)
    fmat = np.matrix(freq)
    fomat = np.transpose(np.matrix(fo_rot))
    nones = np.matrix(np.ones(n))
    mones = np.transpose(np.matrix(np.ones(m)))
    f_matrix = mones*fmat
    fo_matrix = fomat*nones
    dnu_matrix = np.transpose(gamma_rot)*nones
    # % Gross Lineshape
    Aa = (4.0/math.pi)*np.multiply(np.square(f_matrix), dnu_matrix)
    Bb = np.square(np.square(fo_matrix)-np.square(f_matrix))
    Cc = 4.0*np.multiply(np.square(f_matrix), np.square(dnu_matrix))
    F_rot = np.divide(Aa, Bb+Cc)
    Fbr_rot = (1/GHztoinv_cm)*F_rot
    alpha_rot = np.multiply(Con*coef*(P_nh3/To)*((To/T)**(eta+2.0))*STmat_rot*nones, Fbr_rot)

    # %% Computing the opacity due to v2 roto-vibrational lines
    # % Computing the absorption contributed by the v2 rotovibrational lines
    ST_v2 = []
    for i, eo in enumerate(Eo_v2):
        ST_v2.append(Io_v2[i]*(math.exp((1./To-1./T)*eo*hc/kB)))
    STmat_v2 = np.transpose(np.matrix(ST_v2))
    # % Broadening parameters for the v2 vibrational lines
    gH2_v2 = np.transpose(np.matrix(np.linspace(1.4, 1.4, len(fo_v2))))
    gHe_v2 = np.transpose(np.matrix(np.linspace(0.68, 0.68, len(fo_v2))))
    gNH3_v2 = np.transpose(np.matrix(np.linspace(9.5, 9.5, len(fo_v2))))
    # % Factor GAMMA
    eta_H2 = 0.73
    eta_He = 0.5716
    eta_NH3 = 1.0
    # % Factor Con
    Con = 1.1206
    # % Individual broadening parameters
    gH2 = P_h2*gH2_v2
    gHe = P_he*gHe_v2
    gNH3 = P_nh3*gNH3_v2
    # %Total broadening
    gamma_v2 = ((gH2)*((Tdiv)**(eta_H2))+(gHe)*((Tdiv)**(eta_He))+gNH3*(Tdiv)**(eta_NH3))
    n = np.size(freq)
    m = np.size(fo_v2)
    fmat = np.matrix(freq)
    fomat = np.transpose(np.matrix(fo_v2))
    nones = np.matrix(np.ones(n))
    mones = np.transpose(np.matrix(np.ones(m)))
    f_matrix = mones*fmat
    fo_matrix = fomat*nones
    dnu_matrix = gamma_v2*nones
    # #% Gross Lineshape
    Aa = (4.0/math.pi)*np.multiply(np.square(f_matrix), dnu_matrix)
    Bb = np.square(np.square(fo_matrix)-np.square(f_matrix))
    Cc = 4.0*np.multiply(np.square(f_matrix), np.square(dnu_matrix))
    F_v2 = np.divide(Aa, Bb+Cc)
    Fbr_v2 = (1/GHztoinv_cm)*F_v2
    alpha_v2 = np.multiply(Con*coef*(P_nh3/To)*((To/T)**(eta+2.0))*STmat_v2*nones, Fbr_v2)

    # %% Computing the total opacity
    alpha_opdep = (np.sum(np.transpose(alpha_inversion), 1)+np.sum(np.transpose(alpha_rot), 1) +
                   np.sum(np.transpose(alpha_v2), 1))
    alpha_opdep = np.array(np.transpose(alpha_opdep))
    if par.units == 'dBperkm':
        alpha_opdep *= OpticaldepthstodB
    alpha_nh3_temp = np.ndarray.tolist(np.ndarray.flatten(alpha_opdep))
    alpha_nh3 = []
    for aaa in alpha_nh3_temp:
        if aaa <= 0.0:
            aaa = 1E-8
        alpha_nh3.append(aaa)

    return alpha_nh3
Exemple #10
0
def alpha(freq, T, P, X, P_dict, other_dict, **kwargs):
    Joiner = 0
    Spilker = 1
    Interp = 2

    par = parameters.setpar(kwargs)
    # Read in data if needed
    global data
    if data is None:
        readInputFiles(par)

    P_h2 = P * X[P_dict['H2']]
    P_he = P * X[P_dict['HE']]
    P_nh3 = P * X[P_dict['NH3']]
    Pscale = 1.0 + P / 1.0E5  # ad hoc to make this match Berge-Gulkis for deep Jupiter atmosphere

    # Set Joiner
    GH2 = [1.690]
    GHe = [0.750]
    GNH3 = [0.6]
    ZH2 = [1.350]
    ZHe = [0.300]
    ZNH3 = [0.200]
    C = [1.0]
    D = [-0.45]
    # Set Spilker
    rexp = 8.79 * np.exp(-T / 83.0)
    GH2a = np.exp(9.024 - T / 20.3) - 0.9918 + P_h2
    try:
        GH2a = np.power(GH2a, rexp)
    except ValueError:
        GH2a = 0.0
    if GH2a < EPS:  # use Joiner regardless
        GH2.append(1.690)
        GHe.append(0.750)
        GNH3.append(0.60)
        ZH2.append(1.35)
        ZHe.append(0.30)
        ZNH3.append(0.20)
        C.append(1.00)
        D.append(-0.45)
    else:
        GH2a = 2.122 * np.exp(-T / 116.8) / GH2a
        GH2a = 2.34 * (1.0 - GH2a)
        GH2.append(GH2a)
        GHe.append(0.46 + T / 3000.0)
        GNH3.append(0.74)
        ZH2.append(5.7465 - 7.7644 * GH2a + 9.1931 * GH2a**2 -
                   5.6816 * GH2a**3 + 1.2307 * GH2a**4)
        ZHe.append(0.28 - T / 1750.0)
        ZNH3.append(0.50)
        C.append(-0.337 + T / 110.4 - T**2 / 70600.0)
        D.append(-0.45)
    # Set interp index
    GH2.append(0.0)
    GHe.append(0.0)
    GNH3.append(0.0)
    ZH2.append(0.0)
    ZHe.append(0.0)
    ZNH3.append(0.0)
    C.append(0.0)
    D.append(0.0)
    f0 = data['f0']
    I0 = data['I0']
    E = data['E']
    G0 = data['G0']
    n_dvl = 2.0 / 3.0
    n_int = 3.0 / 2.0
    ITG = I0 * np.exp(-((1.0 / T) - (1.0 / T0)) * E * hck)
    alpha_nh3 = []
    for f in freq:
        f2 = f**2
        if f <= fLower:
            use = Spilker
        elif f >= fHigher:
            use = Joiner
        else:
            use = Interp
            flfh = (fLower - fHigher) / (f - fLower)
            GH2[Interp] = GH2[Spilker] + (GH2[Spilker] - GH2[Joiner]) / flfh
            GHe[Interp] = GHe[Spilker] + (GHe[Spilker] - GHe[Joiner]) / flfh
            GNH3[Interp] = GNH3[Spilker] + (GNH3[Spilker] -
                                            GNH3[Joiner]) / flfh
            ZH2[Interp] = ZH2[Spilker] + (ZH2[Spilker] - ZH2[Joiner]) / flfh
            ZHe[Interp] = ZHe[Spilker] + (ZHe[Spilker] - ZHe[Joiner]) / flfh
            ZNH3[Interp] = ZNH3[Spilker] + (ZNH3[Spilker] -
                                            ZNH3[Joiner]) / flfh
            C[Interp] = C[Spilker] + (C[Spilker] - C[Joiner]) / flfh
            D[Interp] = D[Spilker] + (D[Spilker] - D[Joiner]) / flfh
        delta = D[use] * P_nh3

        gamma = np.power((T0 / T), n_dvl) * (
            GH2[use] * P_h2 + GHe[use] * P_he + G0 * GNH3[use] * P_nh3)  # noqa
        g2 = gamma**2
        zeta = np.power((T0 / T), n_dvl) * (
            ZH2[use] * P_h2 + ZHe[use] * P_he + G0 * ZNH3[use] * P_nh3)  # noqa
        z2 = zeta**2

        num = (gamma - zeta) * f2 + (gamma + zeta) * (
            np.power(f0 + delta, 2.0) + g2 - z2)
        den = np.power(
            (f2 - np.power(f0 + delta, 2.0) - g2 + z2), 2.0) + 4.0 * f2 * g2
        shape = GHz * 2.0 * np.power(f / f0, 2.0) * num / (np.pi * den)
        alpha_nh3.append(np.sum(shape * ITG))

    alpha_nh3 = coef * (P_nh3 / T0) * pow(
        (T0 / T), n_int + 2) * np.array(alpha_nh3) * Pscale
    if par.units == 'dBperkm':
        alpha_nh3 *= 434294.5

    return alpha_nh3
Exemple #11
0
def alpha(f, T, P, X, P_dict, other_dict, **kwargs):
    """This is Karpowicz's model from:
       http://users.ece.gatech.edu/~psteffes/palpapers/karpowicz_data/water_model/karpowicz_h2o_model.m
       This function also requires the vvwlineshape function originally written by Jim Hoffman (with
       removal of df factor).
       Also added shift term as is done in Rosenkranz's work.
       Rosenkranz 1998 Radio Science vol 33, pp919-928
       NB (DDB): f may be a list, but T, P, etc should be scalars"""

    par = parameters.setpar(kwargs)
    global data
    if data is None:
        readInputFiles(par)

    par = parameters.setpar(kwargs)
    P_h2 = P * X[P_dict['H2']]
    P_he = P * X[P_dict['HE']]
    P_h2o = P * X[P_dict['H2O']]
    Theta = To / T

    density_h2o = (M_amu * P_h2o) / (8.314472e-5 * T)
    # density_he = (M_amu_he * P_he) / (8.314310e-5 * T)
    # density_h2 = (M_amu_h2 * P_h2) / (8.314472e-5 * T)
    density_h2o = isotope_partition * (density_h2o / M_amu) * NA * (
        1.0 / 1e6)  # need in mol/cc

    # ###Calculate the line-broadening terms
    expo = data['E_o'] * (1.0 - Theta)
    S = data['I_o'] * (Theta**2.5) * np.exp(expo)
    # df aka gamma delta-nu change aka pressure broadening term
    df = data['w_s'] * P_h2o * np.power(Theta, data['x_s'])\
        + data['w_h2'] * P_h2 * np.power(Theta, data['x_h2'])\
        + data['w_he'] * P_he * np.power(Theta, data['x_he'])
    # calculate van-vleck line contribution...returns array of line contributions
    FSsum = vvwlinecontribution_modified(f, data['f_o'], df, data['SR'], S)
    line_contribution = inv_km_to_dB * convert_to_km * density_h2o * FSsum

    # ###Calculate the continuum terms
    Cf_he = (
        (1.0 / mbars_to_bars)**2
    ) * 1.03562010226e-10  # noqa (dB/km)/((GHz x kPa)^2)->db/km((GHz bars)^2)  #eqn 10 Rosenkranz,1998
    Cf_h2 = ((1.0 / mbars_to_bars)**2) * 5.07722009423e-11
    Cs1 = 3.1e-07 * pow(
        Theta, 12.0
    )  # noqa equation 5 (correction applied from ^+6,^-6) Rosenkranz,1998 ==> updated per Paul's Dec 2012 e-mail
    Cs2 = 0.0  # noqa 2.10003048186e-26*pow(P_h2o/mbars_to_bars,6.76418487001)*pow(Theta,0.0435525417274) ==> updated per Paul's Dec 2012 e-mail
    # P_f = P_he + P_h2

    # Continuum Terms Foreign, and self
    # noqa Cf=((1/mbars_to_bars)^2) * 5.43e-10; %  (dB/km)/((GHz x kPa)^2)->db/km((GHz bars)^2)  %eqn 10 Rosenkranz,1998
    # noqa Cs=((1/mbars_to_bars)^2)* 1.8e-8*Theta.^(4.5);    %equation 5 (correction applied from ^+6,^-6) Rosenkranz,1998

    # Foreign_Continuum=Cf.*P_f.*P_h2o.*f.^2*Theta^3; %foreign continuum term from Eqn 6, Rosenkranz
    # Self_Continuum=Cs*P_h2o^2.*f.^2*Theta^3; %self continuum term from Eqn 6, Rosenkranz

    farr = np.array(f)
    Foreign_Continuum_he = Cf_he * P_he * P_h2o * (farr**2) * pow(
        Theta, 3.0)  # noqa foreign continuum term from Eqn 6, Rosenkranz
    Foreign_Continuum_h2 = Cf_h2 * P_h2 * P_h2o * (farr**2) * pow(Theta, 3.0)
    Foreign_Continuum = Foreign_Continuum_he + Foreign_Continuum_h2
    Self_Continuum = Cs1 * ((P_h2o / mbars_to_bars)**2) * (farr**2.0) + Cs2 * (
        farr**2.0
    )  # noqa *power(Theta,3) #self continuum term from Eqn 6, Rosenkranz

    alpha_h2o = line_contribution + inv_km_to_dB * Foreign_Continuum + inv_km_to_dB * Self_Continuum
    # alpha_h2o = inv_km_to_dB*Self_Continuum
    # alpha_h2o = line_contribution
    if par.units != 'dBperkm':
        alpha_h2o = alpha_h2o / 434294.5

    return np.ndarray.tolist(np.ndarray.flatten(alpha_h2o))