wf_psf.psf_models.tf_modules.tf_layers
TensorFlow layers for PSF modelling.
This module contains TensorFlow layers to model PSF variations across the field of view.
- Author:
Tobias Liaudat <tobias.liaudat@cea.fr>
Classes
|
Calculate a monochromatic PSF from a batch of OPDs. |
|
Calculate a polychromatic PSF from an OPD and stored SED values. |
|
Non-parametric OPD generation with only graph-cosntraint variations. |
|
Non-parametric OPD generation with hybrid-MCCD variations. |
Non-parametric OPD generation with polynomial variations. |
|
|
The Zernike physical layer. |
|
Calculate the zernike coefficients for a given position. |
|
Calculate the OPD from Zernike maps and coefficients. |
- class wf_psf.psf_models.tf_modules.tf_layers.TFBatchMonochromaticPSF(*args, **kwargs)[source]
Bases:
LayerCalculate a monochromatic PSF from a batch of OPDs.
The calculation of the
phase_Nvariable is done with the PSFSimulator class but outside the TF class.- Parameters:
obscurations (Tensor [opd_dim, opd_dim]) – Obscurations to apply to the wavefront.
psf_batch (Tensor [batch_size, output_dim, output_dim]) – Tensor containing the psfs that will be updated each time a calculation is required. Can be started with zeros.
output_Q (int) – Output oversampling value.
output_dim (int) – Output PSF stamp dimension.
- Attributes:
activity_regularizerOptional regularizer function for the output of this layer.
compute_dtypeThe dtype of the layer’s computations.
dtypeThe dtype of the layer weights.
dtype_policyThe dtype policy associated with this layer.
dynamicWhether the layer is dynamic (eager-only); set in the constructor.
inbound_nodesReturn Functional API nodes upstream of this layer.
inputRetrieves the input tensor(s) of a layer.
input_maskRetrieves the input mask tensor(s) of a layer.
input_shapeRetrieves the input shape(s) of a layer.
input_specInputSpec instance(s) describing the input format for this layer.
lossesList of losses added using the add_loss() API.
metricsList of metrics added using the add_metric() API.
nameName of the layer (string), set in the constructor.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesSequence of non-trainable variables owned by this module and its submodules.
non_trainable_weightsList of all non-trainable weights tracked by this layer.
outbound_nodesReturn Functional API nodes downstream of this layer.
outputRetrieves the output tensor(s) of a layer.
output_maskRetrieves the output mask tensor(s) of a layer.
output_shapeRetrieves the output shape(s) of a layer.
- stateful
submodulesSequence of all sub-modules.
supports_maskingWhether this layer supports computing a mask using compute_mask.
- trainable
trainable_variablesSequence of trainable variables owned by this module and its submodules.
trainable_weightsList of all trainable weights tracked by this layer.
- updates
variable_dtypeAlias of Layer.dtype, the dtype of the weights.
variablesReturns the list of all layer variables/weights.
weightsReturns the list of all layer variables/weights.
Methods
__call__(*args, **kwargs)Wraps call, applying pre- and post-processing steps.
add_loss(losses, **kwargs)Add loss tensor(s), potentially dependent on layer inputs.
add_metric(value[, name])Adds metric tensor to the layer.
add_update(updates)Add update op(s), potentially dependent on layer inputs.
add_variable(*args, **kwargs)Deprecated, do NOT use! Alias for add_weight.
add_weight([name, shape, dtype, ...])Adds a new variable to the layer.
build(input_shape)Creates the variables of the layer (optional, for subclass implementers).
calculate_monochromatic_PSF(current_opd)Calculate monochromatic PSF from OPD info.
call(opd_batch)Calculate the batch poly PSFs.
compute_mask(inputs[, mask])Computes an output mask tensor.
compute_output_shape(input_shape)Computes the output shape of the layer.
compute_output_signature(input_signature)Compute the output tensor signature of the layer based on the inputs.
count_params()Count the total number of scalars composing the weights.
finalize_state()Finalizes the layers state after updating layer weights.
from_config(config)Creates a layer from its config.
get_config()Returns the config of the layer.
get_input_at(node_index)Retrieves the input tensor(s) of a layer at a given node.
get_input_mask_at(node_index)Retrieves the input mask tensor(s) of a layer at a given node.
get_input_shape_at(node_index)Retrieves the input shape(s) of a layer at a given node.
get_output_at(node_index)Retrieves the output tensor(s) of a layer at a given node.
get_output_mask_at(node_index)Retrieves the output mask tensor(s) of a layer at a given node.
get_output_shape_at(node_index)Retrieves the output shape(s) of a layer at a given node.
get_weights()Returns the current weights of the layer, as NumPy arrays.
Initialise or restart the PSF generator.
set_lambda_phaseN([phase_N, lambda_obs])Set the lambda value for monochromatic PSFs and the phaseN.
set_output_params(output_Q, output_dim)Set output patams, Q and dimension.
set_weights(weights)Sets the weights of the layer, from NumPy arrays.
with_name_scope(method)Decorator to automatically enter the module name scope.
- class wf_psf.psf_models.tf_modules.tf_layers.TFBatchPolychromaticPSF(*args, **kwargs)[source]
Bases:
LayerCalculate a polychromatic PSF from an OPD and stored SED values.
The calculation of the packed values with the respective SED is done with the PSFSimulator class but outside the TF class.
- Parameters:
obscurations (Tensor [opd_dim, opd_dim]) – Obscurations to apply to the wavefront.
packed_SED_data (Tensor [batch_size, 3, n_bins_lda]) –
Comes from: tf.convert_to_tensor(list(list(Tensor,Tensor,Tensor))) Where each inner list consist of a packed_elem:
packed_elems: Tuple of tensors Contains three 1D tensors with the parameters needed for the calculation of one monochromatic PSF.
packed_elems[0]: phase_N packed_elems[1]: lambda_obs packed_elems[2]: SED_norm_val
The SED data is constant in a FoV.
psf_batch (Tensor [batch_size, output_dim, output_dim]) – Tensor containing the psfs that will be updated each time a calculation is required. REMOVED!
- Attributes:
activity_regularizerOptional regularizer function for the output of this layer.
compute_dtypeThe dtype of the layer’s computations.
dtypeThe dtype of the layer weights.
dtype_policyThe dtype policy associated with this layer.
dynamicWhether the layer is dynamic (eager-only); set in the constructor.
inbound_nodesReturn Functional API nodes upstream of this layer.
inputRetrieves the input tensor(s) of a layer.
input_maskRetrieves the input mask tensor(s) of a layer.
input_shapeRetrieves the input shape(s) of a layer.
input_specInputSpec instance(s) describing the input format for this layer.
lossesList of losses added using the add_loss() API.
metricsList of metrics added using the add_metric() API.
nameName of the layer (string), set in the constructor.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesSequence of non-trainable variables owned by this module and its submodules.
non_trainable_weightsList of all non-trainable weights tracked by this layer.
outbound_nodesReturn Functional API nodes downstream of this layer.
outputRetrieves the output tensor(s) of a layer.
output_maskRetrieves the output mask tensor(s) of a layer.
output_shapeRetrieves the output shape(s) of a layer.
- stateful
submodulesSequence of all sub-modules.
supports_maskingWhether this layer supports computing a mask using compute_mask.
- trainable
trainable_variablesSequence of trainable variables owned by this module and its submodules.
trainable_weightsList of all trainable weights tracked by this layer.
- updates
variable_dtypeAlias of Layer.dtype, the dtype of the weights.
variablesReturns the list of all layer variables/weights.
weightsReturns the list of all layer variables/weights.
Methods
__call__(*args, **kwargs)Wraps call, applying pre- and post-processing steps.
add_loss(losses, **kwargs)Add loss tensor(s), potentially dependent on layer inputs.
add_metric(value[, name])Adds metric tensor to the layer.
add_update(updates)Add update op(s), potentially dependent on layer inputs.
add_variable(*args, **kwargs)Deprecated, do NOT use! Alias for add_weight.
add_weight([name, shape, dtype, ...])Adds a new variable to the layer.
build(input_shape)Creates the variables of the layer (optional, for subclass implementers).
calculate_monochromatic_PSF(packed_elems)Calculate monochromatic PSF from packed elements.
calculate_polychromatic_PSF(packed_elems)Calculate a polychromatic PSF.
call(inputs)Calculate the batch polychromatic PSFs.
compute_mask(inputs[, mask])Computes an output mask tensor.
compute_output_shape(input_shape)Computes the output shape of the layer.
compute_output_signature(input_signature)Compute the output tensor signature of the layer based on the inputs.
count_params()Count the total number of scalars composing the weights.
finalize_state()Finalizes the layers state after updating layer weights.
from_config(config)Creates a layer from its config.
get_config()Returns the config of the layer.
get_input_at(node_index)Retrieves the input tensor(s) of a layer at a given node.
get_input_mask_at(node_index)Retrieves the input mask tensor(s) of a layer at a given node.
get_input_shape_at(node_index)Retrieves the input shape(s) of a layer at a given node.
get_output_at(node_index)Retrieves the output tensor(s) of a layer at a given node.
get_output_mask_at(node_index)Retrieves the output mask tensor(s) of a layer at a given node.
get_output_shape_at(node_index)Retrieves the output shape(s) of a layer at a given node.
get_weights()Returns the current weights of the layer, as NumPy arrays.
set_weights(weights)Sets the weights of the layer, from NumPy arrays.
with_name_scope(method)Decorator to automatically enter the module name scope.
- class wf_psf.psf_models.tf_modules.tf_layers.TFNonParametricGraphOPD(*args, **kwargs)[source]
Bases:
LayerNon-parametric OPD generation with only graph-cosntraint variations.
- Parameters:
obs_pos (tensor(n_stars, 2)) – Observed positions of the n_stars in the dataset. The indexing of the positions has to correspond to the indexing in the spatial_dic.
spatial_dic (tensor(n_stars, n_dic_elems)) – Dictionary containing the spatial-constraint dictionary. n_stars corresponds to the total number of stars in the dataset. n_dic_elems corresponds to the number of elements of the dictionary, not to be confounded with n_comp, the total number of non-parametric features of the wavefront-PSF.
graph_comps (int) – Number of wavefront-PSF features correspondign to the graph constraint.
d_max (int) – Max degree of polynomial determining the FoV variations. The number of wavefront-PSF features of the polynomial part is computed (d_max+1)*(d_max+2)/2.
opd_dim (int) – Dimension of the OPD maps. Same as pupil diameter.
- Attributes:
activity_regularizerOptional regularizer function for the output of this layer.
compute_dtypeThe dtype of the layer’s computations.
dtypeThe dtype of the layer weights.
dtype_policyThe dtype policy associated with this layer.
dynamicWhether the layer is dynamic (eager-only); set in the constructor.
inbound_nodesReturn Functional API nodes upstream of this layer.
inputRetrieves the input tensor(s) of a layer.
input_maskRetrieves the input mask tensor(s) of a layer.
input_shapeRetrieves the input shape(s) of a layer.
input_specInputSpec instance(s) describing the input format for this layer.
lossesList of losses added using the add_loss() API.
metricsList of metrics added using the add_metric() API.
nameName of the layer (string), set in the constructor.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesSequence of non-trainable variables owned by this module and its submodules.
non_trainable_weightsList of all non-trainable weights tracked by this layer.
outbound_nodesReturn Functional API nodes downstream of this layer.
outputRetrieves the output tensor(s) of a layer.
output_maskRetrieves the output mask tensor(s) of a layer.
output_shapeRetrieves the output shape(s) of a layer.
- stateful
submodulesSequence of all sub-modules.
supports_maskingWhether this layer supports computing a mask using compute_mask.
- trainable
trainable_variablesSequence of trainable variables owned by this module and its submodules.
trainable_weightsList of all trainable weights tracked by this layer.
- updates
variable_dtypeAlias of Layer.dtype, the dtype of the weights.
variablesReturns the list of all layer variables/weights.
weightsReturns the list of all layer variables/weights.
Methods
__call__(*args, **kwargs)Wraps call, applying pre- and post-processing steps.
add_loss(losses, **kwargs)Add loss tensor(s), potentially dependent on layer inputs.
add_metric(value[, name])Adds metric tensor to the layer.
add_update(updates)Add update op(s), potentially dependent on layer inputs.
add_variable(*args, **kwargs)Deprecated, do NOT use! Alias for add_weight.
add_weight([name, shape, dtype, ...])Adds a new variable to the layer.
build(input_shape)Creates the variables of the layer (optional, for subclass implementers).
call(positions)Calculate the OPD maps for the given positions.
compute_mask(inputs[, mask])Computes an output mask tensor.
compute_output_shape(input_shape)Computes the output shape of the layer.
compute_output_signature(input_signature)Compute the output tensor signature of the layer based on the inputs.
count_params()Count the total number of scalars composing the weights.
finalize_state()Finalizes the layers state after updating layer weights.
from_config(config)Creates a layer from its config.
get_config()Returns the config of the layer.
get_input_at(node_index)Retrieves the input tensor(s) of a layer at a given node.
get_input_mask_at(node_index)Retrieves the input mask tensor(s) of a layer at a given node.
get_input_shape_at(node_index)Retrieves the input shape(s) of a layer at a given node.
get_output_at(node_index)Retrieves the output tensor(s) of a layer at a given node.
get_output_mask_at(node_index)Retrieves the output mask tensor(s) of a layer at a given node.
get_output_shape_at(node_index)Retrieves the output shape(s) of a layer at a given node.
get_weights()Returns the current weights of the layer, as NumPy arrays.
Initialize trainable variables.
predict(positions)Prediction step.
Set alpha matrix to the identity.
Set alpha matrix to zero.
set_weights(weights)Sets the weights of the layer, from NumPy arrays.
with_name_scope(method)Decorator to automatically enter the module name scope.
- call(positions)[source]
Calculate the OPD maps for the given positions.
Calculating: batch(spatial_dict) x alpha x S
- Parameters:
positions (Tensor(batch, 2)) – First element is x-axis, second is y-axis.
- Returns:
opd_maps
- Return type:
Tensor(batch, opd_dim, opd_dim)
- class wf_psf.psf_models.tf_modules.tf_layers.TFNonParametricMCCDOPDv2(*args, **kwargs)[source]
Bases:
LayerNon-parametric OPD generation with hybrid-MCCD variations.
- Parameters:
obs_pos (tensor(n_stars, 2)) – Observed positions of the n_stars in the dataset. The indexing of the positions has to correspond to the indexing in the spatial_dic.
spatial_dic (tensor(n_stars, n_dic_elems)) – Dictionary containing the spatial-constraint dictionary. n_stars corresponds to the total number of stars in the dataset. n_dic_elems corresponds to the number of elements of the dictionary, not to be confounded with n_comp, the total number of non-parametric features of the wavefront-PSF.
graph_comps (int) – Number of wavefront-PSF features correspondign to the graph constraint.
d_max (int) – Max degree of polynomial determining the FoV variations. The number of wavefront-PSF features of the polynomial part is computed (d_max+1)*(d_max+2)/2.
opd_dim (int) – Dimension of the OPD maps. Same as pupil diameter.
- Attributes:
activity_regularizerOptional regularizer function for the output of this layer.
compute_dtypeThe dtype of the layer’s computations.
dtypeThe dtype of the layer weights.
dtype_policyThe dtype policy associated with this layer.
dynamicWhether the layer is dynamic (eager-only); set in the constructor.
inbound_nodesReturn Functional API nodes upstream of this layer.
inputRetrieves the input tensor(s) of a layer.
input_maskRetrieves the input mask tensor(s) of a layer.
input_shapeRetrieves the input shape(s) of a layer.
input_specInputSpec instance(s) describing the input format for this layer.
lossesList of losses added using the add_loss() API.
metricsList of metrics added using the add_metric() API.
nameName of the layer (string), set in the constructor.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesSequence of non-trainable variables owned by this module and its submodules.
non_trainable_weightsList of all non-trainable weights tracked by this layer.
outbound_nodesReturn Functional API nodes downstream of this layer.
outputRetrieves the output tensor(s) of a layer.
output_maskRetrieves the output mask tensor(s) of a layer.
output_shapeRetrieves the output shape(s) of a layer.
- stateful
submodulesSequence of all sub-modules.
supports_maskingWhether this layer supports computing a mask using compute_mask.
- trainable
trainable_variablesSequence of trainable variables owned by this module and its submodules.
trainable_weightsList of all trainable weights tracked by this layer.
- updates
variable_dtypeAlias of Layer.dtype, the dtype of the weights.
variablesReturns the list of all layer variables/weights.
weightsReturns the list of all layer variables/weights.
Methods
__call__(*args, **kwargs)Wraps call, applying pre- and post-processing steps.
add_loss(losses, **kwargs)Add loss tensor(s), potentially dependent on layer inputs.
add_metric(value[, name])Adds metric tensor to the layer.
add_update(updates)Add update op(s), potentially dependent on layer inputs.
add_variable(*args, **kwargs)Deprecated, do NOT use! Alias for add_weight.
add_weight([name, shape, dtype, ...])Adds a new variable to the layer.
build(input_shape)Creates the variables of the layer (optional, for subclass implementers).
call(positions)Calculate the OPD maps for the given positions.
compute_mask(inputs[, mask])Computes an output mask tensor.
compute_output_shape(input_shape)Computes the output shape of the layer.
compute_output_signature(input_signature)Compute the output tensor signature of the layer based on the inputs.
count_params()Count the total number of scalars composing the weights.
finalize_state()Finalizes the layers state after updating layer weights.
from_config(config)Creates a layer from its config.
get_config()Returns the config of the layer.
get_input_at(node_index)Retrieves the input tensor(s) of a layer at a given node.
get_input_mask_at(node_index)Retrieves the input mask tensor(s) of a layer at a given node.
get_input_shape_at(node_index)Retrieves the input shape(s) of a layer at a given node.
get_output_at(node_index)Retrieves the output tensor(s) of a layer at a given node.
get_output_mask_at(node_index)Retrieves the output mask tensor(s) of a layer at a given node.
get_output_shape_at(node_index)Retrieves the output shape(s) of a layer at a given node.
get_weights()Returns the current weights of the layer, as NumPy arrays.
Initialize trainable variables.
predict(positions)Prediction step.
Set alpha matrix to the identity.
Set alpha matrix to zero.
set_weights(weights)Sets the weights of the layer, from NumPy arrays.
with_name_scope(method)Decorator to automatically enter the module name scope.
- call(positions)[source]
Calculate the OPD maps for the given positions.
Calculating: batch(spatial_dict) x alpha x S
- Parameters:
positions (Tensor(batch, 2)) – First element is x-axis, second is y-axis.
- Returns:
opd_maps
- Return type:
Tensor(batch, opd_dim, opd_dim)
- class wf_psf.psf_models.tf_modules.tf_layers.TFNonParametricPolynomialVariationsOPD(*args, **kwargs)[source]
Bases:
LayerNon-parametric OPD generation with polynomial variations.
- Parameters:
- Attributes:
activity_regularizerOptional regularizer function for the output of this layer.
compute_dtypeThe dtype of the layer’s computations.
dtypeThe dtype of the layer weights.
dtype_policyThe dtype policy associated with this layer.
dynamicWhether the layer is dynamic (eager-only); set in the constructor.
inbound_nodesReturn Functional API nodes upstream of this layer.
inputRetrieves the input tensor(s) of a layer.
input_maskRetrieves the input mask tensor(s) of a layer.
input_shapeRetrieves the input shape(s) of a layer.
input_specInputSpec instance(s) describing the input format for this layer.
lossesList of losses added using the add_loss() API.
metricsList of metrics added using the add_metric() API.
nameName of the layer (string), set in the constructor.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesSequence of non-trainable variables owned by this module and its submodules.
non_trainable_weightsList of all non-trainable weights tracked by this layer.
outbound_nodesReturn Functional API nodes downstream of this layer.
outputRetrieves the output tensor(s) of a layer.
output_maskRetrieves the output mask tensor(s) of a layer.
output_shapeRetrieves the output shape(s) of a layer.
- stateful
submodulesSequence of all sub-modules.
supports_maskingWhether this layer supports computing a mask using compute_mask.
- trainable
trainable_variablesSequence of trainable variables owned by this module and its submodules.
trainable_weightsList of all trainable weights tracked by this layer.
- updates
variable_dtypeAlias of Layer.dtype, the dtype of the weights.
variablesReturns the list of all layer variables/weights.
weightsReturns the list of all layer variables/weights.
Methods
__call__(*args, **kwargs)Wraps call, applying pre- and post-processing steps.
add_loss(losses, **kwargs)Add loss tensor(s), potentially dependent on layer inputs.
add_metric(value[, name])Adds metric tensor to the layer.
add_update(updates)Add update op(s), potentially dependent on layer inputs.
add_variable(*args, **kwargs)Deprecated, do NOT use! Alias for add_weight.
add_weight([name, shape, dtype, ...])Adds a new variable to the layer.
assign_S_mat(S_mat)Assign DD features matrix.
build(input_shape)Creates the variables of the layer (optional, for subclass implementers).
call(positions)Calculate the OPD maps for the given positions.
compute_mask(inputs[, mask])Computes an output mask tensor.
compute_output_shape(input_shape)Computes the output shape of the layer.
compute_output_signature(input_signature)Compute the output tensor signature of the layer based on the inputs.
count_params()Count the total number of scalars composing the weights.
finalize_state()Finalizes the layers state after updating layer weights.
from_config(config)Creates a layer from its config.
get_config()Returns the config of the layer.
get_input_at(node_index)Retrieves the input tensor(s) of a layer at a given node.
get_input_mask_at(node_index)Retrieves the input mask tensor(s) of a layer at a given node.
get_input_shape_at(node_index)Retrieves the input shape(s) of a layer at a given node.
get_output_at(node_index)Retrieves the output tensor(s) of a layer at a given node.
get_output_mask_at(node_index)Retrieves the output mask tensor(s) of a layer at a given node.
get_output_shape_at(node_index)Retrieves the output shape(s) of a layer at a given node.
get_weights()Returns the current weights of the layer, as NumPy arrays.
Initialize trainable variables.
Set alpha matrix to the identity.
Set alpha matrix to zero.
set_weights(weights)Sets the weights of the layer, from NumPy arrays.
with_name_scope(method)Decorator to automatically enter the module name scope.
- call(positions)[source]
Calculate the OPD maps for the given positions.
Calculating: Pi(pos) x alpha x S
- Parameters:
positions (Tensor(batch, 2)) – First element is x-axis, second is y-axis.
- Returns:
opd_maps
- Return type:
Tensor(batch, opd_dim, opd_dim)
- class wf_psf.psf_models.tf_modules.tf_layers.TFPhysicalLayer(*args, **kwargs)[source]
Bases:
LayerThe Zernike physical layer.
This layer gives the Zernike contribution of the physical layer. It is fixed and not trainable. It can interpolate the Zernike coefficients at the input positions using different interpolation schemes.
- Parameters:
obs_pos (Tensor (n_stars, 2)) – Observed positions of the n_stars in the dataset. The indexing of the positions has to correspond to the indexing in the zks_prior.
n_zernikes (int) – Number of Zernike polynomials
zks_prior (Tensor (n_stars, n_zernikes)) – Zernike coefficients for each position
interpolation_type (str) – Type of interpolation to be used. Options are: None, ‘all’, ‘top_K’, ‘independent_Zk’. Default is None.
interpolation_args (dict) – Interpolation hyper-parameters. The order of the RBF interpolation, and the K elements in the top_K interpolation.
- Attributes:
activity_regularizerOptional regularizer function for the output of this layer.
compute_dtypeThe dtype of the layer’s computations.
dtypeThe dtype of the layer weights.
dtype_policyThe dtype policy associated with this layer.
dynamicWhether the layer is dynamic (eager-only); set in the constructor.
inbound_nodesReturn Functional API nodes upstream of this layer.
inputRetrieves the input tensor(s) of a layer.
input_maskRetrieves the input mask tensor(s) of a layer.
input_shapeRetrieves the input shape(s) of a layer.
input_specInputSpec instance(s) describing the input format for this layer.
lossesList of losses added using the add_loss() API.
metricsList of metrics added using the add_metric() API.
nameName of the layer (string), set in the constructor.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesSequence of non-trainable variables owned by this module and its submodules.
non_trainable_weightsList of all non-trainable weights tracked by this layer.
outbound_nodesReturn Functional API nodes downstream of this layer.
outputRetrieves the output tensor(s) of a layer.
output_maskRetrieves the output mask tensor(s) of a layer.
output_shapeRetrieves the output shape(s) of a layer.
- stateful
submodulesSequence of all sub-modules.
supports_maskingWhether this layer supports computing a mask using compute_mask.
- trainable
trainable_variablesSequence of trainable variables owned by this module and its submodules.
trainable_weightsList of all trainable weights tracked by this layer.
- updates
variable_dtypeAlias of Layer.dtype, the dtype of the weights.
variablesReturns the list of all layer variables/weights.
weightsReturns the list of all layer variables/weights.
Methods
__call__(*args, **kwargs)Wraps call, applying pre- and post-processing steps.
add_loss(losses, **kwargs)Add loss tensor(s), potentially dependent on layer inputs.
add_metric(value[, name])Adds metric tensor to the layer.
add_update(updates)Add update op(s), potentially dependent on layer inputs.
add_variable(*args, **kwargs)Deprecated, do NOT use! Alias for add_weight.
add_weight([name, shape, dtype, ...])Adds a new variable to the layer.
build(input_shape)Creates the variables of the layer (optional, for subclass implementers).
call(positions)Calculate the prior Zernike coefficients for a batch of positions.
compute_mask(inputs[, mask])Computes an output mask tensor.
compute_output_shape(input_shape)Computes the output shape of the layer.
compute_output_signature(input_signature)Compute the output tensor signature of the layer based on the inputs.
count_params()Count the total number of scalars composing the weights.
finalize_state()Finalizes the layers state after updating layer weights.
from_config(config)Creates a layer from its config.
get_config()Returns the config of the layer.
get_input_at(node_index)Retrieves the input tensor(s) of a layer at a given node.
get_input_mask_at(node_index)Retrieves the input mask tensor(s) of a layer at a given node.
get_input_shape_at(node_index)Retrieves the input shape(s) of a layer at a given node.
get_output_at(node_index)Retrieves the output tensor(s) of a layer at a given node.
get_output_mask_at(node_index)Retrieves the output mask tensor(s) of a layer at a given node.
get_output_shape_at(node_index)Retrieves the output shape(s) of a layer at a given node.
get_weights()Returns the current weights of the layer, as NumPy arrays.
interpolate_all(positions)Interpolate using all the input elements.
interpolate_independent_Zk(positions)Interpolate each Zernike independently.
interpolate_top_K(positions)Interpolate using only the K closest elements.
set_weights(weights)Sets the weights of the layer, from NumPy arrays.
with_name_scope(method)Decorator to automatically enter the module name scope.
- call(positions)[source]
Calculate the prior Zernike coefficients for a batch of positions.
This method calculates the Zernike coefficients for a batch of input positions based on the pre-computed Zernike coefficients for observed positions.
- Parameters:
positions (tf.Tensor) – Tensor of shape (batch_size, 2) representing the positions. The first element represents the x-axis, and the second element represents the y-axis.
- Returns:
zernike_coeffs – Tensor of shape (batch_size, n_zernikes, 1, 1) containing the prior Zernike coefficients corresponding to the input positions.
- Return type:
tf.Tensor
Notes
The method retrieves the Zernike coefficients for each input position from the pre-computed Zernike coefficients stored for observed positions. It matches each input position with the closest observed position and retrieves the corresponding Zernike coefficients.
Before calling this method, ensure that the position polynomial matrix and the corresponding Zernike coefficients have been precomputed and set for the layer.
- Raises:
ValueError – If the shape of the input positions tensor is not compatible.
- interpolate_all(positions)[source]
Interpolate using all the input elements.
The TensorFlow Addons function tfa.image.interpolate_spline is used to perform the RBF interpolation of the Zernike coefficients.
- Parameters:
positions (tf.Tensor) – Tensor of shape (batch_size, 2) representing the positions. The first element represents the x-axis, and the second element represents the y-axis.
- Returns:
interp_zks – Tensor of shape (batch_size, n_zernikes, 1, 1) containing the interpolated Zernike coefficients corresponding to the input positions.
- Return type:
tf.Tensor
- interpolate_independent_Zk(positions)[source]
Interpolate each Zernike independently.
The class wf.utils.IndependentZernikeInterpolation allows to interpolate each order of the Zernike polynomials independently using all the points avaialble to build the interpolant.
- Parameters:
positions (tf.Tensor) – Tensor of shape (batch_size, 2) representing the positions. The first element represents the x-axis, and the second element represents the y-axis.
- Returns:
interp_zks – Tensor of shape (batch_size, n_zernikes, 1, 1) containing the interpolated Zernike coefficients corresponding to the input positions.
- Return type:
tf.Tensor
- interpolate_top_K(positions)[source]
Interpolate using only the K closest elements.
The class wf.utils.ZernikeInterpolation allows to interpolate the Zernike coefficients using only the K closest points to build the interpolant.
- Parameters:
positions (tf.Tensor) – Tensor of shape (batch_size, 2) representing the positions. The first element represents the x-axis, and the second element represents the y-axis.
- Returns:
interp_zks – Tensor of shape (batch_size, n_zernikes, 1, 1) containing the interpolated Zernike coefficients corresponding to the input positions.
- Return type:
tf.Tensor
- class wf_psf.psf_models.tf_modules.tf_layers.TFPolynomialZernikeField(*args, **kwargs)[source]
Bases:
LayerCalculate the zernike coefficients for a given position.
This module implements a polynomial model of Zernike coefficient variation.
- Parameters:
- Attributes:
activity_regularizerOptional regularizer function for the output of this layer.
compute_dtypeThe dtype of the layer’s computations.
dtypeThe dtype of the layer weights.
dtype_policyThe dtype policy associated with this layer.
dynamicWhether the layer is dynamic (eager-only); set in the constructor.
inbound_nodesReturn Functional API nodes upstream of this layer.
inputRetrieves the input tensor(s) of a layer.
input_maskRetrieves the input mask tensor(s) of a layer.
input_shapeRetrieves the input shape(s) of a layer.
input_specInputSpec instance(s) describing the input format for this layer.
lossesList of losses added using the add_loss() API.
metricsList of metrics added using the add_metric() API.
nameName of the layer (string), set in the constructor.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesSequence of non-trainable variables owned by this module and its submodules.
non_trainable_weightsList of all non-trainable weights tracked by this layer.
outbound_nodesReturn Functional API nodes downstream of this layer.
outputRetrieves the output tensor(s) of a layer.
output_maskRetrieves the output mask tensor(s) of a layer.
output_shapeRetrieves the output shape(s) of a layer.
- stateful
submodulesSequence of all sub-modules.
supports_maskingWhether this layer supports computing a mask using compute_mask.
- trainable
trainable_variablesSequence of trainable variables owned by this module and its submodules.
trainable_weightsList of all trainable weights tracked by this layer.
- updates
variable_dtypeAlias of Layer.dtype, the dtype of the weights.
variablesReturns the list of all layer variables/weights.
weightsReturns the list of all layer variables/weights.
Methods
__call__(*args, **kwargs)Wraps call, applying pre- and post-processing steps.
add_loss(losses, **kwargs)Add loss tensor(s), potentially dependent on layer inputs.
add_metric(value[, name])Adds metric tensor to the layer.
add_update(updates)Add update op(s), potentially dependent on layer inputs.
add_variable(*args, **kwargs)Deprecated, do NOT use! Alias for add_weight.
add_weight([name, shape, dtype, ...])Adds a new variable to the layer.
assign_coeff_matrix(coeff_mat)Assign coefficient matrix.
build(input_shape)Creates the variables of the layer (optional, for subclass implementers).
call(positions)Calculate the zernike coefficients for a given position.
compute_mask(inputs[, mask])Computes an output mask tensor.
compute_output_shape(input_shape)Computes the output shape of the layer.
compute_output_signature(input_signature)Compute the output tensor signature of the layer based on the inputs.
count_params()Count the total number of scalars composing the weights.
finalize_state()Finalizes the layers state after updating layer weights.
from_config(config)Creates a layer from its config.
Get coefficient matrix.
get_config()Returns the config of the layer.
get_input_at(node_index)Retrieves the input tensor(s) of a layer at a given node.
get_input_mask_at(node_index)Retrieves the input mask tensor(s) of a layer at a given node.
get_input_shape_at(node_index)Retrieves the input shape(s) of a layer at a given node.
get_output_at(node_index)Retrieves the output tensor(s) of a layer at a given node.
get_output_mask_at(node_index)Retrieves the output mask tensor(s) of a layer at a given node.
get_output_shape_at(node_index)Retrieves the output shape(s) of a layer at a given node.
Return the shape of the coefficient matrix.
get_weights()Returns the current weights of the layer, as NumPy arrays.
Initialize coefficient matrix.
set_weights(weights)Sets the weights of the layer, from NumPy arrays.
with_name_scope(method)Decorator to automatically enter the module name scope.
- call(positions)[source]
Calculate the zernike coefficients for a given position.
The position polynomial matrix and the coefficients should be set before calling this function.
- Parameters:
positions (Tensor(batch, 2)) – First element is x-axis, second is y-axis.
- Returns:
zernikes_coeffs
- Return type:
Tensor(batch, n_zernikes, 1, 1)
- class wf_psf.psf_models.tf_modules.tf_layers.TFZernikeOPD(*args, **kwargs)[source]
Bases:
LayerCalculate the OPD from Zernike maps and coefficients.
This class generates OPD maps from Zernike coefficients and Zernike maps. Both Zernike maps and Zernike coefficients must be provided to the class.
- Parameters:
zernike_maps (Tensor (Num_coeffs, x_dim, y_dim))
z_coeffs (Tensor (batch_size, n_zernikes, 1, 1))
- Returns:
opd
- Return type:
Tensor (batch_size, x_dim, y_dim)
- Attributes:
activity_regularizerOptional regularizer function for the output of this layer.
compute_dtypeThe dtype of the layer’s computations.
dtypeThe dtype of the layer weights.
dtype_policyThe dtype policy associated with this layer.
dynamicWhether the layer is dynamic (eager-only); set in the constructor.
inbound_nodesReturn Functional API nodes upstream of this layer.
inputRetrieves the input tensor(s) of a layer.
input_maskRetrieves the input mask tensor(s) of a layer.
input_shapeRetrieves the input shape(s) of a layer.
input_specInputSpec instance(s) describing the input format for this layer.
lossesList of losses added using the add_loss() API.
metricsList of metrics added using the add_metric() API.
nameName of the layer (string), set in the constructor.
name_scopeReturns a tf.name_scope instance for this class.
non_trainable_variablesSequence of non-trainable variables owned by this module and its submodules.
non_trainable_weightsList of all non-trainable weights tracked by this layer.
outbound_nodesReturn Functional API nodes downstream of this layer.
outputRetrieves the output tensor(s) of a layer.
output_maskRetrieves the output mask tensor(s) of a layer.
output_shapeRetrieves the output shape(s) of a layer.
- stateful
submodulesSequence of all sub-modules.
supports_maskingWhether this layer supports computing a mask using compute_mask.
- trainable
trainable_variablesSequence of trainable variables owned by this module and its submodules.
trainable_weightsList of all trainable weights tracked by this layer.
- updates
variable_dtypeAlias of Layer.dtype, the dtype of the weights.
variablesReturns the list of all layer variables/weights.
weightsReturns the list of all layer variables/weights.
Methods
__call__(*args, **kwargs)Wraps call, applying pre- and post-processing steps.
add_loss(losses, **kwargs)Add loss tensor(s), potentially dependent on layer inputs.
add_metric(value[, name])Adds metric tensor to the layer.
add_update(updates)Add update op(s), potentially dependent on layer inputs.
add_variable(*args, **kwargs)Deprecated, do NOT use! Alias for add_weight.
add_weight([name, shape, dtype, ...])Adds a new variable to the layer.
build(input_shape)Creates the variables of the layer (optional, for subclass implementers).
call(z_coeffs)Perform the weighted sum of Zernikes coeffs and maps.
compute_mask(inputs[, mask])Computes an output mask tensor.
compute_output_shape(input_shape)Computes the output shape of the layer.
compute_output_signature(input_signature)Compute the output tensor signature of the layer based on the inputs.
count_params()Count the total number of scalars composing the weights.
finalize_state()Finalizes the layers state after updating layer weights.
from_config(config)Creates a layer from its config.
get_config()Returns the config of the layer.
get_input_at(node_index)Retrieves the input tensor(s) of a layer at a given node.
get_input_mask_at(node_index)Retrieves the input mask tensor(s) of a layer at a given node.
get_input_shape_at(node_index)Retrieves the input shape(s) of a layer at a given node.
get_output_at(node_index)Retrieves the output tensor(s) of a layer at a given node.
get_output_mask_at(node_index)Retrieves the output mask tensor(s) of a layer at a given node.
get_output_shape_at(node_index)Retrieves the output shape(s) of a layer at a given node.
get_weights()Returns the current weights of the layer, as NumPy arrays.
set_weights(weights)Sets the weights of the layer, from NumPy arrays.
with_name_scope(method)Decorator to automatically enter the module name scope.