Browse Source

commit of WIP plotting routines

  - Also removes .idea project files
  - swaps out filval for only the plotting utilities of filval-python
Caleb Fangmeier 6 years ago
parent
commit
06512fad08
10 changed files with 173 additions and 486 deletions
  1. 2 0
      .gitignore
  2. 3 0
      .gitmodules
  3. 0 11
      .idea/TTTT2.iml
  4. 0 4
      .idea/misc.xml
  5. 0 8
      .idea/modules.xml
  6. 0 7
      .idea/vcs.xml
  7. 0 378
      .idea/workspace.xml
  8. 0 1
      filval
  9. 1 0
      filval-python
  10. 167 77
      yields.py

+ 2 - 0
.gitignore

@@ -1,5 +1,7 @@
 *__pycache__/
 output/
+data/
 env/
+.idea/
 
 *.root

+ 3 - 0
.gitmodules

@@ -1,3 +1,6 @@
 [submodule "filval"]
 	path = filval
 	url = gogs@git.fangmeier.tech:caleb/filval.git
+[submodule "filval-python"]
+	path = filval-python
+	url = gogs@git.fangmeier.tech:caleb/filval-python.git

+ 0 - 11
.idea/TTTT2.iml

@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="PYTHON_MODULE" version="4">
-  <component name="NewModuleRootManager">
-    <content url="file://$MODULE_DIR$" />
-    <orderEntry type="inheritedJdk" />
-    <orderEntry type="sourceFolder" forTests="false" />
-  </component>
-  <component name="TestRunnerService">
-    <option name="PROJECT_TEST_RUNNER" value="Unittests" />
-  </component>
-</module>

+ 0 - 4
.idea/misc.xml

@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (TTTT2)" project-jdk-type="Python SDK" />
-</project>

+ 0 - 8
.idea/modules.xml

@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ProjectModuleManager">
-    <modules>
-      <module fileurl="file://$PROJECT_DIR$/.idea/TTTT2.iml" filepath="$PROJECT_DIR$/.idea/TTTT2.iml" />
-    </modules>
-  </component>
-</project>

+ 0 - 7
.idea/vcs.xml

@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="VcsDirectoryMappings">
-    <mapping directory="$PROJECT_DIR$" vcs="Git" />
-    <mapping directory="$PROJECT_DIR$/filval" vcs="Git" />
-  </component>
-</project>

+ 0 - 378
.idea/workspace.xml

