Skip to content

Commit

Permalink
files updated for upcoming FESTC release
Browse files Browse the repository at this point in the history
  • Loading branch information
lizadams committed Jun 21, 2017
1 parent fe5de01 commit ce36647
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 54 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,19 @@
**/*.o
data
ref
CVS
src/libs
scripts/aa.txt
scripts/diff
scripts/filter_shapefile.csh
scripts/filter_surf_zone.csh
scripts/generate_surrogates_47021.csh
scripts/overlay_sites_on_egrid.csh
src/raster/extractEPIC2CMAQ.cpp.201605
src/raster/extractEPIC2CMAQ_epic0509_120216.cpp
src/raster/extractEPIC2CMAQ_epic0509_SWAT.cpp
src/raster/extractEPIC2CMAQ_swat20170301_soilW_fbare.cpp
src/raster/extractEPIC2CMAQ_swat20170301_soilW_fbare_short.cpp
src/raster/extractEPICYearlyAverage2CMAQ_csv_SWAT_201608.cpp
src/raster/extractdaily_info.csv
src/vector/
Binary file modified bin/64bits/extractEPIC2CMAQ.exe
Binary file not shown.
Binary file modified bin/64bits/extractEPICYearlyAverage2CMAQ.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion src/raster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ OPTFLAGS = -O2
#OPTFLAGS = -O -DDEBUG

#set SA HOME
SA_HOME = /nas01/depts/ie/cempd/apps/sallocator/sa_052014/src
SA_HOME = /proj/ie/proj/apps/sallocator/sa_v4.3.1_062017/src

#set GDAL library and include directory compiled using gcc
GDAL = ${SA_HOME}/libs/gdal-1.11.0/local
Expand Down
79 changes: 41 additions & 38 deletions src/raster/extractEPIC2CMAQ.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -74,44 +74,36 @@ const Line variableDescriptionsS[ ] = { "Soil Number", "Layer1 Bulk Density", "L
***********************************/
bool monthTimeStep; // monthly or daily

int numNCMFileItems = 71;

static int epicVarsPos[] = {12,13,14,15,16,17,18,19,21,22,
23,24,25,26,27,28,29,30,31,32,
33,34,35,36,37,38,39,40,41,42,
43,44,45,46,47,48,49,50,51,52,
53,54,55,56,57,58,59,60,61,62,
63,64,65,67,68,69,70};

int numEpicVars = 57;

const Name variableNamesM[ ] = { "QNO3", "SSFN", "PRKN", "DN", "DN2", "AVOL", "HMN", "NFIX", "YP", "QAP",
"YON", "YW", "Q","HUSC","HU_BASE0", "HU_FRAC", "L1_DEP", "L1_BD","L1_NO3", "L1_NH3",
"L1_ON", "L1_P", "L1_OP", "L1_C", "L1_NITR", "L2_DEP", "L2_BD", "L2_NO3","L2_NH3", "L2_ON",
"L2_P", "L2_OP", "L2_C", "L2_NITR", "T1_DEP", "T1_BD", "T1_NO3", "T1_NH3","T1_ON", "T1_P",
"T1_OP", "T1_C", "T1_NITR", "L1_ANO3", "L1_ANH3", "L1_AON", "L1_AMP", "L1_AOP","L2_ANO3", "L2_ANH3",
"L2_AON", "L2_AMP", "L2_AOP", "UN1", "HUI", "LAI", "CPHT" }; //57 vars

const Name variableUnitsM[ ] = { "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha",
"kg/ha", "ton/ha", "mm", "none", "none", "none", "m", "t/m**3","kg/ha", "kg/ha",
"kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha", "m", "t/m**3", "kg/ha","kg/ha", "kg/ha",
"kg/ha", "kg/ha", "kg/ha", "kg/ha", "m", "t/m**3","kg/ha", "kg/ha","kg/ha", "kg/ha",
"kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha","kg/ha", "kg/ha",
"kg/ha", "kg/ha", "kg/ha", "kg/ha", "None", "None", "m" }; //57 items


