Changeset 600 in lmdz_wrf
- Timestamp:
- Jul 15, 2015, 11:11:44 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diagnostics.py
r449 r600 981 981 982 982 # Transforming to a flux 983 if depvars[2] != 'WRFtime': 984 dtimeunits = var2.getncattr('units') 985 tunits = dtimeunits.split(' ')[0] 986 987 dtime = (var2[1] - var2[0])*timeunits_seconds(tunits) 983 if var2.shape[0] > 0: 984 if depvars[2] != 'WRFtime': 985 dtimeunits = var2.getncattr('units') 986 tunits = dtimeunits.split(' ')[0] 987 988 dtime = (var2[1] - var2[0])*timeunits_seconds(tunits) 989 else: 990 var2 = ncobj.variables['Times'] 991 time1 = var2[0,:] 992 time2 = var2[1,:] 993 tmf1 = '' 994 tmf2 = '' 995 for ic in range(len(time1)): 996 tmf1 = tmf1 + time1[ic] 997 tmf2 = tmf2 + time2[ic] 998 dtdate1 = dt.datetime.strptime(tmf1,"%Y-%m-%d_%H:%M:%S") 999 dtdate2 = dt.datetime.strptime(tmf2,"%Y-%m-%d_%H:%M:%S") 1000 diffdate12 = dtdate2 - dtdate1 1001 dtime = diffdate12.total_seconds() 1002 print 'dtime:',dtime 988 1003 else: 989 var2 = ncobj.variables['Times'] 990 time1 = var2[0,:] 991 time2 = var2[1,:] 992 tmf1 = '' 993 tmf2 = '' 994 for ic in range(len(time1)): 995 tmf1 = tmf1 + time1[ic] 996 tmf2 = tmf2 + time2[ic] 997 dtdate1 = dt.datetime.strptime(tmf1,"%Y-%m-%d_%H:%M:%S") 998 dtdate2 = dt.datetime.strptime(tmf2,"%Y-%m-%d_%H:%M:%S") 999 diffdate12 = dtdate2 - dtdate1 1000 dtime = diffdate12.total_seconds() 1001 print 'dtime:',dtime 1004 print warnmsg 1005 print ' ' + fname + ": only 1 time-step for '" + diag + "' !!" 1006 print ' leaving a zero value!' 1007 diagout = var0*0. 1008 dtime=1. 1002 1009 1003 1010 ncvar.insert_variable(ncobj, 'pr', diagout/dtime, diagoutd, diagoutvd, newnc)
Note: See TracChangeset
for help on using the changeset viewer.