예제 #1
0
 def testRedshiftName(self):
     testsed = Sed(self.testsed.wavelen, self.testsed.flambda, name=self.testsed.name)
     redshift = .2
     testsed.redshiftSED(redshift=redshift)
     newname = testsed.name + '_Z' + '%.2f' % (redshift)
     testsed.name = newname
     self.assertEqual(testsed.name, newname)
예제 #2
0
    def loadwdSEDs(self, subset = None):

        """
        By default will load all seds in wd directory. The user can also define a subset of
        what's in the directory and load only those SEDs instead. Will skip over extraneous
        files in sed folder.

        @param [in] subset is the list of the subset of files wanted if one doesn't want all files
        in the kurucz directory.

        @param [out] sedListH is the set of model SED spectra objects for Hydrogen WDs to be passed onto
        the matching routines.

        @param [out] sedListHE is the set of model SED spectra objects for Helium WDs to be passed onto
        the matching routines.
        """

        if self.wdDir is None:
            try:
                self.wdDir = str(self.sEDDir + '/' +
                                 self.specMapDict['wd'] + '/')
            except:
                raise ValueError(str('self.wdDir is None. ' +
                                     'Add path to wddirectory.'))


        files = []

        if subset is None:
            for fileName in os.listdir(self.wdDir):
                files.append(fileName)
        else:
            for fileName in subset:
                files.append(fileName)

        numFiles = len(files)
        numOn = 0

        sedListH = []
        sedListHE = []

        for fileName in files:
            if numOn % 100 == 0:
                print('Loading %i of %i: WD SEDs' % (numOn, numFiles))

            try:
                spec = Sed()
                spec.readSED_flambda(str(self.wdDir + '/' + fileName))
                spec.name = fileName
                if fileName.split("_")[1] == 'He':
                    sedListHE.append(spec)
                else:
                    sedListH.append(spec)

            except:
                continue

            numOn += 1

        return sedListH, sedListHE
예제 #3
0
    def loadwdSEDs(self, subset=None):
        """
        By default will load all seds in wd directory. The user can also define a subset of
        what's in the directory and load only those SEDs instead. Will skip over extraneous
        files in sed folder.

        @param [in] subset is the list of the subset of files wanted if one doesn't want all files
        in the kurucz directory.

        @param [out] sedListH is the set of model SED spectra objects for Hydrogen WDs to be passed onto
        the matching routines.

        @param [out] sedListHE is the set of model SED spectra objects for Helium WDs to be passed onto
        the matching routines.
        """

        if self.wdDir is None:
            try:
                self.wdDir = str(self.sEDDir + '/' + self.specMapDict['wd'] +
                                 '/')
            except:
                raise ValueError(
                    str('self.wdDir is None. ' + 'Add path to wddirectory.'))

        files = []

        if subset is None:
            for fileName in os.listdir(self.wdDir):
                files.append(fileName)
        else:
            for fileName in subset:
                files.append(fileName)

        numFiles = len(files)
        numOn = 0

        sedListH = []
        sedListHE = []

        for fileName in files:
            if numOn % 100 == 0:
                print('Loading %i of %i: WD SEDs' % (numOn, numFiles))

            try:
                spec = Sed()
                spec.readSED_flambda(str(self.wdDir + '/' + fileName))
                spec.name = fileName
                if fileName.split("_")[1] == 'He':
                    sedListHE.append(spec)
                else:
                    sedListH.append(spec)

            except:
                continue

            numOn += 1

        return sedListH, sedListHE
예제 #4
0
 def testRedshiftName(self):
     testsed = Sed(self.testsed.wavelen,
                   self.testsed.flambda,
                   name=self.testsed.name)
     redshift = .2
     testsed.redshiftSED(redshift=redshift)
     newname = testsed.name + '_Z' + '%.2f' % (redshift)
     testsed.name = newname
     self.assertEqual(testsed.name, newname)
