I'm new for python, I try to create class that put 3 values (channel, mDM, crossec)
to gennerated data from .dat to be like (x, y) value for make chi-square fit. Now I try to print to see data but it doesn't show
my class code file name DMM.py. I try this
from DMM import cal
channel = str(input("Enter channel "))
mDM = int(input("Enter mDM "))
crossec = int(input("Enter crossecn "))
y = cal(channel, mDM, crossec)
print(y)
and it print out
Enter channel t
Enter mDM 150
Enter crossec 1
<DMM.cal object at 0x00FAEBD0>
I try to read from the internet but still not understand
fnames = 'AtProductionNoEW_gammas.dat'
data = np.genfromtxt(fnames, names=True, dtype=None)
mass_vals = data["mDM"]
class cal():
def __init__(self, channel, mDM, crossec):
self.channel = channel
self.mDM = mDM
self.crossec = crossec
index = np.where(np.abs(mass_vals - self.mDM)/mass_vals < 0.0001)
xvals = data["Log10x"][index]
fluxs = data[self.channel][index]/xvals
loadspec = interp1d(xvals, fluxs)
def dNdx(x):
fluxval = loadspec(x)
if (fluxval<0):
return 0
else:
return loadspec(x)*/(8*pi*self.mDM**2)*self.crossec
I want output be like
1, 2
2, 5
7, 8
9, 15
11, 25
...