Exemplo n.º 1
0
    def testSM(self):
        keys = [
            'O', 'B', 'A', 'F', 'G', 'K', 'M', 'HeWD_25200_80', 'WD_11000_85',
            'WD_3000_85'
        ]
        filterNames = ['u', 'g', 'r', 'i', 'z', 'y']

        # Check each type returns the correct format
        for key in keys:
            result = utils.stellarMags(key)
            for fn in filterNames:
                self.assertIn(fn, result)
                self.assertTrue(
                    (isinstance(result[fn], float)) |
                    (isinstance(result[fn], np.float64)),
                    msg='result is neither a float nor a numpy float64')

        # Check the exception gets raised
        self.assertRaises(ValueError, utils.stellarMags, 'ack')

        # Check the mags get fainter
        for st in keys:
            mags = utils.stellarMags(st)
            mags2 = utils.stellarMags(st, rmag=20.)
        for key in mags:
            self.assertLess(mags[key], mags2[key])
Exemplo n.º 2
0
    def __init__(self, metricName='ParallaxCoverageMetric', m5Col='fiveSigmaDepth',
                 mjdCol='observationStartMJD', filterCol='filter', seeingCol='seeingFwhmGeom',
                 rmag=20., SedTemplate='flat',
                 atm_err=0.01, thetaRange=0., snrLimit=5, **kwargs):
        cols = ['ra_pi_amp', 'dec_pi_amp', m5Col, mjdCol, filterCol, seeingCol]
        units = 'ratio'
        super(ParallaxCoverageMetric, self).__init__(cols,
                                                     metricName=metricName, units=units,
                                                     **kwargs)
        self.m5Col = m5Col
        self.seeingCol = seeingCol
        self.filterCol = filterCol
        self.mjdCol = mjdCol

        # Demand the range of theta values
        self.thetaRange = thetaRange
        self.snrLimit = snrLimit

        filters = ['u', 'g', 'r', 'i', 'z', 'y']
        self.mags = {}
        if SedTemplate == 'flat':
            for f in filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
        self.atm_err = atm_err
        caption = "Parallax factor coverage for an r=%.2f star (0 is bad, 0.5-1 is good). " % (rmag)
        caption += "One expects the parallax factor coverage to vary because stars on the ecliptic "
        caption += "can be observed when they have no parallax offset while stars at the pole are always "
        caption += "offset by the full parallax offset."""
        self.comment = caption
Exemplo n.º 3
0
    def __init__(self,
                 metricName='properMotion',
                 m5Col='fiveSigmaDepth',
                 mjdCol='observationStartMJD',
                 units='mas/yr',
                 filterCol='filter',
                 seeingCol='seeingFwhmGeom',
                 rmag=20.,
                 SedTemplate='flat',
                 badval=-666,
                 atm_err=0.01,
                 normalize=False,
                 baseline=10.,
                 **kwargs):
        """ Instantiate metric.

        m5Col = column name for inidivual visit m5
        mjdCol = column name for exposure time dates
        filterCol = column name for filter
        seeingCol = column name for seeing (assumed FWHM)
        rmag = mag of fiducial star in r filter.  Other filters are scaled using sedTemplate keyword
        sedTemplate = template to use (can be 'flat' or 'O','B','A','F','G','K','M')
        atm_err = centroiding error due to atmosphere in arcsec
        normalize = Compare to the uncertainty that would result if half
        the observations were taken at the start of the survey and half
        at the end.  A 'perfect' survey will have a value close to unity,
        while a poorly scheduled survey will be close to zero.
        baseline = The length of the survey used for the normalization (years)
        """
        cols = [m5Col, mjdCol, filterCol, seeingCol]
        if normalize:
            units = 'ratio'
        super(ProperMotionMetric, self).__init__(col=cols,
                                                 metricName=metricName,
                                                 units=units,
                                                 badval=badval,
                                                 **kwargs)
        # set return type
        self.mjdCol = mjdCol
        self.seeingCol = seeingCol
        self.m5Col = m5Col
        filters = ['u', 'g', 'r', 'i', 'z', 'y']
        self.mags = {}
        if SedTemplate == 'flat':
            for f in filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
        self.atm_err = atm_err
        self.normalize = normalize
        self.baseline = baseline
        self.comment = 'Estimated uncertainty of the proper motion fit (assuming no parallax or that parallax is well fit). '
        self.comment += 'Uses visits in all bands, and generates approximate astrometric errors using the SNR in each visit. '
        if SedTemplate == 'flat':
            self.comment += 'Assumes a flat SED. '
        if self.normalize:
            self.comment += 'This normalized version of the metric represents the estimated uncertainty in the proper '
            self.comment += 'motion divided by the minimum uncertainty possible (if all visits were '
            self.comment += 'obtained on the first and last days of the survey). Values closer to 1 '
            self.comment += 'indicate more optimal scheduling.'
Exemplo n.º 4
0
    def __init__(self, metricName='ParallaxHADegenMetric',haCol='HA', snrLimit=5.,
                 m5Col='fiveSigmaDepth', mjdCol='expMJD',
                 filterCol='filter', seeingCol='FWHMgeom',
                 rmag=20., SedTemplate='flat', badval=-666,
                 **kwargs ):
        """
        haCol = Hour angle column name
        snrLimit = only inlcude observations above the snrLimit
        m5Col = column name for inidivual visit m5
        mjdCol = column name for exposure time dates
        filterCol = column name for filter
        seeingCol = column name for seeing (assumed FWHM)
        rmag = mag of fiducial star in r filter.  Other filters are scaled using sedTemplate keyword
        sedTemplate = template to use (can be 'flat' or 'O','B','A','F','G','K','M')
        """

        cols = ['ra_pi_amp', 'dec_pi_amp']
        self.haCol = haCol
        cols.append(haCol)
        units = 'Correlation'
        self.snrLimit = snrLimit
        super(ParallaxHADegenMetric, self).__init__(cols,
                                                    metricName=metricName,
                                                    units=units, **kwargs)
        self.m5Col = m5Col
        self.seeingCol = seeingCol
        self.filterCol = filterCol
        self.mjdCol = mjdCol
        filters=['u','g','r','i','z','y']
        self.mags={}
        if SedTemplate == 'flat':
            for f in filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
Exemplo n.º 5
0
 def __init__(self,
              metricName='ParallaxDcrDegenMetric',
              seeingCol='seeingFwhmGeom',
              m5Col='fiveSigmaDepth',
              atm_err=0.01,
              rmag=20.,
              SedTemplate='flat',
              filterCol='filter',
              tol=0.05,
              **kwargs):
     self.m5Col = m5Col
     self.seeingCol = seeingCol
     self.filterCol = filterCol
     self.tol = tol
     units = 'Correlation'
     # just put all the columns that all the stackers will need here?
     cols = [
         'ra_pi_amp', 'dec_pi_amp', 'ra_dcr_amp', 'dec_dcr_amp', seeingCol,
         m5Col
     ]
     super(ParallaxDcrDegenMetric, self).__init__(cols,
                                                  metricName=metricName,
                                                  units=units,
                                                  **kwargs)
     self.filters = ['u', 'g', 'r', 'i', 'z', 'y']
     self.mags = {}
     if SedTemplate == 'flat':
         for f in self.filters:
             self.mags[f] = rmag
     else:
         self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
     self.atm_err = atm_err
Exemplo n.º 6
0
    def __init__(self,
                 metricName='DCRprecision',
                 seeingCol='seeingFwhmGeom',
                 m5Col='fiveSigmaDepth',
                 HACol='HA',
                 PACol='paraAngle',
                 filterCol='filter',
                 atm_err=0.01,
                 SedTemplate='flat',
                 rmag=20.,
                 **kwargs):

        self.m5Col = m5Col
        self.filterCol = filterCol
        self.PACol = PACol
        self.seeingCol = seeingCol
        self.mags = {}
        self.filters = ['u', 'g', 'r', 'i', 'z', 'y']
        if SedTemplate == 'flat':
            for f in self.filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
        cols = [
            'ra_dcr_amp', 'dec_dcr_amp', seeingCol, m5Col, filterCol,
            'zenithDistance', PACol
        ]
        units = 'arcseconds'
        self.atm_err = atm_err
        super(DcrPrecisionMetric, self).__init__(cols,
                                                 metricName=metricName,
                                                 units=units,
                                                 **kwargs)
Exemplo n.º 7
0
    def __init__(self,
                 metricName='parallax',
                 m5Col='fiveSigmaDepth',
                 mjdCol='expMJD',
                 units='mas',
                 filterCol='filter',
                 seeingCol='FWHMgeom',
                 rmag=20.,
                 SedTemplate='flat',
                 badval=-666,
                 atm_err=0.01,
                 normalize=False,
                 **kwargs):
        """ Instantiate metric.

        m5Col = column name for inidivual visit m5
        mjdCol = column name for exposure time dates
        filterCol = column name for filter
        seeingCol = column name for seeing/FWHMgeom
        rmag = mag of fiducial star in r filter.  Other filters are scaled using sedTemplate keyword
        SedTemplate = string of 'flat' or 'O','B','A','F','G','K','M'.
        atm_err = centroiding error due to atmosphere in arcsec
        normalize = Compare to a survey that has all observations with maximum parallax factor.
        An optimally scheduled survey would be expected to have a normalized value close to unity,
        and zero for a survey where the parallax can not be measured.

        return uncertainty in mas. Or normalized map as a fraction
        """
        Cols = [m5Col, mjdCol, filterCol, seeingCol, 'ra_pi_amp', 'dec_pi_amp']
        if normalize:
            units = 'ratio'
        super(ParallaxMetric, self).__init__(Cols,
                                             metricName=metricName,
                                             units=units,
                                             badval=badval,
                                             **kwargs)
        # set return type
        self.m5Col = m5Col
        self.seeingCol = seeingCol
        self.filterCol = filterCol
        filters = ['u', 'g', 'r', 'i', 'z', 'y']
        self.mags = {}
        if SedTemplate == 'flat':
            for f in filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
        self.atm_err = atm_err
        self.normalize = normalize
        self.comment = 'Estimated uncertainty in parallax measurement (assuming no proper motion or that proper motion '
        self.comment += 'is well fit). Uses measurements in all bandpasses, and estimates astrometric error based on SNR '
        self.comment += 'in each visit. '
        if SedTemplate == 'flat':
            self.comment += 'Assumes a flat SED. '
        if self.normalize:
            self.comment += 'This normalized version of the metric displays the estimated uncertainty in the parallax measurement, '
            self.comment += 'divided by the minimum parallax uncertainty possible (if all visits were six '
            self.comment += 'months apart). Values closer to 1 indicate more optimal scheduling for parallax measurement.'
