コード例 #1
0
def test_optical_depth(test_od):
    # Trap the guess
    if not 0 <= test_od <= 2:
        return 9999999

    od = OpticalDepth(dust_profile, hydro.column_density, fs.extinction,
                      test_od)

    dust_info = (od.total, dust_ssa, dust_pf)
    model = Atmosphere(rayleigh_info, dust_info)

    od_holder = np.zeros(n_wavelengths)
    for wav_index in range(n_wavelengths):
        rfldir, rfldn, flup, dfdt, uavg, uu, albmed, trnmed = \
            disort.disort(USRANG, USRTAU, IBCND, ONLYFL, PRNT, PLANK, LAMBER,
                          DELTAMPLUS, DO_PSEUDO_SPHERE,
                          model.optical_depth[:, wav_index],
                          model.single_scattering_albedo[:, wav_index],
                          model.legendre_moments[:, :, wav_index],
                          TEMPER, WVNMLO, WVNMHI,
                          UTAU, UMU0, PHI0, UMU, PHI, FBEAM, FISOT,
                          ALBEDO, BTEMP, TTEMP, TEMIS, EARTH_RADIUS, H_LYR, RHOQ, RHOU,
                          RHO_ACCURATE, BEMST, EMUST, ACCUR, HEADER, RFLDIR,
                          RFLDN, FLUP, DFDT, UAVG, UU, ALBMED, TRNMED)

        od_holder[wav_index] = uu[0, 0, 0]
    return np.sum((od_holder - rfl)**2)
コード例 #2
0
def myModel(guess, pixel):
    dust_od = guess[0]
    ice_od = guess[1]
    if dust_od <= 0 or ice_od <= 0:
        return 99999
    # The column will change everytime I use a different OD
    dust_column = Column(dust, lay, dust_conrath, np.array([1]),
                         np.array([dust_od]))
    ice_column = Column(ice, lay, ice_profile, np.array([2]),
                        np.array([ice_od]))

    # The phase functions change as columns change
    dust_phase = TabularLegendreCoefficients(
        dust_column,
        dust_phase_function.array,
        particle_sizes=dust_phase_radii.array,
        wavelengths=dust_phase_wavs.array)
    ice_phase = TabularLegendreCoefficients(ice_column, ice_coeff.array)

    # Make the model
    model = ModelAtmosphere()
    dust_info = (dust_column.hyperspectral_total_optical_depths,
                 dust_column.hyperspectral_scattering_optical_depths,
                 dust_phase.coefficients)
    ice_info = (ice_column.hyperspectral_total_optical_depths,
                ice_column.hyperspectral_scattering_optical_depths,
                ice_phase.coefficients)

    # Add everything to the model
    model.add_constituent(dust_info)
    model.add_constituent(ice_info)
    model.add_constituent(rayleigh_info)

    # Once everything is in the model, compute the model
    model.compute_model()
    optical_depths = model.hyperspectral_total_optical_depths
    ssa = model.hyperspectral_total_single_scattering_albedos
    polynomial_moments = model.hyperspectral_legendre_moments

    test_run = np.zeros(len(wavs))
    for w in range(len(wavs)):
        # The 0s here are just me testing this on a single pixel
        junk, junk, junk, junk, junk, uu, junk, junk = disort.disort(
            usrang, usrtau, ibcnd, onlyfl, prnt, plank, lamber, deltamplus,
            do_pseudo_sphere, optical_depths[:, w], ssa[:, w],
            polynomial_moments[:, :, w], temperatures, low_wavenumber[w],
            high_wavenumber[w], utau, umu0[pixel], phi0, umu[pixel],
            phi[pixel], fbeam, fisot, albedo, surface_temp, top_temp,
            top_emissivity, planet_radius, h_lyr, hapke.rhoq, hapke.rhou,
            hapke.rho_accurate[:, pixel], hapke.bemst, hapke.emust, accur,
            header, direct_beam_flux, diffuse_down_flux, diffuse_up_flux,
            flux_divergence, mean_intensity, intensity[:, :, pixel],
            albedo_medium, transmissivity_medium)
        test_run[w] = uu[0, 0]  # Just the the TOA I/F value
    return test_run
