def test_altaz_without_location(caplog): meta = {'ALT_PNT': 20.0, 'AZ_PNT': 170.0} pointing = FixedPointingInfo(meta) with caplog.at_level(logging.WARNING): altaz = pointing.altaz assert altaz.alt.deg == 20.0 assert altaz.az.deg == 170.0 pointing = FixedPointingInfo({}) with caplog.at_level(logging.WARNING): altaz = pointing.altaz assert np.isnan(altaz.alt.value) assert np.isnan(altaz.az.value)
def fixed_pointing_info_aligned(fixed_pointing_info): # Create Fixed Pointing Info aligined between sky and horizon coordinates # (removes rotation in FoV and results in predictable solid angles) origin = SkyCoord( 0, 0, unit="deg", frame="icrs", location=EarthLocation(lat=90 * u.deg, lon=0 * u.deg), obstime=Time("2000-9-21 12:00:00"), ) fpi = fixed_pointing_info meta = fpi.meta.copy() meta["RA_PNT"] = origin.icrs.ra meta["DEC_PNT"] = origin.icrs.dec meta["GEOLON"] = origin.location.lon meta["GEOLAT"] = origin.location.lat meta["ALTITUDE"] = origin.location.height time_start = origin.obstime.datetime - fpi.time_ref.datetime meta["TSTART"] = time_start.total_seconds() meta["TSTOP"] = meta["TSTART"] + 60 return FixedPointingInfo(meta)
def test_fixed_pointing_info_fixed_altaz(): location = observatory_locations["cta_south"] start = Time("2020-11-01T03:00:00") stop = Time("2020-11-01T03:15:00") ref = Time("2020-11-01T00:00:00") pointing_icrs = SkyCoord(ra=83.28 * u.deg, dec=21.78 * u.deg) pointing_altaz = pointing_icrs.transform_to( AltAz(obstime=start, location=location)) meta = time_ref_to_dict(ref) meta['TSTART'] = time_relative_to_ref(start, meta).to_value(u.s) meta['TSTOP'] = time_relative_to_ref(stop, meta).to_value(u.s) meta.update(earth_location_to_dict(location)) meta["OBS_MODE"] = "DRIFT" meta["ALT_PNT"] = pointing_altaz.alt.deg meta["AZ_PNT"] = pointing_altaz.az.deg pointing = FixedPointingInfo(meta=meta) # not given, but assumed if missing assert pointing.mode == PointingMode.DRIFT assert pointing.fixed_icrs is None assert u.isclose(pointing.fixed_altaz.alt, pointing_altaz.alt) assert u.isclose(pointing.fixed_altaz.az, pointing_altaz.az) icrs = pointing.get_icrs(start) assert icrs.obstime == start assert isinstance(icrs.frame, ICRS) back_trafo = icrs.transform_to(pointing_altaz.frame) assert u.isclose(back_trafo.alt, pointing_altaz.alt) assert u.isclose(back_trafo.az, pointing_altaz.az) times = start + np.linspace(0, 1, 50) * (stop - start) icrs = pointing.get_icrs(times) assert len(icrs) == len(times) assert np.all(icrs.obstime == times) assert isinstance(icrs.frame, ICRS) back_trafo = icrs.transform_to(AltAz(location=location, obstime=times)) assert u.isclose(back_trafo.alt, pointing_altaz.alt).all() assert u.isclose(back_trafo.az, pointing_altaz.az).all() assert np.all(u.isclose(pointing_altaz.alt, pointing.get_altaz(times).alt)) assert np.all(u.isclose(pointing_altaz.az, pointing.get_altaz(times).az))
def test_fixed_pointing_info_fixed_icrs(): location = observatory_locations["cta_south"] start = Time("2020-11-01T03:00:00") stop = Time("2020-11-01T03:15:00") ref = Time("2020-11-01T00:00:00") pointing_icrs = SkyCoord(ra=83.28 * u.deg, dec=21.78 * u.deg) meta = time_ref_to_dict(ref) meta['TSTART'] = time_relative_to_ref(start, meta).to_value(u.s) meta['TSTOP'] = time_relative_to_ref(stop, meta).to_value(u.s) meta.update(earth_location_to_dict(location)) meta["RA_PNT"] = pointing_icrs.ra.deg meta["DEC_PNT"] = pointing_icrs.dec.deg pointing = FixedPointingInfo(meta=meta) # not given, but assumed if missing assert pointing.mode == PointingMode.POINTING assert pointing.fixed_icrs == pointing_icrs assert pointing.fixed_altaz is None altaz = pointing.get_altaz(start) assert altaz.obstime == start assert isinstance(altaz.frame, AltAz) assert np.all(u.isclose(pointing_icrs.ra, pointing.get_icrs(start).ra)) back_trafo = altaz.transform_to("icrs") assert u.isclose(back_trafo.ra, pointing_icrs.ra) assert u.isclose(back_trafo.dec, pointing_icrs.dec) times = start + np.linspace(0, 1, 50) * (stop - start) altaz = pointing.get_altaz(times) assert len(altaz) == len(times) assert np.all(altaz.obstime == times) assert isinstance(altaz.frame, AltAz) back_trafo = altaz.transform_to("icrs") assert u.isclose(back_trafo.ra, pointing_icrs.ra).all() assert u.isclose(back_trafo.dec, pointing_icrs.dec).all() assert np.all(u.isclose(pointing_icrs.ra, pointing.get_icrs(times).ra))
def fixed_pointing_info(): filename = "$GAMMAPY_DATA/cta-1dc/data/baseline/gps/gps_baseline_110380.fits" return FixedPointingInfo.read(filename)
def setup_class(cls): filename = "$GAMMAPY_DATA/tests/pointing_table.fits.gz" cls.fpi = FixedPointingInfo.read(filename)
# Define map geometry axis = MapAxis.from_edges(np.logspace(-1.0, 1.0, 10), unit="TeV", name="energy", interp="log") geom = WcsGeom.create(skydir=(0, 0), binsz=0.02, width=(5, 4), coordsys="GAL", axes=[axis]) # In[ ]: # Define some observation parameters # We read in the pointing info from one of the 1dc event list files as an example pointing = FixedPointingInfo.read( "$GAMMAPY_DATA/cta-1dc/data/baseline/gps/gps_baseline_110380.fits") livetime = 1 * u.hour offset_max = 2 * u.deg offset = Angle("2 deg") # In[ ]: exposure = make_map_exposure_true_energy(pointing=pointing.radec, livetime=livetime, aeff=irfs["aeff"], geom=geom) exposure.slice_by_idx({ "energy": 3 }).plot(add_cbar=True)
def setup_class(cls): filename = "$GAMMAPY_DATA/tests/hess_event_list.fits" cls.fpi = FixedPointingInfo.read(filename)