Ejemplo n.º 1
0
    def test_phases(self):
        result = AReader.get_phase_all("msia", 0)
        assert (len(result) == 2)
        assert (result[0].shape[0] == 75 and result[1].shape == (80, 75))

        for re in result[1]:
            # print(re.sum())
            assert (round(re.sum()) == 1)
Ejemplo n.º 2
0
    def test_aeroextinct_profile(self):
        aprofile = SReader.aerosol_profile(taua=0.1)
        taua_scaled = integrate.cumtrapz(aprofile.values[:, 1],
                                         aprofile.values[:, 0],
                                         initial=0)[-1]
        # print(taua_scaled)
        assert (round(taua_scaled, 1) == 0.1)
        referindex = 5
        angstroms = AReader.get_angstroms(self.sensor, 10, referindex,
                                          self.bands)

        aprofile_s = ip.aersol(self.bands, angstroms, profile=aprofile)
        assert (aprofile_s.columns.shape[0] == len(self.bands) + 2)
Ejemplo n.º 3
0
from utils import AhmadAerosolReader as AReader
from inputs import input
import numpy as np


sensor = 'msia'
bands = AReader.get_bands(sensor)
bands_int = np.asarray(bands,dtype=int)

print (bands)

rhs, fmfs =AReader.get_names(sensor)


for i,wl in enumerate(bands_int):
    scatt, phases = AReader.get_phase_all(sensor, 0)
    input.gen_aerosol_phase(sensor=sensor,band=wl, scatt=scatt,phases=phases,rhs=rhs,fmfs=fmfs)






Ejemplo n.º 4
0
    def test_config(self):
        bandindex = 8
        confg = Config(self.sensor, bandindex)
        confg.set_pixels(64, 64)
        confg.set_geometry(30, 0, 0, 0)
        confg.set_resoluztion(300.0, 300.0)
        confg.set_surface("msf_%d" % self.bands_int[bandindex])
        confg.set_aerosol_phases("mdlphs_%d" % self.bands_int[bandindex])

        ## get altitude grid from aerosol profile
        aerosolp = SReader.aerosol_profile(taua=0.1)
        z = aerosolp['z'].values  #km
        z = z * 1000  #convert it from km to m
        # z_str = list(map(lambda x:"%.6E"%(x)),z)                                                                              , z))
        z_str = list(map(lambda x: "%.6E" % (x), z))
        confg.set_altitude_grid(z_str)

        ## get aerosol extinction profile
        referindex = 8  #set 865 as the reference
        angstroms = AReader.get_angstroms(self.sensor, 10, referindex,
                                          self.bands)
        aprofile_s = ip.aersol(self.bands, angstroms, profile=aerosolp)
        aerosol_extinct = aprofile_s['extinct_%d' %
                                     self.bands_int[bandindex]].values
        aerosol_extinct = aerosol_extinct * 0.001  #covert it from km^-1 into m^-1

        taua_scaled = integrate.cumtrapz(aerosol_extinct, z, initial=0)[-1]
        # print(taua_scaled)
        assert (round(taua_scaled, 1) == 0.1)

        confg.set_aerosol(map(lambda x: "%.6E" % (x), aerosol_extinct),
                          ['0.9767' for i in range(aerosol_extinct.shape[0])],
                          38)

        ## get atmosphere profile
        atm_profile = SReader.atm_profile()
        ray_df, unit = ip.rayleight(atm_profile, self.bands)
        ray_df.to_csv("../out/extinction_rayleigh_(%s).csv" % (unit))
        z_ray = ray_df['z[km]'].values * 1e3  #convert from km to m
        ray_extinct = ray_df['extinction_coe_%d' % self.bands_int[
            bandindex]].values * 1e2  #convert from cm^-1 it into m^-1
        f = inp.interp1d(z_ray, ray_extinct)
        ray_extinct = f(z)
        confg.set_rayleigh(map(lambda x: "%.6E" % (x), ray_extinct),
                           ['1.000' for i in range(ray_extinct.shape[0])])

        ray_scaled = integrate.cumtrapz(ray_extinct, z, initial=0)[-1]
        # print(taua_scaled)
        # assert (round(ray_scaled,1)==0.1)
        print(ray_scaled)

        ## get temperature from atmosphere profile
        temp_k = ray_df['t[K]'].values
        f = inp.interp1d(z_ray, temp_k)
        temp_k = f(z)
        confg.set_tempprofile(map(lambda x: "%.6E" % (x), temp_k))

        ## get gas extinction profile
        gas_profile = SReader.gas_profile()
        no2_crosssect = SReader.no2_cross_section()
        o3_crosssect = SReader.ozone_cross_section()
        gas_abs, unit = ip.gas_absorption(bands=self.bands,
                                          profile_df=gas_profile,
                                          no2=no2_crosssect,
                                          o3=o3_crosssect)
        gas_abs.to_csv("../out/gas_abs_(%s).csv" % unit)

        z_gas = gas_abs['Z'].values * 1e3  #convert from km to m
        o3_extinct = gas_abs[
            'abs_o3_%d' %
            self.bands_int[bandindex]].values * 1e2  #convert it into m^-1
        f = inp.interp1d(z_gas, o3_extinct)
        o3_extinct = f(z)

        no2_extinct = gas_abs[
            'abs_no2_%d' %
            self.bands_int[bandindex]].values * 1e2  #convert it into m^-1
        f = inp.interp1d(z_gas, no2_extinct)
        no2_extinct = f(z)

        confg.set_gas([o3_extinct, no2_extinct])

        confg.to_file("../out/config_%d" % (self.bands_int[bandindex]))
Ejemplo n.º 5
0
 def setUp(self):
     self.sensor = 'msia'
     self.bands = AReader.get_bands(self.sensor)
     self.bands_int = np.asarray(self.bands, dtype=int)
Ejemplo n.º 6
0
from utils import SciatranReader as SReader
from scipy import integrate
from inputs import input as ip
from inputs.config import Config
from scipy import interpolate as inp

taua_nirls = [0.005, 0.010, 0.050, 0.100, 0.500]
aero_phs = [0, 9, 20, 29, 50, 59, 70, 79]
resolutions = [30.0, 100.0, 500.0, 1500.0, 5000.0]
theta_s = [5, 10, 30, 50]

rho_diff = []

rho_diff_df = pd.read_csv("../database/s2_rho_diff.csv", index_col=0)
sensor = 'msia'
bands = AReader.get_bands(sensor)
bands_int = np.asarray(bands, dtype=int)

shape = "river"
columns = rows = 64

for bandindex, band in enumerate(rho_diff_df.columns[:-3]):
    confg = Config(sensor, bandindex)
    confg.set_pixels(rows, columns)

    if not os.path.exists("../out/%d" % (bands_int[bandindex])):
        os.mkdir("../out/%d" % (bands_int[bandindex]))

    cur_dir = "../out/%d" % (bands_int[bandindex])
    wavelenth = bands_int[bandindex]