polynomial fitting

179 views
Skip to first unread message

Eduard Mol

unread,
Jun 18, 2024, 8:24:54 AMJun 18
to sara-list
Hi all,

During last Sunday's Drake's Lounge there was some discussion about bandpass correction and polynomial fitting. For those of you who have not followed Drake's Lounge here is a bit of context.
When trying to do spectroscopy on faint and difficult targets (e.g. other galaxies in HI, masers...) the signal is often completely obscured by the uneven bandpass shape of the SDR receiver/ radio telescope system. Proper background subtraction to get a good flat spectrum is really the key to success for such observations. Typically, we take on-target spectra and an equal number of off-target spectra (with the telescope pointed away from the target), then subtract or divide the off-target spectra from the on-target "dark" spectra. This way we (hopefully) get rid of the system response leaving only the faint spectral signal of the target. Unfortunately, it is common that the bandpass shape slightly changes during recording due to factors like temperature variation, leaving a residual slope in the spectrum after background subtraction. This is especially problematic with long observation runs, which are needed to detect the faintest targets. If you are lucky it is a straight slope that can simply be removed by fitting a line, but sometimes the curve is more complex and a (higher order) polynomial may be needed. However, that comes with its own problems.

During the Drake's Lounge I showed an example of this effect in a recent ~2 hour long recording of Orion KL at the 22.2GHz water line. Due to variations in temperature, atmospheric moisture etc there was a strong residual curve in the spectrum after background subtraction, which could be reasonably approximated with a second order fit:
OriKLcurve_2nd.png

However even after subtracting this curve the spectrum was still not as good as I would like to see:
OrionKL_020624_2ndorder.png

For comparison here is a spectrum taken under much better conditions last winter (low humidity and stable temperature). As you can see there are some stronger narrow spikes but also some broader, weaker features between 0- 10 km/s and 15-20 km/s, which are actually composed of numerous weak maser features. 
OrionKL_260124.png

Today I tried a 5th order polynomial fit on the data from June 2 to see if I could get a result that is closer to the spectrum from last winter shown above. As you can see the spectrum is a lot flatter but it is also a bit overcorrected. The broader features are mostly lost and instead there appears to be an absorbtion feature at 8- 15 km/s, which does not really exist! I think it is just the gap between the two broad emission features in the spectrum. 
OriKLcurve_5th.png
OrionKL_020624_5thorder.png

Anyway, I think the lesson here is that while polynomials could be useful for spectral data processing, one has to be careful with applying higher (>2nd) order polynomials to weak signals in noisy data since that could easily introduce artifacts. 

Eduard. 

Alex P

unread,
Jun 18, 2024, 8:37:06 AMJun 18
to Society of Amateur Radio Astronomers
Nicely Done

Another idea, wait a few months till the area of interest is in a more linear part of the LSR correction curve LSR_linear.jpg

Marcus D. Leech

unread,
Jun 18, 2024, 9:33:18 AMJun 18
to sara...@googlegroups.com
I have also experimented with fitting polynomials to the baseline, and had, as you had, mixed results. 


b alex pettit jr

unread,
Jun 18, 2024, 10:04:58 AMJun 18
to sara...@googlegroups.com
High order polynomial curve fit solutions can be Amusing..
They can also be well behaved and Correct.

This is a 6th order Matlab polyfit of LSR correction data calculated at 1/2hr intervals ( Blue Circles ) vs the polyfit solution ( Orange Line )

The 1/2 hr interval data was from a Matlab routine provided by F1EHN and compares with this calculator

===================================================================================

( the X axis is scaled in acquisition samples per day )
Inline image

Alex





Nathan Towne

unread,
Jun 18, 2024, 10:53:23 AMJun 18
to Alex P
A suggestion is to exclude the two sharp peaks near the bottom of the curve as the outliers that they are - they are not background.  This will improve the fit of a second-order polynomial to the background at least a little.

-- 
  Nathan Towne


On Tue, Jun 18, 2024, at 6:24 AM, Eduard Mol wrote:
Hi all,

