SMA Quick Links
DR home
Convert format
Using CASA
Tutorials
FAQs

SMA Polarization Data Calibration with MIR/IDL


WARNING: Parameters used assume the data have been rebinned by a factor of 4. Values for ntrim, preavg, and smoothing should be scaled by any rebin factor.

(1) Open MIR/IDL

$ idl

(2) Read the data into MIR

SWARM operates in dual receiver polarization mode where two receivers with orthogonal linear polarizations can be tuned to the same frequency. In this mode, 1/4 wavelplates are inserted into the optical path in order to measure both righthand- and lefthand-circular polarization on the sky . These plates are rotated in frequnecy in order to measure all 4 combinations. Hence each scan from the correlator contains one of the 4 possible combinations - RR, RL, LR, or LL - on each baseline.

Because both receivers are critical to the processing, the full dataset must be read into MIR. This is in contrast to regaular data processing where it may be advisable to process a single receiver at a time to save on memory requirements.

IDL> readdata,dir='mir_pol_bin4'

View a summary of the data.

IDL> select

By convention, when the 1/4 waveplates are not all in the same oreintation, the source name is appended by the combination (e.g. 3c279_LR).

(3) Flag pointing data

Pointing data will have an integration time < 6 seconds. It used to be sufficient to select scans that were shorter than this using dat_filter and then flag them.

IDL> result=dat_filter(s_f,'"integ" lt "6"',/reset)
IDL> flag, /flag

Since mid 2019, the potential science scan length has been considerably shortened, meaning it is not reliable to blindly flag the pointing scans in newer data based on scan length. Instead a pointing flag has been implemented, and dat_filter can be used like so.

IDL> result=dat_filter(s_f,'"pointing" lt "1"',/reset)
IDL> flag, /flag

If you are unsure, try flagging by pointing option first. If this does not return any results examine your data to see if any pointings need flagging and what the scan lengths are.

Afterwards, you must re-select only the positive weighted (unflagged data). Some scans will have been flagged during the observation (e.g. while the antennas are switching sources) so this will exclude them also.

IDL> select,/pos,/res

(4) Inspect the data visually

Plot the pseudo-continuum channel [1]. This is an average of the spectral channels across all baselines for each point. Its designation is 'c1'.

IDL> plot_continuum, color='pol' [1]

You can also plot the spectral data [2]. Here the noisy edges of the chunks have been trimmed. It is normal to trim 8-10% of the data. For full SWARM resolution of 16384 channels per chunk, 8% is ~1300 channels. As this data has been rechunked by a factor of 4, ntrim is set to 320 (or ~8% of 4096 channels). Note that for x='channel' the units of ntrim are channel number, while for x='fsky' the units are MHz.

IDL> plot_spectra,color='band',ntrim=320 [2]

The option color='band' makes each chunk a different color. The plots are shown source-by-source so right-click to scroll through them all. You can see any frequency spikes and remove them in the next step.

(5) Check for spikes

The MIR task, uti_checkspike, will identify and optionally fix spikes in the frequency data. Alternatively, this can be done manually which is more labor intensive but may be faster.

This example runs a couple of loops of uti_checkspike, then manually removes a remaining spike.

For uti_checkspike a source must be specified. This source will be used as a template to identify the spike positions. As such, choose a source like a gain calibrator quasar, or the bandpass calibrator, which has a flat spectral signature.

IDL> uti_checkspike,source='3c84',ntrim=320,/fix

The /fix option applies the corrections for each spike identified. When a channel is flagged, it is flagged for all sources. By default the spectra are averaged over all baselines, but the option /baseline finds the spikes in each baseline independently. Be warned the /baseline option takes a long time to complete, and with the very high resolution of SWARM it is often not necessary to worry about losing the occasional channel. Another option is threshold; this is the rms threshold above which a spike is identified. This is 10 by default by can be changed using threshold=X.

Checking the spectral plots again show some spikes remaining [3].

IDL> plot_spectra,ntrim=320 [3][4]

Repeatedly run uti_checkspike so it iterates down [4]. The default threshold over which emission qualifies as a spike is 10-sigma. This can be changed with the option threshold=x.


Some small spikes remain which can be fixed by hand. First you must select the chunk in which the spike falls; in this case chunk s3. This must be done to ensure it plots the correct channel numbers on the x-axis.

IDL> select,/p,/re,band='s3',sideband='l'
IDL> plot_spectra,ntrim=320
[5]

By repeatedly zooming in on the first panel (left-click on the panel, then left-click on ether side of the area to be enlarged), the channel containing the spike can be identified as 991 [5]. Right-click to exit from the enlarged view.

Then apply the fix.

IDL> uti_chanfix, chan=991

