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)
def panel2CS(self): d = sd.SDialogue('Convert Existing Panel Variable to CS Variables') varNames = self.proj.getCSTSVariableNames() varNames.sort() txt = """Choose the name of the Panel variable(s) that you would like to decompose by time periods into seperate cross-sectional variables. You may choose more than one at a time""" sd.DualListBoxes(d, varNames, title='Panel Variables', helpText=txt) title = 'Would you like to delete the original Panel Variables?' values = ['No', 'Yes'] txt = """If you select Yes, then the original Panel 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] delete = d.results[1] for var in varList: self.proj.panel2CS(var, delete=delete) self.report(self.proj.variableSummary())
def doMaps(self): # XXX maybe wrap alternative projected maps in a dictionary so that the # final selection of a projection does not require another projection # of the coordinates. i.e., if the user firsts looks at mercator, then # uprojected, then albers, the last map is albers. but, if the user # wants their project to use none or mercator, they would need to # reproject it at this point. for now this is in self.projectedMaps if self.proj.prj == 1: self.report("Your GIS File has already been created!") else: if self.proj.arc == 1: d = sd.SDialogue('Map Views') values = ('None', 'Mercator', 'Albers', 'Transverse Mercator', 'Cylindrical Equidistant') txt = "Select Map Projection (or none for unprojected)\n" rbutton = sd.RadioButtons(d, label='Projection', values=values, align='LEFT', title='Projections', helpText=txt) d.draw() if d.status: type = d.results[0] projections = { 1: Projection.MercatorProj, 2: Projection.AlbersEqualAreaProj, 3: Projection.TransverseMercatorProj, 4: Projection.CylindricalEquidistantProj, 0: "None" } self.proj.createMap(self.proj.shapeFileName, projections[type]) top = Toplevel(self.root) self.projected = Projection.MapView(top, self.proj.map) self.projected.plot() top.title(self.proj.map.projectionName) self.proj.projectedMaps[ self.proj.map.projectionName] = self.proj.map self.projectedCoordsOn = 1 else: self.report("No Shapefile declared for this project")
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