Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: convertHYCOM.py

convertHYCOM.py 5 years 5 months ago #33629

  • sanaz
  • sanaz's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 69
  • Thank you received: 1
Hello,
i tried to download HYCOM data using convertHYCOM.py. It gave me an error that I posted in another post.
I tried also to use the help function for the convertHYCOM.py. It seems there is kind of problem. Not sure if it is related to the scripts or python. I would appreciate if you could run this in your computer to see if it is working or not. We tried on different computers and it is giving the same error. Please see the attached file.

C:\opentelemac-mascaret\v8p0r2\scripts\python27\converters\convertHYCOM.py -h

Thanks.
Attachments:
The administrator has disabled public write access.

convertHYCOM.py 5 years 5 months ago #33632

  • cyamin
  • cyamin's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 997
  • Thank you received: 234
Hello,
This is definitely python related. I had the same error some time ago when I was migrating from python27 scripts to python3 and kept two python installations (2.7 & 3.7). This error was occurring when I was using one python version without properly registering it with the system, so both installations got mixed up. Proper installation depends on the python distribution. I am using WinPython.
Best Regards,
Costas
The administrator has disabled public write access.
The following user(s) said Thank You: sanaz, Cyangou

convertHYCOM.py 4 years 9 months ago #35289

  • Cyangou
  • Cyangou's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 73
  • Thank you received: 2
Hello, Costas
i got the same problem, In order to solve the above problem, I have to exchange the old version of python2.7.5 to use Python3 may better match the statement in convertHYCOM.py.right?

so i downloaded the new python3, but i don't know how to "connect" with my telemac v8p0r2, thats you said you migrating from python27 scripts to python3. Should I re-compile telemac with python3?

and when i migrated it properly and got 2 version, how i can properly register python3 with system to avoid the problem?i am using winPython too, thanks a lot in advance.

All regards
Yang
The administrator has disabled public write access.

convertHYCOM.py 4 years 9 months ago #35290

  • cyamin
  • cyamin's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 997
  • Thank you received: 234
Hello Yang,
No need to recompile telemac with the python3 scripts, but it is a good sign of proper installation if it does.
The steps to migrate from python2 to python 3 are:
  1. At the Winpython 3 installation folder, open/execute WinPython Control Panel go to Advanced tab ->Register distribution.
  2. Change path environmental variable to point to '[your path]\v8p0r2\scripts\python3' folder of the telemac installation. If there exists an entry for the WinPython 2 installation folder, change that to point to WinPython3
Best Regards,
Costas
The administrator has disabled public write access.
The following user(s) said Thank You: Cyangou

convertHYCOM.py 4 years 9 months ago #35293

  • Cyangou
  • Cyangou's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 73
  • Thank you received: 2
Hi Costas thanks to your reply.
i have done the process to migrate from python2 to python 3, its working in telemac

and i tried convertHYCOM.py example again, got the same problem
C:\opentelemac-mascaret\v8p0r2\scripts\python27\converters> convertHYCOM.py --from 2013-08-01 --stop 2013-11-21 --bl 20,-119 --tr 29,-108 -r hycom-2m.slf
Traceback (most recent call last):
File "C:\opentelemac-mascaret\v8p0r2\scripts\python27\converters\convertHYCOM.py", line 41, in <module>
from pydap.client import open_url
File "C:\opentelemac-mascaret\python27\lib\site-packages\pydap-3.2.2-py2.7.egg\pydap\client.py", line 48, in <module>
from six.moves.urllib.parse import urlsplit, urlunsplit
ImportError: No module named urllib.parse

should i use convert_hycom.py in floder python3? sorry i am a beginner trying to use Hycom data in my model.could you give me some suggestions, thanks a lot in advance

All regards
Yang
The administrator has disabled public write access.

convertHYCOM.py 4 years 9 months ago #35294

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3722
  • Thank you received: 1031
Hi yang

Even you're a beginner, you should be logical in the way you work with telemac.
You decided to move to Python3 so you cannot use the old scripts designed for python2!
You should only use python3 scripts and forget the python2

regards
Christophe
The administrator has disabled public write access.
The following user(s) said Thank You: Cyangou

convertHYCOM.py 4 years 9 months ago #35295

  • Cyangou
  • Cyangou's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 73
  • Thank you received: 2
Hi,so embarrassing, but thanks to reply.

I was just prompted to install some modules, after the installation of some modules are completed. I run the script again and ...no nothing happens

whats wrong with it?
Attachments:
The administrator has disabled public write access.

convertHYCOM.py 4 years 9 months ago #35314

  • Cyangou
  • Cyangou's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 73
  • Thank you received: 2
I solved my problem with the script convert_hycom.py in python3
I did the following steps to make it run successfully

1. I wrote the main function in the script
tfrom = 'xxx'
tstop = 'xxx'
blcorner = 'xxx'
trcorner = 'xxx'
root_name = 'xxx'
only_2d = 'no ‘
hycom2srf (tfrom, tstop, blcorner, trcorner, root_name, only_2d)

2. After running I got an error on line 234
self.slf3d.meshx = np.tile (x, ny1d) .reshape (ny1d, nx1d) .itime.ravel ()
itime.ravel () error
I replaced itime.ravel () with T.ravel () Referenced by the statement in python27
Then it runs successfully.

If you have the same problems with this script in python3, you can follow my solution steps, but dont forget install the module first.

all regards
Yang
The administrator has disabled public write access.

convertHYCOM.py 4 years 8 months ago #35587

  • thomas.le
  • thomas.le's Avatar
Hi,

I thank you very much Yang for the solution you gave, I had the same error and it worked for me. But now when run convert_hycom.py I have a new error:

from formats.selafin import Selafin
ModuleNotFoundError: No module named 'formats'

I understand that I don't have the "formats" module, does someone knows where to find it? :huh:

I am running on python 3.7 on spyder. And I used Yang's code (attached here)adaped to python 3 with this command line: "python convert_hycom.py --from 2018-11-01 --stop 2018-11-27 --bl 39,-1 --tr 42,2 -r hycom_bahia_big.slf"

I hope someone will anwser me,
Kind regards,
Thomas
Attachments:
The administrator has disabled public write access.

convertHYCOM.py 4 years 8 months ago #35596

  • Cyangou
  • Cyangou's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 73
  • Thank you received: 2
Update my using script experience, 2 parts of modify
1.only_2d=False
2.also have to modify the line 375 (itime-T)
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: borisb

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.