Exemplo n.º 1
0
def so_solar_spectrum(diffraction_order, instrument_temperature, solspec_file, adj_orders=2):
    """get low res SO channel convoluted solar spectrum for given diffraction order"""
       
    spec_res = spec_res_order(diffraction_order)
    pixels = np.arange(320)
    
    nu_hr, I0_solar_hr, dnu = solar_hr_orders(diffraction_order, adj_orders, instrument_temperature, solspec_file)
    Nbnu_hr = len(nu_hr)
    
    NbP = len(pixels)
    
    W_conv = np.zeros((NbP,Nbnu_hr))
    sconv = spec_res/2.355
    for iord in range(diffraction_order-adj_orders, diffraction_order+adj_orders+1):
        nu_pm = nu_mp(iord, pixels, instrument_temperature)
        W_blaze = F_blaze(iord, pixels, instrument_temperature)
        for ip in pixels:
            W_conv[ip,:] += (W_blaze[ip]*dnu)/(np.sqrt(2.*np.pi)*sconv)*np.exp(-(nu_hr-nu_pm[ip])**2/(2.*sconv**2))
    
    W_aotf = F_aotf_goddard18b(diffraction_order, nu_hr, instrument_temperature)
    I0_hr = W_aotf * I0_solar_hr
    I0_p = np.matmul(W_conv, I0_hr)
    
    nu_pm_centre = nu_mp(diffraction_order, pixels, instrument_temperature)
    
    return nu_pm_centre, I0_p
Exemplo n.º 2
0
def so_solar_line_temperature_shift(diffraction_order, instrument_temperatures, solspec_file, adj_orders=2, cutoff=0.999):
    """unfinished: get so spectrum due to temperature induced solar line shift"""
       
    spec_res = spec_res_order(diffraction_order)
    pixels = np.arange(320)
    
    instrument_temperature  = instrument_temperatures[0]
    
    nu_hr, I0_solar_hr, dnu = solar_hr_orders(diffraction_order, adj_orders, instrument_temperature, solspec_file)
    Nbnu_hr = len(nu_hr)
    
    NbP = len(pixels)
    W_conv = np.zeros((NbP,Nbnu_hr))
    sconv = spec_res/2.355
    for iord in range(diffraction_order-adj_orders, diffraction_order+adj_orders+1):
        nu_pm = nu_mp(iord, pixels, instrument_temperature)
        W_blaze = F_blaze(iord, pixels, instrument_temperature)
        for ip in pixels:
            W_conv[ip,:] += (W_blaze[ip]*dnu)/(np.sqrt(2.*np.pi)*sconv)*np.exp(-(nu_hr-nu_pm[ip])**2/(2.*sconv**2))
    
    
    
    W_aotf = F_aotf_goddard18b(diffraction_order, nu_hr, instrument_temperature)
    I0_hr = W_aotf * I0_solar_hr
    I0_p = np.matmul(W_conv, I0_hr)
    
    #plt.plot(nu_hr, I0_solar_hr)
        #plt.plot(nu_hr, I0_hr)
        #plt.plot(nu_hr, W_aotf)
    #    plt.plot(pixels, I0_p)
    
    instrument_temperature  = instrument_temperatures[1]
    
    nu_hr2, I0_solar_hr2, dnu2 = solar_hr_orders(diffraction_order, adj_orders, instrument_temperature, solspec_file)
    Nbnu_hr2 = len(nu_hr2)
    
    NbP2 = len(pixels)
    W_conv2 = np.zeros((NbP2,Nbnu_hr2))
    sconv2 = spec_res/2.355
    for iord in range(diffraction_order-adj_orders, diffraction_order+adj_orders+1):
        nu_pm2 = nu_mp(iord, pixels, instrument_temperature)
        W_blaze2 = F_blaze(iord, pixels, instrument_temperature)
        for ip in pixels:
            W_conv2[ip,:] += (W_blaze2[ip]*dnu2)/(np.sqrt(2.*np.pi)*sconv2)*np.exp(-(nu_hr2-nu_pm2[ip])**2/(2.*sconv2**2))
    
    
    
    W_aotf2 = F_aotf_goddard18b(diffraction_order, nu_hr2, instrument_temperature)
    I0_hr2 = W_aotf2 * I0_solar_hr2
    I0_p2 = np.matmul(W_conv2, I0_hr2)
    
    ratio = I0_p / I0_p2
    
    polyfit = np.polyval(np.polyfit(pixels, ratio, 5), pixels)
    
    normalisedRatio = ratio/polyfit
    
    return normalisedRatio
