Example #1
0
vv.time = 'ocean_time'
vv[:] = u
#
vv = ds2.createVariable('v', float, ('ocean_time', 'eta_rho', 'xi_rho'))
vv.long_name = 'northward near-surface velocity'
vv.units = 'meter second-1'
vv.time = 'ocean_time'
vv[:] = v

ds1.close()
ds2.close()

#%% prepare for finale
import collections
result_dict = collections.OrderedDict()
time_format = '%Y.%m.%d %H:%M:%S'
result_dict['start_time'] = start_time.strftime(time_format)
end_time = datetime.now()
result_dict['end_time'] = end_time.strftime(time_format)
dt_sec = (end_time - start_time).seconds
result_dict['total_seconds'] = str(dt_sec)
if os.path.isfile(out_fn):
    result_dict['result'] = 'success'
else:
    result_dict['result'] = 'fail'

#%% ************** END CASE-SPECIFIC CODE *****************

ffun.finale(result_dict, Ldir, Lfun)

import collections
result_dict = collections.OrderedDict()
time_format = '%Y.%m.%d %H:%M:%S'
result_dict['start_time'] = start_time.strftime(time_format)
end_time = datetime.now()
result_dict['end_time'] = end_time.strftime(time_format)
dt_sec = (end_time - start_time).seconds
result_dict['total_seconds'] = str(dt_sec)

result_dict['result'] = 'success'
get_time = True
for vn in outvar_list:
    fn = nc_out_dict[vn]
    if os.path.isfile(fn):
        if get_time == True:
            ds = nc.Dataset(fn)
            mt0 = ds[afun.timename_dict[vn]][0]
            mt1 = ds[afun.timename_dict[vn]][-1]
            ds.close()
            dt0 = Lfun.modtime_to_datetime(float(mt0))
            dt1 = Lfun.modtime_to_datetime(float(mt1))
            result_dict['var_start_time'] = dt0.strftime(time_format)
            result_dict['var_end_time'] = dt1.strftime(time_format)
        get_time == False
    else:
        result_dict['result'] = 'fail'

#%% ************** END CASE-SPECIFIC CODE *****************

ffun.finale(result_dict, Ldir, Lfun)