예제 #1
0
def cloud(full_output):
    """
    Plotting the cloud input from ``picaso``. 

    The plot itselfs creates maps of the wavelength dependent single scattering albedo 
    and cloud opacity as a function of altitude. 


    Parameters
    ----------
    full_output

    Returns
    -------
    A row of two bokeh plots with the single scattering and optical depth map
    """
    cols = colfun1(200)
    color_mapper = LinearColorMapper(palette=cols, low=0, high=1)

    dat01 = full_output['layer']['cloud']

    #PLOT W0
    scat01 = np.flip(dat01['w0'], 0)  #[0:10,:]
    xr, yr = scat01.shape
    f01a = figure(x_range=[0, yr],
                  y_range=[0, xr],
                  x_axis_label='Wavelength (micron)',
                  y_axis_label='Pressure (bar)',
                  title="Single Scattering Albedo",
                  plot_width=300,
                  plot_height=300)

    f01a.image(image=[scat01],
               color_mapper=color_mapper,
               x=0,
               y=0,
               dh=xr,
               dw=yr)

    color_bar = ColorBar(
        color_mapper=color_mapper,  #ticker=LogTicker(),
        label_standoff=12,
        border_line_color=None,
        location=(0, 0))

    f01a.add_layout(color_bar, 'left')

    #PLOT OPD
    scat01 = np.flip(dat01['opd'] + 1e-60, 0)

    xr, yr = scat01.shape
    cols = colfun2(200)[::-1]
    color_mapper = LogColorMapper(palette=cols, low=1e-3, high=10)

    f01 = figure(x_range=[0, yr],
                 y_range=[0, xr],
                 x_axis_label='Wavelength (micron)',
                 y_axis_label='Pressure (bar)',
                 title="Cloud Optical Depth Per Layer",
                 plot_width=300,
                 plot_height=300)

    f01.image(image=[scat01],
              color_mapper=color_mapper,
              x=0,
              y=0,
              dh=xr,
              dw=yr)

    color_bar = ColorBar(color_mapper=color_mapper,
                         ticker=LogTicker(),
                         label_standoff=12,
                         border_line_color=None,
                         location=(0, 0))
    f01.add_layout(color_bar, 'left')

    #PLOT G0
    scat01 = np.flip(dat01['g0'] + 1e-60, 0)

    xr, yr = scat01.shape
    cols = colfun3(200)[::-1]
    color_mapper = LinearColorMapper(palette=cols, low=0, high=1)

    f01b = figure(x_range=[0, yr],
                  y_range=[0, xr],
                  x_axis_label='Wavelength (micron)',
                  y_axis_label='Pressure (bar)',
                  title="Assymetry Parameter",
                  plot_width=300,
                  plot_height=300)

    f01b.image(image=[scat01],
               color_mapper=color_mapper,
               x=0,
               y=0,
               dh=xr,
               dw=yr)

    color_bar = ColorBar(color_mapper=color_mapper,
                         ticker=BasicTicker(),
                         label_standoff=12,
                         border_line_color=None,
                         location=(0, 0))
    f01b.add_layout(color_bar, 'left')

    #CHANGE X AND Y AXIS TO BE PHYSICAL UNITS
    #indexes for pressure plot
    pressure = [
        "{:.1E}".format(i) for i in full_output['layer']['pressure'][::-1]
    ]  #flip since we are also flipping matrices
    wave = ["{:.2F}".format(i) for i in 1e4 / full_output['wavenumber']]
    nwave = len(wave)
    npres = len(pressure)
    iwave = np.array(range(nwave))
    ipres = np.array(range(npres))
    #set how many we actually want to put on the figure
    #hard code ten on each..
    iwave = iwave[::int(nwave / 10)]
    ipres = ipres[::int(npres / 10)]
    pressure = pressure[::int(npres / 10)]
    wave = wave[::int(nwave / 10)]
    #create dictionary for tick marks
    ptick = {int(i): j for i, j in zip(ipres, pressure)}
    wtick = {int(i): j for i, j in zip(iwave, wave)}
    for i in [f01a, f01, f01b]:
        i.xaxis.ticker = iwave
        i.yaxis.ticker = ipres
        i.xaxis.major_label_overrides = wtick
        i.yaxis.major_label_overrides = ptick

    return row(f01a, f01, f01b)
