Coder Social home page Coder Social logo

fsps's Introduction

FSPS Files

What this is

FSPSFiles contains classes easily reading and working with FSPS output files (.mags, .spec, and .cmd)

How to the routines

Put this directory in your Python path and then in any program you can import the program,

import FSPSFiles

This will allow you to read in the outfiles. For example,

test = FSPSFiles.readcmd(<fname.cmd>)
test = FSPSFiles.readmags(<fname.mags>)
test = FSPSFiles.readspec(<fname.spec>)

Doing this returns class instances of whatever file you're reading in. It's important to note that what is returned from readcmd, readmags, and readspec are distinct objects that have slightly different behaviors. However, all the file classes take in the attributes given in the headers of the FSPS outfiles and organizes the data such that you can select based on those attributes.

Examples

CMD Files

test = FSPSFiles.readcmd(<fname.cmd>)
smc_agb_84 =[]
for model in test:
    if model['phase'] != 6.0:
        if model['age'] == 8.7:
            smc_agb_84.append(model)

So as you can see you see you can select on any of the attributes given in the .cmd header. In this case I'm making a phase selection and the selecting based on age. The smc_agb_84 array now contains the magnitudes for all the filters that FSPS supports. Note that at the end of this for-loop the file is closed. If you want to do any more selections on it you have to reopen it. If I want to select a certain filter I can do the follow,

smc_nod_84_twom_j = map(lambda source: source['twomass_j'] + smc_distmod, smc_nod_84)

Which gives me the J-band photometry for all the stars in a population of log age = 8.4 for every phase except 6.

Mags Files

test = FSPSFiles.readmags(<fname.mags>)

mphot_980 = []
for model in test:
    if model['log(age)'] == 9.80:
        mphot_980.append(ab_fnu(model['irac1']))
        mphot_980.append(ab_fnu(model['irac2']))
        mphot_980.append(ab_fnu(model['irac3']))
        mphot_980.append(ab_fnu(model['irac4']))
        mphot_980.append(ab_fnu(model['mips_24']))

Here I'm selecting based on age and filling an array with integrated photometry. Note, the file is closed once the for-loop is over.

Spec Files

The behavior of readspec is a bit different but equally straightforward.

test = FSPSFiles.readspec(<fname.spec>)

for model in test:
    if model.logage == 9.80:
        agb_spec_980 = np.asarray(map(lambda value: value, model.flux))
        swave = np.asarray(model.wave)
    if model.logage == 9.85:
        agb_spec_985 = np.asarray(map(lambda value: value, model.flux))
        swave = np.asarray(model.wave)

After I open the file I can loop through the different spectra the file contains and here I'm making selections based on age. Once again, once you leave the for-loop the file is closed.

fsps's People

Contributors

alexavillaume avatar

Stargazers

Rohan Naidu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.