Skip to content

Commit

Permalink
Merge pull request #148 from fact-project/improve_fact_dl3
Browse files Browse the repository at this point in the history
Improve fact dl3
  • Loading branch information
maxnoe authored Mar 19, 2021
2 parents 5161efe + 52daf3a commit d8727dd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ env:

matrix:
include:
- python: '3.6'
- python: '3.7'
- python: '3.8'

Expand All @@ -33,7 +32,7 @@ deploy:
on:
branch: master
tags: true
condition: $TRAVIS_PYTHON_VERSION = '3.7'
condition: $TRAVIS_PYTHON_VERSION = '3.8'


addons:
Expand Down
2 changes: 1 addition & 1 deletion aict_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.25.1'
__version__ = '0.26.0'
2 changes: 1 addition & 1 deletion aict_tools/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def parallelize_array_computation(func, *arrays, n_jobs=-1, **kwargs):
n_jobs = cpu_count()

if n_jobs == 1:
return func(*arrays)
return [func(*arrays)]

n_elements = list(set(len(a) for a in arrays))
if len(n_elements) > 1:
Expand Down
23 changes: 20 additions & 3 deletions aict_tools/scripts/fact_to_dl3.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from astropy.time import Time
from astropy.coordinates import AltAz, SkyCoord
from astropy.coordinates.erfa_astrom import erfa_astrom, ErfaAstromInterpolator
import astropy.units as u

from fact.io import read_h5py, to_h5py
Expand All @@ -31,6 +32,10 @@
from ..preprocessing import calc_true_disp
from ..logging import setup_logging

# use interpolation for all coordinate transforms
# 100x speed increase with no precision lost (~uas)
erfa_astrom.set(ErfaAstromInterpolator(5 * u.min))


dl3_columns = [
'run_id',
Expand All @@ -46,6 +51,8 @@
'theta_deg_off_5',
'pointing_position_az',
'pointing_position_zd',
'az_prediction',
'zd_prediction',
]
dl3_columns_sim_read = [
'corsika_run_header_run_number',
Expand Down Expand Up @@ -92,10 +99,14 @@ def to_altaz(obstime, source):


def concat_results_altaz(results):
obstime = np.concatenate([s.obstime for s in results])
jd1 = np.concatenate([s.obstime.jd1 for s in results])
jd2 = np.concatenate([s.obstime.jd2 for s in results])
obstime = Time(jd1, jd2, format='jd', copy=False)

alt = u.Quantity(np.concatenate([s.alt.deg for s in results]), u.deg, copy=False)
az= u.Quantity(np.concatenate([s.az.deg for s in results]), u.deg, copy=False)
return SkyCoord(
alt=np.concatenate([s.alt.deg for s in results]) * u.deg,
az=np.concatenate([s.az.deg for s in results]) * u.deg,
alt=alt, az=az,
frame=AltAz(location=LOCATION, obstime=obstime)
)

Expand All @@ -109,6 +120,12 @@ def calc_source_features_common(
pointing_position_az,
):
result = {}

k_zd, k_az = 'zd_prediction', 'az_prediction'
result[k_zd], result[k_az] = camera_to_horizontal(
prediction_x, prediction_y,
pointing_position_zd, pointing_position_az,
)
result['theta_deg'] = calc_theta_camera(
prediction_x,
prediction_y,
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
author_email='[email protected]',
license='MIT',
packages=find_packages(),
python_requires='>=3.7',
setup_requires=['pytest-runner'],
tests_require=['pytest'],
install_requires=[
'astropy', # in anaconda
'astropy~=4.2', # in anaconda
'click', # in anaconda
'h5py', # in anaconda
'joblib', # in anaconda
Expand Down Expand Up @@ -78,7 +79,6 @@
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3 :: Only',
Expand Down

0 comments on commit d8727dd

Please sign in to comment.