const Line variableDescriptionsM[ ] = { "N Loss in Surface Runoff", "N in Subsurface Flow", "N Loss in Percolate", "N-NO3 Denitrification", "N-N2O from NO3 Denitrification",
"N-NH3 Emission", "OC Change by Soil Respiration", "N Fixation", "P Loss with Sediment", "Labile P Loss in Runoff",
"N Loss with Sediment", "Wind Erosion", "Runoff", "Heat Unit Schedule", "Base Heat Unit",
"Heat Unit fraction", "Layer1 Depth", "Layer1 Bulk Density", "Layer1 N - Nitrate", "Layer1 N - Ammonia",
"Layer1 Organic N", "Layer1 Mineral P", "Layer1 Organic P", "Layer1 Carbon", "Layer1 N - Nitrified NH3",
"Layer2 Depth", "Layer2 Bulk Density", "Layer2 N - Nitrate", "Layer2 N- Ammonia", "Layer2 Organic N",
"Layer2 Mineral P", "Layer2 Organic P", "Layer2 Carbon", "Layer2 N - Nitrified NH3", "TotalSoilnoLayer1 Depth",
"TotalSoilnoLayer1 Bulk Density", "TotalSoilnoLayer1 N - Nitrate", "TotalSoilnoLayer1 N - Ammonia", "TotalSoilnoLayer1 Organic N", "TotalSoilnoLayer1 Mineral P",
"TotalSoilnoLayer1 Organic P", "TotalSoilnoLayer1 Carbon", "TotalSoilnoLayer1 N - Nitrified NH3", "Layer1 N-NO3 AppRate", "Layer1 N-NH3 AppRate",
"Layer1 ON AppRate", "Layer1 MP AppRate", "Layer1 OP AppRate", "Layer2 N-NO3 AppRate", "Layer2 N-NH3 AppRate",
"Layer2 ON AppRate", "Layer2 MP AppRate", "Layer2 OP AppRate", "N Uptake by Crop", "Heat Unit Index",
"Leaf Area Index", "Crop Height" };
int numNCMFileItems = 87;

// start from 0

static int epicVarsPos[] = {15,16,18,19,24,26,27,28,43,44,
45,46,47,48,51,52,53,54,55,56,
57,58,61,62,63,64,65,66,67,70,
71,72,73,74,77,78,79,85,86,87};

int numEpicVars = 40;

const Name variableNamesM[ ] = { "DN", "DN2", "HMN", "NFIX", "YW", "FPO", "FPL", "MNP", "L1_DEP", "L1_BD",
"L1_SW", "L1_NO3", "L1_NH3", "L1_ON", "L1_C", "L1_NITR", "L2_DEP","L2_BD", "L2_SW", "L2_NO3",
"L2_NH3", "L2_ON", "L2_C", "L2_NITR", "T1_DEP", "T1_BD", "T1_NO3", "T1_NH3","T1_ON", "T1_C",
"T1_NITR", "L1_ANO3", "L1_ANH3", "L1_AON", "L2_ANO3", "L2_ANH3", "L2_AON", "LAI", "CPHT", "FBARE" }; //40 vars

const Name variableUnitsM[ ] = { "kg/ha", "kg/ha", "kg/ha", "kg/ha", "ton/ha","kg/ha", "kg/ha", "kg/ha", "m", "t/m**3",
"mm", "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha", "m", "t/m**3", "mm", "kg/ha",
"kg/ha", "kg/ha", "kg/ha", "kg/ha", "m", "t/m**3", "kg/ha", "kg/ha","kg/ha", "kg/ha",
"kg/ha", "kg/ha", "kg/ha","kg/ha", "kg/ha", "kg/ha", "kg/ha", "m-2/m-2", "m", "fraction" }; //40 items


