import numpy as np def element(energyvalues, mixingvalues, energy, mixing, data, count, count2): # count 2 is for iterating through the different elements, count is for each star # this section is for checking is the energy or mixing values are outside our range """ This module interpolates to grab the correct isotope yields for the given energy and mixing values """ if energy > energyvalues[-1]: energy = energyvalues[-1] elif energy < energyvalues[0]: energy = energyvalues[0] elif mixing > mixingvalues[-1]: mixing = mixingvalues[-1] elif mixing < mixingvalues[0]: mixing = mixingvalues[0] # checks if the enegry or mixing values is exact enlogical = np.isclose(energyvalues, energy) mixlogical = np.isclose(mixingvalues, mixing) if enlogical.any() and mixlogical.any(): # both exact, no interpolation enindex = np.where(enlogical)[0][0] mixindex = np.where(mixlogical)[0][0] element = data[enindex][mixindex][count2][count] elif mixlogical.any(): # just mixing is exact, use energy difference for scaling mixindex = np.where(mixlogical)[0][0] enupper = np.where(energyvalues>energy)[0][0] enlower = np.where(energyvaluesmixing)[0][0] mixlower = np.where(mixingvaluesmixing)[0][0] mixlower = np.where(mixingvaluesenergy)[0][0] enlower = np.where(energyvalues