# ---------------------------------------------------------------------------- # This software is in the public domain, furnished "as is", without technical # support, and with no warranty, express or implied, as to its usefulness for # any purpose. # # ILN_SkyTool # # Author: Jim Lott WFO ILN # ---------------------------------------------------------------------------- # This tool is designed to compute sky cover from model layer RH. It will # convert Percent RH to Percent Sky Cover from 850 mb, 700 mb, 500 mb, and # 300 mb. The user is given the option to select which levels to use and # how much weight to give to each level. The total from each level can be # added together or averaged out depending on what option the user selects. # The percentage of cloud cover selected is multiplied by the layer RH value. # For example 50 percent of an 80 percent RH would give you a 40 percent sky # cover. You can also use just one level by zeroing out all other levels. WeatherElementEdited = "Sky" ToolType = "numeric" from Numeric import * from Tkinter import * import SmartScript VariableList = [ ('Model' , 'Eta80', 'radio', ['Eta12', 'Eta80', 'NGM80', 'RUC80', 'GFS80', 'gfsLR', 'DGEX']), ('Summation or Average' , 'Summation', 'radio', ['Display Sum of All Levels', 'Display Average of All Non-Zero Levels']), ("900 mb RH to convert to cloud cover 0% <--> 100% " , 0, "scale", [0,100]), ("850 mb RH to convert to cloud cover 0% <--> 100% " , 0, "scale", [0,100]), ("700 mb RH to convert to cloud cover 0% <--> 100% " , 0, "scale", [0,100]), ("500 mb RH to convert to cloud cover 0% <--> 100% " , 0, "scale", [0,100]), ("300 mb RH to convert to cloud cover 0% <--> 100% " , 0, "scale", [0,100]), ] class Tool (SmartScript.SmartScript): def __init__(self, dbss): SmartScript.SmartScript.__init__(self, dbss) def execute(self, GridTimeRange, varDict): "Sky from Layer RH" mod = varDict["Model"] weight900 = varDict["900 mb RH to convert to cloud cover 0% <--> 100% "] weight850 = varDict["850 mb RH to convert to cloud cover 0% <--> 100% "] weight700 = varDict["700 mb RH to convert to cloud cover 0% <--> 100% "] weight500 = varDict["500 mb RH to convert to cloud cover 0% <--> 100% "] weight300 = varDict["300 mb RH to convert to cloud cover 0% <--> 100% "] sum_avg = varDict["Summation or Average"] num = 5 if weight900 == 0: num = num -1 if weight850 == 0: num = num -1 if weight700 == 0: num = num -1 if weight500 == 0: num = num -1 if weight300 == 0: num = num -1 if mod == "Eta80": RH900 = self.getGrids("ILN_D2D_Eta80", "rh","MB900", GridTimeRange) RH850 = self.getGrids("ILN_D2D_Eta80", "rh","MB850", GridTimeRange) RH500 = self.getGrids("ILN_D2D_Eta80", "rh","MB500", GridTimeRange) RH700 = self.getGrids("ILN_D2D_Eta80", "rh","MB700", GridTimeRange) RH300 = self.getGrids("ILN_D2D_Eta80", "rh","MB300", GridTimeRange) if mod == "NGM80": RH900 = self.getGrids("ILN_D2D_NGM80", "rh","MB900", GridTimeRange) RH850 = self.getGrids("ILN_D2D_NGM80", "rh","MB850", GridTimeRange) RH500 = self.getGrids("ILN_D2D_NGM80", "rh","MB500", GridTimeRange) RH700 = self.getGrids("ILN_D2D_NGM80", "rh","MB700", GridTimeRange) RH300 = self.getGrids("ILN_D2D_NGM80", "rh","MB300", GridTimeRange) if mod == "GFS80": if weight900 != 0: RH900 = self.getGrids("ILN_D2D_GFS80", "rh","MB900", GridTimeRange) RH850 = self.getGrids("ILN_D2D_GFS80", "rh","MB850", GridTimeRange) RH500 = self.getGrids("ILN_D2D_GFS80", "rh","MB500", GridTimeRange) RH700 = self.getGrids("ILN_D2D_GFS80", "rh","MB700", GridTimeRange) RH300 = self.getGrids("ILN_D2D_GFS80", "rh","MB300", GridTimeRange) RH900 = RH850 if mod == "gfsLR": if weight900!= 0: RH900 = self.getGrids("ILN_D2D_gfsLR", "rh","MB900", GridTimeRange) RH850 = self.getGrids("ILN_D2D_gfsLR", "rh","MB850", GridTimeRange) RH500 = self.getGrids("ILN_D2D_gfsLR", "rh","MB500", GridTimeRange) RH700 = self.getGrids("ILN_D2D_gfsLR", "rh","MB700", GridTimeRange) RH300 = self.getGrids("ILN_D2D_gfsLR", "rh","MB300", GridTimeRange) RH900 = RH850 * 0 if mod == "Eta12": RH900 = self.getGrids("ILN_D2D_Eta12", "rh","MB900", GridTimeRange) RH850 = self.getGrids("ILN_D2D_Eta12", "rh","MB850", GridTimeRange) RH500 = self.getGrids("ILN_D2D_Eta12", "rh","MB500", GridTimeRange) RH700 = self.getGrids("ILN_D2D_Eta12", "rh","MB700", GridTimeRange) RH300 = self.getGrids("ILN_D2D_Eta12", "rh","MB300", GridTimeRange) if mod == "DGEX": RH850 = self.getGrids("ILN_D2D_DGEX", "rh","MB850", GridTimeRange) RH500 = self.getGrids("ILN_D2D_DGEX", "rh","MB500", GridTimeRange) RH700 = self.getGrids("ILN_D2D_DGEX", "rh","MB700", GridTimeRange) RH900 = 0 RH300 = 0 if mod == "RUC80": RH900 = self.getGrids("ILN_D2D_RUC80", "rh","MB900", GridTimeRange) RH850 = self.getGrids("ILN_D2D_RUC80", "rh","MB850", GridTimeRange) RH500 = self.getGrids("ILN_D2D_RUC80", "rh","MB500", GridTimeRange) RH700 = self.getGrids("ILN_D2D_RUC80", "rh","MB700", GridTimeRange) RH300 = self.getGrids("ILN_D2D_RUC80", "rh","MB300", GridTimeRange) if sum_avg == "Display Sum of All Levels": SkyTot = ((RH900 * weight900/100) + (RH850 * weight850/100) + (RH700 * weight700/100) + (RH500 * weight500/100)+ (RH300 * weight300/100)) if sum_avg == "Display Average of All Non-Zero Levels": SkyTot = ((RH900 * weight900/100) + (RH850 * weight850/100) + (RH700 * weight700/100) + (RH500 * weight500/100)+ (RH300 * weight300/100))/num return SkyTot