During last Sunday's Drake's Lounge there was some discussion about bandpass correction and polynomial fitting. For those of you who have not followed Drake's Lounge here is a bit of context.
When trying to do spectroscopy on faint and difficult targets (e.g. other galaxies in HI, masers...) the signal is often completely obscured by the uneven bandpass shape of the SDR receiver/ radio telescope system. Proper background subtraction to get a good flat spectrum is really the key to success for such observations. Typically, we take on-target spectra and an equal number of off-target spectra (with the telescope pointed away from the target), then subtract or divide the off-target spectra from the on-target "dark" spectra. This way we (hopefully) get rid of the system response leaving only the faint spectral signal of the target. Unfortunately, it is common that the bandpass shape slightly changes during recording due to factors like temperature variation, leaving a residual slope in the spectrum after background subtraction. This is especially problematic with long observation runs, which are needed to detect the faintest targets. If you are lucky it is a straight slope that can simply be removed by fitting a line, but sometimes the curve is more complex and a (higher order) polynomial may be needed. However, that comes with its own problems.

During the Drake's Lounge I showed an example of this effect in a recent ~2 hour long recording of Orion KL at the 22.2GHz water line. Due to variations in temperature, atmospheric moisture etc there was a strong residual curve in the spectrum after background subtraction, which could be reasonably approximated with a second order fit:
OriKLcurve_2nd.png

However even after subtracting this curve the spectrum was still not as good as I would like to see:


For comparison here is a spectrum taken under much better conditions last winter (low humidity and stable temperature). As you can see there are some stronger narrow spikes but also some broader, weaker features between 0- 10 km/s and 15-20 km/s, which are actually composed of numerous weak maser features. 


Today I tried a 5th order polynomial fit on the data from June 2 to see if I could get a result that is closer to the spectrum from last winter shown above. As you can see the spectrum is a lot flatter but it is also a bit overcorrected. The broader features are mostly lost and instead there appears to be an absorbtion feature at 8- 15 km/s, which does not really exist! I think it is just the gap between the two broad emission features in the spectrum. 



Anyway, I think the lesson here is that while polynomials could be useful for spectral data processing, one has to be careful with applying higher (>2nd) order polynomials to weak signals in noisy data since that could easily introduce artifacts. 

Eduard. 


--
--
You received this message because you are subscribed to the Google
Groups "Society of Amateur Radio Astronomers" group.
To post to this group, send email to sara...@googlegroups.com
To unsubscribe from this group, send email to
For more options, visit this group at
---
You received this message because you are subscribed to the Google Groups "Society of Amateur Radio Astronomers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sara-list+...@googlegroups.com.

Eduard Mol

unread,
Jun 18, 2024, 11:29:00 AMJun 18
to sara...@googlegroups.com
Yes, in fact I excluded the strongest peak. It’s in the window marked by the green dots. I’d have to go back and adjust my code to exclude more than one peak, but I’d expect it would only marginally improve the fit.

Op di 18 jun 2024 om 16:53 schreef Nathan Towne <tow...@ownmail.net>

Dimitry UA3AVR

unread,
Jun 20, 2024, 4:02:49 AMJun 20
to Society of Amateur Radio Astronomers
Yes, Eduard ... this is a good alternative to the traditional way of the background correction with integrating off-target spectra. At least, the polynomial fitting do not bring an excessive noise to the spectrum besides other advantages.

вторник, 18 июня 2024 г. в 18:29:00 UTC+3, Eduard Mol:

Eduard Mol

unread,
Jun 20, 2024, 10:08:24 AMJun 20
to sara...@googlegroups.com
Hi Dimitry, I think it depends on the situation and the equipment whether or not polynomial fitting works well. 
So far I have been using just background subtraction using off-target spectra, although this contributes some noise this technique has so far given me the most consistent results with my setup. 

At the Dwingeloo telescope we use a sort of hybrid approach, fitting a polynomial through the off-target spectra and then subtracting that curve from the on- target spectra, instead of subtracting off- target from on-target spectra directly.
I have also experimented with applying a moving average filter (for example 5 point or 7 point moving average) to the off-target spectrum to reduce the noise contribution. So far I’ve only noticed a marginal improvement in SNR.

Best regards,
Eduard

Op do 20 jun 2024 om 10:02 schreef Dimitry UA3AVR <ua3avr...@gmail.com>

fasleitung3

unread,
Jun 20, 2024, 12:33:01 PMJun 20
to sara...@googlegroups.com
Am Donnerstag, den 20.06.2024, 16:08 +0200 schrieb Eduard Mol:

At the Dwingeloo telescope we use a sort of hybrid approach, fitting a polynomial through the off-target spectra and then subtracting that curve from the on- target spectra, instead of subtracting off- target from on-target spectra directly.
I have also experimented with applying a moving average filter (for example 5 point or 7 point moving average) to the off-target spectrum to reduce the noise contribution. So far I’ve only noticed a marginal improvement in SNR.


This is the scheme we also use as standard. This avoids adding noise to the spectrum.
Wolfgang

Dimitry UA3AVR

unread,
Jun 24, 2024, 4:50:54 AM (11 days ago) Jun 24
to Society of Amateur Radio Astronomers
I have applied this scheme for recent 6.7 GHz observations. Here the plot with correction by raw off-target background:
2024-06-22_av260_3650s_BW1,5MHz_FFTsise401x50000_utc11-25_small.jpg

... and when the off-target background is fitted by 5th order polynomial:
2024-06-22_av260_3650s_BW1,5MHz_FFTsise401x50000_utc11-25_(background_polinomial-smoothed_5th-order)_SEFD=95000_small.jpg

The integration time for the off-tagret background and the source was the same; so expected difference in the noise floor is about sqrt(2)=1.41... times.

четверг, 20 июня 2024 г. в 19:33:01 UTC+3, fasleitung3:

b alex pettit jr

unread,
Jun 24, 2024, 6:13:03 AM (11 days ago) Jun 24
to sara...@googlegroups.com
Dimitry,
Can you plot the Correction Curve alone ?

Thanks,
Alex
==================================

On Monday, June 24, 2024 at 04:51:03 AM EDT, Dimitry UA3AVR <ua3avr...@gmail.com> wrote:


I have applied this scheme for recent 6.7 GHz observations. Here the plot with correction by raw off-target background:

... and when the off-target background is fitted by 5th order polynomial:
The integration time for the off-tagret background and the source was the same; so expected difference in the noise floor is about sqrt(2)=1.41... times.

Dimitry UA3AVR

unread,
Jun 24, 2024, 7:04:07 AM (11 days ago) Jun 24
to Society of Amateur Radio Astronomers
Sure, Alex, thanks ...

The form of frequency response of my receiver is significantly uneven in a full SDR bandwidth and bell shaped:
background_bell_shaped_small.jpg

The scale is too large to see differences in raw and smoothed background, but with some zoom of the central part the difference can be seen:
background_raw&smoothed_small.jpg
Center part of the bell (with anomaly fall due to DC suppressing in SDR) and edge slopes are excluded from the fit.

понедельник, 24 июня 2024 г. в 13:13:03 UTC+3, b alex pettit jr:

andrew....@googlemail.com

unread,
Jun 26, 2024, 4:57:01 PM (8 days ago) Jun 26
to sara...@googlegroups.com

b alex pettit jr

unread,
Jun 26, 2024, 5:16:12 PM (8 days ago) Jun 26
to andrew.thornett via Society of Amateur Radio Astronomers
Andy,

What are these plots showing ?
They do not look like H-Line spectra

Alex

Inline image


On Wednesday, June 26, 2024 at 04:57:04 PM EDT, andrew.thornett via Society of Amateur Radio Astronomers <sara...@googlegroups.com> wrote:


Hi Folks,

My map so far….

 Andy

--
--

andrew....@googlemail.com

unread,
Jun 27, 2024, 10:19:37 PM (7 days ago) Jun 27
to sara...@googlegroups.com, Ted Cline

I don’t really know – from ezRA suite – Ted, do you know?

Andy

--

--
You received this message because you are subscribed to the Google
Groups "Society of Amateur Radio Astronomers" group.
To post to this group, send email to sara...@googlegroups.com
To unsubscribe from this group, send email to
sara-list-...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sara-list?hl=en
---
You received this message because you are subscribed to the Google Groups "Society of Amateur Radio Astronomers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sara-list+...@googlegroups.com.

image001.png

tedcl...@gmail.com

