diff --git a/GAMS/IntExtOpt.gms b/GAMS/IntExtOpt.gms index aa7e1d674dadb3acccbfe82cc7b38f00ace84e5b..2a0baeee4ffad4c29b62c76b9ccd6fa8ebbe6b24 100644 --- a/GAMS/IntExtOpt.gms +++ b/GAMS/IntExtOpt.gms @@ -1,13 +1,13 @@ - SET all_types / meat, cereals, wheat, maize, rice, tropicalCereals, oilcrops, soybean, pulses, starchyRoots, pasture /; + SET all_types / meat, cereals, wheat, maize, rice, tropicalCereals, oilcrops, pulses, starchyRoots, pasture /; - SET crop(all_types) / wheat, maize, rice, tropicalCereals, oilcrops, soybean, pulses, starchyRoots, pasture /; - SET crop_less_pasture(crop) / wheat, maize, rice, tropicalCereals, oilcrops, soybean, pulses, starchyRoots /; + SET crop(all_types) / wheat, maize, rice, tropicalCereals, oilcrops, pulses, starchyRoots, pasture /; + SET crop_less_pasture(crop) / wheat, maize, rice, tropicalCereals, oilcrops, pulses, starchyRoots /; SET cereal_crop(crop) / wheat, maize, rice, tropicalCereals /; - SET non_cereal_crop(crop) / oilcrops, soybean, pulses, starchyRoots, pasture /; - SET feed_crop(crop) / wheat, maize, oilcrops, soybean, pasture/; - SET feed_crop_less_pasture(feed_crop) / wheat, maize, oilcrops, soybean /; + SET non_cereal_crop(crop) / oilcrops, pulses, starchyRoots, pasture /; + SET feed_crop(crop) / wheat, maize, oilcrops, pasture/; + SET feed_crop_less_pasture(feed_crop) / wheat, maize, oilcrops /; SET not_feed_crop(crop) / rice, tropicalCereals, pulses, starchyRoots /; - SET import_crop(all_types) / meat, wheat, maize, rice, tropicalCereals, oilcrops, soybean, pulses, starchyRoots /; + SET import_crop(all_types) / meat, wheat, maize, rice, tropicalCereals, oilcrops, pulses, starchyRoots /; SET location; PARAMETER suitableLandArea(location) areas of land in Mha; @@ -48,7 +48,6 @@ $gdxin / wheat 0.89 maize 0.7 oilcrops 0.9 - soybean 0.7 pasture 1 / ; * pasture yield is done in DM terms @@ -58,7 +57,6 @@ $gdxin rice 1.1 tropicalCereals 0.9 oilcrops 0.7 - soybean 0.6 pulses 0.5 starchyRoots 4.0 pasture 0.1 / ; diff --git a/config.properties b/config.properties index 95a36d5f156d32233f3c08db54373d353dc39f1d..919ca77f27e7453d6a45ae0f1cd97016ac81ad55 100644 --- a/config.properties +++ b/config.properties @@ -1,2 +1,3 @@ BASE_DIR=/Users/peteralexander/Documents/R_Workspace/UNPLUM -YIELD_DIR=/Users/peteralexander/Documents/LURG/LPJ \ No newline at end of file +YIELD_DIR=/Users/peteralexander/Documents/LURG/LPJ +CHANGE_YIELD_DATA_YEAR=false \ No newline at end of file diff --git a/data/con_prod_c_and_m.csv b/data/con_prod_c_and_m.csv index d749f33a29eb34fe30bdde21580a946b56ec9709..4abec649d03cf6c405d932e2189a31666ae1cb0a 100644 --- a/data/con_prod_c_and_m.csv +++ b/data/con_prod_c_and_m.csv @@ -1022,176 +1022,6 @@ Madagascar,2010,TropicalCereals,0.002565,0,0.00237968437908439,0.001445315620915 Occupied Palestinian Territory,2010,TropicalCereals,0.000285,0.000126,0,0.00015,0 Solomon Islands,2010,TropicalCereals,0,0,0,0,0 Somalia,2010,TropicalCereals,0.36,0,0.01279981749356,0.21500918250644,0 -Afghanistan,2010,Soyabeans,0,0,0.0181396673517777,0,0 -Albania,2010,Soyabeans,3e-04,0.020242,0.0208927048894378,0.000499709778126333,0 -Algeria,2010,Soyabeans,0,0.955716,1.38669470644652,-1.79661159892566e-06,0 -Angola,2010,Soyabeans,0,0.000343,0.0780086382648339,-3.73142408992862e-07,0.015 -Antigua and Barbuda,2010,Soyabeans,0,0,0.000340249157577012,-1.38200892222358e-08,0 -Argentina,2010,Soyabeans,18.130799,3.703491,-43.471944,52.005431,1.7 -Armenia,2010,Soyabeans,0,0.008911,0.0105861150680422,-4.14602676664799e-08,0 -Australia,2010,Soyabeans,0.0313,0.515214,0.505618126954305,0.07223,0.000358 -Austria,2010,Soyabeans,0.034378,0.56935,0.524812286268536,0.0935410208447862,0.002839 -Azerbaijan,2010,Soyabeans,7e-06,0.069508,0.0715263814182787,-0.000203715941010043,5e-06 -Bahamas,2010,Soyabeans,0,0,0.000269364319198297,-4.28422765889024e-07,1e-04 -Bangladesh,2010,Soyabeans,0.040681,0.53069,1.01954959963903,0.0687863151904334,0.08 -Barbados,2010,Soyabeans,0,0.018138,0.0228103418422967,-0.000316341842296748,0.00178 -Belarus,2010,Soyabeans,0,0.274446,0.310781403118875,-7.95760737415985e-05,0 -Belgium,2010,Soyabeans,0,1.122483,1.23088964430241,-0.00556612385478662,0.019886 -Belize,2010,Soyabeans,0.00031,0.009489,0.0102433492864616,0.000649599217412555,0 -Benin,2010,Soyabeans,0.018,0.002165,-0.013587,0.012,0 -Bolivia (Plurinational State of),2010,Soyabeans,0.922115,0.260061,-1.259294,1.843048,0.065 -Bosnia and Herzegovina,2010,Soyabeans,0.004037,0.078165,0.104136691440374,-0.0127313382666974,0 -Botswana,2010,Soyabeans,0,0.006038,0.0103630379006431,-5.54323778703474e-05,0 -Brazil,2010,Soyabeans,23.327296,13.703567,-44.146334,65.756443,2.717479 -Brunei Darussalam,2010,Soyabeans,0,0.00161,0.00254039420258686,0.000389344711209664,0 -Bulgaria,2010,Soyabeans,0.000725,0.099334,0.12235815069524,-0.00357416288782327,0 -Burkina Faso,2010,Soyabeans,0.01782727,0,-0.000269466298567835,0.022394,0 -Cabo Verde,2010,Soyabeans,0,0.001309,0.00927879381814029,-2.76401784449263e-08,0.0045 -Cambodia,2010,Soyabeans,0.103198,0.06161,0.00270876165249835,0.131588,0 -Cameroon,2010,Soyabeans,0.014868,0.028477,0.0344047346176516,0.0125439723598216,0 -Canada,2010,Soyabeans,1.4768,2.276467,-1.52105526382079,4.3453,0.06545 -Central African Republic,2010,Soyabeans,0,0,0.00130275792799131,0,0 -Chile,2010,Soyabeans,0,0.476506,0.731978508601318,-0.000638773390364484,0.119748 -China,2010,Soyabeans,8.516115,50.08519,58.7203915838127,9.74614556872625,7.544093 -Colombia,2010,Soyabeans,0.031604,1.173916,1.56164040523209,0.0493237494402858,0.033055 -Congo,2010,Soyabeans,0,0.000403,0.00110725521447973,-6.91004461111788e-08,0 -Costa Rica,2010,Soyabeans,0,0.197892,0.239466137194109,0.0216768628058913,0.0086 -Cote d'Ivoire,2010,Soyabeans,0.000825,0.015916,0.0174714819769675,0.000868070141084885,0 -Croatia,2010,Soyabeans,0.056456,0.227209,0.131209774659419,0.12358,1e-04 -Cuba,2010,Soyabeans,0,0.361774,0.47970872339079,0.0565765722703785,0.0174 -Cyprus,2010,Soyabeans,0,0.130228,0.147340788718427,-2.01773302644142e-06,0.006 -Czech Republic,2010,Soyabeans,0.0095,0.492153,0.523411539004589,0.0158986907514577,0.005366 -Democratic People's Republic of Korea,2010,Soyabeans,0.3,0.243683,0.107879615784257,0.349646205715911,0 -Denmark,2010,Soyabeans,0,1.5326,1.65499008725847,-0.00142804363942193,0.046438 -Djibouti,2010,Soyabeans,0,0,0.0010942695434936,0,0 -Dominica,2010,Soyabeans,0,0,0.000163728166356954,0,0 -Dominican Republic,2010,Soyabeans,0,0.403243,0.580101657110357,-4.72647051408421e-06,0.04 -Ecuador,2010,Soyabeans,0.043,0.571105,0.66801214733227,0.0699942873495752,0.04065 -Egypt,2010,Soyabeans,0.015233,1.752608,2.49225268483809,-0.0598756333485674,0.267 -El Salvador,2010,Soyabeans,0.0025,0.157485,0.182098092077382,0.00449806518750888,0 -Estonia,2010,Soyabeans,0,0.025465,0.0198257297131013,-5.94263836555911e-07,2e-04 -Ethiopia,2010,Soyabeans,0.011261,0,0.00223477708396696,0.0158213465428693,0 -Fiji,2010,Soyabeans,0,0.007683,0.0126137509057244,-3.17862052111195e-06,5e-04 -Finland,2010,Soyabeans,0,0.178912,0.186825833423964,-0.000145520585934049,5.2e-05 -France,2010,Soyabeans,0.049736,4.13641,4.66438960790382,0.129555057121869,0 -French Polynesia,2010,Soyabeans,0,0.001733,0.00240479732970415,-2.9160388258897e-06,8.2e-05 -Gabon,2010,Soyabeans,0.00366,0.004913,0.00449360227235707,0.0028075561751031,0 -Gambia,2010,Soyabeans,0,0,0.000549654985462928,-5.25163390444504e-07,0 -Georgia,2010,Soyabeans,0.00055,0.001758,-0.00159219165746589,0.00136190325937544,0 -Germany,2010,Soyabeans,0.001,4.25,5.4387917570734,-0.301255949437122,0.357021 -Ghana,2010,Soyabeans,0,0,0.00434261040163188,-5.08579283377821e-06,0 -Greece,2010,Soyabeans,0.0019,0.556384,0.645308049723684,0.00048508875100757,0.053 -Grenada,2010,Soyabeans,0,4e-05,0.000533903702547268,-1.38200892222358e-08,0 -Guatemala,2010,Soyabeans,0.014,0.323246,0.414958821402017,0.0369494737538035,0.03445 -Guinea,2010,Soyabeans,0,0.000213,0.000783939694250904,0,0 -Guinea-Bissau,2010,Soyabeans,0,0,0.00278691252950039,0,0 -Guyana,2010,Soyabeans,0,0.014153,0.019524937905712,-0.00305244228502235,0 -Haiti,2010,Soyabeans,0,7.4e-05,0.0634482006427493,0,0 -Honduras,2010,Soyabeans,0.000849,0.166286,0.176233780250413,0.00213854993127045,0 -Hungary,2010,Soyabeans,0.037688,0.669174,0.638130419322285,0.087122,0 -Iceland,2010,Soyabeans,0,0.015287,0.0193379272429236,-4.97523212001397e-07,0.0011 -India,2010,Soyabeans,9.55419,4.855549,-3.13655438317427,12.586,1 -Indonesia,2010,Soyabeans,0.660823,4.620302,4.7778946338138,0.882980788165847,0 -Iran (Islamic Republic of),2010,Soyabeans,0.076076,2.539149,3.06889798012601,0.243611160350714,0.056431 -Iraq,2010,Soyabeans,4.3e-05,0.006356,0.100570130517638,3.5904549632105e-05,0 -Ireland,2010,Soyabeans,0,0.423086,0.48863373530867,-0.000335385925244947,0.03 -Israel,2010,Soyabeans,0,0.485267,0.590909099042123,-0.0067078981660594,0 -Italy,2010,Soyabeans,0.1595,3.379426,3.64381327832944,0.53246796528712,0.0025 -Jamaica,2010,Soyabeans,0,0.047015,0.0685803469190197,-3.16975400788942e-06,0 -Japan,2010,Soyabeans,0.1377,4.166807,5.79673410763591,0.138559111198171,0.007838 -Jordan,2010,Soyabeans,0,0.239261,0.27894321882066,-1.40964910067851e-06,0 -Kazakhstan,2010,Soyabeans,0.0616,0.015068,-0.007507,0.03289,0 -Kenya,2010,Soyabeans,0.001621,0.015092,0.031302397779108,0.00132104337287628,0 -Kiribati,2010,Soyabeans,0,0,2.02764017844445e-05,-2.76401784444516e-07,0 -Kuwait,2010,Soyabeans,0,0.065947,0.0801888080260575,-3.178620521212e-07,0 -Kyrgyzstan,2010,Soyabeans,0.000121,0.00225,0.00383695012281582,9.21089786719945e-05,0 -Lao People's Democratic Republic,2010,Soyabeans,0.007235,0.003932,-9.4e-05,0.011436,0.000915 -Latvia,2010,Soyabeans,0,0.054412,0.0693244150657648,0.00230640819017506,0.002519 -Lebanon,2010,Soyabeans,0,0.148087,0.177447553797757,-4.66151609465887e-05,0 -Liberia,2010,Soyabeans,0.0074,0.0015,0.0024260055006655,0.00299889439286222,0 -Libya,2010,Soyabeans,0,0.316005,0.347203408231428,-1.58931026054779e-06,0 -Lithuania,2010,Soyabeans,0,0.121159,0.137310431281451,-1.23551597646729e-05,0 -Madagascar,2010,Soyabeans,7.6e-05,0.001775,0.0277305113591678,3.59556674338855e-05,0 -Malawi,2010,Soyabeans,0.075186,0.036142,0.00648106746051961,0.073356,0 -Malaysia,2010,Soyabeans,0,1.565376,1.72570038281528,-0.00851808109256509,0 -Maldives,2010,Soyabeans,0,0,0.000306922391846779,-1.5389834796668e-06,7e-05 -Mali,2010,Soyabeans,0.002719,4.2e-05,0.000129297092414574,0.00187036427589578,0 -Malta,2010,Soyabeans,0,0.016377,0.0189907144263447,-9.39766067109304e-07,0.000619 -Mauritania,2010,Soyabeans,0,0,0.0757390006960587,0,0 -Mauritius,2010,Soyabeans,0,0.03545,0.0474702860898899,-4.98905220922461e-06,0.005 -Mexico,2010,Soyabeans,0.153473,3.731328,4.97207802384101,0.115511166849418,0.49471 -Mongolia,2010,Soyabeans,0,2.4e-05,0.00892111983588607,-8.43025442556609e-07,0 -Morocco,2010,Soyabeans,0.001,0.575127,1.06652627252376,-0.0018267334093356,0.209356 -Mozambique,2010,Soyabeans,0,0.02861,0.0542190382554643,-3.30300132411503e-06,0 -Myanmar,2010,Soyabeans,0.165,0.169389,-0.00323314928391776,0.257813,0 -Namibia,2010,Soyabeans,0,0.002673,0.00304004676709881,-1.38200892220084e-08,0 -Nepal,2010,Soyabeans,0.023942,0.093268,0.187470376538064,0.0217096633608971,0 -Netherlands,2010,Soyabeans,0,2.356616,1.81832042759387,0.724999074815507,0.082608 -Netherlands Antilles,2010,Soyabeans,0,0,0.000772702713166633,0,0.000456 -New Caledonia,2010,Soyabeans,0,0.002781,0.00345373742181066,-1.83807186655577e-06,0 -New Zealand,2010,Soyabeans,0,0.128627,0.158178729355425,-3.01830748613575e-05,0.007125 -Nicaragua,2010,Soyabeans,0.0018268,0.069038,0.106890526326514,0.004035,0.012 -Niger,2010,Soyabeans,0,0.00038,0.00138429556231874,-1.38200892222358e-08,0 -Nigeria,2010,Soyabeans,0.28189,0.058408,0.00392259105423104,0.28505,0 -Norway,2010,Soyabeans,0,0.22792,0.270370602938286,-0.00565960293828591,0 -Occupied Palestinian Territory,2010,Soyabeans,0,0,0.00349836441784284,0,0 -Pakistan,2010,Soyabeans,8.9e-05,0.259239,0.298146169197661,4.88855263490113e-05,0.005169 -Panama,2010,Soyabeans,0.00027,0.1765,0.220714474230806,-1.21768731959164e-05,0 -Paraguay,2010,Soyabeans,2.671059,0.461524,-5.32416,7.260435,0 -Peru,2010,Soyabeans,0.001427,0.988569,1.54757278714933,0.00114461115013273,0.313053 -Philippines,2010,Soyabeans,0.000583,1.121246,1.20702134859354,-0.000686562601146754,0 -Poland,2010,Soyabeans,0.000181,1.899473,2.0535704443958,0.000102092451567762,0.003035 -Portugal,2010,Soyabeans,0,0.795426,1.04246353664429,-0.0116434577634797,0.15 -Republic of Korea,2010,Soyabeans,0.071422,2.462002,3.39543932745078,0.0884283539464637,0 -Republic of Moldova,2010,Soyabeans,0.058229,0.039657,-0.027112,0.074647,0 -Romania,2010,Soyabeans,0.063424,0.383989,0.360825323217419,0.049939,0.000189 -Russian Federation,2010,Soyabeans,1.0363,2.143599,1.38210139160218,1.20757126879968,0.085137 -Rwanda,2010,Soyabeans,0.072353,0,0.00215080483672305,0.057069596594732,4e-06 -Saint Kitts and Nevis,2010,Soyabeans,0,0,0.000296666839913651,-1.38200892222358e-08,3.8e-05 -Saint Lucia,2010,Soyabeans,0,0,0.000451985622540722,-1.02764017844447e-06,0.000382 -Saint Vincent and the Grenadines,2010,Soyabeans,0,0,0.0015702639641269,-0.00101427615216656,0 -Samoa,2010,Soyabeans,0,0,7.60365066916669e-05,-1.03650669166693e-06,0 -Sao Tome and Principe,2010,Soyabeans,0,0,0.00189288606716277,0,0.0014 -Saudi Arabia,2010,Soyabeans,0,0.825737,0.888649662029939,-0.00512178921262699,0 -Senegal,2010,Soyabeans,0,0.011795,0.111844323285105,-0.000166103652361926,0 -Serbia,2010,Soyabeans,0.170359,0.288322,-0.0735867226253756,0.460855,0.019022 -Sierra Leone,2010,Soyabeans,0,0,0.00117790047738816,0,0 -Slovakia,2010,Soyabeans,0.013976,0.128339,0.117850879402331,0.024044,0 -Slovenia,2010,Soyabeans,0.000109,0.022618,-0.0222865026745277,0.000244084710027768,0.0035 -Solomon Islands,2010,Soyabeans,0,0,3.64975232120001e-05,-4.97523212000125e-07,0 -Somalia,2010,Soyabeans,0,0,0.00200243081155987,0,0 -South Africa,2010,Soyabeans,0.31145,1.110992,1.15864542151544,0.421,0 -Spain,2010,Soyabeans,0.000766,4.560957,5.16694886791194,0.0767052760038339,0.203885 -Sri Lanka,2010,Soyabeans,0.0045,0.120241,0.121400534437399,0.00749769437599533,0 -Sudan (former),2010,Soyabeans,0,0.005445,0.0103915346656897,-6.63364282667317e-07,0 -Suriname,2010,Soyabeans,1.5e-05,0.010437,0.0232569593471529,-7.08683347255283e-06,0.0032 -Swaziland,2010,Soyabeans,0,0.00349,0.0040800520322529,-4.6020897110011e-06,0 -Sweden,2010,Soyabeans,0,0.288686,0.328301341509735,-0.000354609669353056,0 -Switzerland,2010,Soyabeans,0.001087,0.303552,0.325191374476593,0.00199488339951867,0 -Syrian Arab Republic,2010,Soyabeans,0.002149,0.805698,0.950682355966392,0.0656816503838487,0.009 -Tajikistan,2010,Soyabeans,0,0.001406,0.00794439685169438,0,0 -Thailand,2010,Soyabeans,0.08976,3.580547,4.54464148324254,0.152007276812389,0.50771 -The former Yugoslav Republic of Macedonia,2010,Soyabeans,0.000306,0.027698,0.0297951383835115,0.000690652666109774,0 -Timor-Leste,2010,Soyabeans,0.000358,0,0,0.000962,0 -Togo,2010,Soyabeans,0.005,6.2e-05,-0.00148209952261184,0.0034,0 -Trinidad and Tobago,2010,Soyabeans,0,0.027692,0.0496506107093343,-0.000155628024731486,0.0063 -Tunisia,2010,Soyabeans,0,0.395473,0.602446212202883,-0.00582888521116902,0.0425 -Turkey,2010,Soyabeans,0.023472,1.786575,2.19975189344792,0.061357876444703,0.018215 -Turkmenistan,2010,Soyabeans,0,0,0.00235580095477632,0,0 -Uganda,2010,Soyabeans,0.15,0.050076,-0.06336,0.18144,0 -Ukraine,2010,Soyabeans,1.0367,1.319086,-0.19873276220355,1.6802,0.000118 -United Arab Emirates,2010,Soyabeans,0,0.009297,0.101419965645678,0.0159471657989034,0.027 -United Kingdom,2010,Soyabeans,0,2.896675,3.29216159757414,-0.0117813496601628,0.001145 -United Republic of Tanzania,2010,Soyabeans,0.00357,8.9e-05,0.0248663697540226,0.00306557911132343,0 -United States of America,2010,Soyabeans,31.0033,31.0985,-51.853643,92.805465,0.4 -Uruguay,2010,Soyabeans,0.8632,0.035045,-1.89994320363787,2.0232,0 -Uzbekistan,2010,Soyabeans,0,0.026,0.0107230227375743,0.0259308995538889,0 -Vanuatu,2010,Soyabeans,0,0,5.98153852641113e-05,-8.1538526411132e-07,0 -Venezuela (Bolivarian Republic of),2010,Soyabeans,0.025,1.175932,1.68964660801562,0.00769931659026397,0.111304 -Viet Nam,2010,Soyabeans,0.1978,0.155,3.30217010255711,0.295868809821034,2.856461 -Yemen,2010,Soyabeans,0,0.105821,0.115949973800326,-5.24886988660146e-05,0 -Zambia,2010,Soyabeans,0.060777,0.001219,-0.0201370756902422,0.109887,0 -Zimbabwe,2010,Soyabeans,0.042288,0.067023,0.0658460394117836,0.0650399340602519,0 Afghanistan,2010,Starchy Roots + (Total),0.0205,0,-0.02607,0.246,0 Albania,2010,Starchy Roots + (Total),0.009,0.068978,0.0311237757498875,0.212135224250112,0.00328 Algeria,2010,Starchy Roots + (Total),0.121996,0,0.12810895302139,3.31733304697861,0.015747 diff --git a/src/ac/ed/lurg/ModelConfig.java b/src/ac/ed/lurg/ModelConfig.java index b6a80705c2e02f7357b5637ed9ec2643e57247a3..a934c029d5da74a89a170f9e1d1184acc5f20ad1 100644 --- a/src/ac/ed/lurg/ModelConfig.java +++ b/src/ac/ed/lurg/ModelConfig.java @@ -98,7 +98,8 @@ public class ModelConfig { // yield data public static final String YIELD_DIR = getProperty("YIELD_DIR"); - + public static final boolean CHANGE_YIELD_DATA_YEAR = getBooleanProperty("CHANGE_YIELD_DATA_YEAR", true); + public static final String ANPP_FILENAME = getProperty("ANPP_FILENAME", "anpp_plum.out"); public static final String YIELD_FILENAME = getProperty("YIELD_FILENAME", "yield_plum.out"); @@ -116,8 +117,8 @@ public class ModelConfig { public static final int START_TIMESTEP = getIntProperty("START_TIMESTEP", 0); - public static final int END_TIMESTEP = getIntProperty("END_TIMESTEP", 0); - public static final int TIMESTEP_SIZE = getIntProperty("END_TIMESTEP", 5); + public static final int END_TIMESTEP = getIntProperty("END_TIMESTEP", 1); + public static final int TIMESTEP_SIZE = getIntProperty("END_TIMESTEP", 1); public static final int BASE_YEAR = getIntProperty("BASE_YEAR", 2010); public static final double MAX_IMPORT_CHANGE = getDoubleProperty("MAX_IMPORT_CHANGE", 0.1); @@ -128,6 +129,8 @@ public class ModelConfig { public static final boolean WRITE_JPEG_IMAGES = getBooleanProperty("WRITE_JPEG_IMAGES", Boolean.TRUE); public static final int LPJG_MONITOR_TIMEOUT_SEC = getIntProperty("LPJG_MONITOR_TIMEOUT", 60*60*2); + public static final String TOTAL_LAND_COVER_FILE = OUTPUT_DIR + File.separator + "total_lc.txt"; + // public static final double PASTURE_HARVEST_FRACTION = getDoubleProperty("PASTURE_HARVEST_FRACTION", 0.5); public static final double MEAT_EFFICIENCY = getDoubleProperty("MEAT_EFFICIENCY", 0.5); diff --git a/src/ac/ed/lurg/ModelMain.java b/src/ac/ed/lurg/ModelMain.java index 6a148feddff23cd96b23642ebee26ae4c5b71f59..acc967ccaa9da6c729e0ae2946880896ba645f4e 100644 --- a/src/ac/ed/lurg/ModelMain.java +++ b/src/ac/ed/lurg/ModelMain.java @@ -1,6 +1,9 @@ package ac.ed.lurg; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -27,6 +30,7 @@ import ac.ed.lurg.landuse.LandCoverReader; import ac.ed.lurg.output.LpjgOutputer; import ac.ed.lurg.types.CropToDoubleMap; import ac.ed.lurg.types.CropType; +import ac.ed.lurg.types.LandCoverType; import ac.ed.lurg.types.ModelFitType; import ac.ed.lurg.utils.LogWriter; import ac.ed.lurg.yield.LPJYieldResponseMapReader; @@ -142,10 +146,60 @@ public class ModelMain { // output results outputTimestepResults(timestep, globalIntensityRaster, globalCropAreaRaster, globalLocationIdRaster, yieldSurfaces); + writeMarketFile(timestep, globalCropAreaRaster); + } + + + private BufferedWriter getFileWriter(Timestep timestep, String file, String columnHeadings) throws IOException { + if (timestep.isInitialTimestep()) { + FileWriter fstream = new FileWriter(file,false); + BufferedWriter outputFile = new BufferedWriter(fstream); + outputFile.write(columnHeadings); + outputFile.newLine(); + return outputFile; + } + else { + FileWriter fstream = new FileWriter(file,true); + return new BufferedWriter(fstream); + } + } + + private double getTotalArea(LandCoverType lcType, RasterSet<AreasItem> globalCropAreaRaster) { + double totalArea = 0; + for (AreasItem item : globalCropAreaRaster.values()) { + totalArea += item.getLandCoverArea(lcType); + } + return totalArea; + } + + private void writeMarketFile(Timestep timestep, RasterSet<AreasItem> cropAreaRaster) { + try { + StringBuffer sbHeadings = new StringBuffer("Year, Cropland (Mha), Pasture (Mha), Natural (Mha)"); + for (CropType crop : CropType.getImportedTypes() ) + sbHeadings.append(",Px_" + crop.getGamsName()); + + BufferedWriter outputFile = getFileWriter(timestep, ModelConfig.TOTAL_LAND_COVER_FILE, sbHeadings.toString()); + + StringBuffer sbData = new StringBuffer(); + sbData.append(String.format("%d,%.1f,%.1f,%.1f", + timestep.getYear(), getTotalArea(LandCoverType.CROPLAND, cropAreaRaster), getTotalArea(LandCoverType.PASTURE, cropAreaRaster), getTotalArea(LandCoverType.OTHER_NATURAL, cropAreaRaster))); + + for (CropType crop : CropType.getImportedTypes() ) + sbData.append(String.format(",%.3f", prevWorldInputCost.get(crop))); + + outputFile.write(sbData.toString()); + outputFile.newLine(); + outputFile.close(); + } + catch (IOException e) { + e.printStackTrace(); + } } private void outputTimestepResults(Timestep timestep, RasterSet<IntensitiesItem> intensityRaster, RasterSet<AreasItem> cropAreaRaster, RasterSet<IntegerRasterItem> locationIdRaster, YieldRaster yieldSurfaces) { + + LpjgOutputer lpjOutputer = new LpjgOutputer(timestep, intensityRaster, cropAreaRaster, yieldSurfaces); lpjOutputer.writeOutput(); @@ -185,8 +239,8 @@ public class ModelMain { }.writeOutput(ModelConfig.WRITE_JPEG_IMAGES); outputAreas(year, cropAreaRaster, CropType.MAIZE); */ - outputAreas(timestep.getYear(), cropAreaRaster, CropType.WHEAT); - outputAreas(timestep.getYear(), cropAreaRaster, CropType.PASTURE); + // outputAreas(timestep.getYear(), cropAreaRaster, CropType.WHEAT); + // outputAreas(timestep.getYear(), cropAreaRaster, CropType.PASTURE); } private void outputAreas(int year, RasterSet<AreasItem> cropAreaRaster, final CropType crop) { @@ -245,7 +299,7 @@ public class ModelMain { Map<Country, Map<CropType, CropUsageData>> cropUsageDataMap = new CropUsageReader().getCommodityData(); - HashSet<String> countryExclusionList = new HashSet<String>(Arrays.asList("Bangladesh", "Portugal", "Haiti")); //"French Polynesia", "Cabo Verde", "Samoa", "Saint Vincent and the Grenadines")); + HashSet<String> countryExclusionList = new HashSet<String>(Arrays.asList("Bangladesh", "Portugal", "Haiti", "Myanmar")); //"French Polynesia", "Cabo Verde", "Samoa", "Saint Vincent and the Grenadines")); for (Map.Entry<Country, List<RasterKey>> entry : countryToKeysMap.entrySet()) { Country country = entry.getKey(); @@ -253,11 +307,11 @@ public class ModelMain { // DEBUG code - if (!(country.getCountryName().equals("United States of America") || country.getCountryName().equals("Russian Federationxx") || country.getCountryName().equals("Brazilxx")) ) { //|| country.getCountryName().equals("China") - continue; - } + // if (!(country.getCountryName().equals("United States of America") || country.getCountryName().equals("Russian Federationxx") || country.getCountryName().equals("Brazilxx")) ) { //|| country.getCountryName().equals("China") + // continue; + // } - if (demandManager.getPopulation(country, 2010) < 8 || countryExclusionList.contains(country.getCountryName())) { + if (demandManager.getPopulation(country, 2010) < 50 || countryExclusionList.contains(country.getCountryName())) { LogWriter.printlnError("Skipping " + country); continue; } @@ -289,7 +343,7 @@ public class ModelMain { private YieldRaster getYieldSurfaces(Timestep timestep) { LPJYieldResponseMapReader yieldReader = new LPJYieldResponseMapReader(desiredProjection); - return yieldReader.getRasterData(ModelConfig.YIELD_DIR + File.separator + timestep.getYieldYear()); + return yieldReader.getRasterData(timestep); } private RasterSet<IrrigationCostItem> getIrrigationCosts() { diff --git a/src/ac/ed/lurg/country/gams/GamsLocationTest.java b/src/ac/ed/lurg/country/gams/GamsLocationTest.java index b1c642b56af33b97f7369df9a75855697fdcc074..b94d4e710fb4d7e384b48238bf5aa0ae767c83f2 100644 --- a/src/ac/ed/lurg/country/gams/GamsLocationTest.java +++ b/src/ac/ed/lurg/country/gams/GamsLocationTest.java @@ -99,7 +99,6 @@ public class GamsLocationTest { dummyMap.setCropFraction(CropType.MAIZE, 0.2); dummyMap.setCropFraction(CropType.RICE, 0.1); dummyMap.setCropFraction(CropType.TROPICAL_CEREALS, 0.1); - dummyMap.setCropFraction(CropType.SOYBEAN, 0.1); dummyMap.setCropFraction(CropType.OILCROPS, 0.1); dummyMap.setCropFraction(CropType.PULSES, 0.1); dummyMap.setCropFraction(CropType.STARCHY_ROOTS, 0.1); @@ -117,7 +116,6 @@ public class GamsLocationTest { dummyMap.put(CropType.MAIZE, 0.4); dummyMap.put(CropType.RICE, 1.0); dummyMap.put(CropType.TROPICAL_CEREALS, 2.0); - dummyMap.put(CropType.SOYBEAN, 0.6); dummyMap.put(CropType.OILCROPS, 10.0); dummyMap.put(CropType.PULSES, 20.0); dummyMap.put(CropType.STARCHY_ROOTS, 5.0); @@ -131,7 +129,6 @@ public class GamsLocationTest { dummyMap.put(CropType.MAIZE, 5.0); dummyMap.put(CropType.OILCROPS, 5.0); dummyMap.put(CropType.TROPICAL_CEREALS, 2.0); - dummyMap.put(CropType.SOYBEAN, 0.6); dummyMap.put(CropType.OILCROPS, 10.0); dummyMap.put(CropType.PULSES, 20.0); dummyMap.put(CropType.STARCHY_ROOTS, 5.0); diff --git a/src/ac/ed/lurg/output/LpjgOutputer.java b/src/ac/ed/lurg/output/LpjgOutputer.java index 44f8671a5543f4a1c78cb38eebf13eb18dce158a..0d07e8536714765d9197bf5598e9ce3bbefe397c 100644 --- a/src/ac/ed/lurg/output/LpjgOutputer.java +++ b/src/ac/ed/lurg/output/LpjgOutputer.java @@ -106,8 +106,8 @@ public class LpjgOutputer { LogWriter.printlnError("LpjgOutputer: Can't find YieldResponsesItem for " + key); double lpjWinterWheatFrac = item.getCropFraction(CropType.OILCROPS, isSpringWheat ? null : CropType.WHEAT); - double lpjSpringWheatFrac = item.getCropFraction(CropType.SOYBEAN, CropType.PULSES, CropType.STARCHY_ROOTS, isSpringWheat ? CropType.WHEAT : null); - double lpjCornFrac = item.getCropFraction(CropType.MAIZE, CropType.SOYBEAN); + double lpjSpringWheatFrac = item.getCropFraction(CropType.PULSES, CropType.STARCHY_ROOTS, isSpringWheat ? CropType.WHEAT : null); + double lpjCornFrac = item.getCropFraction(CropType.MAIZE); double lpjRiceFrac = item.getCropFraction(CropType.RICE); cropFractWriter.write(String.format("%.2f %.2f %.4f %.4f %.4f %.4f", lat, lon, lpjWinterWheatFrac, lpjSpringWheatFrac, lpjCornFrac, lpjRiceFrac)); cropFractWriter.newLine(); diff --git a/src/ac/ed/lurg/types/CropType.java b/src/ac/ed/lurg/types/CropType.java index d42471d87f5b850aafc31f2383b235e320deae18..4e71a09d43e22795d9023075b6d42d30f4534302 100644 --- a/src/ac/ed/lurg/types/CropType.java +++ b/src/ac/ed/lurg/types/CropType.java @@ -14,7 +14,7 @@ public enum CropType { RICE("Rice (Paddy Equivalent)", "rice"), TROPICAL_CEREALS("TropicalCereals", "tropicalCereals"), OILCROPS("Oilcrops + (Total)", "oilcrops"), - SOYBEAN("Soyabeans", "soybean"), +// SOYBEAN("Soyabeans", "soybean"), PULSES("Pulses + (Total)", "pulses"), STARCHY_ROOTS("Starchy Roots + (Total)", "starchyRoots"), MEAT("meatmilkeggs", "meat", true, true), diff --git a/src/ac/ed/lurg/yield/LPJYieldResponseMapReader.java b/src/ac/ed/lurg/yield/LPJYieldResponseMapReader.java index be4b835aea1b297b13ac14c20b3317fb6d7c7535..3365ea25cc68be8fa4c40ded4ecf4cee71e3f25b 100644 --- a/src/ac/ed/lurg/yield/LPJYieldResponseMapReader.java +++ b/src/ac/ed/lurg/yield/LPJYieldResponseMapReader.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.Map; import ac.ed.lurg.ModelConfig; +import ac.ed.lurg.Timestep; import ac.ed.lurg.types.CropType; import ac.ed.lurg.types.FertiliserRate; import ac.ed.lurg.types.IrrigationRate; @@ -23,7 +24,14 @@ public class LPJYieldResponseMapReader extends AbstractTabularRasterReader<Yield this.rasterProj = rasterProj; } - public YieldRaster getRasterData(String rootDir) { + public YieldRaster getRasterData(Timestep timestep) { + String rootDir; + + if (ModelConfig.CHANGE_YIELD_DATA_YEAR) + rootDir = ModelConfig.YIELD_DIR + File.separator + timestep.getYieldYear(); + else + rootDir = ModelConfig.YIELD_DIR; + // wait for data to be available long startTime = System.currentTimeMillis(); WatchForFile fileWatcher = new WatchForFile(new File(rootDir + File.separator + "done")); @@ -85,7 +93,7 @@ public class LPJYieldResponseMapReader extends AbstractTabularRasterReader<Yield item.setYield(yieldType, CropType.TROPICAL_CEREALS, co); item.setYield(yieldType, CropType.OILCROPS, isSpringWheat ? sw : ww); - item.setYield(yieldType, CropType.SOYBEAN, sw); +// item.setYield(yieldType, CropType.SOYBEAN, sw); item.setYield(yieldType, CropType.PULSES, sw); item.setYield(yieldType, CropType.STARCHY_ROOTS, sw); }