# Confusion Noise implementation

## Feature Overview

### Files:

## Function: getContinuumConfusionNoise & getSpectralConfusionNoise

This function returns the confusion noise value.

### Parameters

- weightingResponseLowWeightingCalculationResult
The weighting response object.

### Returns

- number or undefined
A value of type any.

### Usage

```
const confusionNoise = getContinuumConfusionNoise(weightingResponse);
const confusionNoise = getSpectralConfusionNoise(weightingResponse);
```

### Notes

## Function: getContinuumSurfaceBrightnessSensitivity & getSpectralSurfaceBrightnessSensitivity

This function uses the total sensitivity and the surface brightness sensitivity conversion factor (sbs_conv_factor) from the weightingResponse to calculate the surface brightness sensitivity and returns it.

### Parameters

- weightingResponseLowWeightingCalculationResult
The weighting response object.

- continuumTotalSensitivity or spectralTotalSensitivitynumber
The calculated total sensitivity

### Returns

number

### Usage

```
const continuumSurfaceBrightnessSensitivity = this.getContinuumSurfaceBrightnessSensitivity(weightingResponse, continuumTotalSensitivity);
const zoomSurfaceBrightnessSensitivity = this.getContinuumSurfaceBrightnessSensitivity(weightingResponse, spectralTotalSensitivity)
```

## Function: minBeamSizeCheck

This function checks if the beam size in arcseconds is smaller than the minimum beam size limit.

### Parameters

- beam_min_scalednumber
The minor beam size in degrees

- beam_maj_scalednumber
The major beam size in degrees

- precisionnumber
The number of decimal places to display the result to

### Returns

- number
The calculated beam size in square arcseconds

### Usage

```
helpers.calculate.minBeamSizeCheck(weightingResponse, 1)
```

### Notes

## Function: displayResult

This function displays the results of the low continuum sensitivity calculation in the UI.

### Parameters

- calculateResponseLowContinuumSensitivityResponse
The response object from the low continuum sensitivity calculation.

- weightingResponseLowWeightingCalculationResult
The weighting response object.

- showBeamAndSBSboolean
A flag indicating whether to display the synthesized beam size and surface brightness sensitivity.

### Returns

None

### Usage

```
displayResult(calculateResponse, weightingResponse, showBeamAndSBS);
```

### Notes

## Function: selectSensitivityUnit

### Parameters

- valueany
The input value to be converted.

### Returns

- string
The converted value with the appropriate unit and “/beam” appended to it.

### Usage

```
selectSensitivityUnit(value);
```

## Function: convertValueNew

### Parameters

- conversionTypestring
The type of value being converted (time, frequency, or sensitivity).

- conversionUnitstring
The unit to convert to.

- valueany
The value to be converted.

- digitsAfterDecimalnumber
The number of digits after the decimal point to be displayed. Default value is 2.

### Returns

- string
The converted value with the appropriate unit.

### Usage

```
convertValueNew(conversionType, conversionUnit, value, digitsAfterDecimal);
```

### Function: displayResultWithoutWeighting

This function displays the results of the low continuum sensitivity calculation in the UI without taking into account the weighting factor. This is run when custom array is selected.

### Parameters

- calculateResponseLowContinuumSensitivityResponse
The response object from the low continuum sensitivity calculation.

### Returns

None

### Usage

```
displayResultWithoutWeighting(calculateResponse);
```

### Notes

# Confusion Limit Warning implementation

## Feature Overview

## Function: sensitivityLimitCheck

This function checks whether the total sensitivity is approaching the confusion noise limit. The confusion noise limit is when the total sensitivity is less than twice the confusion noise, so we define approaching the limit as any sensitivity within 2 * confusion noise.

### Parameters

- confusionNoisenumber | string | typeof NaN
The calculated confusion noise for the observation.

- sensitivitynumber | string
The total sensitivity that has been calculated using the square of summs of confusion noise and weighted sensitivity.

### Returns

- boolean
Returns true if the sensitivity is near the limit and false otherwise.

### Usage

```
const sensLimitReached = helpers.calculate.sensitivityLimitCheck(continuumConfusionNoise, continuumWeightedSensitivity);
```

### Notes

## Function: sensLimitWarning

This function returns a warning message when the sensitivity limit is reached.

### Returns

- string
The warning message for the sensitivity limit.

### Usage

```
const warningMessage = sensLimitWarning();
```

### Notes

### Usage in HTML

```
<mat-error *ngIf="sensLimitReached" id="sensLimitWarning">
{{sensLimitWarning()}}
</mat-error>
```

This code displays a warning message when the sensitivity limit is reached, as determined by the sensitivityLimitCheck function.