scifysim.director module
- class scifysim.director.simulator(file=None, fpath=None)[source]
Bases:
object
- __annotations__ = {}
- __dict__ = mappingproxy({'__module__': 'scifysim.director', '__init__': <function simulator.__init__>, 'prepare_observatory': <function simulator.prepare_observatory>, 'prepare_injector': <function simulator.prepare_injector>, 'prepare_combiner': <function simulator.prepare_combiner>, 'prepare_fringe_tracker': <function simulator.prepare_fringe_tracker>, 'prepare_sources': <function simulator.prepare_sources>, 'prepare_integrator': <function simulator.prepare_integrator>, 'prepare_spectrograph': <function simulator.prepare_spectrograph>, 'prepare_corrector': <function simulator.prepare_corrector>, 'backup_ldc': <function simulator.backup_ldc>, 'restore_ldc': <function simulator.restore_ldc>, 'point': <function simulator.point>, 'make_metrologic_exposure': <function simulator.make_metrologic_exposure>, 'combine_light': <function simulator.combine_light>, 'combine_light_dask': <function simulator.combine_light_dask>, 'combine_light_dask2': <function simulator.combine_light_dask2>, 'combine_32': <function simulator.combine_32>, 'combine': <function simulator.combine>, 'geometric_phasor': <function simulator.geometric_phasor>, 'geometric_phasor_dask': <function simulator.geometric_phasor_dask>, 'make_exposure': <function simulator.make_exposure>, 'prepare_sequence': <function simulator.prepare_sequence>, 'make_sequence': <function simulator.make_sequence>, 'build_all_maps': <function simulator.build_all_maps>, 'get_loc_map': <function simulator.get_loc_map>, 'build_all_maps_dask': <function simulator.build_all_maps_dask>, 'persist_maps_to_disk': <function simulator.persist_maps_to_disk>, 'make_map_dask': <function simulator.make_map_dask>, 'make_map_dask2': <function simulator.make_map_dask2>, 'make_map': <function simulator.make_map>, 'gain_map': <property object>, '__call__': <function simulator.__call__>, 'reset_static': <function simulator.reset_static>, 'spectral_res': <property object>, '__dict__': <attribute '__dict__' of 'simulator' objects>, '__weakref__': <attribute '__weakref__' of 'simulator' objects>, '__doc__': None, '__annotations__': {}})
- __init__(file=None, fpath=None)[source]
The object meant to assemble and operate the simulator. Construct the injector object from a config file
Parameters:
file : A pre-parsed config file. See
parsefile
submodulefpath : The path to a config file
- __module__ = 'scifysim.director'
- __weakref__
list of weak references to the object (if defined)
- build_all_maps(mapres=100, mapcrop=1.0, dtype=<class 'numpy.float32'>, transmission='default')[source]
Builds the transmission maps for the combiner for all the pointings on self.target at the times of
self.sequence
Parameters:
mapres : The resolution of the map in pixels
mapcrop : Adjusts the extent of the map
Returns (also stored in self.map) a transmission map of shape:
[n_sequence,
n_wl_chanels,
n_outputs,
mapres,
mapres]
To get final flux of a point source :
Map/ds_sr * p.ss * DIT
ds_sr
can be found indirector.vigneting_map
- build_all_maps_dask(mapres=100, mapcrop=1.0, dtype='dask', transmission='default', no_compute=False)[source]
Builds the transmission maps for the combiner for all the pointings on self.target at the times of self.sequence. Returns an uncomputed dask array referencing one input map per pointing that are each stored to disk. call self.maps[element indices].compute() to compute specific elements without computing the whole map.
Parameters: * mapres : The resolution of the map in pixels * mapcrop : Adjusts the extent of the map * transmission : The first item in the transmission-emission objects
if “default”: will use self.src.sky
Returns (also stored in self.map) a transmission map of shape: * [n_sequence, * n_wl_chanels, * n_outputs, * mapres, * mapres]
To get final flux of a point source :
Map/ds_sr * p.ss * DIT
ds_sr
is the scene surface element in steradian and can be found indirector.vigneting_map
- combine(inst_phasor, geom_phasor, amplitude=None)[source]
Computes the output INTENSITY based on the input AMPLITUDE or maps)
Parameters:
inst_phasor : The instrumental phasor to apply to the inputs dimension (n_wl, n_input)
geom_phasor : The geometric phasor due to source location dimension (n_wl, n_input)
amplitude : Complex amplitude of the spectrum of the source dimension (n_wl, n_src)
Returns Output complex amplitudes
- combine_32(inst_phasor, geom_phasor, amplitude=None)[source]
Computes the output INTENSITY based on the input AMPLITUDE This version provides a result in np.float32 format for smaller memory footprint (for maps)
Parameters:
inst_phasor : The instrumental phasor to apply to the inputs dimension (n_wl, n_input)
geom_phasor : The geometric phasor due to source location dimension (n_wl, n_input)
amplitude : Complex amplitude of the spectrum of the source dimension (n_wl, n_src)
Returns Output complex amplitudes
- combine_light(asource, injected, input_array, collected, dosum=True, dtype=<class 'numpy.float64'>)[source]
Computes the combination for a discretized light source object for all the wavelengths of interest. Returns the intensity in all outputs at all wavelengths.
Parameters:
asource : Source object or transmission_emission object including ss and xx_r attributes
injected : complex phasor for the instrumental errors
input_array : The projected geometric configuration of the array use observatory.get_projected_array()
collected : The intensity across wavelength and the difference source origins
dtype : The data type to use (use np.float32 for maps)
- combine_light_dask(asource, injected, input_array, collected, dosum=True, map_index=0)[source]
Computes the combination for a discretized light source object for all the wavelengths of interest. The computation is done out of core using dask. Returns the intensity in all outputs at all wavelengths.
inputs:
asource : Source object or transmission_emission object including ss and xx_r attributes as dask arrays
injected : complex phasor for the instrumental errors
input_array : The projected geometric configuration of the array use observatory.get_projected_array()
collected : Dask version of the intensity across wavelength and the difference source origins
- map_indexThe index of the pointing in the sequence. Mostly use for numbering
of the temporary disk file
Note
In “dask” mode the collected and source.ss are expected as dask arrays
- combine_light_dask2(asource, injected, input_array, collected, dosum=True, map_index=0)[source]
Computes the combination for a discretized light source object for all the wavelengths of interest. The computation is done out of core using dask. Returns the intensity in all outputs at all wavelengths.
inputs:
asource : Source object or transmission_emission object including ss and xx_r attributes as dask arrays
injected : complex phasor for the instrumental errors
input_array : The projected geometric configuration of the array use observatory.get_projected_array()
collected : Dask version of the intensity across wavelength and the difference source origins
- map_indexThe index of the pointing in the sequence. Mostly use for numbering
of the temporary disk file
Note
In “dask” mode the collected and source.ss are expected as dask arrays
- property gain_map
- geometric_phasor(alpha, beta, anarray)[source]
Returns the complex phasor corresponding to the locations of the family of sources
Parameters:
alpha : The coordinate matched to X in the array geometry
beta : The coordinate matched to Y in the array geometry
anarray : The array geometry (n_input, 2)
Returns : A vector of complex phasors
- geometric_phasor_dask(alphas, betas, anarray)[source]
Returns the complex phasor corresponding to the locations of the family of sources
Parameters: * alpha : The coordinate matched to X in the array geometry
as a dask array (field positions)
beta : The coordinate matched to Y in the array geometry as a dask array (field positions)
anarray : The array geometry (n_input, 2)
- get_loc_map(loc)[source]
Get the nearest pixel location of for a relative coordinate Arguments: * loc : the relative coordinate in [mas]
defined in (y, x) as per numpy convention
Returns: (y, x ) coordinate index in pixel as per numpy conv.
- make_exposure(interest, star, diffuse, texp=1.0, t_co=0.002, time=None, monitor_phase=True, use_tqdm=False, dtype=<class 'numpy.float32'>, spectro=None)[source]
Warning: at the moment, this assumes pointing has already been performed.
Simulate an exposure with source of interest and sources of noise
Parameters:
interest : sf.sources.resolved_source object representing the source of intereest (planet)
star : sf.sources.resolved_source object representing the star
diffuse : a list of sf.transmission_emission objects linked in a chain.
texp : Exposure time (seconds)
t_co : Coherence time (seconds)
monitor_phase : If true, will also record values of phase errors from injection and fringe tracking
dtype : Data type to use for results
spectro : spectrograph object to use. If None, the method will assume one pixel per output and per spectral channel
Chained diffuse objects are used both for transmission and thermal background. Result is returned as an integrator object. Currently the integrator object is only a vessel for the individual subexposures, and not used to do the integration.
- make_map(blockindex, vigneting_map, dtype=<class 'numpy.float32'>, transmission=None)[source]
Create sensitivity map in m^2.sr per spectral channel. To get final flux of a point source :
Map/ds_sr * p.ss * DIT
Parameters:
blockindex : The index in the observing sequence to create the map
vigneting_map : The vigneting map drawn used for resolution
Returns the
static_output
: the map
- make_map_dask(blockindex, vigneting_map, dtype='dask', map_index=0, transmission=None, no_compute=False)[source]
Create sensitivity map in m^2.sr per spectral channel. To get final flux of a point source :
Map/ds_sr * p.ss * DIT
Parameters:
blockindex : The index in the observing sequence to create the map
vigneting_map : The vigneting map drawn used for resolution
- make_map_dask2(blockindex, vigneting_map, dtype='dask', map_index=0)[source]
Create sensitivity map in m^2.sr per spectral channel. To get final flux of a point source :
Map/ds_sr * p.ss * DIT
Parameters:
blockindex : The index in the observing sequence to create the map
vigneting_map : The vigneting map drawn used for resolution
- make_metrologic_exposure(interest, star, diffuse, int_sources=None, texp=1.0, t_co=0.002, time=None, monitor_phase=True, dtype=<class 'numpy.float32'>, perfect=False)[source]
Simulate an exposure with source of interest and sources of noise
Warning
At the moment, this assumes pointing has already been performed.
Parameters:
interest : sf.sources.resolved_source object representing the source of intereest (planet)
star : sf.sources.resolved_source object representing the star
diffuse : a list of sf.transmission_emission objects linked in a chain.
texp : Exposure time (seconds)
t_co : Coherence time (seconds)
monitor_phase : If true, will also record values of phase errors from injection and fringe tracking
Chained diffuse objects are used both for transmission and thermal background. Result is returned as an integrator object. Currently the integrator object is only a vessel for the individual subexposures, and not used to do the integration.
Returns
self.integrator
- persist_maps_to_disk(fname='/tmp/full_maps.zarr')[source]
Computes and stores the map to disk. The file is then loaded out of core and is still accessible in the same way (but without the computing times).
- point(time, target, refresh_array=False, disp_override=None, long_disp_override=None, ld_mode_override=None, ft_mode='phase')[source]
Points the array towards the target. Updates the combiner
Parameters:
time : The time to make the observation
target : The skycoord object to point
refresh_array : Whether to call a lambdification of the array
disp_override : None (default) follows the value given by self.transverse_dispersion; True force the transverse dispersion; False deactivate transverse dispersion.
- prepare_combiner(file, **kwargs)[source]
Constructs
self.combiner
Parameters:
file : A parsed config file (see parsefile)
**kwargs to pass to the combiner
__init__
method
- prepare_corrector(config=None, optimize=True, model_air=None)[source]
Prepare the corrector object for the simulator, based on a config file.
Parameters:
config : Either:
None (default) to use the simulators config
A parsed config file
optimize : Boolean. If True, will optimize both depth and shape
apply : Boolean. If True, apply the optimization
model_air: Provide a model for delay line air different from the true air if None (default) the model will be exactly the properties of air.
- prepare_injector(file=None, fpath=None, ntelescopes=None, tt_correction=None, no_piston=None, lambda_range=None, NA=None, a=None, ncore=None, focal_hrange=None, focal_res=None, pscale=None, interpolation=None, res=50, crop=0.7, injector=None, seed=None)[source]
Either:
Provide all parameters
Provide a config file
provide the injector
- prepare_integrator(config=None, keepall=False, n_sources=4, infinite_well=False)[source]
Prepares the integraro object that rules the pixel properties of the detector.
Parameters:
config : A parsed config file (default: None will reuse the config file in self.)
keepall : [boolean] Whether to keep each of the steps accumulated. False is recommended for faster computation and memory efficiency
- n_sourcesNumber of sources sequencially accumulated. (deprecated, do not
rely on this number)
- prepare_observatory(file=None, fpath=None, statlocs=None)[source]
Preprare the observatory object for the simulator.
Parameters:
file : A parsed config file (see parsefile)
fpath: (string) A path to the config file to parse
statlocs : The station locations (optional) (east, north) for each aperture shape is (Na, 2)
- prepare_sequence(file=None, times=None, remove_daytime=False, coordinates=None)[source]
Prepare an observing sequence
Parameters: * file : Parsed config file * times : deprecated * remove_daytimes : (default : False) Whether to remove from
the sequence the daytime occurences
coordinates : read from file by default if skycoord object provided, then use that.
- prepare_sources(file=None)[source]
Prepares a src object containing star, planet, sky and UT.
file : A parsed config file (default: None will reuse the config file in self.)
- prepare_spectrograph(config=None, n_chan=None)[source]
Prepares the spectrograph object that maps the light over the detector.
Parameters:
file : A parsed config file (default: None will reuse the config file in self.)
n_chan : The number of outputs from the chip. If None: tries to get it from the shape of
self.combiner.M
- property spectral_res
The spectral resolution of the instrument. Computed as a mean over all spectral channels.