def runGSA(case_num, autocorrelationRows, autocorrelationCols, sdRows, sdCols, idVariable): fileDict = dao.getFileDict(case_num) observations = weights.extractObservations(fileDict['GSA_Input_CSV'], autocorrelationRows, autocorrelationCols) w = weights.generateWeightsUsingShapefile(fileDict['GSA_Input_SHP'], idVariable=idVariable) globalAutoCorrelation = autocorrelation.globalAutocorrelation(observations, w) localAutoCorrelation = autocorrelation.localAutocorrelation(observations, w) observations = weights.extractObservations(fileDict['GSA_Input_CSV'], sdRows, sdCols) spatialDynamics = spatial_dynamics.markov(observations, w, method="spatial") return localAutoCorrelation, globalAutoCorrelation, spatialDynamics
def reg(): case_num = request.args.get('case_num', None) fileDict = dao.getFileDict(case_num) GSA_file_CSV = fileDict.get('GSA_Input_CSV') GSA_file_SHP = fileDict.get('GSA_Input_SHP') gsa_meta = fileDict.get('GSA_meta') svgNaming = fileDict.get('GSA_data')[0] with open('out/gsa/mymap.svg', 'r') as myfile: mymap = myfile.read() mymap = mymap.replace('"', "'") observations = weights.extractObservations(GSA_file_CSV, "ALL", gsa_meta[3]) w = weights.generateWeightsUsingShapefile(GSA_file_SHP, idVariable=gsa_meta[2]) regions = regionalization.generateRegions(w=w, observations=observations)[0] regions = regionalization.getNamesFromRegions(regions) nameMapping = util.getNameMapping('out/gsa/mymap.svg', gsa_meta[0], gsa_meta[1]) nameMapping = { key: value.replace("'", "APOSTROPHE") for key, value in nameMapping.items() } numRegs = len(set(regions.values())) return render_template("regionalization.html", case_num=case_num, mymap=json.dumps(mymap), regions=json.dumps(regions), numRegs=numRegs, svgNaming=svgNaming, nameMapping=json.dumps(str(nameMapping)))