const Line variableDescriptionsM[ ] = { "N-NO3 Denitrification", "N-N2O from NO3 Denitrification", "OC Change by Soil Respiration", "N Fixation", "Wind Erosion",
"Organic P Fertilizer", "Labile P Fertilizer"," P Mineralized", "Layer1 Depth", "Layer1 Bulk Density",
"Layer1 Soil Water", "Layer1 N - Nitrate", "Layer1 N - Ammonia", "Layer1 N - Organic N", "Layer1 Carbon",
"Layer1 N - Nitrified NH3", "Layer2 Depth", "Layer2 Bulk Density", "Layer2 Soil Water", "Layer2 N - Nitrate",
"Layer2 N- Ammonia", "Layer2 N - Organic N", "Layer2 Carbon", "Layer2 N - Nitrified NH3", "TotalSoilnoLayer1 Depth",
"TotalSoilnoLayer1 Bulk Density", "TotalSoilnoLayer1 N - Nitrate", "TotalSoilnoLayer1 N - Ammonia", "TotalSoilnoLayer1 N - Organic N", "TotalSoilnoLayer1 Carbon",
"TotalSoilnoLayer1 N - Nitrified NH3", "Layer1 N-NO3 AppRate", "Layer1 N-NH3 AppRate", "Layer1 N-ON AppRate", "Layer2 N-NO3 AppRate",
"Layer2 N-NH3 AppRate", "Layer2 N-ON AppRate", "Leaf Area Index", "Crop Height", "Bare Land Fraction for Wind Erosion" }; //40 items



