openmapp-analyses 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. openmapp_analyses-1.0.0/PKG-INFO +144 -0
  2. openmapp_analyses-1.0.0/README.md +127 -0
  3. openmapp_analyses-1.0.0/pyproject.toml +34 -0
  4. openmapp_analyses-1.0.0/setup.cfg +4 -0
  5. openmapp_analyses-1.0.0/src/openmapp_analyses/__init__.py +15 -0
  6. openmapp_analyses-1.0.0/src/openmapp_analyses/__main__.py +6 -0
  7. openmapp_analyses-1.0.0/src/openmapp_analyses/arxiv.py +81 -0
  8. openmapp_analyses-1.0.0/src/openmapp_analyses/cli.py +422 -0
  9. openmapp_analyses-1.0.0/src/openmapp_analyses/combine.py +256 -0
  10. openmapp_analyses-1.0.0/src/openmapp_analyses/hepdata_models.py +76 -0
  11. openmapp_analyses-1.0.0/src/openmapp_analyses/hepdata_sources.py +162 -0
  12. openmapp_analyses-1.0.0/src/openmapp_analyses/inspire.py +174 -0
  13. openmapp_analyses-1.0.0/src/openmapp_analyses/schema.json +141 -0
  14. openmapp_analyses-1.0.0/src/openmapp_analyses/search.py +128 -0
  15. openmapp_analyses-1.0.0/src/openmapp_analyses/sources.json +36 -0
  16. openmapp_analyses-1.0.0/src/openmapp_analyses/store.py +59 -0
  17. openmapp_analyses-1.0.0/src/openmapp_analyses.egg-info/PKG-INFO +144 -0
  18. openmapp_analyses-1.0.0/src/openmapp_analyses.egg-info/SOURCES.txt +24 -0
  19. openmapp_analyses-1.0.0/src/openmapp_analyses.egg-info/dependency_links.txt +1 -0
  20. openmapp_analyses-1.0.0/src/openmapp_analyses.egg-info/entry_points.txt +2 -0
  21. openmapp_analyses-1.0.0/src/openmapp_analyses.egg-info/requires.txt +4 -0
  22. openmapp_analyses-1.0.0/src/openmapp_analyses.egg-info/top_level.txt +1 -0
  23. openmapp_analyses-1.0.0/tests/test_hepdata_models.py +59 -0
  24. openmapp_analyses-1.0.0/tests/test_hepdata_sources.py +164 -0
  25. openmapp_analyses-1.0.0/tests/test_inspire.py +183 -0
  26. openmapp_analyses-1.0.0/tests/test_openmapp_analyses.py +131 -0
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: openmapp-analyses
3
+ Version: 1.0.0
4
+ Summary: Which reinterpretation and analysis-preservation tools implement which experimental analyses, and which analyses have a published statistical model; search them offline
5
+ Author: Arpita Mondal
6
+ Project-URL: Web page, https://openmapp.gitlab.io/analysis-summary/
7
+ Project-URL: OpenMAPP, https://openmapp.gitlab.io
8
+ Keywords: HEP,LHC,reinterpretation,recasting,HEPData,OpenMAPP
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Topic :: Scientific/Engineering :: Physics
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: jsonschema>=4.18
15
+ Provides-Extra: test
16
+ Requires-Dist: pytest; extra == "test"
17
+
18
+ # openmapp-analyses
19
+
20
+ A command-line tool to find which reinterpretation and analysis-preservation tools (Rivet,
21
+ MadAnalysis 5, SModelS, CheckMATE, HackAnalysis, GAMBIT, SimpleAnalysis, ADL) implement which
22
+ experimental analyses, and which analyses have a published statistical model (Combine,
23
+ HistFactory, HS3). It combines the analysis lists into one database, matched by INSPIRE ID, saves
24
+ it on your computer and lets you search it offline.
25
+
26
+ The same information can be browsed on the web page:
27
+ **https://openmapp.gitlab.io/analysis-summary/**
28
+
29
+ Developed by Arpita Mondal within [OpenMAPP](https://openmapp.gitlab.io).
30
+
31
+ ## Requirements
32
+
33
+ - Python 3.8 or newer
34
+ - internet access for `openmapp-analyses update`; everything else works offline
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ python3 -m venv venv
40
+ source venv/bin/activate
41
+ pip install openmapp-analyses
42
+ ```
43
+
44
+ Check the installation with `openmapp-analyses --version`.
45
+
46
+ ## Usage
47
+
48
+ ### Get the data
49
+
50
+ ```bash
51
+ openmapp-analyses update # download and combine all lists (needs internet, a few minutes the first time)
52
+ openmapp-analyses tools # the tools and statistical models, and how many analyses each covers
53
+ ```
54
+
55
+ Run `update` again whenever you want the latest lists; later updates are faster.
56
+
57
+ ### Search
58
+
59
+ All conditions given together must match. Names are flexible: `smodels`, `SModelS` and
60
+ `"MadAnalysis 5"` all work.
61
+
62
+ ```bash
63
+ openmapp-analyses search --tool smodels # implemented in SModelS
64
+ openmapp-analyses search --tool smodels --tool checkmate # in both
65
+ openmapp-analyses search --any-tool smodels --any-tool checkmate # in at least one
66
+ openmapp-analyses search --tool smodels --not-tool checkmate # in SModelS but not CheckMATE
67
+ openmapp-analyses search --tool smodels --tool histfactory # in SModelS, with a HistFactory likelihood
68
+ openmapp-analyses search --tool smodels --other # how many of them each tool has
69
+
70
+ openmapp-analyses search --analysis-id ATLAS-SUSY-2018-31 # by analysis ID
71
+ openmapp-analyses search --arxiv 2102.10874 # by arXiv number
72
+ openmapp-analyses search --inspire-id 1847779 --links # by INSPIRE ID, with links
73
+
74
+ openmapp-analyses search --where collaborations=CMS --where year=2021
75
+ openmapp-analyses search --where "title~dark matter" # ~ means "contains"
76
+ openmapp-analyses search --tool smodels --json > smodels.json # save the results as JSON
77
+ ```
78
+
79
+ | Option | Meaning |
80
+ |---|---|
81
+ | `--tool T` | in T (repeat: in all of them) |
82
+ | `--any-tool T` | in at least one of these (repeat) |
83
+ | `--not-tool T` | not in T |
84
+ | `--analysis-id ID` | this analysis ID, e.g. `ATLAS-SUSY-2018-31` |
85
+ | `--arxiv ID` | this arXiv number |
86
+ | `--inspire-id N` | this INSPIRE ID (repeatable) |
87
+ | `--where FIELD=VALUE` | any field in the data, e.g. `year`, `title`, `collaborations`; `~` for "contains" |
88
+ | `--other` | only show how many analyses, per tool |
89
+ | `--links` | also show the link of each implementation |
90
+ | `--json` | print the full results as JSON |
91
+ | `--limit N` | how many analyses to list (default 50, `0` = all) |
92
+
93
+ `--tool`, `--any-tool` and `--not-tool` also accept the statistical models: `combine`,
94
+ `histfactory`, `hs3`.
95
+
96
+ ### One analysis
97
+
98
+ ```bash
99
+ openmapp-analyses show 1847779 # which tools implement it
100
+ openmapp-analyses show 1847779 --details # plus names and links
101
+ openmapp-analyses show 1847779 --tool smodels # details for one tool
102
+ ```
103
+
104
+ ### The list of tools
105
+
106
+ ```bash
107
+ openmapp-analyses sources # the tools and the addresses of their lists
108
+ ```
109
+
110
+ Run `openmapp-analyses <command> --help` for all options.
111
+
112
+ ## Where the data is saved
113
+
114
+ | System | Location |
115
+ |---|---|
116
+ | Linux | `~/.local/share/openmapp-analyses/analyses.json` |
117
+ | macOS | `~/Library/Application Support/openmapp-analyses/analyses.json` |
118
+ | Windows | `%LOCALAPPDATA%\openmapp-analyses\analyses.json` |
119
+
120
+ Use another folder with the environment variable `OPENMAPP_ANALYSES_DATA`, or another file for
121
+ one command with `openmapp-analyses --data FILE ...`. The file follows the JSON schema
122
+ `schema.json` included in the package.
123
+
124
+ ## Where the data comes from
125
+
126
+ - **The list of tools:** `ANALYSES_ENDPOINTS` in HEPData's
127
+ [`config.py`](https://github.com/HEPData/hepdata/blob/main/hepdata/config.py); a tool added
128
+ there is picked up automatically. The file is only read, never run.
129
+ - **Each tool's analyses:** the JSON file the tool publishes.
130
+ - **HistFactory and HS3 likelihoods:** HEPData's search, with a link to each file.
131
+ - **Analysis information** (arXiv number, title, collaboration, year, report numbers, DOIs):
132
+ [INSPIRE](https://inspirehep.net); missing analysis IDs also from the arXiv comment.
133
+
134
+ If a source cannot be reached, the data from the previous update is kept.
135
+
136
+ ## Use from Python
137
+
138
+ ```python
139
+ from openmapp_analyses import load, search
140
+
141
+ data = load()
142
+ for analysis in search(data, tools=["SModelS", "CheckMATE"]):
143
+ print(analysis["inspire_id"], list(analysis["tools"]))
144
+ ```
@@ -0,0 +1,127 @@
1
+ # openmapp-analyses
2
+
3
+ A command-line tool to find which reinterpretation and analysis-preservation tools (Rivet,
4
+ MadAnalysis 5, SModelS, CheckMATE, HackAnalysis, GAMBIT, SimpleAnalysis, ADL) implement which
5
+ experimental analyses, and which analyses have a published statistical model (Combine,
6
+ HistFactory, HS3). It combines the analysis lists into one database, matched by INSPIRE ID, saves
7
+ it on your computer and lets you search it offline.
8
+
9
+ The same information can be browsed on the web page:
10
+ **https://openmapp.gitlab.io/analysis-summary/**
11
+
12
+ Developed by Arpita Mondal within [OpenMAPP](https://openmapp.gitlab.io).
13
+
14
+ ## Requirements
15
+
16
+ - Python 3.8 or newer
17
+ - internet access for `openmapp-analyses update`; everything else works offline
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ python3 -m venv venv
23
+ source venv/bin/activate
24
+ pip install openmapp-analyses
25
+ ```
26
+
27
+ Check the installation with `openmapp-analyses --version`.
28
+
29
+ ## Usage
30
+
31
+ ### Get the data
32
+
33
+ ```bash
34
+ openmapp-analyses update # download and combine all lists (needs internet, a few minutes the first time)
35
+ openmapp-analyses tools # the tools and statistical models, and how many analyses each covers
36
+ ```
37
+
38
+ Run `update` again whenever you want the latest lists; later updates are faster.
39
+
40
+ ### Search
41
+
42
+ All conditions given together must match. Names are flexible: `smodels`, `SModelS` and
43
+ `"MadAnalysis 5"` all work.
44
+
45
+ ```bash
46
+ openmapp-analyses search --tool smodels # implemented in SModelS
47
+ openmapp-analyses search --tool smodels --tool checkmate # in both
48
+ openmapp-analyses search --any-tool smodels --any-tool checkmate # in at least one
49
+ openmapp-analyses search --tool smodels --not-tool checkmate # in SModelS but not CheckMATE
50
+ openmapp-analyses search --tool smodels --tool histfactory # in SModelS, with a HistFactory likelihood
51
+ openmapp-analyses search --tool smodels --other # how many of them each tool has
52
+
53
+ openmapp-analyses search --analysis-id ATLAS-SUSY-2018-31 # by analysis ID
54
+ openmapp-analyses search --arxiv 2102.10874 # by arXiv number
55
+ openmapp-analyses search --inspire-id 1847779 --links # by INSPIRE ID, with links
56
+
57
+ openmapp-analyses search --where collaborations=CMS --where year=2021
58
+ openmapp-analyses search --where "title~dark matter" # ~ means "contains"
59
+ openmapp-analyses search --tool smodels --json > smodels.json # save the results as JSON
60
+ ```
61
+
62
+ | Option | Meaning |
63
+ |---|---|
64
+ | `--tool T` | in T (repeat: in all of them) |
65
+ | `--any-tool T` | in at least one of these (repeat) |
66
+ | `--not-tool T` | not in T |
67
+ | `--analysis-id ID` | this analysis ID, e.g. `ATLAS-SUSY-2018-31` |
68
+ | `--arxiv ID` | this arXiv number |
69
+ | `--inspire-id N` | this INSPIRE ID (repeatable) |
70
+ | `--where FIELD=VALUE` | any field in the data, e.g. `year`, `title`, `collaborations`; `~` for "contains" |
71
+ | `--other` | only show how many analyses, per tool |
72
+ | `--links` | also show the link of each implementation |
73
+ | `--json` | print the full results as JSON |
74
+ | `--limit N` | how many analyses to list (default 50, `0` = all) |
75
+
76
+ `--tool`, `--any-tool` and `--not-tool` also accept the statistical models: `combine`,
77
+ `histfactory`, `hs3`.
78
+
79
+ ### One analysis
80
+
81
+ ```bash
82
+ openmapp-analyses show 1847779 # which tools implement it
83
+ openmapp-analyses show 1847779 --details # plus names and links
84
+ openmapp-analyses show 1847779 --tool smodels # details for one tool
85
+ ```
86
+
87
+ ### The list of tools
88
+
89
+ ```bash
90
+ openmapp-analyses sources # the tools and the addresses of their lists
91
+ ```
92
+
93
+ Run `openmapp-analyses <command> --help` for all options.
94
+
95
+ ## Where the data is saved
96
+
97
+ | System | Location |
98
+ |---|---|
99
+ | Linux | `~/.local/share/openmapp-analyses/analyses.json` |
100
+ | macOS | `~/Library/Application Support/openmapp-analyses/analyses.json` |
101
+ | Windows | `%LOCALAPPDATA%\openmapp-analyses\analyses.json` |
102
+
103
+ Use another folder with the environment variable `OPENMAPP_ANALYSES_DATA`, or another file for
104
+ one command with `openmapp-analyses --data FILE ...`. The file follows the JSON schema
105
+ `schema.json` included in the package.
106
+
107
+ ## Where the data comes from
108
+
109
+ - **The list of tools:** `ANALYSES_ENDPOINTS` in HEPData's
110
+ [`config.py`](https://github.com/HEPData/hepdata/blob/main/hepdata/config.py); a tool added
111
+ there is picked up automatically. The file is only read, never run.
112
+ - **Each tool's analyses:** the JSON file the tool publishes.
113
+ - **HistFactory and HS3 likelihoods:** HEPData's search, with a link to each file.
114
+ - **Analysis information** (arXiv number, title, collaboration, year, report numbers, DOIs):
115
+ [INSPIRE](https://inspirehep.net); missing analysis IDs also from the arXiv comment.
116
+
117
+ If a source cannot be reached, the data from the previous update is kept.
118
+
119
+ ## Use from Python
120
+
121
+ ```python
122
+ from openmapp_analyses import load, search
123
+
124
+ data = load()
125
+ for analysis in search(data, tools=["SModelS", "CheckMATE"]):
126
+ print(analysis["inspire_id"], list(analysis["tools"]))
127
+ ```
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "openmapp-analyses"
7
+ version = "1.0.0"
8
+ description = "Which reinterpretation and analysis-preservation tools implement which experimental analyses, and which analyses have a published statistical model; search them offline"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ dependencies = ["jsonschema>=4.18"]
12
+ authors = [{ name = "Arpita Mondal" }]
13
+ keywords = ["HEP", "LHC", "reinterpretation", "recasting", "HEPData", "OpenMAPP"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Intended Audience :: Science/Research",
17
+ "Topic :: Scientific/Engineering :: Physics",
18
+ ]
19
+
20
+ [project.urls]
21
+ "Web page" = "https://openmapp.gitlab.io/analysis-summary/"
22
+ OpenMAPP = "https://openmapp.gitlab.io"
23
+
24
+ [project.optional-dependencies]
25
+ test = ["pytest"]
26
+
27
+ [project.scripts]
28
+ openmapp-analyses = "openmapp_analyses.cli:main"
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["src"]
32
+
33
+ [tool.setuptools.package-data]
34
+ openmapp_analyses = ["sources.json", "schema.json"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,15 @@
1
+ """
2
+ openmapp-analyses: combine the analysis lists of tools such as Rivet, SModelS and CheckMATE,
3
+ and search them offline.
4
+
5
+ Python use:
6
+ >>> from openmapp_analyses import load, search
7
+ >>> data = load() # the locally saved database
8
+ >>> papers = search(data, tools=["SModelS", "CheckMATE"])
9
+ """
10
+
11
+ __version__ = "1.0.0"
12
+
13
+ from .combine import build_database # noqa: E402,F401
14
+ from .store import load, save, data_file # noqa: E402,F401
15
+ from .search import search, find_tool_name # noqa: E402,F401
@@ -0,0 +1,6 @@
1
+ """Allows running the tool as `python -m openmapp_analyses ...`."""
2
+ import sys
3
+
4
+ from .cli import main
5
+
6
+ sys.exit(main())
@@ -0,0 +1,81 @@
1
+ """
2
+ Analysis IDs from the current arXiv comment, for papers that have no ID yet.
3
+
4
+ INSPIRE keeps the comment of the first arXiv version; the link to the experiment's result page
5
+ (e.g. ".../Atlas/GROUPS/PHYSICS/PAPERS/<ID>") is sometimes only added in a later version.
6
+ arXiv's API is asked about many papers per request, with the 3 s pause arXiv asks for.
7
+
8
+ API documentation: https://info.arxiv.org/help/api/user-manual.html
9
+ """
10
+
11
+ import re
12
+ import time
13
+ import urllib.parse
14
+ import urllib.request
15
+ import xml.etree.ElementTree as ET
16
+
17
+ from .inspire import analysis_ids_from_links
18
+
19
+ API_URL = "https://export.arxiv.org/api/query"
20
+ BATCH_SIZE = 50
21
+ PAUSE = 3.0
22
+ NS = {"atom": "http://www.w3.org/2005/Atom", "arxiv": "http://arxiv.org/schemas/atom"}
23
+
24
+
25
+ def _get_text(url, timeout=60):
26
+ req = urllib.request.Request(url, headers={"User-Agent": "openmapp-analyses"})
27
+ with urllib.request.urlopen(req, timeout=timeout) as resp:
28
+ return resp.read().decode("utf-8")
29
+
30
+
31
+ def _arxiv_number(entry_id):
32
+ """'http://arxiv.org/abs/1103.2929v2' -> '1103.2929'."""
33
+ number = entry_id.split("/abs/", 1)[-1]
34
+ return number.rsplit("v", 1)[0] if number.rsplit("v", 1)[-1].isdigit() else number
35
+
36
+
37
+ def fetch_comments(arxiv_ids, get_text=_get_text, sleep=time.sleep):
38
+ """Return {arXiv number: comment} for the given arXiv numbers."""
39
+ comments = {}
40
+ for b in range(0, len(arxiv_ids), BATCH_SIZE):
41
+ if b:
42
+ sleep(PAUSE)
43
+ ids = arxiv_ids[b:b + BATCH_SIZE]
44
+ url = API_URL + "?" + urllib.parse.urlencode({"id_list": ",".join(ids), "max_results": len(ids)})
45
+ root = ET.fromstring(get_text(url))
46
+ for entry in root.findall("atom:entry", NS):
47
+ entry_id = entry.findtext("atom:id", default="", namespaces=NS)
48
+ comment = entry.findtext("arxiv:comment", default="", namespaces=NS)
49
+ if entry_id and comment:
50
+ comments[_arxiv_number(entry_id)] = re.sub(r"\s*\n\s*", "", comment)
51
+ return comments
52
+
53
+
54
+ ID_IN_REPORT_NUMBER = re.compile(r"^(ATLAS|CMS|LHCb|ALICE)-(PAS-)?[A-Z0-9]+-\d{2,4}-\d{2,4}$", re.I)
55
+
56
+
57
+ def add_ids_from_arxiv(database, log=print, fetch=None):
58
+ """Add analysis IDs from arXiv to papers that have an arXiv number but no ID yet."""
59
+ fetch = fetch or fetch_comments
60
+ todo = {}
61
+ for a in database["analyses"]:
62
+ info = a.get("inspire", {})
63
+ if not info.get("arXiv_id") or info.get("analysis_ids"):
64
+ continue
65
+ if any(ID_IN_REPORT_NUMBER.match(r) for r in info.get("report_numbers", [])):
66
+ continue
67
+ todo[info["arXiv_id"]] = info
68
+ if not todo:
69
+ return
70
+ try:
71
+ comments = fetch(list(todo))
72
+ except Exception as exc:
73
+ log(f" arXiv: could not be reached ({type(exc).__name__}: {exc}); skipped")
74
+ return
75
+ found = 0
76
+ for number, info in todo.items():
77
+ ids = analysis_ids_from_links(comments.get(number, ""))
78
+ if ids:
79
+ info["analysis_ids"] = ids
80
+ found += 1
81
+ log(f" arXiv: {len(todo)} papers without an analysis ID checked, {found} found")