Skip to content

Commit

Permalink
v1.3
Browse files Browse the repository at this point in the history
data URL update
  • Loading branch information
seanhaythorne committed Jul 8, 2019
1 parent 2ad6e7a commit b513765
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
45 changes: 33 additions & 12 deletions PaleoclimateToolDataFileHelper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BUILD FLAG: Set to True when creating executable packages to ensure dependency work-arounds
# Set to False for code releases to ensure Linux installation is easier to achieve
EXECUTABLE_BUILD_INCLUSION = False
EXECUTABLE_BUILD_INCLUSION = True

# Python modules
import re
Expand Down Expand Up @@ -241,7 +241,7 @@ def checkClimateDataUrl(self) :
#print 'check 2'
return False
except Exception, e :
current_url_file = url.urlopen('http://homepage.cs.latrobe.edu.au/shaythorne/paleoview/current_url.txt')
current_url_file = url.urlopen('https://storage.googleapis.com/paleoview-data/current_url.txt')
self.setClimateDataUrl(current_url_file.readline().rstrip())
try :
current_first_url_file = url.urlopen((self.climate_data_url + 'current_url.txt'))
Expand Down Expand Up @@ -1169,17 +1169,37 @@ def generateNetCdfClimateData(self, parameter, from_year_ad, until_year_ad, min_
window = rootgrp.createVariable('window','i4',('single',))
width = rootgrp.createVariable('width','i4',('single',))
decimals = rootgrp.createVariable('decimals','i4',('single',))
months = rootgrp.createVariable('months','i4',('month',), zlib=zlib)
latitudes = rootgrp.createVariable('latitudes','f8',('lat',), zlib=zlib)
longitudes = rootgrp.createVariable('longitudes','f8',('lon',), zlib=zlib)
latitudes.units = 'degrees north'
longitudes.units = 'degrees east'
## months = rootgrp.createVariable('months','i4',('month',), zlib=zlib)
## latitudes = rootgrp.createVariable('latitudes','f8',('lat',), zlib=zlib)
## longitudes = rootgrp.createVariable('longitudes','f8',('lon',), zlib=zlib)
## latitudes.units = 'degrees north'
## longitudes.units = 'degrees east'
window[:] = np.array(self.download_data_window)
width[:] = np.array(data_width)
decimals[:] = np.array(data_decimals)
months[:] = np.array(range(12)) + 1
latitudes[:] = np.arange(88.75,-88.751,-2.5)
longitudes[:] = np.arange(-178.75,178.751,2.5)
## months[:] = np.array(range(12)) + 1
## latitudes[:] = np.arange(88.75,-88.751,-2.5)
## longitudes[:] = np.arange(-178.75,178.751,2.5)

# Create coordinate variables NEW
month = rootgrp.createVariable('month','i4',('month',), zlib=zlib)
month.units = 'month'
month.axis = 'T'
month.long_name = 'month'
month.standard_name = 'month'
month[:] = np.array(range(12)) + 1
latitude = rootgrp.createVariable('lat','f8',('lat',), zlib=zlib)
latitude.units = 'degrees_north'
latitude.axis = 'Y'
latitude.long_name = 'latitude'
latitude.standard_name = 'latitude'
latitude[:] = np.arange(88.75,-88.751,-2.5)
longitude = rootgrp.createVariable('lon','f8',('lon',), zlib=zlib)
longitude.units = 'degrees_east'
longitude.axis = 'X'
longitude.long_name = 'longitude'
longitude.standard_name = 'longitude'
longitude[:] = np.arange(-178.75,178.751,2.5)

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

# Load grid data into subgroup variable using year label
data = subgroup.createVariable(year_str,'f8',('month','lat','lon',), zlib=zlib, least_significant_digit=(data_decimals+1)) # one more decimal than formatted
data.coordinates = 'month lat lon' # NEW
data.units = self.parameter_unit_string[parameter]
data.long_name = parameter.replace('_',' ').title()
data.standard_name = parameter
Expand Down Expand Up @@ -1259,8 +1280,8 @@ def downloadClimateData(self, parameter, from_year_ad, until_year_ad, delimiter=
# Download NetCDF file
local_netCdf_path = path.join(self.climate_data_directory['path'], netCdf_file)
try :
check_connection = url.urlopen((self.climate_data_url + netCdf_file))
check_connection.close()
#check_connection = url.urlopen((self.climate_data_url + netCdf_file))
#check_connection.close()
urllib.urlretrieve((self.climate_data_url + netCdf_file), local_netCdf_path, reporthook=self.netCdfDownloadProgress)
except Exception, e :
exception_message = 'Could not open ' + netCdf_file + '\nExpected climate data NetCDF file at: \n' + self.climate_data_url + '\n' + str(e)
Expand Down
16 changes: 12 additions & 4 deletions paleo_view_v1_2.py → paleo_view_v1_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
# Python extension modules (requires extension installation)
from Crypto.Cipher import AES
import numpy as np
# imports for py2exe build -
import appdirs
import packaging
import packaging.version
import packaging.specifiers
import packaging.requirements
import packaging.markers
# ---
import pandas as pd

# Python extension Matplot and Basemap modules
Expand All @@ -33,13 +41,13 @@
from matplotlib import rcParams

# Mac version?
MAC_VERSION = True # Make True for releases to enable Linux compatibility
MAC_VERSION = False # Make True for releases to enable Linux compatibility

# Tool library modules
from PaleoclimateToolDataFileHelper import PaleoclimateToolDataFileHelper

# TEST FLAG: Write stdout and stderr to console (not log files)
DEBUG = True
DEBUG = False

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

# Initialise config parameters
self.climate_data_source = 'local' # local/url
self.climate_data_url = 'http://paleoview.ddns.net:60627/data/'
self.climate_data_url = 'https://storage.googleapis.com/paleoview-data/'
self.climate_data_proxy_active = False
self.climate_data_proxy_url = 'http://example.proxy.com:80/'
self.climate_data_proxy_username = ''
Expand Down Expand Up @@ -6401,7 +6409,7 @@ def isNonNegativetiveFloat(self, string_value) :

## Main program

application_name = 'PaleoView v1.2'
application_name = 'PaleoView v1.3'

# Set user application data directory
if MAC_VERSION :
Expand Down

0 comments on commit b513765

Please sign in to comment.