diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..266c3fe0 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,4 @@ +template: | + ## What’s Changed + + $CHANGES diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..840f7b0c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: CI + +on: + push: + branches: + - master + tags: + - '**' + pull_request: + +env: + NUMBA_NUM_THREADS: 1 + MPLBACKEND: Agg + PYTEST_ADDOPTS: --color=yes + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + ctapipe-version: [v0.12.0] + + defaults: + run: + shell: bash -leo pipefail {0} + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set Python version + env: + PYTHON_VERSION: ${{ matrix.python-version }} + run: | + sed -i -e "s/- python=.*/- python=$PYTHON_VERSION/g" environment.yml + + - name: Create and activate env + uses: mamba-org/provision-with-micromamba@v15 + with: + environment-name: "ci" + environment-file: environment.yml + + - name: Install dependencies + env: + PYTHON_VERSION: ${{ matrix.python-version }} + CTAPIPE_VERSION: ${{ matrix.ctapipe-version }} + + run: | + python --version + echo "Installing additional pip packages" + # we install ctapipe using pip to be able to select any commit, e.g. the current master + pip install \ + "git+https://github.com/cta-observatory/ctapipe@$CTAPIPE_VERSION" \ + pytest-cov + + echo "pip install -e ." + pip install -e . + + - name: Tests + run: | + pytest --cov=nectarchain --cov-report=xml + + - uses: codecov/codecov-action@v1 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..ee16e6b5 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,31 @@ +name: Deploy to PyPI + +on: + push: + tags: + - 'v*' + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + # make sure we have version info + - run: git fetch --tags + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + python --version + pip install -U pip setuptools wheel setuptools_scm[toml] + python setup.py sdist bdist_wheel + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 00000000..17fdb961 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,14 @@ +name: Release Drafter + +on: + push: + branches: + - master + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 84752161..dc5fa769 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +_version.py .pytest_cache # Compiled files @@ -8,7 +9,7 @@ __pycache__ # ignore version cache file (generated automatically when setup.py is run) -nectarcam/_version_cache.py +src/nectarchain/_version_cache.py # Ignore .c files by default to avoid including generated code. If you want to # add a non-generated .c extension, use `git add -f filename.c`. diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8570b26d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -language: python - -matrix: - include: - python: 3.6 - os: linux - env: - - CTAPIPE_VERSION=master - - PROTOZFITS_VERSION=v1.5.0 - - CTAPIPE_IO_NECTARCAM_VERSION=master - - -before_install: - - # Use utf8 encoding. Should be default, but this is insurance - # against future changes - - export PYTHONIOENCODING=UTF8 - - export MPLBACKEND=Agg - - - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; - - bash miniconda.sh -b -p $HOME/miniconda - - . $HOME/miniconda/etc/profile.d/conda.sh - - hash -r - - conda config --set always_yes yes --set changeps1 no - - conda update -q conda # get latest conda version - - conda info -a # Useful for debugging any issues with conda - -install: - - conda env create --name cta --file environment.yml - - conda activate cta - - pip install https://github.com/cta-observatory/ctapipe/archive/$CTAPIPE_VERSION.tar.gz - - pip install https://github.com/cta-sst-1m/protozfitsreader/archive/$PROTOZFITS_VERSION.tar.gz - - pip install https://github.com/cta-observatory/ctapipe_io_nectarcam/archive/$CTAPIPE_IO_NECTARCAM_VERSION.tar.gz - - python setup.py install - - -script: - - pytest - - diff --git a/README.md b/README.md index f6fac75e..848af61d 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ -# nectarchain +# nectarchain [![Build Status](https://github.com/cta-observatory/nectarchain/workflows/CI/badge.svg?branch=master)](https://github.com/cta-observatory/nectarchain/actions?query=workflow%3ACI+branch%3Amaster) Repository for the high level analysis of the NectarCAM data. The analysis is heavily based on [ctapipe](https://github.com/cta-observatory/ctapipe), adding custom code for NectarCAM calibration. -master branch status: [![Build Status](https://travis-ci.org/cta-observatory/nectarchain.svg?branch=master)](https://travis-ci.org/cta-observatory/nectarchain) - ## Installation ```shell diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..43f0d8eb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = ["setuptools >= 64.0.3", "setuptools_scm[toml]>=3.4"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +write_to = "src/nectarchain/_version.py" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..492f08da --- /dev/null +++ b/setup.cfg @@ -0,0 +1,57 @@ +[metadata] +name = nectarchain +description = Analysis chain for the CTA MSTN NectarCAM prototype +long_description = file: README.md +long_description_content_type = text/markdown; charset=UTF-8 +author = NectarCAM collaboration +license = BSD-3-Clause + +project_urls = + Bug Tracker = https://github.com/cta-observatory/nectarchain/issues + Source Code = https://github.com/cta-observatory/nectarchain + +classifiers = + Development Status :: 3 - Alpha + License :: OSI Approved :: BSD License + Intended Audience :: Science/Research + Topic :: Scientific/Engineering :: Astronomy + Topic :: Scientific/Engineering :: Physics + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.8 + +[options] +packages = find: +package_dir = + = src +python_requires = ~=3.8 +zip_safe = False +install_requires = + astropy~=4.2 + ctapipe~=0.12 + numpy~=1.22 + protozfits~=2.0 + tables>=3.7 + +[options.packages.find] +where = src +exclude = + nectarchain._dev_version + +[options.extras_require] +tests = + pytest +dev = + setuptools_scm[toml] +all = + %(tests)s + %(dev)s + +[tool:pytest] +minversion = 3.0 +addopts = -v + +[aliases] +test = pytest + +[flake8] +max-line-length = 88 diff --git a/setup.py b/setup.py index 6f22a216..8bf1ba93 100644 --- a/setup.py +++ b/setup.py @@ -1,32 +1,2 @@ -#!/usr/bin/env python -# Licensed under a 3-clause BSD style license - see LICENSE.rst - -from setuptools import setup, find_packages -from os import path - -# read the contents of your README file -this_directory = path.abspath(path.dirname(__file__)) -with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f: - long_description = f.read() - - -setup( - name='nectarchain', - packages=find_packages(), - version='0.1', - description='', - long_description=long_description, - long_description_content_type='text/markdown', - install_requires=[ - 'astropy~=4.2', - 'ctapipe~=0.12', - 'numpy~=1.22.4', - 'tables>=3.7', - ], - tests_require=['pytest'], - setup_requires=['pytest_runner'], - author='NectarCAM collaboration', - url='https://github.com/cta-observatory/nectarchain', - license='' -) - +from setuptools import setup +setup() diff --git a/src/nectarchain/_dev_version/__init__.py b/src/nectarchain/_dev_version/__init__.py new file mode 100644 index 00000000..db418f21 --- /dev/null +++ b/src/nectarchain/_dev_version/__init__.py @@ -0,0 +1,9 @@ +# Try to use setuptools_scm to get the current version; this is only used +# in development installations from the git repository. +# see nectarchain/version.py for details +try: + from setuptools_scm import get_version + + version = get_version(root="..", relative_to=__file__) +except Exception as e: + raise ImportError(f"setuptools_scm broken or not installed: {e}") diff --git a/nectarchain/calibration/Illuminated_pixels_charge_ped_first_post.csv b/src/nectarchain/nectarchain/calibration/Illuminated_pixels_charge_ped_first_post.csv similarity index 100% rename from nectarchain/calibration/Illuminated_pixels_charge_ped_first_post.csv rename to src/nectarchain/nectarchain/calibration/Illuminated_pixels_charge_ped_first_post.csv diff --git a/nectarchain/calibration/NectarGAIN.py b/src/nectarchain/nectarchain/calibration/NectarGAIN.py similarity index 100% rename from nectarchain/calibration/NectarGAIN.py rename to src/nectarchain/nectarchain/calibration/NectarGAIN.py diff --git a/nectarchain/calibration/NectarGainExample.ipynb b/src/nectarchain/nectarchain/calibration/NectarGainExample.ipynb similarity index 100% rename from nectarchain/calibration/NectarGainExample.ipynb rename to src/nectarchain/nectarchain/calibration/NectarGainExample.ipynb diff --git a/nectarchain/calibration/README.md b/src/nectarchain/nectarchain/calibration/README.md similarity index 100% rename from nectarchain/calibration/README.md rename to src/nectarchain/nectarchain/calibration/README.md diff --git a/nectarchain/calibration/__init__.py b/src/nectarchain/nectarchain/calibration/__init__.py similarity index 100% rename from nectarchain/calibration/__init__.py rename to src/nectarchain/nectarchain/calibration/__init__.py diff --git a/nectarchain/calibration/container/__init__.py b/src/nectarchain/nectarchain/calibration/container/__init__.py similarity index 100% rename from nectarchain/calibration/container/__init__.py rename to src/nectarchain/nectarchain/calibration/container/__init__.py diff --git a/nectarchain/calibration/container/charge.py b/src/nectarchain/nectarchain/calibration/container/charge.py similarity index 100% rename from nectarchain/calibration/container/charge.py rename to src/nectarchain/nectarchain/calibration/container/charge.py diff --git a/nectarchain/calibration/container/charge_extractor.py b/src/nectarchain/nectarchain/calibration/container/charge_extractor.py similarity index 100% rename from nectarchain/calibration/container/charge_extractor.py rename to src/nectarchain/nectarchain/calibration/container/charge_extractor.py diff --git a/nectarchain/calibration/container/utils.py b/src/nectarchain/nectarchain/calibration/container/utils.py similarity index 100% rename from nectarchain/calibration/container/utils.py rename to src/nectarchain/nectarchain/calibration/container/utils.py diff --git a/nectarchain/calibration/container/waveforms.py b/src/nectarchain/nectarchain/calibration/container/waveforms.py similarity index 100% rename from nectarchain/calibration/container/waveforms.py rename to src/nectarchain/nectarchain/calibration/container/waveforms.py diff --git a/nectarchain/dqm/README b/src/nectarchain/nectarchain/dqm/README similarity index 100% rename from nectarchain/dqm/README rename to src/nectarchain/nectarchain/dqm/README diff --git a/nectarchain/dqm/ReadPickleFiles.py b/src/nectarchain/nectarchain/dqm/ReadPickleFiles.py similarity index 100% rename from nectarchain/dqm/ReadPickleFiles.py rename to src/nectarchain/nectarchain/dqm/ReadPickleFiles.py diff --git a/nectarchain/dqm/camera_monitoring.py b/src/nectarchain/nectarchain/dqm/camera_monitoring.py similarity index 100% rename from nectarchain/dqm/camera_monitoring.py rename to src/nectarchain/nectarchain/dqm/camera_monitoring.py diff --git a/nectarchain/dqm/charge_integration.py b/src/nectarchain/nectarchain/dqm/charge_integration.py similarity index 100% rename from nectarchain/dqm/charge_integration.py rename to src/nectarchain/nectarchain/dqm/charge_integration.py diff --git a/nectarchain/dqm/dqm_summary_processor.py b/src/nectarchain/nectarchain/dqm/dqm_summary_processor.py similarity index 100% rename from nectarchain/dqm/dqm_summary_processor.py rename to src/nectarchain/nectarchain/dqm/dqm_summary_processor.py diff --git a/nectarchain/dqm/mean_camera_display.py b/src/nectarchain/nectarchain/dqm/mean_camera_display.py similarity index 100% rename from nectarchain/dqm/mean_camera_display.py rename to src/nectarchain/nectarchain/dqm/mean_camera_display.py diff --git a/nectarchain/dqm/mean_waveforms.py b/src/nectarchain/nectarchain/dqm/mean_waveforms.py similarity index 100% rename from nectarchain/dqm/mean_waveforms.py rename to src/nectarchain/nectarchain/dqm/mean_waveforms.py diff --git a/nectarchain/dqm/start_calib.py b/src/nectarchain/nectarchain/dqm/start_calib.py similarity index 100% rename from nectarchain/dqm/start_calib.py rename to src/nectarchain/nectarchain/dqm/start_calib.py diff --git a/nectarchain/dqm/trigger_statistics.py b/src/nectarchain/nectarchain/dqm/trigger_statistics.py similarity index 100% rename from nectarchain/dqm/trigger_statistics.py rename to src/nectarchain/nectarchain/dqm/trigger_statistics.py diff --git a/nectarchain/tools/__init__.py b/src/nectarchain/nectarchain/tools/__init__.py similarity index 100% rename from nectarchain/tools/__init__.py rename to src/nectarchain/nectarchain/tools/__init__.py diff --git a/nectarchain/tools/write_camera_calibration.py b/src/nectarchain/nectarchain/tools/write_camera_calibration.py similarity index 100% rename from nectarchain/tools/write_camera_calibration.py rename to src/nectarchain/nectarchain/tools/write_camera_calibration.py diff --git a/nectarchain/tools/write_camera_calibration_param.json b/src/nectarchain/nectarchain/tools/write_camera_calibration_param.json similarity index 100% rename from nectarchain/tools/write_camera_calibration_param.json rename to src/nectarchain/nectarchain/tools/write_camera_calibration_param.json diff --git a/nectarchain/tools/write_pedestals.py b/src/nectarchain/nectarchain/tools/write_pedestals.py similarity index 100% rename from nectarchain/tools/write_pedestals.py rename to src/nectarchain/nectarchain/tools/write_pedestals.py diff --git a/nectarchain/tools/write_pedestals_param.json b/src/nectarchain/nectarchain/tools/write_pedestals_param.json similarity index 100% rename from nectarchain/tools/write_pedestals_param.json rename to src/nectarchain/nectarchain/tools/write_pedestals_param.json diff --git a/nectarchain/user_scripts/fbradascio/fbradascio b/src/nectarchain/nectarchain/user_scripts/fbradascio/fbradascio similarity index 100% rename from nectarchain/user_scripts/fbradascio/fbradascio rename to src/nectarchain/nectarchain/user_scripts/fbradascio/fbradascio diff --git a/nectarchain/user_scripts/fbrun/ComputeCalibCoefs.py b/src/nectarchain/nectarchain/user_scripts/fbrun/ComputeCalibCoefs.py similarity index 100% rename from nectarchain/user_scripts/fbrun/ComputeCalibCoefs.py rename to src/nectarchain/nectarchain/user_scripts/fbrun/ComputeCalibCoefs.py diff --git a/nectarchain/user_scripts/fbrun/fbrun_scripts b/src/nectarchain/nectarchain/user_scripts/fbrun/fbrun_scripts similarity index 100% rename from nectarchain/user_scripts/fbrun/fbrun_scripts rename to src/nectarchain/nectarchain/user_scripts/fbrun/fbrun_scripts diff --git a/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py b/src/nectarchain/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py similarity index 100% rename from nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py rename to src/nectarchain/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py diff --git a/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.sh b/src/nectarchain/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.sh similarity index 100% rename from nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.sh rename to src/nectarchain/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.sh diff --git a/nectarchain/user_scripts/ggrolleron/test.py b/src/nectarchain/nectarchain/user_scripts/ggrolleron/test.py similarity index 100% rename from nectarchain/user_scripts/ggrolleron/test.py rename to src/nectarchain/nectarchain/user_scripts/ggrolleron/test.py diff --git a/nectarchain/user_scripts/jlenain/Dark room temperature analysis.md b/src/nectarchain/nectarchain/user_scripts/jlenain/Dark room temperature analysis.md similarity index 100% rename from nectarchain/user_scripts/jlenain/Dark room temperature analysis.md rename to src/nectarchain/nectarchain/user_scripts/jlenain/Dark room temperature analysis.md diff --git a/nectarchain/user_scripts/jlenain/dqm_job_submitter/dqm_processor.sh b/src/nectarchain/nectarchain/user_scripts/jlenain/dqm_job_submitter/dqm_processor.sh similarity index 100% rename from nectarchain/user_scripts/jlenain/dqm_job_submitter/dqm_processor.sh rename to src/nectarchain/nectarchain/user_scripts/jlenain/dqm_job_submitter/dqm_processor.sh diff --git a/nectarchain/user_scripts/jlenain/dqm_job_submitter/submit_dqm_processor.py b/src/nectarchain/nectarchain/user_scripts/jlenain/dqm_job_submitter/submit_dqm_processor.py similarity index 100% rename from nectarchain/user_scripts/jlenain/dqm_job_submitter/submit_dqm_processor.py rename to src/nectarchain/nectarchain/user_scripts/jlenain/dqm_job_submitter/submit_dqm_processor.py diff --git a/src/nectarchain/version.py b/src/nectarchain/version.py new file mode 100644 index 00000000..5049bf22 --- /dev/null +++ b/src/nectarchain/version.py @@ -0,0 +1,21 @@ +# this is adapted from https://github.com/astropy/astropy/blob/master/astropy/version.py +# see https://github.com/astropy/astropy/pull/10774 for a discussion on why this needed. + +try: + try: + from ._dev_version import version + except ImportError: + from ._version import version +except Exception: + import warnings + + warnings.warn( + "Could not determine nectarchain version; this indicates a broken installation." + " Install nectarchain from PyPI, using conda or from a local git repository." + " Installing github's autogenerated source release tarballs " + " does not include version information and should be avoided." + ) + del warnings + version = "0.0.0" + +__version__ = version