Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Nov 6, 2011 #1
    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

    Attached Files:

  2. jcsd
  3. Nov 6, 2011 #2


    Staff: Mentor

    What difficulties are you having in getting your python code to run? Incorrect results? Error messages?
  4. Nov 6, 2011 #3
    i am getting the message 'return' outside function and I have played around but cant seem to shift that message.
  5. Nov 6, 2011 #4


    Staff: Mentor

    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.
  6. Nov 6, 2011 #5
    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 im sure it is defined above
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook