Пример #1
0
class SDetected(db.Model):

    __tablename__ = "SDetected"

    id = db.Column(db.Integer, primary_key=True)

    thresh = db.Column(db.Float, nullable=False)
    npix = db.Column(db.Float, nullable=False)
    tnpix = db.Column(db.Float, nullable=False)
    xmin = db.Column(db.Float, nullable=False)
    xmax = db.Column(db.Float, nullable=False)
    ymin = db.Column(db.Float, nullable=False)
    ymax = db.Column(db.Float, nullable=False)
    x = db.Column(db.Float, nullable=False)
    y = db.Column(db.Float, nullable=False)
    x2 = db.Column(db.Float, nullable=False)
    y2 = db.Column(db.Float, nullable=False)
    xy = db.Column(db.Float, nullable=False)
    errx2 = db.Column(db.Float, nullable=False)
    erry2 = db.Column(db.Float, nullable=False)
    errxy = db.Column(db.Float, nullable=False)
    a = db.Column(db.Float, nullable=False)
    b = db.Column(db.Float, nullable=False)
    theta = db.Column(db.Float, nullable=False)
    cxx = db.Column(db.Float, nullable=False)
    cyy = db.Column(db.Float, nullable=False)
    cxy = db.Column(db.Float, nullable=False)
    cflux = db.Column(db.Float, nullable=False)
    flux = db.Column(db.Float, nullable=False)
    cpeak = db.Column(db.Float, nullable=False)
    peak = db.Column(db.Float, nullable=False)
    xcpeak = db.Column(db.Float, nullable=False)
    ycpeak = db.Column(db.Float, nullable=False)
    xpeak = db.Column(db.Float, nullable=False)
    ypeak = db.Column(db.Float, nullable=False)
    flag = db.Column(db.Float, nullable=False)
    #MU_THRESHOLD = db.Column(db.Float, nullable=False)
    #SNR_WIN = db.Column(db.Float, nullable=False)
    DELTAX = db.Column(db.Float, nullable=False)
    DELTAY = db.Column(db.Float, nullable=False)
    RATIO = db.Column(db.Float, nullable=False)
    ROUNDNESS = db.Column(db.Float, nullable=False)
    PEAK_CENTROID = db.Column(db.Float, nullable=False)
    IS_REAL = db.Column(db.Boolean, nullable=True)

    image_id = db.Column(db.Integer, db.ForeignKey('SImages.id'))
    image = db.relationship('SImages',
                            backref=db.backref('Sdetected_srcs', order_by=id))

    def __repr__(self):
        return '{}::{}'.format(self.image, self.id)
Пример #2
0
class NewImages(db.Model):

    __tablename__ = "NewImages"

    id = db.Column(db.Integer, primary_key=True)

    path = db.Column(db.String(100), nullable=False)

    object_id = db.Column(db.Integer, db.ForeignKey('Object.id'))
    object = db.relationship('Object',
                             backref=db.backref('newimage', order_by=id))

    def __repr__(self):
        return self.path
Пример #3
0
class Source(db.Model):

    __tablename__ = 'Source'

    id = db.Column(db.Integer, primary_key=True)
    ra = db.Column(db.Float, nullable=False)
    dec = db.Column(db.Float, nullable=False)
    mag = db.Column(db.Float, nullable=False)
    mag_err = db.Column(db.Float, nullable=False)
    class_source = db.Column(db.String, nullable=True)

    pawprint_id = db.Column(db.Integer, db.ForeignKey('Pawprint.id'))
    pawprint = db.relationship("Pawprint",
                               backref=db.backref('sources', order_by=id))

    def __repr__(self):
        return "({}, {})".format(self.ra, self.dec)
Пример #4
0
class SCorrDetected(db.Model):

    __tablename__ = "SCorrDetected"

    id = db.Column(db.Integer, primary_key=True)

    X_IMAGE = db.Column(db.Float, nullable=False)
    Y_IMAGE = db.Column(db.Float, nullable=False)
    SIGNIFICANCE = db.Column(db.Float, nullable=False)

    IS_REAL = db.Column(db.Boolean, nullable=True)

    image_id = db.Column(db.Integer, db.ForeignKey('SCorrImages.id'))
    image = db.relationship('SCorrImages',
                            backref=db.backref('SCorrdetected_srcs',
                                               order_by=id))

    def __repr__(self):
        return '{}::{}'.format(self.image, self.id)