Exemplo n.º 3
0
def plot_solar_line_shift(ax,
                          instrument_temperature,
                          delta_temperature,
                          diffraction_order,
                          offset=0.005):
    """plot solar line shift due to grating temperature change on axis"""

    instrument_temperatures = [
        instrument_temperature, instrument_temperature + delta_temperature
    ]
    solspec_filepath = os.path.join("reference_files",
                                    "nomad_solar_spectrum_solspec.txt")

    lineShift = so_solar_line_temperature_shift(diffraction_order,
                                                instrument_temperatures,
                                                solspec_filepath,
                                                adj_orders=2)

    pixels = np.arange(320)
    nu = nu_mp(diffraction_order, pixels, instrument_temperature)
    ax.plot(nu,
            lineShift + offset,
            color="brown",
            linestyle="--",
            label="%0.2fC solar line shift offset+%0.3f" %
            (delta_temperature, offset))
Exemplo n.º 4
0
def plot_all_bins_occultation(ax,
                              hdf5_filename,
                              spectra_id_all_bins,
                              use_file_nu=False,
                              instrument_temperature=-999.):
    """plot the selected spectra from all the bins of one hdf5 file.
    If use_file_nu then take the wavenumbers from the file,
    else if an instrument temperature to recalculate nu grid.
    Output = waenumber grid"""

    hdf5_filepath, hdf5_file = getFile(hdf5_filename, "hdf5_level_1p0a", 0)

    #calibrate transmittances for all 4 bins
    obsDict0 = getLevel1Data(
        hdf5_file, hdf5_filename, 0, silent=True,
        top_of_atmosphere=60.0)  #use mean method, returns dictionary
    obsDict1 = getLevel1Data(
        hdf5_file, hdf5_filename, 1, silent=True,
        top_of_atmosphere=60.0)  #use mean method, returns dictionary
    obsDict2 = getLevel1Data(
        hdf5_file, hdf5_filename, 2, silent=True,
        top_of_atmosphere=60.0)  #use mean method, returns dictionary
    obsDict3 = getLevel1Data(
        hdf5_file, hdf5_filename, 3, silent=True,
        top_of_atmosphere=60.0)  #use mean method, returns dictionary

    #cat all data and sort by altitude
    yAll = np.concatenate((obsDict0["y_mean"], obsDict1["y_mean"],
                           obsDict2["y_mean"], obsDict3["y_mean"]))
    altAll = np.concatenate(
        (obsDict0["alt"], obsDict1["alt"], obsDict2["alt"], obsDict3["alt"]))
    sortIndices = altAll.argsort()
    altSorted = altAll[sortIndices]
    ySorted = yAll[sortIndices, :]

    #use wavenumber X from file, or remake from instrument temperature?
    #replace with line detection
    if use_file_nu:
        #       nu = obsDict0["x"][0, :] - 0.1
        nu_obs = obsDict0["x"][0, :]
    else:
        diffraction_order = int(hdf5_filename.split("_")[-1])
        pixels = np.arange(320)
        nu_obs = nu_mp(diffraction_order, pixels, instrument_temperature)

    for spectrum_index in spectra_id_all_bins:
        yBaseline = baseline_als(ySorted[spectrum_index, :])
        yCorrected = ySorted[spectrum_index, :] / yBaseline

        ax.plot(nu_obs,
                yCorrected,
                label="%0.1fkm" % altSorted[spectrum_index])

    return nu_obs
