# ----------------------------------------------------------------------------
# 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.
#
# ForecastBuilderConfig - Version 10.7
#
# Author: ForecastBuilder Tech Working Group - nws.forecastbuilder@noaa.gov
#
# Please reference documentation within this file, as well as the ForecastBuilder
# documentation and configuration spreadsheet
#
# ----------------------------------------------------------------------------

import SmartScript


class ForecastBuilderConfig(SmartScript.SmartScript):
    def __init__(self, dbss):
        SmartScript.SmartScript.__init__(self, dbss)
        self._dbss = dbss

    def Local_Configuration(self, varDict, gridDef, var="varDict"):
        ##################################################################################
        # This is the local configuration section for ForecastBuilder. It has two
        # sections, varDict and gridDef.  Using this style of configuration allows for less
        # frequent config file updates and hence less need for you to merge this file with
        # updates in future builds. Also, it reduces code clutter in the main
        # ForecastBuilder procedure & utility.
        #
        # There are two sections: varDict and gridDef.
        #
        # Think of varDict as general FB settings such as on/off switches (True/False)
        # and lists you can add to.  Meanwhile, gridDef is for defining grid-specific
        # settings, such as changing the default grid length for an element.
        #
        # The configuration of ForecastBuilder is run in the following way:
        # 1) FB-wide default values of varDict are defined in the main
        #    ForecastBuilderNationalConfig file.
        # 2) Each region has an area where the defaults can be overridden called
        #    ForecastBuilderRegionalConfig
        # 3) This present file, ForecastBuilderConfig is called.  This is done first for
        #    varDict and then for gridDef
        #
        # There should be minimal configurations in this file, as the procedure and
        # regional configurations should handle most of the configuration. Consider
        # interoffice consistency implications with any additions made here.
        ##################################################################################
        #
        if var == "varDict":
            #
            # Put varDict local configuration in here. These options can be found in the
            # ForecastBuilderNationalConfig and RegionalConfig files.
            #

            ## Common examples of locally-configured items.
            varDict["Default PType Method"] = "NBM SnowLevel"
            # varDict["Other Possible PType Methods"] = [
            #     "SnowLevel & ProbIcePresent",
            #     "NBM",
            # ]
            # varDict["Hide Ice or Sleet in Step 4"] = False
            # varDict["Interpolate After Populating"] = True
            # varDict["Use Local Time Scale Periods"] = True
            # varDict["Stratiform or Showery Precipitation?"] = "Shower"
            # varDict["Include ESTF"] = True
            # # Set to True if your office populates these elements in the day 4-7 period.
            # varDict["Have QPF and Accum grids in Extended"] = True
            # # If your office would like to populate Aviation grids as part of the Foundation
            # # Grids Step in ForecastBuilder
            # varDict["Include Aviation"] = True
            # # If your office would like to create FireWx grids as part of ForecastBuilder
            # varDict["Include Fire"] = True
            # varDict["Include GHWO"] = True
            # varDict["EditRetention_automaticColor"] = "DarkGreen"
            # varDict["EditRetention_editedColor"] = "Yellow"
            # varDict["EditRetention_manualColor"] = "Red"
            # varDict["CRON_thru_WX"] = True
            ## Example fire weather entries from the Pueblo office.
            # varDict["Possible-Fire Wx: Calculate from GFE/D2D grids?"].extend(
            #     [
            #         "Haines",
            #         "CWR",
            #         "LAL",
            #         "Free Air/Ridge Top Winds",
            #         "Critical Fire Weather Potential",
            #     ]
            # )
            # varDict["Fire Wx:Calculate from GFE/D2D grids?"].extend(
            #     [
            #         "Haines",
            #         "CWR",
            #         "LAL",
            #         "Free Air/Ridge Top Winds",
            #         "Critical Fire Weather Potential",
            #     ]
            varDict["Additional Buttons in Analyze/Adjust Step"].append([
                    [
                        "Load FzLevel",
                        [
                            "self._FBUtility",
                            "callSmartToolFB",
                            ["SnowLevel","loadFzLevel","var|varDict", "var|gridDict"],
                        ],
           
                    ],                    
                ])
            # Set to True to utilize NBM PPI06 grids for 6 hourly PoP
            varDict["6 Hourly PoP from NBM PPI06"] = True
            varDict["Include Marine"] = False


            pass

        elif var == "gridDef":
            #
            # Put gridDefs local configuration in here. Documentation for gridDef settings
            # can be found in the ForecastBuilderNatioanlConfig file.
            #

            # Example of smoothing over an edit area representing a lake
            # for grids in ["T", "Td", "MaxT", "MinT"]:
            #     gridDef[grids, "smoothFactor", "EditArea"] = "NBMLakes"
            #     gridDef[grids, "smoothFactor", "Factor"] = "10"

            # Example of setting the snow preview feature in Step 2 to use the local
            # SnowAmt grid:
            # gridDef["SnowAmtPre", "gridName"] = "SnowAmt"

            # Example of changing the grid lengths for several elements, and changing the
            # sample method for Wind.
            # for grids in [
            #     "T",
            #     "Td",
            #     "RH",
            #     "PotRain",
            #     "PotSnow",
            #     "PotSleet",
            #     "PotFreezingRain",
            #     "SnowRatio",
            #     "SnowLevel",
            # ]:
            #     gridDef[grids, "gridDefinition"] = [
            #         ["Extended", "Extended", 0, 3 * 3600, 3 * 3600]
            #     ]
            #     gridDef[grids, "mode"] = "Max"
            #     if grids == "Wind":
            #         gridDef[grids, "mode"] = "AverageWindSpeed"

            # Example fire weather entries from the Pueblo office.
            # gridDef["MixHgt", "maxTime"] = "Day 3"
            # gridDef["Haines", "function"] = "HainesFromModelData"
            # gridDef["Haines", "hainesType"] = "HIGH"
            # gridDef["Haines", "models"] = ["NAM12", "GFS"]
            # gridDef["LAL", "LALPotThunderList"] = [10, 15, 25, 55]
            # gridDef["CWR", "WettingRangeQPF"] = 0.10
            
            #Sky grids using NBM 4.2 experimental as primary, with operational NBM as backup. This should limit the 57% sky cover issues.
            # gridDef["Sky", "primaryGuidance"] = "NBMEXP"
            # gridDef["Sky", "secondaryGuidance"] = "NBM"
            gridDef["SnowRatio","primaryGuidance"] = "WPCGuide"
            gridDef["SnowRatio","secondaryGuidance"] = "NBM"
            pass
        else:
            print(f"Need a definition for var: {var}")

