Skip to content

Commit 43b5dd4

Browse files
committed
v1.4
file generation performance issues
1 parent c083f65 commit 43b5dd4

5 files changed

Lines changed: 54 additions & 36 deletions

File tree

PaleoclimateToolDataFileHelper.py

Lines changed: 18 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 = True
3+
EXECUTABLE_BUILD_INCLUSION = False
44

55
# Python modules
66
import re
@@ -830,17 +830,23 @@ def loadClimateDataGrid(self, parameter, year_ad, month_index) : # TODO: load fr
830830
# Check current subgroup
831831
sub_interval_ad = self.convertDataIntervalLabelToAD(self.cached_netCdf_data[parameter]['sub_interval_str'])
832832
if sub_interval_ad['from_year_ad'] <= year_ad <= sub_interval_ad['until_year_ad'] :
833-
subgroup = rootgrp.groups[self.cached_netCdf_data[parameter]['sub_interval_str']]
834-
return subgroup.variables[year_str][month_index]
835-
836-
## # Check current rootgrp
837-
## for sub_interval_str in rootgrp.groups.keys() :
838-
## sub_interval_ad = self.convertDataIntervalLabelToAD(sub_interval_str)
839-
## if sub_interval_ad['from_year_ad'] <= year_ad <= sub_interval_ad['until_year_ad'] :
840-
## self.cached_netCdf_data[parameter]['sub_interval_str'] = sub_interval_str
841-
## return rootgrp.groups[sub_interval_str].variables[year_str][month_index]
842-
843-
# Not found - clear cache for parameter
833+
try :
834+
subgroup = rootgrp.groups[self.cached_netCdf_data[parameter]['sub_interval_str']]
835+
return subgroup.variables[year_str][month_index]
836+
except :
837+
ignore = None # re-open netCDF file (as below)
838+
839+
# Check current rootgrp
840+
for sub_interval_str in rootgrp.groups.keys() :
841+
sub_interval_ad = self.convertDataIntervalLabelToAD(sub_interval_str)
842+
if sub_interval_ad['from_year_ad'] <= year_ad <= sub_interval_ad['until_year_ad'] :
843+
self.cached_netCdf_data[parameter]['sub_interval_str'] = sub_interval_str
844+
try :
845+
return rootgrp.groups[sub_interval_str].variables[year_str][month_index]
846+
except :
847+
ignore = None # re-open netCDF file (as below)
848+
849+
# Not found or fail - clear cache for parameter
844850
rootgrp.close()
845851
self.cached_netCdf_data.pop(parameter)
846852

