climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From good...@apache.org
Subject [2/4] git commit: Prevent re-downloading the model file
Date Mon, 02 Jun 2014 21:16:41 GMT
Prevent re-downloading the model file


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

Branch: refs/heads/master
Commit: 50cee8126f7e4a0b57570da5eb4cf120d02de03b
Parents: 6713d72
Author: cgoodale <sigep311@gmail.com>
Authored: Mon Jun 2 13:38:35 2014 -0700
Committer: cgoodale <sigep311@gmail.com>
Committed: Mon Jun 2 13:38:35 2014 -0700

----------------------------------------------------------------------
 examples/knmi_to_cru31_full_bias.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/50cee812/examples/knmi_to_cru31_full_bias.py
----------------------------------------------------------------------
diff --git a/examples/knmi_to_cru31_full_bias.py b/examples/knmi_to_cru31_full_bias.py
index 50b9f96..7440ea7 100644
--- a/examples/knmi_to_cru31_full_bias.py
+++ b/examples/knmi_to_cru31_full_bias.py
@@ -1,7 +1,8 @@
 import datetime
+import urllib
+from os import path
 
 import numpy as np
-import urllib
 
 import ocw.data_source.local as local
 import ocw.data_source.rcmed as rcmed
@@ -20,8 +21,11 @@ MODEL = "AFRICA_KNMI-RACMO2.2b_CTL_ERAINT_MM_50km_1989-2008_tasmax.nc"
 # Filename for the output image/plot (without file extension)
 OUTPUT_PLOT = "cru_31_tmax_knmi_africa_bias_full"
 
-# Download necessary NetCDF file
-urllib.urlretrieve(FILE_LEADER + MODEL, MODEL)
+# Download necessary NetCDF file if not present
+if path.exists(MODEL):
+    pass
+else:
+    urllib.urlretrieve(FILE_LEADER + MODEL, MODEL)
 
 """ Step 1: Load Local NetCDF File into OCW Dataset Objects """
 print("Loading %s into an OCW Dataset Object" % (MODEL,))


Mime
View raw message