示例#1
0
def melin(source_data, source_wavelengths, target_wavelengths):
    source_data = np.atleast_2d(source_data)
    source_wave = np.array(source_wavelengths)
    target_wave = np.array(target_wavelengths)
    assert(source_wave.shape[0] == source_data.shape[1]), \
     'Data / Wavelength mismatch: %s' % str([source_wave.shape[0], source_data.shape[1]])

    AB = np.loadtxt('Data/IOP/AB_Bricaud.csv', delimiter=',')
    A_interp = Akima(AB[:, 0], AB[:, 1])
    B_interp = Akima(AB[:, 0], AB[:, 2])

    lambda_reference = 443
    b, a_ph, a_g, eta, S = QAA(source_data, source_wave, lambda_reference)

    melin_out = []
    for lambda_target in target_wave:
        lambda_source_i = [find(lambda_target, source_wave)]
        lambda_sources = [source_wave[lambda_source_i[0]]]

        # Distance too great - use weighted average if not first / last index
        if abs(lambda_target -
               lambda_sources[0]) > 3 and lambda_source_i[0] not in [
                   0, len(source_wave) - 1
               ]:
            lambda_source_i.append(lambda_source_i[0] + (
                1 if lambda_sources[0] < lambda_target else -1))
            lambda_sources.append(source_wave[lambda_source_i[1]])

        Rrs_es = []
        for lambda_source_idx, lambda_source in zip(lambda_source_i,
                                                    lambda_sources):

            Rrs_fs = []
            for lmbda in [lambda_source, lambda_target]:
                bbp = b * (lambda_reference / lmbda)**eta
                aph = A_interp(lmbda) * (a_ph / A_interp(lambda_reference))**(
                    (1 - B_interp(lmbda)) / (1 - B_interp(lambda_reference)))
                acd = a_g * np.exp(-S * (lmbda - lambda_reference))

                rrs_f = g0 * (bbp / (bbp +
                                     (aph + acd))) + g1 * (bbp /
                                                           (bbp +
                                                            (aph + acd)))**2
                Rrs_fs.append(to_Rrs(rrs_f).flatten())

            Rrs_source, Rrs_target = Rrs_fs
            Rrs_es.append(Rrs_target *
                          (source_data[:, lambda_source_idx] / Rrs_source))

        if len(lambda_sources) > 1:
            Rrs_e = np.abs(lambda_sources[1] - lambda_target) * Rrs_es[
                0] + np.abs(lambda_sources[0] - lambda_target) * Rrs_es[1]
            Rrs_e /= np.abs(lambda_sources[0] - lambda_sources[1])
        else:
            Rrs_e = Rrs_es[0]

        melin_p = Rrs_e
        melin_out.append(melin_p)

    return np.array(melin_out)
示例#2
0
 def LoadRadialDistFuncs(self,
                         filename_current,
                         filename_target,
                         spacing=0.005):
     #read in the data
     r, gr = self.GetRadialDistData(filename_current)
     r_tgt, gr_tgt = self.GetRadialDistData(filename_target)
     #sample according to an akima spline fit
     r_lower, r_upper = (max(r[0], r_tgt[0]), min(r[-1], r_tgt[-1]))
     self.r = arange(r_lower, r_upper, spacing)
     akima = Akima(r, gr)
     self.gr = akima.__call__(self.r, nu=0, extrapolate=None)
     akima = Akima(r_tgt, gr_tgt)
     self.gr_tgt = akima.__call__(self.r, nu=0, extrapolate=None)
     return None
示例#3
0
    def __init__(self):
        # All this stuff is in metric SI units
        altitiude = np.array(
            [0.0, 4000, 8000, 10000, 16666.67, 20000, 26666.67])
        nominal_density = np.array([
            1.225, 0.819129, 0.525168, 0.412707, 0.148913, 0.0880349, 0.0303264
        ])
        percent_departure = np.array([20.0, 6.0, 2.0, 6.0, 26.0, 20, 14])
        density_deviations = nominal_density * percent_departure / 100  # Since the values are percentages

        # Now the deviations indicate the 1% extremes. This means that they represent
        # 49% deviation in one dircetion, i.e.,
        sigma = 0.682689492137 / 2
        std_dev_density = sigma * density_deviations / 0.49

        # Now create an interploation usign Akima polynomial
        self.std_dev_density_interp = Akima(altitiude, std_dev_density)
示例#4
0
def water_interpolators():
    a_data = np.loadtxt(water_absorption_file, delimiter=',')
    s_data = np.loadtxt(water_scattering_file, delimiter=',')
    return Akima(*a_data.T), Akima(*s_data.T)
