网站建设的讲话稿,xml网站地图生成,南宁公司网站建设方案,简单网站建设模板进入STARS后#xff0c;最简单的学习方法就是演示示例数据。对于源码的分析也可以从这里入手。以下为出发菜单项“Example Project”的函数example#xff1a;def example(self):canned loading of data files and matrices for debugging最简单的学习方法就是演示示例数据。对于源码的分析也可以从这里入手。 以下为出发菜单项“Example Project”的函数exampledef example(self):canned loading of data files and matrices for debuggingself.project SProject(current,self.master,self) topDir options.getSTARSHOME()self.project.directory os.path.join(topDir,data)projectFile os.path.join(self.project.directory,csiss.prj)tself.project.ReadProjectFile(projectFile)if hasattr(self.project,coords):self.project.scaleCoords()else:self.report(no coords in project)#self.master.configure(cursoroptions.DEFAULTCURSOR)#self.Editor.configure(cursorcrosshair)self.projectSummary() self.enableMenus()加粗标注的几行代码可作进一步详细了解(1)SProject代码如下所示class SProject(Project):Subclass to compose STARS project inside a GUIdef __init__(self,name,master,app):Constructorname (string): name of projectmaster (Tk): application top level windowapp (App): App instanceProject.__init__(self,name)self.master masterself.app appself.fnt(Times,10)self.screenHeight self.app.winfo_screenheight()self.screenWidth self.app.winfo_screenwidth()if self.screenWidth 1280:self.screenWidth 1280 # prevent spread across 2-extended displayss str(self.screenWidth) str(self.screenHeight)self.screenDim s其中调用了父类Project打开star.py文件找到Project类对其进行分析class Project:Stars project.Example Usage: from stars import Project sProject(s) s.ReadData(csiss) incomes.getVariable(pcincome) regions.getVariable(bea) wspRegionMatrix(region) miMoran(income,w) print(mi.mi[70])0.38918107312def __init__(self,name):self.name nameself.dataBase Database()self.getVariable self.dataBase.getVariableself.getMatrix self.dataBase.getMatrixself.addMatrix self.dataBase.addMatrixself.getMatrixNames self.dataBase.getMatrixNamesself.getVariableNames self.dataBase.getVariableNamesself.getTSVariableNames self.dataBase.getTSVariableNamesself.getCSVariableNames self.dataBase.getCSVariableNamesself.getCSTSVariableNames self.dataBase.getCSTSVariableNames(2)ReadProjectFile代码如下所示def ReadProjectFile(self,fileName):#assumes extension is passed into fileName#check for file existenceif os.path.exists(fileName):self.initialize()config ConfigParser.ConfigParser()config.read(fileName)projectDir os.path.dirname(fileName)#print config.sections()for section in config.sections():options config.options(section)for option in options:value config.get(section,option)# print section,option,valuesecself.options[section]optsec[option]opt.append(value)sec[option]optself.options[section]sec# self.summarizeOptions()# read data filesdataFiles self.options[data][files]for dataFile in dataFiles:# print dataFiledfile os.path.join(projectDir,dataFile)# print dfileself.ReadData(dfile)#print data files# read any gal matriciestry:galFiles self.options[weight][gal][0].split()print galFilesfor galFile in galFiles:# print galFilegfile os.path.join(projectDir,galFile)self.ReadGalMatrix(gfile)#print galexcept:print No Weights Matrices# read any gis boundary filesself.listGISNames []gisFiles self.options[gis][gis]for gisFile in gisFiles:fileName gisFile.gisself.listGISNames.append(fileName)fileName os.path.join(projectDir,fileName)self.ReadGisFile(fileName)fileName os.path.join(projectDir,gisFile.cnt)if os.path.exists(fileName):self.readCentroids(fileName)else:self.__calcCentroids()self.gisResolution self.options[graphics][screen]else:print Error: Cannot read project file: %s%fileName该段代码可以帮助解析STARS工程文件project的大致结构打开系统自带示例的工程文件csiss.prj[data]files: csiss[weight]gal: states48[gis]gis: us48[graphics]screen: 1280 1201可以发现该文件分为四段前三段分别对应有数据文件、权重文件、GIS文件的连接最后一段为显示参数。·数据文件存储统计数据信息又分为两个文件csiss.dht存储数据索引信息csiss.dat存储数据主体信息其中注释CS为空间序列数据TS为时间序列数据CSTS即为时空序列数据。·权重文件存储空间权重信息后缀名为gal。此文件第一行为空间实体数目从第二行开始每两行构成固定格式形如[第一行]实体序号 权重关联实体个数[第二行]权重关联实体序号列表如此循环至最后一个实体。参见states48.gal文件。·GIS文件(后缀名为gis)存储空间实体的地图数据结构形如[数据头]空间实体编号 该实体内多边形编号 该多边形节点数[数据体]X坐标(换行)Y坐标。参见us48.gis文件。(3)projectSummary代码如下所示def projectSummary(self):self.report(self.project.catalogue())在guimaker.py中找到report函数def report(self,message):enters messages into main application window. use forentering results, commands called by gui, etc.self.Editor.insert(END,message)tlen(message)self.Editor.yview_scroll(t,UNITS)self.Editor.insert(END,\n)