ectools/fc.py
def logPRODY(RCA, gdppc):
    """Calculates logPRODY from an RCA matrix and a GDPpc vector, i.e. log gdppc per-product average on countries with weights equal to the RCA.

    Arguments:
        RCA: np.ndarray matrix of floats, of order 2. RCA is intended to be of shape [n_countries,n_products].
        gdppc: np.ndarray of floats, of order 2. Intended to be of shape [n_countries].

    Returns:
        logPRODY: np.ndarray floats, of shape [n_products], containing the results of the calculation.
    """
    RCA = np.array(RCA)
    gdppc = np.array(gdppc)
    # some countries have no gdppc data
    include = np.isfinite(gdppc)
    # initialize vector of zeros
    logPRODY = np.zeros(len(RCA[0, :]))
    # norm = will normalize RCAs by product
    # nb excluding countries with no gdppc data!
    # note the use of nansum, since some values might be nan in RCA matrix too!
    norm = np.nansum(RCA[include], axis=0)
    # calculate, excluding countries with no gdppc data
    for i in range(len(logPRODY)):
        logPRODY[i] = np.dot(RCA[include, i], np.log10(gdppc[include])) / norm[i]
    return logPRODY
Calculates logPRODY from an RCA matrix and a GDPpc vector, i.e. log gdppc per-product average on countries with weights equal to the RCA.

    Arguments:
        RCA: np.ndarray matrix of floats, of order 2. RCA is intended to be of shape [n_countries,n_products].
        gdppc: np.ndarray of floats, of order 2. Intended to be of shape [n_countries].

    Returns:
        logPRODY: np.ndarray floats, of shape [n_products], containing the results of the calculation.
    
Calculates logPRODY from an RCA matrix and a GDPpc vector, i.e. log gdppc per-product average on countries with weights equal to the RCA.
Calculates logPRODY from an RCA matrix and a GDPpc vector i . e . log gdppc per - product average on countries with weights equal to the RCA .
def logPRODY(RCA, gdppc):
    RCA = np.array(RCA)
    gdppc = np.array(gdppc)
    include = np.isfinite(gdppc)
    logPRODY = np.zeros(len(RCA[0, :]))
    norm = np.nansum(RCA[include], axis=0)
    for i in range(len(logPRODY)):
        logPRODY[i] = np.dot(RCA[include, i], np.log10(gdppc[include])) / norm[i]
    return logPRODY
def logPRODY ( RCA , gdppc ) : RCA = np . array ( RCA ) gdppc = np . array ( gdppc ) include = np . isfinite ( gdppc ) logPRODY = np . zeros ( len ( RCA [ 0 , : ] ) ) norm = np . nansum ( RCA [ include ] , axis = 0 ) for i in range ( len ( logPRODY ) ) : logPRODY [ i ] = np . dot ( RCA [ include , i ] , np . log10 ( gdppc [ include ] ) ) / norm [ i ] return logPRODY
Calculates logPRODY from an RCA matrix and a GDPpc vector, i.e.
Calculates logPRODY from an RCA matrix and a GDPpc vector i . e .
"""Calculates logPRODY from an RCA matrix and a GDPpc vector, i.e. log gdppc per-product average on countries with weights equal to the RCA.

    Arguments:
        RCA: np.ndarray matrix of floats, of order 2. RCA is intended to be of shape [n_countries,n_products].
        gdppc: np.ndarray of floats, of order 2. Intended to be of shape [n_countries].

    Returns:
        logPRODY: np.ndarray floats, of shape [n_products], containing the results of the calculation.
    """ # some countries have no gdppc data # initialize vector of zeros # norm = will normalize RCAs by product # nb excluding countries with no gdppc data! # note the use of nansum, since some values might be nan in RCA matrix too! # calculate, excluding countries with no gdppc data
np.ndarray floats, of shape [n_products], containing the results of the calculation.
np . ndarray floats of shape [ n_products ] containing the results of the calculation .
logPRODY
RCA
np.ndarray matrix of floats, of order 2. RCA is intended to be of shape [n_countries,n_products].
np . ndarray matrix of floats of order 2 . RCA is intended to be of shape [ n_countries n_products ] .
gdppc
np.ndarray of floats, of order 2. Intended to be of shape [n_countries].
np . ndarray of floats of order 2 . Intended to be of shape [ n_countries ] .