import sys sys.path.append('..\pyfunctions') from numpy.random import seed seed(756) sys.path.append('..\\') from GetAgeFreq import GetAgeFreq from numpy import log from scipy.stats import linregress csvfile = '..\\TreeNobXdate.csv' col = 0 #Use first column from file SurveyYear = 2005 MaxYear = 1980 MinYear = 1875 data = GetAgeFreq(csvfile, col=col, SurveyYear=SurveyYear, MaxYear=MaxYear, MinYear=MinYear) nyear = len(data) fudge = [.0001, .001, .01, .1, 1] year = [t for t in range(nyear)] for t in fudge: lFA = [log(t + s) for s in data] print(t, linregress(year, lFA)[0], linregress(year, lFA)[-1])
''' 20180513 Create Model and generate MCMC ''' import sys sys.path.append('../') from GetAgeFreq import GetAgeFreq from ConstRecruitConstM import ConstRecruitConstM from ExecuteModel import ExecuteModel #Get the YearBornFrequency as a list col=0 SurveyYear=2005 MaxYear=1980 MinYear=1875 csvfile='../TreeNobXdate.csv' yearbornfrequency=GetAgeFreq(csvfile,col=col,SurveyYear=SurveyYear,MaxYear=MaxYear,MinYear=MinYear) #Create the model Model=ConstRecruitConstM(yearbornfrequency,MinYear=MinYear) #Generate the MCMC ExecuteModel(Model,Niter=1100000,burn=100000,thin=100,basename='MCMC',db='hdf5',verbose=2,maxSimplex=0,maxPowell=0,rseed=20180513)
#The values of yearborn self.YearBorn = [MinYear + i for i in range(self.nyear)] self.MidYear = MinYear + .5 * self.nyear #Inherited from Mortality-class #Generate array of ProbSurv-nodes to represent probability of survival until the survey for each of year-class self.Mortality() #Inherited from Recruitment-class #Generate array of LogRecruit-nodes to represent log of recruitment for each year-class self.Recruitment() #Inherited from SurveySampling-class #Generate array of LogProb-nodes to represent the log of the probability of appearing in the sample for each year-class self.CalcProbYearClass() #Inherited from SurveySampling-class #Assess data against the LogProb-nodes self.SampleAnimals() #Test the function if __name__ == "__main__": from GetAgeFreq import GetAgeFreq csvfile = 'TreeNobXdate.csv' yearbornfrequency = GetAgeFreq(csvfile, col=0, SurveyYear=2005, MaxYear=1980, MinYear=1875) test = LogNormRecruitConstM(yearbornfrequency)