bw2ui.bin.bw2_browser ===================== .. py:module:: bw2ui.bin.bw2_browser .. autoapi-nested-parse:: Brightway2 database and activity browser. Developed by Bernhard Steubing and Chris Mutel, 2013 Usage: bw2-browser bw2-browser bw2-browser bw2-browser Options: -h --help Show this screen. --version Show version. Attributes ---------- .. autoapisummary:: bw2ui.bin.bw2_browser.FTS5_ENABLED_BD_VERSION bw2ui.bin.bw2_browser.GRUMPY bw2ui.bin.bw2_browser.HELP_TEXT bw2ui.bin.bw2_browser.QUIET Classes ------- .. autoapisummary:: bw2ui.bin.bw2_browser.ActivityBrowser Functions --------- .. autoapisummary:: bw2ui.bin.bw2_browser.bw2_compat_annotated_top_emissions bw2ui.bin.bw2_browser.get_autosave_text bw2ui.bin.bw2_browser.has_namespaced_methods bw2ui.bin.bw2_browser.is_legacy_bc bw2ui.bin.bw2_browser.is_legacy_bd bw2ui.bin.bw2_browser.is_legacy_bwa bw2ui.bin.bw2_browser.main bw2ui.bin.bw2_browser.search_bw2 Module Contents --------------- .. py:class:: ActivityBrowser(completekey='tab', stdin=None, stdout=None) Bases: :py:obj:`cmd.Cmd` A command line based Activity Browser for brightway2. Instantiate a line-oriented interpreter framework. The optional argument 'completekey' is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. The optional arguments stdin and stdout specify alternate input and output file objects; if not specified, sys.stdin and sys.stdout are used. .. py:method:: _init(project=None, database=None, activity=None, method=None) Provide initial data. Can't override __init__, because this is an old style class i.e. there is no support for ``super``. .. py:method:: _simple_ascii_chart(all_scores=None, all_labels=None) Fallback simple ASCII bar chart without external dependencies. .. py:method:: acquire_params(full_cols, the_group) .. py:method:: build_method_key_list() .. py:method:: choose_activity(key, restored=False) .. py:method:: choose_category(category) .. py:method:: choose_database(database) .. py:method:: choose_group(group_id) .. py:method:: choose_method(method) .. py:method:: choose_method_namespace(method_namespace) .. py:method:: choose_option(opt) Go to option ``opt`` .. py:method:: choose_project(project) .. py:method:: choose_subcategory(subcategory) .. py:method:: default(line) No ``do_foo`` command - try to select from options. .. py:method:: dehydrate_params(params, fields) Remove keys of each param dictionnary, and only keep fields. .. py:method:: do_G(arg) Do an LCIA of the selected activity + method[s] .. py:method:: do_GC(arg) Do an LCIA of all activities in the temporary list with a fully specified method. .. py:method:: do_GCH(arg) Display ASCII bar charts for GC command results. .. py:method:: do_a(arg) Go to activity id ``arg`` .. py:method:: do_aa(arg) List all activities in the current database. .. py:method:: do_add(arg) Add the currently selected activity to the temporary activities list. .. py:method:: do_ap(arg) If an activity is selected, show its parameters. .. py:method:: do_autosave(arg) Toggle autosave behaviour. If autosave is on, the current database or activity is written to config.p each time it changes. .. py:method:: do_b(arg) List biosphere flows .. py:method:: do_backup(target_dir=None) Backup the current project. Optionally specify a target directory. .. py:method:: do_ca(arg) Print the recursive calculation of an LCA, accepting cutoff as arg. .. py:method:: do_cfs(arg) Print cfs of biosphere flows or method. .. py:method:: do_clear(arg) Clear the temporary activities list. .. py:method:: do_cp(arg) Clear preferences. Only for development. .. py:method:: do_d(arg) Load downstream activities .. py:method:: do_db(arg) Switch to a different database .. py:method:: do_dp(arg) List all database parameters. .. py:method:: do_fp(arg) Find a specific parameter by name. .. py:method:: do_h(arg) Pretty print history of databases & activities .. py:method:: do_help(args) List available commands with "help" or detailed help with "help cmd". .. py:method:: do_i(arg) Info on current activity. TODO: Colors could be improved. .. py:method:: do_ii(arg) Extended Info on current activity. TODO: Colors could be improved. .. py:method:: do_l(arg) List current options .. py:method:: do_ldb(arg) List available databases .. py:method:: do_lm(arg) List methods .. py:method:: do_lpam(arg) List all (Project, Database, Activity) parameters. .. py:method:: do_lpamg(arg) List parameter groups. .. py:method:: do_lpj(arg) List available projects .. py:method:: do_lprods(arg) List product or chimaera activities in the current database. .. py:method:: do_lt(arg) List all activities in the temporary activities list. .. py:method:: do_mi(arg) Show method information .. py:method:: do_n(arg) Go to next page in paged options .. py:method:: do_p(arg) Go to previous page in paged options .. py:method:: do_pe(arg) show production exchanges if they exist .. py:method:: do_pei(arg) show production exchanges if they exist .. py:method:: do_pp(arg) List all project parameters. .. py:method:: do_q(args) Exit the activity browser. .. py:method:: do_quit(args) Exit the activity browser. .. py:method:: do_r(arg) Choose an activity at random .. py:method:: do_restore(arg) Restore a project from a backup archive. .. py:method:: do_s(arg) Search activity names. .. py:method:: do_sc(arg) Print the supply chain of an activity, accepting cutoff as arg. .. py:method:: do_sp(arg) Search for a parameter by name, accepting wildcards in arg. .. py:method:: do_ta(arg) Display top activities if an activity + method are selected. .. py:method:: do_te(arg) Display top emissions if an activity + method are selected. .. py:method:: do_tsv(arg) write the latest table created as tsv file. .. py:method:: do_u(arg) List upstream processes .. py:method:: do_un(arg) Display uncertainty infor of upstream activities if available .. py:method:: do_up(arg) List upstream processes .. py:method:: do_uu(arg) List upstream processes extra info (formulas) .. py:method:: do_wh(arg) .. py:method:: emptyline() No command entered! .. py:method:: format_activity(key, max_length=10000) .. py:method:: format_defaults() .. py:method:: format_exchanges_as_options(es, kind, unit_override=None, show_formulas=False, show_pedigree=False, show_uncertainty=False) .. py:method:: format_history(command) .. py:method:: get_downstream_exchanges(activity) Get the exchanges that consume this activity's product .. py:method:: list_databases() .. py:method:: list_methods() .. py:method:: list_projects() .. py:method:: load_activity(activity) Load given or default activity on start .. py:method:: load_database(database) Load database, trying first .. py:method:: load_method(method) .. py:method:: load_project(project) .. py:method:: print_cfs(current_methods, activity=None) Print cfs for a list of methods, and optionally only for an activity .. py:method:: print_current_options(label=None) .. py:method:: reformat_history(json_data) Convert lists to tuples (from JSON serialization) .. py:method:: set_current_options(options) .. py:method:: unknown_activity() .. py:method:: update_prompt() update prompt and upstream/downstream activity lists .. py:function:: bw2_compat_annotated_top_emissions(lca, names=True, **kwargs) Get list of most damaging biosphere flows in an LCA, sorted by ``abs(direct impact)``. # noqa: E501 Returns a list of tuples: ``(lca score, inventory amount, activity)``. If ``names`` is False, they returns the process key as the last element. # noqa: E501 .. py:function:: get_autosave_text(autosave) .. py:function:: has_namespaced_methods() .. py:function:: is_legacy_bc() .. py:function:: is_legacy_bd() .. py:function:: is_legacy_bwa() .. py:function:: main() .. py:function:: search_bw2(search_criterion, criterion_value, database, needle, search_limit) Search and then filter by criteria. .. py:data:: FTS5_ENABLED_BD_VERSION :value: '4.0.dev47' .. py:data:: GRUMPY .. py:data:: HELP_TEXT :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """ This is a simple way to browse databases and activities in Brightway2. The following commands are available: Basic commands: ?: Print this help screen. quit, q: Exit the activity browser. number: Go to option number when a list of options is present. l: List current options. n: Go to next page in paged options. p: Go to previous page in paged options. p number: Go to page number in paged options. h: List history of databases and activities viewed. wh: Write history to a text file. autosave: Toggle autosave behaviour on and off. Working with projects: lpj: List available projects. backup [directory]: Backup the current project. Optionally specify a target directory. If no directory is specified, the backup will be created in the projects directory with a timestamp. restore [options]: Restore a project from an archive. Supported options: --project NAME, --overwrite. Working with databases: ldb: List available databases. db name: Go to database name. No quotes needed. s [string]: Search activity names in current database with string. Without string the search provides no results. s -loc {LOCATION} [string]: Search activity names in current database with string and location LOCATION. s -cat {CAT::SUBCAT::SUBSUBCAT} [string]: Search activity names in current database with string and category CAT, SUBCAT, SUBCAT [useful for biosphere]. s -rp {REFERENCE PRODUCT} [string]: Search activities in current database that have reference product and optionnaly match string in search. Working with activities: a id: Go to activity id in current database. Complex ids in quotes. aa: List all activities in current database. aa name sorts the activities by name. lprods: List product activities only (product and process_with_reference_product). i: Info on current activity. ii: Extended Info on current activity. r: Choose a random activity from current database. u: List upstream activities (inputs for the current activity). up: List upstream activities with pedigree info if avail (inputs for the current activity). uu: List upstream activities with formula info if avail. un: display uncertainty information of upstream activitities if avail. d: List downstream activities (activities which consume current activity). b: List biosphere flows for the current activity. pe: List production exchanges for current activity. pei: show the information of the production exchange of the current activity. cfs: Show characterization factors for current activity and current method. G: if a method and activity are selected, do an lcia of the activity. ta: if an lcia of the activity has been done, list top activities. te: if an lcia of the activity has been done, list top emissions. ca: do a contribution analysis of an activity with a method. sc: print recursive supply chain of an activity. Working with methods: lm: List methods. mi: Show method metadata. (must select method/category/subcategory first) Working with parameters: lpam: List all parameters (Project, Database and Activity) showing only basic columns (data). lpam [-f]: List all parameters showing all columns (data) of each parameter. lpam [-f] -g {YY}: List parameters for a specific group. Use db or specific data. add as first option -f to show all columns. lpamg: show parameter groups ap [-f]: If an activity is selected, show activity parameters dp [-f]: if a database is selected show database parameters pp [-f]: If a project is selected show project parameters fp : Find parameters (Project, Database or Activity) by name sp : search a parameter (accepts wildcards) Misc: tsv: [filename] export latest table to tsv file (e.g.: results or cfs) GC: Start group contribution mode for comparing multiple activities. add: Add current activity to the list for group contribution/compare analysis. list: List all activities added for group contribution/compare analysis. clear: Clear (empty) the list of added activities for group contribution/compare. GCH: Show the results table from the last group contribution/compare analysis. """ .. raw:: html
.. py:data:: QUIET