Пример #5
0
class LightCurve(db.Model):

    __tablename__ = "LightCurve"

    id = db.Column(
        db.Integer, db.Sequence('lightcurve_id_seq'), primary_key=True)

    source_id = db.Column(
        db.Integer, db.ForeignKey('MasterSource.id'),
        nullable=False, unique=True)
    source = db.relationship(
        "MasterSource", backref=db.backref("lightcurve"), uselist=False)

    obs_number = db.Column(db.Integer)
    pdm_period = db.Column(db.Float, nullable=True)
    ls_period = db.Column(db.Float, nullable=True)

    def __repr__(self):
        return "<LightCurve '{}'>".format(repr(self.source))
Пример #6
0
class MasterSource(db.Model):

    __tablename__ = "MasterSource"
    __table_args__ = (
        db.UniqueConstraint('tile_id', 'order', name='_tile_order_uc'),
    )

    id = db.Column(
        db.Integer, db.Sequence('master_src_id_seq'), primary_key=True)

    tile_id = db.Column(db.Integer, db.ForeignKey('Tile.id'), nullable=False)
    tile = db.relationship("Tile", backref=db.backref("sources"))

    order = db.Column(db.Integer, nullable=False)

    ra_h = db.Column(db.Float, nullable=False)
    dec_h = db.Column(db.Float, nullable=False)

    ra_j = db.Column(db.Float, nullable=False)
    dec_j = db.Column(db.Float, nullable=False)

    ra_k = db.Column(db.Float, nullable=False)
    dec_k = db.Column(db.Float, nullable=False)

    x = db.Column(db.Float, nullable=True)
    y = db.Column(db.Float, nullable=True)
    z = db.Column(db.Float, nullable=True)

    type = db.Column(db.String(255))

    @classmethod
    def conesearch(cls, ra, dec, radius):
        x, y, z = SkyCoord(
            ra=ra, dec=dec, unit="deg", frame="icrs"
        ).represent_as("cartesian").xyz.value
        cos_r = np.cos(radius)
        query = (cls.x * x + cls.y * y + cls.z * z) >= cos_r
        return query

    def __repr__(self):
        return u"<MasterSource '{}[{}]'>".format(self.tile, self.order)
Пример #7
0
class PawprintSource(db.Model):

    __tablename__ = "PawprintSource"
    __table_args__ = (
        db.UniqueConstraint('pawprint_id', 'order', name='_pawprint_order_uc'),
    )

    id = db.Column(
        db.Integer, db.Sequence('pawprint_src_id_seq'), primary_key=True)

    pawprint_id = db.Column(
        db.Integer, db.ForeignKey('Pawprint.id'), nullable=False)
    pawprint = db.relationship(
        "Pawprint", backref=db.backref("pxt"))

    order = db.Column(db.Integer, nullable=False)

    ra_deg = db.Column(db.Float)
    ra_h = db.Column(db.Float)
    ra_m = db.Column(db.Float)
    ra_s = db.Column(db.Float)
    dec_deg = db.Column(db.Float)
    dec_d = db.Column(db.Float)
    dec_m = db.Column(db.Float)
    dec_s = db.Column(db.Float)
    pwp_x = db.Column(db.Float)
    pwp_y = db.Column(db.Float)
    mag = db.Column(db.Float)
    mag_err = db.Column(db.Float)
    chip_nro = db.Column(db.Float)
    stel_cls = db.Column(db.Float)
    elip = db.Column(db.Float)
    pos_ang = db.Column(db.Float)

    hjd = db.Column(db.Float, nullable=True)

    def __repr__(self):
        return u"<PawprintSource '{}[{}]'>".format(self.pawprint, self.order)
Пример #8
0
class LightCurves(db.Model):
    """Stores the sources of the tile and also their observations
    inside a pawprint. This resume are stores inside an hdf5 for
    eficient access

    """

    __tablename__ = "LightCurves"

    id = db.Column(db.Integer, db.Sequence('lc_id_seq'), primary_key=True)

    tile_id = db.Column(db.Integer,
                        db.ForeignKey('Tile.id'),
                        nullable=False,
                        unique=True)
    tile = db.relationship("Tile",
                           backref=db.backref("lcurves", uselist=False),
                           lazy='joined')

    # ~ feats_version  = db.Column(db.String(10), default="1.0")

    _src_obs_counter = db.Column("src_obs_cnt", db.PickleType, nullable=True)

    def __repr__(self):
        return "<LightCurves of '{}'>".format(self.tile.name)

    def _check_write(self, attr):
        if self.tile.ready:
            msg = "Tile {} are ready so the Lightcurve.{} is readonly"
            raise AttributeError(msg.format(self.tile.name, attr))

    def _set_cnt(self, ids):
        cnt = Counter(ids)
        gen = (e for e in cnt.items())
        dtype = [("id", np.int64), ("cnt", int)]
        self._src_obs_counter = np.fromiter(gen, dtype=dtype)

    @property
    def lc_path(self):
        path = os.path.join(settings.LC_DIR, self.tile.name)
        if not os.path.isdir(path):
            os.makedirs(path)
        return path

    @property
    def obs_counter(self):
        return self._src_obs_counter

    @property
    def observations(self):
        fname = "lc_obs_{}.npy".format(self.tile.name)
        path = os.path.join(self.lc_path, fname)
        if os.path.exists(path):
            return np.load(path)

    @observations.setter
    def observations(self, arr):
        self._check_write("observations")
        self._set_cnt(arr["bm_src_id"])
        fname = "lc_obs_{}.npy".format(self.tile.name)
        path = os.path.join(self.lc_path, fname)
        np.save(path, arr)

    @property
    def features(self):
        fname = "features_{}.npy".format(self.tile.name)
        path = os.path.join(self.lc_path, fname)
        if os.path.exists(path):
            return np.load(path)

    @features.setter
    def features(self, arr):
        self._check_write("features")
        fname = "features_{}.npy".format(self.tile.name)
        path = os.path.join(self.lc_path, fname)
        np.save(path, arr)
