diff --git a/README.md b/README.md index e4f3445..726e050 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,8 @@ The database to run the platform for the pilot country of Zambia is avaiable at Once downloaded, the database(s) (a zipped folder for each of the four models) should be extracted. The exact full path to the database (e.g. *C:/Users/[yourusername]/Documents/RE4AFAGRI_database/...* should be parsed onto the different model at the following positions: -- For WaterCROP: +- For WaterCROP: at *lines 1, 4, 21, 55, 65, 68 - and subsequently for each crop - and 785* of the 'WaterCROP1_ETactual.mat' file + at *lines 9, 14, 20, 94* of the 'WaterCROP2_Irrigation_requirements.mat' file - For M-LED: at *line 10* of the `MLED_hourly.R` file, defining the `db_folder` parameter - For OnSSET: include the OnSSET replication data folder unzipped in `onsset\onsset_replication` (more details below) - For NEST: The database only raw data needed in the pre-processing phase. The data needed to run the model is already included in the Github repository @@ -43,7 +44,7 @@ Each models is developed in a specific programming language and has thus specifi - Download or clone this entire repository either using, Github Desktop, `git clone` or downloading it as a .zip folder with all of the subfolders for each model included ### For WaterCROP: - - XXX + - Have 'Matlab' (version >= R2017a) installed on your local computer ### For M-LED: - Have `R` (version >=3.6) installed on your local computer: https://cran.r-project.org/bin/windows/base/ @@ -75,7 +76,8 @@ Each models is developed in a specific programming language and has thus specifi ## Operating the platform ### For WaterCROP: - - XXX + - Open 'WaterCROP1_ETactual.mat' file in MATLAB and select the scenario to run; then run the code. + - Open 'WaterCROP2_Irrigation_requirements.mat' and run the code. The code will produce the input files produces netcdf files of irrigation water requirements and yield growth potential for all African countries. ### For M-LED: - Open the `MLED_hourly.r` file in RStudio @@ -119,7 +121,9 @@ Currently, each model has own reporting methods and formats, although a joint re In particular results can be examined by: ### For WaterCROP: - - + - WaterCROP outputs are found in 'results2' folder, and in each specific crop subfolder, which are automatically created after a model run. + - WaterCROP writes output data at 5 arcmin for the whole African continent + - The results files can be analysed using MATLAB and can be vsualized in GIS softwares ### For M-LED: - M-LED outputs are found in the `results` folder which is automatically created inside the `m-led` home folder after a model run. diff --git a/watercrop/WaterCROP1_ETactual.m b/watercrop/WaterCROP1_ETactual.m index 3b362eb..b85eac2 100644 --- a/watercrop/WaterCROP1_ETactual.m +++ b/watercrop/WaterCROP1_ETactual.m @@ -1,7 +1,7 @@ -cd 'C:\Users\giord\Desktop\IIASA collab\WaterCrop' +cd '~\WaterCrop_replication' climate = imread('thcli1.tif'); -cd 'C:\Users\giord\Desktop\IIASA collab\WaterCrop\1-ET0mm_day' +cd '~\WaterCrop_replication\1-ET0mm_day' ET0_2020=importdata('ET0_2020_370_GFDL_bias.mat'); ET0_2020(isnan(ET0_2020))=0; @@ -18,7 +18,7 @@ ET0_nov=ET0_2020(:,:,11); ET0_dec=ET0_2020(:,:,12); -cd 'C:\Users\giord\Desktop\IIASA collab\WaterCrop\2-Prec_mm_day' +cd '~\WaterCrop_replication\2-Prec_mm_day' P_2020=importdata('P_2020_370_GFDL_bias.mat'); P_2020(isnan(P_2020))=0; @@ -52,7 +52,7 @@ jan_after=14:1/30:15-1/30; days=[dec_before,jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec,jan_after]'; -cartella_kc = 'C:\Users\giord\Desktop\IIASA collab\WaterCrop'; +cartella_kc = '~\WaterCrop_replication'; raccolto=1;%,2,3,4,5,6,7,8,9,10,11,12,13,14,15,24,31,32,33]; %19 crops for r = 1:length(raccolto) %r crop index @@ -62,10 +62,10 @@ %-- II growing season case 1 %Mais - cartella='C:\Users\giord\Desktop\IIASA collab\WaterCrop\Maize'; + cartella='~\WaterCrop_replication\Maize'; coeff_colturale='kc_maize'; - cartella_risultati='C:\Users\giord\Desktop\IIASA collab\WaterCrop\Risultati1_ETa\Maize'; + cartella_risultati='~\WaterCrop_replication\Results1_ETa\Maize'; rd_ini=0.3; %m rd_max_rainfed=1.7; %fao 56 tab 22 pag 190 @@ -782,7 +782,7 @@ kc=xlsread('kc_global_NEWCROPS_def.xlsx',coeff_colturale,'C17:I26'); % -cd 'C:\Users\giord\Desktop\IIASA collab\WaterCrop' +cd '~\WaterCrop_replication' awc_final=importdata('awc_mmalm.mat'); temp=zeros(14,2); @@ -1638,7 +1638,7 @@ end end - +mkdir(cartella_risultati) cd(cartella_risultati) save('ETa_rain.mat','ETa_tot') @@ -1651,16 +1651,16 @@ save('ETc_tot_rain.mat','ETc_tot_rain') save('ETc_tot_irr.mat','ETc_tot_irr') -save('ETa_rf_month.mat','ETa_month') %NEST -save('ETc_rf_month.mat','ETc_month') %NEST +save('ETa_rf_month.mat','ETa_month') +save('ETc_rf_month.mat','ETc_month') save('ET0_rf_month.mat','ET0_rf_month') save('Pre_eff_monthly.mat','Pre_eff_monthly') save('Pre_tot_monthly_gs.mat','Pre_tot_monthly_gs') save('ETgreen_month.mat','ETgreen_month') -save('ETa_irr_month.mat','CWU_month') %NEST -save('ETblue_month.mat','ETblue_month') %NEST -save('I_month.mat','I_month') %NEST -save('ETc_irr_month.mat','ETc_irr_month') %NEST +save('ETa_irr_month.mat','CWU_month') +save('ETblue_month.mat','ETblue_month') +save('I_month.mat','I_month') +save('ETc_irr_month.mat','ETc_irr_month') save('ET0_irr_month.mat','ET0_irr_month') save('Pre_eff_irr_month.mat','Pre_eff_irr_month') save('Pre_tot_irr_month_gs.mat','Pre_tot_irr_month_gs') diff --git a/watercrop/WaterCROP2_Irrigation_requirements.m b/watercrop/WaterCROP2_Irrigation_requirements.m index a466731..99fdfa7 100644 --- a/watercrop/WaterCROP2_Irrigation_requirements.m +++ b/watercrop/WaterCROP2_Irrigation_requirements.m @@ -6,18 +6,18 @@ code = [{'BARL'},'CASS','COCO','COTT','GROU','MAIZ','PMIL','SMIL','OILP','POTA','RAPE','RICE','SORG','SOYB','SUGB','SUGC','SUNF','WHEA','YAMS']; -cd('C:\Users\giord\Desktop\IIASA collab\WaterCrop') +cd('~\WaterCrop_replication') ky = xlsread('crops_list_ky.xlsx','B2:B20'); for cr = 6 %1 2 3 4 5 6 7 9 11 12 22 28 crop number - cd(['C:\Users\giord\Desktop\IIASA collab\WaterCrop\',char(crop_name(cr)),'']) + cd(['~\WaterCrop_replication\',char(crop_name(cr)),'']) area_rf = importdata(['spam2017V2r1_SSA_H_',char(code(cr)),'_R.mat']); area_ir = importdata(['spam2017V2r1_SSA_H_',char(code(cr)),'_I.mat']); ya = importdata(['spam2017V2r1_SSA_Y_',char(code(cr)),'_R.mat']); ya(isnan(ya)) = 0; - cd(['C:\Users\giord\Desktop\IIASA collab\WaterCrop\Risultati1_ETa\',char(crop(cr)),'']) + cd(['~\WaterCrop_replication\Results1_ETa\',char(crop(cr)),'']) ETa_RF = importdata('ETa_rf_month.mat'); ETa_IR = importdata('ETa_irr_month.mat'); @@ -34,34 +34,34 @@ ETa=zeros(2160,4320,12); ETc=zeros(2160,4320,12); - ETa(:,:,1) = (ETa_RF(:,:,1).*area_rf + ETa_IR(:,:,1).*area_ir)./(area_rf + area_ir); - ETa(:,:,2) = (ETa_RF(:,:,2).*area_rf + ETa_IR(:,:,2).*area_ir)./(area_rf + area_ir); - ETa(:,:,3) = (ETa_RF(:,:,3).*area_rf + ETa_IR(:,:,3).*area_ir)./(area_rf + area_ir); - ETa(:,:,4) = (ETa_RF(:,:,4).*area_rf + ETa_IR(:,:,4).*area_ir)./(area_rf + area_ir); - ETa(:,:,5) = (ETa_RF(:,:,5).*area_rf + ETa_IR(:,:,5).*area_ir)./(area_rf + area_ir); - ETa(:,:,6) = (ETa_RF(:,:,6).*area_rf + ETa_IR(:,:,6).*area_ir)./(area_rf + area_ir); - ETa(:,:,7) = (ETa_RF(:,:,7).*area_rf + ETa_IR(:,:,7).*area_ir)./(area_rf + area_ir); - ETa(:,:,8) = (ETa_RF(:,:,8).*area_rf + ETa_IR(:,:,8).*area_ir)./(area_rf + area_ir); - ETa(:,:,9) = (ETa_RF(:,:,9).*area_rf + ETa_IR(:,:,9).*area_ir)./(area_rf + area_ir); - ETa(:,:,10) = (ETa_RF(:,:,10).*area_rf + ETa_IR(:,:,10).*area_ir)./(area_rf + area_ir); - ETa(:,:,11) = (ETa_RF(:,:,11).*area_rf + ETa_IR(:,:,11).*area_ir)./(area_rf + area_ir); - ETa(:,:,12) = (ETa_RF(:,:,12).*area_rf + ETa_IR(:,:,12).*area_ir)./(area_rf + area_ir); - - ETc(:,:,1) = (ETc_RF(:,:,1).*area_rf + ETc_IR(:,:,1).*area_ir)./(area_rf + area_ir); - ETc(:,:,2) = (ETc_RF(:,:,2).*area_rf + ETc_IR(:,:,2).*area_ir)./(area_rf + area_ir); - ETc(:,:,3) = (ETc_RF(:,:,3).*area_rf + ETc_IR(:,:,3).*area_ir)./(area_rf + area_ir); - ETc(:,:,4) = (ETc_RF(:,:,4).*area_rf + ETc_IR(:,:,4).*area_ir)./(area_rf + area_ir); - ETc(:,:,5) = (ETc_RF(:,:,5).*area_rf + ETc_IR(:,:,5).*area_ir)./(area_rf + area_ir); - ETc(:,:,6) = (ETc_RF(:,:,6).*area_rf + ETc_IR(:,:,6).*area_ir)./(area_rf + area_ir); - ETc(:,:,7) = (ETc_RF(:,:,7).*area_rf + ETc_IR(:,:,7).*area_ir)./(area_rf + area_ir); - ETc(:,:,8) = (ETc_RF(:,:,8).*area_rf + ETc_IR(:,:,8).*area_ir)./(area_rf + area_ir); - ETc(:,:,9) = (ETc_RF(:,:,9).*area_rf + ETc_IR(:,:,9).*area_ir)./(area_rf + area_ir); - ETc(:,:,10) = (ETc_RF(:,:,10).*area_rf + ETc_IR(:,:,10).*area_ir)./(area_rf + area_ir); - ETc(:,:,11) = (ETc_RF(:,:,11).*area_rf + ETc_IR(:,:,11).*area_ir)./(area_rf + area_ir); - ETc(:,:,12) = (ETc_RF(:,:,12).*area_rf + ETc_IR(:,:,12).*area_ir)./(area_rf + area_ir); +% ETa(:,:,1) = (ETa_RF(:,:,1).*area_rf + ETa_IR(:,:,1).*area_ir)./(area_rf + area_ir); +% ETa(:,:,2) = (ETa_RF(:,:,2).*area_rf + ETa_IR(:,:,2).*area_ir)./(area_rf + area_ir); +% ETa(:,:,3) = (ETa_RF(:,:,3).*area_rf + ETa_IR(:,:,3).*area_ir)./(area_rf + area_ir); +% ETa(:,:,4) = (ETa_RF(:,:,4).*area_rf + ETa_IR(:,:,4).*area_ir)./(area_rf + area_ir); +% ETa(:,:,5) = (ETa_RF(:,:,5).*area_rf + ETa_IR(:,:,5).*area_ir)./(area_rf + area_ir); +% ETa(:,:,6) = (ETa_RF(:,:,6).*area_rf + ETa_IR(:,:,6).*area_ir)./(area_rf + area_ir); +% ETa(:,:,7) = (ETa_RF(:,:,7).*area_rf + ETa_IR(:,:,7).*area_ir)./(area_rf + area_ir); +% ETa(:,:,8) = (ETa_RF(:,:,8).*area_rf + ETa_IR(:,:,8).*area_ir)./(area_rf + area_ir); +% ETa(:,:,9) = (ETa_RF(:,:,9).*area_rf + ETa_IR(:,:,9).*area_ir)./(area_rf + area_ir); +% ETa(:,:,10) = (ETa_RF(:,:,10).*area_rf + ETa_IR(:,:,10).*area_ir)./(area_rf + area_ir); +% ETa(:,:,11) = (ETa_RF(:,:,11).*area_rf + ETa_IR(:,:,11).*area_ir)./(area_rf + area_ir); +% ETa(:,:,12) = (ETa_RF(:,:,12).*area_rf + ETa_IR(:,:,12).*area_ir)./(area_rf + area_ir); +% +% ETc(:,:,1) = (ETc_RF(:,:,1).*area_rf + ETc_IR(:,:,1).*area_ir)./(area_rf + area_ir); +% ETc(:,:,2) = (ETc_RF(:,:,2).*area_rf + ETc_IR(:,:,2).*area_ir)./(area_rf + area_ir); +% ETc(:,:,3) = (ETc_RF(:,:,3).*area_rf + ETc_IR(:,:,3).*area_ir)./(area_rf + area_ir); +% ETc(:,:,4) = (ETc_RF(:,:,4).*area_rf + ETc_IR(:,:,4).*area_ir)./(area_rf + area_ir); +% ETc(:,:,5) = (ETc_RF(:,:,5).*area_rf + ETc_IR(:,:,5).*area_ir)./(area_rf + area_ir); +% ETc(:,:,6) = (ETc_RF(:,:,6).*area_rf + ETc_IR(:,:,6).*area_ir)./(area_rf + area_ir); +% ETc(:,:,7) = (ETc_RF(:,:,7).*area_rf + ETc_IR(:,:,7).*area_ir)./(area_rf + area_ir); +% ETc(:,:,8) = (ETc_RF(:,:,8).*area_rf + ETc_IR(:,:,8).*area_ir)./(area_rf + area_ir); +% ETc(:,:,9) = (ETc_RF(:,:,9).*area_rf + ETc_IR(:,:,9).*area_ir)./(area_rf + area_ir); +% ETc(:,:,10) = (ETc_RF(:,:,10).*area_rf + ETc_IR(:,:,10).*area_ir)./(area_rf + area_ir); +% ETc(:,:,11) = (ETc_RF(:,:,11).*area_rf + ETc_IR(:,:,11).*area_ir)./(area_rf + area_ir); +% ETc(:,:,12) = (ETc_RF(:,:,12).*area_rf + ETc_IR(:,:,12).*area_ir)./(area_rf + area_ir); - ETa_ann = (ETa_ann_RF.*area_rf + ETa_ann_IR.*area_ir)./(area_rf + area_ir); - ETc_ann = (ETc_ann_RF.*area_rf + ETc_ann_IR.*area_ir)./(area_rf + area_ir); +% ETa_ann = (ETa_ann_RF.*area_rf + ETa_ann_IR.*area_ir)./(area_rf + area_ir); %metti solo rainfed +% ETc_ann = (ETc_ann_RF.*area_rf + ETc_ann_IR.*area_ir)./(area_rf + area_ir); %metti solo rainfed ETc(isnan(ETc)) = 0; ETc(isinf(ETc)) = 0; @@ -82,7 +82,7 @@ end %Doorenbos yield with new ETa - yc = ya .* (ones(2160,4320)-ky(cr)*(ones(2160,4320)-ETc_ann./ETa_ann)); + yc = ya .* (ones(2160,4320)-ky(cr)*(ones(2160,4320)-ETc_ann_RF./ETa_ann_RF)); % yc = ya .* (ones(2160,4320)-ky(cr)*(ones(2160,4320)-(ETa + 0.2*closure_mm)./ETa)); yc(isnan(yc)) = 0; @@ -91,7 +91,7 @@ %percentage variation delta = (yc - ya)./ya * 100; - cart_new = ['C:\Users\giord\Desktop\IIASA collab\WaterCrop\Risultati2_NEST\',char(crop(cr)),'']; + cart_new = ['~\WaterCrop_replication\Results2\',char(crop(cr)),'']; cd(cart_new) save('closure_yield.mat','yc') save('yield_percentage_variation.mat','delta') @@ -106,15 +106,20 @@ closure_m3 = closure_mm .* area_rf./ 10; %[m3] % txt_per_QGis(closure_m3_jan,'closure_m3_jan','-9999','0.0833333') %2D-only - save('closure_mm.mat','closure_mm') - save('closure_m3.mat','closure_m3') + save('closure_mm.mat','closure_mm') + save('closure_m3.mat','closure_m3') actual_I_m3=(actual_I_mm.*area_ir)./10; actual_I_m3(isnan(actual_I_m3))=0; % txt_per_QGis(actual_I_mm(:,:,1),'actual_I_mm_jan','-9999','0.0833333','2') - nccreate('waterwith_2020_monthly_maize_mm.nc','Irr_mm','Dimensions',{'x',2160,'y',4320,'z',12}); + + save('actual_I_mm.mat','actual_I_mm') + save('actual_I_m3.mat','actual_I_m3') + + nccreate('waterwith_2020_monthly_maize_mm.nc','Irr_mm','Dimensions',{'lat',2160,'lon',4320,'months',12},'DeflateLevel',7); ncwrite('waterwith_2020_monthly_maize_mm.nc','Irr_mm',actual_I_mm); - nccreate('waterwith_2020_monthly_maize_m3.nc','Irr_m3','Dimensions',{'x',2160,'y',4320,'z',12}); + nccreate('waterwith_2020_monthly_maize_m3.nc','Irr_m3','Dimensions',{'lat',2160,'lon',4320,'months',12},'DeflateLevel',7); ncwrite('waterwith_2020_monthly_maize_m3.nc','Irr_m3',actual_I_m3); + end \ No newline at end of file diff --git a/watercrop/WaterCROP3_WF_uWF.m b/watercrop/WaterCROP3_WF_uWF.m deleted file mode 100644 index 6f4c214..0000000 --- a/watercrop/WaterCROP3_WF_uWF.m +++ /dev/null @@ -1,349 +0,0 @@ -clear all -clc - - -raccolto=1:40; %crop switch -for r = 1 %crop index - r - -switch raccolto(r) - -case 1 - crop = 'Maize'; - - area_irrigata='spam2017V2r1_SSA_H_MAIZ_I.mat'; - area_rainfed='spam2017V2r1_SSA_H_MAIZ_R.mat'; - area_totale='spam2017V2r1_SSA_H_MAIZ_A.mat'; - - y_avg='spam2017V2r1_SSA_Y_MAIZ_A.mat'; - y_irr='spam2017V2r1_SSA_Y_MAIZ_I.mat'; - y_rf='spam2017V2r1_SSA_Y_MAIZ_R.mat'; - -% case 2 -% crop = 'Wheat'; -% -% area_irrigata='aree_irr_whe_2010.mat'; -% area_rainfed='aree_rf_whe_2010.mat'; -% area_totale='aree_tot_whe_2010.mat'; -% -% y_avg='ya_whe_2071_00_RCP60_avg_CO2_ENSEMBLE.mat'; -% y_irr='ya_whe_2071_00_RCP60_irr_CO2_ENSEMBLE.mat'; -% y_rf='ya_whe_2071_00_RCP60_rf_CO2_ENSEMBLE.mat'; -% -% case 3 -% crop = 'Soy'; -% -% area_irrigata='aree_irr_soy_2010.mat'; -% area_rainfed='aree_rf_soy_2010.mat'; -% area_totale='aree_tot_soy_2010.mat'; -% -% y_avg='ya_soy_2071_00_RCP60_avg_CO2_ENSEMBLE.mat'; -% y_irr='ya_soy_2071_00_RCP60_irr_CO2_ENSEMBLE.mat'; -% y_rf='ya_soy_2071_00_RCP60_rf_CO2_ENSEMBLE.mat'; -% -% case 4 -% crop = 'Sorghum'; -% -% area_irrigata='aree_irr_srg_2010.mat'; -% area_rainfed='aree_rf_srg_2010.mat'; -% area_totale='aree_tot_srg_2010.mat'; -% -% y_avg='ya_srg_2071_00_RCP60_avg_CO2_ENSEMBLE.mat'; -% y_irr='ya_srg_2071_00_RCP60_irr_CO2_ENSEMBLE.mat'; -% y_rf='ya_srg_2071_00_RCP60_rf_CO2_ENSEMBLE.mat'; -% -% case 5 -% crop = 'Rice'; -% -% area_irrigata='aree_irr_rice_2010.mat'; -% area_rainfed='aree_rf_rice_2010.mat'; -% area_totale='aree_tot_rice_2010.mat'; -% -% y_avg='ya_rice_2071_00_RCP60_avg_CO2_ENSEMBLE.mat'; -% y_irr='ya_rice_2071_00_RCP60_irr_CO2_ENSEMBLE.mat'; -% y_rf='ya_rice_2071_00_RCP60_rf_CO2_ENSEMBLE.mat'; -% -% case 6 -% crop = 'Groundnut'; -% -% area_irrigata='aree_irr_gnut_2010.mat'; -% area_rainfed='aree_rf_gnut_2010.mat'; -% area_totale='aree_tot_gnut_2010.mat'; -% -% y_avg='ya_gnut_2071_00_RCP60_avg_CO2_ENSEMBLE.mat'; -% y_irr='ya_gnut_2071_00_RCP60_irr_CO2_ENSEMBLE.mat'; -% y_rf='ya_gnut_2071_00_RCP60_rf_CO2_ENSEMBLE.mat'; -% -% case 7 -% crop = 'Barley'; -% -% area_irrigata='aree_irr_brl_2010.mat'; -% area_rainfed='aree_rf_brl_2010.mat'; -% area_totale='aree_tot_brl_2010.mat'; -% -% y_avg='ya_brl_2071_00_RCP60_avg_CO2_ENSEMBLE.mat'; -% y_irr='ya_brl_2071_00_RCP60_irr_CO2_ENSEMBLE.mat'; -% y_rf='ya_brl_2071_00_RCP60_rf_CO2_ENSEMBLE.mat'; -% -% case 8 -% crop = 'Cassava'; -% -% area_irrigata='aree_irr_cas_2010.mat'; -% area_rainfed='aree_rf_cas_2010.mat'; -% area_totale='aree_tot_cas_2010.mat'; -% -% y_avg='ya_cas_2071_00_RCP60_avg_CO2_ENSEMBLE.mat'; -% y_irr='ya_cas_2071_00_RCP60_irr_CO2_ENSEMBLE.mat'; -% y_rf='ya_cas_2071_00_RCP60_rf_CO2_ENSEMBLE.mat'; -% -% case 9 -% crop = 'Cotton'; -% -% area_irrigata='aree_irr_cot_2010.mat'; -% area_rainfed='aree_rf_cot_2010.mat'; -% area_totale='aree_tot_cot_2010.mat'; -% -% y_avg='ya_cot_2071_00_RCP60_avg_CO2_ENSEMBLE.mat'; -% y_irr='ya_cot_2071_00_RCP60_irr_CO2_ENSEMBLE.mat'; -% y_rf='ya_cot_2071_00_RCP60_rf_CO2_ENSEMBLE.mat'; -% -% case 10 -% crop = 'Millet'; -% -% area_irrigata='aree_irr_mlt_2010.mat'; -% area_rainfed='aree_rf_mlt_2010.mat'; -% area_totale='aree_tot_mlt_2010.mat'; -% -% y_avg='ya_mlt_2071_00_RCP60_avg_CO2_ENSEMBLE.mat'; -% y_irr='ya_mlt_2071_00_RCP60_irr_CO2_ENSEMBLE.mat'; -% y_rf='ya_mlt_2071_00_RCP60_rf_CO2_ENSEMBLE.mat'; -% -% case 11 -% crop = 'Sugarcane'; -% -% area_irrigata='aree_irr_suc_2010.mat'; -% area_rainfed='aree_rf_suc_2010.mat'; -% area_totale='aree_tot_suc_2010.mat'; -% -% y_avg='ya_suc_2071_00_RCP60_avg_CO2_ENSEMBLE.mat'; -% y_irr='ya_suc_2071_00_RCP60_irr_CO2_ENSEMBLE.mat'; -% y_rf='ya_suc_2071_00_RCP60_rf_CO2_ENSEMBLE.mat'; - -% case 12 usa altro codice x yams -% crop = 'Yams'; -% -% % area_irrigata='aree_irr_yam_2010.mat'; -% area_rainfed='aree_rf_yam_2010.mat'; -% % area_totale='aree_tot_yam_2010.mat'; -% -% % y_avg='ya_yam_2071_00_RCP60_avg_CO2_ENSEMBLE.mat'; -% % y_irr='ya_yam_2071_00_RCP60_irr_CO2_ENSEMBLE.mat'; -% y_rf='ya_yam_2071_00_RCP60_rf_CO2_ENSEMBLE.mat'; - -end - -cartella_aree = ['C:\Users\giord\Desktop\IIASA collab\WaterCrop\',crop,'']; - -cartella_ET_Igrow = ['C:\Users\giord\Desktop\IIASA collab\WaterCrop\Risultati1_ETa\',crop,'']; - -cartella_rese = ['C:\Users\giord\Desktop\IIASA collab\WaterCrop\',crop,'']; - -cd(cartella_aree) -area_irr=importdata(area_irrigata); - -area_rain=importdata(area_rainfed); - -area_tot=importdata(area_totale); - -cd(cartella_ET_Igrow) - ET_verde_rain=importdata('ETa_rain.mat'); - ET_blu_irr=importdata('ET_blu.mat'); - ET_tot_irr=importdata('ETa_irr.mat'); - - ET_verde_irr=ET_tot_irr-ET_blu_irr; - -cd(cartella_rese) -resa=importdata(y_avg); -resa_irr=importdata(y_irr); -resa_rain=importdata(y_rf); - -% 2 growing seasons -% ET_verde=(ET_verde_rain.*area_rain+ET_verde_irr.*area_irr + ET_verde_rainII.*area_rain_II+ET_verde_irrII.*area_irr_II)./(area_rain+area_irr + area_rain_II+area_irr_II); -% ET_blu=(ET_blu_irr.*area_irr + ET_blu_irrII.*area_irr_II)./(area_rain+area_irr + area_rain_II+area_irr_II); - -% 1 growing season - ET_verde_I_grow=(ET_verde_rain.*area_rain+ET_verde_irr.*area_irr)./(area_tot); - ET_blu_I_grow=(ET_blu_irr.*area_irr)./(area_tot); - -%calcolo et verde e blu complessive dei due scenari, pesando i contributi in funzione dell'area coltivata - -% ET_rf=(ET_verde_rain.*area_rain + ET_verde_rainII.*area_rain_II)./(area_rain+area_irr + area_rain_II+area_irr_II); -% ET_ir=(ET_tot_irr.*area_irr + ET_tot_irrII.*area_irr_II)./(area_rain+area_irr + area_rain_II+area_irr_II); - -%calcolo l'impronta idrica complessiva dei due scenari - uWF_rf_I_grow=ET_verde_rain*10./resa_rain; - uWF_ir_I_grow=ET_tot_irr*10./resa_irr; - -%calcolo l'impronta idrica complessiva dei due scenari - uWF_verde_I_grow=ET_verde_I_grow*10./resa; %average yield - uWF_blu_I_grow=ET_blu_I_grow*10./resa; - - uWF_rf_I_grow(isinf(uWF_rf_I_grow))=0; - uWF_rf_I_grow(isnan(uWF_rf_I_grow))=0; - - uWF_ir_I_grow(isinf(uWF_ir_I_grow))=0; - uWF_ir_I_grow(isnan(uWF_ir_I_grow))=0; - - uWF_verde_I_grow(isinf(uWF_verde_I_grow))=0; - uWF_verde_I_grow(isnan(uWF_verde_I_grow))=0; - - uWF_blu_I_grow(isinf(uWF_blu_I_grow))=0; - uWF_blu_I_grow(isnan(uWF_blu_I_grow))=0; - - uWF_tot_I_grow=uWF_verde_I_grow+uWF_blu_I_grow; - - uWF_tot_I_grow(isinf(uWF_tot_I_grow))=0; - uWF_tot_I_grow(isnan(uWF_tot_I_grow))=0; - -prod_irr=resa_irr.*area_irr; -prod_rf=resa_rain.*area_rain; -prod_tot=resa.*area_tot; - -WFb=uWF_blu_I_grow.*prod_tot; -WFb(isinf(WFb))=0; -WFb(isnan(WFb))=0; - -WFg=uWF_verde_I_grow.*prod_tot; -WFg(isinf(WFg))=0; -WFg(isnan(WFg))=0; - -WFt=uWF_tot_I_grow.*prod_tot; -WFt(isinf(WFt))=0; -WFt(isnan(WFt))=0; - -WFirr=uWF_ir_I_grow.*prod_irr; -WFirr(isinf(WFirr))=0; -WFirr(isnan(WFirr))=0; - -WFrf=uWF_rf_I_grow.*prod_rf; -WFrf(isinf(WFrf))=0; -WFrf(isnan(WFrf))=0; - -%memorizzo i risultati -cartella_risultati_I_grow=['C:\Users\giord\Desktop\IIASA collab\WaterCrop\Risultati3_WF\',crop,'']; -cd(cartella_risultati_I_grow) - -save('ET_verde_I_grow.mat','ET_verde_I_grow') -save('ET_blu_I_grow.mat','ET_blu_I_grow') -save('uWF_verde_I_grow.mat','uWF_verde_I_grow') -save('uWF_blu_I_grow.mat','uWF_blu_I_grow') -save('uWF_tot_I_grow.mat','uWF_tot_I_grow') -save('uWF_ir_I_grow.mat','uWF_ir_I_grow') -save('uWF_rf_I_grow.mat','uWF_rf_I_grow') -save('WFg.mat','WFg') -save('WFb.mat','WFb') -save('WFt.mat','WFt') -save('WFirr.mat','WFirr') -save('WFrf.mat','WFrf') - -% fid=fopen('uWF_tot_I_grow.txt','w'); -% fprintf(fid,'ncols 4320\r\nnrows 2160\r\nxllcorner -180\r\nyllcorner -90\r\ncellsize 0.0833333\r\nNODATA_value 0\r\n'); -% for i=1:2160 -% -% fprintf(fid,'%.2f ',uWF_tot_I_grow(i,:)); -% -% fprintf(fid,'\r\n'); -% end -% fclose(fid); -% % -% fid=fopen('uWF_blu_I_grow.txt','w'); -% fprintf(fid,'ncols 4320\r\nnrows 2160\r\nxllcorner -180\r\nyllcorner -90\r\ncellsize 0.0833333\r\nNODATA_value 0\r\n'); -% for i=1:2160 -% -% fprintf(fid,'%.2f ',uWF_blu_I_grow(i,:)); -% -% fprintf(fid,'\r\n'); -% end -% fclose(fid); -% % -% fid=fopen('uWF_verde_I_grow.txt','w'); -% fprintf(fid,'ncols 4320\r\nnrows 2160\r\nxllcorner -180\r\nyllcorner -90\r\ncellsize 0.0833333\r\nNODATA_value 0\r\n'); -% for i=1:2160 -% -% fprintf(fid,'%.2f ',uWF_verde_I_grow(i,:)); -% -% fprintf(fid,'\r\n'); -% end -% fclose(fid); -% % -% fid=fopen('uWF_rf_I_grow.txt','w'); -% fprintf(fid,'ncols 4320\r\nnrows 2160\r\nxllcorner -180\r\nyllcorner -90\r\ncellsize 0.0833333\r\nNODATA_value 0\r\n'); -% for i=1:2160 -% -% fprintf(fid,'%.2f ',uWF_rf_I_grow(i,:)); -% -% fprintf(fid,'\r\n'); -% end -% fclose(fid); -% % -% fid=fopen('uWF_ir_I_grow.txt','w'); -% fprintf(fid,'ncols 4320\r\nnrows 2160\r\nxllcorner -180\r\nyllcorner -90\r\ncellsize 0.0833333\r\nNODATA_value 0\r\n'); -% for i=1:2160 -% -% fprintf(fid,'%.2f ',uWF_ir_I_grow(i,:)); -% -% fprintf(fid,'\r\n'); -% end -% fclose(fid); -% -% fid=fopen('WFt.txt','w'); -% fprintf(fid,'ncols 4320\r\nnrows 2160\r\nxllcorner -180\r\nyllcorner -90\r\ncellsize 0.0833333\r\nNODATA_value 0\r\n'); -% for i=1:2160 -% -% fprintf(fid,'%.2f ',WFt(i,:)); -% -% fprintf(fid,'\r\n'); -% end -% fclose(fid); -% % -% fid=fopen('WFb.txt','w'); -% fprintf(fid,'ncols 4320\r\nnrows 2160\r\nxllcorner -180\r\nyllcorner -90\r\ncellsize 0.0833333\r\nNODATA_value 0\r\n'); -% for i=1:2160 -% -% fprintf(fid,'%.2f ',WFb(i,:)); -% -% fprintf(fid,'\r\n'); -% end -% fclose(fid); -% % -% fid=fopen('WFg.txt','w'); -% fprintf(fid,'ncols 4320\r\nnrows 2160\r\nxllcorner -180\r\nyllcorner -90\r\ncellsize 0.0833333\r\nNODATA_value 0\r\n'); -% for i=1:2160 -% -% fprintf(fid,'%.2f ',WFg(i,:)); -% -% fprintf(fid,'\r\n'); -% end -% fclose(fid); -% % -% fid=fopen('WFrf.txt','w'); -% fprintf(fid,'ncols 4320\r\nnrows 2160\r\nxllcorner -180\r\nyllcorner -90\r\ncellsize 0.0833333\r\nNODATA_value 0\r\n'); -% for i=1:2160 -% -% fprintf(fid,'%.2f ',WFrf(i,:)); -% -% fprintf(fid,'\r\n'); -% end -% fclose(fid); -% % -% fid=fopen('WFirr.txt','w'); -% fprintf(fid,'ncols 4320\r\nnrows 2160\r\nxllcorner -180\r\nyllcorner -90\r\ncellsize 0.0833333\r\nNODATA_value 0\r\n'); -% for i=1:2160 -% -% fprintf(fid,'%.2f ',WFirr(i,:)); -% -% fprintf(fid,'\r\n'); -% end -% fclose(fid); -% -% end