installer.iss

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
; NOTE: The value of AppId uniquely identifies this application.
66
; Do not use the same AppId value in installers for other applications.
77
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
8-
AppId={{B6F86A19-6567-42F1-B8A1-7632B7016A81}
8+
AppId={{91C97072-E776-4B4E-8F5A-E6B3F2AC7993}
99
AppName=PaleoView
10-
AppVersion=1.1
11-
AppVerName=PaleoView v1.1
10+
AppVersion=1.4
11+
AppVerName=PaleoView v1.4
1212
AppPublisher=Global Ecology Lab
13-
AppPublisherURL=http://www.example.com/
14-
AppSupportURL=http://www.example.com/
15-
AppUpdatesURL=http://www.example.com/
16-
DefaultDirName={pf}\PaleoView v1.1
17-
DefaultGroupName=PaleoView v1.1
13+
AppPublisherURL=https://github.com/GlobalEcologyLab/PaleoView
14+
AppSupportURL=https://github.com/GlobalEcologyLab/PaleoView
15+
AppUpdatesURL=https://github.com/GlobalEcologyLab/PaleoView
16+
DefaultDirName={pf}\PaleoView v1.4
17+
DefaultGroupName=PaleoView v1.4
1818
OutputBaseFilename=setup
1919
Compression=lzma
2020
SolidCompression=yes
@@ -26,18 +26,18 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
2626
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
2727

2828
[Files]
29-
Source: "C:\Users\shaythorne\Dropbox\GlobalEcology\PythonResources\vcredist_x86.exe"; DestDir: {tmp}
29+
Source: "C:\Users\Sean\GoogleDrive\GEL-Archive\PythonResources\vcredist_x86.exe"; DestDir: {tmp}
3030
Source: "dist\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
3131
Source: "paleo_view_config.txt"; DestDir: "{app}"
3232
Source: "Map Data/*"; DestDir: "{app}/Map Data"; Flags: recursesubdirs createallsubdirs
3333
Source: "Bias Corrections/*"; DestDir: "{app}/Bias Corrections"; Flags: recursesubdirs createallsubdirs
3434
; NOTE: Don't use "Flags: ignoreversion" on any shared system files vcredist_x86.exe
3535

3636
[Icons]
37-
Name: "{group}\PaleoView v1.1"; Filename: "{app}\paleo_view_v1_1.exe"
38-
Name: "{commondesktop}\PaleoView v1.1"; Filename: "{app}\paleo_view_v1_1.exe"; Tasks: desktopicon
37+
Name: "{group}\PaleoView v1.4"; Filename: "{app}\paleo_view_v1_4.exe"
38+
Name: "{commondesktop}\PaleoView v1.4"; Filename: "{app}\paleo_view_v1_4.exe"; Tasks: desktopicon
3939

4040
[Run]
4141
Filename: "{tmp}\vcredist_x86.exe"; Parameters: "/qu"; StatusMsg: "Installing Microsoft Visual C++ 2008 Redistributable Package..."
4242
Filename: "{tmp}\vcredist_x86.exe"; Parameters: ""; StatusMsg: "Installing Microsoft Visual C++ 2008 Redistributable Package..."
43-
Filename: "{app}\paleo_view_v1_1.exe"; Description: "{cm:LaunchProgram,PaleoView}"; Flags: nowait postinstall skipifsilent
43+
Filename: "{app}\paleo_view_v1_4.exe"; Description: "{cm:LaunchProgram,PaleoView}"; Flags: nowait postinstall skipifsilent
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from matplotlib import rcParams
4242

4343
# Mac version?
44-
MAC_VERSION = False # Make True for releases to enable Linux compatibility
44+
MAC_VERSION = True # Make True for releases to enable Linux compatibility
4545

4646
# Tool library modules
4747
from PaleoclimateToolDataFileHelper import PaleoclimateToolDataFileHelper
@@ -57,6 +57,9 @@
5757
DecodeAES = lambda c, e: c.decrypt(base64.b64decode(e)).rstrip(PADDING)
5858
PASSWORDKEY = '\xe7Z\xb2\xc9\x03\xb4\x8c\x04A\xfe\x97\xc3\xf9\xc7\xd2\x1c\xb9\x1eh\xd0\x91E/\xdb\xc9\x9f\xf0\xda\x8e\x06\xae\xd5' # set using os.urandom(BLOCK_SIZE)
5959

60+
# Allow open interval step and size (set to False for releases)
61+
OPEN_INTERVALS = False
62+
6063
## Application GUI
6164
## * Constructs tool GUI components
6265
## * Performs tool operations utilising climate data helper module
@@ -799,9 +802,12 @@ def createPeriodIntervalFrame(self) :
799802
for i, selection in enumerate(self.period_postfix_keys) :
800803
self.period_postfix_menu['from']['menu'].entryconfigure(i, command=(select_period_postfix, 'from', selection))
801804
self.period_postfix_menu['until']['menu'].entryconfigure(i, command=(select_period_postfix, 'until', selection))
802-
self.period_postfix_menu['until']['menu'].entryconfigure(0, state=tk.DISABLED)
805+
#self.period_postfix_menu['until']['menu'].entryconfigure(0, state=tk.DISABLED) # use if initial from is AD
803806

804-
self.interval_step_range = { 'min' : 10, 'max' : 10000 }
807+
if OPEN_INTERVALS :
808+
self.interval_step_range = { 'min' : 1, 'max' : 10000 }
809+
else :
810+
self.interval_step_range = { 'min' : 10, 'max' : 10000 }
805811
self.interval_step_values = [10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000]
806812
self.current_interval_step_values = [10, 20, 50, 100]
807813
self.current_valid_interval_step_value = 20
@@ -811,7 +817,10 @@ def createPeriodIntervalFrame(self) :
811817
self.interval_step_entry.config(command=(interval_step_spinbox_arrow_press))
812818
self.current_interval_steps = 8
813819

814-
self.interval_size_range = { 'min' : 10, 'max' : 100 }
820+
if OPEN_INTERVALS :
821+
self.interval_size_range = { 'min' : 1, 'max' : 10000 }
822+
else :
823+
self.interval_size_range = { 'min' : 10, 'max' : 100 }
815824
self.interval_size_values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
816825
self.current_interval_size_values = [10, 20, 30, 40, 50, 60, 70, 80]
817826
self.current_valid_interval_size_value = 30
@@ -5845,7 +5854,6 @@ def generateDataFiles(self) :
58455854
all_months=self.time_unit_is_all_months,
58465855
correct_bias=self.utilise_bias_correction.get())
58475856
self.parameter_data = parameter_data[0].copy()
5848-
self.data_file_helper.clearNetCdfDataCache()
58495857
except Exception, e :
58505858
self.data_file_helper.clearNetCdfDataCache()
58515859
showerror('Data extraction error', str(e))
@@ -5893,6 +5901,9 @@ def generateDataFiles(self) :
58935901
self.updateToolGenerationLogEntry(grids_generated={ 'number' : generated_file_count, 'expected' : len(period_years_ad) })
58945902
self.updateToolGenerationLogs()
58955903

5904+
# Clear netCDF cache
5905+
self.data_file_helper.clearNetCdfDataCache()
5906+
58965907
else : # Collect series data then generate file
58975908

58985909
# Collect series data
@@ -6409,7 +6420,7 @@ def isNonNegativetiveFloat(self, string_value) :
64096420

64106421
## Main program
64116422

6412-
application_name = 'PaleoView v1.3'
6423+
application_name = 'PaleoView v1.4'
64136424

64146425
# Set user application data directory
64156426
if MAC_VERSION :

setup_mac.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
# python setup_mac.py py2app
1515

16-
APP = ['paleo_view_v1_1.py']
16+
APP = ['paleo_view_v1_2.py']
1717
DATA_FILES= [(u'Map Data', glob(u'/Users/seanhaythorne/Dropbox/GlobalEcology/PaleoView/code/Map Data/*'))]
1818
DATA_FILES.append((u'Bias Corrections', glob(u'//Users/seanhaythorne/Dropbox/GlobalEcology/PaleoView/code/Bias Corrections/*')))
1919
DATA_FILES.append((u'.', glob(u'/Users/seanhaythorne/Dropbox/GlobalEcology/PaleoView/code/paleo_view_config.txt')))
@@ -23,7 +23,7 @@
2323

2424
setup(
2525
app=APP,
26-
name="PaleoView v1.1",
26+
name="PaleoView v1.4",
2727
data_files=DATA_FILES,
2828
options={'py2app': OPTIONS},
2929
# py_modules=[u'lib/PaleoclimateToolDataFileHelper'],

setup_pc.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
from distutils.core import setup
22
from glob import glob
33
import matplotlib
4-
import statsmodels.api
4+
#import statsmodels.api
55
import sys
66
import py2exe
77

88
# >python setup_pc.py py2exe
9+
# >py -2 setup_pc.py py2exe
910

10-
sys.path.append("C:\Users\shaythorne\Dropbox\GlobalEcology\PythonResources\Microsoft.VC90.CRT")
11+
sys.path.append("C:\Users\Sean\GoogleDrive\GEL-Archive\PythonResources\Microsoft.VC90.CRT")
1112

1213
data_files = matplotlib.get_py2exe_datafiles()
13-
#data_files.append(("Microsoft.VC90.CRT", glob(r'C:\Users\shaythorne\Dropbox\GlobalEcology\PythonResources\Microsoft.VC90.CRT\*.*')))
14+
#data_files.append(("Microsoft.VC90.CRT", glob(r'C:\Users\Sean\GoogleDrive\GEL-Archive\PythonResources\Microsoft.VC90.CRT\*.*')))
1415
data_files.append((r'mpl-data\basemap-data', glob(r'C:\Python27\Lib\site-packages\mpl_toolkits\basemap\data\*')))
1516
data_files.append((r'docx-data\templates', glob(r'C:\Python27\Lib\site-packages\docx\templates\*')))
1617
#data_files.append((r'Map Data', glob(r'C:\afat32\Dropbox\GlobalEcologyGroup\ProjectCode\PaleoclimateTool\v0.1\Map Data\*')))
1718
setup(
1819
data_files=data_files,
19-
windows=['paleo_view_v1_1.py'],
20+
windows=['paleo_view_v1_4.py'],
2021
)
2122
# options={'py2exe': { 'includes': 'patsy' }}
2223
# options={'py2exe': { 'excludes': ['_gtkagg', '_qt4agg', '_agg2', '_cairo', '_cocoaagg', '_fltkagg', '_gtk', '_gtkcairo'] }}

0 commit comments

Comments
 (0)