# Removing the continuum from narrow spectral line bands in Miriad

(original text by Demerese Salter --- 11/15/2011)

(edited by Shaye Storm --- 11/16/2011)

• The task uvlin will try to remove the continuum but may not respect mosaicing and should therefore be used with caution. The task uvcal with options=contsub ought to do the same. There some good discussion up on 
• To subtract the continuum, it is best to work within the band where the line is. Flux offsets may exist between spectral windows depending on the separation between bands, and fitting the data with a linear polynomial to account for the spectral slope may not be sufficient. In addition, by subtracting the continuum from the data, you inherently introduce noise to the image, and increasing the bandwidth of the continuum determination only reduces this added noise according to the inverse square root of the number of channels. Therefore, the impact on the noise improvement decreases more quickly than the increasing bandwidth until the it doesn't make sense anymore to include more continuum channels in the solution. This effect is represented by the following equation:
```   sigma_line = sqrt ( (sigma^2)/n + (sigma^2)/m )
, where n is the number of channels in the line and m are the number of channels used in the continuum solution.
```
• One recommended method for continuum subtraction is to flag with uvflag the channels that should not be in the spectral line map. Take these channels and create a cleaned continuum map. Then use uvmodel to subtract the clean components that represent the continuum emission. Re-create the u,v data set without these components and proceed with inverting, cleaning, and restoring the new, line-only u,v data. For mosaiced data the added complexity here is that you will need to use demos to do this to individual fields and re-assemble later.
• An alternative method is to do the subtraction using the dirty maps. This is possible because of the linear nature of Fourier transforms: FT(A) - FT(B) = FT(A-B). The task maths should allow you to subtract one plane (e.g. the continuum) from n planes (e.g. the spectral line emission channels) if you use options=grow. As an example:
```   maths exp='<'\$LCUBE'>-working1' options=grow out=working2
```