Python Help Getting the Tonry model of Peculiar velocity field running in python

AI Thread Summary
The discussion revolves around translating a peculiar velocity flow model from Fortran to Python, specifically the model by Tonry et al. (1999). The user is encountering issues with their Python code, particularly an error message indicating 'return' is outside of a function, which stems from a misplaced return statement. Additionally, there is a problem with an undefined variable 'x' in a calculation involving velocity components. The user is seeking guidance on resolving these coding errors to successfully implement the model, emphasizing that the project is not primarily focused on computing but on getting the model operational.
daniel.corry
Messages
3
Reaction score
0
I am attempting to translate the model of peculiar velocity flow given by Tonry et al (1999) from fortran into python, the language we use on my course, however I am experiencing difficulties in getting the thing to run.


I have attached the original fortran (sbf2flow) and my attempt at translating it into python (tonrymodel).

Any pointers or corrections would be greatly appreciated as this is not a computing project although I am not able to proceed until I have got this model working properly
 

Attachments

Technology news on Phys.org
What difficulties are you having in getting your python code to run? Incorrect results? Error messages?
 
i am getting the message 'return' outside function and I have played around but can't seem to shift that message.
 
I'm fairly certain it's this line, down near the bottom:

return (vx,vy,vz,vr,vsig)

That line is not part of a function, so it makes no sense to try to return something.
 
so i got somewhere however now in line 123,
ivrw = int((vx*x + vy*y + vz*z) / math.sqrt(x*x+y*y+z*z))
it is telling me x is not defined, however I am sure it is defined above
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top