コード例 #1
0
ファイル: ProjectMaker.py プロジェクト: weikang9009/stars
 def createMONTHLY(self):
     d = sd.SDialogue('Monthly Time-Series Dialogue')
     txt = "Choose the starting month for your project."
     months = range(1, 13)
     entries = ['Start Month']
     sd.MultiEntry(d, months, entries, title='', helpText=txt)
     txt = "Choose the start year for your project."
     sd.UserEntry(d,
                  label="Start Year",
                  align="LEFT",
                  title="",
                  helpText=txt)
     txt = "Choose the ending month for your project."
     entries = ['End Month']
     sd.MultiEntry(d, months, entries, title='', helpText=txt)
     txt = "Choose the end year for your project."
     sd.UserEntry(d, label="End Year", align="LEFT", title="", helpText=txt)
     d.draw()
     if d.status:
         startM = int(d.results[0]['Start Month'])
         startYear = int(d.results[1])
         endM = int(d.results[2]['End Month'])
         endYear = int(d.results[3])
         self.proj.createMonthly(startM, startYear, endM, endYear)
         self.report(self.proj.timeSummary)
コード例 #2
0
ファイル: ProjectMaker.py プロジェクト: weikang9009/stars
 def createQUARTERLY(self):
     d = sd.SDialogue('Quarterly Time-Series Dialogue')
     txt = "Choose the starting quarter for your project."
     quarters = range(1, 5)
     entries = ['Start Quarter']
     sd.MultiEntry(d, quarters, entries, title='', helpText=txt)
     txt = "Choose the start year for your project."
     sd.UserEntry(d,
                  label="Start Year",
                  align="LEFT",
                  title="",
                  helpText=txt)
     txt = "Choose the ending quarter for your project."
     entries = ['End Quarter']
     sd.MultiEntry(d, quarters, entries, title='', helpText=txt)
     txt = "Choose the end year for your project."
     sd.UserEntry(d, label="End Year", align="LEFT", title="", helpText=txt)
     d.draw()
     if d.status:
         startQ = int(d.results[0]['Start Quarter'])
         startYear = int(d.results[1])
         endQ = int(d.results[2]['End Quarter'])
         endYear = int(d.results[3])
         self.proj.createQuarterly(startQ, startYear, endQ, endYear)
         self.report(self.proj.timeSummary)
コード例 #3
0
ファイル: ProjectMaker.py プロジェクト: weikang9009/stars
 def cs2Panel(self):
     d = sd.SDialogue('Convert Existing CS Variables to a CSTS Variable')
     varNames = self.proj.getCSVariableNames()
     varNames.sort()
     time = str(self.proj.t)
     txt = """Select the CS variables in temporal order.  Make sure that you
     have the same number of CS vars as time periods"""
     tRemind = "Choose t = " + time + " CS Variables"
     sd.DualListBoxes(d, varNames, title=tRemind, helpText=txt)
     txt = "Choose a name for your STARS Panel variable."
     sd.UserEntry(d,
                  label="Choose Panel Variable Name",
                  align="LEFT",
                  title="",
                  helpText=txt)
     title = 'Would you like to delete the original CS Variables?'
     values = ['No', 'Yes']
     txt = """If you select Yes, then the original CS variables will be erased.  ***The default is No"""
     sd.RadioButtons(d, values=values, title=title, helpText=txt)
     d.draw()
     if d.status:
         varList = d.results[0]
         panelName = d.results[1]
         delete = d.results[2]
         if len(varList) == self.proj.t:
             self.proj.cs2Panel(varList, panelName, delete=delete)
             self.report(self.proj.variableSummary())
         else:
             s = """ERROR:  The number of CS Variables you provided do not match the number of time periods in your project."""
             self.report(s)
