├── docs
├── requirements.txt
├── source
│ ├── logo.jpg
│ ├── BLLac_cte.png
│ ├── VHE_table.png
│ ├── api.rst
│ ├── easyFermiLC.png
│ ├── easyfermiSED.png
│ ├── BLLac_adaptive.png
│ ├── SED_Mrk421_GitHub.png
│ ├── easyfermi_window.png
│ ├── world_map_jan_2025.png
│ ├── easyfermi_diagnostic.png
│ ├── easyfermi_window_loc.png
│ ├── easyfermi_find_sources.png
│ ├── easyfermi_notcataloged.png
│ ├── easyfermi_window_Mrk421.png
│ ├── easyfermi_window_custom.png
│ ├── Extension_M31_above_1GeV.png
│ ├── Sun_path_1LHAASO_J1219+2915.png
│ ├── easyfermi_window_extension.png
│ ├── easyfermi_window_delete_source.png
│ ├── conf.py
│ ├── localization.rst
│ ├── index.rst
│ ├── usage.rst
│ ├── extension.rst
│ ├── lightcurve.rst
│ ├── Basic_analysis.rst
│ ├── SED.rst
│ └── custom_analysis.rst
├── Makefile
└── make.bat
├── src
└── easyfermi
│ ├── __init__.py
│ ├── resources
│ ├── images
│ │ ├── logo.jpg
│ │ ├── fermi.png
│ │ ├── easyFermi.png
│ │ ├── download_logo.png
│ │ ├── easyFermiIcon.png
│ │ └── easyFermiWindow.png
│ └── ebl
│ │ ├── frd_abs.fits.gz
│ │ ├── ebl_dominguez11.fits.gz
│ │ ├── ebl_franceschini.fits.gz
│ │ ├── ebl_franceschini_2017.fits.gz
│ │ └── ebl_saldana-lopez_2021.fits.gz
│ ├── _dev_version
│ └── __init__.py
│ └── version.py
├── MANIFEST.in
├── .mailmap
├── readthedocs.yaml
├── .github
├── ISSUE_TEMPLATE
│ ├── feature-request.yml
│ └── bug-report.yml
├── FUNDING.yml
└── workflows
│ └── ci.yml
├── environment.yml
├── .gitignore
├── LICENSE
├── pyproject.toml
└── README.md
/docs/requirements.txt:
--------------------------------------------------------------------------------
1 | sphinx==7.1.2
2 | sphinx-rtd-theme==1.3.0rc1
3 |
--------------------------------------------------------------------------------
/docs/source/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/logo.jpg
--------------------------------------------------------------------------------
/docs/source/BLLac_cte.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/BLLac_cte.png
--------------------------------------------------------------------------------
/docs/source/VHE_table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/VHE_table.png
--------------------------------------------------------------------------------
/docs/source/api.rst:
--------------------------------------------------------------------------------
1 | API
2 | ===
3 |
4 | .. autosummary::
5 | :toctree: generated
6 |
7 | easyfermi
8 |
--------------------------------------------------------------------------------
/docs/source/easyFermiLC.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/easyFermiLC.png
--------------------------------------------------------------------------------
/docs/source/easyfermiSED.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/easyfermiSED.png
--------------------------------------------------------------------------------
/src/easyfermi/__init__.py:
--------------------------------------------------------------------------------
1 | """The easiest way to analyze Fermi-LAT data."""
2 |
3 | from .easyfermi import *
4 |
5 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include README.md
2 |
3 | prune build
4 | prune src/easyfermi/_dev_version
5 |
6 | global-exclude *.pyc *.o
--------------------------------------------------------------------------------
/docs/source/BLLac_adaptive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/BLLac_adaptive.png
--------------------------------------------------------------------------------
/docs/source/SED_Mrk421_GitHub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/SED_Mrk421_GitHub.png
--------------------------------------------------------------------------------
/docs/source/easyfermi_window.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/easyfermi_window.png
--------------------------------------------------------------------------------
/docs/source/world_map_jan_2025.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/world_map_jan_2025.png
--------------------------------------------------------------------------------
/docs/source/easyfermi_diagnostic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/easyfermi_diagnostic.png
--------------------------------------------------------------------------------
/docs/source/easyfermi_window_loc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/easyfermi_window_loc.png
--------------------------------------------------------------------------------
/docs/source/easyfermi_find_sources.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/easyfermi_find_sources.png
--------------------------------------------------------------------------------
/docs/source/easyfermi_notcataloged.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/easyfermi_notcataloged.png
--------------------------------------------------------------------------------
/docs/source/easyfermi_window_Mrk421.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/easyfermi_window_Mrk421.png
--------------------------------------------------------------------------------
/docs/source/easyfermi_window_custom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/easyfermi_window_custom.png
--------------------------------------------------------------------------------
/src/easyfermi/resources/images/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/src/easyfermi/resources/images/logo.jpg
--------------------------------------------------------------------------------
/docs/source/Extension_M31_above_1GeV.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/Extension_M31_above_1GeV.png
--------------------------------------------------------------------------------
/src/easyfermi/resources/images/fermi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/src/easyfermi/resources/images/fermi.png
--------------------------------------------------------------------------------
/docs/source/Sun_path_1LHAASO_J1219+2915.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/Sun_path_1LHAASO_J1219+2915.png
--------------------------------------------------------------------------------
/docs/source/easyfermi_window_extension.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/easyfermi_window_extension.png
--------------------------------------------------------------------------------
/src/easyfermi/resources/ebl/frd_abs.fits.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/src/easyfermi/resources/ebl/frd_abs.fits.gz
--------------------------------------------------------------------------------
/src/easyfermi/resources/images/easyFermi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/src/easyfermi/resources/images/easyFermi.png
--------------------------------------------------------------------------------
/docs/source/easyfermi_window_delete_source.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/docs/source/easyfermi_window_delete_source.png
--------------------------------------------------------------------------------
/src/easyfermi/resources/images/download_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/src/easyfermi/resources/images/download_logo.png
--------------------------------------------------------------------------------
/src/easyfermi/resources/images/easyFermiIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/src/easyfermi/resources/images/easyFermiIcon.png
--------------------------------------------------------------------------------
/src/easyfermi/resources/ebl/ebl_dominguez11.fits.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/src/easyfermi/resources/ebl/ebl_dominguez11.fits.gz
--------------------------------------------------------------------------------
/src/easyfermi/resources/images/easyFermiWindow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/src/easyfermi/resources/images/easyFermiWindow.png
--------------------------------------------------------------------------------
/src/easyfermi/resources/ebl/ebl_franceschini.fits.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/src/easyfermi/resources/ebl/ebl_franceschini.fits.gz
--------------------------------------------------------------------------------
/src/easyfermi/resources/ebl/ebl_franceschini_2017.fits.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/src/easyfermi/resources/ebl/ebl_franceschini_2017.fits.gz
--------------------------------------------------------------------------------
/src/easyfermi/resources/ebl/ebl_saldana-lopez_2021.fits.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranieremenezes/easyfermi/HEAD/src/easyfermi/resources/ebl/ebl_saldana-lopez_2021.fits.gz
--------------------------------------------------------------------------------
/.mailmap:
--------------------------------------------------------------------------------
1 | Michele Peresano Michele Peresano
2 | Raniere de Menezes
3 | Clodomir Vianna clodo <104923248+clodoN1109@users.noreply.github.com>
--------------------------------------------------------------------------------
/readthedocs.yaml:
--------------------------------------------------------------------------------
1 | version: "2"
2 |
3 | build:
4 | os: "ubuntu-22.04"
5 | tools:
6 | python: "3.10"
7 |
8 | python:
9 | install:
10 | - requirements: docs/requirements.txt
11 |
12 | sphinx:
13 | configuration: docs/source/conf.py
14 |
--------------------------------------------------------------------------------
/src/easyfermi/_dev_version/__init__.py:
--------------------------------------------------------------------------------
1 | # Try to use setuptools_scm to get the current version; this is only used
2 | # in development installations from the git repository.
3 | # see easyfermi/version.py for details
4 | try:
5 | from setuptools_scm import get_version
6 |
7 | version = get_version(root="../../..", relative_to=__file__)
8 | except Exception as e:
9 | raise ImportError(f"setuptools_scm broken or not installed: {e}")
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature-request.yml:
--------------------------------------------------------------------------------
1 | name: Feature request
2 | description: Suggest an idea to make easyfermi better!
3 | title: "[Feature request]: "
4 | labels: ["enhancement", "suggestion"]
5 |
6 | body:
7 | - type: textarea
8 | id: what
9 | attributes:
10 | label: Describe the solution you would like
11 | description: A clear and concise description of why this feature is needed.
12 | validations:
13 | required: true
--------------------------------------------------------------------------------
/environment.yml:
--------------------------------------------------------------------------------
1 | name: easyfermi
2 | channels:
3 | - conda-forge
4 | dependencies:
5 | - python
6 | - pip
7 | # core dependencies
8 | - astropy=5.3.3
9 | - astroquery=0.4.6
10 | - emcee
11 | - fermi::fermitools=2.2.0
12 | - fermipy=v1.2
13 | - gammapy=1.1
14 | - healpy=1.16.1
15 | - matplotlib=3.8.2
16 | - psutil=5.9.8
17 | - pyqt=5.15.9
18 | - scipy=1.11.4
19 | # development
20 | - black
21 | - pre-commit
22 | - ruff
23 | - pip:
24 | - corner
25 |
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line, and also
5 | # from the environment for the first two.
6 | SPHINXOPTS ?=
7 | SPHINXBUILD ?= sphinx-build
8 | SOURCEDIR = source
9 | BUILDDIR = build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21 |
--------------------------------------------------------------------------------
/src/easyfermi/version.py:
--------------------------------------------------------------------------------
1 | # this is adapted from https://github.com/astropy/astropy/blob/master/astropy/version.py
2 | # see https://github.com/astropy/astropy/pull/10774 for a discussion on why this needed.
3 |
4 | try:
5 | try:
6 | from ._dev_version import version
7 | except ImportError:
8 | from ._version import version
9 | except Exception:
10 | import warnings
11 |
12 | warnings.warn(
13 | "Could not determine easyfermi version; this indicates a broken installation."
14 | " Install easyfermi from PyPI, using conda or from a local git repository."
15 | " Installing github's autogenerated source release tarballs "
16 | " does not include version information and should be avoided."
17 | )
18 | del warnings
19 | version = "0.0.0"
20 |
21 | __version__ = version
--------------------------------------------------------------------------------
/docs/source/conf.py:
--------------------------------------------------------------------------------
1 | # Configuration file for the Sphinx documentation builder.
2 |
3 | # -- Project information
4 |
5 | project = 'easyfermi'
6 | copyright = '2021, Raniere de Menezes'
7 | author = 'Raniere de Menezes'
8 |
9 | release = '2.0'
10 | version = '2.0.0'
11 |
12 | # -- General configuration
13 |
14 | extensions = [
15 | 'sphinx.ext.duration',
16 | 'sphinx.ext.doctest',
17 | 'sphinx.ext.autodoc',
18 | 'sphinx.ext.autosummary',
19 | 'sphinx.ext.intersphinx',
20 | ]
21 |
22 | intersphinx_mapping = {
23 | 'python': ('https://docs.python.org/3/', None),
24 | 'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
25 | }
26 | intersphinx_disabled_domains = ['std']
27 |
28 | templates_path = ['_templates']
29 |
30 | # -- Options for HTML output
31 |
32 | html_theme = 'sphinx_rtd_theme'
33 |
34 | # -- Options for EPUB output
35 | epub_show_urls = 'footnote'
36 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13 | custom: ['https://www.buymeacoffee.com/easyfermi'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
14 |
--------------------------------------------------------------------------------
/docs/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | pushd %~dp0
4 |
5 | REM Command file for Sphinx documentation
6 |
7 | if "%SPHINXBUILD%" == "" (
8 | set SPHINXBUILD=sphinx-build
9 | )
10 | set SOURCEDIR=source
11 | set BUILDDIR=build
12 |
13 | if "%1" == "" goto help
14 |
15 | %SPHINXBUILD% >NUL 2>NUL
16 | if errorlevel 9009 (
17 | echo.
18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19 | echo.installed, then set the SPHINXBUILD environment variable to point
20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you
21 | echo.may add the Sphinx directory to PATH.
22 | echo.
23 | echo.If you don't have Sphinx installed, grab it from
24 | echo.http://sphinx-doc.org/
25 | exit /b 1
26 | )
27 |
28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29 | goto end
30 |
31 | :help
32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33 |
34 | :end
35 | popd
36 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled files
2 | *.py[co]
3 | *.a
4 | *.o
5 | *.so
6 | __pycache__
7 |
8 | # Packages/installer info
9 | *.egg
10 | *.eggs
11 | *.egg-info
12 | dist
13 | build
14 | eggs
15 | parts
16 | bin
17 | var
18 | sdist
19 | develop-eggs
20 | .installed.cfg
21 | distribute-*.tar.gz
22 |
23 | # Other
24 | .*.swp
25 | *~
26 | \#*
27 | .\#*
28 |
29 | # Mac OSX
30 | .DS_Store
31 |
32 | # data files (should not be stored in git)
33 | **/wget*log*
34 | *.log
35 | *.csv
36 | *.fits
37 | *.fits.gz
38 | *.npy
39 | *.xml
40 | *.jpg
41 | *.par
42 | *.yml
43 | *.pdf
44 |
45 | # Exclude from ignoring what we actually need
46 | !src/easyfermi/resources/ebl/*.fits.gz
47 | !src/easyfermi/resources/images/*.png
48 | !src/easyfermi/resources/images/*.jpg
49 | !environment.yml
50 | !.github/**/*.yml
51 |
52 | # ignore version cache file
53 | easyfermi/_version_cache.py
54 | src/easyfermi/_version.py
55 |
56 | # Editors and IDEs
57 |
58 | # Visual Studio Code
59 | .vscode
60 | # Eclipse
61 | .project
62 | .pydevproject
63 | .settings
64 | # Pycharm
65 | .idea
66 | # KDevelop
67 | *kdev4
68 |
--------------------------------------------------------------------------------
/docs/source/localization.rst:
--------------------------------------------------------------------------------
1 | Relocalization
2 | ==============
3 |
4 | .. image:: ./easyfermi_window_loc.png
5 | :width: 700
6 |
7 | .. _Relocalization:
8 |
9 | Relocalization
10 | --------------
11 |
12 |
13 | If the box "Relocalize" is checked, ``easyfermi`` will find the best-fit R.A. and Dec. for the gamma-ray target by calling the ``fermipy`` function `localize() `_ with the following configuration:
14 |
15 | .. code-block::
16 |
17 | localize(Target_Name, make_plots=True, update=True)
18 |
19 |
20 | The input parameters for this function are:
21 |
22 | * **Target_Name**: This is the name of the target as listed in the adopted Fermi-LAT catalog or the target name written in the field "Target name" in the graphical interface.
23 |
24 | * **make_plots**: This is always True in easyfermi, meaning that the diagnostic plots will always be saved in the output directory.
25 |
26 | * **update**: This is always True in easyfermi, meaning that the RoI model will be updated with the new best-fit coordinates for the target (only if the fit succeeds).
27 |
28 | This method also generates two data files, namely "TARGET_NAME_loc.fits" and "TARGET_NAME_loc.npy", containing the old and new coordinates of the gamma-ray target, as well as the r68, r95, and r99 uncertainty radii. These files are saved in the output directory defined in the graphical interface.
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report.yml:
--------------------------------------------------------------------------------
1 | name: Bug Report
2 | description: File a bug report
3 | title: "[Bug]: "
4 | labels: ["bug", "triage"]
5 | assignees:
6 | - ranieremenezes
7 | body:
8 | - type: markdown
9 | attributes:
10 | value: |
11 | Thanks for taking the time to fill out this bug report!
12 | - type: textarea
13 | id: what-happened
14 | attributes:
15 | label: What happened?
16 | description: Please be sure to detail the issue.
17 | placeholder: Tell us what you see!
18 | value: "A bug happened for the target XXXX, coords RA-DEC, energy range XXX-XXXX, time interval XXX-XXX. I was expecting to find the result X, but I found Y!\nI am also attaching a screenshot with the easyfermi window."
19 | validations:
20 | required: true
21 | - type: textarea
22 | attributes:
23 | label: Environment
24 | description: |
25 | List any relevant information about your environment, for example:
26 | - **OS**: Ubuntu 20.04
27 | - **easyfermi**: vX.Y.Z
28 | - **fermipy**: vX.Y.Z
29 | - **fermitools**: vX.Y.Z
30 | value: |
31 | - OS:
32 | - Node:
33 | - npm:
34 | render: markdown
35 | validations:
36 | required: false
37 | - type: textarea
38 | id: logs
39 | attributes:
40 | label: Relevant log output
41 | description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
42 | render: shell
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2022, ranieremenezes
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | 3. Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [build-system]
2 | requires = ["setuptools>=64", "setuptools_scm[toml]>=8"]
3 | build-backend = "setuptools.build_meta"
4 |
5 |
6 | [project]
7 | name = "easyfermi"
8 | authors = [
9 | { name = "Raniere de Menezes", email = "easyfermi@gmail.com" },
10 | { name = "Michele Peresano", email = "peresano.michele@gmail.com" },
11 | ]
12 | description = "The easiest way to analyze Fermi-LAT data"
13 | readme = "README.md"
14 | requires-python = ">=3.9,<3.10"
15 | keywords = [
16 | "python",
17 | "fermi",
18 | "GUI",
19 | "graphical interface",
20 | "easyfermi",
21 | "gamma-rays",
22 | ]
23 | license = { text = "BSD-3-Clause" }
24 | classifiers = [
25 | "Development Status :: 4 - Beta",
26 | "Intended Audience :: Science/Research",
27 | "Topic :: Scientific/Engineering :: Astronomy",
28 | "License :: OSI Approved :: BSD License",
29 | "Programming Language :: Python :: 3",
30 | "Programming Language :: Python :: 3.9",
31 | "Programming Language :: Python :: Implementation :: CPython",
32 | "Operating System :: Unix",
33 | "Operating System :: MacOS :: MacOS X",
34 | ]
35 | dependencies = [
36 | "astropy==5.3.3",
37 | "astroquery==0.4.6",
38 | "corner",
39 | "emcee",
40 | "fermipy==v1.2",
41 | "gammapy==1.1",
42 | "healpy==1.16.1",
43 | 'importlib-metadata; python_version<"3.10"',
44 | "matplotlib==3.8.2",
45 | "psutil==5.9.8",
46 | "PyQt5==5.15.9",
47 | "scipy==1.11.4",
48 | ]
49 | dynamic = ["version"]
50 |
51 | [tool.setuptools_scm]
52 | write_to = "src/easyfermi/_version.py"
53 |
54 | [tool.setuptools.packages.find]
55 | where = ["src"]
56 |
57 | [tool.setuptools.package-data]
58 | "resources.ebl" = ["*.fits.gz"]
59 | "reousrce.images" = ["*.png", "*.jpg"]
60 |
61 | [project.optional-dependencies]
62 | dev = ["easyfermi[docs]", "easyfermi[tests]", "ruff", "pre-commit"]
63 |
64 | [project.scripts]
65 | my-script = "my_package.module:function"
66 |
67 | # ... other project metadata fields as listed in:
68 | # https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
69 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | tags:
8 | - "**"
9 | pull_request:
10 |
11 |
12 | jobs:
13 |
14 | install:
15 | runs-on: ${{ matrix.os }}
16 | strategy:
17 | matrix:
18 | python-version: [3.9]
19 | os: [ubuntu-latest]
20 |
21 | defaults:
22 | run:
23 | # We need login shells (-l) for micromamba to work.
24 | shell: bash -leo pipefail {0}
25 |
26 | steps:
27 | - uses: actions/checkout@v4
28 | with:
29 | fetch-depth: 0
30 |
31 | - name: Prepare mamba installation
32 | env:
33 | PYTHON_VERSION: ${{ matrix.python-version }}
34 | run: |
35 | # setup correct python version
36 | sed -i -e "s/- python=.*/- python=$PYTHON_VERSION/g" environment.yml
37 |
38 | - name: mamba setup
39 | uses: mamba-org/setup-micromamba@v1
40 | with:
41 | environment-file: environment.yml
42 | cache-downloads: true
43 |
44 | - name: Python setup
45 | uses: actions/setup-python@v5
46 | with:
47 | python-version: ${{ matrix.python-version }}
48 | check-latest: true
49 |
50 | - if: runner.os == 'macOS'
51 | name: Fix Python PATH on macOS
52 | # See https://github.com/actions/setup-python/issues/132 and
53 | # https://github.com/actions/setup-python/issues/132#issuecomment-779406058
54 | # Login shells on macOS prepend system paths, so we need to
55 | # prepend the python path from actions/setup-python.
56 | # Micromamba sets up ~/.bash_profile, where we need to set the path now.
57 | run: |
58 | tee -a ~/.bash_profile <<<'export PATH="$pythonLocation/bin:$PATH"'
59 |
60 | - name: Install dependencies
61 | env:
62 | PYTHON_VERSION: ${{ matrix.python-version }}
63 | run: |
64 | python --version | grep "Python ${PYTHON_VERSION}"
65 | python --version | grep "Python ${PYTHON_VERSION}"
66 | pip install -e .
67 | pip freeze
68 |
--------------------------------------------------------------------------------
/docs/source/index.rst:
--------------------------------------------------------------------------------
1 | Welcome to easyfermi's documentation!
2 | =====================================
3 |
4 | The graphical interface `easyfermi `_ provides a user-friendly way to analyze *Fermi*-LAT data, making use of `fermipy `_, `gammapy `_, `astropy `_, and `emcee `_.
5 |
6 |
7 | **easyfermi** allows for several different analysis on Fermi-LAT data, such as:
8 |
9 | * Modeling of the region of interest (RoI) using the `Binned likelihood analsyis `_.
10 |
11 | * Generating TS and residual maps for the RoI.
12 |
13 | * Extracting a spectral energy distribution (SED) for a target.
14 |
15 | * Correcting an SED for EBL absorption.
16 |
17 | * Generating a light curve for a target (adaptive or constant time bins).
18 |
19 | * Localizing a source or fitting its spatial extension.
20 |
21 | * Fitting several SED models with a MCMC approach.
22 |
23 |
24 | Check out the :doc:`usage` section for further information, including
25 | the GUI :ref:`installation`.
26 |
27 |
28 |
29 | Acknowledging *easyfermi*
30 | ---------------------
31 |
32 | To acknowledge *easyfermi* in a publication please cite `de Menezes, R. 2022 `_.
33 |
34 | Since easyfermi relies on fermipy, gammapy, astropy, and emcee, please also cite `Wood et al. 2017 `_, `Donath et al. 2023 `_, `Astropy Collaboration et al. 2018 `_, and `Foreman-Mackey et al. 2013 `_.
35 |
36 | The EBL models adopted in *easyfermi* are from:
37 | - `Franceschini et al. 2008 `_.
38 | - `Finke et al. 2010 `_.
39 | - `Dominguez et al. 2011 `_.
40 | - `Franceschini & Rodighiero 2017 `_.
41 | - `Saldana-Lopez et al. 2021 `_.
42 |
43 | If you make use of one of these models in your publication, please cite the corresponding paper.
44 |
45 |
46 | Contents
47 | --------
48 |
49 | .. toctree::
50 |
51 | usage
52 | Basic_analysis
53 | lightcurve
54 | SED
55 | localization
56 | extension
57 | custom_analysis
58 |
--------------------------------------------------------------------------------
/docs/source/usage.rst:
--------------------------------------------------------------------------------
1 | Usage
2 | =====
3 |
4 | .. _installation:
5 |
6 | Installation
7 | ------------
8 |
9 | To use ``easyfermi``, first install the fermitools environment using mamba (or conda):
10 |
11 | .. code-block:: console
12 |
13 | $ mamba create --name easyfermi -c conda-forge -c fermi python=3.9 "fermitools>=2.2.0" "healpy=1.16.1" "gammapy=1.1" "scipy=1.10.1" "astropy=5.3.3" "pyqt=5.15.9" "astroquery=0.4.6" "psutil=5.9.8" "emcee=3.1.4" "corner=2.2.2"
14 |
15 | Then activate the environment and install ``fermipy`` and ``easyfermi``:
16 |
17 | .. code-block:: console
18 |
19 | $ mamba activate easyfermi
20 | $ pip install fermipy easyfermi
21 |
22 | * (ONLY FOR WINDOWS) Install the libgl1 package:
23 |
24 | .. code-block:: console
25 |
26 | $ sudo apt-get install libgl1
27 |
28 | * If you want, you can set *easyfermi* as an environmental variable. For instance, if you use a Bash shell environment, you can open the .bashrc file in your home and set:
29 |
30 | .. code-block:: console
31 |
32 | $ alias easyfermi="mamba activate easyfermi && python -c 'import easyfermi'"
33 |
34 | substituting miniforge and mamba by e.g. anaconda and conda if needed. This line of command depends on which distribution of Python you installed and how you set up the mamba/conda environment.
35 |
36 | Upgrading
37 | ----------------
38 |
39 | You can check your currently installed version of easyfermi with pip show:
40 |
41 | .. code-block:: console
42 |
43 | $ pip show easyfermi
44 |
45 | If you have **easyfermi 2.0.X** installed, upgrade your installation to the latest version by running the following command in the easyfermi environment:
46 |
47 | .. code-block:: console
48 |
49 | $ pip install easyfermi --upgrade --no-deps
50 |
51 | If instead, you have **easyfermi 1.X.X** installed, please install easyfermi V2 following section :ref:`installation`.
52 |
53 | Uninstalling
54 | ----------------
55 |
56 | In the terminal, run:
57 |
58 | .. code-block:: console
59 |
60 | $ mamba deactivate
61 | $ mamba env remove --name easyfermi
62 |
63 |
64 | Running
65 | ----------------
66 |
67 | If you defined the variable *easyfermi* in your shell environment (see :ref:`installation`), simply type the following in the terminal:
68 |
69 | .. code-block:: console
70 |
71 | $ easyfermi
72 |
73 | Otherwise, type:
74 |
75 | .. code-block:: console
76 |
77 | $ mamba activate easyfermi
78 | $ python -c "import easyfermi"
79 |
80 | Substituting mamba by conda if this is the case for you.
81 |
82 | YouTube tutorials
83 | -----------------
84 |
85 | Please check the `easyfermi YouTube channel `_ for details on how to use it.
86 |
87 |
88 |
--------------------------------------------------------------------------------
/docs/source/extension.rst:
--------------------------------------------------------------------------------
1 | Extension
2 | =========
3 |
4 | .. image:: ./easyfermi_window_extension.png
5 | :width: 700
6 |
7 | .. _Extension basics:
8 |
9 | Extension - Basics
10 | ------------------
11 |
12 | If the box "Extension" is checked, ``easyfermi`` will look for extended emission for the gamma-ray target by calling the ``fermipy`` function `extension() `_ with the following configuration:
13 |
14 | .. code-block::
15 |
16 | extension(Target_Name,width=scan_list, spatial_model='RadialDisk', sqrt_ts_threshold = 3, update = True)
17 |
18 | Where the input parameters for this function are:
19 |
20 | * **Target_Name**: This is the name of the target as listed in the adopted Fermi-LAT catalog or the target name written in the field "Target name" in the graphical interface.
21 |
22 | * **scan_list**: This is a list with 20 elements, where the first element is set to 0.01°, and the last element is defined by the user in the graphical interface spinbox "Max. radius". The default value is 1°. Each element of this list defines a radius for the given spatial model (see **spatial_model** below), such that at the end we will fit 20 disks or 2D-Gaussians and extract the significance profile.
23 |
24 | * **spatial_model**: The spatial model is defined by the user in the graphical interface. It accepts only two models: 'RadialDisk' and 'RadialGaussian'.
25 |
26 | * **sqrt_ts_threshold**: The threshold on sqrt(TS_ext) that will be applied when update = True. This value is set as 3, meaning that the model will be updated only if the extended emission significance is above 3 sigma.
27 |
28 | * **update**: Set as True. The RoI model will be updated with the extended fit if the significance of the extended source with respect to a poin-like source is above 3 sigma.
29 |
30 |
31 | This method also generates two data files, namely "TARGET_NAME_ext.fits" and "TARGET_NAME_ext.npy", containing the extendend emission fit results, and a "Quickplot_extension" plot showing the delta log-likelihood profile as a function of the spatial model radius, the 68% containment radius :math:`R_{68}`, and :math:`TS_{ext}`, which tells us how significant is the extended model if compared with a point-like model. These files are saved in the output directory defined in the graphical interface. The figure below shows the "Quickplot_extension" plot for the Andromeda galaxy (M31) observed over ~ 15 years with the Fermi-LAT at energies above 1 GeV, where we can see a hint of extended emission.
32 |
33 |
34 | .. image:: ./Extension_M31_above_1GeV.png
35 | :width: 700
36 |
37 |
38 | .. _Extension_advanced:
39 |
40 | Extension - Advanced
41 | --------------------
42 |
43 |
44 | If you want to use customized spatial models, you should use easyfermi in the "Custom" mode. The box "Extension" will not be useful for you in this case, so leave it unchecked.
45 |
46 | If you don't know how to use the "Custom" mode in easyfermi, take a look at this tutorial `here `_.
47 |
48 | Ok, now that you know how to use the "Custom" mode, you need to follow only two steps:
49 |
50 | * Create the spatial map in the shape you prefer by following `this tutorial `_.
51 |
52 | * Open the config.yaml file and edit the **model** section as follows:
53 |
54 | .. code-block::
55 |
56 | [...]
57 | model:
58 | src_roiwidth : 20
59 | galdiff : '/home/username/path/to/diffuse/gll_iem_v07.fits'
60 | isodiff : '/home/username/path/to/diffuse/iso_P8R3_SOURCE_V3_v1.txt'
61 | catalogs : ['4FGL-DR3']
62 | sources :
63 | - { name: 'Target_Nickname', ra : 0.0, dec : 0.0,
64 | SpectrumType : 'PowerLaw', Index : 2.0, Scale : 1000, Prefactor : !!float 1e-11,
65 | SpatialModel: 'SpatialMap', Spatial_Filename : '/home/path/to/the_template_you_did_in_the_previous_step.fits' }
66 |
67 | where you have to substitute the variables *name, ra, dec, SpectrumType* and *Spatial_Filename* by the values corresponding to your analysis. Note that the entries *Index, Scale*, and *Prefactor* are not mandatory. The *SpectrumType* options and corresponding parameters are named according to the LAT `spectral model definitions `_.
68 |
69 |
70 | .. note::
71 |
72 | If your target is already listed as a point-like source in the adopted catalog (default is 4FGL-DR3), you **must** delete this point-like source from the RoI model using the field "Delete sources". Otherwise we will have an extended source superposed with a point-like source.
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/docs/source/lightcurve.rst:
--------------------------------------------------------------------------------
1 | Light curves
2 | ============
3 |
4 | .. image:: ./easyFermiLC.png
5 | :width: 700
6 |
7 | .. _Constant time bins:
8 |
9 | Constant-binning light curve
10 | ---------------------------
11 |
12 |
13 | A constant-binning light curve is generated with the ``fermipy`` function `lightcurve() `_ with the following configuration for Linux/WindowsWSL OS:
14 |
15 | .. code-block::
16 |
17 | lightcurve(Target_Name, nbins=N_Bins, free_radius=Radius,
18 | use_local_ltcube=True, use_scaled_srcmap=True, free_params=['norm','shape'],
19 | shape_ts_threshold=9, multithread=True, nthread=N_cores)
20 |
21 | And the following one for Mac OS:
22 |
23 | .. code-block::
24 |
25 | lightcurve(Target_Name, nbins=N_Bins, free_radius=Radius,
26 | use_local_ltcube=True, use_scaled_srcmap=True, free_params=['norm','shape'],
27 | shape_ts_threshold=9)
28 |
29 | Where the only difference is that for Mac OS we do not parallelize the computation of the light curve. The input parameters for this function are:
30 |
31 | * **Target_Name**: This is the name of the target as listed in the adopted Fermi-LAT catalog or the target name written in the field "Target name" in the graphical interface.
32 |
33 | * **N_Bins**: The number of time bins set up in the graphical interface as "**N° of time bins**".
34 |
35 | * **Radius**: All sources within this radius (centered on the target) are free to vary in the fit. This radius is set as half of the RoI width (see :ref:`basic`) or defined by the user within the box "Radius" within the "Fine-tuning the fit" box.
36 |
37 | * **N_cores**: Number of cores read from the graphical interface as "**N° cores**".
38 |
39 | .. note::
40 |
41 | **easyfermi** will look for preexisting light curves with the same number of time bins set up in the graphical interface. If, for instance, you already produced a light curve with 20 bins, and you are asking for a new light curve with 20 bins, **easyfermi** will give you a warning in the log, and skip the light curve computation.
42 |
43 | Adaptive-binning light curve
44 | ----------------------------
45 |
46 | This method allows for the computation of a light curve with adaptive time bins, giving us much more information about the variability of the target. It requires a precomputed light curve with constant time bins, as show in the section `Constant time bins`_.
47 |
48 | Here we do a loop over every bin of the precomputed light curve and check if the TS of that bin is larger than :math:`2~\times~ TS_{Threshold}`, where :math:`TS_{Threshold}` is read from the graphical interface as "**TS threshold**". For the bins at which this condition is satisfied, we apply the ``fermipy`` function `lightcurve() `_ again with:
49 |
50 | .. code-block::
51 |
52 | N_Bins = int( (TS of the current bin)/(TS_{Threshold}) )
53 |
54 | Such that ``N_Bins`` is the lower closest integer to this ratio. For a target with a relatively constant gamma-ray emission, the new bins will all have :math:`TS \sim TS_{Threshold}`.
55 |
56 | For each new run of ``lightcurve()`` for a specific bin, we adopt the local data files (i.e. *ft1_00.fits*, *srcmap_00.fits*, *bexpmap_00* etc) produced by ``fermipy``.
57 |
58 | The parameter ``N_iter`` is read from the graphical interface as "**N° iterations**" and tells **easyfermi** how many times it should rerun the function ``lightcurve()`` in the latest light curve available. For instance, if ``N_iter = 2`` and there is no precomputed light curve, **easyfermi** will first run the constant-binning light curve (see `Constant time bins`_), then compute an adaptive-binning light curve by increasing the time resolution of the bins with :math:`TS > 2 ~\times~ TS_{Threshold}`, and then compute a third (even finer) adaptive-binning light curve by increasing the resolution of the remaining bins with :math:`TS > 2 ~\times~ TS_{Threshold}`. In summary: the higher is the value of ``N_iter``, the higher is the final resolution of the light curve.
59 |
60 |
61 |
62 | This method of computing an adaptive-binning light curve is different from the method described in `Lott et al. 2012 `_, and presents some advantages and disadvantages:
63 |
64 | **Pros:**
65 |
66 | * Analysis can be done in parallel (except for Mac OS).
67 |
68 | * Analysis becomes faster and faster at each new iteration, since we select only the bins that satisfy :math:`TS > 2 \times TS_{Threshold}`.
69 |
70 | **Cons:**
71 |
72 | * We can eventually run into upper limits, especially if we set :math:`TS_{Threshold} < 50`.
73 |
74 |
75 | .. note::
76 |
77 | We recommend setting :math:`TS_{Threshold} \geq 50`. With smaller threshold values we can achieve higher time resolution, however, we increase the probability of running into upper limits.
78 |
79 | In the figures below, we show the constant- and adaptive-binned light curves for BL Lac from 04/08/2019 15:43:36 up to 14/01/2024 15:43:00 and in the energy range 100 MeV up to 300000 MeV, during some major flaring activity. Since in this especific case we have extraordinary statistics, we set :math:`TS_{Threshold} = 5000` and 2 iterations for the adaptive-binned light curve. We see that both light curves present the same overall behavior, although in the adaptive-binned case we can recover much more information (in this specific case, the statistics is so high that we barely can see the error bars).
80 |
81 | .. image:: ./BLLac_cte.png
82 | :width: 700
83 |
84 | .. image:: ./BLLac_adaptive.png
85 | :width: 700
86 |
87 |
88 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
easyfermi
4 |
5 |
6 |
7 |
8 |
9 | 
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | [](https://github.com/ranieremenezes/easyfermi/actions/workflows/ci.yml)
19 |
20 | The easiest way to analyze Fermi-LAT data.
21 |
22 |
23 |
24 | `easyfermi` is a solution to facilitate Fermi-LAT data analysis by providing an intuitive graphical interface to interact with the Fermi science tools.
25 |
26 | If you would like to support `easyfermi`'s maintenance, consider buying us a coffee:
27 |
28 |
29 |
30 |
31 | # Requirements
32 |
33 | - Linux OS / Windows with WSL (Windows Subsystem for Linux)
34 | - [Miniconda 3](https://docs.conda.io/projects/miniconda/en/latest/),
35 | [Anaconda 3](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) or [Miniforge](https://github.com/conda-forge/miniforge) (recommended) distribution.
36 |
37 | # Installation
38 |
39 | The following instructions assume an installation of `conda` or `mamba` (i.e. a faster version of `conda`).
40 |
41 | ### Mamba-based installation
42 |
43 | In the terminal, run:
44 | mamba create --name easyfermi -c conda-forge -c fermi python=3.9 "fermitools>=2.2.0" "healpy=1.16.1" "gammapy=1.1" "scipy=1.10.1" "astropy=5.3.3" "pyqt=5.15.9" "astroquery=0.4.6" "psutil=5.9.8" "emcee=3.1.4" "corner=2.2.2" "matplotlib=3.8.2"
45 |
46 | This will create the virtual environment and install all dependencies. Then activate the environment and install _fermipy_ and _easyfermi_:
47 | mamba activate easyfermi
48 | pip install fermipy easyfermi
49 |
50 | - (ONLY FOR WINDOWS) Install the `libgl1` package:
51 | sudo apt-get install libgl1
52 |
53 | - If you want, you can set _easyfermi_ as an environmental variable. For instance, if you use a Bash shell environment, you can open the `.bashrc` file in your home and set:
54 | alias easyfermi="mamba activate easyfermi && python -c 'import easyfermi'"
55 | substituting _miniforge_ and _mamba_ by e.g. _anaconda_ and _conda_ if needed. This line of command depends on which distribution of Python you installed and how you set up the _mamba/conda_ environment.
56 |
57 | ### Installation for developers
58 |
59 | Another option to install `easyfermi` is by cloning the GitHub repository:
60 | git clone https://github.com/ranieremenezes/easyfermi.git
61 |
62 | Then change to the `easyfermi` directory and create the environment:
63 | cd easyfermi
64 | mamba env create -f environment.yml
65 | mamba activate easyfermi
66 |
67 | Install `easyfermi` in editable mode:
68 | pip install -e .
69 |
70 | # Upgrading
71 |
72 | You can check your currently installed version of `easyfermi` with _pip show_:
73 | pip show easyfermi
74 |
75 | If you have `easyfermi 2.0.X` installed, upgrade your installation to the latest version by running the following command in the _easyfermi_ environment:
76 | pip install easyfermi --upgrade --no-deps
77 |
78 | If instead, you have `easyfermi 1.X.X` installed, please install easyfermi V2 following section **Installation**.
79 |
80 |
81 | # Uninstalling
82 |
83 | In the terminal, run:
84 | mamba deactivate
85 | mamba env remove --name easyfermi
86 |
87 | # Running
88 |
89 | If you defined the variable _easyfermi_ in your shell environment (see **Installation**), simply type the following in the terminal:
90 | easyfermi
91 |
92 | Otherwise, type:
93 | mamba activate easyfermi
94 | python -c "import easyfermi"
95 |
96 | Substituting _mamba_ by _conda_ if this is the case for you.
97 |
98 | The main window of _easyfermi_ looks like this:
99 |
100 |
101 |
102 |
103 | # Tutorials and Documentation
104 |
105 | Check our tutorials on the `easyfermi` YouTube channel:
106 |
107 |
108 |
109 | 
110 |
111 |
112 |
113 | - [Learn how to analyze Fermi-LAT data under 10 min.](https://www.youtube.com/watch?v=utwvFsl67_4&t=5s&ab_channel=easyFermi)
114 | - [Saving time using an external ltcube.](https://www.youtube.com/watch?v=jaNKL3jUfy8&ab_channel=easyFermi)
115 | - [Loading a previous analysis.](https://www.youtube.com/watch?v=EnbeujVh6wA&ab_channel=easyFermi)
116 | - [Selecting specific time intervals when building the SED](https://www.youtube.com/watch?v=BG3ldxJv7t4&ab_channel=easyFermi)
117 | - [Going to the sensitivity limit of Fermi-LAT](https://www.youtube.com/watch?v=2TpgRcXf24M&ab_channel=easyFermi)
118 |
119 |
120 | The documentation of `easyfermi` can be found [here](https://easyfermi.readthedocs.io/en/latest/index.html).
121 |
122 |
123 | # Acknowledgments
124 |
125 | To acknowledge `easyfermi` in a publication, please cite [de Menezes, R (2022)](https://ui.adsabs.harvard.edu/abs/2022arXiv220611272D/abstract) and [de Menezes et al. (2025)](https://doi.org/10.5281/zenodo.17135824).
126 |
127 | Since _easyfermi_ relies on _fermipy_, _gammapy_, _astropy_, _astroquery_, and _emcee_, please also cite [Wood et al. 2017](https://ui.adsabs.harvard.edu/abs/2017ICRC...35..824W/abstract), [Donath et al. 2023](https://ui.adsabs.harvard.edu/abs/2023A%26A...678A.157D/abstract), [Astropy Collaboration et al. 2018](https://ui.adsabs.harvard.edu/abs/2018AJ....156..123A/abstract), [Ginsburg et al. 2019](https://ui.adsabs.harvard.edu/abs/2019AJ....157...98G/abstract), and [Foreman-Mackey et al. 2013](https://ui.adsabs.harvard.edu/abs/2013PASP..125..306F/abstract).
128 |
129 | The EBL models adopted in _easyfermi_ are from:
130 | - Franceschini et al. 2008 (http://adsabs.harvard.edu/abs/2008A%26A...487..837F)
131 | - Finke et al. 2010 (http://adsabs.harvard.edu/abs/2009arXiv0905.1115F)
132 | - Dominguez et al. 2011 (http://adsabs.harvard.edu/cgi-bin/bib_query?arXiv:1007.1459)
133 | - Franceschini & Rodighiero 2017 (https://ui.adsabs.harvard.edu/abs/2017A%26A...603A..34F/abstract)
134 | - Saldana-Lopez et al. 2021 (https://ui.adsabs.harvard.edu/abs/2021MNRAS.507.5144S/abstract)
135 |
136 | If you make use of EBL correction via _easyfermi_ in your publication, please cite the papers corresponding to the adopted EBL models. The EBL data files in this repository were collected from the _gammapy_ repository at https://github.com/gammapy/gammapy-data/tree/main/ebl
137 |
138 | I want to thank Clodomir Vianna for helping me with the design of _easyfermi_, for making the _easyfermi_ logo, and for the several hours of discussion about this project. Clodomir is the one responsible for making _easyfermi_ user-friendly. Thanks to Fabio Cafardo, Lucas Costa Campos, Raí Menezes, and Michele Peresano for their help and strong support to this project. A big thanks to Alessandra Azzollini, Douglas Carlos, Kaori Nakashima, Lucas Siconato, Matt Pui, and Romana Grossova, the first users/testers of _easyfermi_.
139 |
140 |
141 |
142 |
143 |
144 |
145 | # easyfermi community
146 |
147 | Want to be included in the map? Just fill out this short form: https://forms.gle/hcXoxwTHpdpHn24X8
148 |
149 | 
150 |
--------------------------------------------------------------------------------
/docs/source/Basic_analysis.rst:
--------------------------------------------------------------------------------
1 | Basic Analysis
2 | ==============
3 |
4 |
5 | .. _basic:
6 |
7 | Binned likelihood analysis
8 | --------------------------
9 |
10 | The `binned likelihood analysis `_ performed in ``easyfermi`` starts by instantiating the ``fermipy`` class `GTAnalysis `_ and feeding it with a configuration file (i.e. `'config.yaml'`) generated with the information given by the user in the graphical interface. The standard event classification and event type are set as ``evclass=128`` and ``evtype=3``, but these values can be changed by the user by checking the box **Improve resolution** or if the analysis is done in the **Custom** mode.
11 |
12 | The region of interest (RoI) width and zenith angle (:math:`z_{max}`) cut adopted in the **Standard** mode of ``easyfermi`` depend on the minimum energy set up in the graphical interface. In summary, if
13 |
14 | - :math:`E_{min} < 100` MeV, the RoI width is set to 17°, and :math:`z_{max} = 80°`.
15 | - :math:`100 \leq E_{min} < 500` MeV, the RoI width is set to 15°, and :math:`z_{max} = 90°`.
16 | - :math:`500 \leq E_{min} < 1000` MeV, the RoI width is set to 12°, and :math:`z_{max} = 100°`.
17 | - :math:`E_{min} \geq 1000` MeV, the RoI width is set to 10°, and :math:`z_{max} = 105°`.
18 |
19 | For all these cases, we also include in the model all the cataloged sources lying in a region 10° larger than the width of the RoI (i.e. we set **src_roiwidth : roi_width + 10** in the configuration file). All these values can be changed by the user in the **Custom** mode of ``easyfermi``. Similarly, the data downloaded directly from the graphical interface contain photons within a region with radius :math:`14°~\mathrm{if}~E_{min} < 100` MeV, :math:`12°~\mathrm{if}~~100 \leq E_{min} < 500` MeV, :math:`11°~\mathrm{if}~~500 \leq E_{min} < 1000` MeV, and :math:`9°~\mathrm{if}~E_{min} \geq 1000` MeV. Furthermore, if the box **Improve sensitivity** is checked, the data will be split into 2 or 3 energy components (depending on :math:`E_{min}`) and :math:`z_{max}` will then assume the values shown above for each one of these components (if :math:`E_{min} < 500` MeV, the lowest energy component will have :math:`z_{max} = 90°` if :math:`E_{min} \geq 100` MeV, and :math:`z_{max} = 80°` otherwise).
20 |
21 | The remaining **Standard** configuration of ``easyfermi`` is:
22 |
23 | - edisp : True, for the energy dispersion.
24 | - irfs : 'P8R3_SOURCE_V3', for the instrument response function.
25 | - edisp_disable : ['isodiff'], to disable the energy dispersion correction in the isotropic component.
26 | - edisp_bins : -2, to add two extra energy bins when accounting for energy dispersion.
27 |
28 | All the intermediate analsyis files, such as ccube, ltcube, srcmaps, and exposure map are generated with the ``fermipy`` function ``setup()``. Once the setup is done, ``easyfermi`` computes a counts map (saved in the output directory as cmap.fits) by summing all the energy components of the ccube.fits file.
29 |
30 | .. note::
31 |
32 | - For analyses in a time window larger than 1 year, the computation of the ltcube can take several hours to finish. In extreme situations, e.g. if you ara analyzing 14 years of data and check the box "improve sensitivity" on the graphical interface, the computation of the ltcube can take more than 20 hours.
33 | - If you want to analyze different targets **in the same time window and energy interval**, you don't need to compute the ltcube multiple times. You compute it once, and for the subsequent analyses you can simply import the ltcube list file (called "ltcube_list.txt" and saved in the output directory) under the checkbox "Use external ltcube".
34 |
35 | The next step in the analysis is calling the ``fermipy`` function `optimize() `_ with the following configuration:
36 |
37 | .. code-block::
38 |
39 | optimize(npred_frac=0.95, npred_threshold=50, shape_ts_threshold=30)
40 |
41 | This function optimizes the RoI model in three sequential steps:
42 |
43 | - Free the normalization of the N largest components (as determined from NPred) that contain a fraction *npred_frac* of the total predicted counts in the model and perform a simultaneous fit of the normalization parameters of these components.
44 | - Individually fit the normalizations of all sources that were not included in the first step in order of their *Npred* values. Skip any sources that have `NPred < npred_threshold`.
45 | - Individually fit the shape and normalization parameters of all sources with `TS > shape_ts_threshold` where TS is determined from the first two steps of the ROI optimization.
46 |
47 |
48 | After the optimization, we give the option to the user to call the ``fermipy`` function `find_sources() `_ (by checking the box **Find extra sources in the ROI**, as shown in the figure below) with the following configuration:
49 |
50 | .. code-block::
51 |
52 | find_sources(sqrt_ts_threshold=Minimum_significance, min_separation=Minimum_separation, multithread=True)
53 |
54 | which will look for possible non-cataloged gamma-ray sources by generating a TS map for the RoI and identify peaks with :math:`\sqrt{TS} >` *Minimum_significance* and an angular separation of at least *Minimum_separation* from a higher amplitude peak in the TS map. This method can run several times until no sources with :math:`sqrt(TS) >` *Minimum_significance* are found. The values for *Minimum_significance* and *Minimum_separation* can be defined by the user in the graphical interface.
55 |
56 | .. image:: ./easyfermi_find_sources.png
57 | :width: 700
58 |
59 | The standard fit in ``easyfermi`` is done with the ``fermipy`` function `fit() `_ with ``NewMinuit`` as the optimizer, although this can be changed by the user in the checkbox **Change optimizer**. The radius within which the parameters of all sources are free to vary (normalization and spectral shape) is set as half the RoI width (see the second paragraph of this section), but can be changed by the user in the panel **Free source radius**, under the **Customized** button. The adopted spectral model for the target will be that listed in the selected *Fermi*-LAT catalog (default is 4FGL-DR3) or a power law if the target is not listed in the selected catalog. This model can be changed at any time by the user under the box **Change model**, and the complete description of all available models can be found `here `_.
60 |
61 | If the fit does not converge, ``easyfermi``:
62 |
63 | - deletes all sources with :math:`TS < TS_{cut}` from the RoI or...
64 | - deletes all sources with :math:`TS < TS_{target}` if :math:`TS_{target} < TS_{cut}`.
65 | - reruns the fit.
66 |
67 | The default value for :math:`TS_{cut}` is 16, but the user can change this value in panel **Fine-tuning the fit** in the graphical interface.
68 |
69 | If even after that the fit does not converge, the user can freely modify the parameters in the panel **Fine-tuning the fit** and rerun the analysis.
70 |
71 | .. note::
72 |
73 | The :math:`TS_{target}` threshold was fixed at 25 until ``easyfermi 2.0.7``.
74 |
75 | Once the RoI fit is done, the results are saved in the output directory in the file *Target_results.txt* (for a quick look at the target parameters) and in the file *Results.fits* (for all sources in the RoI).
76 |
77 |
78 | Non-cataloged target
79 | --------------------
80 |
81 | If your target is not listed in the adopted *Fermi*-LAT catalog, you have to set the combo box **Target cataloged/name** to **No** (see figure below) and give a nickname to your target. It can be any name you want. This target will be added as a point-source with a power-law spectrum, but you can change this spectral model under the box **Change model**.
82 |
83 | .. image:: ./easyfermi_notcataloged.png
84 | :width: 700
85 |
86 | Diagnostic plots
87 | ----------------
88 |
89 | If the box **Diagnostic plots** is checked (see figure below), all of the diagnostic plots created by ``fermipy`` are saved in the output directory, such as the model map, the excess map, the y and x counts profile, etc.
90 |
91 | .. image:: ./easyfermi_diagnostic.png
92 | :width: 700
93 |
94 | The novelty diagnostic plot of ``easyfermi`` is the angular separation between the target and the Sun within the given time window. We compute this separation based on the data available in the *Fermi*-LAT spacecraft file and using the ``astropy`` class `SkyCoord() `_. This plot is useful, e.g., to look for possible solar contamination on your SED or light curve. In the figure below, we show the diagnostic plot for the angular separation between the target 1LHAASO J1219+2915 and the Sun over the period of ~3 years.
95 |
96 | .. image:: ./Sun_path_1LHAASO_J1219+2915.png
97 | :width: 700
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/docs/source/SED.rst:
--------------------------------------------------------------------------------
1 | Spectral energy distribution (SED)
2 | ==================================
3 |
4 | .. image:: ./easyfermiSED.png
5 | :width: 700
6 |
7 | .. _Standar SED:
8 |
9 | Standard SED
10 | ------------
11 |
12 | The standard SED generated with **easyfermi** uses the ``fermipy`` function `sed() `_ with the following configuration:
13 |
14 | .. code-block::
15 |
16 | sed(Target_Name,loge_bins=N_energy_bins,make_plots=False,use_local_index=use_local_index,write_npy=False)
17 |
18 |
19 | Where the input parameters are:
20 |
21 | * **Target_Name**: This is the name of the target as listed in the adopted Fermi-LAT catalog or the target name written in the field "Target name" in the graphical interface.
22 |
23 | * **N_energy_bins**: The number of energy bins set up in the graphical interface as "**N° of energy bins**".
24 |
25 | * **use_local_index**: If the box **Use local index** is checked in the graphical interface, we use a power-law approximation to the shape of the global spectrum in each bin. If not checked, then a constant index, :math:`\gamma = 2`, will be adopted for all energy bins.
26 |
27 | The parameters **make_plots** and **write_npy** are always set as **False** in **easyfermi**. For more details on them, see the `fermipy sed documentation `_.
28 |
29 |
30 | Extragalactic background light (EBL) absorption correction
31 | ----------------------------------------------------------
32 |
33 | This method corrects the EBL absorption observed in the highest energy bins in the SEDs of extragalactic targets using the ``gammapy`` class `EBLAbsorptionNormSpectralModel `_. This correction will be applied to any analysis as long as the box **Redshift** has a value above zero. The user can then select which EBL absorption model to use, where the options are:
34 |
35 | - `Franceschini et al. 2008 `_.
36 | - `Finke et al. 2010 `_.
37 | - `Dominguez et al. 2011 `_.
38 | - `Franceschini & Rodighiero 2017 `_.
39 | - `Saldana-Lopez et al. 2021 `_.
40 |
41 | If this correction is applied, the MCMC estimation (see Section `MCMC`_) of parameters will be performed in the corrected SED.
42 |
43 |
44 | .. _MCMC:
45 |
46 | Markov Chain Monte Carlo (MCMC)
47 | -------------------------------
48 |
49 | The estimation of parameters with MCMC in ``easyfermi`` is done with `emcee `_ and it requires a minimum number of 3 data points with :math:`TS > 9`. The likelihood function that we maximize in ``easyfermi`` is given by:
50 |
51 | :math:`\mathcal{L} = - \frac{1}{2}\sum_n\left[ \frac{(y_n - f(\vec\theta,x_n))^2}{\sigma_n^2} \right]`
52 |
53 | where the sum is performed over all data points with :math:`TS > 9`, :math:`y_n` and :math:`x_n` are the y (differential flux) and x (energy) values for each data point, :math:`\sigma_n` is the error associated with the :math:`y` component of each data point, and :math:`f(\vec\theta,x_n)` is the adopted specral model feeded with a set of parameters :math:`\vec\theta`.
54 |
55 | The spectral models available for the MCMC are:
56 |
57 | - **PowerLaw**: :math:`\frac{dN}{dE} = N_0\left(\frac{E}{E_0} \right)^{-\alpha}`, i.e the classical power-law function, where :math:`\frac{dN}{dE}` is in units of :math:`\mathrm{cm}^{-2}\mathrm{s}^{-1}\mathrm{MeV}^{-1}`, :math:`E` is in MeV, and the priors are -15 < :math:`\log(N_0)` < -8 and 0.5 < :math:`\alpha` < 5.0.
58 |
59 | - **LogPar**: :math:`\frac{dN}{dE} = N_0\left(\frac{E}{E_0} \right)^{-\alpha -\beta\log(E/E_0)}`, i.e. the classical log-parabola function, where :math:`\frac{dN}{dE}` is in units of :math:`\mathrm{cm}^{-2}\mathrm{s}^{-1}\mathrm{MeV}^{-1}`, :math:`E` is in MeV, and the priors are set to -15 < :math:`\log(N_0)` < -8, 1.0 < :math:`\alpha` < 4.0, and -1 < :math:`\beta` < 1.0.
60 |
61 | - **LogPar_MTT**: :math:`S(E) = S_p10^{-\alpha\log^2_{10}(E/E_p)}`, which is another parametrization of the log-parabola, conveniently giving us the differential energy flux at the log-parabola peak, :math:`S_p` [MeV :math:`\mathrm{cm}^{-2}\mathrm{s}^{-1}`], the position of this peak in the energy axis, :math:`E_p` [MeV], and the spectral curvature :math:`\alpha`. The priors are set to -7 < :math:`\log(S_p)` < -1, -1.0 < :math:`\alpha` < 1.0, and 2 < :math:`E_p` < 7. The suffix "MTT" stands for Massaro et al. (2004), Tanihata et al. (2004), and Tramacere et al. (2007), which are the first works reporting this parametrization of the log-parabola curve.
62 |
63 | - **PLEC**: :math:`\frac{dN}{dE} = N_0\left(\frac{E}{E_0} \right)^{-\alpha} e^{-(E/E_0)^b}`, i.e. a power-law with a super exponential cutoff, where :math:`\frac{dN}{dE}` is in units of :math:`\mathrm{cm}^{-2}\mathrm{s}^{-1}\mathrm{MeV}^{-1}` and :math:`E` is in MeV. The priors are set to -15 < :math:`\log(N_0)` < -8, 1.0 < :math:`\alpha` < 4.0, 3.0 < :math:`E_c` < 7.0, and 0.2 < :math:`b` < 3.0.
64 |
65 | - **PLEC_bfix**: same as above, but with :math:`b \equiv 1`.
66 |
67 | - **PLEC_deMenezes**: :math:`S(E) = S_p\left(\frac{E_p}{E} \right)^{\alpha-2} e^{((2-\alpha)/b)(1-(E/E_p)^b)}`, which is a parametrization of the PLEC developed for ``easyfermi`` conveniently giving us the differential energy flux at the PLEC peak, :math:`S_p` [MeV :math:`\mathrm{cm}^{-2}\mathrm{s}^{-1}`], the position of this peak in the energy axis, :math:`E_p` [MeV], the power law spectral index :math:`\alpha`, and the super-exponential index :math:`b`. With this model one can directly estimate :math:`S_p`, :math:`E_p`, and their corresponding errors without recurring to huge error propagation formulas. If you use this parametrization in another context, please cite the ``easyfermi`` paper `de Menezes (2022) `_ and this documentation. The priors are set to -8 < :math:`\log(S_p)` < -1, 0 < :math:`\alpha` < 4.0, 2.0 < :math:`E_p` < 7.0, and 0.01 < :math:`b` < 3.0.
68 |
69 | Finally, we adopt 300 walkers, iterate them 500 times, and fix :math:`E_0 \equiv E_{min}`, where :math:`E_{min}` is read from the graphical interface or from the customized configuration file.
70 |
71 |
72 | .. note::
73 |
74 | The upper limits (i.e. any energy bin with TS < 9) are not included in the MCMC parameter estimation.
75 |
76 |
77 |
78 | VHE table format
79 | ----------------
80 |
81 | The format of the VHE data table is a standard SED table produced with ``gammapy`` 1.1.
82 |
83 | It will work with any **.fits** table, as long as this table contains the following columns in the first extension HDU (e.g. hdul[1].data):
84 |
85 | - **e_ref**, **e_min**, and **e_max**, all in TeV
86 | - **e2dnde**, **e2dnde_err**, **e2dnde_ul**, all in TeV cm-2 s-1
87 | - **ts**
88 |
89 | In the figure below we show you how this table should look like (this is actually **fake** data for Mrk 421).
90 |
91 | .. image:: ./VHE_table.png
92 | :width: 700
93 |
94 |
95 | Model selection with the Akaike information criterion
96 | -----------------------------------------------------
97 |
98 | As a tool for model selection, ``easyfermi`` provides the `Akaike information criterion (AIC) `_. The AIC is printed in the ``easyfermi`` log and saved in the files *Target_results.txt* and *TARGET_NAME_sed.fits*.
99 |
100 | We use a slightly modified form of this method defined as:
101 |
102 | :math:`AIC = 2k + 2ln(-\mathcal{L}_{max})`,
103 |
104 | where *k* is the number of free parameters in the given model, and :math:`\mathcal{L}_{max}` is the maximized likelihood function defined above.
105 |
106 | Given a set of candidate models for the data, the preferred model is the one with the minimum AIC value. For the same dataset, two spectral models can be compared by the following expression:
107 |
108 | :math:`e^{(AIC_{min} − AIC_{test})/2}`.
109 |
110 | For instance, let's suppose that you have the spectral data for Mrk 421 and you try to fit this data with a power law (PL) and then with a log-parabola (LP). Let's also suppose that :math:`AIC_{PL} = 6.1` and :math:`AIC_{LP} = 7.5`. Since the minimum AIC is achieved for the PL model, this means that the LP model is
111 |
112 | :math:`e^{(6.1 − 8.5)/2} = 0.301` times as probable as the power-law model to minimize the information loss.
113 |
114 |
115 | Data points with less than 5 photons
116 | ------------------------------------
117 |
118 | The likelihood ratio method adopted in the fermitools, fermipy and easyfermi attributes higher significance to higher energy photons, such that a couple of photons with energies > 100 GeV can easily reach TS > 25. For source detection, this is perfectly fine, since the background at these energies is relatively low and the photon/hadron separation and direction reconstructed by LAT are much better than at low energies (e.g. below 1 GeV). This means that if you detect 2 photons with more than 100 GeV coming from the same position in the sky, it is indeed very likely that there is a gamma-ray source there.
119 |
120 | There is, however, a subtle but important difference between being able to detect a source and being able to measure its flux. When trying to build an SED, for instance, the highest-energy bins may have only a few photons and still give you relatively high TSs. In the figure below, we show the spectrum of Mrk 421 observed over 2 months. We see that the highest-energy bins have TSs ~ 60, although we have only 2 or 3 photons for each bin. The differential flux measurements with such a low number of photons is prone to strong fluctuations that can possibly affect the modeling of the SED. Furthermore, we cannot trust statistical error bars if the measurement is not done in a statistically valid sample (i.e. a large number of counts).
121 |
122 | In easyfermi, we warn the users about this issue by checking how many photons within a radius of 0.5° from the RoI center are detected for all the SED bins with energies > 10 GeV. If a specific bin has less than 5 photons, it will apear as a magenta point in the SED quickplot. These warnings are saved in the column "Warning_few_photons" in the TARGET_NAME_sed.fits file and can help the users in the task of selecting or not these data points when trying to fit a model.
123 |
124 | .. image:: ./SED_Mrk421_GitHub.png
125 | :width: 700
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/docs/source/custom_analysis.rst:
--------------------------------------------------------------------------------
1 | Custom analysis
2 | ===============
3 |
4 | .. role:: raw-html(raw)
5 | :format: html
6 |
7 | .. image:: ./easyfermi_window_custom.png
8 | :width: 700
9 |
10 | .. _Custom:
11 |
12 | Here we give you some examples on how to customize your analysis with ``easyfermi``. In summary, you simply have to modify a configuration file and upload it in the ``easyfermi`` window as indicated in the figure above.
13 |
14 | If you don't know where to start with your own configuration file, you can add the coordinates (or name), desired energy and time ranges, and the paths to the data files under the "Standard" button in the ``easyfermi`` main window and then click in the button "Generate config file". This action will generate a 'config.yaml' file within the output directory, allowing you full flexibility to customize it according to your preferences.
15 |
16 | .. note::
17 |
18 | If you check the boxes "Improve resolution" and/or "Improve sensitivity", the config.yaml file generated with the button "Generate config file" will be modified accordingly.
19 |
20 |
21 | Below we give you some examples of customized configuration files.
22 |
23 | Precise selection of time intervals
24 | -----------------------------------
25 |
26 | `Tutorial available on YouTube `_.
27 |
28 | Let's suppose you want to build the average SED for 3 specific time windows for BL Lac. In this case, the only feature you need to add to the "config.yaml" file is the line "filter", as indicated in the highlighted line below.
29 |
30 |
31 | .. code-block::
32 | :emphasize-lines: 20
33 |
34 | data:
35 | evfile : /home/user/Documentos/GUI/Tutorials/BLLac/Output/list.txt
36 | scfile : /home/user/Documentos/spacecraft/L240206050150320729A098_SC00.fits
37 |
38 | binning:
39 | roiwidth : 15
40 | binsz : 0.1
41 | binsperdec : 8
42 |
43 | selection :
44 | emin : 100.0
45 | emax : 300000.0
46 | zmax : 90
47 | evclass : 128
48 | evtype : 3
49 | ra: 330.68038041666665
50 | dec: 42.277771944444446
51 | tmin: 638496005
52 | tmax: 655776005
53 | filter: '((START>6.40997722E8) && (STOP<6.41582362E8)) || ((START>6.4909916E8) && (STOP<6.4943324E8)) || ((START>6.4943324E8) && (STOP<6.4976732E8))'
54 |
55 | gtlike:
56 | edisp : True
57 | irfs : 'P8R3_SOURCE_V3'
58 | edisp_disable : ['isodiff']
59 | edisp_bins : -2
60 |
61 | model:
62 | src_roiwidth : 25
63 | galdiff : '/home/user/Documentos/Background_Models/gll_iem_v07.fits'
64 | isodiff : '/home/user/Documentos/Background_Models/iso_P8R3_SOURCE_V3_v1.txt'
65 | catalogs : ['4FGL-DR3']
66 |
67 |
68 |
69 | Customized resolution and better SED for a target on the Galactic plane
70 | -----------------------------------------------------------------------
71 |
72 | At the cost of decreasing the sensitivity, you can cut the photons with worst positional reconstruction from your dataset by selecting only the photons lying within the best PSF quartiles (`details here `_.)
73 |
74 | Below we give the example of a config.yaml file generated with the button "Generate config file" for Mrk 501, and then we discuss how you can modify it to analyze the data that better suits your goals.
75 |
76 | This config.yaml file was generated with the boxes "Improve resolution" and "Improve sensitivity" checked. Checking the box "Improve sensitivity" for such a large energy range (i.e. from 100 MeV up to 800 GeV), means that we will perform the Fermi-LAT analysis for three different energy components, tuned to improve sensitivity at the highest energies (see :doc:`Basic_analysis`).
77 |
78 | .. note::
79 |
80 | Even if you are not interested in a better resolution, you can use this method to improve the quality of your low energy (i.e. < 500 MeV) SED data points. For instance, if your target is in the Galactic plane, where the contamination levels are very high at low energies, a standard analysis eventually gives you an SED where the lowest energy data points seem too high to be true (e.g. more than :math:`3\sigma` away from the fitted model). This happens because several badly reconstructed photons that do not belong to your target are being swallowed into your analysis. So if you are analyzing a strong source in the Galactic plane, it is typically a good idea to remove the low-energy photons with the worst reconstruction (i.e. PSF0) from your analysis.
81 |
82 | .. code-block::
83 |
84 | data:
85 | evfile : /home/user/Documentos/GUI/easyFermi/code/LHAASO_counterparts/Output_Mrk501/list.txt
86 | scfile : /home/user/Documentos/GUI/easyFermi/code/LHAASO_counterparts/spacecraft/L240204110942320729A088_SC00.fits
87 |
88 | binning:
89 | roiwidth : 15
90 | binsz : 0.1
91 | binsperdec : 8
92 |
93 | selection :
94 | emin : 100.0
95 | emax : 800000.0
96 | zmax : 90
97 | evclass : 128
98 | evtype : 48
99 | ra: 253.46756916666664
100 | dec: 39.76016888888889
101 | tmin: 636249601
102 | tmax: 686275200
103 |
104 | gtlike:
105 | edisp : True
106 | irfs : 'P8R3_SOURCE_V3'
107 | edisp_disable : ['isodiff']
108 | edisp_bins : -2
109 |
110 | model:
111 | src_roiwidth : 25
112 | galdiff : '/home/user/Documentos/Background_Models/gll_iem_v07.fits'
113 | isodiff : '/home/user/Documentos/Background_Models/iso_P8R3_SOURCE_V3_v1.txt'
114 | catalogs : ['4FGL-DR3']
115 |
116 | components:
117 | - model:
118 | galdiff : '/home/user/Documentos/Background_Models/gll_iem_v07.fits'
119 | isodiff : '/home/user/Documentos/Background_Models/iso_P8R3_SOURCE_V3_v1.txt'
120 | selection:
121 | emin : 100.0
122 | emax : 500
123 | zmax : 90
124 | evtype : 48
125 | - model:
126 | galdiff : '/home/user/Documentos/Background_Models/gll_iem_v07.fits'
127 | isodiff : '/home/user/Documentos/Background_Models/iso_P8R3_SOURCE_V3_v1.txt'
128 | selection:
129 | emin : 500
130 | emax : 1000
131 | zmax : 100
132 | evtype : 56
133 | - model:
134 | galdiff : '/home/user/Documentos/Background_Models/gll_iem_v07.fits'
135 | isodiff : '/home/user/Documentos/Background_Models/iso_P8R3_SOURCE_V3_v1.txt'
136 | selection:
137 | emin : 1000
138 | emax : 300000.0
139 | zmax : 105
140 | evtype : 3
141 |
142 | We see that for the lowest-energy component (i.e. 100 MeV up to 500 MeV), we use only PSF 2 and 3 events (i.e. `evtype = 48`), equivalent to 50% of all photons detected in this energy range, while in the medium energy range (i.e. from 500 MeV up to 1 GeV), we use PSF 1, 2 and 3 (`evtype = 56`), equivalent to 75% of all photons detected in this energy band. So let's suppose you prefer to include all photons with more than 500 MeV in your analysis (i.e. `evtype : 3`). The only thing you need to do is to modify the highlighted line in the following part of the file:
143 |
144 | .. code-block:: yaml
145 | :emphasize-lines: 9
146 |
147 | [...]
148 | - model:
149 | galdiff : '/home/user/Documentos/Background_Models/gll_iem_v07.fits'
150 | isodiff : '/home/user/Documentos/Background_Models/iso_P8R3_SOURCE_V3_v1.txt'
151 | selection:
152 | emin : 500
153 | emax : 1000
154 | zmax : 100
155 | evtype : 3
156 | [...]
157 |
158 | But how do you know which `evtype` number to choose for different PSF selections? The detailed answer is provided `here `_.
159 |
160 | You can also play with the zenith angle cut. The recommended zenith angle cuts (zmax in the config.yaml file) selections have been optimized to reduce the limb contamination to a negligible level (< 5% of the total diffuse emission at high latitudes). For diffuse analysis more restrictive selections may be required. For `evtype = 3`, the recommended zenith angle cuts are:
161 |
162 | * 80°, for :math:`E_{min} > 50` MeV
163 | * 90°, for :math:`E_{min} > 100` MeV
164 | * 95°, for :math:`E_{min} > 200` MeV
165 | * 100°, for :math:`E_{min} > 300` MeV
166 | * 100°, for :math:`E_{min} > 500` MeV
167 |
168 | For :math:`E_{min} > 1` GeV, it is common practice to set zmax = 105, but try avoiding zenith angle cuts larger than that.
169 |
170 |
171 | Customized extended emission
172 | ----------------------------
173 |
174 | `easyfermi` provides the users with two simple spatial models for extended emission, which are a disk and a 2D Gaussian. If you want to do your own spatial model, please see :ref:`Extension_advanced`.
175 |
176 |
177 |
178 | Adjusting the parameter ranges of a spectral model
179 | --------------------------------------------------
180 |
181 |
182 | Let's say you want to modify the values and/or ranges for the parameters in a spectral model before performing the fit. Here are the steps you must follow:
183 |
184 | * If your target is listed in the adopted FGL catalog, you must delete it from the model using the check-box "Delete sources". E.g. if your RoI is centered on the source 4FGL J2202.7+4216, you can do as in the figure below:
185 |
186 | .. image:: ./easyfermi_window_delete_source.png
187 | :width: 700
188 |
189 | * Now manually add your target to the config.yaml file setting the parameter values and ranges as you prefer. This name **cannot contain blank spaces** as e.g. "NGC 1022", **neither it can be listed in the adopted Fermi-LAT catalog**, as e.g. "Mkn_421", so please give it single name not listed in the LAT catalog, like "SourceA", "NGC_1022", "Super_duper_Mkn_421", or something else in this line. In the figure below we show the example for a power-law model:
190 | .. code-block::
191 |
192 | data:
193 | evfile : /home/user/Documentos/GUI/Tutorials/BLLac/Output/list.txt
194 | scfile : /home/user/Documentos/spacecraft/L240206050150320729A098_SC00.fits
195 |
196 | binning:
197 | roiwidth : 15
198 | binsz : 0.1
199 | binsperdec : 8
200 |
201 | selection :
202 | emin : 100.0
203 | emax : 300000.0
204 | zmax : 90
205 | evclass : 128
206 | evtype : 3
207 | ra: 330.68038041666665
208 | dec: 42.277771944444446
209 | tmin: 638496005
210 | tmax: 655776005
211 | filter: '((START>6.40997722E8) && (STOP<6.41582362E8)) || ((START>6.4909916E8) && (STOP<6.4943324E8)) || ((START>6.4943324E8) && (STOP<6.4976732E8))'
212 |
213 | gtlike:
214 | edisp : True
215 | irfs : 'P8R3_SOURCE_V3'
216 | edisp_disable : ['isodiff']
217 | edisp_bins : -2
218 |
219 | model:
220 | src_roiwidth : 25
221 | galdiff : '/home/user/Documentos/Background_Models/gll_iem_v07.fits'
222 | isodiff : '/home/user/Documentos/Background_Models/iso_P8R3_SOURCE_V3_v1.txt'
223 | catalogs : ['4FGL-DR3']
224 | sources :
225 | - { name: 'SourceA', ra : 330.68038, dec : 42.27777,
226 | SpectrumType : 'PowerLaw',
227 | Prefactor : {value: 1.0, scale : !!float 1e-11, free : "1", max : "1000", min : "1e-03"},
228 | Index : {value: 2.0, scale : "-1", free : "1", max : "3", min : "1.5"},
229 | SpatialModel: 'PointSource' }
230 |
231 | * If instead of a power-law you are interested in a log-parabola or PLEC (equivalent to PLSuperExpCutoff in the LAT spectral models), you can change the last part of the configuration file to:
232 |
233 | .. code-block::
234 |
235 | [...]
236 |
237 | model:
238 | src_roiwidth : 25
239 | galdiff : '/home/user/Documentos/Background_Models/gll_iem_v07.fits'
240 | isodiff : '/home/user/Documentos/Background_Models/iso_P8R3_SOURCE_V3_v1.txt'
241 | catalogs : ['4FGL-DR3']
242 | sources :
243 | - { name: 'SourceA', ra : 330.68038, dec : 42.27777,
244 | SpectrumType : 'LogParabola',
245 | norm : {value: 1.0, scale : !!float 1e-11, free : "1", max : "1000", min : "1e-03"},
246 | alpha : {value: 2.0, scale : "1", free : "1", max : "3", min : "1.5"},
247 | beta : {value: 0.1, scale : "1", free : "1", max : "1", min : "0"},
248 | SpatialModel: 'PointSource' }
249 |
250 | or
251 |
252 | .. code-block::
253 |
254 | [...]
255 |
256 | model:
257 | src_roiwidth : 25
258 | galdiff : '/home/user/Documentos/Background_Models/gll_iem_v07.fits'
259 | isodiff : '/home/user/Documentos/Background_Models/iso_P8R3_SOURCE_V3_v1.txt'
260 | catalogs : ['4FGL-DR3']
261 | sources :
262 | - { name: 'SourceA', ra : 330.68038, dec : 42.27777,
263 | SpectrumType : 'PLSuperExpCutoff',
264 | Prefactor : {value: 1.0, scale : !!float 1e-11, free : "1", max : "1000", min : "1e-03"},
265 | Index1 : {value: 2.0, scale : "1", free : "1", max : "3", min : "1.5"},
266 | Cutoff : {value: 1, scale : "1e+04", free : "1", max : "100", min : "0.01"},
267 | Index2 : {value: 0.1, scale : "1", free : "1", max : "4", min : "0"},
268 | SpatialModel: 'PointSource' }
269 |
270 | * For other spectral models you can follow the exact nomenclature of parameters found in the `LAT Source Model Definitions `_. The equiavalencies between easyfermi and Fermitools spectral models are 'Power-law': 'PowerLaw', 'Power-law2': 'PowerLaw2', 'LogPar': 'LogParabola', 'PLEC': 'PLSuperExpCutoff', 'PLEC2': 'PLSuperExpCutoff2', 'PLEC3': 'PLSuperExpCutoff3', 'PLEC4': 'PLSuperExpCutoff4', 'BPL': 'BrokenPowerLaw', 'ExpCutOff-EBL': 'ExpCutoff'.
271 |
272 | * Now upload your modified configuration file under the button "Custom" and press "Go!". That's all.
273 |
--------------------------------------------------------------------------------