Beispiel #1
0
    def __init__(self, geo_input_path, condition, *unit_system):

        # general directories and parameters
        self.cache = config.dir2sh + ".cache\\"
        self.condition = condition
        self.dir_in_geo = geo_input_path
        self.path_hsi = config.dir2sh + "HSI\\" + str(condition) + "\\"
        self.error = False
        self.flow_dict_h = {}
        self.flow_dict_u = {}
        self.fish = cFi.Fish()
        self.logger = logging.getLogger("logfile")
        self.raster_dict = {}
        self.ras_h = []
        self.ras_u = []

        fGl.chk_dir(self.cache)
        fGl.clean_dir(self.cache)
        fGl.chk_dir(self.path_hsi)
        fGl.chk_dir(self.dir_in_geo)

        # set unit system variables
        try:
            self.units = unit_system[0]
        except:
            self.units = "us"
            print("WARNING: Invalid unit_system identifier. unit_system must be either \'us\' or \'si\'.")
            print("         Setting unit_system default to \'us\'.")
Beispiel #2
0
 def make_fish_menu(self):
     # rebuild = True -> rebuilt menu mode
     if not self.rebuild_fish_menu:
         # initial menu construction
         sys.path.append(config.dir2ripy)
         try:
             import cFish as cFi
             self.fish = cFi.Fish()
         except:
             showinfo(
                 "ERROR",
                 "Invalid directory to RiverArchitect/.site_packages/riverpy/."
             )
             return -1
         self.fishmenu.entryconfig(0,
                                   label="EDIT FISH",
                                   command=lambda: self.fish.edit_xlsx())
         self.fishmenu.add_command(label="RE-BUILD FISH MENU",
                                   command=lambda: self.make_fish_menu())
         self.fishmenu.add_command(label="_____________________________")
         self.fishmenu.add_command(label="ALL",
                                   command=lambda: self.set_fish("all"))
         self.fishmenu.add_command(label="CLEAR ALL",
                                   command=lambda: self.set_fish("clear"))
         self.fishmenu.add_command(label="_____________________________")
         for f_spec in self.fish.species_dict.keys():
             lf_stages = self.fish.species_dict[f_spec]
             for lf_stage in lf_stages:
                 entry = str(f_spec) + " - " + str(lf_stage)
                 self.fishmenu.add_command(
                     label=entry,
                     command=lambda arg1=f_spec, arg2=lf_stage: self.
                     set_fish(arg1, arg2))
         self.rebuild_fish_menu = True
     else:
         self.fish.assign_fish_names()
         entry_count = 6
         for f_spec in self.fish.species_dict.keys():
             lf_stages = self.fish.species_dict[f_spec]
             for lf_stage in lf_stages:
                 entry = str(f_spec) + " - " + str(lf_stage)
                 self.fishmenu.entryconfig(
                     entry_count,
                     label=entry,
                     command=lambda arg1=f_spec, arg2=lf_stage: self.
                     set_fish(arg1, arg2))
                 entry_count += 1
