Simulating data acquisition
An essential part of Strip polarimeters is the set of four Analogue-to-Digital Converters (ADC) that measure input voltages as 20-bit digital numbers. This process is called quantization, and it is a non-invertible operation that causes loss of information. Ideal ADCs perform a linear operation (modulo a rounding operation), but real-world components are never perfectly linear.
Because of the fact that CMB experiments like Strip measure brightness temperatures, Stripeline models ADCs as devices that convert temperatures into ADUs, neglecting the fact that Strip polarimeters convert incoming fluxes into voltages.
Stripeline offers a few functions to simulate the behaviour of an ADC. The simulation of ADC behaviour is useful to estimate the impact of quantization and non linearities. The following schema show how things work:
Function adc_response
takes a temperature as input, and it produces the output that would be emitted by an ADC. The function adc_inv_response
performs the reverse transformation: it converts a digital number back to a temperature. Function adc_filter
combines the two functions: it takes a temperature as input, and it returns the temperature that has been measured by the ADC, including the effect of quantization and non linearities.
An important difference between adc_response
and adc_inv_response
is the fact that adc_response
considers non linearities, while adc_inv_response
does not.
Stripeline.ADC
— TypeA structure representing the configuration of an Analogue-to-Digital Converter (ADC). To simplify things, we assume that the ADC is fed with some temperature, instead of a voltage. In this case we can avoid dealing with the calibration from Volt to Kelvin, which is seldom useful in simulations.
The equation used to model the ADC is the following:
x(V) = round(gain_k_over_adu * (V - offset_k)) + zero_point_adu
and the output is clipped within a user-defined range. The following fields are available:
offset_k
gain_k_over_adu
zero_point_adu
min_output_adu
: output values below this will be clippedmax_output_adu
: output values above this will be clippednon_linearities_x_adu
: see belownon_linearities_y_adu
: see below
Non linearities must be specified using the two arrays non_linearities_x_adu
and non_linearities_y_adu
. For each input voltage fed to the ADC, a non linearity is applied to the output according to the following algorithm:
- The function computes the ideal output (i.e., without non linearities);
- It checks if the value of the ideal output is found in the array
non_linearities_x_adu
; - If the value is found, add the corresponding value in the array
non_linearities_y_adu
(i.e., the element with the same index as the element innon_linearities_x_adu
) to the ideal output; - If the value is not found, but it falls within two consecutive values, use a linear interpolation;
- If the value is smaller than the first element or larger than the last element in
non_linearities_x_adu
, do not apply any correction to the output.
It is fundamental that non_linearities_x_adu
is sorted in ascending order, and that the order of the in elements non_linearities_y_adu
matches the order in non_linearities_x_adu
.
Stripeline.optimized_adc
— Functionoptimized_adc(; min_input_k = 0.0, max_input_k = 100.0, dynamic_range = 0.35, nbits = 20, non_linearities_x_adu = Float64[], non_linearities_y_adu = Float64[])
Return an object of type ADC
that is optimized to measure temperatures between min_input_k
and max_input_k
. The ADC is configured to return signed numbers in the range -2^nbits…2^nbits.
The function accepts the following keywords:
min_input_k
: temperature that should trigger the lowest output within the dynamic rangemax_input_k
: temperature that should trigger the lowest output within the dynamic rangedynamic_range
: pure number in the interval 0…1 that specifies the dynamic range of the outputnbits
: number of bits used by the ADCnon_linearities_x_adu
: same parameter used in the constructor forADC
non_linearities_y_adu
: same parameter used in the constructor forADC
Stripeline.adc_response
— Functionadc_response(adc::ADC, input_k; include_non_linearities = true)
Simulate the response of an ADC on some voltage input_k
. If include_non_linearities
is true
, non-linearities specified in adc
will be considered; otherwise, the ADC will be assumed to be ideal.
See also adc_inv_response
for the (pseudo)inverse function.
Stripeline.adc_inv_response
— Functionadc_inv_response(adc::ADC, input_adu)
Apply the inverse transformation of an ADC to get some voltage from a digital measurement in ADU.This function assumes that the ADC is ideal, i.e., that it does not have non-linearities.
See also adc_response
.
Stripeline.adc_filter
— Functionadc_filter(adc::ADC, input_k; include_non_linearities = true)
Simulate the measurement of the temperature input_k
through the ADC adc
. The result is still a temperature, after it has been converted into ADUs by the ADC and then converted back to a temperature again. If non-linearities are specified in adc
, they will be applied only to the K→ADU transformation.