climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boust...@apache.org
Subject svn commit: r1513284 - /incubator/climate/branches/RefactorInput/ocw/data_source/rcmed.py
Date Mon, 12 Aug 2013 22:30:26 GMT
Author: boustani
Date: Mon Aug 12 22:30:26 2013
New Revision: 1513284

URL: http://svn.apache.org/r1513284
Log:
to automatically get the parameter's missing value from parameter_metadata function

Modified:
    incubator/climate/branches/RefactorInput/ocw/data_source/rcmed.py

Modified: incubator/climate/branches/RefactorInput/ocw/data_source/rcmed.py
URL: http://svn.apache.org/viewvc/incubator/climate/branches/RefactorInput/ocw/data_source/rcmed.py?rev=1513284&r1=1513283&r2=1513284&view=diff
==============================================================================
--- incubator/climate/branches/RefactorInput/ocw/data_source/rcmed.py (original)
+++ incubator/climate/branches/RefactorInput/ocw/data_source/rcmed.py Mon Aug 12 22:30:26
2013
@@ -56,16 +56,23 @@ def parameters_metadata():
     return param_info_list
 
 
-def _make_mask_array(values):  
+def _make_mask_array(values, parameter_id):  
     '''Created masked array to deal with missing values
 
     :param values: Numpy array of values which may contain missing values
     :type values: Numpy array
+    :param parameter_id: Parameter's id
+    :type parameter_id: Integer
+
     :returns: Masked array of values
     :rtype: Masked array
     '''
-
-    missing_values = -9999
+    
+    all_param_info = parameters_metadata()
+    for each in all_param_info:
+        if each['parameter_id'].encode() == str(parameter_id):
+            missing_values = each['missingdataflag'].encode()
+            break
     values = ma.masked_array(values, mask=(values == missing_values))
 
     return values
@@ -338,6 +345,6 @@ def parameter_dataset(dataset_id, parame
     unique_lats_lons_levels_times = _make_unique(lats, lons, levels, times)
     unique_times = _calculate_time(unique_lats_lons_levels_times[3], time_step)
     values = _reshape_values(values, unique_lats_lons_levels_times)
-    values = _make_mask_array(values)
+    values = _make_mask_array(values, parameter_id)
     
     return Dataset(unique_lats_lons_levels_times[0], unique_lats_lons_levels_times[1], unique_times,
values, parameter_name)
\ No newline at end of file



Mime
View raw message