Repository: climate
Updated Branches:
  refs/heads/master a4ccb10f7 -> 334194118


CLIMATE-743 - Update utils.normalize_lat_lon_values

- Any longitude values between 180 and 360 is converted to -180 and 0.


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/51dd397d
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/51dd397d
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/51dd397d

Branch: refs/heads/master
Commit: 51dd397d522c0471c01c29d1f522aeab45bc7c49
Parents: d9e3c7e
Author: huikyole <[email protected]>
Authored: Mon Feb 1 18:52:00 2016 -0800
Committer: huikyole <[email protected]>
Committed: Mon Feb 1 18:52:00 2016 -0800

----------------------------------------------------------------------
 ocw/utils.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/51dd397d/ocw/utils.py
----------------------------------------------------------------------
diff --git a/ocw/utils.py b/ocw/utils.py
index 3c7beb0..442382a 100755
--- a/ocw/utils.py
+++ b/ocw/utils.py
@@ -43,6 +43,8 @@ def decode_time_values(dataset, time_var_name):
     '''
     time_data = dataset.variables[time_var_name]
     time_format = time_data.units
+    if time_format[-1].lower() == 'z':
+        time_format = time_format[:-1]
 
     time_units = parse_time_units(time_format)
     time_base = parse_time_base(time_format)
@@ -186,8 +188,7 @@ def normalize_lat_lon_values(lats, lons, values):
     '''
     if lats.ndim ==1 and lons.ndim ==1:
         # Avoid unnecessary shifting if all lons are higher than 180
-        if lons.min() > 180:
-            lons -= 360
+        lons[lons > 180] = lons[lons > 180] - 360.
 
        # Make sure lats and lons are monotonically increasing
        lats_decreasing = np.diff(lats) < 0
@@ -222,6 +223,9 @@ def normalize_lat_lon_values(lats, lons, values):
 
         return lats_out, lons_out, data_out
     else:
+        # Avoid unnecessary shifting if all lons are higher than 180
+        lons[lons > 180] = lons[lons > 180] - 360.
+
         return lats, lons, values
 
 

Reply via email to