Skip to content

Commit

Permalink
Export Accumulation
Browse files Browse the repository at this point in the history
  • Loading branch information
TCallaghan2 committed Jun 16, 2024
1 parent e5ab092 commit 9b98824
Show file tree
Hide file tree
Showing 11 changed files with 316 additions and 93 deletions.
4 changes: 2 additions & 2 deletions Configuration/Interpolation/SpatialFcnsGB.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# This is true for fitting the nonlinear parameters of function 3 hence
# the parameters of function 1 must be fit before the parameters of function 3.
Function, dim=z, shape=Logistic, precon=0
Function, dim=x, shape=Logistic, precon=0
Function, dim=y, shape=Logistic, precon=0
Function, dim=z, shape=Gaussian, precon=0
Function, dim=z, shape=SinExp, precon=0
Function, dim=x, shape=Logistic, precon=1
Function, dim=y, shape=Logistic, precon=1
8 changes: 2 additions & 6 deletions Configuration/Interpolation/SpatialFcnsMA.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
# This is true for fitting the nonlinear parameters of function 3 hence
# the parameters of function 1 must be fit before the parameters of function 3.
Function, dim=z, shape=Logistic, precon=0
Function, dim=x, shape=Logistic, precon=0
Function, dim=y, shape=Logistic, precon=0
Function, dim=z, shape=Gaussian, precon=0
Function, dim=z, shape=SinExp, precon=0
Function, dim=x, shape=Logistic, precon=1
Function, dim=y, shape=Logistic, precon=1
Function, dim=x, shape=Logistic, precon=2
Function, dim=y, shape=Logistic, precon=2
Function, dim=x, shape=Logistic, precon=3
Function, dim=y, shape=Logistic, precon=3
13 changes: 13 additions & 0 deletions Configuration/Interpolation/UK.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@ NLS Spatial Fcn File Name = SpatialFcns.cfg
# Save interim data by writing out supporting data files
#
Save Data = F
#
# Interpolation can sometimes create excessively large values.
# To bypass, Use Saturate can be T or F, but set a larger threshold, i.e. 1E309 (Infinity).
# The user can choose to saturate to the threshold, (T), or
# reset the value to 0.0 when exceeded, (F).
#
Use Saturate = F
#
# Threshold value to use
# Use Saturate = T, if field > Threshold then field = Threshold
# Use Saturate = F, if field > Threshold then field = 0.0
#
Overflow Threshold = 1E10
13 changes: 13 additions & 0 deletions Configuration/Interpolation/UK_GB.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@ NLS Spatial Fcn File Name = SpatialFcnsGB.cfg
# Save interim data by writing out supporting data files
#
Save Data = F
#
# Interpolation can sometimes create excessively large values.
# To bypass, Use Saturate can be T or F, but set a larger threshold, i.e. 1E309 (Infinity).
# The user can choose to saturate to the threshold, (T), or
# reset the value to 0.0 when exceeded, (F).
#
Use Saturate = F
#
# Threshold value to use
# Use Saturate = T, if field > Threshold then field = Threshold
# Use Saturate = F, if field > Threshold then field = 0.0
#
Overflow Threshold = 1E10
13 changes: 13 additions & 0 deletions Configuration/Interpolation/UK_MA.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@ NLS Spatial Fcn File Name = SpatialFcnsMA.cfg
# Save interim data by writing out supporting data files
#
Save Data = F
#
# Interpolation can sometimes create excessively large values.
# To bypass, Use Saturate can be T or F, but set a larger threshold, i.e. 1E309 (Infinity).
# The user can choose to saturate to the threshold, (T), or
# reset the value to 0.0 when exceeded, (F).
#
Use Saturate = F
#
# Threshold value to use
# Use Saturate = T, if field > Threshold then field = Threshold
# Use Saturate = F, if field > Threshold then field = 0.0
#
Overflow Threshold = 1E10
45 changes: 24 additions & 21 deletions PythonScripts/GUI/GeoSAM/GeoSams.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import os
import sys
import platform
import csv
from collections import defaultdict

