scifysim.analysis module

class scifysim.analysis.BasicETC(asim)[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'scifysim.analysis', '__init__': <function BasicETC.__init__>, 'contribs_variance_rate': <property object>, 'get_min_exp_time': <function BasicETC.get_min_exp_time>, 'planet_photons': <function BasicETC.planet_photons>, 'show_signal_noise': <function BasicETC.show_signal_noise>, '__dict__': <attribute '__dict__' of 'BasicETC' objects>, '__weakref__': <attribute '__weakref__' of 'BasicETC' objects>, '__doc__': None, '__annotations__': {}})
__init__(asim)[source]

Parameters: * ipeak : [] * pdiam : [m] * S_collecting [m^2] * lambda_science_range [m] * diffuse [] * throughput [] * eta [e-/ph] * fiber_etendue [sr] * cold_enclosure [e-/s] * dark_current [e-/s] * src_names [] * contribs [ph/s]

__module__ = 'scifysim.analysis'
__weakref__

list of weak references to the object (if defined)

property contribs_variance_rate

The variance rate in e-**2/s

get_min_exp_time(planet_mag, planet_T, snr=3.0, dit_0=None, verbose=False)[source]

Arguments: * planet_mag : [Vega mag] * planet_T : [K] * snr : (3) Signal to noise ratio to reach * dit_0 : (None) [s] * verbose : (False)

planet_photons(planet_mag, dit=1.0, T=None, verbose=False)[source]

Arguments: * planet_mag : * dit : (1.) [s] * T T (None) [] * verbose : (False)

show_signal_noise(planet_mag, dit=1.0, T=None, verbose=True, decompose=True, plot=True, show=True)[source]

Arguments: * planet_mag : The magnitude of the planet in the science band (Vega). * dit : (1.) The individual detector integration time. Typically

adjusted for different spectral resolutions. [s]

  • T : (None) Temperature [K]

  • verbose : (True)

  • decompose : (True)

  • plot : (True)

  • show : (True)

scifysim.analysis.F2mag(F)[source]
scifysim.analysis.contrib2variance(acontrib, unit=Unit('electron'))[source]

Assumes incoming signals proportional to electrons.

Tweaks the unit to a poisson variance (e.g. from e- to e-**2)

scifysim.analysis.correlation_map(signal, maps, postproc=None, K=None, n_diffobs=1, verbose=False)[source]

Returns the raw correlation map of a signal with a map.

Arguments:

  • signal : The signal measured on sky shape: (n_slots, n_wl, n_outputs)

  • maps : The maps for comparison shape: (n_slots, n_wl, n_outputs, x_resolution, y_resolution)

  • postproc : The whitening matrix to use

  • n_diffobs : The number of differential observables for this combiner (1 for double bracewell, 3 for VIKiNG)

Returns

  • cmap1 : The correlation map

  • xtx_map : The normalization map

scifysim.analysis.get_Tnp_threshold(x, Pfa)[source]
scifysim.analysis.get_Tnp_threshold_map(xTx_map, Pfa)[source]
scifysim.analysis.get_planet_residual(my_params, target_signal, asim, dit, K, postproc, diffuse, notres=False)[source]

arguments:

  • my_paramsAn lmfit Parameters object containing:
    • “Sep” separation in [mas]

    • “PA” position angle in [deg]

    • “Radius” The radius in [R_sun]

    • “Temperature” The temperature [K]

  • target_signal : The observed signal to fit

  • asim : The simulator object

  • dit : The detector integration time

  • K : The matrix that transforms the outputs into observables (single row for double bracewell)

  • postproc : An array of whitening matrices for each chunk (n_chunk, n_wl x n_k)

  • notres : If True this will return the non-whitened model signal if False this will return the difference between the whitened model signal and the whitened target.