예제 #2
0
def plot_cld_input(nwno,
                   nlayer,
                   filename=None,
                   df=None,
                   pressure=None,
                   wavelength=None,
                   **pd_kwargs):
    """
    This function was created to investigate CLD input file for PICASO. 

    The plot itselfs creates maps of the wavelength dependent single scattering albedo 
    and cloud opacity and assymetry parameter as a function of altitude. 


    Parameters
    ----------
    nwno : int 
        Number of wavenumber points. For runs from Ackerman & Marley, this will always be 196. 
    nlayer : int 
        Should be one less than the number of levels in your pressure temperature grid. Cloud 
        opacity is assigned for slabs. 
    file : str , optional
        (Optional)Path to cloud input file
    df : str 
        (Optional)Dataframe of cloud input file
    wavelength : array , optional
        (Optional) this allows you to reset the tick marks to wavelengths instead of indicies 
    pressure : array, optional 
        (Optional) this allows you to reset the tick marks to pressure instead of indicies  
    pd_kwargs : kwargs
        Pandas key word arguments for `pandas.read_csv`

    Returns
    -------
    Three bokeh plots with the single scattering, optical depth, and assymetry maps
    """
    if (pressure is not None):
        pressure_label = 'Pressure (units by user)'
    else:
        pressure_label = 'Pressure Grid, TOA ->'
    if (wavelength is not None):
        wavelength_label = 'Wavelength (units by user)'
    else:
        wavelength_label = 'Wavenumber Grid'
    cols = colfun1(200)
    color_mapper = LinearColorMapper(palette=cols, low=0, high=1)

    if not isinstance(filename, type(None)):
        dat01 = pd.read_csv(filename, **pd_kwargs)
    elif not isinstance(df, type(None)):
        dat01 = df

    #PLOT W0
    scat01 = np.flip(np.reshape(dat01['w0'].values, (nlayer, nwno)), 0)
    xr, yr = scat01.shape
    f01a = figure(x_range=[0, yr],
                  y_range=[0, xr],
                  x_axis_label=wavelength_label,
                  y_axis_label=pressure_label,
                  title="Single Scattering Albedo",
                  plot_width=300,
                  plot_height=300)

    f01a.image(image=[scat01],
               color_mapper=color_mapper,
               x=0,
               y=0,
               dh=xr,
               dw=yr)

    color_bar = ColorBar(
        color_mapper=color_mapper,  #ticker=LogTicker(),
        label_standoff=12,
        border_line_color=None,
        location=(0, 0))

    f01a.add_layout(color_bar, 'left')

    #PLOT OPD
    scat01 = np.flip(np.reshape(dat01['opd'].values, (nlayer, nwno)), 0)

    xr, yr = scat01.shape
    cols = colfun2(200)[::-1]
    color_mapper = LogColorMapper(palette=cols, low=1e-3, high=10)

    f01 = figure(x_range=[0, yr],
                 y_range=[0, xr],
                 x_axis_label=wavelength_label,
                 y_axis_label=pressure_label,
                 title="Cloud Optical Depth Per Layer",
                 plot_width=300,
                 plot_height=300)

    f01.image(image=[scat01],
              color_mapper=color_mapper,
              x=0,
              y=0,
              dh=xr,
              dw=yr)

    color_bar = ColorBar(color_mapper=color_mapper,
                         ticker=LogTicker(),
                         label_standoff=12,
                         border_line_color=None,
                         location=(0, 0))
    f01.add_layout(color_bar, 'left')

    #PLOT G0
    scat01 = np.flip(np.reshape(dat01['g0'].values, (nlayer, nwno)), 0)

    xr, yr = scat01.shape
    cols = colfun3(200)[::-1]
    color_mapper = LinearColorMapper(palette=cols, low=0, high=1)

    f01b = figure(x_range=[0, yr],
                  y_range=[0, xr],
                  x_axis_label=wavelength_label,
                  y_axis_label=pressure_label,
                  title="Assymetry Parameter",
                  plot_width=300,
                  plot_height=300)

    f01b.image(image=[scat01],
               color_mapper=color_mapper,
               x=0,
               y=0,
               dh=xr,
               dw=yr)

    color_bar = ColorBar(color_mapper=color_mapper,
                         ticker=BasicTicker(),
                         label_standoff=12,
                         border_line_color=None,
                         location=(0, 0))
    f01b.add_layout(color_bar, 'left')

    #CHANGE X AND Y AXIS TO BE PHYSICAL UNITS
    #indexes for pressure plot
    if (pressure is not None):
        pressure = ["{:.1E}".format(i) for i in pressure[::-1]
                    ]  #flip since we are also flipping matrices
        npres = len(pressure)
        ipres = np.array(range(npres))
        #set how many we actually want to put on the figure
        #hard code ten on each..
        ipres = ipres[::int(npres / 10)]
        pressure = pressure[::int(npres / 10)]
        #create dictionary for tick marks
        ptick = {int(i): j for i, j in zip(ipres, pressure)}
        for i in [f01a, f01, f01b]:
            i.yaxis.ticker = ipres
            i.yaxis.major_label_overrides = ptick
    if (wavelength is not None):
        wave = ["{:.2F}".format(i) for i in wavelength]
        nwave = len(wave)
        iwave = np.array(range(nwave))
        iwave = iwave[::int(nwave / 10)]
        wave = wave[::int(nwave / 10)]
        wtick = {int(i): j for i, j in zip(iwave, wave)}
        for i in [f01a, f01, f01b]:
            i.xaxis.ticker = iwave
            i.xaxis.major_label_overrides = wtick

    return row(f01a, f01, f01b)