Exemplo n.º 5
0
def plot_single_bin_occultation(ax,
                                hdf5_filename,
                                spectra_id_all_bins,
                                use_file_nu=False,
                                instrument_temperature=-999.):
    """plot the selected spectra from a single bin of one hdf5 file.
    If use_file_nu then take the wavenumbers from the file,
    else if an instrument temperature to recalculate nu grid.
    Output = waenumber grid"""

    hdf5_filepath, hdf5_file = getFile(hdf5_filename, "hdf5_level_1p0a", 0)

    #find which spectrum indices in the source file correspond to those in the chosen bin
    bins = hdf5_file["Science/Bins"][:, 0]
    uniqueBins = sorted(list(set(bins)))
    binIndices = np.where(bins == uniqueBins[CHOSEN_BIN])[0]
    binIds = []
    for binId, binIndex in enumerate(binIndices):
        if binIndex in spectra_id_all_bins:
            binIds.append(binId)

    #get data for the chosen bin
    obsDict = getLevel1Data(
        hdf5_file,
        hdf5_filename,
        CHOSEN_BIN,
        silent=True,
        top_of_atmosphere=60.0)  #use mean method, returns dictionary

    #use wavenumber X from file, or remake from instrument temperature?
    #replace with line detection
    if use_file_nu:
        nu_obs = obsDict["x"][0, :]
    else:
        diffraction_order = int(hdf5_filename.split("_")[-1])
        pixels = np.arange(320)
        nu_obs = nu_mp(diffraction_order, pixels, instrument_temperature)

    #remove baseline continuum and plot
    for spectrumIndex in binIds:
        y_mean_baseline = baseline_als(obsDict["y_mean"][spectrumIndex, :])
        y_mean_corrected = obsDict["y_mean"][
            spectrumIndex, :] / y_mean_baseline

        ax.plot(nu_obs,
                y_mean_corrected,
                label="SO bin %i @ %0.1fkm " %
                (CHOSEN_BIN, obsDict["alt"][spectrumIndex]))

    return nu_obs
Exemplo n.º 6
0
        9, 10, 11, 15
    ], :]  #chosen to avoid bad pixels
    dim_rows = detector_centre_data.shape

    good_indices = range(dim[0])

    colours = get_colours(len(good_indices))

    d["title"] = "%s simulation orders %i-%i" % (hdf5_filename, order_range[0],
                                                 order_range[1])

    d["text"] = ["A=%ikHz" % i for i in aotf_freq[good_indices]]
    """spectral grid and blaze functions of all orders"""
    dnu = 0.001
    nu_range = [
        nu_mp(order_range[0], [0.0], temperature)[0] - 5.0, \
        nu_mp(order_range[1], [319.0], temperature)[0] + 5.0
            ]
    nu_hr = np.arange(nu_range[0], nu_range[1], dnu)

    I0_solar_hr = get_solar_hr(nu_hr, solspec_filepath=ss_file)

    Nbnu_hr = len(nu_hr)
    NbP = len(pixels)

    sconv = spec_res / 2.355
    W_conv_old = np.zeros((NbP, Nbnu_hr))
    W_conv_new = np.zeros((NbP, Nbnu_hr))
    for iord in range(order_range[0], order_range[1] + 1):
        print("Blaze order %i" % iord)
        nu_pm = nu_mp(iord, pixels, temperature)
Exemplo n.º 7
0
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  4 09:45:39 2019

@author: iant

SIMULATE SOLAR LINE SHIFTS IN SO