コード例 #3
0
    def fit_ssa(guess, wav_index: int):
        # Trap the guess
        if not 0 <= guess <= 1:
            return 9999999
        test_cext = np.copy(cext)
        test_csca = np.copy(csca)

        # BECAUSE I'm using NN, just set all of the coefficients to be my guess
        # test_csca[:, wav_index] = guess * test_cext[:, wav_index]
        test_csca = guess * test_cext

        fs = ForwardScattering(test_csca, test_cext, fsp_psizes, fsp_wavs,
                               pgrad, wavelengths, wave_ref)
        fs.make_nn_properties()

        od = OpticalDepth(dust_profile, hydro.column_density, fs.extinction,
                          pixel_od[pixel_index])

        tlc = TabularLegendreCoefficients(phsfn, pf_psizes, pf_wavs, pgrad,
                                          wavelengths)
        tlc.make_nn_phase_function()

        dust_info = (od.total, fs.single_scattering_albedo, tlc.phase_function)

        model = Atmosphere(rayleigh_info, dust_info)

        oa = OutputArrays(cp.n_polar, cp.n_user_levels, cp.n_azimuth)

        rfldir, rfldn, flup, dfdt, uavg, uu, albmed, trnmed = \
            disort.disort(ob.user_angles, ob.user_optical_depths,
                          ob.incidence_beam_conditions, ob.only_fluxes,
                          mb.print_variables, te.thermal_emission,
                          lamb[wav_index].lambertian,
                          mb.delta_m_plus, mb.do_pseudo_sphere,
                          model.optical_depth[:, wav_index],
                          model.single_scattering_albedo[:, wav_index],
                          model.legendre_moments[:, :, wav_index],
                          hydro.temperature, spectral.low_wavenumber,
                          spectral.high_wavenumber, ulv.optical_depth_output,
                          angles.mu0[pixel_index], angles.phi0[pixel_index],
                          angles.mu[pixel_index], angles.phi[pixel_index],
                          flux.beam_flux, flux.isotropic_flux,
                          lamb[wav_index].albedo, te.bottom_temperature,
                          te.top_temperature, te.top_emissivity,
                          mb.radius, hydro.scale_height, lamb[wav_index].rhoq,
                          lamb[wav_index].rhou, lamb[wav_index].rho_accurate,
                          lamb[wav_index].bemst, lamb[wav_index].emust,
                          mb.accuracy, mb.header, oa.direct_beam_flux,
                          oa.diffuse_down_flux, oa.diffuse_up_flux,
                          oa.flux_divergence, oa.mean_intensity, oa.intensity,
                          oa.albedo_medium, oa.transmissivity_medium)
        return (uu[0, 0, 0] - reflectance[pixel_index, wav_index])**2
コード例 #4
0
RHOQ = sfc.rhoq
BEMST = sfc.bemst
EMUST = sfc.emust
RHO_ACCURATE = sfc.rho_accurate

# Run the model
import disort

test_run = np.zeros(pixel_wavelengths.shape)

for ind in range(pixel_wavelengths.size):
    rfldir, rfldn, flup, dfdt, uavg, uu, albmed, trnmed = \
        disort.disort(USRANG, USRTAU, IBCND, ONLYFL, PRNT, PLANK, LAMBER,
                      DELTAMPLUS, DO_PSEUDO_SPHERE, DTAUC[:, ind], SSALB[:, ind],
                      PMOM[:, :, ind], TEMPER, WVNMLO, WVNMHI,
                      UTAU, UMU0, PHI0, UMU, PHI, FBEAM, FISOT,
                      ALBEDO, BTEMP, TTEMP, TEMIS, EARTH_RADIUS, H_LYR, RHOQ, RHOU,
                      RHO_ACCURATE, BEMST, EMUST, ACCUR, HEADER, RFLDIR,
                      RFLDN, FLUP, DFDT, UAVG, UU, ALBMED, TRNMED)

    test_run[ind] = uu[0, 0, 0]