예제 #3
0
def cloud(full_output):
    """
	Plotting the cloud input from ``picaso``. 

	The plot itselfs creates maps of the wavelength dependent single scattering albedo 
	and cloud opacity as a function of altitude. 


	Parameters
	----------
	full_output

	Returns
	-------
	A row of two bokeh plots with the single scattering and optical depth map
	"""
    cols = colfun1(200)
    color_mapper = LinearColorMapper(palette=cols, low=0, high=1)

    dat01 = full_output['layer']['cloud']

    #PLOT W0
    scat01 = np.flip(dat01['w0'], 0)  #[0:10,:]
    xr, yr = scat01.shape
    f01a = figure(x_range=[0, yr],
                  y_range=[0, xr],
                  x_axis_label='Wavenumber Grid',
                  y_axis_label='Pressure Grid, TOA ->',
                  title="Single Scattering Albedo",
                  plot_width=300,
                  plot_height=300)

    f01a.image(image=[scat01],
               color_mapper=color_mapper,
               x=0,
               y=0,
               dh=xr,
               dw=yr)

    color_bar = ColorBar(
        color_mapper=color_mapper,  #ticker=LogTicker(),
        label_standoff=12,
        border_line_color=None,
        location=(0, 0))

    f01a.add_layout(color_bar, 'left')

    #PLOT OPD
    scat01 = np.flip(dat01['opd'] + 1e-60, 0)

    xr, yr = scat01.shape
    cols = colfun2(200)[::-1]
    color_mapper = LogColorMapper(palette=cols, low=1e-3, high=10)

    f01 = figure(x_range=[0, yr],
                 y_range=[0, xr],
                 x_axis_label='Wavenumber Grid',
                 y_axis_label='Pressure Grid, TOA ->',
                 title="Cloud Optical Depth Per Layer",
                 plot_width=300,
                 plot_height=300)

    f01.image(image=[scat01],
              color_mapper=color_mapper,
              x=0,
              y=0,
              dh=xr,
              dw=yr)

    color_bar = ColorBar(color_mapper=color_mapper,
                         ticker=LogTicker(),
                         label_standoff=12,
                         border_line_color=None,
                         location=(0, 0))
    f01.add_layout(color_bar, 'left')

    #PLOT G0
    scat01 = np.flip(dat01['g0'] + 1e-60, 0)

    xr, yr = scat01.shape
    cols = colfun3(200)[::-1]
    color_mapper = LinearColorMapper(palette=cols, low=0, high=1)

    f01b = figure(x_range=[0, yr],
                  y_range=[0, xr],
                  x_axis_label='Wavenumber Grid',
                  y_axis_label='Pressure Grid, TOA ->',
                  title="Assymetry Parameter",
                  plot_width=300,
                  plot_height=300)

    f01b.image(image=[scat01],
               color_mapper=color_mapper,
               x=0,
               y=0,
               dh=xr,
               dw=yr)

    color_bar = ColorBar(color_mapper=color_mapper,
                         ticker=BasicTicker(),
                         label_standoff=12,
                         border_line_color=None,
                         location=(0, 0))
    f01b.add_layout(color_bar, 'left')
    return column(row(f01a, f01, row(f01b)))