Пример #9
0
class DetectedHOT(db.Model):

    __tablename__ = "DetectedHOT"

    id = db.Column(db.Integer, primary_key=True)

    NUMBER = db.Column(db.Integer, nullable=False)
    FLUX_ISO = db.Column(db.Float, nullable=False)
    FLUXERR_ISO = db.Column(db.Float, nullable=False)
    MAG_ISO = db.Column(db.Float, nullable=False)
    MAGERR_ISO = db.Column(db.Float, nullable=False)
    FLUX_APER = db.Column(db.Float, nullable=False)
    FLUXERR_APER = db.Column(db.Float, nullable=False)
    MAG_APER = db.Column(db.Float, nullable=False)
    MAGERR_APER = db.Column(db.Float, nullable=False)
    FLUX_AUTO = db.Column(db.Float, nullable=False)
    FLUXERR_AUTO = db.Column(db.Float, nullable=False)
    MAG_AUTO = db.Column(db.Float, nullable=False)
    MAGERR_AUTO = db.Column(db.Float, nullable=False)
    BACKGROUND = db.Column(db.Float, nullable=False)
    THRESHOLD = db.Column(db.Float, nullable=False)
    FLUX_MAX = db.Column(db.Float, nullable=False)
    XMIN_IMAGE = db.Column(db.Float, nullable=False)
    YMIN_IMAGE = db.Column(db.Float, nullable=False)
    XMAX_IMAGE = db.Column(db.Float, nullable=False)
    YMAX_IMAGE = db.Column(db.Float, nullable=False)
    XPEAK_IMAGE = db.Column(db.Float, nullable=False)
    YPEAK_IMAGE = db.Column(db.Float, nullable=False)
    X_IMAGE = db.Column(db.Float, nullable=False)
    Y_IMAGE = db.Column(db.Float, nullable=False)
    X2_IMAGE = db.Column(db.Float, nullable=False)
    Y2_IMAGE = db.Column(db.Float, nullable=False)
    XY_IMAGE = db.Column(db.Float, nullable=False)
    CXX_IMAGE = db.Column(db.Float, nullable=False)
    CYY_IMAGE = db.Column(db.Float, nullable=False)
    CXY_IMAGE = db.Column(db.Float, nullable=False)
    A_IMAGE = db.Column(db.Float, nullable=False)
    B_IMAGE = db.Column(db.Float, nullable=False)
    THETA_IMAGE = db.Column(db.Float, nullable=False)
    MU_MAX = db.Column(db.Float, nullable=False)
    FLAGS = db.Column(db.Float, nullable=False)
    FWHM_IMAGE = db.Column(db.Float, nullable=False)
    ELONGATION = db.Column(db.Float, nullable=False)
    ELLIPTICITY = db.Column(db.Float, nullable=False)
    CLASS_STAR = db.Column(db.Float, nullable=False)
    MU_THRESHOLD = db.Column(db.Float, nullable=False)
    SNR_WIN = db.Column(db.Float, nullable=False)

    DELTAX = db.Column(db.Float, nullable=False)
    DELTAY = db.Column(db.Float, nullable=False)
    RATIO = db.Column(db.Float, nullable=False)
    ROUNDNESS = db.Column(db.Float, nullable=False)
    PEAK_CENTROID = db.Column(db.Float, nullable=False)
    IS_REAL = db.Column(db.Boolean, nullable=True)

    image_id = db.Column(db.Integer, db.ForeignKey('ImagesHOT.id'))
    image = db.relationship('ImagesHOT',
                            backref=db.backref('detected_srcs', order_by=id))

    def __repr__(self):
        return '{}::{}'.format(self.image, self.NUMBER)