示例#5
0
                                    3.16E-07, 3.13E-07, 3.11E-07, 3.09E-07, 3.06E-07, 3.04E-07,
                                    3.02E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
                                    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
                                    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
                                    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
                                    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
                                    2.99E-07, 2.99E-07, 3.00E-07, 3.00E-07, 3.00E-07, 3.01E-07,
                                    3.01E-07, 3.01E-07, 3.02E-07, 3.02E-07, 3.03E-07, 3.03E-07,
                                    3.03E-07, 3.04E-07, 3.04E-07, 3.04E-07, 3.05E-07, 3.05E-07,
                                    3.05E-07, 3.06E-07, 3.06E-07, 3.06E-07, 3.07E-07, 3.07E-07,
                                    3.08E-07, 3.08E-07, 3.08E-07, 3.09E-07, 3.09E-07, 3.09E-07,
                                    3.10E-07, 3.10E-07, 3.10E-07, 3.11E-07, 3.11E-07, 3.11E-07,
                                    3.13E-07, 3.18E-07, 3.23E-07, 3.28E-07, 3.33E-07, 3.37E-07,
                                    3.42E-07, 3.47E-07, 3.51E-07, 3.56E-07])

T_interp = Akima(USatm1976Data.alt, USatm1976Data.T)
P_interp = Akima(USatm1976Data.alt, USatm1976Data.P)
rho_interp = Akima(USatm1976Data.alt, USatm1976Data.rho)
visc_interp = Akima(USatm1976Data.alt, USatm1976Data.viscosity)

T_interp_deriv = T_interp.derivative(1)
P_interp_deriv = P_interp.derivative(1)
rho_interp_deriv = rho_interp.derivative(1)
visc_interp_deriv = visc_interp.derivative(1)
drho_dh_interp_deriv = rho_interp_deriv.derivative(1)


class USatm1976Comp(ExplicitComponent):

    def initialize(self):
        self.options.declare('num_nodes', types=int,
示例#6
0
    0, 0.82, 0.86, 0.871, 0.881, 0.885, 0.8875, 0.889, 0.892, 0.894, 0.895,
    0.895
])
# TGL 1 - next generation technology level ~2% better
EtaPoly_SE1 = np.array([
    0, 0.84, 0.88, 0.891, 0.901, 0.905, 0.9075, 0.909, 0.912, 0.914, 0.915,
    0.915
])
# TGL 2 - beyond next generation technology level ~4% better
EtaPoly_SE2 = np.array([
    0, 0.855, 0.900, 0.912, 0.917, 0.920, 0.922, 0.9235, 0.926, 0.930, 0.931,
    0.931
])

# Create continuously differentiable interpolations
EtaPoly_SE0_interp = Akima(Wc_SE, EtaPoly_SE0)
EtaPoly_SE1_interp = Akima(Wc_SE, EtaPoly_SE1)
EtaPoly_SE2_interp = Akima(Wc_SE, EtaPoly_SE2)

# gather derivatives
EtaPoly_SE0_interp_deriv = EtaPoly_SE0_interp.derivative(1)
EtaPoly_SE1_interp_deriv = EtaPoly_SE1_interp.derivative(1)
EtaPoly_SE2_interp_deriv = EtaPoly_SE2_interp.derivative(1)


class SmallCoreEffBalance(ImplicitComponent):
    """ Polytropic/ Adiabatic efficiency balance. """
    def initialize(self):
        self.options.declare(
            'tech_level',
            default=0,
示例#7
0
    3.36E-07, 3.34E-07, 3.31E-07, 3.29E-07, 3.27E-07, 3.25E-07, 3.22E-07,
    3.20E-07, 3.18E-07, 3.16E-07, 3.13E-07, 3.11E-07, 3.09E-07, 3.06E-07,
    3.04E-07, 3.02E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 3.00E-07, 3.00E-07,
    3.00E-07, 3.01E-07, 3.01E-07, 3.01E-07, 3.02E-07, 3.02E-07, 3.03E-07,
    3.03E-07, 3.03E-07, 3.04E-07, 3.04E-07, 3.04E-07, 3.05E-07, 3.05E-07,
    3.05E-07, 3.06E-07, 3.06E-07, 3.06E-07, 3.07E-07, 3.07E-07, 3.08E-07,
    3.08E-07, 3.08E-07, 3.09E-07, 3.09E-07, 3.09E-07, 3.10E-07, 3.10E-07,
    3.10E-07, 3.11E-07, 3.11E-07, 3.11E-07, 3.13E-07, 3.18E-07, 3.23E-07,
    3.28E-07, 3.33E-07, 3.37E-07, 3.42E-07, 3.47E-07, 3.51E-07, 3.56E-07
])  #units='lbf*s/ft**2'