from MainInputFrame import *
Expand Down Expand Up @@ -97,7 +98,9 @@ def __init__(self, title, maxAreas, maxCorners, maxYears):
self.style.configure('SAMS.TFrame', borderwidth=1, relief='solid', labelmargins=20)
self.style.configure('SAMS.TFrame.Label', font=('courier', 10, 'bold'))
self.style.configure("BtnGreen.TLabel", padding=6, relief='raised', background="#0F0")
self.style.configure("BtnLime.TLabel", padding=6, relief='raised', background="#d3eb00")
self.style.configure("BtnBluGrn.TLabel", padding=6, relief='raised', background="#0FF")
self.style.configure("BtnMaize.TLabel", padding=6, relief='raised', background="#cf34eb")
self.style.configure("Help.TLabel", padding=6, relief='raised', foreground='blue', background="#42e6f5")


Expand Down Expand Up @@ -455,8 +458,6 @@ def InterpAndPlotResults(self):
# PLOTTING
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# We have the needed output paramters so lets plot data and save to pdf files
messagebox.showinfo("Matlab/Octave", f'Plotting Results')

p = platform.platform()
for pStr in self.paramStr:
str1 = 'Results/Lat_Lon_Surv_' + pStr + self.domainName
Expand All @@ -473,7 +474,7 @@ def InterpAndPlotResults(self):
if (result.returncode != 0):
errorStr = '' + ''.join(str(e)+' ' for e in cmd) + ' error: ' + hex(result.returncode) + ''
print(errorStr)
return (result.returncode, result.args)
return (result.returncode, result.args, errorStr)

return (0, '', '')

Expand All @@ -489,8 +490,8 @@ def SaveConfigFiles(self):
self.WriteGrowthConfig()
self.WriteGridMgrConfig()
self.WriteUKConfig()
cfgFile = os.path.join(self.root,'Configuration', 'Interpolation', self.frame4.spatCfgFile.myEntry.get())
self.WriteSpatialFncsConfig(cfgFile)
# cfgFile = os.path.join(self.root,'Configuration', 'Interpolation', self.frame4.spatCfgFile.myEntry.get())
# self.WriteSpatialFncsConfig(cfgFile)
messagebox.showinfo("Save Files", "Configuration Files Saved")

#-------------------------------------------------------------------------------------
Expand Down Expand Up @@ -644,31 +645,33 @@ def WriteGridMgrConfig(self):
#-------------------------------------------------------------------------------------
def WriteUKConfig(self):
cfgFile = os.path.join(self.root,'Configuration', 'Interpolation', self.frame1.ukCfgFile.myEntry.get())
self.CloseUKConfig(cfgFile, self.frame4.formCombo.get(), self.frame4.spatCfgFile.myEntry.get()),

