-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update source to ctapipe 0.17 #161
Conversation
Codecov ReportBase: 88.12% // Head: 88.64% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #161 +/- ##
==========================================
+ Coverage 88.12% 88.64% +0.52%
==========================================
Files 16 18 +2
Lines 1507 1911 +404
==========================================
+ Hits 1328 1694 +366
- Misses 179 217 +38
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@FrancaCassol @rlopezcoto @moralejo I think this is ready to be reviewed, tests are passing |
Ok, the positions are now calculated to the reference position calculated from official lon/lat values using abelardo's method (area weighted average with mirror areas of 23² m² for LST and 17² m² for MAGIC-{1,2}). The calculated positions are within 0.6 m of the monte carlo positions. The computations require astropy 5.2 and I crosschecked them with the much more straight forward code of using |
For future reference: from astropy.coordinates import EarthLocation, AltAz, ITRS
from astropy.time import Time
import astropy.units as u
import matplotlib.pyplot as plt
from pyproj import CRS, Transformer
import numpy as np
from ctapipe.io import EventSource
locations = {
"LST-1": dict(
loc=EarthLocation(lon=-17.89149701 * u.deg, lat=28.76152611 * u.deg, height=2185 * u.m),
rough_area=23**2 * u.m**2,
tel_id=1,
),
"MAGIC-1": dict(
loc=EarthLocation(lon=-17.8900665372 * u.deg, lat=28.7619439944 * u.deg, height=2184.763 * u.m),
rough_area=17**2 * u.m**2,
tel_id=2,
),
"MAGIC-2": dict(
loc=EarthLocation(lon=-17.8905595556 * u.deg, lat=28.7613094808 * u.deg, height=2186.764 * u.m),
rough_area=17**2 * u.m**2,
tel_id=3,
),
}
s = EventSource('./test_data/mc/simtel_theta_20_az_180_gdiffuse_10evts.simtel.gz')
print(s.subarray.tel_coords)
for l in locations.values():
l['area'] = s.subarray.tel[l['tel_id']].optics.mirror_area
l['simtel_pos'] = s.subarray.positions[l['tel_id']].to_value(u.m)
for key in ('area', 'rough_area'):
areas = [l[key].to_value(u.m**2) for l in locations.values()]
ref_lon = np.average([l['loc'].lon.deg for l in locations.values()], weights=areas)
ref_lat = np.average([l['loc'].lat.deg for l in locations.values()], weights=areas)
print(f'Reference location ({key}): {ref_lon:.6f}°, {ref_lat:.6f}°')
crs = CRS.from_dict(dict(proj='tmerc', ellps='WGS84', lon_0=ref_lon, lat_0=ref_lat, axis='enu', units='m'))
proj = Transformer.from_crs(crs.geodetic_crs, crs)
print("PROJ coordinates")
for label, d in locations.items():
y, x = proj.transform(d['loc'].lon.deg, d['loc'].lat.deg)
print(f"{label:10s} {x: 7.3f} m {y: 7.3f} m")
sx, sy, sz = d['simtel_pos']
sy = -sy
print(f'dx={x - sx:.2f}, {y - sy:.2f}')
print("Astropy Coordinates")
ref = EarthLocation(lon=ref_lon * u.deg, lat=ref_lat * u.deg, height=2199 * u.m)
ref_cart = ref.get_itrs().cartesian
fig, ax = plt.subplots()
print(f'Reference location: {ref_lon:.6f}°, {ref_lat:.6f}°')
for i, (label, d) in enumerate(locations.items()):
cart = d['loc'].get_itrs().cartesian
altaz = ITRS(cart - ref_cart, location=ref).transform_to(AltAz(location=ref))
x, y, z = altaz.cartesian.xyz.to_value(u.m)
print(f"{label:10s} {x: 7.3f} m {y: 7.3f} m")
ax.plot(x, y, 'o', color='w', mec=f'C{i}', markeredgewidth=2, label=f'{label} (astropy)')
sx, sy, sz = d['simtel_pos']
sy = -sy
print(f'dx={x - sx:.2f}, {y - sy:.2f}')
ax.plot(sx, sy, 'o', color='k', mec=f'C{i}', markeredgewidth=2, label=f'{label} (sim-config)')
ax.legend(ncol=3, loc='lower center', bbox_to_anchor=(0.5, 1.02))
plt.show() |
|
The difference in height is due to this issue here: cta-observatory/lst-sim-config#43 |
Tests run with the exception for the tests needing calibration files. These require new calibration files produced with ctapipe 0.17.
I intend to solve this hen/egg problem by also opening the PR in lstchain and use the two branches together to produce new calibration files with what already works.