CLIMATE-687 - A new loader to read GPM precipitation data with a file list - ocw.data_source.local.load_GPM_IMERG_files is added
Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/491c78ba Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/491c78ba Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/491c78ba Branch: refs/heads/master Commit: 491c78ba884493c7e7200dd80101d261e9883e5f Parents: 32b184d Author: huikyole <[email protected]> Authored: Wed Oct 7 18:09:57 2015 -0700 Committer: huikyole <[email protected]> Committed: Wed Oct 7 18:09:57 2015 -0700 ---------------------------------------------------------------------- ocw/data_source/local.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/491c78ba/ocw/data_source/local.py ---------------------------------------------------------------------- diff --git a/ocw/data_source/local.py b/ocw/data_source/local.py index 97e482b..766eb8f 100644 --- a/ocw/data_source/local.py +++ b/ocw/data_source/local.py @@ -367,7 +367,9 @@ def load_GPM_IMERG_files(file_path=None, lats = file_object_first['Grid']['lat'][:] lons = file_object_first['Grid']['lon'][:] - lons, lats = np.meshgrid(lons, lats) + lons, lats = numpy.meshgrid(lons, lats) + + variable_unit = "mm/hr" times = [] nfile = len(GPM_files) @@ -375,12 +377,11 @@ def load_GPM_IMERG_files(file_path=None, print 'Reading file '+str(ifile+1)+'/'+str(nfile), file file_object = h5py.File(file) time_struct_parsed = strptime(file[-39:-23],"%Y%m%d-S%H%M%S") - for ihour in numpy.arange(24): - times.append(datetime(*time_struct_parsed[:6])) - values0= ma.masked_less(file_object['Grid'][variable_name][:], 0.) + times.append(datetime(*time_struct_parsed[:6])) + values0= numpy.transpose(ma.masked_less(file_object['Grid'][variable_name][:], 0.)) + values0= numpy.expand_dims(values0, axis=0) if ifile == 0: - values = values0 - variable_unit = file_object.variables[variable_name].units + values = values0 else: values = numpy.concatenate((values, values0)) file_object.close()