Exemplo n.º 8
0
    def __init__(self,
                 metricName='ParallaxCoverageMetric',
                 m5Col='fiveSigmaDepth',
                 mjdCol='observationStartMJD',
                 filterCol='filter',
                 seeingCol='seeingFwhmGeom',
                 rmag=20.,
                 SedTemplate='flat',
                 badval=-666,
                 atm_err=0.01,
                 thetaRange=0.,
                 snrLimit=5,
                 **kwargs):
        """
        instantiate metric

        m5Col = column name for inidivual visit m5
        mjdCol = column name for exposure time dates
        filterCol = column name for filter
        seeingCol = column name for seeing (assumed FWHM)
        rmag = mag of fiducial star in r filter.  Other filters are scaled using sedTemplate keyword
        sedTemplate = template to use (can be 'flat' or 'O','B','A','F','G','K','M')
        atm_err = centroiding error due to atmosphere in arcsec
        thetaRange = range of parallax offset angles to demand (in radians) default=0 means no range requirement
        snrLimit = only include points above the snrLimit (default 5) when computing thetaRange.
        """

        cols = ['ra_pi_amp', 'dec_pi_amp', m5Col, mjdCol, filterCol, seeingCol]
        units = 'ratio'
        super(ParallaxCoverageMetric, self).__init__(cols,
                                                     metricName=metricName,
                                                     units=units,
                                                     **kwargs)
        self.m5Col = m5Col
        self.seeingCol = seeingCol
        self.filterCol = filterCol
        self.mjdCol = mjdCol

        # Demand the range of theta values
        self.thetaRange = thetaRange
        self.snrLimit = snrLimit

        filters = ['u', 'g', 'r', 'i', 'z', 'y']
        self.mags = {}
        if SedTemplate == 'flat':
            for f in filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
        self.atm_err = atm_err
Exemplo n.º 9
0
    def __init__(self, metricName='parallax', m5Col='fiveSigmaDepth',
                 mjdCol='expMJD', units = 'mas',
                 filterCol='filter', seeingCol='FWHMgeom', rmag=20.,
                 SedTemplate='flat', badval=-666,
                 atm_err=0.01, normalize=False,**kwargs):

        """ Instantiate metric.

        m5Col = column name for inidivual visit m5
        mjdCol = column name for exposure time dates
        filterCol = column name for filter
        seeingCol = column name for seeing/FWHMgeom
        rmag = mag of fiducial star in r filter.  Other filters are scaled using sedTemplate keyword
        SedTemplate = string of 'flat' or 'O','B','A','F','G','K','M'.
        atm_err = centroiding error due to atmosphere in arcsec
        normalize = Compare to a survey that has all observations with maximum parallax factor.
        An optimally scheduled survey would be expected to have a normalized value close to unity,
        and zero for a survey where the parallax can not be measured.

        return uncertainty in mas. Or normalized map as a fraction
        """
        Cols = [m5Col, mjdCol,filterCol,seeingCol, 'ra_pi_amp', 'dec_pi_amp']
        if normalize:
            units = 'ratio'
        super(ParallaxMetric, self).__init__(Cols, metricName=metricName, units=units,
                                             badval=badval, **kwargs)
        # set return type
        self.m5Col = m5Col
        self.seeingCol = seeingCol
        self.filterCol = filterCol
        filters=['u','g','r','i','z','y']
        self.mags={}
        if SedTemplate == 'flat':
            for f in filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
        self.atm_err = atm_err
        self.normalize = normalize
        self.comment = 'Estimated uncertainty in parallax measurement (assuming no proper motion or that proper motion '
        self.comment += 'is well fit). Uses measurements in all bandpasses, and estimates astrometric error based on SNR '
        self.comment += 'in each visit. '
        if SedTemplate == 'flat':
            self.comment += 'Assumes a flat SED. '
        if self.normalize:
            self.comment += 'This normalized version of the metric displays the estimated uncertainty in the parallax measurement, '
            self.comment += 'divided by the minimum parallax uncertainty possible (if all visits were six '
            self.comment += 'months apart). Values closer to 1 indicate more optimal scheduling for parallax measurement.'