@@ -1,378 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ChangeListManager">
-    <list default="true" id="57bbb064-ceb0-4277-b651-b49e70e3c99a" name="Default" comment="">
-      <change beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
-      <change beforePath="$PROJECT_DIR$/filval" afterPath="$PROJECT_DIR$/filval" />
-      <change beforePath="$PROJECT_DIR$/yields.py" afterPath="$PROJECT_DIR$/yields.py" />
-    </list>
-    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
-    <option name="TRACKING_ENABLED" value="true" />
-    <option name="SHOW_DIALOG" value="false" />
-    <option name="HIGHLIGHT_CONFLICTS" value="true" />
-    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
-    <option name="LAST_RESOLUTION" value="IGNORE" />
-  </component>
-  <component name="FileEditorManager">
-    <leaf>
-      <file leaf-file-name="yields.py" pinned="false" current-in-tab="true">
-        <entry file="file://$PROJECT_DIR$/yields.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="936">
-              <caret line="52" column="18" lean-forward="false" selection-start-line="52" selection-start-column="18" selection-end-line="52" selection-end-column="18" />
-              <folding>
-                <element signature="e#22#40#0" expanded="true" />
-                <marker date="1512080022393" expanded="true" signature="2324:2542" ph="r&quot;&quot;&quot; $\frac{S}{S+B}$''...='k')" />
-                <marker date="1512080022393" expanded="true" signature="2618:2942" ph="@decl_plot&#10;def plot_si...alse)" />
-                <marker date="1512080022393" expanded="true" signature="2945:3681" ph="if __name__ == '__main...ot'))" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file leaf-file-name="histogram_utils.py" pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/filval/python/filval/histogram_utils.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="774">
-              <caret line="78" column="19" lean-forward="false" selection-start-line="78" selection-start-column="19" selection-end-line="78" selection-end-column="19" />
-              <folding>
-                <element signature="e#1125#2185#0" expanded="false" />
-                <element signature="e#2222#2523#0" expanded="false" />
-                <element signature="e#2782#3020#0" expanded="false" />
-                <element signature="e#3059#3164#0" expanded="false" />
-                <element signature="e#3320#3508#0" expanded="false" />
-                <element signature="e#3535#3565#0" expanded="false" />
-                <element signature="e#3594#3783#0" expanded="false" />
-                <element signature="e#4334#4524#0" expanded="false" />
-                <element signature="e#4568#4595#0" expanded="false" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file leaf-file-name="plotter.py" pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/filval/python/filval/plotter.py">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="-1203">
-              <caret line="57" column="8" lean-forward="false" selection-start-line="57" selection-start-column="8" selection-end-line="57" selection-end-column="8" />
-              <folding>
-                <element signature="e#24#59#0" expanded="true" />
-                <element signature="e#3113#4582#0" expanded="false" />
-                <element signature="e#5416#6029#0" expanded="false" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
-    </leaf>
-  </component>
-  <component name="Git.Settings">
-    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
-  </component>
-  <component name="IdeDocumentHistory">
-    <option name="CHANGED_PATHS">
-      <list>
-        <option value="$PROJECT_DIR$/filval/python/requirements.txt" />
-        <option value="$PROJECT_DIR$/filval/python/setup.py" />
-        <option value="$PROJECT_DIR$/filval/python/filval/histogram_utils.py" />
-        <option value="$PROJECT_DIR$/filval/python/filval/plotter.py" />
-        <option value="$PROJECT_DIR$/yields.py" />
-      </list>
-    </option>
-  </component>
-  <component name="ProjectFrameBounds">
-    <option name="y" value="27" />
-    <option name="width" value="1389" />
-    <option name="height" value="2133" />
-  </component>
-  <component name="ProjectView">
-    <navigator currentView="ProjectPane" proportions="" version="1">
-      <flattenPackages />
-      <showMembers />
-      <showModules />
-      <showLibraryContents />
-      <hideEmptyPackages />
-      <abbreviatePackageNames />
-      <autoscrollToSource />
-      <autoscrollFromSource />
-      <sortByType />
-      <manualOrder />
-      <foldersAlwaysOnTop value="true" />
-    </navigator>
-    <panes>
-      <pane id="Scope" />
-      <pane id="Scratches" />
-      <pane id="ProjectPane">
-        <subPane>
-          <expand>
-            <path>
-              <item name="TTTT2" type="b2602c69:ProjectViewProjectNode" />
-              <item name="TTTT2" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="TTTT2" type="b2602c69:ProjectViewProjectNode" />
-              <item name="TTTT2" type="462c0819:PsiDirectoryNode" />
-              <item name="output" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="TTTT2" type="b2602c69:ProjectViewProjectNode" />
-              <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
-            </path>
-            <path>
-              <item name="TTTT2" type="b2602c69:ProjectViewProjectNode" />
-              <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
-              <item name="&lt; Python 3.6 (TTTT2) &gt;" type="70bed36:NamedLibraryElementNode" />
-            </path>
-          </expand>
-          <select />
-        </subPane>
-      </pane>
-    </panes>
-  </component>
-  <component name="PropertiesComponent">
-    <property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
-  </component>
-  <component name="RunDashboard">
-    <option name="ruleStates">
-      <list>
-        <RuleState>
-          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
-        </RuleState>
-        <RuleState>
-          <option name="name" value="StatusDashboardGroupingRule" />
-        </RuleState>
-      </list>
-    </option>
-  </component>
-  <component name="RunManager" selected="Python.yields">
-    <configuration name="plotter" type="PythonConfigurationType" factoryName="Python" temporary="true">
-      <option name="INTERPRETER_OPTIONS" value="" />
-      <option name="PARENT_ENVS" value="true" />
-      <envs>
-        <env name="PYTHONUNBUFFERED" value="1" />
-      </envs>
-      <option name="SDK_HOME" value="" />
-      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/filval/python/filval" />
-      <option name="IS_MODULE_SDK" value="true" />
-      <option name="ADD_CONTENT_ROOTS" value="true" />
-      <option name="ADD_SOURCE_ROOTS" value="true" />
-      <module name="TTTT2" />
-      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/filval/python/filval/plotter.py" />
-      <option name="PARAMETERS" value="" />
-      <option name="SHOW_COMMAND_LINE" value="false" />
-      <option name="EMULATE_TERMINAL" value="false" />
-      <option name="MODULE_MODE" value="false" />
-    </configuration>
-    <configuration name="setup" type="PythonConfigurationType" factoryName="Python" temporary="true">
-      <option name="INTERPRETER_OPTIONS" value="" />
-      <option name="PARENT_ENVS" value="true" />
-      <envs>
-        <env name="PYTHONUNBUFFERED" value="1" />
-      </envs>
-      <option name="SDK_HOME" value="" />
-      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/filval/python" />
-      <option name="IS_MODULE_SDK" value="true" />
-      <option name="ADD_CONTENT_ROOTS" value="true" />
-      <option name="ADD_SOURCE_ROOTS" value="true" />
-      <module name="TTTT2" />
-      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/filval/python/setup.py" />
-      <option name="PARAMETERS" value="install" />
-      <option name="SHOW_COMMAND_LINE" value="false" />
-      <option name="EMULATE_TERMINAL" value="false" />
-      <option name="MODULE_MODE" value="false" />
-    </configuration>
-    <configuration name="yields" type="PythonConfigurationType" factoryName="Python" temporary="true">
-      <option name="INTERPRETER_OPTIONS" value="" />
-      <option name="PARENT_ENVS" value="true" />
-      <envs>
-        <env name="PYTHONUNBUFFERED" value="1" />
-      </envs>
-      <option name="SDK_HOME" value="" />
-      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
-      <option name="IS_MODULE_SDK" value="true" />
-      <option name="ADD_CONTENT_ROOTS" value="true" />
-      <option name="ADD_SOURCE_ROOTS" value="true" />
-      <module name="TTTT2" />
-      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/yields.py" />
-      <option name="PARAMETERS" value="" />
-      <option name="SHOW_COMMAND_LINE" value="false" />
-      <option name="EMULATE_TERMINAL" value="false" />
-      <option name="MODULE_MODE" value="false" />
-    </configuration>
-    <list size="3">
-      <item index="0" class="java.lang.String" itemvalue="Python.setup" />
-      <item index="1" class="java.lang.String" itemvalue="Python.yields" />
-      <item index="2" class="java.lang.String" itemvalue="Python.plotter" />
-    </list>
-    <recent_temporary>
-      <list size="3">
-        <item index="0" class="java.lang.String" itemvalue="Python.yields" />
-        <item index="1" class="java.lang.String" itemvalue="Python.setup" />
-        <item index="2" class="java.lang.String" itemvalue="Python.plotter" />
-      </list>
-    </recent_temporary>
-  </component>
-  <component name="ShelveChangesManager" show_recycled="false">
-    <option name="remove_strategy" value="false" />
-  </component>
-  <component name="SvnConfiguration">
-    <configuration />
-  </component>
-  <component name="TaskManager">
-    <task active="true" id="Default" summary="Default task">
-      <changelist id="57bbb064-ceb0-4277-b651-b49e70e3c99a" name="Default" comment="" />
-      <created>1512071116470</created>
-      <option name="number" value="Default" />
-      <option name="presentableId" value="Default" />
-      <updated>1512071116470</updated>
-    </task>
-    <servers />
-  </component>
-  <component name="ToolWindowManager">
-    <frame x="0" y="27" width="1389" height="2133" extended-state="0" />
-    <layout>
-      <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25197983" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
-      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
-      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
-      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1611468" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
-      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
-      <window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32970837" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
-      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
-      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
-      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
-      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
-      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
-      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
-      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
-      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
-      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
-      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
-      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
-    </layout>
-  </component>
-  <component name="VcsContentAnnotationSettings">
-    <option name="myLimit" value="2678400000" />
-  </component>
-  <component name="XDebuggerManager">
-    <breakpoint-manager />
-    <watches-manager />
-  </component>
-  <component name="editorHistoryManager">
-    <entry file="file://$PROJECT_DIR$/templates/dashboard.htm">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="0">
-          <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/plots.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="0">
-          <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$USER_HOME$/.virtualenvs/TTTT2/lib/python3.6/site-packages/latexipy/_latexipy.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-4097">
-          <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/filval/python/setup.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="216">
-          <caret line="12" column="4" lean-forward="false" selection-start-line="12" selection-start-column="4" selection-end-line="12" selection-end-column="4" />
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/filval/python/requirements.txt">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="36">
-          <caret line="2" column="0" lean-forward="false" selection-start-line="2" selection-start-column="0" selection-end-line="2" selection-end-column="0" />
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/filval/python/filval/result_set.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="0">
-          <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
-          <folding>
-            <element signature="e#0#11#0" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/filval/python/filval/plotter.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-1203">
-          <caret line="57" column="8" lean-forward="false" selection-start-line="57" selection-start-column="8" selection-end-line="57" selection-end-column="8" />
-          <folding>
-            <element signature="e#24#59#0" expanded="true" />
-            <element signature="e#3113#4582#0" expanded="false" />
-            <element signature="e#5416#6029#0" expanded="false" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/filval/python/filval/histogram_utils.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="774">
-          <caret line="78" column="19" lean-forward="false" selection-start-line="78" selection-start-column="19" selection-end-line="78" selection-end-column="19" />
-          <folding>
-            <element signature="e#1125#2185#0" expanded="false" />
-            <element signature="e#2222#2523#0" expanded="false" />
-            <element signature="e#2782#3020#0" expanded="false" />
-            <element signature="e#3059#3164#0" expanded="false" />
-            <element signature="e#3320#3508#0" expanded="false" />
-            <element signature="e#3535#3565#0" expanded="false" />
-            <element signature="e#3594#3783#0" expanded="false" />
-            <element signature="e#4334#4524#0" expanded="false" />
-            <element signature="e#4568#4595#0" expanded="false" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/output/yield.html">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="0">
-          <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
-          <folding />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/yields.py">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="936">
-          <caret line="52" column="18" lean-forward="false" selection-start-line="52" selection-start-column="18" selection-end-line="52" selection-end-column="18" />
-          <folding>
-            <element signature="e#22#40#0" expanded="true" />
-            <marker date="1512080022393" expanded="true" signature="2324:2542" ph="r&quot;&quot;&quot; $\frac{S}{S+B}$''...='k')" />
-            <marker date="1512080022393" expanded="true" signature="2618:2942" ph="@decl_plot&#10;def plot_si...alse)" />
-            <marker date="1512080022393" expanded="true" signature="2945:3681" ph="if __name__ == '__main...ot'))" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
-  </component>
-  <component name="masterDetails">
-    <states>
-      <state key="ScopeChooserConfigurable.UI">
-        <settings>
-          <splitter-proportions>
-            <option name="proportions">
-              <list>
-                <option value="0.2" />
-              </list>
-            </option>
-          </splitter-proportions>
-        </settings>
-      </state>
-    </states>
-  </component>
-</project>

