fineprint-global / mrio-viewer

A set of tools that allow for interactive visualization of input-output tables.
GNU General Public License v3.0
10 stars 1 forks source link

Change unit of livestock products to head instead of 1000 head #13

Closed Gutschlhofer closed 5 years ago

Gutschlhofer commented 5 years ago
UPDATE "input-output_leontief"
SET amount = amount * 1000
WHERE from_product IN (SELECT id FROM product WHERE product_group = 3);
Gutschlhofer commented 5 years ago

ad "add livestock products that were cut off before but can now be added":

Added for allocation 1 and 2013, crashed because of memory allocation problem on our RStudio -> restarted for 2012:2008, which means that allocation 2 2013 is still missing

Gutschlhofer commented 5 years ago

also now failed after allocation 2, 2011, so allocation 2 2010-2008 are also missing!

Gutschlhofer commented 5 years ago

2010-2008 done. Deleted 2013-livestock, re-ran to add all and to have more precision for the old data that was only multiplied by 1000.

Gutschlhofer commented 5 years ago

This of course also needs to be done for the EXIO-hybrid IO-Leontief.

Gutschlhofer commented 5 years ago

I now deleted 2013 livestock for EXIO with

DELETE FROM "input-output_leontief" WHERE year = 2013 AND from_product BETWEEN 97 AND 110 AND to_region >= 193;

and am now inserting the new numbers for 2013. As for the other years I will probably also do the exact same thing if it does not take too long and then repeat for FABIO IO-L, too. Otherwise I would just go for filtering all values < 0.01 (that would have been omitted before), multiply them by 1000 and then keep the ones > 0.01, what I did for FABIO 2012 and below.

Gutschlhofer commented 5 years ago

Updated 2013 (took approx. 40 minutes * 2 allocations) and I now deleted all EXIO IO-L livestock before 2013 and will add the new livestock data.

DELETE FROM "input-output_leontief" WHERE year < 2013 AND from_product BETWEEN 97 AND 110 AND to_region >= 193;
Gutschlhofer commented 5 years ago

I also need to divide by 1000 in the IO-L for each livestock to_product

Gutschlhofer commented 5 years ago

For data already in the database I do the following:

UPDATE "input-output_leontief"
SET amount = amount / 1000
WHERE to_product IN (SELECT id FROM product WHERE product_group = 3);