Exemplo n.º 10
0
    def __init__(self, metricName='properMotion',
                 m5Col='fiveSigmaDepth', mjdCol='expMJD', units='mas/yr',
                 filterCol='filter', seeingCol='FWHMgeom',  rmag=20.,
                 SedTemplate='flat', badval= -666,
                 atm_err=0.01, normalize=False,
                 baseline=10., **kwargs):
        """ Instantiate metric.

        m5Col = column name for inidivual visit m5
        mjdCol = column name for exposure time dates
        filterCol = column name for filter
        seeingCol = column name for seeing (assumed FWHM)
        rmag = mag of fiducial star in r filter.  Other filters are scaled using sedTemplate keyword
        sedTemplate = template to use (can be 'flat' or 'O','B','A','F','G','K','M')
        atm_err = centroiding error due to atmosphere in arcsec
        normalize = Compare to the uncertainty that would result if half
        the observations were taken at the start of the survey and half
        at the end.  A 'perfect' survey will have a value close to unity,
        while a poorly scheduled survey will be close to zero.
        baseline = The length of the survey used for the normalization (years)
        """
        cols = [m5Col, mjdCol,filterCol,seeingCol]
        if normalize:
            units = 'ratio'
        super(ProperMotionMetric, self).__init__(col=cols, metricName=metricName, units=units,
                                                 badval=badval, **kwargs)
        # set return type
        self.seeingCol = seeingCol
        self.m5Col = m5Col
        filters=['u','g','r','i','z','y']
        self.mags={}
        if SedTemplate == 'flat':
            for f in filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
        self.atm_err = atm_err
        self.normalize = normalize
        self.baseline = baseline
        self.comment = 'Estimated uncertainty of the proper motion fit (assuming no parallax or that parallax is well fit). '
        self.comment += 'Uses visits in all bands, and generates approximate astrometric errors using the SNR in each visit. '
        if SedTemplate == 'flat':
            self.comment += 'Assumes a flat SED. '
        if self.normalize:
            self.comment += 'This normalized version of the metric represents the estimated uncertainty in the proper '
            self.comment += 'motion divided by the minimum uncertainty possible (if all visits were '
            self.comment += 'obtained on the first and last days of the survey). Values closer to 1 '
            self.comment += 'indicate more optimal scheduling.'
Exemplo n.º 11
0
    def __init__(self, metricName='ParallaxHADegenMetric',haCol='HA', snrLimit=5.,
                 m5Col='fiveSigmaDepth', mjdCol='expMJD',
                 filterCol='filter', seeingCol='FWHMgeom',
                 rmag=20., SedTemplate='flat', \
                     useSpearmanR=False,\
                     badval=-666,
                 **kwargs ):
        """
        haCol = Hour angle column name
        snrLimit = only inlcude observations above the snrLimit
        m5Col = column name for inidivual visit m5
        mjdCol = column name for exposure time dates
        filterCol = column name for filter
        seeingCol = column name for seeing (assumed FWHM)
        rmag = mag of fiducial star in r filter.  Other filters are scaled using sedTemplate keyword
        sedTemplate = template to use (can be 'flat' or 'O','B','A','F','G','K','M')
        useSpearmanR = use spearman-r coefficient for correlation? (Default False)
        """

        cols = ['ra_pi_amp', 'dec_pi_amp']
        self.haCol = haCol
        cols.append(haCol)
        units = 'Correlation'
        self.snrLimit = snrLimit

        # 2016-05-01: New instance-level variable - what correlation
        # method are we using?
        self.correlMethod = pearsonr
        if useSpearmanR:
            self.correlMethod = spearmanr

        super(ParallaxHADegenMetric, self).__init__(cols,
                                                    metricName=metricName,
                                                    units=units, \
                                                        **kwargs)
        self.m5Col = m5Col
        self.seeingCol = seeingCol
        self.filterCol = filterCol
        self.mjdCol = mjdCol
        filters = ['u', 'g', 'r', 'i', 'z', 'y']
        self.mags = {}
        if SedTemplate == 'flat':
            for f in filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
