-
Notifications
You must be signed in to change notification settings - Fork 5
pycnal_toolbox ocean_in
Kate Hedstrom edited this page Nov 13, 2016
·
2 revisions
This is a tool for dealing with the the ROMS ocean.in file using Python. You create a Python dictionary with the constructor:
from pycnal_toolbox import ocean_in
ocean_1 = ocean_in("ocean_foo.in")
ocean_1 now contains a Python dictionary:
print(ocean_1.var_dict['Lm'])
['688']
You can not only query the values but change them too:
print(ocean_1.var_dict['NPT'])
['6']
ocean_1.var_dict['NPT'] = ['8']
print(ocean_1.var_dict['NPT'])
['8']
'Lm' and 'NPT' have to be lists to handle ocean.in files for multiple grids.
Once you've modified the file, you can write it back out, either as an ocean.in file or as a json file (should you need such a thing):
ocean_1.write_ocean_in('ocean_foo.in')
ocean_1.write_json_dict('ocean_foo.jsn')
Best of all, for nested grid applications, you can generate a two-grid file very easily:
ocean_1.merge_dicts([ocean_1])
ocean_1.write_ocean_in('ocean_twogrids.in')
print(ocean_1.var_dict['Ngrids'])
['2']