/*This program calculates the annual peak biomass of the non-sedge C4 grass Spartina patens (Aiton) Muhl. and Distichlis spicata (L.) Greene. Other species include Atriplex patula,
Iva frutescens, Kosteletskya virginica, Lythrum lineare, and Polygonum hydropiper etc. They are from an experiment that begain in 1987 in which the air CO2 concentration was increased
in three plant communities. The program ingests data from the file that has stem count and dry weight from each clipped plot. This file is used to calculate the area-based dry mass
for C4 grass and other species. This file represent the data in a clean but largely unmodified form. Because methods varied over the course of this long-term study, there is code
that makes a variety of adjustments to the input data in order arrive at a comparable annual figure for each plot. Contact Pat Megonigal for details.*/
/******************************************START QUADRAT-BASED HARVEST DATA FOR NON-SEDGE BIOMASS******************************/
proc import datafile="S:\Biogeochemistry\GCREW\0-GCREW Archive\Archived Data\1-CO2xCommunity\
4-C4 Harvest Data\CO2xComm Master C4 Harvest 1987-2019 (published 04-21-2020).csv"
out=SPbiomass
dbms=dlm
replace;
delimiter=",";
proc sort; by year community treatment chamber quadrat;
run;
data Biomass; set SPbiomass;
/*Assign Missing Values*/
if SPCount=-99 then SPCount=.;
if SPGreenMass=-99 then SPGreenMass=.; /*identifying missing values*/
if SPScenescentMass=-99 then SPScenescentMass=.;
if SPTotalMass=-99 then SPTotalMass=.;
if DICount=-99 then DICount=.;
if DIGreenMass=-99 then DIGreenMass=.;
if DIScenescentMass=-99 then DIScenescentMass=.;
if DITotalMass=-99 then DITotalMass=.;
if Other1Count=-99 then Other1Count=.;
if Other1Mass=-99 then Other1Mass=.;
if Other2Count=-99 then Other2Count=.;
if Other2Mass=-99 then Other2Mass=.;
/*In the early years of the study, individual stems of the C4 species (SP and DI) were sometimes separated in the portion that was green and the portion
that was scenescent. The mass of the green portion was always recorded, but not always the mass of the scenescent portion or the total (green+scenescent)
mass. Thus, the dataset sometimes has just the green fraction, sometimes just the total biomass, and sometimes the green and scenescent mass but not the
total. The calculation below generates a total mass for cases where it was not recorded. In some years (e.g. 1987) this total consists only of the green
biomass fraction because no scenescent mass was recorded; in these cases total biomass is an underestimate for SP and DI*/
if SPTotalMass=. then SPTotalMass=sum(SPGreenMass, SPScenescentMass);
if DITotalMass=. then DITotalMass=sum(DIGreenMass, DIScenescentMass);
/*Sum the biomass and counts of the two "OTHER" species categories into one category*/
OTHERMass=sum(OTHER1Mass, OTHER2Mass);
OTHERCount=sum(OTHER1Count, OTHER2Count);
/*FIX 1987 and 1988 UNITS*/
/*In 1987-1988 the raw data show a single chamber-wide value for all variables. We do not know how they arrived at a whole chamber figure, but the values
represent total biomass or total stem counts in units of grams per m2. There is no quadrat information. In order to simplify our calculations below, we
converted the 1987 and 1988 to units that match the replicate 25 cm2 quadrats that were used from 1989 data onward. To do this we assigned quadrat a
value of "1" (rather than -99) to effectively make the chamber one big quadrat. Then we convert to 25 cm2 by dividing by 0.0025 (i.e. cm2 converted to m2).*/
if year=1987 or year=1988 then do;
quadrat=1;
SPCount=SPCount/(1/0.0025);
SPTotalMass=SPTotalMass/(1/0.0025);
DICount=DICount/(1/0.0025);
DITotalMass=DITotalMass/(1/0.0025);
OTHERCount=OTHERCount/(1/0.0025);
OTHERMass=OTHERMass/(1/0.0025);
end;
run;
Data QuadratMass; set Biomass;
proc sort; by year community treatment chamber;
proc means noprint;
var SPTotalMass DITotalMass OTHERMass SPCount DICount OTHERCount;
by year community treatment chamber;
output out=QuadMass (drop = _type_ _freq_) mean=SPTotalMass DITotalMass OTHERMass SPCount DICount OTHERCount;
run;
Data ChamberMass; set QuadMass;
SPmass_m2=SPTotalMass/0.0025;/*Divide by 0.0025 m2, the area in m2 of the 5cm x 5cm quadrats*/
DImass_m2=DITotalMass/0.0025;
OTHERmass_m2=OTHERMass/0.0025;
SPdensity_m2=SPCount/0.0025;
DIdensity_m2=DICount/0.0025;
OTHERdensity_m2=OTHERCount/0.0025;
run;
/******************************************END QUADRAT-BASED HARVEST DATA FOR NON-SEDGE BIOMASS******************************/
/*************************************START WHOLE CHAMBER-BASED HARVEST DATA FOR 1989, 1990 & 1993 *************************/
/*When the study began in 1987 the plots in the Scirpus community were purely Scripus (SC). Apparently other species began to emerge in the SC plots, so
a decision was made in 1989, 1990 and 1993 to completely harvest all of the non-sedge species. In 1989 these other species were counted but not weighted
for mass. Both counts and mass were determined on the non-sedge harvest in 1990 and 1993. These data are in a separate file from the regular harvest data
because the methods were so different. Here we read in that file and tranform the variables so that species are in columns as in the SPbiomass file.*/
Data WholeChamber; set WCdata;
proc import datafile="S:\Biogeochemistry\GCREW\0-GCREW Archive\Archived Data\1-CO2xCommunity\
4-C4 Harvest Data\CO2xComm Full-Chamber Harvests 89-90-93 (08-21-2015).csv"
out=WCdata
dbms=dlm
replace;
delimiter=",";
run;
Data WC3Species; set WholeChamber;
if Count=-99 then Count=.;
If Mass=-99 then Mass=.;
if species eq 'C4DEAD' then delete;
If species ne 'SPPA' and species ne "DISP" then species="OTHER";
run;
proc sort; by year community treatment chamber species;
run;
Data WC3SpeciesSum; set WC3Species;
proc means noprint;
var Count Mass;
by year community treatment chamber species;
output out=WCsums (drop = _type_ _freq_) sum=WCCount WCMass;
run;
proc transpose data=WCsums
out=WCcount;
var WCCount;
by year community treatment chamber;
run;
proc transpose data=WCsums
out=WCmass;
var WCMass;
by year community treatment chamber;
run;
Data TransMerge; merge WCcount (rename=(COL1=DIWCCount COL2=OTHERWCCount COL3=SPWCCount) drop=_NAME_)
WCmass (rename=(COL1=DIWCMass COL2=OTHERWCMass COL3=SPWCMass) drop=_NAME_);
by year community treatment chamber;
run;
/*************************************END WHOLE CHAMBER-BASED HARVEST DATA FOR 1989, 1990 & 1993 *************************/
/*Combine the quadrat-based and whole chamber-based biomass into a single dataset to calculate density and biomass of non-sedge species*/
Data MergeData; merge ChamberMass TransMerge; by year community treatment chamber;
SPmass_m2=sum(SPmass_m2, SPWCMass);
DImass_m2=sum(DImass_m2, DIWCMass);
OTHERmass_m2=sum(OTHERmass_m2, OTHERWCMass);
SPdensity_m2=sum(SPdensity_m2, SPWCCount);
DIdensity_m2=sum(DIdensity_m2, DIWCCount);
OTHERdensity_m2=sum(OTHERdensity_m2, OTHERWCCount);
run;
Data AllNonSedge; set MergeData (drop=SPTotalMass DITotalMass OTHERMass SPCount DICount OTHERCount OTHERWCCount SPWCCount DIWCCount OTHERWCMass SPWCMass DIWCMass);
if SPmass_m2=. then SPmass_m2=-99;
if DImass_m2=. then DImass_m2=-99;
if OTHERmass_m2=. then OTHERmass_m2=-99;
if SPdensity_m2=. then SPdensity_m2=-99;
if DIdensity_m2=. then DIdensity_m2=-99;
if OTHERdensity_m2=. then OTHERdensity_m2=-99;
run;
proc export data=AllNonSedge
outfile='S:\Biogeochemistry\GCREW\0-GCREW Archive\Archived Data\1-CO2xCommunity\1-Biomass (Derived)\
2-CO2xComm Non-Sedge Shoot Biomass 1987-2019.csv' replace dbms=dlm; delimiter=',';
run;