def CloseUKConfig(self, cfgFile, combo, fName):
with open(cfgFile, 'w') as f:
f.write('# Set inputs for universal kriging\n')
#DEPRECATE#f.write('# Observation files are expecting in the Data subdirectory\n')
#DEPRECATE#f.write('#\n')
#DEPRECATE#f.write('#(max interp field < hlf*max(obs))\n')
#DEPRECATE#f.write('High Limit Factor = '+self.frame4.highLimit.myEntry.get()+'\n')
f.write('Kriging variogram form = '+self.frame4.formCombo.get()+'\n')
f.write('Kriging variogram form = '+combo+'\n')
f.write('#\n')
#DEPRECATE#f.write('# Keep this line before "Power Transform Parameter"\n')
#DEPRECATE#f.write('#\n')
#DEPRECATE#f.write('Log Transform = '+self.frame4.useLogTransCombo.get()+'\n')
#DEPRECATE#f.write('#\n')
#DEPRECATE#f.write('# Power transform interpolates f(x)^alpha \n')
#DEPRECATE#f.write('# generally 0< alpha < 1 but this has not been tested \n')
#DEPRECATE#f.write('# not used if "Log Transform = T"\n')
#DEPRECATE#f.write('#\n')
#DEPRECATE#f.write('Power Transform Parameter = '+self.frame4.powerTrans.myEntry.get()+'\n')
#DEPRECATE#f.write('#\n')
f.write('# Configuration files are expected to be in the Configuration directory\n')
f.write('#\n')
f.write('NLS Spatial Fcn File Name = '+self.frame4.spatCfgFile.myEntry.get()+'\n')
f.write('NLS Spatial Fcn File Name = '+fName+'\n')
f.write('#\n')
f.write('# Save interim data by writing out supporting data files\n')
f.write('#\n')
f.write('Save Data = F\n')
f.write('#\n')
f.write('# Interpolation can sometimes create excessively large values.\n')
f.write('# To bypass, Use Saturate can be T or F, but set a larger threshold, i.e. 1E309 (Infinity).\n')
f.write('# The user can choose to saturate to the threshold, (T), or \n')
f.write('# reset the value to 0.0 when exceeded, (F).\n')
f.write('#\n')
f.write('Use Saturate = '+ self.frame1.useSaturateCombo.get()+'\n')
f.write('#\n')
f.write('# Threshold value to use\n')
f.write('# Use Saturate = T, if field > Threshold then field = Threshold\n')
f.write('# Use Saturate = F, if field > Threshold then field = 0.0\n')
f.write('#\n')
f.write('Overflow Threshold = '+ self.frame1.saturateThresh.myEntry.get() +'\n')
f.close()

#-------------------------------------------------------------------------------------
Expand Down
37 changes: 8 additions & 29 deletions PythonScripts/GUI/GeoSAM/InterpolationFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def SaveSpatialFcnConfigFName(self):
if file_path:
self.spatCfgFile.myEntry.delete(0,tk.END)
self.spatCfgFile.myEntry.insert(0,f[-1])
self.parent.WriteSpatialFncsConfig()
self.parent.WriteSpatialFncsConfig(file_path)

def SaveMASpatialFcnConfigFName(self):
file_path = filedialog.asksaveasfilename(title="Open Configuration File", filetypes=[("CFG files", "*.cfg")], defaultextension='cfg', initialdir=self.startDir)
Expand All @@ -251,19 +251,7 @@ def SaveMASpatialFcnConfigFName(self):

# Save MA Unique UK Config file
cfgFile = os.path.join(self.root,'Configuration', 'Interpolation', 'UK_MA.cfg')
with open(cfgFile, 'w') as f:
f.write('# Set inputs for universal kriging\n')
f.write('Kriging variogram form = '+self.formMACombo.get()+'\n')
f.write('#\n')
f.write('# Configuration files are expected to be in the Configuration directory\n')
f.write('#\n')
f.write('NLS Spatial Fcn File Name = '+self.spatMACfgFile.myEntry.get()+'\n')
f.write('#\n')
f.write('# Save interim data by writing out supporting data files\n')
f.write('#\n')
f.write('Save Data = F\n')
f.close()

self.parent.CloseUKConfig(cfgFile, self.formMACombo.get(), self.spatMACfgFile.myEntry.get())

def SaveGBSpatialFcnConfigFName(self):
file_path = filedialog.asksaveasfilename(title="Open Configuration File", filetypes=[("CFG files", "*.cfg")], defaultextension='cfg', initialdir=self.startDir)
Expand All @@ -275,18 +263,7 @@ def SaveGBSpatialFcnConfigFName(self):

# Save GB Unique UK Config file
cfgFile = os.path.join(self.root,'Configuration', 'Interpolation', 'UK_GB.cfg')
with open(cfgFile, 'w') as f:
f.write('# Set inputs for universal kriging\n')
f.write('Kriging variogram form = '+self.formGBCombo.get()+'\n')
f.write('#\n')
f.write('# Configuration files are expected to be in the Configuration directory\n')
f.write('#\n')
f.write('NLS Spatial Fcn File Name = '+self.spatGBCfgFile.myEntry.get()+'\n')
f.write('#\n')
f.write('# Save interim data by writing out supporting data files\n')
f.write('#\n')
f.write('Save Data = F\n')
f.close()
self.parent.CloseUKConfig(cfgFile, self.formGBCombo.get(), self.spatGBCfgFile.myEntry.get())

