def grow(self, day, date, fdecay, rdecay): """Evolve plant state, photosynthesis, distribute N and C" Parameters: ----------- day : intefer simulation day date : date string object date object string (yr/mth/day) fdecay : float foliage decay rate rdecay : float fine root decay rate """ daylen = day_length(date, self.params.latitude) # calculate NPP self.carbon_production(date, day, daylen) # calculate water balance and adjust C production for any water stress. # If we are using the MATE model then water stress is applied directly # through the Ci:Ca reln, so do not apply any scalar to production. if self.control.water_model == 1: self.wb.calculate_water_balance(day, daylen) # adjust carbon production for water limitations, all models except # MATE! if self.control.assim_model != 7: self.wl.adjust_cproduction(self.control.water_model) # leaf N:C as a fraction of Ncmaxyoung, i.e. the max N:C ratio of # foliage in young stand nitfac = min(1.0, self.state.shootnc / self.params.ncmaxfyoung) # figure out allocation fractions for C (alleaf, alroot, albranch, alstem, alroot_exudate) = self.allocate_carbon(nitfac) # Distribute new C and N through the system (ncbnew, ncwimm, ncwnew) = self.calculate_ncwood_ratios(nitfac) self.nitrogen_distribution(ncbnew, ncwimm, ncwnew, fdecay, rdecay, alleaf, alroot, albranch, alstem, alroot_exudate) self.carbon_distribution(alleaf, alroot, albranch, alstem, alroot_exudate, nitfac) self.update_plant_state(fdecay, rdecay)
def calc_npp(M, control, params, state, fluxes, met_data): state.lai = (params.slainit * const.M2_AS_HA / const.KG_AS_TONNES / params.cfracts * state.shoot) # Specific LAI (m2 onesided/kg DW) state.sla = params.slainit year = str(control.startyear) month = str(control.startmonth) day = str(control.startday) datex = datetime.datetime.strptime((year + month + day), "%Y%m%d") npp = np.zeros(0) for project_day in xrange(365): state.shootnc = state.shootn / state.shoot state.ncontent = (state.shootnc * params.cfracts / state.sla * const.KG_AS_G) daylen = day_length(datex, params.latitude) state.wtfac_root = 1.0 #state.lai = laidata[project_day] if float_lt(state.lai, params.lai_cover): frac_gcover = state.lai / params.lai_cover else: frac_gcover = 1.0 state.light_interception = ((1.0 - math.exp(-params.kext * state.lai / frac_gcover)) * frac_gcover) M.calculate_photosynthesis(project_day, daylen) npp = np.append(npp, fluxes.npp_gCm2) datex += datetime.timedelta(days=1) return npp.sum()
for project_day in xrange(len(met_data['prjday'])): state.shootnc = state.shootn / state.shoot # when it reads the duke file the shootn is very low and it buggers # this up if ur running standalone to test so play with the shootnc # ratio. Checked and the actual code seems fine #state.shootnc = 0.02 state.ncontent = (state.shootnc * params.cfracts / state.sla * const.KG_AS_G) daylen = day_length(datex, params.latitude) if float_lt(state.lai, params.lai_cover): frac_gcover = state.lai / params.lai_cover else: frac_gcover = 1.0 B.calculate_photosynthesis(frac_gcover, datex, project_day, daylen) print fluxes.gpp_gCm2 datex += datetime.timedelta(days=1)
#laidata = np.loadtxt(laifname) fdecay = 0.5 rdecay = 0.5 fluxes.deadleaves = 0.0 fluxes.ceaten = 0.0 fluxes.neaten = 0.0 fluxes.deadroots = 0.0 fluxes.deadbranch = 0.0 fluxes.deadstems = 0.0 for project_day in xrange(len(met_data['prjday'])): state.shootnc = state.shootn / state.shoot state.ncontent = (state.shootnc * params.cfracts / state.sla * const.KG_AS_G) daylen = day_length(datex, params.latitude) state.wtfac_root = 1.0 #state.lai = laidata[project_day] if float_lt(state.lai, params.lai_cover): frac_gcover = state.lai / params.lai_cover else: frac_gcover = 1.0 state.fpar = ((1.0 - exp(-params.kext * state.lai / frac_gcover)) * frac_gcover) PG.grow(project_day, datex, fdecay, rdecay) print fluxes.gpp / const.HA_AS_M2 * const.TONNES_AS_G datex += datetime.timedelta(days=1)