Skip to content

Commit b513765

Browse files
committed
v1.3
data URL update
1 parent 2ad6e7a commit b513765

2 files changed

Lines changed: 45 additions & 16 deletions

File tree

PaleoclimateToolDataFileHelper.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# BUILD FLAG: Set to True when creating executable packages to ensure dependency work-arounds
22
# Set to False for code releases to ensure Linux installation is easier to achieve
3-
EXECUTABLE_BUILD_INCLUSION = False
3+
EXECUTABLE_BUILD_INCLUSION = True
44

55
# Python modules
66
import re
@@ -241,7 +241,7 @@ def checkClimateDataUrl(self) :
241241
#print 'check 2'
242242
return False
243243
except Exception, e :
244-
current_url_file = url.urlopen('http://homepage.cs.latrobe.edu.au/shaythorne/paleoview/current_url.txt')
244+
current_url_file = url.urlopen('https://storage.googleapis.com/paleoview-data/current_url.txt')
245245
self.setClimateDataUrl(current_url_file.readline().rstrip())
246246
try :
247247
current_first_url_file = url.urlopen((self.climate_data_url + 'current_url.txt'))
@@ -1169,17 +1169,37 @@ def generateNetCdfClimateData(self, parameter, from_year_ad, until_year_ad, min_
11691169
window = rootgrp.createVariable('window','i4',('single',))
11701170
width = rootgrp.createVariable('width','i4',('single',))
11711171
decimals = rootgrp.createVariable('decimals','i4',('single',))
1172-
months = rootgrp.createVariable('months','i4',('month',), zlib=zlib)
1173-
latitudes = rootgrp.createVariable('latitudes','f8',('lat',), zlib=zlib)
1174-
longitudes = rootgrp.createVariable('longitudes','f8',('lon',), zlib=zlib)
1175-
latitudes.units = 'degrees north'
1176-
longitudes.units = 'degrees east'
1172+
## months = rootgrp.createVariable('months','i4',('month',), zlib=zlib)
1173+
## latitudes = rootgrp.createVariable('latitudes','f8',('lat',), zlib=zlib)
1174+
## longitudes = rootgrp.createVariable('longitudes','f8',('lon',), zlib=zlib)
1175+
## latitudes.units = 'degrees north'
1176+
## longitudes.units = 'degrees east'
11771177
window[:] = np.array(self.download_data_window)
11781178
width[:] = np.array(data_width)
11791179
decimals[:] = np.array(data_decimals)
1180-
months[:] = np.array(range(12)) + 1
1181-
latitudes[:] = np.arange(88.75,-88.751,-2.5)
1182-
longitudes[:] = np.arange(-178.75,178.751,2.5)
1180+
## months[:] = np.array(range(12)) + 1
1181+
## latitudes[:] = np.arange(88.75,-88.751,-2.5)
1182+
## longitudes[:] = np.arange(-178.75,178.751,2.5)
1183+
1184+
# Create coordinate variables NEW
1185+
month = rootgrp.createVariable('month','i4',('month',), zlib=zlib)
1186+
month.units = 'month'
1187+
month.axis = 'T'
1188+
month.long_name = 'month'
1189+
month.standard_name = 'month'
1190+
month[:] = np.array(range(12)) + 1
1191+
latitude = rootgrp.createVariable('lat','f8',('lat',), zlib=zlib)
1192+
latitude.units = 'degrees_north'
1193+
latitude.axis = 'Y'
1194+
latitude.long_name = 'latitude'
1195+
latitude.standard_name = 'latitude'
1196+
latitude[:] = np.arange(88.75,-88.751,-2.5)
1197+
longitude = rootgrp.createVariable('lon','f8',('lon',), zlib=zlib)
1198+
longitude.units = 'degrees_east'
1199+
longitude.axis = 'X'
1200+
longitude.long_name = 'longitude'
1201+
longitude.standard_name = 'longitude'
1202+
longitude[:] = np.arange(-178.75,178.751,2.5)
11831203

11841204
# Add overlap to allow for interval window
11851205
from_year_ad = max((from_year_ad - self.download_data_window), min_year_ad)
@@ -1223,6 +1243,7 @@ def generateNetCdfClimateData(self, parameter, from_year_ad, until_year_ad, min_
12231243

12241244
# Load grid data into subgroup variable using year label
12251245
data = subgroup.createVariable(year_str,'f8',('month','lat','lon',), zlib=zlib, least_significant_digit=(data_decimals+1)) # one more decimal than formatted
1246+
data.coordinates = 'month lat lon' # NEW
12261247
data.units = self.parameter_unit_string[parameter]
12271248
data.long_name = parameter.replace('_',' ').title()
12281249
data.standard_name = parameter
@@ -1259,8 +1280,8 @@ def downloadClimateData(self, parameter, from_year_ad, until_year_ad, delimiter=
12591280
# Download NetCDF file
12601281
local_netCdf_path = path.join(self.climate_data_directory['path'], netCdf_file)
12611282
try :
1262-
check_connection = url.urlopen((self.climate_data_url + netCdf_file))
1263-
check_connection.close()
1283+
#check_connection = url.urlopen((self.climate_data_url + netCdf_file))
1284+
#check_connection.close()
12641285
urllib.urlretrieve((self.climate_data_url + netCdf_file), local_netCdf_path, reporthook=self.netCdfDownloadProgress)
12651286
except Exception, e :
12661287
exception_message = 'Could not open ' + netCdf_file + '\nExpected climate data NetCDF file at: \n' + self.climate_data_url + '\n' + str(e)
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
# Python extension modules (requires extension installation)
1818
from Crypto.Cipher import AES
1919
import numpy as np
20+
# imports for py2exe build -
21+
import appdirs
22+
import packaging
23+
import packaging.version
24+
import packaging.specifiers
25+
import packaging.requirements
26+
import packaging.markers
27+
# ---
2028
import pandas as pd
2129

2230
# Python extension Matplot and Basemap modules
@@ -33,13 +41,13 @@
3341
from matplotlib import rcParams
3442

3543
# Mac version?
36-
MAC_VERSION = True # Make True for releases to enable Linux compatibility
44+
MAC_VERSION = False # Make True for releases to enable Linux compatibility
3745

3846
# Tool library modules
3947
from PaleoclimateToolDataFileHelper import PaleoclimateToolDataFileHelper
4048

4149
# TEST FLAG: Write stdout and stderr to console (not log files)
42-
DEBUG = True
50+
DEBUG = False
4351

4452
# Code for encrypting/decrypting the proxy password when saved/retrieved from the config file
4553
BLOCK_SIZE = 32
@@ -73,7 +81,7 @@ def __init__(self, user_application_data_directory, master=None) :
7381

7482
# Initialise config parameters
7583
self.climate_data_source = 'local' # local/url
76-
self.climate_data_url = 'http://paleoview.ddns.net:60627/data/'
84+
self.climate_data_url = 'https://storage.googleapis.com/paleoview-data/'
7785
self.climate_data_proxy_active = False
7886
self.climate_data_proxy_url = 'http://example.proxy.com:80/'
7987
self.climate_data_proxy_username = ''
@@ -6401,7 +6409,7 @@ def isNonNegativetiveFloat(self, string_value) :
64016409

64026410
## Main program
64036411

6404-
application_name = 'PaleoView v1.2'
6412+
application_name = 'PaleoView v1.3'
64056413

64066414
# Set user application data directory
64076415
if MAC_VERSION :

0 commit comments

Comments
 (0)