예제 #5
0
    def loadBC03(self, subset=None):
        """
        This loads the Bruzual and Charlot SEDs that are currently in the SIMS_SED_LIBRARY.
        If the user wants to use different SEDs another loading method can be created and used in place
        of this.

        @param [in] subset is the list of the subset of files in the galDir that the user
        can specify if using all the SEDs in the directory is not desired.

        @param [out] sedList is the set of model SED spectra objects to be passed onto the matching routines.
        """

        if self.galDir is None:
            raise ValueError(
                'self.galDir is None. Add path to galaxy directory.')

        files = []

        if subset is None:
            for fileName in os.listdir(self.galDir):
                files.append(fileName)
        else:
            for fileName in subset:
                files.append(fileName)

        numFiles = len(files)
        numOn = 0

        sedList = []

        for fileName in files:
            if numOn % 100 == 0:
                print('Loading %i of %i: BC Galaxy SEDs' % (numOn, numFiles))

            try:
                spec = Sed()
                spec.readSED_flambda(str(self.galDir + '/' + fileName))
                spec.name = fileName
                fileNameAsList = fileName.split('.')
                spec.type = fileNameAsList[0]
                spec.age = float(fileNameAsList[1])
                metallicity = fileNameAsList[2].split('Z')[0]
                #Final form is z/zSun
                spec.metallicity = float(metallicity) * (10**(
                    (len(metallicity) - 1) * -1))

            except:
                continue

            sedList.append(spec)

            numOn += 1

        return sedList
예제 #6
0
    def loadmltSEDs(self, subset=None):
        """
        By default will load all seds in mlt directory. The user can also define a subset of
        what's in the directory and load only those SEDs instead. Will skip over extraneous
        files in sed folder.

        @param [in] subset is the list of the subset of files wanted if one doesn't want all files
        in the mlt directory.

        @param [out] sedList is the set of model SED spectra objects to be passed onto the matching
        routines.
        """

        if self.mltDir is None:
            try:
                self.mltDir = str(self.sEDDir + '/' + self.specMapDict['mlt'] +
                                  '/')
            except:
                raise ValueError(
                    str('self.mltDir is None. ' +
                        'Add path to mlt directory.'))

        files = []

        if subset is None:
            for fileName in os.listdir(self.mltDir):
                files.append(fileName)
        else:
            for fileName in subset:
                files.append(fileName)

        numFiles = len(files)
        numOn = 0

        sedList = []

        for fileName in files:
            if numOn % 100 == 0:
                print('Loading %i of %i: MLT SEDs' % (numOn, numFiles))

            try:
                spec = Sed()
                spec.readSED_flambda(str(self.mltDir + '/' + fileName))
                spec.name = fileName

            except:
                continue

            sedList.append(spec)

            numOn += 1

        return sedList
예제 #7
0
    def loadBC03(self, subset = None):

        """
        This loads the Bruzual and Charlot SEDs that are currently in the SIMS_SED_LIBRARY.
        If the user wants to use different SEDs another loading method can be created and used in place
        of this.

        @param [in] subset is the list of the subset of files in the galDir that the user
        can specify if using all the SEDs in the directory is not desired.

        @param [out] sedList is the set of model SED spectra objects to be passed onto the matching routines.
        """

        if self.galDir is None:
            raise ValueError('self.galDir is None. Add path to galaxy directory.')

        files = []

        if subset is None:
            for fileName in os.listdir(self.galDir):
                files.append(fileName)
        else:
            for fileName in subset:
                files.append(fileName)

        numFiles = len(files)
        numOn = 0

        sedList = []

        for fileName in files:
            if numOn % 100 == 0:
                print('Loading %i of %i: BC Galaxy SEDs' % (numOn, numFiles))

            try:
                spec = Sed()
                spec.readSED_flambda(str(self.galDir + '/' + fileName))
                spec.name = fileName
                fileNameAsList = fileName.split('.')
                spec.type = fileNameAsList[0]
                spec.age = float(fileNameAsList[1])
                metallicity = fileNameAsList[2].split('Z')[0]
                #Final form is z/zSun
                spec.metallicity = float(metallicity) * (10 ** ((len(metallicity)-1)*-1))

            except:
                continue

            sedList.append(spec)

            numOn += 1

        return sedList