Beispiel #3
0
 def __init__(self, input_xlsx, *args, **kwargs):
     # input_xlsx = STR full path of an input xlsx file
     # functionality:
     # 1) instantiate object
     # 2) assign fish species with self.get_fish_seasons and run self.make_flow_duration() for each species/lifestage
     self.export_dict = {}
     self.fish = cFi.Fish()
     self.fish_seasons = {}
     self.date_column = []
     self.flow_column = []
     self.flow_matrix = []  # rows=n-days, cols=m-years
     self.season_flow_lists = {}
     self.logger = logging.getLogger("logfile")
     self.min_year = 9999
     self.max_year = 1
     self.season_years = int()
     self.xlsx_template = config.dir2ra + "00_Flows\\templates\\flow_duration_template.xlsx"
     self.disc_xlsx_template = config.dir2ra + "00_Flows\\templates\\disc_freq_template.xlsx"
     self.read_flow_series(input_xlsx)
    def __init__(self, condition, species, lifestage, units, *args, **kwargs):
        self.logger = logging.getLogger("logfile")
        self.cache = config.dir2co + ".cache%s\\" % str(
            random.randint(1000000, 9999999))
        fGl.chk_dir(self.cache)
        arcpy.env.workspace = self.cache
        arcpy.env.overwriteOutput = True
        self.condition = condition
        self.dir2condition = config.dir2conditions + self.condition + "\\"

        self.units = units
        self.q_units = 'cfs' if self.units == "us" else 'm^3/s'
        self.length_units = 'ft' if self.units == "us" else 'm'
        self.u_units = self.length_units + '/s'
        self.area_units = self.length_units + '^2'

        self.species = species
        self.lifestage = lifestage
        self.lifestage_code = self.species.lower()[:2] + self.lifestage.lower(
        )[:2]
        # read in fish data (minimum depth needed, max swimming speed, ...)
        self.h_min = cFi.Fish().get_travel_threshold(self.species,
                                                     self.lifestage, "h_min")
        self.logger.info("minimum swimming depth = %s %s" %
                         (self.h_min, self.length_units))
        self.u_max = cFi.Fish().get_travel_threshold(self.species,
                                                     self.lifestage, "u_max")
        self.logger.info("maximum swimming speed  = %s %s" %
                         (self.u_max, self.u_units))
        self.analyze_v = True

        try:
            self.method = kwargs['method']
        except:
            self.method = "IDW"

        try:
            self.out_dir = args[0]
        except:
            self.out_dir = config.dir2co + "Output\\" + self.condition + "\\"

        fGl.chk_dir(self.out_dir)
        # these directories don't depend on applied flow reduction, share with other runs
        self.h_interp_dir = os.path.join(self.out_dir, "h_interp\\")
        fGl.chk_dir(self.h_interp_dir)
        self.u_interp_dir = os.path.join(self.out_dir, "u_interp\\")
        fGl.chk_dir(self.u_interp_dir)
        self.va_interp_dir = os.path.join(self.out_dir, "va_interp\\")
        fGl.chk_dir(self.va_interp_dir)

        try:
            self.q_high = kwargs['q_high']
            self.q_low = kwargs['q_low']
            self.out_dir = os.path.join(
                self.out_dir, "flow_red_%06d_%06d" % (self.q_high, self.q_low))
        except:
            self.q_high = self.q_low = None

        try:
            self.dt = kwargs['dt']
        except:
            self.dt = None

        fGl.chk_dir(self.out_dir)
        # these directories depend on applied flow reduction
        self.shortest_paths_dir = os.path.join(self.out_dir,
                                               "shortest_paths\\")
        fGl.chk_dir(self.shortest_paths_dir)
        self.areas_dir = os.path.join(self.out_dir, "areas\\")
        fGl.chk_dir(self.areas_dir)
        self.disc_areas_dir = os.path.join(self.out_dir, "disc_areas\\")
        fGl.chk_dir(self.disc_areas_dir)
        # populated by self.get_hydraulic_rasters()
        self.discharges = []
        self.Q_h_dict = {}
        self.Q_u_dict = {}
        self.Q_va_dict = {}
        # populated by self.get_interpolated_rasters()
        self.Q_h_interp_dict = {}
        self.Q_u_interp_dict = {}
        self.Q_va_interp_dict = {}
        # populated by self.get_hsi_rasters()
        self.Q_chsi_dict = {}
        # populated by self.make_shortest_paths_map(Q)
        self.Q_escape_dict = {}
        # populated by self.disconnected_areas(Q)
        self.Q_disc_areas_dict = {}
        # populated by self.make_disconnect_Q_map()
        self.target = ''

        self.xlsx = os.path.join(self.out_dir, "disconnected_area.xlsx")
        self.xlsx_writer = cIO.Write(config.xlsx_connectivity)
        self.xlsx_writer.write_cell("E", 4, self.species)
        self.xlsx_writer.write_cell("E", 5, self.lifestage)
        self.xlsx_writer.write_cell("E", 6, self.h_min)
        self.xlsx_writer.write_cell("E", 7, self.u_max)

        self.get_hydraulic_rasters()
        self.get_interpolated_rasters()
        self.get_hsi_rasters()
        self.get_target_raster()