コード例 #4
0
ファイル: ProjectMaker.py プロジェクト: weikang9009/stars
 def createANNUAL(self):
     d = sd.SDialogue('Annual Time-Series Dialogue')
     txt = "Choose the start year for your project."
     sd.UserEntry(d,
                  label="Start Year",
                  align="LEFT",
                  title="",
                  helpText=txt)
     txt = "Choose the end year for your project."
     sd.UserEntry(d, label="End Year", align="LEFT", title="", helpText=txt)
     d.draw()
     if d.status:
         start = d.results[0]
         end = d.results[1]
         self.proj.createAnnual(start, end)
         self.report(self.proj.timeSummary)
コード例 #5
0
ファイル: ProjectMaker.py プロジェクト: weikang9009/stars
 def createIRREGULAR(self):
     d = sd.SDialogue('Irregular Time-Series Dialogue')
     txt = "Choose the number of time periods (Integer)"
     sd.UserEntry(d,
                  label="Number of Time Periods (t)",
                  align="LEFT",
                  title="",
                  helpText=txt)
     d.draw()
     if d.status:
         t = int(d.results[0])
         self.proj.createIrregular(t)
         self.report(self.proj.timeSummary)
コード例 #6
0
ファイル: ProjectMaker.py プロジェクト: weikang9009/stars
 def convertCSTSVariable(self):
     d = sd.SDialogue('Convert Initial Fields to a STARS Panel Variables')
     varNames = self.proj.getDBFVariableNames()
     varNames.sort()
     txt = """Select the fields in time order to be create a panel variable."""
     time = str(self.proj.t)
     tRemind = "Choose t = " + time + " fields"
     sd.DualListBoxes(d, varNames, title=tRemind, helpText=txt)
     txt = "Choose a name for your STARS Panel variable."
     sd.UserEntry(d,
                  label="Choose Panel Variable Name",
                  align="LEFT",
                  title="",
                  helpText=txt)
     entries = ['Aggregation Method']
     txt = """If the same cross-sectional unit has more than one value
     associated with it, ProjectMaker will have to combine the values in
     some way.  You have the following options:
         Sum: will sum up any values associated with the same cross-section.
         Max: will take the maximum value of any values associated with the same cross-section.
         Min: will take the minimum value of any values associated with the same cross-section.
         Average: will average the values associated with the same cross-section.
         String: will essentially use the value of the last instance for
         each cross-section.  Furthermore the value is a string.  Use this
         for categorical data.
         
     ***The default method is "Average"."""
     types = ['Sum', 'Max', 'Min', 'Average', 'String']
     sd.MultiEntry(d,
                   types,
                   entries,
                   title='Optional Arguments',
                   helpText=txt)
     d.draw()
     if d.status:
         varList = d.results[0]
         varName = d.results[1]
         cohesion = d.results[2]['Aggregation Method']
         if cohesion:
             pass
         else:
             cohesion = 'Average'
         createVar = self.proj.convertArcViewVariable(
             cohesion, varName, varList)
         self.report(self.proj.variableSummary())