T_interp = Akima(USatm1976Data.alt, USatm1976Data.T)
P_interp = Akima(USatm1976Data.alt, USatm1976Data.P)
rho_interp = Akima(USatm1976Data.alt, USatm1976Data.rho)

T_interp_deriv = T_interp.derivative(1)
P_interp_deriv = P_interp.derivative(1)
rho_interp_deriv = rho_interp.derivative(1)

drho_dh_interp_deriv = rho_interp.derivative(2)


class USatm1976Comp(ExplicitComponent):
    def setup(self):
        self.add_input('alt', val=1., units='ft')

        self.add_output('Ts', val=1., units='degR')
示例#8
0
    3.36E-07, 3.34E-07, 3.31E-07, 3.29E-07, 3.27E-07, 3.25E-07, 3.22E-07,
    3.20E-07, 3.18E-07, 3.16E-07, 3.13E-07, 3.11E-07, 3.09E-07, 3.06E-07,
    3.04E-07, 3.02E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 3.00E-07, 3.00E-07,
    3.00E-07, 3.01E-07, 3.01E-07, 3.01E-07, 3.02E-07, 3.02E-07, 3.03E-07,
    3.03E-07, 3.03E-07, 3.04E-07, 3.04E-07, 3.04E-07, 3.05E-07, 3.05E-07,
    3.05E-07, 3.06E-07, 3.06E-07, 3.06E-07, 3.07E-07, 3.07E-07, 3.08E-07,
    3.08E-07, 3.08E-07, 3.09E-07, 3.09E-07, 3.09E-07, 3.10E-07, 3.10E-07,
    3.10E-07, 3.11E-07, 3.11E-07, 3.11E-07, 3.13E-07, 3.18E-07, 3.23E-07,
    3.28E-07, 3.33E-07, 3.37E-07, 3.42E-07, 3.47E-07, 3.51E-07, 3.56E-07
])  #units='lbf*s/ft**2'

temp_interp = Akima(USatm1976Data.h, USatm1976Data.temp)
pres_interp = Akima(USatm1976Data.h, USatm1976Data.pres)
rho_interp = Akima(USatm1976Data.h, USatm1976Data.rho)
a_interp = Akima(USatm1976Data.h, USatm1976Data.a)
viscosity_interp = Akima(USatm1976Data.h, USatm1976Data.viscosity)

temp_interp_deriv = temp_interp.derivative(1)
pres_interp_deriv = pres_interp.derivative(1)
rho_interp_deriv = rho_interp.derivative(1)
a_interp_deriv = a_interp.derivative(1)
viscosity_interp_deriv = viscosity_interp.derivative(1)


class AtmosComp(ExplicitComponent):
    def initialize(self):
        self.options.declare('num_nodes', types=int, default=1)
示例#9
0
                                    3.02E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
                                    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
                                    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
                                    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
                                    2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07, 2.99E-07,
                                    2.99E-07, 2.99E-07, 3.00E-07, 3.00E-07, 3.00E-07, 3.01E-07,
                                    3.01E-07, 3.01E-07, 3.02E-07, 3.02E-07, 3.03E-07, 3.03E-07,
                                    3.03E-07, 3.04E-07, 3.04E-07, 3.04E-07, 3.05E-07, 3.05E-07,
                                    3.05E-07, 3.06E-07, 3.06E-07, 3.06E-07, 3.07E-07, 3.07E-07,
                                    3.08E-07, 3.08E-07, 3.08E-07, 3.09E-07, 3.09E-07, 3.09E-07,
                                    3.10E-07, 3.10E-07, 3.10E-07, 3.11E-07, 3.11E-07, 3.11E-07,
                                    3.13E-07, 3.18E-07, 3.23E-07, 3.28E-07, 3.33E-07, 3.37E-07,
                                    3.42E-07, 3.47E-07, 3.51E-07, 3.56E-07])

# Interpolations as a function of altitide
T_interp_alt = Akima(USatm1976Data.alt, USatm1976Data.T)
P_interp_alt = Akima(USatm1976Data.alt, USatm1976Data.P)
rho_interp_alt = Akima(USatm1976Data.alt, USatm1976Data.rho)
visc_interp_alt = Akima(USatm1976Data.alt, USatm1976Data.viscosity)
# Their derivatives
T_interp_deriv = T_interp_alt.derivative(1)
P_interp_deriv = P_interp_alt.derivative(1)
rho_interp_deriv = rho_interp_alt.derivative(1)
visc_interp_deriv = visc_interp_alt.derivative(1)
drho_dh_interp_deriv = rho_interp_deriv.derivative(1)

# Interpolations as a function of density
a_vs_rho_interp = Akima(np.flip(USatm1976Data.rho), np.flip(USatm1976Data.a))
a_vs_rho_interp_deriv = a_vs_rho_interp.derivative(1)

class USatm1976Group(Group):