예제 #4
0
def all_optics(out):
    """
    Maps of the wavelength dependent single scattering albedo 
    and cloud opacity and asymmetry parameter as a function of altitude. 

    Parameters
    ----------
    out : dict 
        Dictionary output from pyeddy run 

    Returns
    -------
    Three bokeh plots with the single scattering, optical depth, and assymetry maps
    """
    #get into DataFrame format
    dat01 = pyeddy.picaso_format(out['opd_per_layer'],
                      out['asymmetry'],out['single_scattering'])

    nwno=len(out['wave'])
    nlayer=len(out['pressure'])
    pressure=out['pressure']

    pressure_label = 'Pressure (Bars)'

    wavelength_label = 'Wavelength (um)'
    wavelength = out['wave']

    cols = colfun1(200)
    color_mapper = LinearColorMapper(palette=cols, low=0, high=1)

    #PLOT W0
    scat01 = np.flip(np.reshape(dat01['w0'].values,(nlayer,nwno)),0)
    xr, yr = scat01.shape
    f01a = figure(x_range=[0, yr], y_range=[0,xr],
                           x_axis_label=wavelength_label, y_axis_label=pressure_label,
                           title="Single Scattering Albedo",
                          plot_width=300, plot_height=300)


    f01a.image(image=[scat01],  color_mapper=color_mapper, x=0,y=0,dh=xr,dw =yr )

    color_bar = ColorBar(color_mapper=color_mapper, #ticker=LogTicker(),
                       label_standoff=12, border_line_color=None, location=(0,0))

    f01a.add_layout(color_bar, 'left')


    #PLOT OPD
    scat01 = np.flip(np.reshape(dat01['opd'].values,(nlayer,nwno)),0)

    xr, yr = scat01.shape
    cols = colfun2(200)[::-1]
    color_mapper = LogColorMapper(palette=cols, low=1e-3, high=10)


    f01 = figure(x_range=[0, yr], y_range=[0,xr],
                           x_axis_label=wavelength_label, y_axis_label=pressure_label,
                           title="Cloud Optical Depth Per Layer",
                          plot_width=320, plot_height=300)

    f01.image(image=[scat01],  color_mapper=color_mapper, x=0,y=0,dh=xr,dw =yr )

    color_bar = ColorBar(color_mapper=color_mapper, ticker=LogTicker(),
                       label_standoff=12, border_line_color=None, location=(0,0))
    f01.add_layout(color_bar, 'left')

    #PLOT G0
    scat01 = np.flip(np.reshape(dat01['g0'].values,(nlayer,nwno)),0)

    xr, yr = scat01.shape
    cols = colfun3(200)[::-1]
    color_mapper = LinearColorMapper(palette=cols, low=0, high=1)


    f01b = figure(x_range=[0, yr], y_range=[0,xr],
                           x_axis_label=wavelength_label, y_axis_label=pressure_label,
                           title="Assymetry Parameter",
                          plot_width=300, plot_height=300)

    f01b.image(image=[scat01],  color_mapper=color_mapper, x=0,y=0,dh=xr,dw =yr )

    color_bar = ColorBar(color_mapper=color_mapper, ticker=BasicTicker(),
                       label_standoff=12, border_line_color=None, location=(0,0))
    f01b.add_layout(color_bar, 'left')

    #CHANGE X AND Y AXIS TO BE PHYSICAL UNITS 
    #indexes for pressure plot 
    if (pressure is not None):
        pressure = ["{:.1E}".format(i) for i in pressure[::-1]] #flip since we are also flipping matrices
        npres = len(pressure)
        ipres = np.array(range(npres))
        #set how many we actually want to put on the figure 
        #hard code ten on each.. 
        ipres = ipres[::int(npres/10)]
        pressure = pressure[::int(npres/10)]
        #create dictionary for tick marks 
        ptick = {int(i):j for i,j in zip(ipres,pressure)}
        for i in [f01a, f01, f01b]:
            i.yaxis.ticker = ipres
            i.yaxis.major_label_overrides = ptick
    if (wavelength is not None):
        wave = ["{:.2F}".format(i) for i in wavelength]
        nwave = len(wave)
        iwave = np.array(range(nwave))
        iwave = iwave[::int(nwave/10)]
        wave = wave[::int(nwave/10)]
        wtick = {int(i):j for i,j in zip(iwave,wave)}
        for i in [f01a, f01, f01b]:
            i.xaxis.ticker = iwave
            i.xaxis.major_label_overrides = wtick       

    return row(f01a, f01,f01b)
