예제 #1
0
def _generate_request_passband(pbr, content_request, gzipped=False, save=True):
    if app._verbose:
        print("_generate_request_passband {} {} gzipped={} save={}".format(
            pbr, content_request, gzipped, save))

    # we have to force reloading from the file here or else changing the content
    # will persist in memory
    pb = phoebe.get_passband(pbr, reload=True)

    prefix = '{}_{}'.format(pb.pbset.lower(), pb.pbname.lower())
    filename = '{}.fits.gz'.format(prefix) if gzipped else '{}.fits'.format(
        prefix)

    if isinstance(content_request, str):
        if content_request.lower() == 'all':
            pass
        else:
            raise ValueError(
                "pass content_request through _unpack_content_request first")
    else:
        content_return = []
        for c in content_request:
            c_expanded = _expand_content_item(pb, c)
            # if not len(c_expanded):
            #     raise ValueError("could not find content match for content_request={}".format(c))
            content_return += c_expanded

        content_return = list(set(content_return))
        print("serving {} passband with content={}".format(
            pbr, content_return))
        pb.content = content_return

    if save:
        pbf = tempfile.NamedTemporaryFile(
            mode='w+b',
            dir=tmpdir,
            prefix=prefix,
            suffix=".fits.gz" if gzipped else ".fits")
        if gzipped:
            gzf = gzip.GzipFile(mode='wb', fileobj=pbf)
            pb.save(gzf, update_timestamp=False)
            return gzf, filename

        else:
            pb.save(pbf, update_timestamp=False)
            return pbf, filename

    else:
        return pb
예제 #2
0
# In[8]:

print pb.content

# We can now test-drive the blackbody lookup table we just created. For this we will use a low-level `Passband` class method that computes normal emergent passband intensity, `Inorm()`. For the sake of simplicity, we will turn off limb darkening by setting `ld_func` to `'linear'` and `ld_coeffs` to `'[0.0]'`:

# In[9]:

print pb.Inorm(Teff=5772, atm='blackbody', ld_func='linear', ld_coeffs=[0.0])

# Let us now plot a range of temperatures, to make sure that normal emergent passband intensities do what they are supposed to do. While at it, let us compare what we get for the Johnson:V passband.

# In[10]:

jV = phoebe.get_passband('Johnson:V')
teffs = np.linspace(5000, 8000, 100)
plt.xlabel('Temperature [K]')
plt.ylabel('Inorm [W/m^2/A]')
plt.plot(teffs,
         pb.Inorm(teffs, atm='blackbody', ld_func='linear', ld_coeffs=[0.0]),
         label='mypb')
plt.plot(teffs,
         jV.Inorm(teffs, atm='blackbody', ld_func='linear', ld_coeffs=[0.0]),
         label='jV')
plt.legend(loc='lower right')
plt.show()

# This makes perfect sense: Johnson V transmission function is wider than our boxed transmission function, so intensity in the V band is larger the lower temperatures. However, for the hotter temperatures the contribution to the UV flux increases and our box passband with a perfect transmission of 1 takes over.

# Computing Castelli & Kurucz (2004) response
예제 #3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Nov  9 16:18:03 2019

@author: dyz
"""

import phoebe
from phoebe import u
import numpy as np
import matplotlib.pyplot as plt

logger = phoebe.logger(clevel='WARNING')

kepler = phoebe.get_passband('Kepler:mean')
tess = phoebe.get_passband('TESS:default')

#calculate the two passband flux
teffs = np.linspace(3500, 8000, 100)
fig=plt.figure()
plt.xlabel('Temperature [K]')
plt.ylabel('Inorm [W/m^2/A]')
plt.plot(teffs, kepler.Inorm(teffs, atm='blackbody', ld_func='linear', ld_coeffs=[0.0]), label='Kepler')
plt.plot(teffs, tess.Inorm(teffs, atm='blackbody', ld_func='linear', ld_coeffs=[0.0]), label='TESS')
plt.legend(loc='lower right')

plt.savefig("two_passband_flux.eps")
#plt.show()

"""