# Introduction

This is a short tutorial on how to use ASAP for simple on of dual IF observations. It is highly customisable via ".aipsrc" parameters. It can read rpfits,sdfits and measurement sets, and export to sdfits, ms, ASCII and image fits. ASAP provides a lot more functionality, such as frequency alignment, averaging which can't be presented here.

# Part I - Reduction

To start ASAP type the follwing at the *nix command line prompt

    localhost> asap

To get the list of available commands in asap type:

    commands()

Help can be accessed by using help:

    help(scantable)
    help(scantable.summary)

To start we are reading in the data into a scantable, which can be accessed via th variable s. After reading in we have a look at the data.

    s = scantable("2005-05-08_0350.rpf")
    s.summary()

We can plot the scan now. First we set up the plotter to plot "IF" as stcked colours and "time" across panels. Then we issue th plot command.

    plotter.set_mode("IF","time")
    plotter.plot(s) # plot s

Now we can build the quotient. This applies the quotient to both IFs.

    q = auto_quotient()
    plotter.plot(q) # plot q

Now we can set some information anbout the velocity setup. We set the rest frequencies for 13Co and SiO and want to operate in "LSRK".

    restfreqs = [110.201,86.243]     # 13CO-1/0, SiO the two IF
    q.set_restfreqs(restfreqs,"GHz") # set the restfrequencies, as not in data
    q.set_unit("km/s")               # set the unit to be used from now on
    q.set_freqframe("LSRK")          # set frequency frame
    plotter.plot()                   # replot, should show velocity now

Now we can subtract a baseline. ASAP can do this automatically if ther is good S/N and the lines aren't too broad.

    q.auto_poly_baseline() # determine and subtract a poly baseline automatically
    plotter.plot() # replot

We can zoom in on the spectrum and format the title and legend. ASAP accepts LATEX math expressions.

    plotter.set_range(-35,35)                                  # zoom in  bit
    plotter.set_legend([r"$^{13}CO(1\leftarrow 0)$",r"$SiO$"]) # make nice latex IF labels
    plotter.set_title(['Mopra Tutorial 2005'])                 # set the title

Now convert Brightness temperature to Flux density.

    q.convert_flux() # K -> Jy
    plotter.plot()

This "final" plot can be saved now as "png", "ps" or "eps"

    plotter.save("tutorial.png")
    plotter.save("tutorial.eps")

We can also do some stats on the spectra. We select a line free region first, which get applied to the statistics.

    msk = q.create_mask([-70,20], [20,70]) # line free region - two windows
    rms = q.stats("rms",msk)
    med = q.stats("median",msk)

# Part II - Fitting

This part shows how easy it is to fit gaussian line profiles.

    f = fitter()

We start with the first spectrum (IF=0) bys setting the selection. We want to fit two gaussian components.

    sel = selector()
    sel.set_ifs(0)
    q.set_selection(sel)
    f.set_scan(q)
    f.set_function(gauss=2) # fit two gaussians
    f.fit()
    f.plot(

The second IFs spectrum is more complex. We select it and fit seven gaussians to it. Here we also plot residuals, the individual components and the fit parameters.

    sel.set_ifs(1)
    q.set_selection(sel)
    f.set_function(gauss=7)
    f.fit()
    f.plot(residual=True)
    f.plot(components=[0,1,2,3,4,5,6,-1])
    f.plot(components=[0,1,2,3,4,5,6,-1],plotparms=True)

# Appendix

More info can be found on the ASAP homepage http://www.atnf.csiro.au/computing/software/asap