scifysim.analysis.get_sensitivity_Te(maps, mod=<module 'numpy' from '/lhome/romain/miniconda3/envs/scify/lib/python3.8/site-packages/numpy/__init__.py'>, pfa=0.002, pdet=0.9, postproc_mat=None, ref_mag=10.0, verbose=True)[source]

Magnitude map at which a companion is detectable for a given map and whitening matrix. The throughput for the signal of interest is given by the map at a reference magnitude. The effective noise floor is implicitly described by the whitening matrix.

Parameters

  • maps : Differential map for a given reference magnitude and exposure time

  • mod : The math module to use for vector ops default=numpy

  • pfa : The false alarm rate used to determine the threshold

  • pdet : The detection probability used to determine the threshold

  • postproc_mat : The matrix of the whitening transformation ($Sigma^{-1/2}$)

  • ref_mag : The reference mag for the given map

  • verbose : Print some information along the way

See Ceau et al. 2019 for more information

Returns

  • mags : The magnitude at which Te crosses the threshold

  • fluxs: The fluxes at which Te crosses the threshold

  • Tes : The values of the test statistic on the map at the reference magnitude

scifysim.analysis.get_sensitivity_Te_old(maps, pfa=0.002, pdet=0.9, postproc_mat=None, ref_mag=10.0, verbose=True)[source]

Deprecated

Magnitude map at which a companion is detectable for a given map and whitening matrix. The throughput for the signal of interest is given by the map at a reference magnitude. The effective noise floor is implicitly described by the whitening matrix.

Parameters

  • maps : Differential map for a given reference magnitude

  • pfa : The false alarm rate used to determine the threshold

  • pdet : The detection probability used to determine the threshold

  • postproc_mat : The matrix of the whitening transformation ($Sigma^{-1/2}$)

  • ref_mag : The reference mag for the given map

  • verbose : Print some information along the way

See Ceau et al. 2019 for more information

Returns

  • mags : The magnitude at which Te crosses the threshold

  • fluxs: The fluxes at which Te crosses the threshold

  • Tes : The values of the test statistic on the map at the reference magnitude

scifysim.analysis.get_sensitivity_Tnp(maps, pfa=0.002, pdet=0.9, postproc_mat=None, ref_mag=10.0, verbose=False, use_tqdm=True)[source]

Magnitude map at which a companion is detectable for a given map and whitening matrix. The throughput for the signal of interest is given by the map at a reference magnitude. The effective noise floor is implicitly described by the whitening matrix.

Arguments:

  • maps : Differential map for a given reference magnitude

  • pfa : The false alarm rate used to determine the threshold

  • pdet : The detection probability used to determine the threshold

  • postproc_mat : The matrix of the whitening transformation ($Sigma^{-1/2}$)

  • ref_mag : The reference mag for the given map

  • verbose : Print some information along the way

Returns: A magnitude map

scifysim.analysis.get_sensitivity_Tnp_old(maps, pfa=0.002, pdet=0.9, postproc_mat=None, ref_mag=10.0, verbose=False, use_tqdm=True)[source]

Deprecated

Magnitude map at which a companion is detectable for a given map and whitening matrix. The throughput for the signal of interest is given by the map at a reference magnitude. The effective noise floor is implicitly described by the whitening matrix.

Arguments:

  • maps : Differential map for a given reference magnitude

  • pfa : The false alarm rate used to determine the threshold

  • pdet : The detection probability used to determine the threshold

  • postproc_mat : The matrix of the whitening transformation ($Sigma^{-1/2}$)

  • ref_mag : The reference mag for the given map

  • verbose : Print some information along the way

Returns: A magnitude map

scifysim.analysis.mag2F(mag)[source]
scifysim.analysis.make_source(params, lambda_range, distance)[source]

Creates a source from scratch for purpose of model fitting.

Arguments:

  • params: An lmfit Parameters object containing:
    • “Sep” separation in [mas]

    • “PA” position angle in [deg]

    • “Radius” The radius in [R_sun]

    • “Temperature” The temperature [K]

  • lambda_range : array of the wavelength channels used [m]

  • distance: Distance to the system [pc]

