Skip to content

Write models to JSON#12

Closed
WesIngwersen wants to merge 7 commits intodevelopfrom
to_json
Closed

Write models to JSON#12
WesIngwersen wants to merge 7 commits intodevelopfrom
to_json

Conversation

@WesIngwersen
Copy link

No description provided.

@WesIngwersen WesIngwersen requested a review from bl-young October 27, 2025 18:59
@WesIngwersen WesIngwersen self-assigned this Oct 27, 2025
@WesIngwersen
Copy link
Author

A problem with the JSON as well as the API writing is that we have some matrices where we don't write out a proper index.

As background, all matrices in the JSON and binary formats written out do not have row and column ids. Eg. here is what the first row of U looks like for USEEIOv2.6.0-phoebe-23:

[
  [8332000000, 455000000, 40000000, 0, 0, 3000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 827000000, 631000000, 16695000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 251000000, 0, 10000000, 9000000, 9000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3000000, 0, 0, 0, 1087000000, 0, 0, 21000000, 0, 0, 2000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -250000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1330000000, 12088000000, -963000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

for reference this is what the U from the Excel looks like for the first 6 columns of that row

  1111A0/US 1111B0/US 111200/US 111300/US 111400/US 111900/US
1111A0/US 8.33E+09 4.55E+08 40000000 0 0 3000000

The sectors.json metadata file is intended to provided the indices for matrices/vectors. Here is what the first 6 items look like

[
  {
    "Index": 0,
    "ID": "1111A0/US",
    "Name": "Fresh soybeans, canola, flaxseeds, and other oilseeds",
    "Code": "1111A0",
    "Location": "US",
    "Category": "11: Agriculture, Forestry, Fishing and Hunting/1111: Oilseed and Grain Farming",
    "Unit": "USD"
  },
  {
    "Index": 1,
    "ID": "1111B0/US",
    "Name": "Fresh wheat, corn, rice, and other grains",
    "Code": "1111B0",
    "Location": "US",
    "Category": "11: Agriculture, Forestry, Fishing and Hunting/1111: Oilseed and Grain Farming",
    "Unit": "USD"
  },
  {
    "Index": 2,
    "ID": "111200/US",
    "Name": "Fresh vegetables, melons, and potatoes",
    "Code": "111200",
    "Location": "US",
    "Category": "11: Agriculture, Forestry, Fishing and Hunting/1112: Vegetable and Melon Farming",
    "Unit": "USD"
  },
  {
    "Index": 3,
    "ID": "111300/US",
    "Name": "Fresh fruits and tree nuts",
    "Code": "111300",
    "Location": "US",
    "Category": "11: Agriculture, Forestry, Fishing and Hunting/1113: Fruit and Tree Nut Farming",
    "Unit": "USD"
  },
  {
    "Index": 4,
    "ID": "111400/US",
    "Name": "Greenhouse crops, mushrooms, nurseries, and flowers",
    "Code": "111400",
    "Location": "US",
    "Category": "11: Agriculture, Forestry, Fishing and Hunting/1114: Greenhouse, Nursery, and Floriculture Production",
    "Unit": "USD"
  },
  {
    "Index": 5,
    "ID": "111900/US",
    "Name": "Tobacco, cotton, sugarcane, peanuts, sugar beets, herbs and spices, and other crops",
    "Code": "111900",
    "Location": "US",
    "Category": "11: Agriculture, Forestry, Fishing and Hunting/1119: Other Crop Farming",
    "Unit": "USD"
  },

The problem is that this was designed when we wrote out only matrices where the sectors were commodities, like A, L, M, etc. While called 'sectors' , it is only for commodities.
The columns of U are the industries plus the final demand components
The rows of U are the commodities plus the value added components.
The index of X are the industries.

So we're exporting matrices and vectors without provided full index metadata.

@WesIngwersen
Copy link
Author

Closing due to lack of full support for exporting all needed objects to JSON and lack of clear need

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants