ALMaSS Partridge ODdox  1.1
The partridge model description following ODdox protocol
k_factors Class Reference

Class for calculating k-factors. More...

#include <Partridge_All.h>

Public Member Functions

void calcreal_1 ()
 
void calcreal_2 ()
 
void calcreal_3 ()
 
void calcDickPottsk ()
 
void Output_kfactors ()
 
void CreateInfoDatabaseFile ()
 
 k_factors ()
 
 ~k_factors ()
 

Public Attributes

population_attributesm_ThisYear
 
population_attributesm_LastYear
 

Protected Member Functions

void reset ()
 
void DumpInfoDatabase1 (int, int, double)
 
void DumpInfoDatabase ()
 

Protected Attributes

FILE * kfactorsfile
 
double m_rk1
 
double m_rk2
 
double m_rk3
 
double m_rk4
 
double m_rk5
 
double m_rk6
 
double m_dpk1
 
double m_dpk2
 
double m_dpk3
 
double m_dpk4
 
double m_dpk5
 

Detailed Description

Class for calculating k-factors.

Definition at line 235 of file Partridge_All.h.

Constructor & Destructor Documentation

◆ k_factors()

k_factors::k_factors ( )

Definition at line 2858 of file Partridge_All.cpp.

2859 {
2860  kfactorsfile = fopen("k_factors_output.txt", "w" );
2861  if ( !kfactorsfile ) {
2862  g_msg->Warn( "k_factors::k_factors()","Cannot open k_factors_output.txt" );
2863  exit( 1 );
2864  }
2867  reset();
2868 }

References g_msg, kfactorsfile, m_LastYear, m_ThisYear, reset(), and MapErrorMsg::Warn().

◆ ~k_factors()

k_factors::~k_factors ( )

Definition at line 2871 of file Partridge_All.cpp.

2872 {
2873  fclose( kfactorsfile );
2874  delete m_ThisYear;
2875  delete m_LastYear;
2876 }

References kfactorsfile, m_LastYear, and m_ThisYear.

Member Function Documentation

◆ calcDickPottsk()

void k_factors::calcDickPottsk ( )

Definition at line 3026 of file Partridge_All.cpp.

3027 {
3028  // Dick makes some assumptions such it is assumed old males seen on 1st sept
3029  // is the same number as the number of pairs in Spring.
3030  // He also uses a calculation for the number of chicks hatched based on
3031  // the geometric mean of brood size on 1st September.
3032  // k2 assumes the differences between old males and old females is female on nest mortality
3033 
3034  // Requires the following values to be set before entry:
3035  // 1) GeoMean brood size, 1st sept.
3036  // 2) No. old males
3037  // 3) No. old females
3038  // 4) No. Males Sept
3039  // 5) No. Females Sept
3040  // 6) No. Females Sept of last year
3041  // 7) No. chicks at 1st Sept.
3042 
3043  // Calculate HatchedChicks
3044  double HatchedChicks;
3045  double CSR;
3046  if ( m_LastYear->m_geomeanBroodSize < 10.0 ) CSR = 0.03665 * ( pow( ( double )m_LastYear->m_geomeanBroodSize, ( double )1.293 ) );
3047  else
3048  CSR = m_LastYear->m_geomeanBroodSize / 13.84;
3049  if ( CSR > 0 ) HatchedChicks = m_LastYear->m_NoChicksSept / CSR;
3050  else
3051  HatchedChicks = 0;
3052  //
3053  double Broods = HatchedChicks / 13.8; // 13.8 is the mean brood size used by Dick, but we use 14
3054  // k2 is assuming old males is the same as pairs
3055  m_dpk2 = log10( ( double )( 1 + m_LastYear->m_NoOldMales ) / ( double )( 1 + m_LastYear->m_NoOldFemales ) );
3056  // k1 assumes old males in sept is the same as no. pairs in spring
3057  m_dpk1 = log10( ( double )( 1 + m_LastYear->m_NoOldMales ) / ( 1 + Broods ) ) - m_dpk2;
3058  // k3 contains a calculated number of chicks at six weeks based on the number
3059  // of chicks in Sept and brood size.
3060  m_dpk3 = log10( ( double )( 1 + HatchedChicks ) / ( double )( 1 + m_LastYear->m_NoChicksSept ) );
3061  // k4 Shooting numbers recorded so should be solid
3062  double NoBirdsAfterShoot = ( ( m_LastYear->m_NoMalesSept + m_LastYear->m_NoFemalesSept ) - m_LastYear->m_NoShotBirds );
3063  m_dpk4 = log10( ( double )( ( 1 + m_LastYear->m_NoMalesSept + m_LastYear->m_NoFemalesSept ) ) / ( double )( 1 + NoBirdsAfterShoot ) );
3064  // k5 - tricky one. Assumes 1:1 sex ratio. Assumes that the number of females
3065  // at the end of year 1 is equal to the number of breeding males and this is
3066  // equal to the number of old males in year 2. Hence the difference is the number
3067  // of birds that die of everything else except hen mortality.
3068  m_dpk5 = log10( ( double )( 1 + (m_LastYear->m_NoFemalesSept - m_LastYear->m_NoShotFemales)) / ( double )( 1 + m_ThisYear->m_NoOldMales ) );
3069  DumpInfoDatabase1( ( int )Broods, ( int )HatchedChicks, CSR );
3070 
3072  //m_ThisYear->reset(); // ***CJT*** 6/7/2010 removed because otherwise our counts are destroyed - why was this here?
3073 }