scifysim.analysis.make_th_exps(asim, dit, interest, diffuse, obs=None)[source]

Creates a model observation of an idealized source of interest.

Simulator/obs are required to account for array projection, pointing and combination scheme.

Arguments:

  • asim : Simulator object

  • dit : Detector integration time

  • interest : Synthetic source of interest

  • diffuse : The diffuse light chain, used to model absorption of instrument/sky

  • obs : A given observatory object (default: None)

Returns: (n_chunk, n_wl, n_out) array recorded in the integration time.

class scifysim.analysis.noiseprofile(integ, asim, diffobs_series, verbose=False, n_pixsplit=1)[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'scifysim.analysis', '__init__': <function noiseprofile.__init__>, 'get_noises': <function noiseprofile.get_noises>, 'diff_noise_floor_dit': <function noiseprofile.diff_noise_floor_dit>, 'plot_noise_sources': <function noiseprofile.plot_noise_sources>, 'summary': <function noiseprofile.summary>, '__dict__': <attribute '__dict__' of 'noiseprofile' objects>, '__weakref__': <attribute '__weakref__' of 'noiseprofile' objects>, '__doc__': None, '__annotations__': {}})
__init__(integ, asim, diffobs_series, verbose=False, n_pixsplit=1)[source]

An object to dynamically compute a parametric noise floor

Patameters:

  • integAn integrator object augmented by some mean

    and static measurements (see below)

  • asimA simulator object (mostly used to get some combiner

    and injector parameters)

  • diffobsA series of realisations of te differential observable

    intensity (e.g. diffobs = np.einsum(“ij, mkj->mk”,asim.combiner.K, dit_intensity))

Creation makes use of:

  • integ.mean_starlight (run integ.mean_starlight = np.mean(starlights, axis=0))

  • integ.mean_planetlight (run integ.mean_planetlight = np.mean(planetlights, axis=0))

  • integ.get_static() (run integ.static = asim.computed_static)

Notes:

  • self.sigma_ron in [e-]

  • self.s_enc_bg is defined in [ph/s/pix]

  • self.s_dark_current is defined in [e-/s/pix]

  • self.s_d is defined in [ph/s/ch] (that is per channel)

  • self.s_total_bg_current_ch is in [e-/s/ch]

__module__ = 'scifysim.analysis'
__weakref__

list of weak references to the object (if defined)

diff_noise_floor_dit(m_star, dit, matrix=False)[source]

Returns the compound noise floor WARNING: if matrix is True, then the result is a covariance matrix (beware of variances on diagonal)

Arguments:

  • m_star : Magnitude of the star

  • dit : Detector integratioon time [s]

Returns:

Either sigma_tot_diff or cov_tot_diff depending on matrix.

get_noises(m_star, dit, matrix=False)[source]

Returns the different noises

Warning!

If matrix is True, then sigma_phi_d is a covariance matrix (beware of variances on diagonal)

Arguments:

  • m_star : Magnitude of the star

  • dit : Detector integration time [s]

Returns:

sigma_phot_d, sigma_phi_d : standard deviation vectors (or covariance matrix for sigma_phi_d)

plot_noise_sources(wls, dit=1.0, starmags=array([2., 3., 4., 5., 6.]), show=True, legend_loc='best', legend_font='x-small', ymin=0.0, ymax=1.0, n_dits=1)[source]
summary()[source]
scifysim.analysis.pdet_e(lamb, xsi, rank)[source]

Computes the residual of Pdet

Arguments:

  • lamb : The noncentrality parameter representing the feature

  • xsi : The location of threshold

  • rank : The rank of observable

Returns the Pdet difference

scifysim.analysis.residual_pdet_Te(lamb, xsi, rank, targ)[source]

Computes the residual of Pdet

Arguments:

  • lamb : The noncentrality parameter representing the feature

  • targ : The target Pdet to converge to

  • xsi : The location of threshold

  • rank : The rank of observable