Exemplo n.º 12
0
    def __init__(self, metricName='ParallaxHADegenMetric',haCol='HA', snrLimit=5.,
                 m5Col='fiveSigmaDepth', mjdCol='expMJD',
                 filterCol='filter', seeingCol='FWHMgeom',
                 rmag=20., SedTemplate='flat', \
                     useSpearmanR=False,\
                     badval=-666,
                 **kwargs ):
        """
        haCol = Hour angle column name
        snrLimit = only inlcude observations above the snrLimit
        m5Col = column name for inidivual visit m5
        mjdCol = column name for exposure time dates
        filterCol = column name for filter
        seeingCol = column name for seeing (assumed FWHM)
        rmag = mag of fiducial star in r filter.  Other filters are scaled using sedTemplate keyword
        sedTemplate = template to use (can be 'flat' or 'O','B','A','F','G','K','M')
        useSpearmanR = use spearman-r coefficient for correlation? (Default False)
        """

        cols = ['ra_pi_amp', 'dec_pi_amp']
        self.haCol = haCol
        cols.append(haCol)
        units = 'Correlation'
        self.snrLimit = snrLimit

        # 2016-05-01: New instance-level variable - what correlation
        # method are we using?
        self.correlMethod = pearsonr
        if useSpearmanR:
            self.correlMethod = spearmanr

        super(ParallaxHADegenMetric, self).__init__(cols,
                                                    metricName=metricName,
                                                    units=units, \
                                                        **kwargs)
        self.m5Col = m5Col
        self.seeingCol = seeingCol
        self.filterCol = filterCol
        self.mjdCol = mjdCol
        filters=['u','g','r','i','z','y']
        self.mags={}
        if SedTemplate == 'flat':
            for f in filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
Exemplo n.º 13
0
    def __init__(self,
                 metricName='ParallaxHADegenMetric',
                 haCol='HA',
                 snrLimit=5.,
                 m5Col='fiveSigmaDepth',
                 mjdCol='expMJD',
                 filterCol='filter',
                 seeingCol='FWHMgeom',
                 rmag=20.,
                 SedTemplate='flat',
                 badval=-666,
                 **kwargs):
        """
        haCol = Hour angle column name
        snrLimit = only inlcude observations above the snrLimit
        m5Col = column name for inidivual visit m5
        mjdCol = column name for exposure time dates
        filterCol = column name for filter
        seeingCol = column name for seeing (assumed FWHM)
        rmag = mag of fiducial star in r filter.  Other filters are scaled using sedTemplate keyword
        sedTemplate = template to use (can be 'flat' or 'O','B','A','F','G','K','M')
        """

        cols = ['ra_pi_amp', 'dec_pi_amp']
        self.haCol = haCol
        cols.append(haCol)
        units = 'Correlation'
        self.snrLimit = snrLimit
        super(ParallaxHADegenMetric, self).__init__(cols,
                                                    metricName=metricName,
                                                    units=units,
                                                    **kwargs)
        self.m5Col = m5Col
        self.seeingCol = seeingCol
        self.filterCol = filterCol
        self.mjdCol = mjdCol
        filters = ['u', 'g', 'r', 'i', 'z', 'y']
        self.mags = {}
        if SedTemplate == 'flat':
            for f in filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
