当前位置: 首页>>代码示例>>Python>>正文


Python Bandpass.readThroughput方法代码示例

本文整理汇总了Python中lsst.sims.photUtils.Bandpass.readThroughput方法的典型用法代码示例。如果您正苦于以下问题:Python Bandpass.readThroughput方法的具体用法?Python Bandpass.readThroughput怎么用?Python Bandpass.readThroughput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lsst.sims.photUtils.Bandpass的用法示例。


在下文中一共展示了Bandpass.readThroughput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: buildVendorDetector

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
def buildVendorDetector(vendorDir, addLosses=True):
    """
    Builds a detector response from the files in vendorDir, by reading the *_QE.dat
      and *_Losses subdirectory for a single version of the detector.
    Returns a Bandpass object.
    If addLosses is True, the QE curve is multiplied by the losses in the *Losses.dat files.
    If addLosses is False, the QE curve does not have any losses included.
    """
    # Read the QE file.
    qefile = glob(os.path.join(vendorDir, '*_QE.dat'))
    if len(qefile) != 1:
        raise ValueError('Expected a single QE file in this directory, found: ', qefile)
    qefile = qefile[0]
    qe = Bandpass()
    qe.readThroughput(qefile)
    if addLosses:
        loss = _readLosses(vendorDir)
        wavelength, sb = qe.multiplyThroughputs(loss.wavelen, loss.sb)
        qe.setBandpass(wavelength, sb)
    # Verify that no values go significantly below zero.
    belowzero = np.where(qe.sb < 0)
    # If there are QE values significantly < 0, raise an exception.
    if qe.sb[belowzero] < belowZeroThreshhold:
        raise ValueError('Found values in QE response significantly below zero.')
    # If they are just small errors in interpolation, set to zero.
    qe.sb[belowzero] = 0
    return qe
开发者ID:krvikassingh,项目名称:syseng_throughputs,代码行数:29,代码来源:bandpassUtils.py

示例2: loadTotalBandpassesFromFiles

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
    def loadTotalBandpassesFromFiles(cls,
                                    bandpassNames=['u', 'g', 'r', 'i', 'z', 'y'],
                                    bandpassDir = os.path.join(getPackageDir('throughputs'),'baseline'),
                                    bandpassRoot = 'total_'):
        """
        This will take the list of band passes named by bandpassNames and load them into
        a BandpassDict

        The bandpasses loaded this way are total bandpasses: they account for instrumental
        and atmospheric transmission.

        @param [in] bandpassNames is a list of names identifying each filter.
        Defaults to ['u', 'g', 'r', 'i', 'z', 'y']

        @param [in] bandpassDir is the name of the directory where the bandpass files are stored

        @param [in] bandpassRoot contains the first part of the bandpass file name, i.e., it is assumed
        that the bandpasses are stored in files of the type

        bandpassDir/bandpassRoot_bandpassNames[i].dat

        if we want to load bandpasses for a telescope other than LSST, we would do so
        by altering bandpassDir and bandpassRoot

        @param [out] bandpassDict is a BandpassDict containing the loaded throughputs
        """

        bandpassList = []

        for w in bandpassNames:
            bandpassDummy = Bandpass()
            bandpassDummy.readThroughput(os.path.join(bandpassDir,"%s.dat" % (bandpassRoot + w)))
            bandpassList.append(bandpassDummy)

        return cls(bandpassList, bandpassNames)
开发者ID:mpwiesner,项目名称:sims_photUtils,代码行数:37,代码来源:BandpassDict.py

示例3: testLoadTotalBandpassesFromFiles

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
    def testLoadTotalBandpassesFromFiles(self):
        """
        Test that the class method loadTotalBandpassesFromFiles produces the
        expected result
        """

        bandpassDir = os.path.join(getPackageDir('sims_photUtils'), 'tests', 'cartoonSedTestData')
        bandpassNames = ['g', 'r', 'u']
        bandpassRoot = 'test_bandpass_'

        bandpassDict = BandpassDict.loadTotalBandpassesFromFiles(bandpassNames=bandpassNames,
                                                                 bandpassDir=bandpassDir,
                                                                 bandpassRoot = bandpassRoot)

        controlBandpassList = []
        for bpn in bandpassNames:
            dummyBp = Bandpass()
            dummyBp.readThroughput(os.path.join(bandpassDir,bandpassRoot+bpn+'.dat'))
            controlBandpassList.append(dummyBp)

        wMin = controlBandpassList[0].wavelen[0]
        wMax = controlBandpassList[0].wavelen[-1]
        wStep = controlBandpassList[0].wavelen[1]-controlBandpassList[0].wavelen[0]

        for bp in controlBandpassList:
            bp.resampleBandpass(wavelen_min=wMin, wavelen_max=wMax, wavelen_step=wStep)

        for test, control in zip(bandpassDict.values(), controlBandpassList):
            numpy.testing.assert_array_almost_equal(test.wavelen, control.wavelen, 19)
            numpy.testing.assert_array_almost_equal(test.sb, control.sb, 19)
开发者ID:jonathansick-shadow,项目名称:sims_photUtils,代码行数:32,代码来源:testBandpassDict.py

示例4: setUp

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
    def setUp(self):

        starFileName = os.path.join(lsst.utils.getPackageDir("sims_sed_library"), "starSED")
        starFileName = os.path.join(starFileName, "kurucz", "km20_5750.fits_g40_5790.gz")
        starName = os.path.join(lsst.utils.getPackageDir("sims_sed_library"), starFileName)
        self.starSED = Sed()
        self.starSED.readSED_flambda(starName)
        imsimband = Bandpass()
        imsimband.imsimBandpass()
        fNorm = self.starSED.calcFluxNorm(22.0, imsimband)
        self.starSED.multiplyFluxNorm(fNorm)

        hardwareDir = os.path.join(lsst.utils.getPackageDir("throughputs"), "baseline")
        componentList = ["detector.dat", "m1.dat", "m2.dat", "m3.dat", "lens1.dat", "lens2.dat", "lens3.dat"]
        self.skySed = Sed()
        self.skySed.readSED_flambda(os.path.join(hardwareDir, "darksky.dat"))

        totalNameList = ["total_u.dat", "total_g.dat", "total_r.dat", "total_i.dat", "total_z.dat", "total_y.dat"]

        self.bpList = []
        self.hardwareList = []
        for name in totalNameList:
            dummy = Bandpass()
            dummy.readThroughput(os.path.join(hardwareDir, name))
            self.bpList.append(dummy)

            dummy = Bandpass()
            hardwareNameList = [os.path.join(hardwareDir, name)]
            for component in componentList:
                hardwareNameList.append(os.path.join(hardwareDir, component))
            dummy.readThroughputList(hardwareNameList)
            self.hardwareList.append(dummy)

        self.filterNameList = ["u", "g", "r", "i", "z", "y"]
开发者ID:mpwiesner,项目名称:sims_photUtils,代码行数:36,代码来源:testSNR.py

示例5: buildMirror

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
def buildMirror(mirrorDir, addLosses=True):
    """
    Build a mirror throughput curve.
    Assumes there are *Losses.dat subdirectory with loss files
       and a m*_Ideal.dat file with the mirror throughput.
    Returns a bandpass object.
    If addLosses is True, the *_Ideal.dat file is multiplied by the *_Losses/*.dat files.
    """
    # Read the mirror reflectance curve.
    mirrorfile = glob(os.path.join(mirrorDir, 'm*Ideal.dat'))
    if len(mirrorfile) != 1:
        raise ValueError('Expected a single mirror file in directory %s, found: ' %mirrorDir, mirrorfile)
    mirrorfile = mirrorfile[0]
    mirror = Bandpass()
    mirror.readThroughput(mirrorfile)
    if addLosses:
        loss = _readLosses(mirrorDir)
        wavelen, sb = mirror.multiplyThroughputs(loss.wavelen, loss.sb)
        mirror.setBandpass(wavelen, sb)
    # Verify that no values go significantly below zero.
    belowzero = np.where(mirror.sb < 0)
    # If there are QE values significantly < 0, raise an exception.
    if mirror.sb[belowzero] < belowZeroThreshhold:
        raise ValueError('Found values in mirror response significantly below zero')
    # If they are just small errors in interpolation, set to zero.
    mirror.sb[belowzero] = 0
    return mirror
开发者ID:krvikassingh,项目名称:syseng_throughputs,代码行数:29,代码来源:bandpassUtils.py

示例6: fit_invsnr

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
def fit_invsnr(mags, floor, m5, bandpass_name='r'):
    filterdir = os.getenv('LSST_THROUGHPUTS_BASELINE')
    bandpass = Bandpass()
    bandpass.readThroughput(os.path.join(filterdir, 'total_%s.dat'%bandpass_name))
    invsnr_arr = []
    for mag in mags:
        snr = flat_sed_snr(mag, bandpass, m5)
        invsnr_arr.append(math.hypot(1./snr, floor))
    return invsnr_arr
开发者ID:DarkEnergyScienceCollaboration,项目名称:Twinkles,代码行数:11,代码来源:calc_snr.py

示例7: read_stdatmo

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
def read_stdatmo(override_filename = None):
    # read the standard atmosphere bandpass file, precomputed by MODTRAN & DaveBurke.
    # this is closely equivalent to atmos_12.dat
    atmosdir = os.getenv("LSST_THROUGHPUTS_ATMOS")
    atmos_bp = Bandpass()
    if override_filename == None:
        atmos_bp.readThroughput(os.path.join(atmosdir, "atmos_std.dat"))
    else:
        atmos_bp.readThroughput(os.path.join(atmosdir, override_filename))
    return atmos_bp
开发者ID:moeyensj,项目名称:atmo2mags-Notebooks,代码行数:12,代码来源:plot_dmagsMod.py

示例8: setUpClass

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
    def setUpClass(cls):
        lsstDefaults=LSSTdefaults()
        cls.dbName = 'uncertaintyTestDB.db'
        if os.path.exists(cls.dbName):
            os.unlink(cls.dbName)

        default_obs_metadata = makePhoSimTestDB(filename=cls.dbName, size=10, radius = 5.0)
        bandpass = ['u', 'g', 'r', 'i', 'z', 'y']
        m5 = lsstDefaults._m5.values()

        cls.obs_metadata = ObservationMetaData(
                                              pointingRA = default_obs_metadata.pointingRA,
                                              pointingDec = default_obs_metadata.pointingDec,
                                              rotSkyPos = default_obs_metadata.rotSkyPos,
                                              bandpassName = bandpass,
                                              m5 = m5
                                              )

        cls.obs_metadata.setBandpassM5andSeeing(bandpassName=bandpass, m5=m5)
        cls.driver = 'sqlite'
        cls.host = ''

        cls.skySeds = []
        cls.hardwareBandpasses = []
        cls.totalBandpasses = []
        cls.bandpasses = ['u', 'g', 'r', 'i', 'z', 'y']

        components = ['detector.dat', 'm1.dat', 'm2.dat', 'm3.dat',
                      'lens1.dat', 'lens2.dat', 'lens3.dat']

        for b in cls.bandpasses:
            bandpassDummy = Bandpass()
            bandpassDummy.readThroughput(os.path.join(lsst.utils.getPackageDir('throughputs'),
                                                      'baseline', 'total_%s.dat' % b))
            cls.totalBandpasses.append(bandpassDummy)

        for b in cls.bandpasses:
            finalComponents = []
            for c in components:
                finalComponents.append(os.path.join(lsst.utils.getPackageDir('throughputs'), 'baseline', c))
            finalComponents.append(os.path.join(lsst.utils.getPackageDir('throughputs'), 'baseline', 'filter_%s.dat' %b))
            bandpassDummy = Bandpass()
            bandpassDummy.readThroughputList(finalComponents)
            cls.hardwareBandpasses.append(bandpassDummy)

        for i in range(len(cls.bandpasses)):
            sedDummy = Sed()
            sedDummy.readSED_flambda(os.path.join(lsst.utils.getPackageDir('throughputs'), 'baseline', 'darksky.dat'))
            normalizedSedDummy = setM5(cls.obs_metadata.m5[cls.bandpasses[i]], sedDummy,
                                       cls.totalBandpasses[i], cls.hardwareBandpasses[i],
                                       FWHMeff=lsstDefaults.FWHMeff(cls.bandpasses[i]),
                                       photParams=PhotometricParameters())

            cls.skySeds.append(normalizedSedDummy)
开发者ID:jonathansick-shadow,项目名称:sims_catUtils,代码行数:56,代码来源:testGetters.py

