I'm trying to run the code below, where Bwavelength, throughput and newflux are lists.
def ABconversion(Bwavelength, throughput):
ABconstant=[]
c=3e18
i=0
for i in range(0, len(Bwavelength)):
ABconstant.append(((3e18/((Bwavelength[i])**2))*throughput[i]))
i+=1
print len(Bwavelength), len(ABconstant), ABconstant
a=Bwavelength[0]
b=Bwavelength[-1]
h=((b-a)/len(Bwavelength))
ABflux = numpy.trapz(Bwavelength, ABconstant, h)
return ABflux
def ABmagnitude(newflux, ABflux):
ABmagarray=[]
for i in range(len(newflux)):
ABmag = -2.5*log10((newflux[i])/ABflux) - 48.6
ABmagarray.append(ABmag)
return ABmagarray
ABflux1 = ABconversion(Bwavelength, throughput)
print ABflux1
ABmagarray = ABmagnitude(z, ABflux1)
print epoch, ABmagarray
z is defined earlier in the file and is also a list.
However, when I run this I get the message:
Traceback (most recent call last):
File "Rewrite17.11.2014.py", line 196, in <module>
ABflux1 = ABconversion(Bwavelength, throughput)
File "Rewrite17.11.2014.py", line 186, in ABconversion
ABflux = numpy.trapz(Bwavelength, ABconstant, h)
File "C:\Python27\lib\site-packages\numpy\lib\function_base.py, line 3234, in trapz
ret = add.reduce(d * (y[slice1]+y[slice2]/2.0, axis)
ValueError: Operands could not be broadcast together with shapes (0,) (444,)
I don't quite understand the error (I'm fairly new to programming), but I think it means the two "shapes" don't have the same dimensions. I'm not sure why this is.
Thanks in advance.