+ 0 - 1
filval

@@ -1 +0,0 @@
-Subproject commit dc3a8bf6f559cb14e9c0643fe79df23436a0320d

+ 1 - 0
filval-python

@@ -0,0 +1 @@
+Subproject commit 933573447dedebfcf1d8b02217b5a9d46a7f2307

+ 167 - 77
yields.py

@@ -4,47 +4,108 @@ import matplotlib.pyplot as plt
 
 from filval.result_set import ResultSet
 from filval.histogram_utils import hist, hist_add, hist_normalize, hist_scale
-from filval.plotter import (decl_plot, render_plots, hist_plot, hist_plot_stack, Plot, generate_dashboard)
+from filval.plotter import (decl_plot, render_plots, hist_plot, hist_plot_stack,
+                            Plot, generate_dashboard, hists_to_table)
 
+an_tttt = ([0.47, 0.33, 0.18, 0.78, 0.49, 0.52, 0.33, 0.49],
+           [0, 0, 0,  0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
+an_ttw = ([2.29663, 0.508494, 0.161166, 1.03811, 0.256401, 0.127582, 0.181522, 0.141659],
+          [0, 0, 0,  0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
+an_ttz = ([0.974751, 0.269195, 1e-06, 0.395831, 0.0264703, 0.06816, 0.8804, 0.274265],
+          [0, 0, 0,  0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
+an_tth = ([1.13826, 0.361824, 0.162123, 0.683917, 0.137608, 0.0632719, 0.554491, 0.197864],
+          [0, 0, 0,  0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
 
 @decl_plot
-def plot_yield_grid(rss):
+def plot_yield_grid(rss, tau_category=-1):
     r"""## Event Yield
 
     The event yield for the eight signal regions defined in AN-17-115. Data is normalized
-    to the Moriond 2018 integrated luminosity ($35.9\textrm{fb}^{-1}$). Code for the histogram generation is
-    here: <https://github.com/cfangmeier/FTAnalysis/blob/master/studies/tau/Yield.C>
+    to the integrated luminosity of $35.9\textrm{fb}^{-1}$.
+
+    Ignoring taus means both that there is no requirement on number of good taus *and*
+    the taus, if present, are not considered for the SS pair.
+
+    If taus are not ignored, any good tau with $p_T$>20Gev is considered in constructing the SS lepton pair. The yields
+    are then further broken down by the number of good taus in the event.
+
+    A "good" tau in the above means any tau candidate passing the `byTightIsolationMVArun2v1DBoldDMwLT` ID w/ pt>20GeV.
+    It is also required to pass tau-lepton cross cleaning where it must not match any electron or muon within
+    $\delta R < 0.4$.
+
+    Truth-matched taus are those that match within $\delta R < 0.3$ with gen-level taus that pass the flag `fromHardProcessDecayed`.
     """
+
+    def get_sr(rs, tm=False):
+        if tm:
+            if tau_category == 0:
+                return hist(rs.SRs_0tmtau)
+            if tau_category == 1:
+                return hist(rs.SRs_1tmtau)
+            elif tau_category == 2:
+                return hist(rs.SRs_2tmtau)
+        else:
+            if tau_category == -1:
+                return hist(rs.ignore_tau_SRs)
+            elif tau_category == 0:
+                return hist(rs.SRs_0tau)
+            elif tau_category == 1:
+                return hist(rs.SRs_1tau)
+            elif tau_category == 2:
+                return hist(rs.SRs_2tau)
+
     _, ((ax_tttt, ax_ttw), (ax_ttz, ax_tth)) = plt.subplots(2, 2)
-    ft, ttw, ttz, tth = map(lambda rs: hist(rs.SRs), rss)
-    # ft, ttw = map(lambda rs: hist(rs.SRs), rss[:2])
+    tttt, ttw, ttz, tth = [get_sr(rs) for rs in rss]
+    tm_tttt, tm_ttw, tm_ttz, tm_tth = [get_sr(rs, True) for rs in rss]
+
     plt.sca(ax_tttt)
-    an = ((0.47, 0.33, 0.18, 0.78, 0.49, 0.52, 0.33, 0.49),
-          (0, 0, 0,  0, 0, 0, 0, 0), [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
-    hist_plot(ft, title='TTTT', stats=False, label='Mock')
-    hist_plot(an, title='TTTT', stats=False, label='AN')
+    hist_plot(tttt, title='TTTT', stats=False, label='Mock', include_errors=True)
+    if tau_category == -1:
+        hist_plot(an_tttt, title='TTTT', stats=False, label='AN')
+    elif tau_category >= 0:
+        hist_plot(tm_tttt, title='TTTT', stats=False, label='Truth-Matched Taus', include_errors=True)
+    plt.ylim((0, None))
 
     plt.sca(ax_ttw)
-    an = ([2.29663, 0.508494, 0.161166, 1.03811, 0.256401, 0.127582, 0.181522, 0.141659],
-          [0, 0, 0,  0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
-    hist_plot(ttw, title='TTW', stats=False, label='Mock')
-    hist_plot(an, title='TTW', stats=False, label='AN')
+    hist_plot(ttw, title='TTW', stats=False, label='Mock', include_errors=True)
+    if tau_category == -1:
+        hist_plot(an_ttw, title='TTW', stats=False, label='AN')
+    elif tau_category >= 0:
+        hist_plot(tm_ttw, title='TTW', stats=False, label='Truth-Matched Taus', include_errors=True)
+    plt.ylim((0, None))
     plt.legend()
 
     plt.sca(ax_ttz)
-    an = ([0.974751, 0.269195, 1e-06, 0.395831, 0.0264703, 0.06816, 0.8804, 0.274265],
-          [0, 0, 0,  0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
-    hist_plot(ttz, title='TTZ', stats=False, label='Mock')
-    hist_plot(an, title='TTZ', stats=False, label='AN')
+    hist_plot(ttz, title='TTZ', stats=False, label='Mock', include_errors=True)
+    if tau_category == -1:
+        hist_plot(an_ttz, title='TTZ', stats=False, label='AN')
+    elif tau_category >= 0:
+        hist_plot(tm_ttz, title='TTZ', stats=False, label='Truth-Matched Taus', include_errors=True)
+    plt.ylim((0, None))
     plt.xlabel('Signal Region')
 
     plt.sca(ax_tth)
-    an = ([1.13826, 0.361824, 0.162123, 0.683917, 0.137608, 0.0632719, 0.554491, 0.197864],
-          [0, 0, 0,  0, 0, 0, 0, 0], [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5])
-    hist_plot(tth, title='TTH', stats=False, label='Mock')
-    hist_plot(an, title='TTH', stats=False, label='AN')
+    hist_plot(tth, title='TTH', stats=False, label='Mock', include_errors=True)
+    if tau_category == -1:
+        hist_plot(an_tth, title='TTH', stats=False, label='AN')
+    elif tau_category >= 0:
+        hist_plot(tm_tth, title='TTH', stats=False, label='Truth-Matched Taus', include_errors=True)
+    plt.ylim((0, None))
     plt.xlabel('Signal Region')
 
+    def to_table(hists):
+        return hists_to_table(hists, row_labels=['TTTT', 'TTW', 'TTZ', 'TTH'],
+                              column_labels=[f'SR{n}' for n in range(1, 9)])
+
+    tables = '<h2>Mock</h2>'
+    tables += to_table([tttt, ttw, ttz, tth])
+    if tau_category == -1:
+        tables += '<h2>AN</h2>'
+        tables += to_table([an_tttt, an_ttw, an_ttz, an_tth])
+    elif tau_category >= 0:
+        tables += '<h2>TM Taus</h2>'
+        tables += to_table([tm_tttt, tm_ttw, tm_ttz, tm_tth])
+    return tables
 
 
 @decl_plot
@@ -89,6 +150,7 @@ def plot_lep_multi(rss, dataset):
     _plot(ax_taus, taus)
     plt.xlabel('\\# Good Taus')
 
+
 @decl_plot
 def plot_sig_strength(rss):
     r""" The signal strength of the TTTT signal defined as
@@ -101,9 +163,11 @@ def plot_sig_strength(rss):
     strength = ft[0] / np.sqrt(ft[0] + bg[0])
     hist_plot((strength, ft[1], ft[2]), stats=False)
 
+
 @decl_plot
-def plot_event_obs(rss, dataset):
-    r"""
+def plot_event_obs(rss, dataset, in_signal_region=True):
+    r"""The distribution of $N_{jet}$, $N_{Bjet}$, MET, and $H_T$ in either all events
+    or only signal region (igoring taus) events.
 
     """
     _, ((ax_njet, ax_nbjet), (ax_ht, ax_met)) = plt.subplots(2, 2)
@@ -116,10 +180,16 @@ def plot_event_obs(rss, dataset):
 
     def _plot(ax, obs):
         plt.sca(ax)
-        h = {'MET': rs.met_in_SR,
-             'HT': rs.ht_in_SR,
-             'NJET': rs.njet_in_SR,
-             'NBJET': rs.nbjet_in_SR}[obs]
+        if in_signal_region:
+            h = {'MET': rs.met_in_SR,
+                 'HT': rs.ht_in_SR,
+                 'NJET': rs.njet_in_SR,
+                 'NBJET': rs.nbjet_in_SR}[obs]
+        else:
+            h = {'MET': rs.met,
+                 'HT': rs.ht,
+                 'NJET': rs.njet,
+                 'NBJET': rs.nbjet}[obs]
         hist_plot(hist(h), stats=False, label=dataset, xlabel=obs)
 
     _plot(ax_njet, 'NJET')
@@ -127,8 +197,9 @@ def plot_event_obs(rss, dataset):
     _plot(ax_ht, 'HT')
     _plot(ax_met, 'MET')
 
+
 @decl_plot
-def plot_event_obs_stack(rss):
+def plot_event_obs_stack(rss, in_signal_region=True):
     r"""
 
     """
@@ -136,10 +207,16 @@ def plot_event_obs_stack(rss):
 
     def _plot(ax, obs):
         plt.sca(ax)
-        attr = {'MET': 'met_in_SR',
-                'HT': 'ht_in_SR',
-                'NJET': 'njet_in_SR',
-                'NBJET': 'nbjet_in_SR'}[obs]
+        if in_signal_region:
+            attr = {'MET': 'met_in_SR',
+                    'HT': 'ht_in_SR',
+                    'NJET': 'njet_in_SR',
+                    'NBJET': 'nbjet_in_SR'}[obs]
+        else:
+            attr = {'MET': 'met',
+                    'HT': 'ht',
+                    'NJET': 'njet',
+                    'NBJET': 'nbjet'}[obs]
         ft, ttw, ttz, tth = map(lambda rs: hist(getattr(rs, attr)), rss)
         hist_plot_stack([ttw, ttz, tth], labels=["TTW", "TTZ", "TTH"])
         hist_plot(hist_scale(ft, 5), label="TTTT (x5)", color='k')
@@ -151,6 +228,7 @@ def plot_event_obs_stack(rss):
     _plot(ax_ht, 'HT')
     _plot(ax_met, 'MET')
 
+
 @decl_plot
 def plot_tau_purity(rss):
     _, ((ax_ft, ax_ttw), (ax_ttz, ax_tth)) = plt.subplots(2, 2)
@@ -173,46 +251,73 @@ def plot_tau_purity(rss):
 
 
 if __name__ == '__main__':
-    # First create a ResultSet object which loads all of the objects from output.root
+    # First create a ResultSet object which loads all of the objects from root file
     # into memory and makes them available as attributes
     rss = (ResultSet("ft", 'data/yield_ft.root'),
            ResultSet("ttw", 'data/yield_ttw.root'),
            ResultSet("ttz", 'data/yield_ttz.root'),
            ResultSet("tth", 'data/yield_tth.root'))
-    rss_notau = (ResultSet("ft_notau", 'data/yield_ft_notau.root'),
-                 ResultSet("ttw_notau", 'data/yield_ttw_notau.root'),
-                 ResultSet("ttz_notau", 'data/yield_ttz_notau.root'),
-                 ResultSet("tth_notau", 'data/yield_tth_notau.root'))
 
     # Next, declare all of the (sub)plots that will be assembled into full
     # figures later
-    yield_tau = (plot_yield_grid, (rss,), {})
-    yield_notau = (plot_yield_grid, (rss_notau,), {})
+    yield_tau_ignore_tau = plot_yield_grid, (rss, -1)
+    yield_tau_0tau = plot_yield_grid, (rss, 0)
+    yield_tau_1tau = plot_yield_grid, (rss, 1)
+    yield_tau_2tau = plot_yield_grid, (rss, 2)
 
-    yield_tau_stack = (plot_yield_stack, (rss,), {})
-    yield_notau_stack = (plot_yield_stack, (rss_notau,), {})
+    ft_event_obs_in_sr = plot_event_obs, (rss, 'TTTT'), {'in_signal_region': True}
+    ttw_event_obs_in_sr = plot_event_obs, (rss, 'TTW'), {'in_signal_region': True}
+    ttz_event_obs_in_sr = plot_event_obs, (rss, 'TTZ'), {'in_signal_region': True}
+    tth_event_obs_in_sr = plot_event_obs, (rss, 'TTH'), {'in_signal_region': True}
 
-    sig_strength_tau = (plot_sig_strength, (rss,), {})
-    sig_strength_notau = (plot_sig_strength, (rss_notau,), {})
+    ft_event_obs = plot_event_obs, (rss, 'TTTT'), {'in_signal_region': False}
+    ttw_event_obs = plot_event_obs, (rss, 'TTW'), {'in_signal_region': False}
+    ttz_event_obs = plot_event_obs, (rss, 'TTZ'), {'in_signal_region': False}
+    tth_event_obs = plot_event_obs, (rss, 'TTH'), {'in_signal_region': False}
 
-    ft_lep_multi = (plot_lep_multi, (rss, 'TTTT'), {})
-    ttw_lep_multi = (plot_lep_multi, (rss, 'TTW'), {})
-    ttz_lep_multi = (plot_lep_multi, (rss, 'TTZ'), {})
-    tth_lep_multi = (plot_lep_multi, (rss, 'TTH'), {})
+    ft_lep_multi = plot_lep_multi, (rss, 'TTTT')
+    ttw_lep_multi = plot_lep_multi, (rss, 'TTW')
+    ttz_lep_multi = plot_lep_multi, (rss, 'TTZ')
+    tth_lep_multi = plot_lep_multi, (rss, 'TTH')
 
-    ft_event_obs = (plot_event_obs, (rss_notau, 'TTTT'), {})
-    ttw_event_obs = (plot_event_obs, (rss_notau, 'TTW'), {})
-    ttz_event_obs = (plot_event_obs, (rss_notau, 'TTZ'), {})
-    tth_event_obs = (plot_event_obs, (rss_notau, 'TTH'), {})
-
-    event_obs_stack = (plot_event_obs_stack, (rss_notau,), {})
-
-    tau_purity = (plot_tau_purity, (rss,), {})
+    # tau_purity = plot_tau_purity, (rss)
 
     # Now assemble the plots into figures.
     plots = [
-        # Plot([[yield_tau]],
-        #      'Yield With Tau'),
+        Plot([[yield_tau_ignore_tau]],
+             'Yield Ignoring Taus'),
+        Plot([[yield_tau_0tau]],
+             'Yield For events with 0 Tau'),
+        Plot([[yield_tau_1tau]],
+             'Yield For events with 1 Tau'),
+        Plot([[yield_tau_2tau]],
+             'Yield For events with 2 or more Tau'),
+
+        Plot([[ft_lep_multi]],
+             'Lepton Multiplicity - TTTT'),
+        Plot([[ttw_lep_multi]],
+             'Lepton Multiplicity - TTW'),
+        Plot([[ttz_lep_multi]],
+             'Lepton Multiplicity - TTZ'),
+        Plot([[tth_lep_multi]],
+             'Lepton Multiplicity - TTH'),
+        Plot([[ft_event_obs_in_sr]],
+             'TTTT - Event Observables (In SR)'),
+        Plot([[ttw_event_obs_in_sr]],
+             'TTW - Event Observables (In SR)'),
+        Plot([[ttz_event_obs_in_sr]],
+             'TTZ - Event Observables (In SR)'),
+        Plot([[tth_event_obs_in_sr]],
+             'TTH - Event Observables (In SR)'),
+        Plot([[ft_event_obs]],
+             'TTTT - Event Observables (All Events)'),
+        Plot([[ttw_event_obs]],
+             'TTW - Event Observables (All Events)'),
+        Plot([[ttz_event_obs]],
+             'TTZ - Event Observables (All Events)'),
+        Plot([[tth_event_obs]],
+             'TTH - Event Observables (All Events)'),
+
         # Plot([[yield_notau]],
         #      'Yield Without Tau'),
         # Plot([[yield_tau_stack]],
@@ -225,29 +330,14 @@ if __name__ == '__main__':
         # Plot([[sig_strength_tau],
         #       [sig_strength_notau]],
         #      'Signal Strength'),
-        # Plot([[ft_lep_multi]],
-        #      'Lepton Multiplicity - TTTT'),
-        # Plot([[ttw_lep_multi]],
-        #      'Lepton Multiplicity - TTW'),
-        # Plot([[ttz_lep_multi]],
-        #      'Lepton Multiplicity - TTZ'),
-        # Plot([[tth_lep_multi]],
-        #      'Lepton Multiplicity - TTH'),
-        # Plot([[ft_event_obs]],
-        #      'TTTT - Event Observables'),
-        # Plot([[ttw_event_obs]],
-        #      'TTW - Event Observables'),
-        # Plot([[ttz_event_obs]],
-        #      'TTZ - Event Observables'),
-        # Plot([[tth_event_obs]],
-        #      'TTH - Event Observables'),
         # Plot([[event_obs_stack]],
         #      'Event Observables'),
-        Plot([[tau_purity]],
-             'Tau Purity'),
+        # Plot([[tau_purity]],
+        #      'Tau Purity'),
     ]
 
     # Finally, render and save the plots and generate the html+bootstrap
     # dashboard to view them
     render_plots(plots, to_disk=False)
-    generate_dashboard(plots, 'TTTT Yields', output='yield2.html', source_file=__file__)
+    generate_dashboard(plots, 'TTTT Yields', output='yield_breakout_4.html', source_file=__file__,
+                       ana_source="https://github.com/cfangmeier/FTAnalysis/commit/46fc1afab42f6b04c9e21ba519e6a30524983550")