- Timestamp:
- Feb 26, 2015, 1:02:09 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r314 r315 2619 2619 self.lastTm: last time value as matrix (from datetime; [Y], [M], [D], [H], [M], [S]) 2620 2620 """ 2621 2622 import datetime as dt2623 2624 2621 def __init__(self, ncfu, tname): 2622 import datetime as dt 2623 fname = 'cls_time_information' 2625 2624 2626 2625 if ncfu is None: … … 2648 2647 if not searchInlist(attvar, 'units'): 2649 2648 print warnmsg 2650 print ' cls_time_information: time variable "' + tname +\2649 print ' ' + fname + ': time variable "' + tname + \ 2651 2650 '" does not have attribute: "units"' 2652 2651 units = None … … 2668 2667 self.lastTS = None 2669 2668 self.lastTm = None 2669 elif len(times.shape) == 2: 2670 if times.dimensions[1] == 'DateStrLen' and times.shape[1] == 19: 2671 print warnmsg 2672 print ' ' + fname + ": WRF 'Times' variable !!" 2673 self.unitsval = 'seconds since 1949-12-01 00:00:00' 2674 self.units = 'seconds' 2675 self.calendar = 'standard' 2676 self.Urefdate = '1949-12-01 00:00:00' 2677 self.Srefdate = '19491201000000' 2678 self.refdate = datetimeStr_datetime('1949-12-01_00:00:00') 2679 self.dimt = times.shape[0] 2680 self.firstTS = datetimeStr_conversion(times[0,:], \ 2681 'WRFdatetime', 'YmdHMS') 2682 self.firstTm = datetimeStr_conversion(times[0,:], \ 2683 'WRFdatetime', 'YmdHMS') 2684 self.lastTS = datetimeStr_conversion(times[self.dimt-1,:], \ 2685 'WRFdatetime', 'YmdHMS') 2686 self.lastTm = datetimeStr_conversion(times[self.dimt-1,:], \ 2687 'WRFdatetime', 'matYmdHMS') 2688 2689 secondTS = datetimeStr_conversion(times[1,:], 'WRFdatetime', \ 2690 'YmdHMS') 2691 secondTt = dt.datetime.strptime(secondTS, '%Y%m%d%H%M%S') 2692 self.firstTt = dt.datetime.strptime(self.firstTS, \ 2693 '%Y%m%d%H%M%S') 2694 self.lastTu = None 2695 self.lastTt = dt.datetime.strptime(self.lastTS, \ 2696 '%Y%m%d%H%M%S') 2697 2698 difft = self.firstTt - secondTt 2699 self.dt = difft.days/(3600.*24.) + difft.seconds + \ 2700 difft.microseconds/10.e6 2701 2702 difft = self.firstTt - self.refdate 2703 self.firstTu = difft.days/(3600.*24.) + difft.seconds + \ 2704 difft.microseconds/10.e6 2705 difft = self.lastTt - self.refdate 2706 self.lastTu = difft.days/(3600.*24.) + difft.seconds + \ 2707 difft.microseconds/10.e6 2708 2670 2709 else: 2671 2710 self.dimt = None … … 13531 13570 newvar = onc.variables[vn + 'de'] 13532 13571 13533 newvar[:] = deaccum 13572 if timeinf.dt is not None: 13573 newvar[:] = deaccum / timeinf.dt 13574 else: 13575 newvar[:] = deaccum 13534 13576 13535 13577 newattr = set_attribute(newvar, 'deaccumulated', 'True') 13536 13578 if timeinf.dt is not None: 13537 print timeinf.dt13538 13579 newattr = set_attributek(newvar, 'time_step_diff', timeinf.dt, \ 13539 13580 'npfloat') 13581 newattr = set_attribute(newvar, 'values', 'divided by time_step_diff') 13540 13582 13541 13583 for attrn in varinf.attributes:
Note: See TracChangeset
for help on using the changeset viewer.