fao_total_specifications_2023.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. function specifications = fao_total_specifications_2023(sourcename)
  2. % fao_specifications just creates a structure containing all informations
  3. % needed to parse the fao files...
  4. %
  5. % INPUT PARAMETERS: None
  6. %
  7. % RETURN PARAMETERS:
  8. % specifications: a structure with many constants needed to parse the
  9. % input xls files for the program read_bulkplus_sheet.
  10. % specifications contains two fields, 'keystruct', and 'mapstruct'.
  11. % - specifications.keystruct - is a structure of sheet fieldnames (e.g.
  12. % 'sheet_category'), where the value is a cellstr of the labels that
  13. % should be used to assign the value. The list is taken in the order it
  14. % is listed.
  15. % - specifications.mapstruct - is a structure that maps column headers (or other
  16. % inputs, such as $filename or $sheetname for the filename or sheetname,
  17. % respectively) to the values to be assigned to sheet fields.
  18. % mapstruct.names contains the list of headers names, where the index of
  19. % each header corresponds to the field 'var[index]'. mapstruct.varX
  20. % contains the field 'value', as well as fields for each sheet
  21. % fieldname (e.g. sheet_category) that gets mappings from this
  22. % parameter source. the field 'value' can have three types of values:
  23. % - a cellstr of possible values in the input file. In this case,
  24. % cellstrs of the same length are given for the sheet fieldnames, which
  25. % provide the values to map too.
  26. % - the string 'echo'. In this case, the value in the input file is fed
  27. % to a function, the name of which is given in the sheet fieldname
  28. % fields. if the function is an empty string, then the value in the
  29. % input file is simply fed directly.
  30. % - the string 'split'. In this case, the value in the input file for
  31. % this column is a year, such that before this year the data is to have
  32. % one designation, and after and including this year, it is to have a
  33. % different designation. (this is used for the IMF WEO data). The
  34. % designations are provided in the sheet fieldname field.
  35. %
  36. %
  37. % GLOBALS:
  38. % CONSTANTS: A structure containing string and numeric constants, which are
  39. % used in the PRIMAP functions. These are configurations like
  40. % scaling factors, but also fieldnames for the database and
  41. % mapping vectors etc.
  42. %
  43. % NOTES:
  44. %
  45. % (c) Written by Kathleen Markmann and the PRIMAP - PIK team, June 2012.
  46. % This file is shared under a "Attribution-NonCommercial-ShareAlike 3.0"
  47. % licence, which means that you must give credit to the author, are not
  48. % allowed to use it for commercial purposes and you may share your
  49. % derivatives of this work only under a similar licence. Other than that,
  50. % you are free to copy, display, use, modify the code. The details of this
  51. % licence are given at: http://creativecommons.org/licenses/by-nc-sa/3.0/
  52. %
  53. % version: 150602 JG - based on fao_specifications
  54. % version: 201001 JG - adpated for FAO 2020A
  55. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  56. global CONSTANTS
  57. if isempty(CONSTANTS)
  58. error('Empty global variable! Please initialise with the drive_set_paths_and_globals... function!')
  59. end
  60. %please insert the download date?!
  61. date = 'Jan 2023'; % for FAO2019A
  62. %sourcename='FAO2018';
  63. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  64. %%%%%%%%%%%%%%%%%%%%%%%%%%%% sheet management %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  65. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  66. % INPUT NAMES OF EXCEL SHEETS TO READ IN. IF NOT SPECIFIED, ALL SHEETS ARE
  67. % READ IN
  68. %specifications.sheetsToRead = {...
  69. %};
  70. % INPUT NAMES OF EXCEL SHEETS TO NOT READ IN. IF SHEET IS ENCOUNTERED THAT
  71. % IS NOT LISTED IN THE SHEETSTOREAD OR SHEETSTOIGNORE, A WARNING IS GIVEN
  72. %specifications.sheetsToIgnore = {...
  73. %};
  74. % data in csv-format?
  75. specifications.isCSV = true;
  76. specifications.CSVdelimiter = ',';
  77. specifications.CSVQuotesToRemove = '';
  78. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  79. %%%%%%%%%%%%%%%%%%%%%%%%%%%%% READING SHEETS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  80. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  81. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  82. % SPECIFY IF DATA IS EXTRA LONG AND NEEDS TO BE READ IN BLOCKS
  83. % IF BlockSize and dataBottomRightCorner IS NOT FIELD, DEFAULT IS TO READ IN ALL DATA AT ONCE
  84. specifications.blockSize = 10000;
  85. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  86. % SPECIFY IF LABEL IS ONLY ONE COLUMN. DEFAULT IS FALSE. IF TRUE, THEN
  87. % COLUMN NAMES DO NOT NEED TO BE SPECIFIED. LABELS ASSUMED TO BE IN FIRST
  88. % COLUMN
  89. specifications.singleLabel = false;
  90. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  91. % SPECIFY COLUMN INDEX WHERE ANNUAL DATA STARTS
  92. %%%% TEMP %%%%
  93. specifications.colStartOfYear = 9;
  94. %temporarily because index has been written in files by mistake
  95. %%%% TEMP %%%%
  96. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  97. % SPECIFY ROW INDEX WHERE THE HEADER IS FOUND. IF NOT GIVEN, DEFAULT IS 1.
  98. % CAN BE MULTIPLE ROWS. IN THIS CASE, ALL ROWS LISTED ARE CONCATENATED WITH
  99. % NO SPACES BETWEEN EACH ROW.
  100. specifications.rowOfHeader = 1;
  101. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  102. % SPECIFY ROW INDEX WHERE DATA STARTS. DEFAULT IS ROW AFTER HEADER
  103. specifications.rowOfData = 2;
  104. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  105. % HEADER VALUE THAT INDICATES THE END OF DATA. DATA IS
  106. % ASSUMED TO END BEFORE THIS. IF NOT GIVEN, DEFAULT IS NaN
  107. %specifications.nonDataKeyword = '2014F';
  108. %each of these specification columns has to be defined in the following...
  109. %the way is the same for all of them: first you define the name for the
  110. %column than you define the mapping
  111. %always the bulk name and in the same order the according PRIMAPDB names
  112. %specifications.yearColIgnore = '\d*F';
  113. %specifications.yearColTransform = '\d*'; %this is used to match a string
  114. % which is then taken as the year
  115. % DEFINE KEYSTRUCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  116. % FOR EVERY SHEET KEY THAT IS TO BE DEFINED FROM THE INPUT FILE, PROVIDE
  117. % THE SHEET KEY NAME AS A FIELD, AND THEN LIST THE COLUMN HEADERS (OR
  118. % $filename or $sheetname FOR THE FILENAME OR EXCEL SHEETNAME,
  119. % RESPECTIVELY) IN THE SUBFIELD colName. IF SINGLE COLUMN MODE IS DEFINED,
  120. % THEN USE $label.
  121. specifications.keystruct.(CONSTANTS.nameOfSheetEntity).colName = {'Element'};
  122. specifications.keystruct.(CONSTANTS.nameOfCountryVector).colName = {'Area Code'};
  123. specifications.keystruct.(CONSTANTS.nameOfSheetCategory).colName = {'Item'};
  124. specifications.keystruct.(CONSTANTS.nameOfSheetType).colName = {'Element'};
  125. specifications.keystruct.(CONSTANTS.nameOfSheetUnit).colName = {'Unit', 'Element', 'Variable'}; % {'Unit'};
  126. %% TODO
  127. % we need an new FAO specification because the new emission data does not really fit into the old categories
  128. % we now have the following
  129. % * Emissions on agricultural land
  130. % = Farm-gate emissions + Fires in humid tropical forests + Net Forest conversion + Fires in organic soils
  131. % * Farm-gate emissions (1)
  132. % = Enteric Fermentation (1A) + Manure Management (1B) + Rice Cultivation (1C) + Synthetic Fertilizers (1D)
  133. % + Manure applied to Soils (1E) + Manure left on Pasture (1F) + Crop Residues (1G) + Burning - Crop residues (1J)
  134. % + Drained organic soils (1H, CO2 and N2O) + On-farm energy use (1K)
  135. % * FORESTLAND = Forestland + Forest fires
  136. % * LAND USE CHANGE = Fires in humid tropical forests + Net Forest conversion + Fires in organic soils
  137. % (FORESTLAND and LAND USE CHANGE are not available in the csv files, but named on the
  138. % "FAOSTAT Domain Emissions Totals. Metadata" document)
  139. % IPCC type categories
  140. % AFOLU = IPCC Agriculture + LULUCF
  141. % IPCC Agriculture = Farm-gate emissions - On-farm energy use - Drained organic soils (CO2)
  142. % LULUCF = LAND USE CHANGE + FORESTLAND + Drained organic soils (CO2)
  143. % or LULUCF = Fires in humid tropical forests + Net Forest conversion + Fires in organic soils
  144. % + Forestland + Forest fires
  145. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  146. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MAPPING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  147. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  148. % LISTS MAPPING BETWEEN VALUES IN THE INPUT FILE AND VALUES FOR THE
  149. % DATATABLES. THE COLUMN HEADERS (OR $filename or $sheetname FOR THE
  150. % FILENAME OR EXCEL SHEETNAME, RESPECTIVELY) ARE LISTED IN FIELD name.
  151. % STANDARD INPUT FOR var[i].value IS TO PROVIDE A CELLSTR OF ALL VALUES
  152. % FROM THE COLUMN LISTED IN name{i} THAT ARE TO BE ASSIGNED. VALUES TO BE
  153. % IGNORED CAN BE LISTED IN FIELD var[i].valuesToIgnore, TO REDUCE WARNING
  154. % MESSAGES. THE SHEET KEYS TO MAP TO ARE LISTED AS FIELDS UNDER var[i],
  155. % WITH THE VALUE IN THE STANDARD CASE BEING A CELLSTR WITH THE SAME LENGTH
  156. % AS THE FIELD value, THAT PROVIDES THE VALUES TO BE USED IN THE
  157. % DATATABLES.
  158. % ALTERNATE INPUTS FOR FIELD value ARE THE STRINGS 'echo' OR
  159. % 'split'. 'echo' PASSES THE INPUT VALUE TO THE FUNCTION LISTED UNDER THE
  160. % SHEET KEY FIELD, AND ASSIGNS THE OUTPUT TO THE SHEET KEY. 'split' ASSUMES
  161. % THAT THE INPUT VALUES IS A YEAR. THE DATA WILL BE SPLIT INTO TWO
  162. % DATATABLES AT THAT YEAR, WITH THAT YEAR BEING A PART OF THE SECOND
  163. % DATATABLE. THE FIRST TABLE WILL GET THE FIRST ELEMENT ASSIGNED TO SHEET
  164. % KEY FIELD, AND THE SECOND TABLE WILL GET THE SECOND ELEMENT.
  165. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% entity, category and unit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  166. i = 1;
  167. specifications.mapstruct.name{i} = 'Element';
  168. specifications.mapstruct.(['var' num2str(i)]).value = { ...
  169. 'Emissions (CH4)', 'Emissions (N2O)', 'Emissions (CO2)', ...
  170. 'Emissions (CO2eq) (AR5)', 'Direct emissions (N2O)', 'Indirect emissions (N2O)', ...
  171. 'Emissions (CO2eq) from F-gases (AR5)',
  172. };
  173. specifications.mapstruct.(['var' num2str(i)]).(CONSTANTS.nameOfSheetEntity) = { ...
  174. 'CH4', 'N2O', 'CO2', ...
  175. 'KYOTOGHGAR5', 'N2O', 'N2O', ...
  176. 'FGASESAR5', ...
  177. };
  178. specifications.mapstruct.(['var' num2str(i)]).(CONSTANTS.nameOfSheetUnit) = { ...
  179. '', '', '', ...
  180. 'CO2eq', '', '', ...
  181. 'CO2eq', ...
  182. };
  183. specifications.mapstruct.(['var' num2str(i)]).(CONSTANTS.nameOfSheetType) = { ...
  184. 'NET', 'NET', 'NET', ...
  185. 'NET', 'DIR', 'IND', ...
  186. 'NET', ...
  187. };
  188. specifications.mapstruct.(['var' num2str(i)]).valueToIgnore = { ...
  189. 'Emissions (CO2eq) from N2O (AR5)', ...
  190. 'Emissions (CO2eq) from CH4 (AR5)', ...
  191. };
  192. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% region %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  193. i = 2;
  194. specifications.mapstruct.name{i} = 'Area Code';
  195. specifications.mapstruct.(['var' num2str(i)]).value = { ...
  196. '1', '2', '3', '4', '5', ...
  197. '6', '7', '8', '9', '10', ...
  198. '11', '12', '13', '14', '15', ...
  199. '16', '17', '18', '19', '20', ...
  200. '21', '22', '23', '24', '25', ... % 5
  201. '26', '27', '28', '29', '30', ...
  202. '31', '32', '33', '35', '36', ...
  203. '37', '38', '39', '40', '41', ...
  204. '42', '43', '44', '45', '46', ...
  205. '47', '48', '49', '50', '51', ... % 10
  206. '52', '53', '54', '55', '56', ...
  207. '57', '58', '59', '60', '61', ...
  208. '62', '63', '64', '65', '66', ...
  209. '67', '68', '69', '70', '71', ...
  210. '72', '73', '74', '75', '77', ... % 15
  211. '78', '79', '80', '81', '82', ...
  212. '83', '84', '85', '86', '87', ...
  213. '88', '89', '90', '91', '92', ...
  214. '93', '94', '95', '96', '97', ...
  215. '98', '99', '100', '101', '102', ... % 20
  216. '103', '104', '105', '106', '107', ...
  217. '108', '109', '110', '111', '112', ...
  218. '113', '114', '115', '116', '117', ...
  219. '118', '119', '120', '121', '122', ...
  220. '123', '124', '125', '126', '127', ... % 25
  221. '128', '129', '130', '131', '132', ...
  222. '133', '134', '135', '136', '137', ...
  223. '138', '139', '140', '141', '142', ...
  224. '143', '144', '145', '146', '147', ...
  225. '148', '149', '150', '151', '153', ... %30
  226. '154', '155', '156', '157', '158', ...
  227. '159', '160', '161', '162', '163', ...
  228. '164', '165', '166', '167', '168', ...
  229. '169', '170', '171', '172', '173', ...
  230. '174', '175', '176', '177', '178', ... %35
  231. '179', '180', '181', '182', '183', ...
  232. '184', '185', '186', '187', '188', ...
  233. '189', '190', '191', '192', '193', ...
  234. '194', '195', '196', '197', '198', ...
  235. '199', '200', '201', '202', '203', ... % 40
  236. '205', '206', '207', '208', '209', ...
  237. '210', '211', '212', '213', '214', ...
  238. '215', '216', '217', '218', '219', ...
  239. '220', '221', '222', '223', '224', ...
  240. '225', '226', '227', '228', '229', ... % 45
  241. '230', '231', '232', '233', '234', ...
  242. '235', '236', '237', '238', '239', ...
  243. '240', '242', '243', '244', '248', ...
  244. '249', '250', '251', '255', '256', ...
  245. '258', '259', '260', '264', '270', ... % 50
  246. '271', '272', '273', '274', '275', ...
  247. '276', '277', '278', '279', '280', ...
  248. '281', '282', '283', '284', '299', ...
  249. };
  250. specifications.mapstruct.(['var' num2str(i)]).(CONSTANTS.nameOfCountryVector) = { ...
  251. 'ARM', 'AFG', 'ALB', 'DZA', 'ASM', ...
  252. 'AND', 'AGO', 'ATG', 'ARG', 'AUS', ...
  253. 'AUT', 'BHS', 'BHR', 'BRB', 'BELLUX', ...
  254. 'BGD', 'BMU', 'BTN', 'BOL', 'BWA', ...
  255. 'BRA', 'ABW', 'BLZ', 'IOT', 'SLB', ... % 5
  256. 'BRN', 'BGR', 'MMR', 'BDI', 'ATA', ...
  257. 'BVT', 'CMR', 'CAN', 'CPV', 'CYM', ...
  258. 'CAF', 'LKA', 'TCD', 'CHL', 'CHN', ...
  259. 'CXR', 'CCK', 'COL', 'COM', 'COG', ...
  260. 'COK', 'CRI', 'CUB', 'CYP', 'CZESVK', ... % 10
  261. 'AZE', 'BEN', 'DNK', 'DMA', 'DOM', ...
  262. 'BLR', 'ECU', 'EGY', 'SLV', 'GNQ', ...
  263. 'ETHERI', 'EST', 'FRO', 'FLK', 'FJI', ...
  264. 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', ...
  265. 'DJI', 'GEO', 'GAB', 'GMB', 'F77', ... % 15
  266. 'F78', 'DEU', 'BIH', 'GHA', 'GIB', ... %F77,78 is GDR and BRD but no data in FAOSTAT
  267. 'KIR', 'GRC', 'GRL', 'GRD', 'GLP', ...
  268. 'GUM', 'GTM', 'GIN', 'GUY', 'HMD', ...
  269. 'HTI', 'VAT', 'HND', 'HKG', 'HUN', ...
  270. 'HRV', 'ISL', 'IND', 'IDN', 'IRN', ... % 20
  271. 'IRQ', 'IRL', 'ISR', 'ITA', 'CIV', ...
  272. 'KAZ', 'JAM', 'JPN', 'JTN', 'JOR', ... % not sure what JTN is
  273. 'KGZ', 'KEN', 'KHM', 'PRK', 'KOR', ...
  274. 'KWT', 'LVA', 'LAO', 'LBN', 'LSO', ...
  275. 'LBR', 'LBY', 'LIE', 'LTU', 'MHL', ... % 25
  276. 'MAC', 'MDG', 'MWI', 'MYS', 'MDV', ...
  277. 'MLI', 'MLT', 'MTQ', 'MRT', 'MUS', ...
  278. 'MEX', 'MID', 'MCO', 'MNG', 'MSR', ... % MID unknown
  279. 'MAR', 'MOZ', 'FSM', 'MDA', 'NAM', ...
  280. 'NRU', 'NPL', 'NLD', 'ANT', 'NCL', ... % 30
  281. 'MKD', 'VUT', 'NZL', 'NIC', 'NER', ...
  282. 'NGA', 'NIU', 'NFK', 'NOR', 'MNP', ...
  283. 'TTPI', 'PAK', 'PAN', 'CZE', 'PNG', ...
  284. 'PRY', 'PER', 'PHL', 'PCN', 'POL', ...
  285. 'PRT', 'GNB', 'TLS', 'PRI', 'ERI', ... % 35
  286. 'QAT', 'PLW', 'ZWE', 'REU', 'ROU', ...
  287. 'RWA', 'RUS', 'SRBMNE', 'SHN', 'KNA', ...
  288. 'LCA', 'SPM', 'VCT', 'SMR', 'STP', ...
  289. 'SAU', 'SEN', 'SYC', 'SLE', 'SVN', ...
  290. 'SVK', 'SGP', 'SOM', 'ZAF', 'ESP', ... % 40
  291. 'ESH', 'SDNSSD', 'SUR', 'TJK', 'SWZ', ...
  292. 'SWE', 'CHE', 'SYR', 'TKM', 'TWN', ...
  293. 'TZA', 'THA', 'TGO', 'TKL', 'TON', ...
  294. 'TTO', 'OMN', 'TUN', 'TUR', 'TCA', ...
  295. 'ARE', 'UGA', 'TUV', 'FSU', 'GBR', ... % 45
  296. 'UKR', 'USA', 'UMI', 'BFA', 'URY', ...
  297. 'UZB', 'VEN', 'VNM', 'ETH', 'VGB', ...
  298. 'VIR', 'WAK', 'WLF', 'WSM', 'YUG', ... % WAK unknown
  299. 'YEM', 'COD', 'ZMB', 'BEL', 'LUX', ...
  300. 'AIA', 'CHI', 'SJM', 'IMN', 'MYT', ... % 50
  301. 'SGS', 'SRB', 'MNE', 'GGY', 'UVK', ... % UVK unknown
  302. 'SDN', 'SSD', 'BES', 'CUW', 'SXM', ...
  303. 'MAF', 'BLM', 'JEY', 'ALA', 'PSE', ...
  304. };
  305. specifications.mapstruct.(['var' num2str(i)]).valueToIgnore = { ...
  306. '5000', '5100', '5101', '5102', '5103', ...
  307. '5104', '5105', '5200', '5203', '5204', ...
  308. '5206', '5207', '5300', '5301', '5302', ...
  309. '5303', '5304', '5305', '5400', '5401', ...
  310. '5402', '5403', '5404', '5500', '5501', ...
  311. '5502', '5503', '5504', '5707', '5801', ...
  312. '5802', '5803', '5815', '5817', '5848', ...
  313. '5849', '5873', 'F246', 'F247', 'F609', 'F614', ...
  314. 'F616', 'F617', 'F618', 'F619', 'F620', ...
  315. 'F621', 'F622', '351', ... %351 is China but we have it split up here
  316. };
  317. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  318. i = 3;
  319. specifications.mapstruct.name{i} = 'Item';
  320. specifications.mapstruct.(['var' num2str(i)]).value = { ...
  321. 'LULUCF', 'IPCC Agriculture', ...
  322. 'Enteric Fermentation', 'Manure Management', 'Synthetic Fertilizers', ...
  323. 'Manure applied to Soils', 'Manure left on Pasture', 'Crop Residues', ...
  324. 'Burning - Crop residues', 'Net Forest conversion', 'Forestland', ...
  325. 'Savanna fires', 'AFOLU', ...
  326. 'Rice Cultivation', 'Agricultural Soils', ...
  327. 'All sectors with LULUCF', 'All sectors without LULUCF', 'Energy', ...
  328. 'IPPU', 'Other', 'Waste', ...
  329. 'Drained organic soils', 'Drained organic soils (N2O)', 'Drained organic soils (CO2)', ...
  330. %'Forest fires', ... %5
  331. %'Fires in organic soils', 'On-farm energy use', 'Emissions on agricultural land', ...
  332. %'Farm-gate emissions', 'Fires in humid tropical forests',
  333. %'Agri-food systems',
  334. %'Farm gate', 'Fertilizers Manufacturing',
  335. %'Food Household Consumption', 'Food Packaging',
  336. %'Food Processing', 'Food Retail',
  337. %'Food Transport', 'Food systems waste disposal',
  338. % 'Land Use change', 'On-farm electricity use',
  339. % 'Pre- and post- production',
  340. };
  341. specifications.mapstruct.(['var' num2str(i)]).(CONSTANTS.nameOfSheetCategory) = { ...
  342. 'IPCMLULUCF', 'IPCMAG', ...
  343. 'IPC3A1', 'IPC3A2', 'IPC3C4A', ...
  344. 'IPC3C4B', 'IPC3C4C', 'IPC3C4D', ...
  345. 'IPC3C1B', 'IPCMNFC', 'IPC3B1', ...
  346. 'IPC3C1C', 'IPC3', ...
  347. 'IPC3C7', 'IPCM3C45AG', ...
  348. 'IPC0', 'IPCM0EL', 'IPC1', ...
  349. 'IPC2', 'IPC5', 'IPC4', ...
  350. 'IPCM3C45DOS', 'IPCM3C45DOSN2O', 'IPCM3C45DOSCO2', ...
  351. %'MFF', ... %5
  352. %'2D3', '1K', 'MAL', ...
  353. %'MFG', '2D1',
  354. %'1H', 'M1HAG', 'M1HLU', ...
  355. };
  356. specifications.mapstruct.(['var' num2str(i)]).valueToIgnore = { ...
  357. 'Forest fires', ... %5
  358. 'Fires in organic soils', 'On-farm energy use', 'Emissions on agricultural land', ...
  359. 'Farm-gate emissions', 'Fires in humid tropical forests', ...
  360. 'Agri-food systems', 'Farm gate', 'Fertilizers Manufacturing', ...
  361. 'Food Household Consumption', 'Food Packaging', ...
  362. 'Food Processing', 'Food Retail', ...
  363. 'Food Transport', 'Food systems waste disposal', ...
  364. 'Land Use change', 'On-farm electricity use', ...
  365. 'Pre- and post- production', ...
  366. 'Agrifood Systems Waste Disposal', 'Agrifood systems', ... % below new in 2024A
  367. 'Pesticides Manufacturing', 'Pre- and Post- Production', ...
  368. 'Emissions from crops', 'Emissions from livestock', ... don't fit IPCC categories
  369. };
  370. % general caveats in mapping: does not distinguish between direct and
  371. % indirect. All mapped to direct IPCC cats (3.C.4)
  372. % it's unclear where drained organic soils should be mapped to. It's
  373. % included in Agricultural soils and thus implicitly mapped to M.3.C.45AG
  374. % TODO make new FAO terminology
  375. % FAO sector hierarchy (total domain)
  376. % IPCC Agriculture (CH4, N2O) X
  377. % * Enteric fermentation (CH4 only) X
  378. % * Manure Management X
  379. % * Burning - crop residues X
  380. % * Savanna fires X
  381. % * Rice cultivation (CH4 only) X
  382. % * Agricultural soils (N2O only) X
  383. % * Synthetic Fertilizers X
  384. % * Manure applied to soils X
  385. % * Manure left on Pasture X
  386. % * Crop Residues X
  387. % * Drained organic soils (N2O)
  388. % not in IPCC Agriculture hierarchy
  389. % Drained organic soils (CO2)
  390. % Net Forest conversion
  391. % Fires in humid tropical forests
  392. % Fires in organic soils
  393. % Forest fires
  394. % Forestland
  395. % On-farm energy use
  396. % agg
  397. % Agricultural Soils
  398. % IPCC Agriculture
  399. % LULUCF
  400. % AFOLU
  401. % Emissions on agricultural land
  402. % Farm-gate emissions
  403. % Land Use change
  404. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  405. i = 4;
  406. specifications.mapstruct.name{i} = 'Unit';
  407. specifications.mapstruct.(['var' num2str(i)]).value = { ...
  408. 'Gigagrams', 'gigagrams', 'tonnes', 'Kg', 'Head', ...
  409. 'kilotonnes', 'kt', ...
  410. };
  411. specifications.mapstruct.(['var' num2str(i)]).(CONSTANTS.nameOfSheetUnit) = { ...
  412. 'Gg', 'Gg', 't', 'Kg', 'Heads', ...
  413. 'kt', 'kt', ...
  414. };
  415. specifications.mapstruct.(['var' num2str(i)]).valueToIgnore = { ...
  416. 'g N20/kg dry matter', 'g CH4/kg dry matter', 'Ha', ...
  417. 'Kg of nutrients', 'kg N2O-N/kg N', 'million kWh', ...
  418. 'Terajoule', 'Kg/TJ', 'Kg CH4/head', ...
  419. 'kg N2O-N/kg N', ...
  420. };
  421. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  422. i = 5;
  423. specifications.mapstruct.name{i} = 'Variable';
  424. specifications.mapstruct.(['var' num2str(i)]).value = { ...
  425. 'Value', ...
  426. };
  427. specifications.mapstruct.(['var' num2str(i)]).(CONSTANTS.nameOfSheetUnit) = { ...
  428. '', ...
  429. };
  430. specifications.mapstruct.(['var' num2str(i)]).valueToIgnore = { ...
  431. 'Flag', 'Note', 'FAO Source', 'Source Code', ...
  432. 'Domain', 'Flag Description', 'Domain Code', ...
  433. 'Source', 'Area Code (M49)', ...
  434. };
  435. %%%%%%%%%%%%%%%%%%%%%%%%%%%% default table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  436. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  437. %since we want to build up datatables we need a default table which gets
  438. %parametrised according to the row which we are parsing
  439. %specify default datatable (all necessary fields...)
  440. specifications.patternTable.(CONSTANTS.nameOfSheetCode) = '';
  441. specifications.patternTable.(CONSTANTS.nameOfSheetCategory) = '';
  442. specifications.patternTable.(CONSTANTS.nameOfSheetCategoryName) = '';
  443. specifications.patternTable.(CONSTANTS.nameOfSheetEntity) = '';
  444. specifications.patternTable.(CONSTANTS.nameOfSheetType) = '';
  445. specifications.patternTable.(CONSTANTS.nameOfSheetClass) = 'TOTAL';
  446. specifications.patternTable.(CONSTANTS.nameOfSheetDescr) = '';
  447. specifications.patternTable.(CONSTANTS.nameOfSheetNote) = 'Read in by JG';
  448. specifications.patternTable.(CONSTANTS.nameOfSheetSource) = sourcename;
  449. specifications.patternTable.(CONSTANTS.nameOfSheetFirstdatarow) = 0;
  450. specifications.patternTable.(CONSTANTS.nameOfSheetUnit) = '';
  451. specifications.patternTable.(CONSTANTS.nameOfSheetScenario) = 'HISTORY';
  452. specifications.patternTable.(CONSTANTS.nameOfSheetDatatype) = 'CountryYearMatrix';
  453. specifications.patternTable.(CONSTANTS.nameOfCountryVector) = {};
  454. specifications.patternTable.(CONSTANTS.nameOfDataField) = [];
  455. specifications.patternTable.(CONSTANTS.nameOfYearVector) = [];
  456. specifications.patternTable.(CONSTANTS.nameOfSheetSubsource) = {};
  457. specifications.patternTable.(CONSTANTS.nameOfSheetTablekind) = CONSTANTS.defaultForSheetTablekind;
  458. end %function bp_specifications