def generateTrueRelProbDistMapsForAllSpp (self, guppy): """ #-------------------------------------------------------------------- # Here, we now want to have the option to create the true relative # probability maps in a different way. # 1) Generate a very small number of presence locations. # 2) Hand these to maxent with the environment layers and # have it fit a distribution from them (no bootstrapping). # 3) Return that as the true relative probability map. #-------------------------------------------------------------------- # NOTE: This function is defined in computeSppDistributions.R """ print "\n\nGenerate true rel prob map using MAXENT.\n\n" combinedSppPresTable = \ self.genCombinedSppPresTable (guppy) ### guppy.imgNumRows, guppy.imgNumCols) print "\n\ncombinedSppPresTable = \n" print combinedSppPresTable combinedSppPresencesFilename = guppy.curFullMaxentSamplesDirName + \ CONST.dirSlash + \ "maxentGenSppPresCombined" + ".csv" combinedSppPresTable.to_csv (combinedSppPresencesFilename, index=False) # writeCsv (combinedSppPresTable, # file = combinedSppPresencesFilename, # rowNames = False, # quote=False) # Now have to make whatever changes and initializations are necessary to # call maxent and have it generate new layers in the proper subdirectory # and not do any bootstrapping. # OUTPUTS FROM THIS GENERATOR NEED TO GO INTO THE MaxentProbDistLayers # directory, just like the outputs of the arithmetic generator. # Need to see where it builds its directory name and writes to it. # Also, when maxent is finished generating these layers, there will probably # be tons of crap left in there by maxent that needs to be deleted. # This suggests it might be better to just make a scratch area for maxent # to dump into and then just copy the species distribution files I need # out of there and into the MaxentProbDistLayers directory. # Call it MaxentProbDistGenOutputs. #---------------------------------------------------------------- # Run maxent to generate a true relative probability map. #---------------------------------------------------------------- runMaxentCmd (combinedSppPresencesFilename, # guppy.maxentGenOutputDir, \ guppy.sppGenOutputDir, \ guppy.doMaxentReplicates, guppy.maxentReplicateType, \ guppy.numMaxentReplicates, \ guppy.maxentFullPathName, \ guppy.curFullMaxentEnvLayersDirName, \ guppy.numProcessors, \ guppy.verboseMaxent \ )
def run(self): # -------------------------------- # Generate environment layers. # -------------------------------- self.loadEnvLayers() # -------------------------------------------- # Generate true relative probability maps. # -------------------------------------------- self.getTrueRelProbDistMapsForAllSpp() # ---------------------------- # Generate true presences. # ---------------------------- # Currently, this also generates the Sampled presences inside # the same call to pyper genPresences(). # Need to separate that behavior out and make a new method # for Guppy to genSampledPresences() and apply a SampleBias class # to the data and the true presences to generate the # sampled presences. # ---------------------------- print "\n\n+++++\tBefore getNumTruePresencesForEachSpp()\n" sys.stdout.flush() # moved from up above. numTruePresences = self.getNumTruePresencesForEachSpp() print "\n\n+++++\tBefore genTruePresencesForAllSpp\n" sys.stdout.flush() listOfTruePresencesAndXYlocs = self.genTruePresencesForAllSpp(numTruePresences) print "\n\n+++++\tJust after self.genTruePresencesForAllSpp (numTruePresences), listOfTruePresencesAndXYlocs = " pprint(listOfTruePresencesAndXYlocs) sys.stdout.flush() # print "\n\n\n--------------- EXITING NOW ---------------\n\n\n" # exit() # combinedSppTruePresencesTable = \ # listOfTruePresencesAndXYlocs ["combined.spp.true.presences.table"] # allSppTruePresenceLocsXY = \ # listOfTruePresencesAndXYlocs ["all.spp.true.presence.locs.x.y"] # ---------------------------------------------------------------- # Run maxent to generate a predicted relative probability map. # ---------------------------------------------------------------- maxentSamplesFileName = self.combinedPresSamplesFileName print "\n\n+++++\tBefore", "runMaxentCmd", "\n" sys.stdout.flush() runMaxentCmd( maxentSamplesFileName, self.maxentOutputDir, self.doMaxentReplicates, self.maxentReplicateType, self.numMaxentReplicates, self.maxentFullPathName, self.curFullMaxentEnvLayersDirName, self.numProcessors, self.verboseMaxent, ) # ---------------------------------------------------------------- # Evaluate the results of maxent by comparing its output maps # to the true relative probability maps. # ---------------------------------------------------------------- print "\n\n+++++\tBefore" + "evaluateMaxentResults" + "\n" ### evaluateMaxentResults () ###rinterface.set_flushconsole() self.Rcaller.assign("rNumSppToCreate", self.numSppToCreate) self.Rcaller.assign("rDoMaxentReplicates", self.doMaxentReplicates) self.Rcaller.assign("rTrueProbDistFilePrefix", self.trueProbDistFilePrefix) self.Rcaller.assign("rShowRawErrorInDist", self.showRawErrorInDist) self.Rcaller.assign("rShowAbsErrorInDist", self.showAbsErrorInDist) self.Rcaller.assign("rShowPercentErrorInDist", self.showPercentErrorInDist) self.Rcaller.assign("rShowAbsPercentErrorInDist", self.showAbsPercentErrorInDist) self.Rcaller.assign("rShowTruncatedPercentErrImg", self.showTruncatedPercentErrImg) self.Rcaller.assign("rShowHeatmap", self.showHeatmap) self.Rcaller.assign("rMaxentOutputDirWithSlash", self.maxentOutputDirWithSlash) # self.Rcaller.assign('rProbDistLayersDirWithSlash', self.probDistLayersDirWithSlash) self.Rcaller.assign("rSppGenOutputDirWithSlash", self.sppGenOutputDirWithSlash) self.Rcaller.assign("rAnalysisDirWithSlash", self.analysisDirWithSlash) self.Rcaller.assign("rUseOldMaxentOutputForInput", self.PARuseOldMaxentOutputForInput) self.Rcaller.assign("rWriteToFile", self.writeToFile) self.Rcaller.assign("rUseDrawImage", self.useDrawImage) self.Rcaller("source ('/Users/Bill/D/rdv-framework/projects/guppy/evaluateMaxentResultsPyper.R')") self.Rcaller( "evaluateMaxentResults (rNumSppToCreate, rDoMaxentReplicates, \ rTrueProbDistFilePrefix, rShowRawErrorInDist, rShowAbsErrorInDist, \ rShowPercentErrorInDist, rShowAbsPercentErrorInDist, \ rShowTruncatedPercentErrImg, rShowHeatmap, rMaxentOutputDirWithSlash, \ rSppGenOutputDirWithSlash, rAnalysisDirWithSlash, \ rUseOldMaxentOutputForInput, rWriteToFile, rUseDrawImage)" )