Returns the Pdet difference. See Ceau et al. 2019 for more information

scifysim.analysis.residual_pdet_Tnp(xTx, xsi, targ)[source]

Computes the residual of Pdet in a NP test.

Arguments:

  • xTx : The noncentrality parameter representing the feature

  • targ : The target Pdet to converge to

  • xsi : The location of threshold

Returns the Pdet difference.

class scifysim.analysis.simplified_context(mycontext)[source]

Bases: spectral_context

__init__(mycontext)[source]

Spectral context for magnitude considerations

Arguments:

  • vegafile : Either

    • The parsed config file of the original simulator: a modified copy will be created for the reference Vega observations.

    • The path str to a file for observation of Vega in the same spectral configuration.

  • compensate_chromatic: Argument to be passed to the new simulator

  • verbose : whether to give more details

__module__ = 'scifysim.analysis'
to_pickle(apath)[source]

Saving the context to a pickle file.

class scifysim.analysis.spectral_context(vegafile='config/vega.ini', compensate_chromatic=True, verbose=False)[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'scifysim.analysis', '__init__': <function spectral_context.__init__>, 'create_vega_config': <function spectral_context.create_vega_config>, 'sflux_from_vegamag': <function spectral_context.sflux_from_vegamag>, 'vegamag_from_ss': <function spectral_context.vegamag_from_ss>, 'get_mags_of_sim': <function spectral_context.get_mags_of_sim>, 'get_difmap_flux': <function spectral_context.get_difmap_flux>, 'get_maxmap': <function spectral_context.get_maxmap>, 'get_planet_max_signal': <function spectral_context.get_planet_max_signal>, '__dict__': <attribute '__dict__' of 'spectral_context' objects>, '__weakref__': <attribute '__weakref__' of 'spectral_context' objects>, '__doc__': None, '__annotations__': {}})
__init__(vegafile='config/vega.ini', compensate_chromatic=True, verbose=False)[source]

Spectral context for magnitude considerations

Arguments:

  • vegafile : Either

    • The parsed config file of the original simulator: a modified copy will be created for the reference Vega observations.

    • The path str to a file for observation of Vega in the same spectral configuration.

  • compensate_chromatic: Argument to be passed to the new simulator

  • verbose : whether to give more details

__module__ = 'scifysim.analysis'
__weakref__

list of weak references to the object (if defined)

create_vega_config(config, tarloc='Kraz')[source]

Builds the config file for a reference observation of Vega

Arguments:

  • config: A parsed config file from the simulator itself.

  • tarloc: A star used as a proxy to observe close to Zenith. Kraz is a good fit for Paranal.

Returns a modified parsed config file that has the same settings but that is designed to reproduce an observation of Vega near zenith. Most parameters describing the instrument are the same. A shorter sequence is created (only the central one is to be used: index 3). The target is chosen so that it passes near zenith at observatory.

get_difmap_flux(sim, map=None, mode='e-', K=None, planet=None, single_out=True)[source]

Get the map in terms of flux of a given planet Not kernel-ready

get_mags_of_sim(asim)[source]

Magnitudes of planet and star of a simulator object

Arguments:

  • asim : A simulator object

get_maxmap(map, time_index=None, max=True)[source]

Returns the maximum of the map

Arguments: * map: A map object (asim.maps) * time_index: An index for the (asim.sequence)

observing series

  • max : (True) Returns only the max signal of the map

get_planet_max_signal(sim, planet=None, max=True, time_index=None)[source]

Returns the differential flux signal ph/s collected for a given planet

Arguments: * sim : A director object * planet : a source. * time_index: An index for the (asim.sequence)

observing series

  • max : (True) Returns only the max signal of the map

sflux_from_vegamag(amag)[source]

inverse of vegamag_from_ss()

vegamag_from_ss(flux)[source]

inverse of sflux_form_vegamag()