示例9: getFilesAndBandpasses

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
    def getFilesAndBandpasses(
        self,
        catalog,
        nameRoot=None,
        bandpassDir=os.path.join(lsst.utils.getPackageDir("throughputs"), "baseline"),
        bandpassRoot="total_",
    ):

        """
        Take a GalSimCatalog.  Return a list of fits files and and OrderedDict of bandpasses associated
        with that catalog

        @param [in] catalog is a GalSimCatalog instantiation

        @param [in] nameRoot is the nameRoot prepended to the fits files output by that catalog

        @param[in] bandpassDir is the directory where bandpass files can be found

        @param [in] bandpassRoot is the root of the name of the bandpass files

        @param [out] listOfFiles is a list of the names of the fits files written by this catalog

        @param [out] bandpassDict is an OrderedDict of Bandpass instantiations corresponding to the
        filters in this catalog.
        """

        # write the fits files
        catalog.write_images(nameRoot=nameRoot)

        # a list of bandpasses over which we are integraging
        listOfFilters = []
        listOfFiles = []

        # read in the names of all of the written fits files directly from the
        # InstanceCatalog's GalSimInterpreter
        # Use AFW to read in the FITS files and calculate the ADU
        for name in catalog.galSimInterpreter.detectorImages:
            if nameRoot is not None:
                name = nameRoot + "_" + name

            listOfFiles.append(name)

            if name[-6] not in listOfFilters:
                listOfFilters.append(name[-6])

        bandpassDict = OrderedDict()
        for filterName in listOfFilters:
            bandpassName = os.path.join(bandpassDir, bandpassRoot + filterName + ".dat")
            bandpass = Bandpass()
            bandpass.readThroughput(bandpassName)
            bandpassDict[filterName] = bandpass

        return listOfFiles, bandpassDict
开发者ID:lsst,项目名称:sims_GalSimInterface,代码行数:55,代码来源:testGalSimInterface.py

示例10: make_invsnr_arr

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
def make_invsnr_arr(mag_bright=16., mag_dim=27., mag_delta=0.1, floor=0.02, m5=24.5):
    filterdir = os.getenv('LSST_THROUGHPUTS_BASELINE')
    bandpass = Bandpass()
    bandpass.readThroughput(os.path.join(filterdir, 'total_r.dat'))
    mag = mag_bright
    mag_arr = []
    invsnr_arr = []
    while mag < mag_dim:
        snr = flat_sed_snr(mag, bandpass, m5)
        mag_arr.append(mag)
        invsnr_arr.append(math.hypot(1./snr, floor))
        mag += mag_delta
    return mag_arr, invsnr_arr
开发者ID:jchiang87,项目名称:Twinkles,代码行数:15,代码来源:calc_snr.py

示例11: calcColors

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
def calcColors(sedname='C.dat'):
    # Calculate SSO colors.
    filterdir = os.getenv('LSST_THROUGHPUTS_BASELINE')
    filterlist = ('u', 'g', 'r', 'i', 'z', 'y')
    lsst ={}
    for f in filterlist:
        lsst[f] = Bandpass()
        lsst[f].readThroughput(os.path.join(filterdir, 'total_'+f+'.dat'))
    vband = Bandpass()
    vband.readThroughput('harris_V.dat')
    csed = Sed()
    csed.readSED_flambda(sedname)
    vmag = csed.calcMag(vband)
    dmags = {}
    for f in filterlist:
        dmags[f] = csed.calcMag(lsst[f]) - vmag
    return dmags
开发者ID:mjuric,项目名称:MafSSO,代码行数:19,代码来源:proto2.py

示例12: readAtmosphere

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
def readAtmosphere(atmosDir, atmosFile='pachonModtranAtm_12.dat'):
    """
    Read an atmosphere throughput curve, from the default location 'atmosDir'
     and default filename 'pachonModtranAtm_12.dat'
    Returns a bandpass object.
    """
    atmofile = os.path.join(atmosDir, atmosFile)
    atmo = Bandpass()
    atmo.readThroughput(atmofile)
    # Verify that no values go significantly below zero.
    belowzero = np.where(atmo.sb < 0)
    # If there are QE values significantly < 0, raise an exception.
    if atmo.sb[belowzero] < belowZeroThreshhold:
        raise ValueError('Found values in atmospheric transmission significantly below zero')
    # If they are just small errors in interpolation, set to zero.
    atmo.sb[belowzero] = 0
    return atmo
开发者ID:krvikassingh,项目名称:syseng_throughputs,代码行数:19,代码来源:bandpassUtils.py