예제 #8
0
    def loadmltSEDs(self, subset = None):

        """
        By default will load all seds in mlt directory. The user can also define a subset of
        what's in the directory and load only those SEDs instead. Will skip over extraneous
        files in sed folder.

        @param [in] subset is the list of the subset of files wanted if one doesn't want all files
        in the mlt directory.

        @param [out] sedList is the set of model SED spectra objects to be passed onto the matching
        routines.
        """

        if self.mltDir is None:
            try:
                self.mltDir = str(self.sEDDir + '/' +
                                  self.specMapDict['mlt'] + '/')
            except:
                raise ValueError(str('self.mltDir is None. ' +
                                     'Add path to mlt directory.'))

        files = []

        if subset is None:
            for fileName in os.listdir(self.mltDir):
                files.append(fileName)
        else:
            for fileName in subset:
                files.append(fileName)

        numFiles = len(files)
        numOn = 0

        sedList = []

        for fileName in files:
            if numOn % 100 == 0:
                print('Loading %i of %i: MLT SEDs' % (numOn, numFiles))

            try:
                spec = Sed()
                spec.readSED_flambda(str(self.mltDir + '/' + fileName))
                spec.name = fileName

            except:
                continue

            sedList.append(spec)

            numOn += 1

        return sedList
예제 #9
0
    def loadKuruczSEDs(self, subset=None):
        """
        By default will load all seds in kurucz directory. The user can also define a subset of
        what's in the directory and load only those SEDs instead. Will skip over extraneous
        files in sed folder.

        @param [in] subset is the list of the subset of files wanted if one doesn't want all files
        in the kurucz directory.

        @param [out] sedList is the set of model SED spectra objects to be passed onto the matching
        routines.
        """

        if self.kuruczDir is None:
            try:
                self.kuruczDir = str(self.sEDDir + '/' +
                                     self.specMapDict['kurucz'] + '/')
            except:
                raise ValueError(
                    str('self.kuruczDir is None. ' +
                        'Add path to kurucz directory.'))

        files = []

        if subset is None:
            for fileName in os.listdir(self.kuruczDir):
                files.append(fileName)
        else:
            for fileName in subset:
                files.append(fileName)

        numFiles = len(files)
        numOn = 0

        sedList = []

        for fileName in files:
            if numOn % 100 == 0:
                print('Loading %i of %i: Kurucz SEDs' % (numOn, numFiles))

            try:
                spec = Sed()
                spec.readSED_flambda(str(self.kuruczDir + '/' + fileName))

                logZTimesTen, temp, gravity, fineTemp = [
                    x.split(".")[0] for x in fileName.split("_")
                ]

                if logZTimesTen[1] == 'm':
                    spec.logZ = -1.0 * float(logZTimesTen[2:]) * 0.1
                else:
                    spec.logZ = float(logZTimesTen[2:]) * 0.1

                spec.logg = float(gravity[1:]) * 0.1
                spec.temp = float(fineTemp)
                spec.name = fileName

            except:
                continue

            sedList.append(spec)

            numOn += 1

        return sedList
예제 #10
0
    def loadKuruczSEDs(self, subset = None):
        """
        By default will load all seds in kurucz directory. The user can also define a subset of
        what's in the directory and load only those SEDs instead. Will skip over extraneous
        files in sed folder.

        @param [in] subset is the list of the subset of files wanted if one doesn't want all files
        in the kurucz directory.

        @param [out] sedList is the set of model SED spectra objects to be passed onto the matching
        routines.
        """

        if self.kuruczDir is None:
            try:
                self.kuruczDir = str(self.sEDDir + '/' +
                                     self.specMapDict['kurucz'] + '/')
            except:
                raise ValueError(str('self.kuruczDir is None. ' +
                                     'Add path to kurucz directory.'))

        files = []

        if subset is None:
            for fileName in os.listdir(self.kuruczDir):
                files.append(fileName)
        else:
            for fileName in subset:
                files.append(fileName)

        numFiles = len(files)
        numOn = 0

        sedList = []

        for fileName in files:
            if numOn % 100 == 0:
                print('Loading %i of %i: Kurucz SEDs' % (numOn, numFiles))

            try:
                spec = Sed()
                spec.readSED_flambda(str(self.kuruczDir + '/' + fileName))

                logZTimesTen, temp, gravity, fineTemp = [x.split(".")[0] for x in fileName.split("_")]

                if logZTimesTen[1] == 'm':
                    spec.logZ = -1.0 * float(logZTimesTen[2:]) * 0.1
                else:
                    spec.logZ = float(logZTimesTen[2:]) * 0.1

                spec.logg = float(gravity[1:]) * 0.1
                spec.temp = float(fineTemp)
                spec.name = fileName

            except:
                continue

            sedList.append(spec)

            numOn += 1

        return sedList