Пример #1
0
def test_calculate_healpixel():
    north_pole = AlertRecord(
        candidate_id=None,
        object_id=None,
        timestamp=None,
        raw_data=None,
        raw_dict=None,
        position=SkyCoord(
            ra=0,
            dec=90,
            unit="deg",
        ),
    )
    assert north_pole.healpixel(1) == 3
    assert north_pole.healpixel(2) == 15
    assert north_pole.healpixel(3) == 63

    zeros = north_pole
    zeros.position = SkyCoord(
        ra=0,
        dec=0,
        unit="deg",
    )
    assert zeros.healpixel(1) == 17
    assert zeros.healpixel(2) == 70
    assert zeros.healpixel(3) == 282
Пример #2
0
def test_load_alertrecord_from_file_unsafely(alert_file):
    ar = AlertRecord.from_file_unsafe(open(alert_file, "rb"))
    assert ar.candidate_id == 1311156250015010003
    assert ar.object_id == "ZTF18aaylcqb"
    assert ar.position.ra.value == 234.1362886
    assert ar.position.dec.value == 16.6055949
    assert ar.timestamp.jd == 2459065.65625
Пример #3
0
 def insert(self, url: str, alert: AlertRecord) -> None:
     self._write(
         alert_url=url,
         candidate_id=alert.candidate_id,
         object_id=alert.object_id,
         time=alert.timestamp,
         healpixel=alert.healpixel(self.order),
     )
def iterate_tarfile(tarfile_path: pathlib.Path) -> Iterator[AlertRecord]:
    """
    Iterate over the alerts found in a standard ZTF alert archive tarball. The
    tarball should be gzipped, and contain individual alert files.
    """
    with tarfile.open(tarfile_path, mode="r:gz") as tf:
        for member in tf.getmembers():
            buf = tf.extractfile(member)
            assert buf is not None
            ar = AlertRecord.from_file_unsafe(buf)
            yield ar
            buf.close()
Пример #5
0
def alert_record():
    return AlertRecord(
        candidate_id="cid",
        object_id=1,
        timestamp=astropy.time.Time("2010-01-01T00:00:00"),
        raw_data=b"123",
        raw_dict={},
        position=astropy.coordinates.SkyCoord(
            ra=0,
            dec=90,
            unit="deg",
        ),
    )
Пример #6
0
def alert_from_file():
    alert_file = "testdata/alertfiles/1311156250015010003.avro"
    ar = AlertRecord.from_file_safe(open(alert_file, "rb"))
    return ar