Skip to content

Commit

Permalink
Merge branch 'main' into feature/runlist_configs
Browse files Browse the repository at this point in the history
# Conflicts:
#	pyV2DL3/vegas/fillEVENTS_not_safe.py
  • Loading branch information
deividribeiro committed Dec 11, 2024
2 parents 4d1d474 + 1a7d569 commit 92681b7
Show file tree
Hide file tree
Showing 28 changed files with 169 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.ipynb filter=nbstrip_full
*.ipynb filter=nbstrip_full
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Set update schedule for GitHub Actions

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"

4 changes: 2 additions & 2 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# make sure we have version info
- run: git fetch --tags

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/v2dl3-codeChecking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
python-version: [3.8]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/v2dl3-eventdisplay-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
flavor: latest=true

- name: Build and push Docker image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
build-args: BUILD_BRANCH=${{ env.BUILD_BRANCH }}
Expand Down
37 changes: 15 additions & 22 deletions .github/workflows/v2dl3-eventdisplay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,21 @@ jobs:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install mamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment-eventdisplay.yml
create-args: python=${{ matrix.python-version }}
init-shell: bash
- name: Pip install
run: |
pip install .[tests]
- name: pytest
shell: bash -leo pipefail {0}
env:
PYTHONPATH: .
run: |
pytest .
Expand All @@ -51,16 +46,14 @@ jobs:
- name: Eventdisplay-pointlike
shell: bash -leo pipefail {0}
env:
PYTHONPATH: .
run: |
# point-like tests
python pyV2DL3/script/v2dl3_for_Eventdisplay.py \
v2dl3-eventdisplay \
-f ./64080.anasum.root \
./effectiveArea.root \
--logfile test-pointlike.fits.log \
test-pointlike-CI.fits.gz
python pyV2DL3/script/compareFitsFiles.py \
v2dl3-compareFitsFiles \
-f ED-pointlike-CI.fits.gz test-pointlike-CI.fits.gz \
-d test-pointlike.log
cat test-pointlike.log
Expand All @@ -72,12 +65,12 @@ jobs:
PYTHONPATH: .
run: |
# full-enclosure tests
python pyV2DL3/script/v2dl3_for_Eventdisplay.py --full-enclosure \
v2dl3-eventdisplay --full-enclosure \
-f ./64080.anasum.root \
./effectiveArea.root \
--logfile test-full-enclosure.fits.log \
test-full-enclosure-CI.fits.gz
python pyV2DL3/script/compareFitsFiles.py \
v2dl3-compareFitsFiles \
-f ED-fullenclosure-CI.fits.gz test-full-enclosure-CI.fits.gz \
-d test-full-enclosure.log
cat test-full-enclosure.log
Expand All @@ -89,13 +82,13 @@ jobs:
PYTHONPATH: .
run: |
# point-like tests (with DB)
python pyV2DL3/script/v2dl3_for_Eventdisplay.py \
v2dl3-eventdisplay \
-f ./64080.anasum.root \
./effectiveArea.root \
--db_fits_file ./64080.db.fits.gz \
--logfile test-pointlike-db.fits.log \
test-pointlike-db-CI.fits.gz
python pyV2DL3/script/compareFitsFiles.py \
v2dl3-compareFitsFiles \
-f ED-pointlike-db-CI.fits.gz test-pointlike-db-CI.fits.gz \
-d test-pointlike-db.log
cat test-pointlike-db.log
Expand All @@ -107,13 +100,13 @@ jobs:
PYTHONPATH: .
run: |
# point-like tests with event selection
python pyV2DL3/script/v2dl3_for_Eventdisplay.py \
v2dl3-eventdisplay \
-f ./64080.allevents.anasum.root \
./effectiveArea.root \
--evt_filter eventfilter.yml \
--logfile test-pointlike-all.fits.log \
test-pointlike-all-CI.fits.gz
python pyV2DL3/script/compareFitsFiles.py \
v2dl3-compareFitsFiles \
-f ED-pointlike-all-CI.fits.gz test-pointlike-all-CI.fits.gz \
-d test-pointlike-all.log
cat test-pointlike-all.log
Expand All @@ -125,13 +118,13 @@ jobs:
PYTHONPATH: .
run: |
# full-enclosure tests with event selection
python pyV2DL3/script/v2dl3_for_Eventdisplay.py --full-enclosure \
v2dl3-eventdisplay --full-enclosure \
-f ./64080.allevents.anasum.root \
./effectiveArea.root \
--evt_filter eventfilter.yml \
--logfile test-full-enclosure-all.fits.log \
test-full-enclosure-all-CI.fits.gz
python pyV2DL3/script/compareFitsFiles.py \
v2dl3-compareFitsFiles \
-f ED-full-enclosure-all-CI.fits.gz test-full-enclosure-all-CI.fits.gz \
-d test-full-enclosure-all.log
cat test-full-enclosure-all.log
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/v2dl3-vegas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout new branch
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Pull docker image
run: |
Expand All @@ -55,7 +55,7 @@ jobs:
sudo rm -rf $GITHUB_WORKSPACE/*
- name: Checkout main branch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: main

Expand Down
40 changes: 36 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
repos:
# https://pycqa.github.io/isort/docs/configuration/black_compatibility.html#integration-with-pre-commit
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html?highlight=other%20tools#flake8
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.1.1
hooks:
- id: flake8
args: ["--max-line-length=100", "--extend-ignore=E203,E712"]
args: ["--max-line-length=125", "--extend-ignore=E203,E712"]
# https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
args: ['--maxkb=500']
# Github action
- repo: https://github.com/rhysd/actionlint
rev: v1.7.4
hooks:
- id: actionlint
# https://pyproject-fmt.readthedocs.io/en/latest/
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "v2.5.0"
hooks:
- id: pyproject-fmt
# codespell
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: [
"--ignore-words-list=livetime",
]
# markdownlint
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.43.0
hooks:
- id: markdownlint
args: ["--disable", "MD041"]
# yamllint
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
args: ["--strict", "-d", '{rules: {line-length: {max: 250}}}']
2 changes: 1 addition & 1 deletion README_vegas.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Events which fall outside the FoV defined in your EA file's cuts parameters will
Use `-r 2` to choose ITM reconstruction instead of standard. If you're using a King PSF, make sure your parameters file is for the appropriate reconstruction type.

## Full Enclosure Analysis
`--full-enclosure`
`--full-enclosure`

v2dl3-vegas now supports full-enclosure via King PSF. Point-like remains default.

Expand Down
4 changes: 1 addition & 3 deletions pyV2DL3/addHDUClassKeyword.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from pyV2DL3.constant import HDUCLASS
from pyV2DL3.constant import HDUDOC
from pyV2DL3.constant import HDUVERS
from pyV2DL3.constant import HDUCLASS, HDUDOC, HDUVERS


def addHDUClassKeyword(hdu, class1, class2=None, class3=None, class4=None):
Expand Down
2 changes: 1 addition & 1 deletion pyV2DL3/eventdisplay/fillEVENTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
import uproot
from astropy.time import Time
from scipy.stats import circmean

from pyV2DL3.constant import (
VTS_REFERENCE_HEIGHT,
Expand All @@ -17,7 +18,6 @@
getRunQuality,
produce_tel_list,
)
from scipy.stats import circmean

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion pyV2DL3/genHDUList.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def genPrimaryHDU():

def loadROOTFiles(data_file, effective_area_file, file_type, **kwargs):
"""
Load event lists, event header, and instrument reponse functions
Load event lists, event header, and instrument response functions
from VEGAS / Eventdisplay ROOT files.
"""
Expand Down
2 changes: 1 addition & 1 deletion pyV2DL3/script/compareFitsFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# compare two fits files and write
# differences into a file
from astropy.io import fits
import click
from astropy.io import fits

CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])

Expand Down
18 changes: 9 additions & 9 deletions pyV2DL3/script/v2dl3_for_vegas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from pyV2DL3.generateObsHduIndex import create_obs_hdu_index_file


CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])


Expand Down Expand Up @@ -161,11 +160,10 @@ def cli(
print("Logging level INFO")

logging.debug("Start importing ROOT")
from pyV2DL3.genHDUList import genHDUlist
from pyV2DL3.genHDUList import loadROOTFiles
from pyV2DL3.vegas.root_lib_util import (
from pyV2DL3.genHDUList import genHDUlist, loadROOTFiles
from pyV2DL3.vegas.root_lib_util import ( # Lundy- I don't like that this is where these are imported
cpp_print_context,
) # Lundy- I don't like that this is where these are imported
)

# Store in a dict the IRFs to be stored within a file.
# By default we will only store point-like IRFs.
Expand Down Expand Up @@ -380,10 +378,12 @@ def make_eclass_path(output, fname_base, eclass_idx):


def runlist_to_file_pairs(runlist, event_class_mode, output):
from pyV2DL3.vegas.parseSt6RunList import parseRunlistStrs
from pyV2DL3.vegas.parseSt6RunList import RunlistParsingError
from pyV2DL3.vegas.parseSt6RunList import RunlistValidationError
from pyV2DL3.vegas.parseSt6RunList import validateRunlist
from pyV2DL3.vegas.parseSt6RunList import (
RunlistParsingError,
RunlistValidationError,
parseRunlistStrs,
validateRunlist,
)

with open(runlist) as f:
lines = f.readlines()
Expand Down
4 changes: 2 additions & 2 deletions pyV2DL3/tests/test_IrfExtractor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from pyV2DL3.eventdisplay.IrfExtractor import find_closest_az
from pyV2DL3.eventdisplay.IrfExtractor import find_nearest

from pyV2DL3.eventdisplay.IrfExtractor import find_closest_az, find_nearest


def test_find_nearest():
Expand Down
3 changes: 2 additions & 1 deletion pyV2DL3/tests/test_addHDUClassKeyword.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from astropy.io import fits
import numpy as np
from astropy.io import fits

import pyV2DL3.addHDUClassKeyword


Expand Down
4 changes: 2 additions & 2 deletions pyV2DL3/tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pyV2DL3.eventdisplay.util import getGTI
from pyV2DL3.eventdisplay.util import getRunQuality
import numpy as np

from pyV2DL3.eventdisplay.util import getGTI, getRunQuality


def test_getRunQuality():
vpm_messages = [
Expand Down
7 changes: 4 additions & 3 deletions pyV2DL3/vegas/EffectiveAreaFile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import ROOT
import logging
import numpy as np
from ctypes import c_float

from pyV2DL3.vegas.util import getCuts
import numpy as np
import ROOT

from pyV2DL3.vegas.load_vegas import VEGASStatus
from pyV2DL3.vegas.util import getCuts

logger = logging.getLogger(__name__)

Expand Down
Loading

0 comments on commit 92681b7

Please sign in to comment.