climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1562273 - /incubator/climate/trunk/ocw/utils.py
Date Tue, 28 Jan 2014 22:20:01 GMT
Author: joyce
Date: Tue Jan 28 22:20:01 2014
New Revision: 1562273

URL: http://svn.apache.org/r1562273
Log:
CLIMATE-328 - Update decode_time_values and parse_time_units documentation

Modified:
    incubator/climate/trunk/ocw/utils.py

Modified: incubator/climate/trunk/ocw/utils.py
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/ocw/utils.py?rev=1562273&r1=1562272&r2=1562273&view=diff
==============================================================================
--- incubator/climate/trunk/ocw/utils.py (original)
+++ incubator/climate/trunk/ocw/utils.py Tue Jan 28 22:20:01 2014
@@ -21,15 +21,23 @@ import sys
 import datetime as dt
 
 def decode_time_values(dataset, time_var_name):
-    ''''''
-    # Grab the time data and time unit info
+    ''' Decode NetCDF time values into Python datetime objects.
+
+    :param dataset: The dataset from which time values should be extracted.
+    :type dataset: netCDF4.Dataset
+    :param time_var_name: The name of the time variable in dataset.
+    :type time_var_name: String
+
+    :returns: The list of converted datetime values.
+
+    :raises ValueError: If the time units value couldn't be parsed, if the
+        base time value couldn't be parsed, or if the time_var_name could not
+        be found in the dataset.
+    '''
     time_data = dataset.variables[time_var_name]
     time_format = time_data.units
 
-    # NOTE: Could raise ValueError
     time_units = parse_time_units(time_format)
-
-    # NOTE: Could raise ValueError
     time_base = parse_time_base(time_format)
 
     times = []
@@ -48,7 +56,21 @@ def decode_time_values(dataset, time_var
     return times
 
 def parse_time_units(time_format):
-    ''''''
+    ''' Parse units value from time units string.
+
+    The only units that are supported are: seconds, minutes, hours, days, 
+        months, or years. 
+
+    :param time_format: The time data units string from the dataset
+        being processed. The string should be of the format
+        '<units> since <base time date>'
+    :type time_format: String
+
+    :returns: The unit substring from the time units string
+
+    :raises ValueError: If the units present in the time units string doesn't
+        match one of the supported unit value.
+    '''
     for unit in ['seconds', 'minutes', 'hours', 'days', 'months', 'years']:
         if unit in time_format:
             return unit



Mime
View raw message