Beispiel #1
0
    def onMouseMotion( self, event ):
        index, flags = self.DtList.HitTest(event.GetPosition())
        if index == wx.NOT_FOUND:
            self.pvLabel.SetLabel('Select Ref station, IR series, then float over dates to preview')
            return
        if flags & wx.LIST_HITTEST_NOWHERE:
            self.pvLabel.SetLabel('Select Ref station, IR series, then float over dates to preview')
            return
        txtDate = self.DtList.GetItemText(index)
        if txtDate != self.stDateToPreview:
            self.Canvas.InitAll()
            self.Canvas.SetProjectionFun(self.ScalePreviewCanvas)
            self.Canvas.Draw()
            self.stDateToPreview = txtDate
            print "date to preview:", self.stDateToPreview
            self.pvLabel.SetLabel('Generating preview for ' + self.stDateToPreview)
            
            # get the station ID, if selected
            staID = scidb.getComboboxIndex(self.cbxRefStationID)
            if staID == None:
                self.pvLabel.SetLabel('Select Reference Station, to preview dates')
                return
            # get the IR series ID, if selected
            serID = scidb.getComboboxIndex(self.cbxIRRefSeriesID)
            if serID == None:
                self.pvLabel.SetLabel('Select IR series for the Reference Station, to preview dates')
                return
            # get the hour offset from the station longitude
            longitude = scidb.stationLongitude(staID)
            if longitude == None:
                hrOffLon = 0
            else:
                hrOffLon = longitude / 15 # one hour for every 15 degrees of longitude
            # get the minute offet from the Equation of Time table
            stSQLm = """SELECT MinutesCorrection FROM EqnOfTime
                WHERE DayOfYear = strftime('%j','{sDt}');
                """.format(sDt=self.stDateToPreview)
            minOffEqTm = scidb.curD.execute(stSQLm).fetchone()['MinutesCorrection']
            stSQL = """SELECT DATETIME(Data.UTTimestamp, '{fHo} hour', '{fEq} minute') AS SolarTime, 
                strftime('%s', DATETIME(Data.UTTimestamp, '{fHo} hour', '{fEq} minute')) - strftime('%s', '{sDt}') AS Secs,
                Data.Value
                FROM ChannelSegments LEFT JOIN Data ON ChannelSegments.ChannelID = Data.ChannelID
                WHERE ChannelSegments.StationID = {iSt}  AND ChannelSegments.SeriesID = {iSe}
                AND SolarTime >= '{sDt}' AND SolarTime < DATETIME('{sDt}', '1 day')
                AND Data.UTTimestamp >= ChannelSegments.SegmentBegin
                AND  Data.UTTimestamp <= COALESCE(ChannelSegments.SegmentEnd, DATETIME('now'))
                ORDER BY SolarTime;
                """.format(iSt=staID, iSe=serID, fHo=hrOffLon, fEq=minOffEqTm, sDt=self.stDateToPreview)
            ptRecs = scidb.curD.execute(stSQL).fetchall()
            if len(ptRecs) == 0:
                self.pvLabel.SetLabel('No data for for ' + self.stDateToPreview)
                return
            pts = []
            for ptRec in ptRecs:
#                print ptRec['Secs'], ptRec['Value']
                pts.append((ptRec['Secs'], ptRec['Value']))
            self.Canvas.AddLine(pts, LineWidth = 1, LineColor = 'BLUE')
            self.Canvas.ZoomToBB()
Beispiel #2
0
    def onClick_BtnWorkOnSite(self, event, str):
        """
        """
        print "in onClick_BtnWorkOnSite, str = '" + str + '"'
        if str == "New":
            dia = Dialog_SiteDetails(self, wx.ID_ANY, actionCode = ['New', 0])

        elif str == "Edit":
            recNum = scidb.getComboboxIndex(self.cbxFldSites)
            
#            siteItem = self.lstSites.GetFocusedItem()
            if recNum == None:
                wx.MessageBox('Select a Site to edit', 'No Selection',
                    wx.OK | wx.ICON_INFORMATION)
                return
#            recNum = self.lstSites.GetItemData(siteItem)
            dia = Dialog_SiteDetails(self, wx.ID_ANY, actionCode = ['Edit', recNum])

        else:
            return
        # the dialog contains an 'InfoPanel_SiteDetails' named 'pnl'
        result = dia.ShowModal()
        # dialog is exited using EndModal, and comes back here
        print "Modal FieldSite dialog result:", result
        # test of pulling things out of the modal dialog
        self.siteName = dia.pnl.tcSiteName.GetValue()
        print "Name of site, from the Modal:", self.siteName
        dia.Destroy()
        self.fillSitesList()
        self.ShowSiteLatLon()
