You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by bo...@apache.org on 2013/08/13 00:30:26 UTC
svn commit: r1513284 -
/incubator/climate/branches/RefactorInput/ocw/data_source/rcmed.py
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