Esempio n. 1
0
    def run_kappa(self):
        self.status_label["text"] = "Status: performing kappa analysis..."
        self.status_label.update_idletasks()
        self.kappa_button["state"] = DISABLED

        (startdate,
         enddate) = self.get_date_range(self.kappa_startdate_entry.get(),
                                        self.kappa_enddate_entry.get())
        window_start = int(self.kappa_window_start_entry.get())
        window_end = int(self.kappa_window_end_entry.get())
        window_step = int(self.kappa_window_step_entry.get())
        lag_start = int(self.kappa_lag_start_entry.get())
        lag_end = int(self.kappa_lag_end_entry.get())
        lag_step = int(self.kappa_lag_step_entry.get())

        useanalysisarea = False

        if window_start > window_end:
            tkMessageBox.showwarning(
                "Kappa",
                "value for window_start must be less than or equal to window_end"
            )
        elif lag_start > lag_end:
            tkMessageBox.showwarning(
                "Kappa",
                "value for lag_start must be less than or equal to lag_end")
        elif window_step < 1:
            tkMessageBox.showwarning(
                "Kappa",
                "value for window_step must be greater than or equal to 1")
        elif lag_step < 1:
            tkMessageBox.showwarning(
                "Kappa",
                "value for lag_step must be greater than or equal to 1")
        else:
            filehandle = dycast.init_kappa_output(
                self.kappa_export_dir_entry.get() + os.sep +
                self.kappa_export_file_entry.get())
            for window in range(window_start, window_end + window_step,
                                window_step):
                for lag in range(lag_start, lag_end + lag_step, lag_step):
                    self.status_label[
                        "text"] = "Status: performing kappa analysis... window %s, lag %s" % (
                            window, lag)
                    self.status_label.update_idletasks()
                    try:
                        if useanalysisarea:
                            print dycast.kappa(window, lag, startdate, enddate,
                                               dycast.get_analysis_area_id(),
                                               filehandle)
                        else:
                            print dycast.kappa(window, lag, startdate, enddate,
                                               None, filehandle)
                    except Exception, inst:
                        tkMessageBox.showwarning(
                            "Kappa",
                            "Could not calculate kappa for window %s, lag %s, startdate %s, enddate %s: %s"
                            % (window, lag, startdate, enddate, inst))
            dycast.close_kappa_output(filehandle)
Esempio n. 2
0
File: ui.py Progetto: almccon/DYCAST
 def run_kappa(self):
     self.status_label["text"] = "Status: performing kappa analysis..."
     self.status_label.update_idletasks()
     self.kappa_button["state"] = DISABLED
     
     (startdate, enddate) = self.get_date_range(
         self.kappa_startdate_entry.get(),
         self.kappa_enddate_entry.get()
     )
     window_start = int(self.kappa_window_start_entry.get())
     window_end = int(self.kappa_window_end_entry.get())
     window_step = int(self.kappa_window_step_entry.get())
     lag_start = int(self.kappa_lag_start_entry.get())
     lag_end = int(self.kappa_lag_end_entry.get())
     lag_step = int(self.kappa_lag_step_entry.get())
     
     useanalysisarea = False
     
     if window_start > window_end:
         tkMessageBox.showwarning(
             "Kappa",
             "value for window_start must be less than or equal to window_end"
         )
     elif lag_start > lag_end:
         tkMessageBox.showwarning(
             "Kappa",
             "value for lag_start must be less than or equal to lag_end"
         )
     elif window_step < 1:
         tkMessageBox.showwarning(
             "Kappa",
             "value for window_step must be greater than or equal to 1"
         )
     elif lag_step < 1:
         tkMessageBox.showwarning(
             "Kappa",
             "value for lag_step must be greater than or equal to 1"
         )
     else:             
         filehandle = dycast.init_kappa_output(self.kappa_export_dir_entry.get() + os.sep + self.kappa_export_file_entry.get())
         for window in range(window_start, window_end+window_step, window_step):
             for lag in range(lag_start, lag_end+lag_step, lag_step):
                 self.status_label["text"] = "Status: performing kappa analysis... window %s, lag %s" % (window, lag)
                 self.status_label.update_idletasks()
                 try:
                     if useanalysisarea:
                         print dycast.kappa(window, lag, startdate, enddate, dycast.get_analysis_area_id(), filehandle)
                     else:
                         print dycast.kappa(window, lag, startdate, enddate, None, filehandle)
                 except Exception, inst:
                     tkMessageBox.showwarning(
                         "Kappa",
                         "Could not calculate kappa for window %s, lag %s, startdate %s, enddate %s: %s" % (window, lag, startdate, enddate, inst)
                     )            
         dycast.close_kappa_output(filehandle)
Esempio n. 3
0
if options.lagstart > options.lagend:
    print "value for lagstart must be less than or equal to lagend"
    sys.exit()

if options.windowstep < 1:
    print "value for windowstep must be greater than or equal to 1"
    sys.exit()

if options.lagstep < 1:
    print "value for lagstep must be greater than or equal to 1"
    sys.exit()

filehandle = dycast.init_kappa_output()

for window in range(options.windowstart,
                    options.windowend + options.windowstep,
                    options.windowstep):
    for lag in range(options.lagstart, options.lagend + options.lagstep,
                     options.lagstep):
        if options.useanalysisarea:
            dycast.kappa(window, lag, startdate, enddate,
                         dycast.get_analysis_area_id(), filehandle)
            #if options.analysisareaid != None:
            #    print dycast.kappa(window, lag, startdate, enddate, dycast.get_analysis_area_id())
            #else:
            #    print dycast.kappa(window, lag, startdate, enddate, options.analysisareaid) # I haven't tested this one
        else:
            dycast.kappa(window, lag, startdate, enddate, None, filehandle)

dycast.close_kappa_output(filehandle)
Esempio n. 4
0
  print "value for windowstart must be less than or equal to windowend"
  sys.exit()

if options.lagstart > options.lagend:
  print "value for lagstart must be less than or equal to lagend"
  sys.exit()

if options.windowstep < 1:
  print "value for windowstep must be greater than or equal to 1"
  sys.exit()

if options.lagstep < 1:
  print "value for lagstep must be greater than or equal to 1"
  sys.exit()


filehandle = dycast.init_kappa_output()

for window in range(options.windowstart, options.windowend+options.windowstep, options.windowstep):
    for lag in range(options.lagstart, options.lagend+options.lagstep, options.lagstep):
        if options.useanalysisarea:
            dycast.kappa(window, lag, startdate, enddate, dycast.get_analysis_area_id(), filehandle)
            #if options.analysisareaid != None:
            #    print dycast.kappa(window, lag, startdate, enddate, dycast.get_analysis_area_id())
            #else:
            #    print dycast.kappa(window, lag, startdate, enddate, options.analysisareaid) # I haven't tested this one
        else:
            dycast.kappa(window, lag, startdate, enddate, None, filehandle)

dycast.close_kappa_output(filehandle)