climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From huiky...@apache.org
Subject [1/2] climate git commit: CLIMATE-952 - Update ocw.data_processor.write_netcdf to compatible with xarray
Date Fri, 15 Jun 2018 20:57:20 GMT
Repository: climate
Updated Branches:
  refs/heads/master fd8ca98c5 -> aa7b8f4ce


CLIMATE-952 - Update ocw.data_processor.write_netcdf to compatible with xarray

- write_netcdf and write_netcdf_multiple_datasets_with_subregions have been updated
- now the time dimension is unlimited
- x and y are names for the dimensions for longitudinal and latitudinal coordinates


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

Branch: refs/heads/master
Commit: 38c240aa1ab9bc4ad648511e86e40a2aa62251e1
Parents: fd8ca98
Author: huikyole <huikyole@argo.jpl.nasa.gov>
Authored: Wed Jun 13 12:08:08 2018 -0700
Committer: huikyole <huikyole@argo.jpl.nasa.gov>
Committed: Wed Jun 13 12:08:08 2018 -0700

----------------------------------------------------------------------
 ocw/dataset_processor.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/38c240aa/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index a167acc..423682c 100755
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -631,31 +631,31 @@ def write_netcdf(dataset, path, compress=True):
     if dataset.lats.ndim == 2:
         lat_len = dataset.lats.shape[0]
         lon_len = dataset.lons.shape[1]
-        lat_dim_info = ('lat', 'lon')
-        lon_dim_info = ('lat', 'lon')
+        lat_dim_info = ('y', 'x')
+        lon_dim_info = ('y', 'x')
 
     else:
         lat_len = len(dataset.lats)
         lon_len = len(dataset.lons)
-        lat_dim_info = ('lat',)
-        lon_dim_info = ('lon',)
+        lat_dim_info = ('y',)
+        lon_dim_info = ('x',)
 
     time_len = len(dataset.times)
 
     # Create attribute dimensions
-    out_file.createDimension('lat', lat_len)
-    out_file.createDimension('lon', lon_len)
-    out_file.createDimension('time', time_len)
+    out_file.createDimension('y', lat_len)
+    out_file.createDimension('x', lon_len)
+    out_file.createDimension('time', None)
 
     # Create variables
     lats = out_file.createVariable('lat', 'f8', lat_dim_info, zlib=compress)
     lons = out_file.createVariable('lon', 'f8', lon_dim_info, zlib=compress)
-    times = out_file.createVariable('time', 'f8', ('time',), zlib=compress)
+    times = out_file.createVariable('time', 'f8', ('time'), zlib=compress)
 
     var_name = dataset.variable if dataset.variable else 'var'
     values = out_file.createVariable(var_name,
                                      'f8',
-                                     ('time', 'lat', 'lon'),
+                                     ('time', 'y', 'x'),
                                      zlib=compress)
 
     # Set the time variable units


Mime
View raw message