예제 #5
0
def plot_cld_input(nwno, nlayer, filename=None, df=None, **pd_kwargs):
    """
	This function was created to investigate CLD input file for PICASO. 

	The plot itselfs creates maps of the wavelength dependent single scattering albedo 
	and cloud opacity and assymetry parameter as a function of altitude. 


	Parameters
	----------
	nwno : int 
		Number of wavenumber points. For runs from Ackerman & Marley, this will always be 196. 
	nlayer : int 
		Should be one less than the number of levels in your pressure temperature grid. Cloud 
		opacity is assigned for slabs. 
	file : str 
		(Optional)Path to cloud input file
	df : str 
		(Optional)Dataframe of cloud input file
	pd_kwargs : kwargs
		Pandas key word arguments for `pandas.read_csv`

	Returns
	-------
	Three bokeh plots with the single scattering, optical depth, and assymetry maps
	"""
    cols = colfun1(200)
    color_mapper = LinearColorMapper(palette=cols, low=0, high=1)

    if not isinstance(filename, type(None)):
        dat01 = pd.read_csv(filename, **pd_kwargs)
    elif not isinstance(df, type(None)):
        dat01 = df

    #PLOT W0
    scat01 = np.flip(np.reshape(dat01['w0'].values, (nlayer, nwno)), 0)
    xr, yr = scat01.shape
    f01a = figure(x_range=[0, yr],
                  y_range=[0, xr],
                  x_axis_label='Wavenumber Grid',
                  y_axis_label='Pressure Grid, TOA ->',
                  title="Single Scattering Albedo",
                  plot_width=300,
                  plot_height=300)

    f01a.image(image=[scat01],
               color_mapper=color_mapper,
               x=0,
               y=0,
               dh=xr,
               dw=yr)

    color_bar = ColorBar(
        color_mapper=color_mapper,  #ticker=LogTicker(),
        label_standoff=12,
        border_line_color=None,
        location=(0, 0))

    f01a.add_layout(color_bar, 'left')

    #PLOT OPD
    scat01 = np.flip(np.reshape(dat01['opd'].values, (nlayer, nwno)), 0)

    xr, yr = scat01.shape
    cols = colfun2(200)[::-1]
    color_mapper = LogColorMapper(palette=cols, low=1e-3, high=10)

    f01 = figure(x_range=[0, yr],
                 y_range=[0, xr],
                 x_axis_label='Wavenumber Grid',
                 y_axis_label='Pressure Grid, TOA ->',
                 title="Cloud Optical Depth Per Layer",
                 plot_width=300,
                 plot_height=300)

    f01.image(image=[scat01],
              color_mapper=color_mapper,
              x=0,
              y=0,
              dh=xr,
              dw=yr)

    color_bar = ColorBar(color_mapper=color_mapper,
                         ticker=LogTicker(),
                         label_standoff=12,
                         border_line_color=None,
                         location=(0, 0))
    f01.add_layout(color_bar, 'left')

    #PLOT G0
    scat01 = np.flip(np.reshape(dat01['g0'].values, (nlayer, nwno)), 0)

    xr, yr = scat01.shape
    cols = colfun3(200)[::-1]
    color_mapper = LinearColorMapper(palette=cols, low=0, high=1)

    f01b = figure(x_range=[0, yr],
                  y_range=[0, xr],
                  x_axis_label='Wavenumber Grid',
                  y_axis_label='Pressure Grid, TOA ->',
                  title="Assymetry Parameter",
                  plot_width=300,
                  plot_height=300)

    f01b.image(image=[scat01],
               color_mapper=color_mapper,
               x=0,
               y=0,
               dh=xr,
               dw=yr)

    color_bar = ColorBar(color_mapper=color_mapper,
                         ticker=BasicTicker(),
                         label_standoff=12,
                         border_line_color=None,
                         location=(0, 0))
    f01b.add_layout(color_bar, 'left')
    return column(row(f01a, f01, row(f01b)))