<jupyter_start><jupyter_text>Get started with Cymetric to process Cyclus output files you'll need to install [Cymetric](https://github.com/cyclus/cymetric) and [pandas](https://pandas.pydata.org/) before being able to run this jupyter notebook yourself. Oh, and [Jupyter](https://jupyter.org/), if this is your first experience with it as an interactive computing tool.First, let's import these packages.<jupyter_code>import pandas as pd 
import cymetric as cym<jupyter_output><empty_output><jupyter_text>Next, we'll designate one of our minimal output files (which are all named according to their corresponding input file) to process. Let's try the most complicated one, (which is still pretty simple) `source_3_lifetime_sink_1.sqlite` to open as our database<jupyter_code>database = cym.dbopen('minimal-input/source_3_lifetime_sink_1.sqlite')<jupyter_output><empty_output><jupyter_text>Read the database into an `Evaluator` object to be more computationally efficient. We'll call the evaluator to evaluate any metrics or pull any data from there.<jupyter_code>evaler = cym.Evaluator(db=database)<jupyter_output><empty_output><jupyter_text>Pull data into DataFramesI often use Cymetric to pull the databases I am most interested in so I can do my own work to them as pandas DataFrames. Let's grab the agents (the facilities acting in the simulation) first<jupyter_code>agents = evaler.eval('Agents')
agents.head(10)<jupyter_output><empty_output><jupyter_text>Now, we probably care about more than the agents and their lifetimes, so lets pull their transactions. Here instead of just pulling the database transactions (`transactions = evaler.eval('Transactions')`), which doesn't include all the information we may want, we're going to rely on a premade metric that also gives us information on the quantity of material moved in the transaction (information technically housed in the `Resources` database/root metric)<jupyter_code>transactions = evaler.eval('TransactionQuantity')
transactions.head(10)<jupyter_output><empty_output><jupyter_text>Some basic pandas manipulationLet's say we want to get some information about one of our sources. We know it's from the prototype called source, and for some reason we know it's the last one deployed. So lets pull all the Source prototypes<jupyter_code>agents.loc[agents["Prototype"] == "Source"]<jupyter_output><empty_output><jupyter_text>Ok, it's the last one, so its AgentId = 12. The AgentId is important, because there are three agents that have the same exact parameters (they are copies of the prototype Source, but each acts independently). Let's look at the transactions for Source-12.Transactions are categorized by their sender and their receiver. Source-12 is only a sender, so lets look for transactions where it sent material.<jupyter_code>transactions.loc[transactions["SenderId"] == 12]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07398402222994095, 'fraction_numerical': 0.0055574852379298365, 'mean_word_length': 6.51958224543081, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '257482', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 830, 'n_tokens_neox': 783, 'n_words': 329, 'path': 'cymetric_basics.ipynb', 'repo_name': 'nuclearkatie/cyclus-explicit-inventory-examples', 'size': '2879'}