If you already have your SD data in MS format, you can operate on that data as follows. Here is an example to fit 3rd order polynomials to spectra stored in the FLOAT_DATA column with field='M100' and with spw=5 and 7, subtract it, then save the residual spectra into another file:


sdms.set_selection(field='M100', spw='5,7')

sdms.subtract_baseline(order=3, datacolumn='float_data', outfile='bar.ms')


When importing SD data from other data formats than MS, you need not to invoke sdms.open() and sdms.close(). Just do as follows:

sdms.importnro(infile='foo.Y', outfile='bar.ms')      # import from NOSTAR format


sdms.importasap(infile='foo.asap', outfile='baz.ms')  # import from Scantable

Once you get your data in MS, you can process it like the code sample at the top of this page.