unread,
Jun 28, 2024, 2:19:22 AM (7 days ago) Jun 28
to Society of Amateur Radio Astronomers

Wow, this is way off the original post topic.



"What are these plots showing ?"

To study the Galactic arms, one must collect spectrum data from many Galactic plane Longitudes.
One must try to "collect them all".
And better if many samples of each.

On the left is the ezRA software ezGal519 plot showing the number of Galactic plane samples collected, by their 1-degree Galactic Longitude.
Some Galactic Longitudes will be hard to collect from a northern hemisphere telescope location.
Something of a scorecard of current accomplishments.
The "ezGal511velGLonCount.txt" file is a text version of this scorecard, and includes text for an MIT Haystack SRT command file to automate the collecting of the missing Galactic Longitudes with a motored antenna.
I think the left side of this plot says you have collected 200 of the 361 possible 1-degree Galactic Longitudes.

On the right is the ezGal516 plot showing the average velocity collected, by their 1-degree Galactic Longitude.

Not shown is an ezGal517 plot showing the maximum velocity collected, by their 1-degree Galactic Longitude.
More interesting than the ezGal516 plot ?

Helpful ?

---
Ted Cline   N0RQV
tedclinegit at gmail.com

I posted updated ezRA files on June-16-2024.

For folks starting to explore radio astronomy,
      ezRA - Easy Radio Astronomy
      Free 1420 MHz Galactic hydrogen data collection and analysis
      Open source
      Windows and Linux
      https://github.com/tedcline/ezRA




On Wednesday, June 26, 2024 at 3:16:12 PM UTC-6 b alex pettit jr wrote:
Andy,

What are these plots showing ?
They do not look like H-Line spectra

Alex

Inline image


On Wednesday, June 26, 2024 at 04:57:04 PM EDT, andrew.thornett via Society of Amateur Radio Astronomers wrote:
 

fasleitung3

unread,
Jun 28, 2024, 11:28:01 AM (6 days ago) Jun 28
to sara...@googlegroups.com
Ted, Andy,
My understanding of Andy's recording is that he did drift scans. This would mean that for each scan he is covering 24 hrs of right ascension at one specific declination depending on the elevation of his telescope (and, of course, his location).
Expressing this in galactic corrdinates means that it covers a certain part of galactic longitudes and galactic latitudes. So this is not a scan of the galactic plane per se.
The plots of the individual spectra do not show the galacitc latitude (or am I missing something here?) of the location. It seens that it is assumed that the galactic latitude is 0, which in case it is not.
So I am a bit confused, maybe you can clarify.
Regards,
Wolfgang
--
--
You received this message because you are subscribed to the Google
Groups "Society of Amateur Radio Astronomers" group.
To post to this group, send email to sara...@googlegroups.com
To unsubscribe from this group, send email to
sara-list-...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sara-list?hl=en
---
You received this message because you are subscribed to the Google Groups "Society of Amateur Radio Astronomers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sara-list+...@googlegroups.com.

tedcl...@gmail.com

unread,
Jun 28, 2024, 1:22:42 PM (6 days ago) Jun 28
to Society of Amateur Radio Astronomers
Hi Wolfgang,
Once the data is collected, ezCon and ezGal can selectively focus on the data subset from different Galactic Latitudes with the   ezConGalCrossingGLatCenter   parameters, but the default is Galactic Latitude zero, the plane of the Milky Way.
I see "P00.0" in the filename at the top left of those plots, which says the mentioned  ezGal516, ezGal517, and ezGal519 plots are from that default focus on Galactic Latitude zero.  The default   ezConGalCrossingGLatNear   value is a wide 5 degrees.  So I expect the focused data subset is the samples from Galactic Latitude  -5 to +5 degrees.

Much of the ezRA analysis is to help study and improve the data set.

---
Ted Cline   N0RQV
tedclinegit at gmail.com


fasleitung3

unread,
Jun 29, 2024, 6:54:57 AM (6 days ago) Jun 29
to sara...@googlegroups.com
Thanks for the clarification. So it picks the spectra which are from positions close to the galactic plane from the total dataset.
Cheers,
Wolfgang
Reply all
Reply to author
Forward
0 new messages