def transform_data(spec_list, z):
    dict = {}
    for spec in spec_list:
        flux_array = []
        wavelength_array = []
        sigma_array = []
        data = spec[1].data
        for j in range(data.shape[0]):
            flux_data = data[j][0]
            flux_array.append(flux_data)
            wavelengths_uncorrected = (10 ** data[j][1])
            wavelengths_corrected = redshift_correct(z, wavelengths_uncorrected)
            wavelength_array.append(wavelengths_corrected)
            inverse_variance = data[j][2]
            one_over_sigma = (inverse_variance ** 0.5)
            sigma = (1 / one_over_sigma)
            sigma_array.append(sigma)
    smoothedFlux = convolve(flux_array, Box1DKernel(9))
    if ('flux' in dict):
        dict['flux'].append([smoothedFlux])
    else:
        dict['flux'] = [smoothedFlux]
    if ('wavelength' in dict):
        dict['wavelength'].append([wavelength_array])
    else:
        dict['wavelength'] = [wavelength_array]
    if ('1sigma' in dict):
        dict['1sigma'].append([sigma_array])
    else:
        dict['1sigma'] = [sigma_array]
    return dict
def transform_data(spec_list, z):
    dict = {}
    for spec in spec_list:
        flux_array = []
        wavelength_array = []
        sigma_array = []
        data = spec[1].data
        for j in range(data.shape[0]):
            flux_data = data[j][0]
            flux_array.append(flux_data)
            wavelengths_uncorrected = (10 ** data[j][1])
            wavelengths_corrected = redshift_correct(z, wavelengths_uncorrected)
            wavelength_array.append(wavelengths_corrected)
            inverse_variance = data[j][2]
            one_over_sigma = (inverse_variance ** 0.5)
            sigma = (1 / one_over_sigma)
            sigma_array.append(sigma)
    smoothedFlux = convolve(flux_array, Box1DKernel(9))
    if ('flux' in dict):
        dict['flux'].append([smoothedFlux])
    else:
        dict['flux'] = [smoothedFlux]
    if ('wavelength' in dict):
        dict['wavelength'].append([wavelength_array])
    else:
        dict['wavelength'] = [wavelength_array]
    if ('1sigma' in dict):
        dict['1sigma'].append([sigma_array])
    else:
        dict['1sigma'] = [sigma_array]
    return dict