#--------------------------------------------------------------------------------------------------
##
Expand Down Expand Up @@ -514,19 +491,21 @@ def pop_up(self):
This is the name of the file used to hold the spatial function definitions.
It is saved in the UK Configuration file.
SPECIAL NOTE: When processing AL domain, two additional boxes will appear
SPECIAL NOTE: When processing AL domain, two additional boxes will appear.
Load, save these files to also setup UK_MA and UK_MB to desired UK settings
MA Parameters:
MA Spatial Fcn: 'SpatialFcnsMA.cfg'
Is used to interpolate data points within the MA region.
The user can load this file, change the setting, and then save to a
different file to preserve installed file.
different file to preserve installed file, keep it the same.
GB Parameters:
GB Spatial Fcn: 'SpatialFcnsGB.cfg'
Is used to interpolate data points within the GB region.
The user can load this file, change the setting, and then save to a
different file to preserve installed file.
different file to preserve installed file, keep it the same.
UK_MA.cfg, UK_GB.cfg:
These file names are not configurable. The GUI will save the config
Expand Down
27 changes: 25 additions & 2 deletions PythonScripts/GUI/GeoSAM/MainInputFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,20 @@ def __init__(self, container, friend, tsPerYear, selectedOutputs):
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
interpFrame = ttk.LabelFrame(self, text='Interpolation Configuration Files', style='SAMS.TFrame')
self.ukCfgFile = SubFrameElement(self, interpFrame, 'UK Config File', 'UK.cfg', 0, 0, 1, width=20)
self.openUKConfigtButton = ttk.Button(interpFrame, text='Change/Save UK File', style="BtnBluGrn.TLabel", command=self.GetUKConfigFName)
self.openUKConfigtButton.grid(row=0, column=3)
self.openUKConfigButton = ttk.Button(interpFrame, text='Change/Save UK File', style="BtnBluGrn.TLabel", command=self.GetUKConfigFName)
self.openUKConfigButton.grid(row=0, column=3)
#-------------------------------------------------------------------------------------------
self.useSaturateLabel = ttk.Label(interpFrame, text='Use Saturate')
self.useSaturateLabel.grid(row=1, column=0)
#-------------------------------------------------------------------------------------------
self.useSaturateCombo = ttk.Combobox(interpFrame, width=3, values=['T', 'F'])
self.useSaturateCombo.current(1)
self.useSaturateCombo.grid(row=1, column=1, sticky='n')
#-------------------------------------------------------------------------------------------
self.saturateThresh = SubFrameElement(self, interpFrame, 'Saturate\nThreshold', '1E309', 2, 0, 1, width=10)
#-------------------------------------------------------------------------------------------
interpFrame.grid(row=2, column=0, padx=5, sticky='n')

# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
recruitFrame = ttk.LabelFrame(self, text='Recruitment', style='SAMS.TFrame')
Expand Down Expand Up @@ -327,6 +338,18 @@ def pop_up(self):
namely the form selected. The remaining data is kept in the
Spatial Fcn Config File
Saturate
Interpolation can sometimes create excessively large values.
To bypass, Use Saturate can be T or F, but set a larger threshold,
i.e. 1E309 (Infinity).
The user can choose to saturate to the threshold, (T), or
reset the value to 0.0 when exceeded, (F).
Saturate Threshold
Threshold value to use
Use Saturate = T, if field > Threshold then field = Threshold
Use Saturate = F, if field > Threshold then field = 0.0
Output Selection
Selects the desired outputs to be analyzed.
Checkboxes allow the user to select the desired parameters of interest.
Expand Down
Loading

0 comments on commit 9b98824

Please sign in to comment.