Expand Down Expand Up @@ -861,6 +853,11 @@ void extractSoilData (float *dataV[], vector<string> soilFiles, gridInfo grid)
{
int pos = soilVarsPos [ k ];
tmp_str = vecString [pos];
if ( tmp_str.find ("*") != string::npos )
{
printf ("\nError: *** in EPIC soil file- %s\n", soilFiles[i].c_str() );
exit ( 1 );
}

double soilValue = atof ( tmp_str.c_str() ) ;

Expand Down Expand Up @@ -1027,6 +1024,12 @@ void extractDMData (float *dataV[], vector<string> dmFiles, string startTimeStr,
int pos = epicVarsPos [j];
tmp_str = vecString [pos];

if ( tmp_str.find ("*") != string::npos )
{
printf ("\nError: *** in EPIC daily file- %s\n", dmFiles[i].c_str() );
exit ( 1 );
}

double epicValue = atof ( tmp_str.c_str() ) ;

dataV[dayIndex*numEpicVars+j][index] = epicValue;
Expand Down
Binary file modified src/raster/extractEPIC2CMAQ.exe
Binary file not shown.
53 changes: 38 additions & 15 deletions src/raster/extractEPICYearlyAverage2CMAQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ const char *cropFVarName = "CROPF"; //crop fraction array variable in BELD4 n
string cropNamesStr = string ( "Hay,Hay_ir,Alfalfa,Alfalfa_ir,Other_Grass,Other_Grass_ir,Barley,Barley_iri,BeansEdible,BeansEdible_ir,CornGrain,CornGrain_ir,CornSilage,CornSilage_ir,Cotton,Cotton_ir,Oats,Oats_ir,Peanuts,Peanuts_ir,Potatoes,Potatoes_ir,Rice,Rice_ir,Rye,Rye_ir,SorghumGrain,SorghumGrain_ir,SorghumSilage,SorghumSilage_ir,Soybeans,Soybeans_ir,Wheat_Spring,Wheat_Spring_ir,Wheat_Winter,Wheat_Winter_ir,Other_Crop,Other_Crop_ir,Canola,Canola_ir,Beans,Beans_ir" ); //crop number from 22 to 63

int numCrops; //number of crops in EPIC modeling
int numFileItems = 73; //title has 316 items CHECK with Verel
int numFileItems = 77; //title has 131 items


string epicVarsStr = string ("GMN,NMN,NFIX,NITR,AVOL, DN,YON,QNO3,SSFN,PRKN, FNO,FNO3,FNH3,OCPD,TOC, TNO3,DN2,YLDG,YLDF,YLN, YLP,FTN,FTP,IRGA,WS, NS,IPLD,IGMD,IHVD,YP, QAP,YW,Q"); //29+4 varaibles
string epicVarsStr = string ("GMN,NMN,NFIX,NITR,AVOL, DN,YON,QNO3,SSFN,PRKN, FNO,FNO3,FNH3,OCPD,TOC, TNO3,DN2,YLDG,YLDF,YLN, YLP,FTN,FTP,IRGA,WS, NS,IPLD,IGMD,IHVD,YP, QAP,YW,Q,SSF,PRK, PRCP,PET,ET,QDRN,MUSL, DRNN,DRNP,PRKP,FPO,FPL, MNP"); //29+4+13 varaibles


static int epicVarsPos[] = {20,21,22,23,24, 25,26,27,28,29, 30,31,32,41,43, 45,46,52,53,56, 57,58,59,60,67, 68,75,76,77,36, 37,19,14,15,16, 11,12,13,47,48, 49,50,38,33,34, 35}; //start from 1


static int epicVarsPos[] = {20,21,22,23,24, 25,26,27,28,29, 30,31,32,41,43, 45,46,48,49,52, 53,54,55,56,63, 64,71,72,73,36, 37,19,14}; //start from 1
int numEpicVars;


Expand All @@ -68,7 +70,10 @@ const Name variableNames[ ] = { "GMN", "NMN", "NFIX", "NITR", "AVOL",
"TNO3", "DN2", "YLDG", "T_YLDG", "YLDF", "T_YLDF", "YLN",
"YLP", "FTN", "FTP", "IRGA", "WS",
"NS", "IPLD", "IGMD", "IHVD", "YP",
"QAP", "YW", "Q" };
"QAP", "YW", "Q", "SSF", "PRK",
"PRCP", "PET", "ET", "QDRN", "MUSL",
"DRNN", "DRNP", "PRKP", "FPO", "FPL",
"MNP" };


const Name variableUnits[ ] = { "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha",
Expand All @@ -77,7 +82,10 @@ const Name variableUnits[ ] = { "kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha",
"kg/ha", "kg/ha", "ton/ha", "1000ton", "ton/ha", "1000ton", "kg/ha",
"kg/ha", "kg/ha", "kg/ha", "mm", "days",
"days", "Julian Date", "Julian Date", "Julian Date", "kg/ha",
"kg/ha", "ton/ha", "mm" };
"kg/ha", "ton/ha", "mm", "mm", "mm",
"mm", "mm", "mm", "mm", "ton/ha",
"kg/ha", "kg/ha", "kg/ha", "kg/ha", "kg/ha",
"kg/ha" };


const Line variableDescriptions[ ] = { "N Mineralized", "Humus Mineralization", "N Fixation", "Nitrification", "N Volitilization",
Expand All @@ -86,30 +94,45 @@ const Line variableDescriptions[ ] = { "N Mineralized", "Humus Mineralization",
"Total NO3 in Soil Profile", "Denitrification_N2", "Grain Yield", "T - Grain Yield", "Forage Yield", "T - Forage Yield", "N Used by Crop",
"P Used by Crop", "N Applied", "P Applied", "Irrigation Volume Applied", "Water Stress Days",
"N Stress Days", "Planting Date", "Germination Date", "Harvest Date", "P Loss with Sediment",
"Labile P Loss in Runoff", "Wind Erosion", "Runoff" };

"Labile P Loss in Runoff", "Wind Erosion", "Runoff", "Subsurface Flow", "Percolation",
"Rainfall", "Potential ET", "Evapotranspiration", "Drain Tile Flow", "Water erosion (MUSL)",
"Nitrogen in drain tile flow", "P in drain tile flow", "P in percolation", "Organic P fertilizer", "Organic P fertilizer",
"P mineralized" };


//output total
const Name TvariableNames[ ] = { "T_GMN", "T_NMN", "T_NFIX", "T_NITR", "T_AVOL",
"T_DN", "T_YON", "T_QNO3", "T_SSFN", "T_PRKN",
"T_FNO", "T_FNO3", "T_FNH3", "T_OCPD", "T_TOC",
"T_TNO3", "T_DN2", "T_YLN",
"T_YLP", "T_FTN", "T_FTP", "T_IRGA",
"T_YP", "T_QAP", "T_YW", "T_Q" };
"T_YP", "T_QAP", "T_YW", "T_Q",
"T_SSF", "T_PRK",
"T_PRCP", "T_PET", "T_ET", "T_QDRN", "T_MUSL",
"T_DRNN", "T_DRNP", "T_PRKP", "T_FPO", "T_FPL",
"T_MNP" };

