예제 #1
0
def get_thruput(inst, niriss=1, nirspec='f100lp'):
    """Returns complete instrument photon to electron conversion efficiency
    Pulls complete instrument photon to electron conversion efficiency 
    (PCE) based on instrument key input 
    
    Parameters
    ----------
    inst : str
        One of the instrument keys in `print_instruments`
    niriss : int
        (Optional) defines which niriss order you want (1 or 2)
    nirspec : str
        (Optional) for NIRISS G140M/H there are two available filters (f100lp and f070lp)
        if you are selecting G140M or G140H, this allows you to pick which one
    Returns
    ------- 
    dict 
        Dictionary with wave solution and PCE
    
    Example
    -------
    >>> thru_dict = get_thruput('NIRISS SOSS_Or1')
    """

    #pull correct dictionary
    input_dict = SetDefaultModes(inst).pick()
    conf = input_dict['configuration']
    conf['detector']['ngroup'] = 2

    if conf['instrument']['instrument'].lower() == 'niriss':
        #pandeia handles slit losses inside the 2d engine. So, you need to account for the
        #extra .663 here
        conf["instrument"][
            "disperser"] = conf["instrument"]["disperser"] + '_' + str(niriss)
        i = InstrumentFactory(config=conf)
        wr = i.get_wave_range()
        wave = np.linspace(wr['wmin'], wr['wmax'], num=500)
        pce = i.get_total_eff(wave)
        return {'wave': wave, 'pce': 0.663 * pce}
    elif (conf['instrument']['instrument'].lower()
          == 'nirspec') and ('g140' in conf["instrument"]["disperser"]):
        conf["instrument"]["filter"] = nirspec

    i = InstrumentFactory(config=conf)
    wr = i.get_wave_range()
    wave = np.linspace(wr['wmin'], wr['wmax'], num=500)
    pce = i.get_total_eff(wave)
    return {'wave': wave, 'pce': pce}
예제 #2
0
def get_thruput(inst):
    """Returns complete instrument photon to electron conversion efficiency
    Pulls complete instrument photon to electron conversion efficiency 
    (PCE) based on instrument key input 
    
    Parameters
    ----------
    inst : str
        One of the instrument keys in `print_instruments`
    
    Returns
    ------- 
    dict 
        Dictionary with wave solution and PCE
    
    Example
    -------
    >>> thru_dict = get_thruput('NIRISS SOSS_Or1')
    """

    #pull correct dictionary
    input_dict = SetDefaultModes(inst).pick()

    conf = {'instrument': input_dict['configuration']['instrument']}
    i = InstrumentFactory(config=conf)
    wr = i.get_wave_range()
    wave = np.linspace(wr['wmin'], wr['wmax'], num=500)
    pce = i.get_total_eff(wave)
    return {'wave': wave, 'pce': pce}
예제 #3
0
def get_thruput(inst):
    """Returns complete instrument photon to electron conversion efficiency
    Pulls complete instrument photon to electron conversion efficiency 
    (PCE) based on instrument key input 
    
    Parameters
    ----------
    inst : str
        One of the instrument keys in `print_instruments`
    
    Returns
    ------- 
    dict 
        Dictionary with wave solution and PCE
    
    Example
    -------
    >>> thru_dict = get_thruput('NIRISS SOSS_Or1')
    """
    
    #pull correct dictionary
    input_dict =  SetDefaultModes(inst).pick()
                             
    conf = {'instrument': input_dict['configuration']['instrument']}
    i = InstrumentFactory(config=conf)
    wr = i.get_wave_range()
    wave = np.linspace(wr['wmin'], wr['wmax'], num=500)
    pce = i.get_total_eff(wave)
    return {'wave':wave,'pce':pce}
