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

Click For Summary

Discussion Overview

The discussion revolves around translating the Tonry model of peculiar velocity flow from Fortran to Python. Participants are addressing specific coding issues encountered during the translation process, focusing on error messages and debugging challenges.

Discussion Character

  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant is attempting to translate the Tonry model from Fortran to Python and is seeking assistance with coding issues.
  • Another participant inquires about the specific difficulties faced, asking if the issues are related to incorrect results or error messages.
  • A participant identifies an error related to a 'return' statement that is outside of a function, suggesting that it is not valid in its current context.
  • Another participant reports a new error indicating that a variable 'x' is not defined, despite being defined earlier in the code.

Areas of Agreement / Disagreement

The discussion remains unresolved, with participants sharing individual coding challenges without reaching a consensus on solutions.

Contextual Notes

Participants have not provided details on the definitions of variables or the overall structure of the code, which may contribute to the confusion regarding variable scope and function definitions.

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
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
15
Views
11K
  • · Replies 1 ·
Replies
1
Views
4K