Exemplo n.º 14
0
    def run(self, dataSlice, slicePoint=None):
        result = 0
        n_pts = np.size(dataSlice[self.mjdCol])
        n_filt = np.size(np.unique(dataSlice[self.filterCol]))

        # If we had a correct model with phase, amplitude, period, mean_mags, then chi_squared/DoF would be ~1 with 3+n_filt free parameters.
        # The mean is one free parameter
        p1 = n_filt
        p2 = 3. + n_filt
        chi_sq_2 = 1. * (n_pts - p2)

        u_filters = np.unique(dataSlice[self.filterCol])

        if n_pts > p2:
            for period, starMag, amplitude in zip(self.periods, self.starMags,
                                                  self.amplitudes):
                chi_sq_1 = 0
                mags = utils.stellarMags(self.SedTemplate, rmag=starMag)
                for filtername in u_filters:
                    in_filt = np.where(
                        dataSlice[self.filterCol] == filtername)[0]
                    lc = amplitude * np.sin(
                        dataSlice[self.mjdCol][in_filt] *
                        (np.pi * 2) / period) + mags[filtername]
                    snr = m52snr(lc, dataSlice[self.m5Col][in_filt])
                    delta_m = 2.5 * np.log10(1. + 1. / snr)
                    weights = 1. / (delta_m**2)
                    weighted_mean = np.sum(weights * lc) / np.sum(weights)
                    chi_sq_1 += np.sum(((lc - weighted_mean)**2 / delta_m**2))
                # Yes, I'm fitting magnitudes rather than flux. At least I feel kinda bad about it.
                # F-test for nested models Regression problems:  https://en.wikipedia.org/wiki/F-test
                f_numerator = (chi_sq_1 - chi_sq_2) / (p2 - p1)
                f_denom = 1.  # This is just reduced chi-squared for the more complicated model, so should be 1.
                f_val = f_numerator / f_denom
                # Has DoF (p2-p1, n-p2)
                # https://stackoverflow.com/questions/21494141/how-do-i-do-a-f-test-in-python/21503346
                p_value = scipy.stats.f.sf(f_val, p2 - p1, n_pts - p2)
                if np.isfinite(p_value):
                    if p_value < self.sig_level:
                        result += 1

        return result
Exemplo n.º 15
0
 def __init__(self, metricName='ParallaxDcrDegenMetric', seeingCol='seeingFwhmGeom',
              m5Col='fiveSigmaDepth', atm_err=0.01, rmag=20., SedTemplate='flat',
              filterCol='filter', tol=0.05, **kwargs):
     self.m5Col = m5Col
     self.seeingCol = seeingCol
     self.filterCol = filterCol
     self.tol = tol
     units = 'Correlation'
     # just put all the columns that all the stackers will need here?
     cols = ['ra_pi_amp', 'dec_pi_amp', 'ra_dcr_amp', 'dec_dcr_amp',
             seeingCol, m5Col]
     super(ParallaxDcrDegenMetric, self).__init__(cols, metricName=metricName, units=units,
                                                  **kwargs)
     self.filters = ['u', 'g', 'r', 'i', 'z', 'y']
     self.mags = {}
     if SedTemplate == 'flat':
         for f in self.filters:
             self.mags[f] = rmag
     else:
         self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
     self.atm_err = atm_err
Exemplo n.º 16
0
 def __init__(self, metricName='properMotion',
              m5Col='fiveSigmaDepth', mjdCol='observationStartMJD',
              filterCol='filter', seeingCol='seeingFwhmGeom', rmag=20.,
              SedTemplate='flat', badval= -666,
              atm_err=0.01, normalize=False,
              baseline=10., **kwargs):
     cols = [m5Col, mjdCol, filterCol, seeingCol]
     if normalize:
         units = 'ratio'
     else:
         units = 'mas/yr'
     super(ProperMotionMetric, self).__init__(col=cols, metricName=metricName, units=units,
                                              badval=badval, **kwargs)
     # set return type
     self.mjdCol = mjdCol
     self.seeingCol = seeingCol
     self.m5Col = m5Col
     filters = ['u', 'g', 'r', 'i', 'z', 'y']
     self.mags = {}
     if SedTemplate == 'flat':
         for f in filters:
             self.mags[f] = rmag
     else:
         self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
     self.atm_err = atm_err
     self.normalize = normalize
     self.baseline = baseline
     self.comment = 'Estimated uncertainty of the proper motion fit ' \
                    '(assuming no parallax or that parallax is well fit). '
     self.comment += 'Uses visits in all bands, and generates approximate ' \
                     'astrometric errors using the SNR in each visit. '
     if SedTemplate == 'flat':
         self.comment += 'Assumes a flat SED. '
     if self.normalize:
         self.comment += 'This normalized version of the metric represents ' \
                         'the estimated uncertainty in the proper '
         self.comment += 'motion divided by the minimum uncertainty possible ' \
                         '(if all visits were '
         self.comment += 'obtained on the first and last days of the survey). '
         self.comment += 'Values closer to 1 indicate more optimal scheduling.'