예제 #4
0
def get_pce(instrument='niriss',
            mode='soss',
            filter='clear',
            disperser='gr700xd',
            aperture='soss',
            detector=None):
    """
    Use pandeia to generate the JWST throughputs

    Parameters
    ----------
    instrument: str
        The JWST instrument to use, ['niriss', 'nirspec', 'miri', 'nircam']
    mode: str
        The observing mode to use, ['soss', 'wfss', 'ami', etc.]
    filter: str
        The filter wheel element to use
    disperser: str
        The dispersion element to use
    aperture: str
        The aperture to use

    Returns
    -------
    wave, pce
        The wavelength and throughput
    """
    # Get optical element configuration
    obsmode = {
        'instrument': instrument,
        'mode': mode,
        'filter': filter,
        'aperture': aperture,
        'disperser': disperser
    }
    conf = {'instrument': obsmode, 'detector': detector}
    i = InstrumentFactory(config=conf)

    # Determine wavelength range
    wr = i.get_wave_range()
    wave = np.linspace(wr['wmin'], wr['wmax'], num=500)

    # Evaluate the throughput
    pce = i.get_total_eff(wave)

    return wave, pce
예제 #5
0
def get_pce(instrument, mode, config):

    obsmode = {
        'instrument': instrument,
        'mode': mode,
        'filter': config['filter'],
        'aperture': config['aperture'],
        'disperser': config['disperser']
    }

    conf = {'instrument': obsmode}

    i = InstrumentFactory(config=conf)
    wr = i.get_wave_range()
    wave = np.linspace(wr['wmin'], wr['wmax'], num=500)
    pce = i.get_total_eff(wave)

    return wave, pce
    if os.path.isfile(filename):
        print("%s already exists. skipping..." % filename)
        continue

    # make the instrument instance, set up the wavelength vector, and get out the total efficiency.
    instrument_factory = InstrumentFactory(config=conf)

    print(iconf['instrument'], iconf['mode'], iconf['aperture'])
    try:
        wave_range = instrument_factory.get_wave_range()
    except:
        print('***  Exception with get_wave_range  ***')
        pass

    wave = np.linspace(wave_range['wmin'], wave_range['wmax'], num=500)
    eff = instrument_factory.get_total_eff(wave)

    # make the plot, save it to a file, and close things up when done.
    f = plt.figure(facecolor='white')
    ax = plt.gca()
    ax.tick_params(axis='both', which='major', labelsize='14', colors='black')
    ax.set_ylim(0.0, 1.05)
    ax.set_axis_bgcolor('white')
    plt.ylabel("Total System Throughput", fontsize=18, color='black')
    plt.xlabel(r"$\lambda$ ($\mu$m)", fontsize=18, color='black')
    plt.plot(wave, eff, linewidth=1.5)
    plt.title(title, fontsize=20)
    plt.grid('on', which='major', color='#444444', linestyle='-')
    ax.spines['bottom'].set_color('black')
    ax.spines['top'].set_color('black')
    ax.spines['right'].set_color('black')
    if os.path.isfile(filename):
        print("%s already exists. skipping..." % filename)
        continue

    # make the instrument instance, set up the wavelength vector, and get out the total efficiency.
    instrument_factory = InstrumentFactory(config=conf)

    print(iconf['instrument'], iconf['mode'], iconf['aperture'])
    try:
        wave_range = instrument_factory.get_wave_range()
    except:
        print('***  Exception with get_wave_range  ***')
        pass

    wave = np.linspace(wave_range['wmin'], wave_range['wmax'], num=500)
    eff = instrument_factory.get_total_eff(wave)

    # make the plot, save it to a file, and close things up when done.
    f = plt.figure(facecolor='white')
    ax = plt.gca()
    ax.tick_params(axis='both', which='major', labelsize='14', colors='black')
    ax.set_ylim(0.0, 1.05)
    ax.set_axis_bgcolor('white')
    plt.ylabel("Total System Throughput", fontsize=18, color='black')
    plt.xlabel(r"$\lambda$ ($\mu$m)", fontsize=18, color='black')
    plt.plot(wave, eff, linewidth=1.5)
    plt.title(title, fontsize=20)
    plt.grid('on', which='major', color='#444444', linestyle='-')
    ax.spines['bottom'].set_color('black')
    ax.spines['top'].set_color('black') 
    ax.spines['right'].set_color('black')