- #1
BiGyElLoWhAt
Gold Member
- 1,622
- 131
Homework Statement
Somewhat irrelevant, but we need to simulate the redshift for a star system. Pretty open ended. Single star, binary, whatever.
The problem is this:
TypeError: <lambda>() takes at most 1 argument (5 given)
And upon searching, most people who get this error have a function that they're using named lambda and it takes some number of arguments and they input the wrong ones such as here:
http://stackoverflow.com/questions/31447844/typeerror-lambda-takes-exactly-1-argument-3-given
That's not the case with mine.
Homework Equations
Quite a few
Code:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 14 20:49:29 2016
@author: Tyler
"""
from __future__ import division
from math import sin, cos, sqrt, pi
step = float(input("Enter the step size in seconds: "))
G = 6.674*10**(-11)
c = 3*10**8
def Move_Stars(r, theta):
x= r*cos(theta + step)
y = r*sin(theta + step)
return x,y
Mass1 = int(input("Enter the mass of object 1 in Kg: "))
Mass2 = int(input("Enter the mass of object 2 in Kg: "))
x_obs = float(input("Enter the x coordinate of the observer in m: "))
y_obs = float(input("Enter the y coordinate of the observer in m: "))
distance = float(input("Enter the distance between the two stars: "))
CoM1 = distance/(1+Mass1/Mass2) (Comment pound-pound) Distance to center of mass of system
CoM2 = distance/(1+Mass2/Mass1) (Comment pound-pound) Distance to center of mass of system
speed1 = sqrt(G*Mass2/CoM1)
speed2 = sqrt(G*Mass1/CoM2)
XS1 = CoM1
XS2 = -CoM2
YS1, YS2 = 0.0, 0.0
input("The speed and orbital radius of Object 1 are ", speed1, " and ", CoM1 , " respectively. Input any key to continue. ")
input("The speed and orbital radius of Object 2 are ", speed2, " and ", CoM2 , " respectively. Input any key to continue. ")
timeLapse = float(input("Enter the time you would like to watch over in seconds: "))
time = 0
omega = speed1/CoM1
theta1 = 0
theta2 = pi
z=0
Rs1 = 2*G*Mass1/(c**2)
while time < timeLapse:
XS1, YS1 = Move_Stars(CoM1, theta1)
XS2, YS2 = Move_Stars(CoM2, theta2)
theta1 += omega*step
theta2 += omega*step
print("Position 1 = (",XS1, ",",YS1, ")")
print("Position 1 = (",XS2, ",",YS2, ")")
time += step
Sorry for the lack of comments.
It works fine up until this:
Python:
Enter the distance between the two stars: 100000
Traceback (most recent call last):
File "<ipython-input-2-713c37472433>", line 1, in <module>
runfile('C:/Python27/Lib/site-packages/xy/Compu2Modern.py', wdir='C:/Python27/Lib/site-packages/xy')
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Python27/Lib/site-packages/xy/Compu2Modern.py", line 31, in <module>
input("The speed and orbital radius of Object 1 are ", speed1, " and ", CoM1 , " respectively. Input any key to continue. ")
TypeError: <lambda>() takes at most 1 argument (5 given)
The Attempt at a Solution
So where is it getting this lambda thing from?
To me, it looks like it's error-ing on line 31, which is nothing. Just an arbitrary input, not assigned to any variable, to give the user time to read some info before it starts running the loop.