data_directory = 'TRANK_nk_fit/' from TRANK import functionize_nk_file, TMM_spectra, error_plot, reducible_rms_error_spectrum, rms_error_spectrum if __name__=='__main__': from numpy import loadtxt, array, arange, square, mean, sqrt lamda_fine = loadtxt(data_directory+'fit_nk_fine.txt', usecols = [0], unpack = True) lamda_list = loadtxt(data_directory+'fit_nk.txt', usecols = [0], unpack = True) fit_nk_f = functionize_nk_file(data_directory+'fit_nk.txt', skiprows = 0, kind = 'linear') #lamda_fine = arange(lamda_list.min(), lamda_list.max(), 100) spectra_from_fit = TMM_spectra(lamda_list = lamda_fine, nk_f = fit_nk_f, parameter_list_generator = parameter_list_generator) #spectra_from_fit[lamda][ param spectrum] # computational reasons why this is ordered is this way #now i need to build independent lamda lists and their spectra list_of_lamda_lists = [] list_of_fit_spectra = [] for spectrum_function in spectrum_function_list: # create the sub lists for these to all go into list_of_lamda_lists.append( []) list_of_fit_spectra.append( []) for lamda_index in range(len(lamda_fine )): lamda = lamda_fine[lamda_index] param_index = 0 for spectrum_index in range(len(spectrum_function_list)): if spectrum_function_list[spectrum_index].is_in_bounds(lamda):
make_plots = True tmm_spectra_dir = 'tmm_predicted_spectra/' noise = 2.0 / 100.0 dlamda_min = 1 lamda_min = 300 lamda_max = 1200 lamda_list = arange(lamda_min, lamda_max + dlamda_min / 2.0, dlamda_min) # this little monster calculates the spectra in parallel spectra = array( TMM_spectra( lamda_list=lamda_list, nk_f=nk_f_list[ layer_index_of_fit], # we may have buit our parameter_list_generator to have our layer of interest in it, but these functions are all built around analyze variations of our layer nk parameter_list_generator=parameter_list_generator)) #####spectra[lamda index][ T/R/A spectrum index] for reference! ## for adding noise from numpy.random import rand ### for plotting if make_plots: from matplotlib.pyplot import figure, plot, minorticks_on, show, xlabel, ylabel, close from matplotlib.pyplot import gca, subplots_adjust, legend, savefig, title, tight_layout ### for saving data try_mkdir(tmm_spectra_dir)