示例13: testNoise

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
    def testNoise(self):
        """
        Test that ExampleCCDNoise puts the expected counts on an image
        by generating a flat image, adding noise and background to it,
        and calculating the variance of counts in the image.
        """

        lsstDefaults = LSSTdefaults()
        gain = 2.5
        readnoise = 6.0
        photParams=PhotometricParameters(gain=gain, readnoise=readnoise)
        img = galsim.Image(100,100)
        noise = ExampleCCDNoise(seed=42)
        m5 = 24.5
        bandpass = Bandpass()
        bandpass.readThroughput(os.path.join(lsst.utils.getPackageDir('throughputs'),'baseline','total_r.dat'))
        background = calcSkyCountsPerPixelForM5(m5, bandpass, seeing=lsstDefaults.seeing('r'),
                                            photParams=photParams)

        noisyImage = noise.addNoiseAndBackground(img, bandpass, m5=m5,
                                                 seeing=lsstDefaults.seeing('r'),
                                                 photParams=photParams)

        mean = 0.0
        var = 0.0
        for ix in range(1,101):
            for iy in range(1,101):
                mean += noisyImage(ix, iy)

        mean = mean/10000.0

        for ix in range(1,101):
            for iy in range(1,101):
                var += (noisyImage(ix, iy) - mean)*(noisyImage(ix, iy) - mean)

        var = var/9999.0

        varElectrons = background*gain + readnoise
        varADU = varElectrons/(gain*gain)

        msg = 'background %e mean %e ' % (background, mean)
        self.assertTrue(numpy.abs(background/mean - 1.0) < 0.05, msg=msg)

        msg = 'var %e varADU %e ; ratio %e ; background %e' % (var, varADU, var/varADU, background)
        self.assertTrue(numpy.abs(var/varADU - 1.0) < 0.05, msg=msg)
开发者ID:linan7788626,项目名称:sims_GalSimInterface,代码行数:47,代码来源:testGalSimInterface.py

示例14: getListOfBandpasses

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
    def getListOfBandpasses(self, nBp):
        """
        Generate a list of nBp bandpass names and bandpasses

        Intentionally do so a nonsense order so that we can test
        that order is preserved in the BandpassDict
        """
        dexList = numpy.random.random_integers(0, len(self.bandpassPossibilities)-1, nBp)
        bandpassNameList = []
        bandpassList = []
        for dex in dexList:
            name = self.bandpassPossibilities[dex]
            bp = Bandpass()
            bp.readThroughput(os.path.join(self.bandpassDir,'total_%s.dat' % name))
            while name in bandpassNameList:
                name += '0'
            bandpassNameList.append(name)
            bandpassList.append(bp)

        return bandpassNameList, bandpassList
开发者ID:jonathansick-shadow,项目名称:sims_photUtils,代码行数:22,代码来源:testBandpassDict.py

示例15: buildLens

# 需要导入模块: from lsst.sims.photUtils import Bandpass [as 别名]
# 或者: from lsst.sims.photUtils.Bandpass import readThroughput [as 别名]
def buildLens(lensDir, addLosses=True):
    """
    Build the lens throughput curve from the files in lensDir.
    Returns a bandpass object.
    The coatings for the lens are in *_Coatings, the loss files are in *_Losses.
    The borosilicate glass throughput is in l*_Glass.dat; this file is smoothed using the
     savitzsky_golay function.
    The glass response is multiplied by the coatings and (if addLosses is True),
      also the loss curves.
    """
    lens = Bandpass()
    # Read the glass base file.
    glassfile = glob(os.path.join(lensDir, 'l*_Glass.dat'))
    if len(glassfile) != 1:
        raise ValueError('Expected a single glass file in this directory, found: ', glassfile)
    glassfile = glassfile[0]
    glass = Bandpass()
    glass.readThroughput(glassfile)
    # Smooth the glass response.
    smoothSb = savitzky_golay(glass.sb, 31, 3)
    lens = Bandpass()
    lens.setBandpass(glass.wavelen, smoothSb)
    # Read the broad band antireflective (BBAR) coatings files.
    bbars = _readCoatings(lensDir)
    # Multiply the bbars by the glass.
    wavelen, sb = lens.multiplyThroughputs(bbars.wavelen, bbars.sb)
    lens.setBandpass(wavelen, sb)
    # Add losses.
    if addLosses:
        loss = _readLosses(lensDir)
        wavelen, sb = lens.multiplyThroughputs(loss.wavelen, loss.sb)
        lens.setBandpass(wavelen, sb)
    # Verify that no values go significantly below zero.
    belowzero = np.where(lens.sb < 0)
    # If there are QE values significantly < 0, raise an exception.
    if lens.sb[belowzero] < belowZeroThreshhold:
        raise ValueError('Found values in lens throughput significantly below zero.')
    # If they are just small errors in interpolation, set to zero.
    lens.sb[belowzero] = 0
    return lens
开发者ID:krvikassingh,项目名称:syseng_throughputs,代码行数:42,代码来源:bandpassUtils.py


注:本文中的lsst.sims.photUtils.Bandpass.readThroughput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。