New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 9325 for branches/2017/dev_merge_2017/NEMOGCM/TOOLS/MISCELLANEOUS/icb_pp.py – NEMO

Ignore:
Timestamp:
2018-02-13T17:28:22+01:00 (6 years ago)
Author:
davestorkey
Message:

Small fix to TOOLS/MISCELLANEOUS/icb_pp.py. Ticket #2008.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2017/dev_merge_2017/NEMOGCM/TOOLS/MISCELLANEOUS/icb_pp.py

    r8509 r9325  
    9292# Now flatten the lists and reduce to the unique spanning set 
    9393# 
    94 icu = np.concatenate(icu) 
     94try: 
     95    icu = np.concatenate(icu) 
     96except ValueError: 
     97    # No icebergs: create an empty output file. 
     98    print 'No icebergs in the model.' 
     99    fw = Dataset(pathstart+'0000.nc') 
     100    fo = Dataset(pathout, 'w', format='NETCDF4_CLASSIC') 
     101    ntrj = fo.createDimension('ntraj', None) 
     102    icbn = fo.createVariable('iceberg_number', 'i4',('ntraj')) 
     103    n = 0 
     104    for key, value in varlist.iteritems() : 
     105        if key != "iceberg_number" : 
     106            print 'key is ',key 
     107            oout = fo.createVariable(key, value.dtype, ('ntraj'), 
     108                                 zlib=True, complevel=1) 
     109            oout.long_name = fw.variables[key].getncattr('long_name') 
     110            oout.units = fw.variables[key].getncattr('units') 
     111            n = n + 1 
     112    fw.close() 
     113    fo.close()     
     114    sys.exit() 
     115 
    95116icu = np.unique(icu) 
    96117times = np.concatenate(times) 
Note: See TracChangeset for help on using the changeset viewer.