You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by hu...@apache.org on 2015/08/03 05:38:21 UTC
[1/2] climate git commit: Added:
ocw.dataset_processor.variable_unit_conversion
Repository: climate
Updated Branches:
refs/heads/master 536aa3e64 -> d4eeb03ee
Added: ocw.dataset_processor.variable_unit_conversion
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/3b297dbf
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/3b297dbf
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/3b297dbf
Branch: refs/heads/master
Commit: 3b297dbf29e789f4aec46e5f2f3ea151d9e14372
Parents: 83d83ba
Author: huikyole <hu...@argo.jpl.nasa.gov>
Authored: Thu Jul 30 16:37:34 2015 -0700
Committer: huikyole <hu...@argo.jpl.nasa.gov>
Committed: Thu Jul 30 16:37:34 2015 -0700
----------------------------------------------------------------------
ocw/dataset_processor.py | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/3b297dbf/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index 984e142..2a8602c 100755
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -421,7 +421,42 @@ def water_flux_unit_conversion(dataset):
dataset.units = 'mm/day'
return dataset
+def variable_unit_conversion(dataset):
+ ''' Convert water flux or temperature variables units as necessary
+
+ For water flux variables, convert full SI units water flux units to more common units.
+ For temperature, convert Celcius to Kelvin.
+
+ :param dataset: The dataset to convert.
+ :type dataset: :class:`dataset.Dataset`
+ :returns: A Dataset with values converted to new units.
+ :rtype: :class:`dataset.Dataset`
+ '''
+
+ water_flux_variables = ['pr', 'prec','evspsbl', 'mrro', 'swe']
+ temperature_variables = ['temp','tas','tasmax','taxmin','T']
+ variable = dataset.variable.lower()
+
+ if any(subString in variable for subString in water_flux_variables):
+ dataset_units = dataset.units.lower()
+ if variable in 'swe':
+ if any(unit in dataset_units for unit in ['m', 'meter']):
+ dataset.values = 1.e3 * dataset.values
+ dataset.units = 'km'
+ else:
+ if any(unit in dataset_units
+ for unit in ['kg m-2 s-1', 'mm s-1', 'mm/sec']):
+ dataset.values = 86400. * dataset.values
+ dataset.units = 'mm/day'
+
+ if any(subString in variable for subString in temperature_variables):
+ dataset_units = dataset.units.lower()
+ if dataset_units == 'c':
+ dataset.values = 273.15+dataset.values
+ dataset.units = 'K'
+
+ return dataset
def _rcmes_normalize_datetimes(datetimes, timestep):
""" Normalize Dataset datetime values.
[2/2] climate git commit: Merge branch 'CLIMATE-643'
Posted by hu...@apache.org.
Merge branch 'CLIMATE-643'
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/d4eeb03e
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/d4eeb03e
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/d4eeb03e
Branch: refs/heads/master
Commit: d4eeb03eeb70d8cd2f2a57762d95fdfc5f4fb765
Parents: 536aa3e 3b297db
Author: huikyole <hu...@argo.jpl.nasa.gov>
Authored: Sun Aug 2 20:38:14 2015 -0700
Committer: huikyole <hu...@argo.jpl.nasa.gov>
Committed: Sun Aug 2 20:38:14 2015 -0700
----------------------------------------------------------------------
ocw/dataset_processor.py | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/d4eeb03e/ocw/dataset_processor.py
----------------------------------------------------------------------