コード例 #7
0
ファイル: ProjectMaker.py プロジェクト: weikang9009/stars
    def convertCSTSVariableBatch(self):
        d = sd.SDialogue('Convert Initial Fields to a STARS Panel Variables')
        varNames = self.proj.getDBFVariableNames()
        batch = MATCH.batchSplit(varNames)
        varNames = batch['strings']
        varNames.sort()
        timeInfo = batch['ints']
        timeInfo.sort()
        txt = """Select the fields to create panel variables via the batch method."""
        time = str(self.proj.t)
        add = """Remember that field must have " + time + " time periods
        associated with it."""
        txt = txt + "\n" + add
        title = "Choose fields for batch CSTS creation"
        sd.DualListBoxes(d, varNames, title=title, helpText=txt)

        txt = """Choose a variable associated with the first time period in
        your study, and an additional oone for the year time period.  You may
        also type this in manuallly."""
        timeStuff = ['Start Period for Batch', 'End Period for Batch']
        sd.MultiEntry(d,
                      timeInfo,
                      timeStuff,
                      title='Time Period Arguments',
                      helpText=txt)

        txt = """Provide the time period increment:
            I.e.    Annual:   1
                    BiAnnual: 2
                    Decadal:  10
            """
        sd.UserEntry(d,
                     label="Integer Value",
                     align="LEFT",
                     title="User Defined Time Increment",
                     helpText=txt)

        entries = ['Aggregation Method']
        txt = """If the same cross-sectional unit has more than one value
        associated with it, ProjectMaker will have to combine the values in
        some way.  You have the following options:
            Sum: will sum up any values associated with the same cross-section.
            Max: will take the maximum value of any values associated with the same cross-section.
            Min: will take the minimum value of any values associated with the same cross-section.
            Average: will average the values associated with the same cross-section.
            String: will essentially use the value of the last instance for
            each cross-section.  Furthermore the value is a string.  Use this
            for categorical data.
            
        ***The default method is "Average"."""
        types = ['Sum', 'Max', 'Min', 'Average', 'String']
        sd.MultiEntry(d,
                      types,
                      entries,
                      title='Optional Arguments',
                      helpText=txt)
        d.draw()
        if d.status:
            vars = MATCH.Matcher('vars', d.results[0])
            varList = vars.unique
            start = int(d.results[1]['Start Period for Batch'])
            end = int(d.results[1]['End Period for Batch'])
            step = int(d.results[2])
            cohesion = d.results[3]['Aggregation Method']
            if cohesion:
                pass
            else:
                cohesion = 'Average'
            for var in varList:
                try:
                    newVar = [
                        var + str(i) for i in range(start, end + step, step)
                    ]
                    createVar = self.proj.convertArcViewVariable(
                        cohesion, var, newVar)
                except:
                    beg = "Could not create new variable for " + var + "."
                    end = "\nPerhaps the the time series does not match."
                    self.report(beg + end)
                    self.report(self.proj.variableSummary())
コード例 #8
0
ファイル: ProjectMaker.py プロジェクト: weikang9009/stars
    def createNewSTARSProject(self):
        """
        Creates a new STARS project.
        Callback.
        """
        d = sd.SDialogue('Create New STARS Project')
        values = 'ArcView', 'CSV'
        txt = "Choose the type of file you want to use as your base data.\n"
        rbutton = sd.RadioButtons(d,
                                  label='Base Data',
                                  values=values,
                                  align='LEFT',
                                  title='Types',
                                  helpText=txt)
        d.draw()
        if d.status:
            type = d.results[0]
            if type == 0:
                fileType = "*.dbf"
            else:
                fileType = "*.csv"
            FILE_TYPES = [("Files", fileType)]
            baseFileName = askopenfilename(filetypes=FILE_TYPES,
                                           title="Choose Base Data File.")
            if baseFileName:
                self.prj = 0
                type = baseFileName.split(".")[-1]
                if type == "dbf":
                    arc = 1
                    self.report("Base data generated from an ArcView Project")
                else:
                    arc = 0
                    self.report(
                        "Base data generated from a Comma Delimited File")
                self.proj = ProjectMaker(baseFileName, arc=arc)
            d = sd.SDialogue('Create STARS Project Name')
            txt = """Choose a name for the STARS project you want to create."""
            sd.UserEntry(d,
                         label="Project Prefix",
                         align="LEFT",
                         title="",
                         helpText=txt)
            d.draw()
            if d.status:
                self.proj.changeProjPrefix(d.results[0])
            self.baseVariableTable()

            d = sd.SDialogue('Choose Time Series Type')
            values = 'Decadal', 'Annual', 'Quarterly', 'Monthly', 'Irregular'
            txt = "Choose the type of file you want to use as your base data.\n"
            rbutton = sd.RadioButtons(d,
                                      label='Time-Series',
                                      values=values,
                                      align='LEFT',
                                      title='Types',
                                      helpText=txt)
            d.draw()
            if d.status:
                type = d.results[0]
                self.evalTimeInfo(values[type])

            self.createIdsAndNames()
            if arc == 1:
                self.createGal()
            self.starsProjectOn = 1