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)
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)
def createIdsAndNames(self): d = sd.SDialogue('Create Region Names and Ids') txt = """You must identify names for the regions in your project. *** All the options in this dialogue are optional. If you leave them blank, your regions will be identified by the integers associated with the number of rows in the input .dbf or .csv file. 1. Use the Unique Field to identify unique labels that match the number of cross-sections in your study. Examples would include NUTS or FIPS codes. 2. If there are no Fields that can be used to determine the uniqueness of each cross-section you may combine the values from two fields to create region ids. The Join Field term will be combined with the Unique Field to create a "more unique" identifier. 3. Use the Optional Name Field if you have identified regions with either the Unique or Joined method, but you want the names of the regions to be determined by this field. 4. The user can select the type of delimiter used join field entries. The default delimiter is an underscore: field1_field2 """ varNames = self.proj.getDBFVariableNames() varNames.sort() entries = [ 'Unique Field', 'Join Field', 'Optional Name Field', 'Delimiter' ] sd.MultiEntry(d, varNames, entries, title='Optional Arguments', helpText=txt) d.draw() if d.status: nameField = d.results[0]['Unique Field'] if nameField: nameField = self.proj.getDBFVariable(nameField) else: nameField = [] joinField = d.results[0]['Join Field'] if joinField: joinField = self.proj.getDBFVariable(joinField) else: joinField = [] finalField = d.results[0]['Optional Name Field'] if finalField: finalField = self.proj.getDBFVariable(finalField) else: finalField = [] delimiter = d.results[0]['Delimiter'] if delimiter: pass else: delimiter = "_" self.proj.createNamesAndIDs(var1=nameField, var2=joinField, var3=finalField, delim=delimiter) self.report(self.proj.variableSummary())
def joinCS(self): FILE_TYPES = [("Files", "*.csv")] fileName = askopenfilename(filetypes=FILE_TYPES, title="JOIN Additional CS Data.") if fileName: self.proj.readJoinCSV(fileName) d = sd.SDialogue('Join Data Dialogue') txt = """Identify the existing cross-sectional field in the project to serve as the master in the matching process. """ varNames = self.proj.getCSVariableNames() varNames.sort() entries = ['Field'] sd.MultiEntry(d, varNames, entries, title='Identify Master Field', helpText=txt) txt = """Identify the field in your new data that will serve as the slave in the matching process. """ varNames = self.proj.data2Join.names varNames.sort() entries = ['Field'] sd.MultiEntry(d, varNames, entries, title='Identify Slave Field', helpText=txt) d.draw() if d.status: master = d.results[0]['Field'] slave = d.results[1]['Field'] self.proj.joinCS(master, slave) self.report(self.proj.variableSummary())
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())
def convertCSVariables(self): d = sd.SDialogue( 'Convert Initial Field(s) to STARS Cross-Sectional Variables(s)') varNames = self.proj.getDBFVariableNames() varNames.sort() txt = """Select one or more initial variables to convert into pure cross-sectional STARS variables.""" sd.DualListBoxes(d, varNames, title='Fields', 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] cohesion = d.results[1]['Aggregation Method'] if cohesion: pass else: cohesion = 'Average' createVars = [ self.proj.convertArcViewVariable(cohesion, var, [var]) for var in varList ] self.report(self.proj.variableSummary())
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())