Пример #1
0
    def run_daily_risk(self):
        self.status_label["text"] = "Status: generating risk..."
        self.status_label.update_idletasks()
        self.daily_risk_button["state"] = DISABLED

        (curdate, enddate) = self.get_date_range(
            self.daily_risk_entry1.get(),
            self.daily_risk_entry2.get()
        )
        oneday = datetime.timedelta(days=1)
        
        # TODO: really, I should query the databsae to see which possible parameter
        # sets exist, and offer these to the user instead of letting them specify
        # their own.
        
        cs = self.daily_risk_cs_entry.get()
        ct = self.daily_risk_ct_entry.get()
        sd = self.daily_risk_sd_entry.get()
        td = self.daily_risk_td_entry.get()
        
        param_id = dycast.get_param_record_id(cs, ct, sd, td)
        if not param_id:
            tkMessageBox.showerror(
                "Daily risk",
                "Cannot run daily risk: monte carlo simulations have not been generated for this set of parameters. Choose different parameters, or generate them from the Initialization window."
            )
        else:
            while (curdate <= enddate):
                self.status_label["text"] = "Status: generating risk... %s" % curdate
                self.status_label.update_idletasks()
                try:
                    dycast.daily_risk(curdate, cs, ct, sd, td)
                    #dycast.daily_risk(curdate, cs, ct, sd, td, 5580000, 5710000) # for testing
                except:
                    tkMessageBox.showwarning(
                        "Daily risk",
                        "Could not run daily risk for %s" % curdate
                    )
                    break
                curdate = curdate + oneday

        self.daily_risk_button["state"] = NORMAL
        self.status_label["text"] = "Status: ready"
        self.status_label.update_idletasks()
Пример #2
0
    def run_daily_risk(self):
        self.status_label["text"] = "Status: generating risk..."
        self.status_label.update_idletasks()
        self.daily_risk_button["state"] = DISABLED

        (curdate, enddate) = self.get_date_range(self.daily_risk_entry1.get(),
                                                 self.daily_risk_entry2.get())
        oneday = datetime.timedelta(days=1)

        # TODO: really, I should query the databsae to see which possible parameter
        # sets exist, and offer these to the user instead of letting them specify
        # their own.

        cs = self.daily_risk_cs_entry.get()
        ct = self.daily_risk_ct_entry.get()
        sd = self.daily_risk_sd_entry.get()
        td = self.daily_risk_td_entry.get()

        param_id = dycast.get_param_record_id(cs, ct, sd, td)
        if not param_id:
            tkMessageBox.showerror(
                "Daily risk",
                "Cannot run daily risk: monte carlo simulations have not been generated for this set of parameters. Choose different parameters, or generate them from the Initialization window."
            )
        else:
            while (curdate <= enddate):
                self.status_label[
                    "text"] = "Status: generating risk... %s" % curdate
                self.status_label.update_idletasks()
                try:
                    dycast.daily_risk(curdate, cs, ct, sd, td)
                    #dycast.daily_risk(curdate, cs, ct, sd, td, 5580000, 5710000) # for testing
                except:
                    tkMessageBox.showwarning(
                        "Daily risk",
                        "Could not run daily risk for %s" % curdate)
                    break
                curdate = curdate + oneday

        self.daily_risk_button["state"] = NORMAL
        self.status_label["text"] = "Status: ready"
        self.status_label.update_idletasks()
Пример #3
0
  cs = default_cs
if options.closetime:
  ct = options.closetime
else:
  ct = default_ct
if options.spatialdomain:
  sd = options.spatialdomain
else:
  sd = default_sd
if options.temporaldomain:
  td = options.temporaldomain
else:
  td = default_td

i = int(options.num_days)

cur_date = datetime.date.today()
oneday = datetime.timedelta(days=1)

if cur_date.weekday() == calendar.FRIDAY:
    dycast.backup_birds()

dycast.download_birds() # All options set in config file
dycast.load_bird_file() # All options set in config file 
while i > 0:
    dycast.daily_risk(cur_date, cs, ct, sd, td) # this just needs to know date, and the parameters to use
    dycast.export_risk(cur_date) # needs to know date; use default directory
    dycast.upload_new_risk() # upload everything from default directory
    cur_date -= oneday  # back up one day
    i -= 1              # number of times remaining to back up
Пример #4
0
if options.spatialdomain:
  sd = options.spatialdomain
else:
  sd = default_sd
if options.temporaldomain:
  td = options.temporaldomain
else:
  td = default_td

if riskdate == "today" or not riskdate:
    riskdate = datetime.date.today()
else:
    try:
        # This very simple parsing will work fine if date is YYYY-MM-DD
        (y, m, d) = riskdate.split('-')
        riskdate = datetime.date(int(y), int(m), int(d))
    except Exception, inst:
        print "couldn't parse", riskdate
        print inst
        sys.exit()

if options.endpoly and options.startpoly:
    dycast.daily_risk(riskdate, cs, ct, sd, td, options.startpoly, options.endpoly)
elif options.endpoly and not options.startpoly:
    print "ERROR: the endpoly option is only supported along with startpoly"
elif options.startpoly:
    dycast.daily_risk(riskdate, cs, ct, sd, td, options.startpoly)
else:
    dycast.daily_risk(riskdate, cs, ct, sd, td)

Пример #5
0
if options.spatialdomain:
    sd = options.spatialdomain
else:
    sd = default_sd
if options.temporaldomain:
    td = options.temporaldomain
else:
    td = default_td

if riskdate == "today" or not riskdate:
    riskdate = datetime.date.today()
else:
    try:
        # This very simple parsing will work fine if date is YYYY-MM-DD
        (y, m, d) = riskdate.split('-')
        riskdate = datetime.date(int(y), int(m), int(d))
    except Exception, inst:
        print "couldn't parse", riskdate
        print inst
        sys.exit()

if options.endpoly and options.startpoly:
    dycast.daily_risk(riskdate, cs, ct, sd, td, options.startpoly,
                      options.endpoly)
elif options.endpoly and not options.startpoly:
    print "ERROR: the endpoly option is only supported along with startpoly"
elif options.startpoly:
    dycast.daily_risk(riskdate, cs, ct, sd, td, options.startpoly)
else:
    dycast.daily_risk(riskdate, cs, ct, sd, td)