Skip to content

Docstrings

Ben Young edited this page Sep 22, 2021 · 2 revisions

Functions available in the lciafmt public API

clear_cache()
    Delete all stored methods in local temporary cache.

generate_endpoints(file: str, name=None, matching_fields=None) -> pandas.core.frame.DataFrame
    Generate an endpoint method for a supplied file based on specs.
    
    :param file: name of file in data folder, without extension, containing
        endpoint data based on the format specs for endpoint files
    :param name: str, optional str for naming the generated method
    :param matching_fields: list of fields on which to apply unique endpoint
        conversions, if None
    :return: DataFrame of endpoint method

get_mapped_method(method_id, indicators=None, methods=None) -> pandas.core.frame.DataFrame
    Return a mapped method stored as parquet.
    
    If a mapped method does not exist locally, it is generated.
    :param method_id: class Method or str, based on id field of
        supported_methods
    :param indicators: list, if not None, return only those indicators passed
    :param methods: list, if not None, return only the version of the methods
        passed. Applies only to methods with multiple versions.
    :return: DataFrame of mapped method

get_method(method_id, add_factors_for_missing_contexts=True, endpoint=True, summary=False, file=None, subset=None, url=None) -> pandas.core.frame.DataFrame
    Generate the method from source in standard format.
    
    The IDs of supported methods can be obtained using `supported_methods` or
    directly use the constants defined in the Method enumeration type.
    :param method_id: class Method or str, based on id field of
        supported_methods
    :param add_factors_for_missing_contexts: bool, if True applies
        lciafmt.util.aggregate_factors_for_primary_contexts to generate average
        factors for unspecified contexts
    :param endpoint: bool, pass-through for RECIPE_2016, if True generates
        endpoint indicators from midpoints
    :param summary: bool, pass-through for RECIPE_2016, if True aggregates
        endpoint methods into summary indicators
    :param subset: pass-through for FEDEFL_INV, a list of dictionary keys from
        available inventory methods in fedelemflowlist, if none provided all
        available methods will be generated
    :param file: str, alternate filepath for method, defaults to file stored
        in cache
    :param url: str, alternate url for method, defaults to url in method config
    :return: DataFrame of method in standard format

map_flows(df: pandas.core.frame.DataFrame, system=None, mapping=None, preserve_unmapped=False, case_insensitive=False) -> pandas.core.frame.DataFrame
    Map the flows in a method using a mapping from fedelemflowlist.
    
    :param system: str, the named mapping file from fedelemflowlist
    :param mapping: df, alternate mapping that meets FEDEFL mapping file
        specifications
    :param preserve_unmapped: bool, if True unmapped flows remain in the method
    :param case_insensitive, bool, if True case is ignored for source flows
    :return: DataFrame of method with mapped flows.

supported_indicators(method_id) -> list
    Return a list of indicators for the identified method_id.

supported_mapping_systems() -> list
    Return supported mapping systems.

supported_methods() -> list
    Return a list of dictionaries of supported method meta data.

to_jsonld(df: pandas.core.frame.DataFrame, zip_file: str, write_flows=False)
    Generate a JSONLD file of the methods passed as DataFrame.