Beispiel #5
0
    def __init__(self, from_master):
        sg.RaModuleGui.__init__(self, from_master)
        self.ww = 800  # window width
        self.wh = 840  # window height
        self.title = "SHArC"
        self.set_geometry(self.ww, self.wh, self.title)

        self.bound_shp = ""  # full path of a boundary shapefile
        self.combine_method = "geometric_mean"
        self.dir_conditions = config.dir2sh + "HSI\\"
        self.dir_inp_hsi_hy = ""
        self.dir_inp_hsi_cov = ""
        self.chsi_condition_hy = ""
        self.chsi_condition_cov = ""
        self.condition_list = fGl.get_subdir_names(self.dir_conditions)
        self.cover_applies = False
        self.fish = cFi.Fish()
        self.fish_applied = {}
        self.max_columnspan = 5
        self.sharea_threshold = 0.5
        self.side_pnl_width = 15
        self.xlsx_condition = []

        self.apply_boundary = tk.BooleanVar()
        self.apply_wua = tk.BooleanVar()
        self.external_flow_series = tk.BooleanVar()
        self.cover_applies_sharea = tk.BooleanVar()

        # LABELS
        self.l_side_bar = tk.Label(self,
                                   text="",
                                   bg="white",
                                   height=55,
                                   width=self.side_pnl_width + self.xd)
        self.l_side_bar.grid(sticky=tk.W,
                             row=0,
                             rowspan=30,
                             column=self.max_columnspan,
                             padx=self.xd,
                             pady=self.yd)
        self.l_aqua = tk.Label(self,
                               fg="firebrick3",
                               text="Select Physical Habitat (at least one)")
        self.l_aqua.grid(sticky=tk.W,
                         row=0,
                         column=0,
                         columnspan=2,
                         padx=self.xd,
                         pady=self.yd)
        self.l_combine = tk.Label(self, text="Select HSI combination method: ")
        self.l_combine.grid(sticky=tk.W,
                            row=2,
                            column=0,
                            columnspan=1,
                            padx=self.xd,
                            pady=self.yd)
        tk.Label(self, text="").grid(sticky=tk.W, row=3, column=0)  # dummy

        imsg = "\n(Use \'Make HSI Rasters\' menu to create habitat conditions)"
        self.l_condition_hy = tk.Label(
            self,
            justify=tk.LEFT,
            fg="cyan4",
            text="Hydraulic habitat conditions (no cover):" + imsg)
        self.l_condition_hy.grid(sticky=tk.W,
                                 row=4,
                                 rowspan=3,
                                 column=0,
                                 columnspan=2,
                                 padx=self.xd,
                                 pady=self.yd)
        self.l_inpath_hy = tk.Label(self,
                                    justify=tk.LEFT,
                                    fg="cyan4",
                                    text="Source: " + str(self.dir_conditions))
        self.l_inpath_hy.grid(sticky=tk.W,
                              row=7,
                              column=0,
                              columnspan=self.max_columnspan + 1,
                              padx=self.xd,
                              pady=self.yd)
        tk.Label(self, text="").grid(sticky=tk.W, row=9, column=0)  # dummy
        self.l_condition_hy["state"] = "disabled"
        self.l_inpath_hy["state"] = "disabled"

        self.l_condition_cov = tk.Label(self,
                                        justify=tk.LEFT,
                                        fg="gold4",
                                        text="Cover habitat conditions:" +
                                        imsg)
        self.l_condition_cov.grid(sticky=tk.W,
                                  row=10,
                                  rowspan=3,
                                  column=0,
                                  columnspan=2,
                                  padx=self.xd,
                                  pady=self.yd)
        self.l_inpath_cov = tk.Label(self,
                                     justify=tk.LEFT,
                                     fg="gold4",
                                     text="Source: " +
                                     str(self.dir_conditions))
        self.l_inpath_cov.grid(sticky=tk.W,
                               row=13,
                               column=0,
                               columnspan=self.max_columnspan + 1,
                               padx=self.xd,
                               pady=self.yd)
        tk.Label(self, text="").grid(sticky=tk.W, row=15, column=0)  # dummy
        self.l_condition_cov["state"] = "disabled"
        self.l_inpath_cov["state"] = "disabled"

        # DROP DOWN ENTRIES (SCROLL BARS)
        self.sb_condition_hy = tk.Scrollbar(self, orient=tk.VERTICAL)
        self.sb_condition_hy.grid(sticky=tk.W,
                                  row=4,
                                  column=3,
                                  padx=0,
                                  pady=self.yd)
        self.lb_condition_hy = tk.Listbox(
            self, height=3, width=15, yscrollcommand=self.sb_condition_hy.set)
        self.sb_condition_cov = tk.Scrollbar(self, orient=tk.VERTICAL)
        self.sb_condition_cov.grid(sticky=tk.W,
                                   row=10,
                                   column=3,
                                   padx=0,
                                   pady=self.yd)
        self.lb_condition_cov = tk.Listbox(
            self, height=3, width=15, yscrollcommand=self.sb_condition_cov.set)
        self.list_habitat_conditions()

        # CHECK BUTTONS -- determine if geometric mean or product is used
        self.cb_combine_method_gm = tk.Checkbutton(
            self,
            text="Geometric mean",
            variable=self.combine_method,
            onvalue="geometric_mean",
            offvalue="product")
        self.cb_combine_method_gm.grid(sticky=tk.W,
                                       row=2,
                                       column=2,
                                       padx=self.xd,
                                       pady=self.yd)
        self.cb_combine_method_gm.select()
        self.cb_combine_method_pd = tk.Checkbutton(
            self,
            text="Product",
            variable=self.combine_method,
            onvalue="product",
            offvalue="geometric_mean")
        self.cb_combine_method_pd.grid(sticky=tk.W,
                                       row=2,
                                       column=3,
                                       columnspan=2,
                                       padx=self.xd,
                                       pady=self.yd)
        self.cb_bshp = tk.Checkbutton(
            self,
            text="Use calculation boundary (polygon) shapefile",
            variable=self.apply_boundary,
            onvalue=True,
            offvalue=False,
            command=lambda: self.activate_shape_selection(self.b_select_bshp))
        self.cb_bshp.grid(sticky=tk.W,
                          row=1,
                          column=0,
                          columnspan=self.max_columnspan - 1,
                          padx=self.xd,
                          pady=self.yd)
        self.cb_use_cov = tk.Checkbutton(
            self,
            fg="gold4",
            text="Use cover CHSI (requires COVER HSI conditions)",
            variable=self.cover_applies_sharea,
            onvalue=True,
            offvalue=False)
        self.cb_use_cov.grid(sticky=tk.W,
                             row=16,
                             column=0,
                             columnspan=2,
                             padx=self.xd,
                             pady=self.yd)
        self.cb_use_cov["state"] = "disabled"
        # self.cb_use_wua = tk.Checkbutton(self, fg="gold4", text="Use weighted usable area",
        #                                  variable=self.apply_wua,
        #                                  onvalue=True, offvalue=False, command=lambda: self.set_wua())
        # self.cb_use_wua.grid(sticky=tk.W, row=16, column=3, columnspan=2, padx=self.xd,
        #                      pady=self.yd)
        # self.cb_use_wua["state"] = "disabled"

        # BUTTONS
        self.b_show_fish = tk.Button(
            self,
            width=self.side_pnl_width,
            fg="RoyalBlue3",
            bg="white",
            text="Show selected\nPhysical Habitat(s)",
            command=lambda: self.shout_dict(self.fish_applied))
        self.b_show_fish.grid(sticky=tk.EW,
                              row=0,
                              rowspan=2,
                              column=self.max_columnspan,
                              padx=self.xd,
                              pady=self.yd)
        self.b_show_fish["state"] = "disabled"

        self.b_select_bshp = tk.Button(
            self,
            width=8,
            bg="white",
            text="Select file",
            command=lambda: self.select_boundary_shp())
        self.b_select_bshp.grid(sticky=tk.W,
                                row=1,
                                column=self.max_columnspan - 1,
                                padx=self.xd,
                                pady=self.yd)
        self.b_select_bshp["state"] = "disabled"

        self.b_csi_nc = tk.Button(
            self,
            fg="cyan4",
            width=30,
            bg="white",
            text="Combine HSI rasters (pure hydraulic)",
            command=lambda: self.start_app("cHSI", cover=False))
        self.b_csi_nc.grid(sticky=tk.EW,
                           row=8,
                           column=0,
                           columnspan=self.max_columnspan,
                           padx=self.xd,
                           pady=self.yd)
        self.b_csi_nc["state"] = "disabled"

        self.b_csi_c = tk.Button(
            self,
            fg="gold4",
            width=30,
            bg="white",
            text="Combine HSI rasters (hydraulic and cover)",
            command=lambda: self.start_app("cHSI", cover=True))
        self.b_csi_c.grid(sticky=tk.EW,
                          row=14,
                          column=0,
                          columnspan=self.max_columnspan,
                          padx=self.xd,
                          pady=self.yd)
        self.b_csi_c["state"] = "disabled"

        self.b_sharc = tk.Button(
            self,
            width=30,
            bg="white",
            text="Run Seasonal Habitat Area Calculator - SHArC",
            command=lambda: self.start_app("sharea", cover=False))
        self.b_sharc.grid(sticky=tk.EW,
                          row=17,
                          column=0,
                          columnspan=self.max_columnspan,
                          rowspan=2,
                          padx=self.xd,
                          pady=self.yd)
        self.b_sharc["state"] = "disabled"

        self.b_sha_th = tk.Button(
            self,
            width=self.side_pnl_width,
            fg="RoyalBlue3",
            bg="white",
            text="Set SHArea\nthreshold\nCurrent: CHSI = " +
            str(self.sharea_threshold),
            command=lambda: self.set_sharea())
        self.b_sha_th.grid(sticky=tk.EW,
                           row=16,
                           rowspan=4,
                           column=self.max_columnspan,
                           padx=self.xd,
                           pady=self.yd)
        self.b_sha_th["state"] = "disabled"

        # Q-UA analyses section
        tk.Label(self, text="").grid(sticky=tk.W,
                                     row=18,
                                     column=0,
                                     columnspan=self.max_columnspan)  # dummy
        tk.Label(self, text="", bg="LightBlue1",
                 height=10).grid(sticky=tk.EW,
                                 row=19,
                                 rowspan=6,
                                 column=0,
                                 columnspan=self.max_columnspan)  # dummy
        self.l_qua = tk.Label(self, text="Q -  Area Analysis", bg="LightBlue1")
        self.l_qua.grid(sticky=tk.NW,
                        row=19,
                        column=0,
                        columnspan=self.max_columnspan,
                        padx=self.xd,
                        pady=self.yd)
        self.cb_extq = tk.Checkbutton(self,
                                      text="Use other flow duration curve",
                                      variable=self.external_flow_series,
                                      onvalue=True,
                                      offvalue=False,
                                      bg="LightBlue1")
        self.cb_extq.grid(sticky=tk.W,
                          row=20,
                          column=0,
                          columnspan=self.max_columnspan,
                          padx=self.xd,
                          pady=self.yd)
        self.cb_extq.deselect()
        self.b_qua = tk.Button(
            self,
            bg="LightBlue1",
            text="Discharge - Physical Habitat Area Curve",
            command=lambda: self.make_qua(input_type="statistic"))
        self.b_qua.grid(sticky=tk.EW,
                        row=21,
                        column=0,
                        columnspan=1,
                        padx=self.xd,
                        pady=self.yd)
        self.b_quat = tk.Button(
            self,
            bg="LightBlue1",
            text="Time series - Physical Habitat Area",
            command=lambda: self.make_qua(input_type="time_series"))
        self.b_quat.grid(sticky=tk.EW,
                         row=21,
                         column=2,
                         columnspan=2,
                         padx=self.xd,
                         pady=self.yd)
        self.b_qua["state"] = "disabled"
        self.b_quat["state"] = "disabled"

        self.complete_menus()
    def __init__(self, master):
        top = self.top = tk.Toplevel(master)
        self.condition = ""
        self.condition_list = fGl.get_subdir_names(config.dir2conditions)
        self.dir2condition_act = '.'
        self.dir2dem = ''
        self.dir2h = ''
        self.dir2u = ''
        self.eco_flow_type = cFi.Fish()
        self.eco_flow_type_applied = {}
        self.eco_flow_type_list = []
        self.flows_xlsx = ''
        self.flow_series_xlsx = None
        self.logger = logging.getLogger("logfile")

        # define analysis type identifiers (default = False)
        self.bool_var = tk.BooleanVar()
        self.top.iconbitmap(config.code_icon)

        # ARRANGE GEOMETRY
        # width and height of the window.
        ww = 590
        wh = 370
        self.xd = 5  # distance holder in x-direction (pixel)
        self.yd = 5  # distance holder in y-direction (pixel)
        # height and location
        wx = (self.top.winfo_screenwidth() - ww) / 2
        wy = (self.top.winfo_screenheight() - wh) / 2
        self.top.geometry("%dx%d+%d+%d" % (ww, wh, wx, wy))
        self.top.title("Analyze Discharge")  # window title

        self.col_0_width = 25

        # Set Condition
        self.l_0 = tk.Label(top, text="1) Analyze a Condition")
        self.l_0.grid(sticky=tk.W,
                      row=0,
                      column=0,
                      columnspan=2,
                      padx=self.xd,
                      pady=self.yd)
        self.l_name = tk.Label(top, text="Select condition: ")
        self.l_name.grid(sticky=tk.W,
                         row=1,
                         rowspan=3,
                         column=0,
                         padx=self.xd,
                         pady=self.yd)
        self.sb_condition = tk.Scrollbar(top, orient=tk.VERTICAL)
        self.sb_condition.grid(sticky=tk.W,
                               row=1,
                               column=2,
                               padx=0,
                               pady=self.yd)
        self.lb_condition = tk.Listbox(top,
                                       height=3,
                                       width=15,
                                       yscrollcommand=self.sb_condition.set)
        for ce in self.condition_list:
            self.lb_condition.insert(tk.END, ce)
        self.lb_condition.grid(sticky=tk.EW,
                               row=1,
                               column=1,
                               padx=0,
                               pady=self.yd)
        self.sb_condition.config(command=self.lb_condition.yview)
        self.b_sc = tk.Button(top,
                              width=self.col_0_width - 5,
                              fg="firebrick3",
                              bg="white",
                              text="Analyze",
                              command=lambda: self.scan_condition())
        self.b_sc.grid(sticky=tk.E,
                       row=1,
                       rowspan=3,
                       column=2,
                       padx=self.xd,
                       pady=self.yd)
        self.l_c_dir = tk.Label(
            top,
            fg="firebrick3",
            text="Select a condition and press \'Analyze\'.")
        self.l_c_dir.grid(sticky=tk.W,
                          row=4,
                          column=0,
                          columnspan=4,
                          padx=self.xd,
                          pady=self.yd)
        tk.Label(top, text="").grid(sticky=tk.W, row=5, column=0)  # dummy

        # 02 Make input file for condition
        self.l_1 = tk.Label(top, text="2) Generate Flow Duration Curves")
        self.l_1.grid(sticky=tk.W,
                      row=6,
                      column=0,
                      columnspan=2,
                      padx=self.xd,
                      pady=self.yd)
        self.b_mod = tk.Button(top,
                               bg="white",
                               text="Modify Source",
                               command=lambda: self.modify_eco_flow_source())
        self.b_mod.grid(sticky=tk.E,
                        row=6,
                        column=2,
                        padx=self.xd,
                        pady=self.yd)
        self.l_s_type = tk.Label(top, text="Add season / target species: ")
        self.l_s_type.grid(sticky=tk.W,
                           row=7,
                           rowspan=3,
                           column=0,
                           padx=self.xd,
                           pady=self.yd)
        self.sb_type = tk.Scrollbar(top, orient=tk.VERTICAL)
        self.sb_type.grid(sticky=tk.W, row=7, column=2, padx=0, pady=self.yd)
        self.lb_type = tk.Listbox(top,
                                  height=3,
                                  width=25,
                                  yscrollcommand=self.sb_type.set)
        self.lb_type.grid(sticky=tk.EW, row=7, column=1, padx=0, pady=self.yd)
        self.make_eco_type_list(rebuild=False)
        self.b_sct = tk.Button(top,
                               fg="firebrick3",
                               width=self.col_0_width - 5,
                               bg="white",
                               text="Add",
                               command=lambda: self.select_eco_type())
        self.b_sct.grid(sticky=tk.E,
                        row=7,
                        rowspan=3,
                        column=2,
                        padx=self.xd,
                        pady=self.yd)
        self.l_ct_dir = tk.Label(top,
                                 text="Current selection: {0}".format(
                                     fGl.print_dict(
                                         self.eco_flow_type_applied)))
        self.l_ct_dir.grid(sticky=tk.W,
                           row=10,
                           column=0,
                           columnspan=4,
                           padx=self.xd,
                           pady=self.yd)

        self.b_q_inp = tk.Button(
            top,
            width=self.col_0_width * 2,
            fg="firebrick3",
            bg="white",
            text="Select input Flow Series",
            command=lambda: self.select_flow_series_xlsx())
        self.b_q_inp.grid(sticky=tk.EW,
                          row=11,
                          column=0,
                          columnspan=2,
                          padx=self.xd,
                          pady=self.yd)

        self.b_q_dur = tk.Button(top,
                                 width=self.col_0_width * 2,
                                 fg="firebrick3",
                                 bg="white",
                                 text="Make flow duration curve(s)",
                                 command=lambda: self.make_flow_duration())
        self.b_q_dur.grid(sticky=tk.EW,
                          row=12,
                          column=0,
                          columnspan=2,
                          padx=self.xd,
                          pady=self.yd)

        self.b_sct["state"] = "disabled"
        self.b_q_inp["state"] = "disabled"
        self.b_q_dur["state"] = "disabled"

        self.b_return = tk.Button(top,
                                  width=self.col_0_width,
                                  fg="RoyalBlue3",
                                  bg="white",
                                  text="RETURN to MAIN WINDOW",
                                  command=lambda: self.gui_quit())
        self.b_return.grid(sticky=tk.E,
                           row=12,
                           column=2,
                           padx=self.xd,
                           pady=self.yd)
    def __init__(self, from_master):
        sg.RaModuleGui.__init__(self, from_master)
        self.ww = 580  # window width
        self.wh = 650  # window height
        self.title = "Stranding Risk"
        self.set_geometry(self.ww, self.wh, self.title)

        self.condition = ""
        self.out_dir = ""
        self.fish = cFi.Fish()
        self.fish_applied = {}

        row = 0

        self.l_prompt = tk.Label(self,
                                 text="Select Condition and Physical Habitat")
        self.l_prompt.grid(sticky=tk.W,
                           row=row,
                           column=0,
                           columnspan=3,
                           padx=self.xd,
                           pady=self.yd)
        row += 1

        # select condition
        self.l_condition = tk.Label(self, text="Select condition:")
        self.l_condition.grid(sticky=tk.W,
                              row=row,
                              column=0,
                              padx=self.xd,
                              pady=self.yd)
        self.combo_c = ttk.Combobox(self)
        self.combo_c.grid(sticky=tk.W,
                          row=row,
                          column=1,
                          padx=self.xd,
                          pady=self.yd)
        self.combo_c['values'] = tuple(
            fGl.get_subdir_names(config.dir2conditions))
        self.combo_c['state'] = 'readonly'
        self.b_s_condition = tk.Button(self,
                                       fg="red",
                                       text="Select",
                                       command=lambda: self.select_condition())
        self.b_s_condition.grid(sticky=tk.W,
                                row=row,
                                column=2,
                                columnspan=2,
                                padx=self.xd,
                                pady=self.yd)
        row += 1

        self.l_inpath_curr = tk.Label(self,
                                      fg="gray60",
                                      text="Source: " + config.dir2conditions)
        self.l_inpath_curr.grid(sticky=tk.W,
                                row=row,
                                column=0,
                                columnspan=3,
                                padx=self.xd,
                                pady=self.yd)
        row += 1

        # select Physical Habitat
        self.b_show_fish = tk.Button(
            self,
            width=10,
            fg="RoyalBlue3",
            bg="white",
            text="Show selected Physical Habitat(s)",
            command=lambda: self.shout_dict(self.fish_applied))
        self.b_show_fish.grid(sticky=tk.EW,
                              row=row,
                              column=0,
                              columnspan=2,
                              padx=self.xd,
                              pady=self.yd)
        self.b_show_fish["state"] = "disabled"
        self.l_aqua = tk.Label(self,
                               fg="red",
                               text="Select Physical Habitat (at least one)")
        self.l_aqua.grid(sticky=tk.W,
                         row=row,
                         column=2,
                         columnspan=2,
                         padx=0,
                         pady=self.yd)
        row += 1

        # Apply flow reduction
        tk.Label(self, text=" ").grid(row=row, column=0, columnspan=4)  # dummy
        row += 1

        tk.Label(self, text="", bg="LightBlue1",
                 height=10).grid(sticky=tk.EW,
                                 row=row,
                                 rowspan=4,
                                 column=0,
                                 columnspan=4)  # dummy
        self.l_flow_red = tk.Label(self,
                                   text="Apply flow reduction",
                                   bg="LightBlue1")
        self.l_flow_red.grid(sticky=tk.W,
                             row=row,
                             column=0,
                             columnspan=4,
                             padx=self.xd,
                             pady=self.yd)
        row += 1

        self.l_q_high = tk.Label(self, text="Q_high:", bg="LightBlue1")
        self.l_q_high.grid(sticky=tk.W,
                           row=row,
                           column=0,
                           padx=self.xd,
                           pady=self.yd)
        self.c_q_high = ttk.Combobox(self)
        self.c_q_high.grid(sticky=tk.W,
                           row=row,
                           column=1,
                           padx=self.xd,
                           pady=self.yd)
        self.c_q_high['state'] = 'disabled'

        self.l_q_low = tk.Label(self, text="Q_low:", bg="LightBlue1")
        self.l_q_low.grid(sticky=tk.W,
                          row=row,
                          column=2,
                          padx=self.xd,
                          pady=self.yd)
        self.c_q_low = ttk.Combobox(self)
        self.c_q_low.grid(sticky=tk.W,
                          row=row,
                          column=3,
                          padx=self.xd,
                          pady=self.yd)
        self.c_q_low['state'] = 'disabled'
        row += 1

        self.l_dt = tk.Label(self, text="Time period (mins):", bg="LightBlue1")
        self.l_dt.grid(sticky=tk.W,
                       row=row,
                       column=0,
                       padx=self.xd,
                       pady=self.yd)
        self.e_dt = tk.Entry(self)
        self.e_dt.grid(sticky=tk.W,
                       row=row,
                       column=1,
                       padx=self.xd,
                       pady=self.yd)

        self.l_interp = tk.Label(self,
                                 text="Interpolation method:",
                                 bg="LightBlue1")
        self.l_interp.grid(sticky=tk.W,
                           row=row,
                           column=2,
                           padx=self.xd,
                           pady=self.yd)
        self.c_interp = ttk.Combobox(self)
        self.c_interp.grid(sticky=tk.W,
                           row=row,
                           column=3,
                           padx=self.xd,
                           pady=self.yd)
        self.c_interp['state'] = 'readonly'
        self.c_interp['values'] = ["IDW", "EBK", "Kriging", "Nearest Neighbor"]
        self.c_interp.set("IDW")

        row += 1

        self.b_apply_flow_red = tk.Button(
            self,
            text="Apply Flow Reduction",
            bg="LightBlue1",
            width=50,
            command=lambda: self.apply_flow_red())
        self.b_apply_flow_red.grid(sticky=tk.W,
                                   row=row,
                                   column=0,
                                   columnspan=4,
                                   padx=self.xd,
                                   pady=self.yd)
        self.b_apply_flow_red['state'] = 'disabled'

        self.complete_menus()