Ocean Modeling Discussion

ROMS/TOMS

Search for:
It is currently Sun Jul 21, 2019 8:58 am




Post new topic Reply to topic  [ 8 posts ] 

All times are UTC

Author Message
PostPosted: Thu May 18, 2017 8:45 am 
Offline

Joined: Wed Apr 26, 2017 5:23 pm
Posts: 15
Location: Sun Yat-sen University
I will appreciate it if anyone can give me some advice.
Before creating boundary files(by pycnal), I used the make_remap_weights_file.py, and the hycom grid was made by the get_hycom_GLBa0.08_Palau_grid.py. I just changed the domain.
when I run "python3 make_remap_weights_file.py", the error message is:

Quote:
Traceback (most recent call last):
File "make_remap_weights_file.py", line 7, in <module>
srcgrd = pycnal_toolbox.Grid_HYCOM.get_nc_Grid_HYCOM('./HYCOM_GLBa0.08_PALAU_grid.nc')
File "/usr/local/pycnal/lib/python3.5/site-packages/pycnal_toolbox/Grid_HYCOM/get_nc_Grid_HYCOM.py", line 47, in get_nc_Grid_HYCOM
h[j,i] = depth_bnds[bottom[j,i]+1]
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

I think there must be something wrong with the hycom grid, any suggestions?
Thanks in advance.
Vera


Top
 Profile  
Reply with quote  
PostPosted: Thu May 18, 2017 5:14 pm 
Offline
User avatar

Joined: Wed Jul 02, 2003 5:29 pm
Posts: 3633
Location: IMS/UAF, USA
Quote:
I think there must be something wrong with the hycom grid, any suggestions?
No, the problem is not with the HYCOM grid. The problem is that Python is getting picky as it matures. This:
Code:
h[j,i] = depth_bnds[bottom[j,i]+1]
needs to be:
Code:
h[j,i] = depth_bnds[int(bottom[j,i])+1]


I need to collect my current code and push the updates.


Top
 Profile  
Reply with quote  
PostPosted: Fri May 19, 2017 2:06 am 
Offline

Joined: Wed Apr 26, 2017 5:23 pm
Posts: 15
Location: Sun Yat-sen University
That's very nice of you. Thank you, Kate!
I'm sorry that I didn't know python much.


Top
 Profile  
Reply with quote  
PostPosted: Tue May 23, 2017 1:02 pm 
Offline

Joined: Wed Apr 26, 2017 5:23 pm
Posts: 15
Location: Sun Yat-sen University
I met anyother strange problem again, please help me.
After I run make_bry_file.py, it will list all the hycom data I get,and give the following message:
Code:
Load geographical grid from file
b'/home/le/PyCNAL-master/examples/Nanhai/data/HYCOM_GLBa0.08_salt_2015_001.nc'

Creating boundary file /home/le/PyCNAL-master/examples/Nanhai/bdry/HYCOM_GLBa0.08_salt_2015_001_ssh_bdry_Nanhai.nc
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/lib/python3.5/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/usr/lib/python3.5/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "make_bdry_file.py", line 26, in do_file
    zeta = remap_bdry(file, 'ssh', src_grd, dst_grd, dst_dir=dst_dir)
  File "/home/le/PyCNAL-master/examples/Nanhai/remap_bdry.py", line 40, in remap_bdry
    src_var = cdf.variables[src_varname]
KeyError: 'ssh'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "make_bdry_file.py", line 83, in <module>
    results = p.map(partial_do_file, lst_file)
  File "/usr/lib/python3.5/multiprocessing/pool.py", line 260, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/usr/lib/python3.5/multiprocessing/pool.py", line 608, in get
    raise self._value
KeyError: 'ssh'

The first thing I'm comfused is, why the file is not a grid file after the sentence "Load geographical grid from file"? should I change this and how to change? I have no clue.
The second, which file is the target file of the function "do_file" in make_bry_file.py? I can't understand python well, sorry.
The last, how to solve my problem.
Thank you very much


Top
 Profile  
Reply with quote  
PostPosted: Tue May 23, 2017 4:54 pm 
Offline
User avatar

Joined: Wed Jul 02, 2003 5:29 pm
Posts: 3633
Location: IMS/UAF, USA
Sorry, I've been playing with multiprocessing to use more than one core at a time. These are much, much easier to debug without that. Some of the examples have both the straightforward version of things as well as the multiprocessing version. See if you can find one of those to work from.


Top
 Profile  
Reply with quote  
PostPosted: Wed May 24, 2017 4:03 am 
Offline

Joined: Wed Apr 26, 2017 5:23 pm
Posts: 15
Location: Sun Yat-sen University
Thank you for your reply, Kate!
I set processes = 1, but it is still the same problem.
I find the straight version in Yellow_sea example, and imitate it(still using Hycom data).The error messeage is:
Quote:
Load geographical grid from file
b'/home/le/PyCNAL-master/examples/Nanhai/data/HYCOM_GLBa0.08_salt_2015_001.nc'

Creating boundary file /home/le/PyCNAL-master/examples/Nanhai/bdry/HYCOM_GLBa0.08_salt_2015_001_ssh_bdry_Nanhai.nc
Traceback (most recent call last):
File "make_bry.py", line 46, in <module>
zeta = remap_bdry(file, 'ssh', src_grd, dst_grd, dst_dir=dst_dir)
File "/home/le/PyCNAL-master/examples/Nanhai/remap_bdry.py", line 40, in remap_bdry
src_var = cdf.variables[src_varname]
KeyError: 'ssh'

So I think the problem maybe isn't relative to Multi-process。


Top
 Profile  
Reply with quote  
PostPosted: Wed May 24, 2017 4:53 am 
Offline
User avatar

Joined: Wed Jul 02, 2003 5:29 pm
Posts: 3633
Location: IMS/UAF, USA
It's looking for 'ssh' in the HYCOM file. What variables are in your HYCOM file? Do you know how to read the traceback? Both agree that line 40 of remap_bdry.py is in trouble. So you look at that line and figure out if it should be succeeding, or why it isn't.


Top
 Profile  
Reply with quote  
PostPosted: Wed May 24, 2017 9:33 am 
Offline

Joined: Wed Apr 26, 2017 5:23 pm
Posts: 15
Location: Sun Yat-sen University
I have solved it, thank you.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group