climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From whiteh...@apache.org
Subject [1/2] climate git commit: CLIMATE-624 - fix logical error in subregions_portrait_diagram.py example - Update the function call used to use calc_climatology_year - Update to normalize_dataset_datetimes instead of temporal_rebin - Update printed documenta
Date Thu, 23 Apr 2015 20:54:15 GMT
Repository: climate
Updated Branches:
  refs/heads/master f836d76ef -> 4c95ae091


CLIMATE-624 - fix logical error in subregions_portrait_diagram.py example
- Update the function call used to use calc_climatology_year
- Update to normalize_dataset_datetimes instead of  temporal_rebin
- Update printed documentation


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

Branch: refs/heads/master
Commit: 218e777cdba7538ba2b4fed3e9eab13f172875f4
Parents: b258cce
Author: Kim Whitehall <kim.d.whitehall@jpl.nasa.gov>
Authored: Tue Apr 21 16:31:52 2015 -0700
Committer: Kim Whitehall <kim.d.whitehall@jpl.nasa.gov>
Committed: Tue Apr 21 16:31:52 2015 -0700

----------------------------------------------------------------------
 examples/subregions_portrait_diagram.py | 59 ++++++++++++----------------
 1 file changed, 25 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/218e777c/examples/subregions_portrait_diagram.py
----------------------------------------------------------------------
diff --git a/examples/subregions_portrait_diagram.py b/examples/subregions_portrait_diagram.py
index 243b7d6..e0d789a 100644
--- a/examples/subregions_portrait_diagram.py
+++ b/examples/subregions_portrait_diagram.py
@@ -65,27 +65,24 @@ target_datasets.append(local.load_file(FILE_1, varName, name="KNMI"))
 target_datasets.append(local.load_file(FILE_2, varName, name="REGCM"))
 target_datasets.append(local.load_file(FILE_3, varName, name="UCT"))
 
-
 """ Step 2: Fetch an OCW Dataset Object from the data_source.rcmed module """
 print("Working with the rcmed interface to get CRU3.1 Daily Precipitation")
 # the dataset_id and the parameter id were determined from  
 # https://rcmes.jpl.nasa.gov/content/data-rcmes-database 
 CRU31 = rcmed.parameter_dataset(10, 37, LAT_MIN, LAT_MAX, LON_MIN, LON_MAX, START, END)
 
-""" Step 3: Resample Datasets so they are the same shape """
-print("Resampling datasets ...")
+""" Step 3: Processing Datasets so they are the same shape """
+print("Processing datasets ...")
+CRU31 = dsp.normalize_dataset_datetimes(CRU31, 'monthly')
 print("... on units")
 CRU31 = dsp.water_flux_unit_conversion(CRU31)
-print("... temporal")
-CRU31 = dsp.temporal_rebin(CRU31, datetime.timedelta(days=30))
 
 for member, each_target_dataset in enumerate(target_datasets):
-	target_datasets[member] = dsp.water_flux_unit_conversion(target_datasets[member])
-	target_datasets[member] = dsp.temporal_rebin(target_datasets[member], datetime.timedelta(days=30))

 	target_datasets[member] = dsp.subset(EVAL_BOUNDS, target_datasets[member])	
-	
-#Regrid
-print("... regrid")
+	target_datasets[member] = dsp.water_flux_unit_conversion(target_datasets[member])
+	target_datasets[member] = dsp.normalize_dataset_datetimes(target_datasets[member], 'monthly')
		
+		
+print("... spatial regridding")
 new_lats = np.arange(LAT_MIN, LAT_MAX, gridLatStep)
 new_lons = np.arange(LON_MIN, LON_MAX, gridLonStep)
 CRU31 = dsp.spatial_regrid(CRU31, new_lats, new_lons)
@@ -93,13 +90,12 @@ CRU31 = dsp.spatial_regrid(CRU31, new_lats, new_lons)
 for member, each_target_dataset in enumerate(target_datasets):
 	target_datasets[member] = dsp.spatial_regrid(target_datasets[member], new_lats, new_lons)
 	
-#find the mean values
-#way to get the mean. Note the function exists in util.py as def calc_climatology_year(dataset):
-CRU31.values, CRU31.times = utils.calc_climatology_monthly(CRU31)
-	
+#find the total annual mean. Note the function exists in util.py as def calc_climatology_year(dataset):
+_,CRU31.values = utils.calc_climatology_year(CRU31)
+
 for member, each_target_dataset in enumerate(target_datasets):
-	target_datasets[member].values, target_datasets[member].times = utils.calc_climatology_monthly(target_datasets[member])
-		
+	_, target_datasets[member].values = utils.calc_climatology_year(target_datasets[member])
+
 #make the model ensemble
 target_datasets_ensemble = dsp.ensemble(target_datasets)
 target_datasets_ensemble.name="ENS"
@@ -110,25 +106,20 @@ target_datasets.append(target_datasets_ensemble)
 for target in target_datasets:
 	allNames.append(target.name)
 
-#update what times are for the subregion
-#get time bounds from existing datasets
-START_SUB = CRU31.times[0]
-END_SUB = CRU31.times[-1]
-
 list_of_regions = [
- Bounds(-10.0, 0.0, 29.0, 36.5, START_SUB, END_SUB), 
- Bounds(0.0, 10.0,  29.0, 37.5, START_SUB, END_SUB),
- Bounds(10.0, 20.0, 25.0, 32.5, START_SUB, END_SUB),
- Bounds(20.0, 33.0, 25.0, 32.5, START_SUB, END_SUB),
- Bounds(-19.3,-10.2,12.0, 20.0, START_SUB, END_SUB),
- Bounds( 15.0, 30.0, 15.0, 25.0,START_SUB, END_SUB),
- Bounds(-10.0, 10.0, 7.3, 15.0, START_SUB, END_SUB),
- Bounds(-10.9, 10.0, 5.0, 7.3,  START_SUB, END_SUB),
- Bounds(33.9, 40.0,  6.9, 15.0, START_SUB, END_SUB),
- Bounds(10.0, 25.0,  0.0, 10.0, START_SUB, END_SUB),
- Bounds(10.0, 25.0,-10.0,  0.0, START_SUB, END_SUB),
- Bounds(30.0, 40.0,-15.0,  0.0, START_SUB, END_SUB),
- Bounds(33.0, 40.0, 25.0, 35.0, START_SUB, END_SUB)]
+ Bounds(-10.0, 0.0, 29.0, 36.5), 
+ Bounds(0.0, 10.0,  29.0, 37.5), 
+ Bounds(10.0, 20.0, 25.0, 32.5), 
+ Bounds(20.0, 33.0, 25.0, 32.5), 
+ Bounds(-19.3,-10.2,12.0, 20.0), 
+ Bounds( 15.0, 30.0, 15.0, 25.0),
+ Bounds(-10.0, 10.0, 7.3, 15.0), 
+ Bounds(-10.9, 10.0, 5.0, 7.3),  
+ Bounds(33.9, 40.0,  6.9, 15.0), 
+ Bounds(10.0, 25.0,  0.0, 10.0), 
+ Bounds(10.0, 25.0,-10.0,  0.0), 
+ Bounds(30.0, 40.0,-15.0,  0.0), 
+ Bounds(33.0, 40.0, 25.0, 35.00)]
 
 region_list=["R"+str(i+1) for i in xrange(13)]
 


Mime
View raw message