Beispiel #3
0
    def onClick_BtnWorkOnSite(self, event, str):
        """
        """
        print "in onClick_BtnWorkOnSite, str = '" + str + '"'
        if str == "New":
            dia = Dialog_SiteDetails(self, wx.ID_ANY, actionCode = ['New', 0])

        elif str == "Edit":
            recNum = scidb.getComboboxIndex(self.cbxFldSites)
            
#            siteItem = self.lstSites.GetFocusedItem()
            if recNum == None:
                wx.MessageBox('Select a Site to edit', 'No Selection',
                    wx.OK | wx.ICON_INFORMATION)
                return
#            recNum = self.lstSites.GetItemData(siteItem)
            dia = Dialog_SiteDetails(self, wx.ID_ANY, actionCode = ['Edit', recNum])

        else:
            return
        # the dialog contains an 'InfoPanel_SiteDetails' named 'pnl'
        result = dia.ShowModal()
        # dialog is exited using EndModal, and comes back here
        print "Modal FieldSite dialog result:", result
        # test of pulling things out of the modal dialog
        self.siteName = dia.pnl.tcSiteName.GetValue()
        print "Name of site, from the Modal:", self.siteName
        dia.Destroy()
        self.fillSitesList()
        self.ShowSiteLatLon()
Beispiel #4
0
 def FillDictFromPanel(self):
     # clean up whitespace; remove leading/trailing & multiples
     self.StDict['StationName'] = " ".join(self.tcStationName.GetValue().split())
     self.StDict['SiteID'] = scidb.getComboboxIndex(self.cbxFldSites)
     try:
         self.StDict['LatitudeDecDegrees'] = float(self.tcLat.GetValue())
     except:
         self.StDict['LatitudeDecDegrees'] = None
     try:
         self.StDict['LongitudeDecDegrees'] = float(self.tcLon.GetValue())
     except:
         self.StDict['LongitudeDecDegrees'] = None
Beispiel #5
0
 def FillDictFromPanel(self):
     # clean up whitespace; remove leading/trailing & multiples
     self.StDict['StationName'] = " ".join(self.tcStationName.GetValue().split())
     self.StDict['SiteID'] = scidb.getComboboxIndex(self.cbxFldSites)
     try:
         self.StDict['LatitudeDecDegrees'] = float(self.tcLat.GetValue())
     except:
         self.StDict['LatitudeDecDegrees'] = None
     try:
         self.StDict['LongitudeDecDegrees'] = float(self.tcLon.GetValue())
     except:
         self.StDict['LongitudeDecDegrees'] = None
Beispiel #6
0
 def ShowSiteLatLon(self):
     recID = scidb.getComboboxIndex(self.cbxFldSites)
     if recID == None:
         stSiteLL = 'Site lat/lon: (none yet)'
     else:
         stSQL_SiLL = 'SELECT LatitudeDecDegrees, LongitudeDecDegrees FROM FieldSites WHERE ID = ?'
         rec = scidb.curD.execute(stSQL_SiLL, (recID,))
         rec = scidb.curD.fetchone() # returns one record, or None
         if rec == None:
             stSiteLL = 'Site lat/lon: (can not read)'
         else:
             stSiteLL = 'Site lat/lon: (' + ('%.6f' % rec['LatitudeDecDegrees']) + \
                 ', ' + ('%.6f' % rec['LongitudeDecDegrees']) + ')'
     self.txSiteLLMsg.SetLabel(stSiteLL)
Beispiel #7
0
 def ShowSiteLatLon(self):
     recID = scidb.getComboboxIndex(self.cbxFldSites)
     if recID == None:
         stSiteLL = 'Site lat/lon: (none yet)'
     else:
         stSQL_SiLL = 'SELECT LatitudeDecDegrees, LongitudeDecDegrees FROM FieldSites WHERE ID = ?'
         rec = scidb.curD.execute(stSQL_SiLL, (recID,))
         rec = scidb.curD.fetchone() # returns one record, or None
         if rec == None:
             stSiteLL = 'Site lat/lon: (can not read)'
         else:
             stSiteLL = 'Site lat/lon: (' + ('%.6f' % rec['LatitudeDecDegrees']) + \
                 ', ' + ('%.6f' % rec['LongitudeDecDegrees']) + ')'
     self.txSiteLLMsg.SetLabel(stSiteLL)