rfl = np.array([0.116, 0.108, 0.084, 0.094, 0.092])


def test_optical_depth(test_od):
    # Trap the guess
    if not 0 <= test_od <= 2:
        return 9999999

    od = OpticalDepth(dust_profile, hydro.column_density, fs.extinction,
コード例 #5
0
#hapke = Hapke(size, obs, control, boundary, albedo)
#hapke = HapkeHG2(size, obs, control, boundary, albedo, w=0.12, asym=0.75, frac=0.9, b0=1, hh=0.04, n_mug=200)
hapke = HapkeHG2Roughness(size,
                          obs,
                          control,
                          boundary,
                          albedo,
                          w=0.12,
                          asym=0.75,
                          frac=0.5,
                          b0=1,
                          hh=0.04,
                          n_mug=200,
                          roughness=0.5)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Run the model
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

rfldir, rfldn, flup, dfdt, uavg, uu, albmed, trnmed = disort.disort(
    usrang, usrtau, ibcnd, onlyfl, prnt, plank, lamber, deltamplus,
    do_pseudo_sphere, optical_depths, ssa, polynomial_moments, temperatures,
    low_wavenumber, high_wavenumber, utau, umu0, phi0, umu, phi, fbeam, fisot,
    albedo, surface_temp, top_temp, top_emissivity, planet_radius, h_lyr,
    hapke.rhoq, hapke.rhou, hapke.rho_accurate, hapke.bemst, hapke.emust,
    accur, header, direct_beam_flux, diffuse_down_flux, diffuse_up_flux,
    flux_divergence, mean_intensity, intensity, albedo_medium,
    transmissivity_medium)

print(uu[0, :20, 0])  # shape: (1, 81, 1)
コード例 #6
0
lamber = hapke.lambertian
rhou = hapke.rhou
rhoq = hapke.rhoq
bemst = hapke.bemst
emust = hapke.emust
rho_accurate = hapke.rho_accurate

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# I guess I have no idea where to put this still
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
utau = np.zeros(n_user_levels)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Run the model
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfldir, rfldn, flup, dfdt, uavg, uu, albmed, trnmed = \
    disort.disort(usrang, usrtau, ibcnd, onlyfl, prnt, plank, lamber,
                  deltamplus, dopseudosphere, optical_depths, ssa,
                  polynomial_moments, temperatures, low_wavenumber,
                  high_wavenumber, utau, mu0, phi0, mu, phi, fbeam, fisot,
                  albedo, btemp, ttemp, temis, radius, h_lyr, rhoq, rhou,
                  rho_accurate, bemst, emust, accur, header, rfldir,
                  rfldn, flup, dfdt, uavg, uu, albmed, trnmed)

print(uu[0, 0, 0])  # shape: (1, 81, 1)
# This gives          0.027767317
# disort_multi gives  ??? I'm unsure how to test this in d_m
# I'm running
# testInput.txt is: 1, 0.5, 10, 30, 50, 40, 20, 1, 0, 0
# And dust_phsfn has 65 moments at 1.5 micron (size) and 9.3 microns(wavelength)
コード例 #7
0
ファイル: disotest9.py プロジェクト: kconnour/pyRT_DISORT
rfldir, rfldn, flup, dfdt, uavg, uu, albmed, trnmed = disort.disort(
    usrang,
    usrtau,
    ibcnd,
    onlyfl,
    prnt,
    plank,
    lamber,
    deltamplus,
    do_pseudo_sphere,
    dtauc,
    ssalb,
    pmom,
    temper,
    wvnmlo,
    wvnmhi,
    utau,
    umu0,
    phi0,
    umu,
    phi,
    fbeam,
    fisot,
    albedo,
    btemp,
    ttemp,
    temis,
    earth_radius,
    h_lyr,
    rhoq,
    rhou,
    rho_accurate,
    bemst,
    emust,
    accur,
    header,
    rfldir,
    rfldn,
    flup,
    dfdt,
    uavg,
    uu,
    albmed,
    trnmed,
    maxcly=nlyr,
    maxmom=nmom,
    maxcmu=nstr,
    maxumu=numu,
    maxphi=nphi,
    maxulv=ntau)
コード例 #8
0
ファイル: retrieval.py プロジェクト: kconnour/pyuvs-rt
    def fit_ssa(guess, wav_index: int):
        # Trap the guess
        if not 0 <= guess <= 1:
            return 9999999

        # Take care of surface variables
        albedo = hapke[wav_index].albedo
        lamber = hapke[wav_index].lambertian
        rhou = hapke[wav_index].rhou
        rhoq = hapke[wav_index].rhoq
        bemst = hapke[wav_index].bemst
        emust = hapke[wav_index].emust
        rho_accurate = hapke[wav_index].rho_accurate

        cext = dust_file.array['primary'].data[:, :, 0]
        csca = dust_file.array['primary'].data[:, :, 1]
        csca[:, 0:2] = guess * cext[:, 0:2]
        c_ext = ForwardScatteringProperty(
            cext,
            particle_size_grid=sizes,
            wavelength_grid=wavs)
        c_sca = ForwardScatteringProperty(
            csca,
            particle_size_grid=sizes,
            wavelength_grid=wavs)

        dust_properties = ForwardScatteringPropertyCollection()
        dust_properties.add_property(c_ext, 'c_extinction')
        dust_properties.add_property(c_sca, 'c_scattering')

        # Use the Curiosity OD
        dust_col = Column(dust_properties, model_eos,
                          conrath_profile.profile, p_sizes,
                          short_wav[pixel_index, :], 0.88, pixel_od[pixel_index],
                          dust_phsfn)

        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # Make the model
        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        model = ModelAtmosphere()
        # Make tuples of (dtauc, ssalb, pmom) for each constituent
        dust_info = (
        dust_col.total_optical_depth, dust_col.scattering_optical_depth,
        dust_col.scattering_optical_depth * dust_col.phase_function)
        rayleigh_info = (
        rco2.scattering_optical_depths, rco2.scattering_optical_depths,
        rco2.phase_function)  # This works since scat OD = total OD

        # Add dust and Rayleigh scattering to the model
        model.add_constituent(dust_info)
        model.add_constituent(rayleigh_info)

        model.compute_model()

        optical_depths = model.hyperspectral_total_optical_depths[:, wav_index]
        ssa = model.hyperspectral_total_single_scattering_albedos[:, wav_index]
        polynomial_moments = model.hyperspectral_legendre_moments[:, :, wav_index]

        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # Make the output arrays
        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        oa = OutputArrays(cp)
        albmed = oa.albedo_medium
        flup = oa.diffuse_up_flux
        rfldn = oa.diffuse_down_flux
        rfldir = oa.direct_beam_flux
        dfdt = oa.flux_divergence
        uu = oa.intensity
        uavg = oa.mean_intensity
        trnmed = oa.transmissivity_medium

        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # Optical depth output structure
        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        utau = UserLevel(cp, mb).optical_depth_output

        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # Run the model
        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        rfldir, rfldn, flup, dfdt, uavg, uu, albmed, trnmed = \
            disort.disort(usrang, usrtau, ibcnd, onlyfl, prnt, plank, lamber,
                          deltamplus, dopseudosphere, optical_depths, ssa,
                          polynomial_moments, temperatures, low_wavenumber,
                          high_wavenumber, utau,
                          mu0[pixel_index],
                          phi0[pixel_index],
                          mu[pixel_index],
                          phi[pixel_index], fbeam, fisot,
                          albedo, btemp, ttemp, temis, radius, h_lyr, rhoq, rhou,
                          rho_accurate, bemst, emust, accur, header, rfldir,
                          rfldn, flup, dfdt, uavg, uu, albmed, trnmed)
        return (uu[0, 0, 0] - reflectance[pixel_index, wav_index])**2