const Name TvariableUnits[ ] = { "mt", "mt", "mt", "mt", "mt",
"mt", "mt", "mt", "mt", "mt",
"mt", "mt", "mt", "mt", "mt",
"mt", "mt", "mt",
"mt", "mt", "mt", "mm",
"mt", "mt", "1000ton", "mm" };
"mt", "mt", "1000ton", "mm",
"mm", "mm",
"mm", "mm", "mm", "mm", "1000ton",
"mt", "mt", "mt", "mt", "mt",
"mt" };

const Line TvariableDescriptions[ ] = { "T - N Mineralized", "T - Humus Mineralization", "T - N Fixation", "T - Nitrification", "T - N Volitilization",
"T - Denitrification", "T - N Loss with Sediment", "T - N Loss in Surface Runoff", "T - N in Subsurface Flow", "T - N Loss in Percolate",
"T - Organic N Fertilizer", "T - N Fertilizer Nitrate", "T - N Fertilizer Ammonia", "T - Organic Carbon in Plow Layer", "T - Organic Carbon in Soil Profile",
"T - Total NO3 in Soil Profile", "T - Denitrification_N2", "T - N Used by Crop",
"T - Used by Crop", "T - N Applied", "T - P Applied", "Crop Weighted Irrigation Volume Applied",
"T - P Loss with Sediment", "T - Labile P Loss in Runoff", "T - Wind Erosion", "T - Runoff" };
"T - P Loss with Sediment", "T - Labile P Loss in Runoff", "T - Wind Erosion", "T - Runoff",
"T - Subsurface Flow", "T - Percolation",
"T - Rainfall", "T - Potential ET", "T - Evapotranspiration", "T - Drain Tile Flow", "T - Water erosion (MUSL)",
"T - Nitrogen in drain tile flow", "T - P in drain tile flow", "T - P in percolation", "T - Organic P fertilizer", "T - Organic P fertilizer",
"T - P mineralized" };



Expand Down Expand Up @@ -350,7 +373,7 @@ int main(int nArgc, char *argv[])
/* read BELD4 file info */
/******************************/
float *cropV, *dataP;
int totalVarT = 22+4; //total chemical variables, add 4 swat vars
int totalVarT = 22+4+13; //total chemical variables, add 4 swat vars, add 13 new vars for eco-analysis
int totalVarC = 2; //total yield variables

float *TdataV[totalVarT];
Expand Down Expand Up @@ -410,7 +433,7 @@ int main(int nArgc, char *argv[])
}
else
{
dataP = dataV[i+5]; //last 4 vars from 33 vars total
dataP = dataV[i+5]; // skip 5 day varaibles to be not in total
}

for (j=0; j<grid.rows; j++)
Expand All @@ -430,9 +453,9 @@ int main(int nArgc, char *argv[])

float cellValue;

if ( Tcount == 21 || Tcount == 25 )
if ( Tcount == 21 || ( Tcount >= 25 && Tcount <= 31) )
{
cellValue = dataP[index3D] * cropV[index3D]; //Tcount=21 for IRGA Tcount=25 for Q
cellValue = dataP[index3D] * cropV[index3D]; //Tcount=21 for IRGA; Tcount=25 for Q to Tcount=31 for QDRN -- unit "mm"
total_cropP += cropV[index3D];
}
else
Expand Down Expand Up @@ -461,7 +484,7 @@ int main(int nArgc, char *argv[])

} //n crop

if ( (Tcount == 21 || Tcount == 25 ) && total_cropP > 0.0 )
if ( (Tcount == 21 || ( Tcount >= 25 && Tcount <= 31) ) && total_cropP > 0.0 )
{
TdataV[Tcount][index2D] = TdataV[Tcount][index2D] / total_cropP; //weighted by total crop area for IRGA or Q
}
Expand Down
Binary file modified src/raster/extractEPICYearlyAverage2CMAQ.exe
Binary file not shown.

0 comments on commit ce36647

Please sign in to comment.