Exemplo n.º 17
0
    def __init__(self, metricName='ParallaxCoverageMetric', m5Col='fiveSigmaDepth',
                 mjdCol='expMJD', filterCol='filter', seeingCol='FWHMgeom',
                 rmag=20., SedTemplate='flat', badval=-666,
                 atm_err=0.01, thetaRange=0., snrLimit=5, **kwargs):
        """
        instantiate metric

        m5Col = column name for inidivual visit m5
        mjdCol = column name for exposure time dates
        filterCol = column name for filter
        seeingCol = column name for seeing (assumed FWHM)
        rmag = mag of fiducial star in r filter.  Other filters are scaled using sedTemplate keyword
        sedTemplate = template to use (can be 'flat' or 'O','B','A','F','G','K','M')
        atm_err = centroiding error due to atmosphere in arcsec
        thetaRange = range of parallax offset angles to demand (in radians) default=0 means no range requirement
        snrLimit = only include points above the snrLimit (default 5) when computing thetaRange.
        """

        cols = ['ra_pi_amp', 'dec_pi_amp', m5Col, mjdCol, filterCol, seeingCol]
        units = 'ratio'
        super(ParallaxCoverageMetric, self).__init__(cols,
                                                     metricName=metricName, units=units,
                                                      **kwargs)
        self.m5Col = m5Col
        self.seeingCol = seeingCol
        self.filterCol = filterCol
        self.mjdCol = mjdCol

        # Demand the range of theta values
        self.thetaRange = thetaRange
        self.snrLimit = snrLimit

        filters=['u','g','r','i','z','y']
        self.mags={}
        if SedTemplate == 'flat':
            for f in filters:
                self.mags[f] = rmag
        else:
            self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
        self.atm_err = atm_err
Exemplo n.º 18
0
 def __init__(self, metricName='parallax', m5Col='fiveSigmaDepth',
              filterCol='filter', seeingCol='seeingFwhmGeom', rmag=20.,
              SedTemplate='flat', badval=-666,
              atm_err=0.01, normalize=False, **kwargs):
     Cols = [m5Col, filterCol, seeingCol, 'ra_pi_amp', 'dec_pi_amp']
     if normalize:
         units = 'ratio'
     else:
         units = 'mas'
     super(ParallaxMetric, self).__init__(Cols, metricName=metricName, units=units,
                                          badval=badval, **kwargs)
     # set return type
     self.m5Col = m5Col
     self.seeingCol = seeingCol
     self.filterCol = filterCol
     filters = ['u', 'g', 'r', 'i', 'z', 'y']
     self.mags = {}
     if SedTemplate == 'flat':
         for f in filters:
             self.mags[f] = rmag
     else:
         self.mags = utils.stellarMags(SedTemplate, rmag=rmag)
     self.atm_err = atm_err
     self.normalize = normalize
     self.comment = 'Estimated uncertainty in parallax measurement ' \
                    '(assuming no proper motion or that proper motion '
     self.comment += 'is well fit). Uses measurements in all bandpasses, ' \
                     'and estimates astrometric error based on SNR '
     self.comment += 'in each visit. '
     if SedTemplate == 'flat':
         self.comment += 'Assumes a flat SED. '
     if self.normalize:
         self.comment += 'This normalized version of the metric displays the ' \
                         'estimated uncertainty in the parallax measurement, '
         self.comment += 'divided by the minimum parallax uncertainty possible ' \
                         '(if all visits were six '
         self.comment += 'months apart). Values closer to 1 indicate more optimal ' \
                         'scheduling for parallax measurement.'