import numpy as np def remnant(energyvalues, mixingvalues, energy, mixing, rem, count): # count 2 is for iterating through the different elements, count is for each star """ This program linearly interpolates the remnant masses to grab the correct one for a given energy and mixing value """ 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] remnantmass = rem[enindex][mixindex][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