示例#1
0
def check_uvis_limbs(regex, file_level):
    """plot and print uvis limbs with minimum tangent height and spectral binning data"""
    hdf5_files, hdf5_filenames, _ = make_filelist(regex, file_level)
    colours = get_colours(len(hdf5_filenames))

    fig, ax = plt.subplots()

    for file_index, (hdf5_file, hdf5_filename) in enumerate(
            zip(hdf5_files, hdf5_filenames)):

        tangent_alts = np.mean(
            hdf5_file["Geometry/Point0/TangentAltAreoid"][...], axis=1)
        valid_indices = np.where(tangent_alts > -990.0)[0]

        ax.plot(tangent_alts[valid_indices],
                label=hdf5_filename,
                color=colours[file_index])

        binning = hdf5_file["Channel/HorizontalAndCombinedBinningSize"][0]

        n_spectra = len(tangent_alts)

        centre_indices = np.arange(int(n_spectra / 4), int(n_spectra * 3 / 4))
        min_tangent_alt = np.min(tangent_alts[centre_indices])

        print(hdf5_filename, "min alt=%0.1f" % min_tangent_alt,
              "binning=%i" % binning)

    ax.legend()
示例#2
0
        order_range_file[0] - SIMULATION_ADJACENT_ORDERS,
        order_range_file[1] + SIMULATION_ADJACENT_ORDERS
    ]
    c_order = int(np.mean(order_range))
    spec_res = spec_res_order(c_order)

    dim = detector_data_all.shape

    detector_centre_data = detector_data_all[:, [
        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)
示例#3
0
        diffraction_orders = hdf5_file["Channel/DiffractionOrder"][...]
        alts = hdf5_file["Geometry/Point0/TangentAltAreoid"][:, 0]

        indices = [
            i for i, x in enumerate(diffraction_orders)
            if x == search_diffraction_order
        ]

        if len(indices) == 0:  #if diff order not in file
            plt.close()
            continue

        x = hdf5_file["Science/X"][indices[0], :]

        colours = get_colours(len(indices))

        spectra = 0
        for i, index in enumerate(indices):
            y = hdf5_file["Science/Y"][index, :]
            if max(y) < y_limits[1] and min(y) > y_limits[0]:
                spectra += 1
                alt = alts[index]
                ax.plot(x,
                        y,
                        color=colours[i],
                        label="i=%i, alt=%0.1f" % (index, alt))
                if vertical_line_nu > 0.0:
                    ax.axvline(x=vertical_line_nu, color="k", linestyle="--")

        if spectra > 0:
示例#4
0
nu_grid = np.arange(4200., 4300., 0.01)

ice_profile = np.interp(nu_grid, ice_profile_raw[:, 0], ice_profile_raw[:, 1])

# ice_profile -= 0.7
ice_profile /= np.max(ice_profile)

flat_profile = np.ones_like(ice_profile)

central_order = 189
pixels = np.arange(320.0)
temperature = -10.0
n_orders = 1

colours = get_colours(n_orders * 2 + 1)

plt.figure(figsize=(15, 6))
plt.title("CO2 ice spectrum, applying blaze function and order addition")
plt.xlabel("Wavenumbers cm-1")
plt.ylabel("Normalised response")
aotf_grid = F_aotf_goddard19draft(central_order, nu_grid, temperature)
# plt.plot(nu_grid, aotf_grid)
# plt.plot(nu_grid, ice_profile)

pixel_response_ice = np.zeros(len(pixels))
pixel_response_flat = np.zeros(len(pixels))

nu_px_centre = nu_mp(central_order, pixels, temperature)

for order_index, diffraction_order in enumerate(
示例#5
0
alts = hdf5_file["Geometry/Point0/TangentAltAreoid"][:,0]

orders = hdf5_file["Channel/DiffractionOrder"][...]

a = np.where(orders == order)
b = np.where((60 < alts) & (alts < 73))
indices = np.intersect1d(a, b)


y = hdf5_file["Science/Y"][:,:]
x = hdf5_file["Science/X"][indices[0],:]

# plt.plot(y[indices, :].T, alpha=0.5)
fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1)
colours = get_colours(len(indices), cmap="plasma")
for i, index in enumerate(indices):
    if i>0:
        prev_index = indices[i-1]
        # plt.plot(y[index, :]/np.max(y[index, :]) - y[index-1, :]/np.max(y[index-1, :]), alpha=0.5, color=colours[i], label="%0.1f" %alts[index])
        # plt.plot(y[index, :] - y[index-1, :], alpha=0.5, color=colours[i], label="%0.1f" %alts[index])
        # plt.plot(y[index, :], alpha=0.5, color=colours[i], label="%0.1f" %alts[index])
        norm = (y[index, :]-y[index, pixel_low])/(y[index, pixel_high]-y[index, pixel_low])
        norm1 = (y[prev_index, :]-y[prev_index, pixel_low])/(y[prev_index, pixel_high]-y[prev_index, pixel_low])
    
        ax2.plot(x, norm-norm1, alpha=0.5, color=colours[i], label="%0.1f" %alts[index])
        ax1.plot(x, norm1, alpha=0.5, color=colours[i], label="%0.1f km" %alts[index])
     
ax1.legend(loc='center left', bbox_to_anchor=(1, 0))
# fig.colorbar(ax1)
chosen_hdf5_files = []
chosen_hdf5_filenames = []

for file_index, (hdf5_filename, hdf5_file) in enumerate(zip(hdf5_filenames, hdf5_files)):
    
    sza = np.mean(hdf5_file["Geometry/Point0/IncidenceAngle"][...], axis=1)
    
    valid_ys = np.where(sza < MAX_SZA)[0]
    if len(valid_ys) == 0:
        continue
    
    chosen_hdf5_files.append(hdf5_file)
    chosen_hdf5_filenames.append(hdf5_filename)


colours = get_colours(len(chosen_hdf5_filenames))


interpolation_pixels = np.arange(50.0, 300.0, 20.)
curvature_dict = {}
for interpolation_pixel in interpolation_pixels:
    curvature_dict[interpolation_pixel] = []


reference_temperature_peak = np.polyval(lno_curvature_dict[diffraction_order]["temperature_shift_coeffs"], reference_temperature)


variables = {"temperature":[], "peak":[], "peak_shifted":[], "shift":[], "colours":[]}

#loop through low SZA files
for file_index, (hdf5_filename, hdf5_file) in enumerate(zip(chosen_hdf5_filenames, chosen_hdf5_files)):
示例#7
0
        # redraw the full figure
        self.line.figure.canvas.draw()

    def disconnect(self):
        'disconnect all the stored connection ids'
        self.line.figure.canvas.mpl_disconnect(self.cidpress)
        self.line.figure.canvas.mpl_disconnect(self.cidrelease)
        self.line.figure.canvas.mpl_disconnect(self.cidmotion)



chosen_bins = [8,9,10,11,12]

pixels = np.arange(320)
    
colours = get_colours(42, cmap="plasma") #from -20C to +20C



order_data_dict = {}

for diffraction_order, order_dict in order_dicts.items():

    order_data_dict[diffraction_order] = {}


    order_data_dict[diffraction_order]["mean_gradient_all_bins"] = []
    order_data_dict[diffraction_order]["std_gradient_all_bins"] = []
    order_data_dict[diffraction_order]["n_gradients_all_bins"] = []

    
    print(hdf5_filename)

    channel = hdf5_filename.split("_")[3].lower()

    detector_data_all = hdf5_file["Science/Y"][...]
    window_top_all = hdf5_file["Channel/WindowTop"][...]
    binning = hdf5_file["Channel/Binning"][0] + 1

    dim = detector_data_all.shape
    n_rows_raw = dim[1]  #data rows
    n_rows_binned = dim[1] * binning  #pixel detector rows
    frame_indices = np.arange(dim[0])
    n_u = len(list(set(window_top_all)))  #number of unique window tops
    n_ff = int(np.floor(dim[0] / n_u))  #number of full frames

    colours = get_colours(dim[1])

    #if not window stepping
    row_no = np.arange(window_top_all[0], window_top_all[0] + n_rows_binned,
                       binning)

    y_mean = np.mean(detector_data_all[:, 12, 160:240], axis=1)

    aotf_freq = hdf5_file["Channel/AOTFFrequency"][...]
    if channel == "so":
        orders = [m_aotf_so(a) for a in aotf_freq]
    elif channel == "lno":
        orders = [m_aotf_lno(a) for a in aotf_freq]
    print("Starting Order=%i" % orders[0])

    minima = {}
# TEMPERATURE_GRID_TO_USE = "measurement_temperature"
TEMPERATURE_GRID_TO_USE = "calculated_temperature"
# TEMPERATURE_GRID_TO_USE = "mean_temperature"

# regex = re.compile("(20161121_233000|20180702_112352|20181101_213226|20190314_021825|20190609_011514|20191207_051654)_0p1a_LNO_1")
regex = re.compile(
    "(20161121_233000|20180702_112352|20181101_213226|20190314_021825|20190609_011514|20190921_222413|20191207_051654|20200105_132318|20200324_145739)_0p1a_LNO_1"
)
fileLevel = "hdf5_level_0p1a"
hdf5Files, hdf5Filenames, titles = make_filelist(regex, fileLevel)
"""plot solar lines in solar fullscan data for orders contains strong solar lines"""
temperature_range = np.arange(-20., 15., 0.1)
pixels = np.arange(320.0)

colours = get_colours(len(temperature_range), "plasma")

output_title = "LNO_Reflectance_Factor_Calibration_Table"
if MAKE_AUX_FILE:
    hdf5_file_out = h5py.File(
        os.path.join(paths["BASE_DIRECTORY"], output_title + ".h5"), "w")

#for diffraction_order in [116]:
for diffraction_order in ref_fact_orders_dict.keys():

    error = False

    ref_fact_order_dict = ref_fact_orders_dict[diffraction_order]

    # reference_dict = get_reference_dict(diffraction_order, ref_fact_order_dict)
    solar_molecular = ref_fact_order_dict["solar_molecular"]
示例#10
0
        pixel = int(pixel)
        linear_fit, coefficients = fit_polynomial(continuum[:, pixel],
                                                  deviation[:, pixel],
                                                  coeffs=True)
        fit_coefficients.append(coefficients)

    fit_coefficients = np.asfarray(fit_coefficients).T
    correction_dict[bin_index]["coefficients"] = fit_coefficients

save_dict_to_hdf5(correction_dict, "test2")

if 0 in plot_type:
    print(0)
    sys.exit()

colours = get_colours(len(pixels), cmap="viridis")
if 5 in plot_type:

    pixel = 69
    bin_index = 3

    plt.figure()
    plt.scatter(correction_dict[bin_index]["continuum"][:, pixel],
                correction_dict[bin_index]["deviation"][:, pixel],
                color=colours[pixel])
    plt.plot(np.arange(0.0, 1.0, 0.1),
             np.polyval(correction_dict[bin_index]["coefficients"][:, pixel],
                        np.arange(0.0, 1.0, 0.1)),
             color=colours[pixel])
    plt.xlabel("Continuum transmittance of pixel")
    plt.ylabel("Deviation from continuum")