"""

import os
import numpy as np
import matplotlib.pyplot as plt

from tools.spectra.solar_spectrum_so import so_solar_line_temperature_shift
from instrument.nomad_so_instrument import nu_mp

diffractionOrder = 134
instrumentTemperatures = [-5.0, -4.0]
solspecFile = os.path.join("reference_files",
                           "nomad_solar_spectrum_solspec.txt")

lineShift = so_solar_line_temperature_shift(diffractionOrder,
                                            instrumentTemperatures,
                                            solspecFile,
                                            adj_orders=2,
                                            cutoff=0.999)
nu = nu_mp(diffractionOrder, np.arange(320), instrumentTemperatures[0])

plt.plot(nu, lineShift)
Exemplo n.º 8
0
            # plt.plot(px_sum/max(px_sum), label="Solar spectrum approximation")

            ss_file = os.path.join(paths["RETRIEVALS"]["SOLAR_DIR"],
                                   "Solar_irradiance_ACESOLSPEC_2015.dat")
            spec_res = spec_res_order(c_order)

            nu_hr, dnu = nu_hr_grid(c_order, adj_orders, temperature)
            I0_solar_hr = get_solar_hr(nu_hr, solspec_filepath=ss_file)

            Nbnu_hr = len(nu_hr)
            NbP = len(pixels)

            W_conv = np.zeros((NbP, Nbnu_hr))
            sconv = spec_res / 2.355
            for iord in range(c_order - adj_orders, c_order + adj_orders + 1):
                nu_pm = nu_mp(iord, pixels, temperature)
                W_blaze = F_blaze(iord, pixels, temperature)
                for ip in pixels:
                    W_conv[ip, :] += (W_blaze[ip] * dnu) / (np.sqrt(
                        2. * np.pi) * sconv) * np.exp(-(nu_hr - nu_pm[ip])**2 /
                                                      (2. * sconv**2))

            W_aotf = F_aotf_goddard18b(0.,
                                       nu_hr,
                                       temperature,
                                       A=aotf_freq[frame_no])
            I0_hr = W_aotf * I0_solar_hr
            I0_p = np.matmul(W_conv, I0_hr)
            solar = I0_p

            solar_norm = solar / max(solar)
Exemplo n.º 9
0
from instrument.nomad_so_instrument import nu_mp
from tools.spectra.molecular_spectrum_so import get_molecular_hr
from tools.spectra.solar_spectrum_so import nu_hr_grid
from tools.spectra.smooth_hr import smooth_hr

SMOOTHING_LEVEL = 350

#order = 129 
order = 130 
molecule = "HCl"
molecule = "CO2"
molecule = "H2O"

instrument_temperature = 0.0

nu = nu_mp(order, np.arange(320), instrument_temperature)
nu_hr, _ = nu_hr_grid(order, 0, instrument_temperature)
#nu_hr = np.arange(nu[0], nu[-1], 0.001)

molecular_spectrum_hr = get_molecular_hr(molecule, nu_hr, Smin=1.0e-33)

molecular_spectrum = smooth_hr(molecular_spectrum_hr, window_len=(SMOOTHING_LEVEL-1))
normalised_molecular_spectrum = 1.0 - molecular_spectrum[int(SMOOTHING_LEVEL/2-1):-1*int(SMOOTHING_LEVEL/2-1)]

plt.figure()
plt.plot(nu_hr, normalised_molecular_spectrum)
plt.title("%s Spectrum Order %i Simulation" %(molecule, order))
plt.xlabel("Wavenumber (cm-1)")
plt.ylabel("Normalised Transmittance")
plt.savefig("%s_simulation_order_%i.png" %(molecule, order))
Exemplo n.º 10
0
def simple_retrieval(y_in,
                     alt,
                     molecule,
                     order,
                     instrument_temperature,
                     snr=500.0):

    resolving_power = 10000.

    retDict = {}
    #    TangentAlt = obsDict["alt"]
    #    retDict["XObs"] = obsDict["x"]
    #    retDict["YObs"] = y_in
    #    retDict["NbZ"] = NbZ
    #    print("TangentAlt=", TangentAlt)

    TangentAlt = np.arange(alt, 100.0, 5.0)
    NbZ = len(TangentAlt)
    retDict["NbZ"] = NbZ
    retDict["instrument_temperature"] = instrument_temperature

    retDict["YObs"] = np.ones((NbZ, len(y_in)))
    retDict["YObs"][0, :] = y_in
    retDict["YError"] = np.zeros_like(retDict["YObs"]) + y_in / snr

    #    atmolist = gem_tools.get_observation_atmolist_filename(obsDict)
    #    with open(os.path.join(paths["RETRIEVALS"]["APRIORI_FILE_DESTINATION"], atmolist), 'r') as f:
    #        all_atmofiles = f.readlines()
    atmofile = os.path.join(paths["RETRIEVALS"]["APRIORI_FILE_DESTINATION"],
                            "generic.dat")

    atmo = {}
    atmo['Z'] = TangentAlt
    atmo['T'] = np.zeros(NbZ)
    atmo['P'] = np.zeros(NbZ)
    atmo['NT'] = np.zeros(NbZ)
    Zin, Tin, Pin, NTin = np.loadtxt(atmofile,
                                     comments='%',
                                     usecols=(0, 1, 2, 3),
                                     unpack=True)
    for iz in range(NbZ):
        iz2 = np.argmax(atmo['Z'][iz] > Zin)

        f = (Zin[iz2 - 1] - atmo['Z'][iz]) / (Zin[iz2 - 1] - Zin[iz2])
        atmo['T'][iz] = (1. - f) * Tin[iz2 - 1] + f * Tin[iz2]
        atmo['P'][iz] = np.exp((1. - f) * np.log(Pin[iz2 - 1]) +
                               f * np.log(Pin[iz2]))
        atmo['NT'][iz] = np.exp((1. - f) * np.log(NTin[iz2 - 1]) +
                                f * np.log(NTin[iz2]))
    retDict["atmo"] = atmo

    gem_version_string = 'gem-mars-a585'
    #    apriori_version = 'apriori_1_1_1_GEMZ_wz_mixed'
    apriori_version = 'apriori_4_2_4_GEMZ_wz_mixed'
    #    geom = nomadtools.get_obs_geometry(obsDict)
    apriori_zone = "Spring_Southern_Day"  #apriori_zone='AllSeasons_AllHemispheres_AllTime'
    print("apriori_zone=", apriori_zone)

    #    molecule = obsDict["molecule"]

    if molecule == "CH4":
        retDict["xa"] = np.ones(
            len(atmo['Z'])
        ) * 1.0e-9  #1ppb constant, converted to dimensionless quantity
        retDict["sa"] = np.ones(
            len(atmo['Z'])
        ) * 10.0  #10x variation allowed above/below.  #for CH4, don't scale CO2 allowed deviation
    elif molecule == "HCl":
        retDict["xa"] = np.ones(
            len(atmo['Z'])
        ) * 1.0e-9  #1ppb constant, converted to dimensionless quantity
        retDict["sa"] = np.ones(
            len(atmo['Z'])
        ) * 10.0  #10x variation allowed above/below.  #for CH4, don't scale CO2 allowed deviation
    elif molecule == "PH3":
        retDict["xa"] = np.ones(
            len(atmo['Z'])
        ) * 1.0e-9  #1ppb constant, converted to dimensionless quantity
        retDict["sa"] = np.ones(
            len(atmo['Z'])
        ) * 10.0  #10x variation allowed above/below.  #for CH4, don't scale CO2 allowed deviation
    else:
        name = molecule
        atmo_dir = os.path.join(gem_version_string, apriori_version)
        mean_file = gem_version_string + '_' + apriori_zone + '_mean_' + name + '.dat'
        stdev_file = gem_version_string + '_' + apriori_zone + '_stdev_' + name + '.dat'
        xa_file = os.path.join(atmo_dir, mean_file)
        sa_file = os.path.join(atmo_dir, stdev_file)

        za_in, xa_in = np.loadtxt(os.path.join(
            paths["RETRIEVALS"]['ATMOSPHERE_DIR'], xa_file),
                                  comments='%',
                                  usecols=(
                                      0,
                                      1,
                                  ),
                                  unpack=True)  #read in ppm
        sa_in = np.loadtxt(os.path.join(paths["RETRIEVALS"]['ATMOSPHERE_DIR'],
                                        sa_file),
                           comments='%',
                           usecols=(1, ))

        xa_fun = interpolate.interp1d(za_in[::-1], xa_in[::-1])
        sa_fun = interpolate.interp1d(za_in[::-1], sa_in[::-1])

        retDict["xa"] = xa_fun(
            atmo['Z']
        ) * 1.0e-6  #state vector: get a priori VMR in ppm from GEM. Convert to no units
        retDict["sa"] = sa_fun(atmo['Z'])

    retDict["xa_fact"] = np.ones_like(retDict["xa"])

    adj_orders = 0
    retDict["order"] = order
    retDict["adj_orders"] = adj_orders

    nu_hr_min = nu_mp(order - adj_orders, 0.,
                      retDict["instrument_temperature"]) - 5.
    nu_hr_max = nu_mp(order + adj_orders, 320.,
                      retDict["instrument_temperature"]) + 5.
    nu_centre = nu_mp(order, 160.0, retDict["instrument_temperature"])
    dnu = 0.001
    Nbnu_hr = int(np.ceil((nu_hr_max - nu_hr_min) / dnu)) + 1
    retDict["nu_hr"] = np.linspace(nu_hr_min, nu_hr_max, Nbnu_hr)
    dnu = retDict["nu_hr"][1] - retDict["nu_hr"][0]

    # read in solar
    solspecFilepath = os.path.join(paths["REFERENCE_DIRECTORY"],
                                   "nomad_solar_spectrum_solspec.txt")
    I0_solar_hr = get_solar_hr(retDict["nu_hr"], solspecFilepath)

    retDict["Nbnu_hr"] = Nbnu_hr
    retDict["dnu"] = dnu
    retDict["I0_hr"] = I0_solar_hr

    M = pytran.get_molecule_id(molecule)
    filename = os.path.join(paths["RETRIEVALS"]['HITRAN_DIR'],
                            '%02i_hit16_2000-5000_CO2broadened.par' % M)
    if not os.path.exists(filename):
        filename = os.path.join(paths["RETRIEVALS"]['HITRAN_DIR'],
                                '%02i_hit16_2000-5000.par' % M)

    if molecule == "CO2" and order > 140:
        Smin = 1.0e-26
    elif molecule == "H2O":
        Smin = 1.0e-27
    else:
        Smin = 1.0e-33

    nlines = 999
    while nlines > 200:
        Smin *= 10.0
        LineList = pytran.read_hitran2012_parfile(filename,
                                                  nu_hr_min,
                                                  nu_hr_max,
                                                  Smin=Smin,
                                                  silent=True)
        nlines = len(LineList['S'])
        print('Found %i lines' % nlines)

    retDict["LineList"] = LineList

    retDict["sigma_hr"] = np.zeros((NbZ, Nbnu_hr))
    for i in range(NbZ):
        if np.mod(i, 10) == 0:
            print("%d of %d" % (i, NbZ))
        retDict["sigma_hr"][i, :] = pytran.calculate_hitran_xsec(
            LineList,
            M,
            retDict["nu_hr"],
            T=atmo['T'][i],
            P=atmo['P'][i] * 1e3)

    #limit range
    retDict["pixels"] = np.arange(len(y_in))
    NbP = len(retDict["pixels"])
    retDict["NbP"] = NbP
    retDict["nu_p"] = nu_mp(order, retDict["pixels"],
                            retDict["instrument_temperature"])
    retDict["Trans_p"] = np.ones((NbZ, NbP))

    background_degree = 4
    retDict["background_degree"] = background_degree
    retDict["background_coeffs"] = np.zeros((NbZ, background_degree + 1))
    retDict["Trans_background"] = np.ones((NbZ, NbP))

    print("Computing convolution matrix")
    W_conv_old = np.zeros((NbP, Nbnu_hr))
    W_conv = np.zeros((NbP, Nbnu_hr))

    retDict["spectral_resolution"] = nu_centre / resolving_power
    retDict["sconv"] = retDict["spectral_resolution"] / 2.355  #0.40/2.355

    #    if obsDict["gaussian_scalar"] is not None:
    #        scalar = obsDict["gaussian_scalar"]
    #        xoffset = obsDict["gaussian_xoffset"]
    #        width = retDict["sconv"] * obsDict["gaussian_width"]

    for iord in range(order - adj_orders, order + adj_orders + 1):
        retDict["%i" % iord] = {}
        retDict["%i" % iord]["nu_pm"] = nu_mp(
            iord, retDict["pixels"], retDict["instrument_temperature"])
        W_blaze = F_blaze(iord, retDict["pixels"],
                          retDict["instrument_temperature"])
        retDict["%i" % iord]["W_blaze"] = W_blaze
        for pixelIndex, _ in enumerate(retDict["pixels"]):
            #(W_blaze[pixelIndex]*dnu) / (np.sqrt(2.*np.pi)*sconv) * np.exp(-(nu_hr-nu_pm[pixelIndex])**2/(2.*sconv**2))
            gaussian = (retDict["%i" % iord]["W_blaze"][pixelIndex] *
                        retDict["dnu"]
                        ) / (np.sqrt(2. * np.pi) * retDict["sconv"]) * np.exp(
                            -(retDict["nu_hr"] -
                              retDict["%i" % iord]["nu_pm"][pixelIndex])**2 /
                            (2. * retDict["sconv"]**2))
            #            if obsDict["gaussian_scalar"] is not None:
            #                gaussian2 = (retDict["%i" %iord]["W_blaze"][pixelIndex]*retDict["dnu"]*scalar)/(np.sqrt(2.*np.pi)*width)*np.exp(-(retDict["nu_hr"]-retDict["%i" %iord]["nu_pm"][pixelIndex]+xoffset)**2/(2.*width**2))
            retDict["%i" % iord]["gaussian"] = gaussian
            #            if obsDict["gaussian_scalar"] is not None:
            #                retDict["%i" %iord]["gaussian2"] = gaussian2
            W_conv_old[pixelIndex, :] += gaussian
            W_conv[pixelIndex, :] += gaussian


#            if obsDict["gaussian_scalar"] is not None:
#                W_conv[pixelIndex,:] += gaussian2
    retDict["W_conv"] = W_conv
    retDict["W_conv_old"] = W_conv_old

    return retDict
Exemplo n.º 11
0
    return nu_obs


###start script###

nBestSpectra = 1000
print("Getting data for best spectra from .mat file")
chosenSource, allSources, sourceDiffractionOrder, sourceList = best_observation_list(
    matFilepath, nBestSpectra)
co2LineListDict = get_co2_line_list(lineListFilepath)

#get wavenumber scale for Frederic analysis
sourceInstTemperature = -7.5  #this temperature is required to match wavenumber scale to Frederic's plot
pixels = np.arange(320)
nuSource = nu_mp(sourceDiffractionOrder, pixels, sourceInstTemperature)
"""plot all sources on a figure"""
#fig, ax = plt.subplots(figsize=(FIG_X, FIG_Y))
#plot_sources(ax, allSources, nuSource, co2LineListDict)
#plot_co2_line_list(ax, co2LineListDict, 0.07)
"""plot a single observation selected above"""
obsDiffractionOrder = int(hdf5Filename.split("_")[-1])

fig, ax = plt.subplots(figsize=(FIG_X, FIG_Y))
ax.set_title(hdf5Filename)
nuObservation = plot_single_bin_occultation(
    ax,
    hdf5Filename,
    spectraIdAllBins,
    instrument_temperature=instrumentTemperature)
plot_co2_line_list(ax, co2LineListDict, 1.01, alpha_intensity=True)
Exemplo n.º 12
0
                  top_of_atmosphere=toa_alt),
    getLevel1Data(chosen_hdf5_file,
                  chosen_hdf5_filename,
                  2,
                  silent=True,
                  top_of_atmosphere=toa_alt),
    getLevel1Data(chosen_hdf5_file,
                  chosen_hdf5_filename,
                  3,
                  silent=True,
                  top_of_atmosphere=toa_alt),
]

#x = obs_dicts[0]["x"][0,:]
#x = pixels
x = nu_mp(diffraction_order, pixels, instrument_temperature)

if 2 in plot_type:
    #plot bin 3 chosen altitude uncorrected
    bin_index = 3
    alts = obs_dicts[bin_index]["alt"]
    spectrum_index = get_nearest_index(plot_altitude, alts)

    alt = obs_dicts[bin_index]["alt"][spectrum_index]

    y = obs_dicts[bin_index]["y_mean"][spectrum_index, :]
    y_continuum = fit_polynomial(pixels, y, 5, indices=indices_no_strong_abs)
    y_corrected = y / y_continuum
    ax1.plot(x,
             y_corrected,
             "g",