By default, uti_chanfix replaces the value of the given channel with an average of the adjacent 3rd channel on each side. You can select which channels will be used to produce the average with the option 'sample'. If a spike is a few channels wide for example, using sample=10 will use the 10th channel on either side for an average. The 'sample' option can also be used with /fix for uti_checkspike.

(6) Apply the system temperature correction

View the system temperature. Check the points and profile for outliers.

IDL> plot_var [6]

The scaling of the plot is thrown off by some outliers [6]. Here there was a problem recording the Tsys - the data itself are unaffected. Check underlying causes by looking at the observing report to see if any issues were reported.

To re-scale the y-axis select data with the range of Tsys to be plotted (here <1000K); then plot that subset [7]. Now points that are offset from the standard curve become visible. Remember to re-select all the data afterwards.

IDL> result=dat_filter(s_f, ' "tssb" gt "1000" and "wt" gt "0"',/reset)
IDL> plot_var
[7]
IDL> select,/pos,/re

All these points can be fixed using the MIR task uti_tsys_fix. This refits the Tsys for points below 'high=X', and above 'low=Y'. It then replaces any points that differ from the re-fitted curve by more than 'loose=Z'.

IDL> uti_tsys_fix, high=500,loose=100,/refit

Checking the result shows a few Uranus points which could not be fit to the curve.

In this case there is the option to replace the system temperature for the entire antenna with those from a different antenna - in this case replacing antenna 3 with 6.

IDL> tsys_ant
IDL> tsys_replace
     ;x=3
     ;y=6
IDL> tsys_bsl

With the system temperature plots looking normal the correction can be applied.

IDL> apply_tsys

Then regenerate the continuum channel.

IDL> uti_avgband

(7) Perform polarization bandpass calibration

At this step the reduction sequence for polarization data differs from regular SWARM data: note the use of 'pass_cal_pol' rather than simply 'pass_cal'.

This routine calculates the antenna-based bandpass solutions for 345x345 and 400x400. From this it derives the bandpass shapes for 345x400 and 400x345 and corrects all four receiver combinations.

For SWARM data use either no or minimal smoothing as there is a lot of detailed structure in the baseline. Note that the pass_cal_pol command treats each sideband (and receiver) independently.

IDL> pass_cal_pol,preavg=8, smoothing=1, ntrim=320, refant=4 [8]

At this stage there is the option to accept the sources it suggests or add/remove any. Usually the bandpass calibrator(s) is identified as such in the software (and listed as YES) but not always. Add or remove sources by typing 3C273 YES or 0449+113 NO.

Once it has generated a solution it will create a plot of the fits [8]. Right-click through the solutions for each baseline. After exiting the plot window it will prompt to apply the suggested solution to all other sources.

The routine pass_cal_pol applies antenna-based passband solutions, so an tel_bsl setting is ignored. It does however need a refant.

For polarization data the passband calibration is applied once, unlike regular data where the phase and amplitude calibrations are applied separately.

Note the ntrim and preavg values have been scaled to account for this data having been rebinned by 4. For unbinned data use 1300 and 32 respectively.

(8) Save the data

Select all unflagged data, regenerate the continuum and save in MIR format. It is important to save the dataset before starting flux measurement as the phases will be irreversibly disrupted.

IDL> select,/p,/re
IDL> uti_avgband
IDL> mir_save,'mir2018_rx240_pol.mir'

(9) Apply cross RX delay

After applying the passband solution the cross-receiver data (e.g. 345x400) and 400x345) still has delay and offsets between the chunks. These are corrected with the command uti_xdelay. You will need to supply a reference source - this will be one of the gain calibrators observed in a cross-polarization state.

IDL> uti_xdelay, reference='3c279_LR', preavg=4, smoothing=1, ntrim=320

(10) Apply gain calibration

The gain calibrator should have been observed in both parallel and orthogonal waveplate orientations (e.g. 3c279 and 3c279_LR). This allows the temporal phase drift of one receiver relative to the other to be tracked. The task gain_cal_pol perfomrs similar to pass_cal_pro in that it generates the gain calibration for the 345x345 and 400x400 receiver combinations, and from that derives the solutions for the cross-receiver combinations (e.g. 345x400 and 400x345).

IDL> gain_cal_pol, x='hours',refant=4,smoothing=0.3

After this step you can perform you usual flux calibration procedure.

(11) Dervive cross-rx gain

After applying the gain solutions above, the final step is to correct for the cross-receiver phase drift with time.

IDL> uti_xgain,x='hours',/preavg,smoothing=0.3,/connect

This is similar to gain_cal; it derives a vector-averaged gains solution which is applied to the cross-reeciver data.