Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor suggestions in docstr #53

Merged
merged 4 commits into from Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions pymrio/core/mriosystem.py
Expand Up @@ -1388,7 +1388,7 @@ def file_name_nr(a, c):
plt.ion()

def get_rows(self):
""" Returns the name of the rows of the extension"""
""" Returns the name of the rows of the extension """
possible_dataframes = [
"F",
"F_Y",
Expand Down Expand Up @@ -1518,9 +1518,9 @@ class IOSystem(CoreSystem):
final demand with MultiIndex with index.names = (['region', 'sector'])
and column.names = (['region', 'category'])
A : pandas.DataFrame
coefficient input output table, MultiTndex as Z
coefficient input output table, MultiIndex as Z
L : pandas.DataFrame
Leontief, MultiTndex as Z
Leontief (= inv(I-A)), MultiIndex as Z
unit : pandas.DataFrame
Unit for each row of Z
system : string
Expand Down Expand Up @@ -1642,7 +1642,13 @@ def calc_system(self):
"""
Calculates the missing part of the core IOSystem

The method checks Z, x, A, L and calculates all which are None
The method checks Z, A, x, L and calculates all which are None

The possible cases are:
Case Provided Calculated
1) Z A, x, L
2) A, x Z, L
3) A, Y L, x, Z
"""

# Possible cases:
Expand Down
26 changes: 26 additions & 0 deletions pymrio/tools/iomath.py
Expand Up @@ -19,6 +19,8 @@
def calc_x(Z, Y):
"""Calculate the industry output x from the Z and Y matrix

industry output (x) = flows (sum_columns(Z)) + final demand (sum_columns(Y))

Parameters
----------
Z : pandas.DataFrame or numpy.array
Expand Down Expand Up @@ -46,6 +48,10 @@ def calc_x(Z, Y):
def calc_x_from_L(L, y):
"""Calculate the industry output x from L and a y vector

x = Ly

The industry output x is computed from a demand vector y

Parameters
----------
L : pandas.DataFrame or numpy.array
Expand All @@ -71,6 +77,11 @@ def calc_x_from_L(L, y):
def calc_Z(A, x):
"""calculate the Z matrix (flows) from A and x

A = Z / x[None, :] => Z = A * x[None, :]

By definition, the coefficient matrix A is basically the normalized flows
So Z is just derived from A by un-normalizing using the industrial output x

Parameters
----------
A : pandas.DataFrame or numpy.array
Expand Down Expand Up @@ -101,6 +112,8 @@ def calc_Z(A, x):
def calc_A(Z, x):
"""Calculate the A matrix (coefficients) from Z and x

A is a normalized version of the industrial flows Z

Parameters
----------
Z : pandas.DataFrame or numpy.array
Expand Down Expand Up @@ -140,6 +153,19 @@ def calc_A(Z, x):
def calc_L(A):
"""Calculate the Leontief L from A

L = inverse matrix of (I - A)

Where I is an identity matrix of same shape as A

Comes from:
x = Ax + y => (I-A)x = y
Where:
A: coefficient input () - output () table
x: output vector
y: final demand vector

Hence, L allows to derive a required output vector x for a given demand y

Parameters
----------
A : pandas.DataFrame or numpy.array
Expand Down