References population_attributes::copyself(), DumpInfoDatabase1(), m_dpk1, m_dpk2, m_dpk3, m_dpk4, m_dpk5, population_attributes::m_geomeanBroodSize, m_LastYear, population_attributes::m_NoChicksSept, population_attributes::m_NoFemalesSept, population_attributes::m_NoMalesSept, population_attributes::m_NoOldFemales, population_attributes::m_NoOldMales, population_attributes::m_NoShotBirds, population_attributes::m_NoShotFemales, and m_ThisYear.

Referenced by Partridge_Population_Manager::DoFirst().

◆ calcreal_1()

void k_factors::calcreal_1 ( )

Definition at line 2994 of file Partridge_All.cpp.

2995 {
2996  // These can be calculated on Sept 1st.
2997  double anum = 1 + ( m_ThisYear->m_NoClutches - m_ThisYear->m_NoHensPredated );
2998  m_rk2 = log10( ( 1 + m_ThisYear->m_NoClutches ) / anum );
2999  anum = 1 + m_ThisYear->m_NoClutchesHatched;
3000  m_rk1 = log10( ( 1 + m_ThisYear->m_NoClutches ) / anum ) - m_rk2;
3001  anum = 1 + m_ThisYear->m_NoChicksSept;
3002  m_rk3 = log10( ( 1 + m_ThisYear->m_NoChicksHatched ) / anum );
3003 }

References population_attributes::m_NoChicksHatched, population_attributes::m_NoChicksSept, population_attributes::m_NoClutches, population_attributes::m_NoClutchesHatched, population_attributes::m_NoHensPredated, m_rk1, m_rk2, m_rk3, and m_ThisYear.

Referenced by Partridge_Population_Manager::DoFirst().

◆ calcreal_2()

void k_factors::calcreal_2 ( )

Definition at line 3006 of file Partridge_All.cpp.

3007 {
3008  // This can only be calculated after shooting
3009  double NoBirdsAfterShoot = ( ( m_ThisYear->m_NoMalesSept + m_ThisYear->m_NoFemalesSept ) - m_ThisYear->m_NoShotBirds );
3010  double anum = 1 + NoBirdsAfterShoot;
3011  m_rk4 = log10( ( 1 + m_ThisYear->m_NoMalesSept + m_ThisYear->m_NoFemalesSept ) / anum );
3012 }

References population_attributes::m_NoFemalesSept, population_attributes::m_NoMalesSept, population_attributes::m_NoShotBirds, m_rk4, and m_ThisYear.

Referenced by Partridge_Population_Manager::DoFirst().

◆ calcreal_3()

void k_factors::calcreal_3 ( )

Definition at line 3015 of file Partridge_All.cpp.

3016 {
3017  // K5 is the number of males and females in Sept/those that survive to
3018  // breeding time. This means k5 can only be calculated in April.
3019  double anum = 1 + m_ThisYear->m_NoFemalesSept - m_ThisYear->m_NoShotBirds / 2;
3020  m_rk5 = log10( anum / ( double )( 1 + m_ThisYear->m_NoFemalesApril ) );
3022  m_rk6 = log10( anum / ( double )( 1 + m_ThisYear->m_NoBirdsApril ) );
3023 }

References population_attributes::m_NoBirdsApril, population_attributes::m_NoFemalesApril, population_attributes::m_NoFemalesSept, population_attributes::m_NoMalesSept, population_attributes::m_NoShotBirds, m_rk5, m_rk6, and m_ThisYear.

Referenced by Partridge_Population_Manager::DoFirst().

◆ CreateInfoDatabaseFile()

void k_factors::CreateInfoDatabaseFile ( )

Open a k-factor output file.

Definition at line 3145 of file Partridge_All.cpp.

3146 {
3147  FILE * idb = fopen("k_facInfoBase.txt", "w" );
3148  if (!idb) {
3149  g_msg->Warn("k_factors::CreateInfoDatabaseFile","Cannot open k_facInfoBase.txt" );
3150  exit( 1 );
3151  }
3152  fclose( idb );
3153 }

References g_msg, and MapErrorMsg::Warn().

Referenced by Partridge_Population_Manager::Init().

◆ DumpInfoDatabase()

void k_factors::DumpInfoDatabase ( )
protected

Definition at line 3088 of file Partridge_All.cpp.

3089 {
3090  FILE * idb = fopen("k_facInfoBase.txt", "a" );
3091  if (!idb) {
3092  g_msg->Warn( "k_factors::DumpInfoDatabase","Cannot open k_facInfoBase.txt" );
3093  exit( 1 );
3094  }
3095  fprintf( idb, "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%g\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
3102 
3103  /*
3104  1m_NoClutches,
3105  2m_NoClutchesHatched,
3106  3m_NoHensPredated,
3107  4m_NoChicksSixWeeks,
3108  5m_NoChicksSept,
3109  6m_NoMalesSept,
3110  7m_NoFemalesSept,
3111  8m_NoDeadFemales,
3112  9m_NoDeadMales,
3113  10m_NoShotBirds,
3114  11m_NoChicksHatched,
3115  12m_NoOldMales,
3116  13m_NoOldFemales,
3117  14m_geomeanBroodSize,
3118  15m_NoClutchesPredated,
3119  16m_NoFemalesApril,
3120  17m_NoTerritorialFemalesApril,
3121  18m_NoDeadChicks,
3122  19m_NoDeadClutches,
3123  20m_NoClutchesReplacements,
3124  21m_NoAgDeadClutches,
3125  22m_NoPairsApril,
3126  23m_NoMalesApril,
3127  24m_NoTerritorialFemalesMay,
3128  25m_NoNonTerritorialFemalesMay
3129  26m_NoMalesDec
3130  27m_NoFemalesDec
3131  28m_NoChick1sAug,
3132  29m_NoChick2sAug,
3133  30m_NoMalesAug,
3134  31m_NoFemsAug
3135  32m_NoStarvedChicks
3136  */
3137 
3138  fclose( idb );
3139 }

References g_msg, population_attributes::m_geomeanBroodSize, population_attributes::m_NoAgDeadClutches, population_attributes::m_NoChick1sAug, population_attributes::m_NoChick2sAug, population_attributes::m_NoChicksHatched, population_attributes::m_NoChicksSept, population_attributes::m_NoChicksSixWeeks, population_attributes::m_NoClutches, population_attributes::m_NoClutchesHatched, population_attributes::m_NoClutchesPredated, population_attributes::m_NoClutchesReplacements, population_attributes::m_NoDeadChicks, population_attributes::m_NoDeadClutches, population_attributes::m_NoDeadFemales, population_attributes::m_NoDeadMales, population_attributes::m_NoFemalesApril, population_attributes::m_NoFemalesDec, population_attributes::m_NoFemalesSept, population_attributes::m_NoFemsAug, population_attributes::m_NoHensPredated, population_attributes::m_NoMalesApril, population_attributes::m_NoMalesAug, population_attributes::m_NoMalesDec, population_attributes::m_NoMalesSept, population_attributes::m_NoNonTerritorialFemalesMay, population_attributes::m_NoOldFemales, population_attributes::m_NoOldMales, population_attributes::m_NoPairsApril, population_attributes::m_NoShotBirds, population_attributes::m_NoShotFemales, population_attributes::m_NoStarvedChicks, population_attributes::m_NoTerritorialFemalesApril, population_attributes::m_NoTerritorialFemalesMay, m_ThisYear, and MapErrorMsg::Warn().

Referenced by Output_kfactors().

◆ DumpInfoDatabase1()

void k_factors::DumpInfoDatabase1 ( int  Broods,
int  HC,
double  CSR 
)
protected

Definition at line 3076 of file Partridge_All.cpp.

3077 {
3078  FILE * idb = fopen("k_facInfoBase.txt", "a" );
3079  if ( !idb ) {
3080  g_msg->Warn( "k_factors::DumpInfoDatabase1","Cannot open k_facInfoBase.txt" );
3081  exit( 1 );
3082  }
3083  fprintf( idb, "%d\t%d\t%d\t%g\t", HC, Broods, m_ThisYear->m_NoOldMales, CSR );
3084  fclose( idb );
3085 }

References g_msg, population_attributes::m_NoOldMales, m_ThisYear, and MapErrorMsg::Warn().

Referenced by calcDickPottsk().

◆ Output_kfactors()

void k_factors::Output_kfactors ( )

Definition at line 2893 of file Partridge_All.cpp.

2894 {
2895  //calcDickPottsk();
2896  fprintf( kfactorsfile, "%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\n", m_rk1, m_rk2, m_rk3, m_rk4, m_rk5, m_rk6, m_dpk1,
2897  m_dpk2, m_dpk3, m_dpk4, m_dpk5 );
2898  fflush( kfactorsfile );
2899  DumpInfoDatabase();
2900  reset();
2901 }

References DumpInfoDatabase(), kfactorsfile, m_dpk1, m_dpk2, m_dpk3, m_dpk4, m_dpk5, m_rk1, m_rk2, m_rk3, m_rk4, m_rk5, m_rk6, and reset().

Referenced by Partridge_Population_Manager::DoFirst().

◆ reset()

void k_factors::reset ( )
protected

Definition at line 2978 of file Partridge_All.cpp.

2979 {
2980  m_ThisYear-> reset();
2981  m_rk1 = 0;
2982  m_rk2 = 0;
2983  m_rk3 = 0;
2984  m_rk4 = 0;
2985  m_rk5 = 0;
2986  m_dpk1 = 0;
2987  m_dpk2 = 0;
2988  m_dpk3 = 0;
2989  m_dpk4 = 0;
2990  m_dpk5 = 0;
2991 
2992 }

References m_dpk1, m_dpk2, m_dpk3, m_dpk4, m_dpk5, m_rk1, m_rk2, m_rk3, m_rk4, m_rk5, and m_ThisYear.

Referenced by k_factors(), and Output_kfactors().

Member Data Documentation

◆ kfactorsfile

FILE* k_factors::kfactorsfile
protected

This class contains the functionality required to make two types of k-factors the first type is the 'real' k-factor, the second is the way Dick Potts calculated his.
Not yet functional/tested - 5thOct2008

Definition at line 243 of file Partridge_All.h.

Referenced by k_factors(), Output_kfactors(), and ~k_factors().

◆ m_dpk1

double k_factors::m_dpk1
protected

Definition at line 245 of file Partridge_All.h.

Referenced by calcDickPottsk(), Output_kfactors(), and reset().

◆ m_dpk2

double k_factors::m_dpk2
protected

Definition at line 245 of file Partridge_All.h.

Referenced by calcDickPottsk(), Output_kfactors(), and reset().

◆ m_dpk3

double k_factors::m_dpk3
protected

Definition at line 245 of file Partridge_All.h.

Referenced by calcDickPottsk(), Output_kfactors(), and reset().

◆ m_dpk4

double k_factors::m_dpk4
protected

Definition at line 245 of file Partridge_All.h.

Referenced by calcDickPottsk(), Output_kfactors(), and reset().

◆ m_dpk5

double k_factors::m_dpk5
protected

Definition at line 245 of file Partridge_All.h.

Referenced by calcDickPottsk(), Output_kfactors(), and reset().

◆ m_LastYear

population_attributes* k_factors::m_LastYear

Definition at line 252 of file Partridge_All.h.

Referenced by calcDickPottsk(), k_factors(), and ~k_factors().

◆ m_rk1

double k_factors::m_rk1
protected

Definition at line 244 of file Partridge_All.h.

Referenced by calcreal_1(), Output_kfactors(), and reset().

◆ m_rk2

double k_factors::m_rk2
protected

Definition at line 244 of file Partridge_All.h.

Referenced by calcreal_1(), Output_kfactors(), and reset().

◆ m_rk3

double k_factors::m_rk3
protected

Definition at line 244 of file Partridge_All.h.

Referenced by calcreal_1(), Output_kfactors(), and reset().

◆ m_rk4

double k_factors::m_rk4
protected

Definition at line 244 of file Partridge_All.h.

Referenced by calcreal_2(), Output_kfactors(), and reset().

◆ m_rk5

double k_factors::m_rk5
protected

Definition at line 244 of file Partridge_All.h.

Referenced by calcreal_3(), Output_kfactors(), and reset().

◆ m_rk6

double k_factors::m_rk6
protected

Definition at line 244 of file Partridge_All.h.

Referenced by calcreal_3(), and Output_kfactors().

◆ m_ThisYear


The documentation for this class was generated from the following files:
k_factors::m_ThisYear
population_attributes * m_ThisYear
Definition: Partridge_All.h:251
k_factors::m_rk5
double m_rk5
Definition: Partridge_All.h:244
k_factors::m_dpk1
double m_dpk1
Definition: Partridge_All.h:245
k_factors::DumpInfoDatabase
void DumpInfoDatabase()
Definition: Partridge_All.cpp:3088
k_factors::m_rk3
double m_rk3
Definition: Partridge_All.h:244
population_attributes::m_NoMalesSept
int m_NoMalesSept
Definition: Partridge_All.h:53
population_attributes::m_NoDeadMales
int m_NoDeadMales
Definition: Partridge_All.h:75
k_factors::m_dpk4
double m_dpk4
Definition: Partridge_All.h:245
population_attributes::m_NoNonTerritorialFemalesMay
int m_NoNonTerritorialFemalesMay
Definition: Partridge_All.h:77
population_attributes::m_NoStarvedChicks
int m_NoStarvedChicks
Definition: Partridge_All.h:84
population_attributes::m_geomeanBroodSize
double m_geomeanBroodSize
Definition: Partridge_All.h:60
population_attributes::m_NoTerritorialFemalesApril
int m_NoTerritorialFemalesApril
Definition: Partridge_All.h:67
population_attributes::m_NoOldFemales
int m_NoOldFemales
Definition: Partridge_All.h:59
k_factors::m_dpk2
double m_dpk2
Definition: Partridge_All.h:245
k_factors::m_rk6
double m_rk6
Definition: Partridge_All.h:244
k_factors::m_rk4
double m_rk4
Definition: Partridge_All.h:244
population_attributes::m_NoChicksHatched
int m_NoChicksHatched
Definition: Partridge_All.h:51
k_factors::m_rk2
double m_rk2
Definition: Partridge_All.h:244
population_attributes::m_NoDeadChicks
int m_NoDeadChicks
Definition: Partridge_All.h:73
population_attributes::m_NoChick2sAug
int m_NoChick2sAug
Definition: Partridge_All.h:81
k_factors::kfactorsfile
FILE * kfactorsfile
Definition: Partridge_All.h:243
k_factors::DumpInfoDatabase1
void DumpInfoDatabase1(int, int, double)
Definition: Partridge_All.cpp:3076
population_attributes::m_NoAgDeadClutches
int m_NoAgDeadClutches
Definition: Partridge_All.h:72
population_attributes::m_NoFemalesApril
int m_NoFemalesApril
Definition: Partridge_All.h:65
population_attributes
Definition: Partridge_All.h:45
population_attributes::m_NoMalesDec
int m_NoMalesDec
Definition: Partridge_All.h:69
population_attributes::m_NoMalesApril
int m_NoMalesApril
Definition: Partridge_All.h:66
k_factors::m_rk1
double m_rk1
Definition: Partridge_All.h:244
population_attributes::m_NoFemsAug
int m_NoFemsAug
Definition: Partridge_All.h:83
g_msg
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:41
population_attributes::m_NoChicksSept
int m_NoChicksSept
Definition: Partridge_All.h:55
population_attributes::m_NoFemalesSept
int m_NoFemalesSept
Definition: Partridge_All.h:54
population_attributes::m_NoShotBirds
int m_NoShotBirds
Definition: Partridge_All.h:56
population_attributes::m_NoBirdsApril
int m_NoBirdsApril
Definition: Partridge_All.h:68
k_factors::m_dpk5
double m_dpk5
Definition: Partridge_All.h:245
population_attributes::copyself
void copyself(population_attributes *a_population_attributes)
Definition: Partridge_All.cpp:2904
population_attributes::m_NoClutchesPredated
int m_NoClutchesPredated
Definition: Partridge_All.h:62
population_attributes::m_NoTerritorialFemalesMay
int m_NoTerritorialFemalesMay
Definition: Partridge_All.h:76
population_attributes::m_NoChicksSixWeeks
int m_NoChicksSixWeeks
Definition: Partridge_All.h:52
k_factors::m_LastYear
population_attributes * m_LastYear
Definition: Partridge_All.h:252
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
k_factors::m_dpk3
double m_dpk3
Definition: Partridge_All.h:245
population_attributes::m_NoClutchesReplacements
int m_NoClutchesReplacements
Definition: Partridge_All.h:61
population_attributes::m_NoChick1sAug
int m_NoChick1sAug
Definition: Partridge_All.h:80
population_attributes::m_NoFemalesDec
int m_NoFemalesDec
Definition: Partridge_All.h:70
population_attributes::m_NoPairsApril
int m_NoPairsApril
Definition: Partridge_All.h:64
k_factors::reset
void reset()
Definition: Partridge_All.cpp:2978
population_attributes::m_NoOldMales
int m_NoOldMales
Definition: Partridge_All.h:58
population_attributes::m_NoShotFemales
int m_NoShotFemales
Definition: Partridge_All.h:57
population_attributes::m_NoDeadFemales
int m_NoDeadFemales
Definition: Partridge_All.h:74
population_attributes::m_NoClutches
int m_NoClutches
Definition: Partridge_All.h:50
population_attributes::m_NoHensPredated
int m_NoHensPredated
Definition: Partridge_All.h:63
population_attributes::m_NoDeadClutches
int m_NoDeadClutches
Definition: Partridge_All.h:71
population_attributes::m_NoClutchesHatched
int m_NoClutchesHatched
Definition: Partridge_All.h:78
population_attributes::m_NoMalesAug
int m_NoMalesAug
Definition: Partridge_All.h:82