Spectralindex

From CASA Guides
Revision as of 15:11, 14 March 2012 by Thunter (talk | contribs)
Jump to navigationJump to search

Return to Analysis Utilities

This page documents the spectralindex function of the linfit class in the Python module analysisUtils.

This function is designed to fit a power-law spectral index to the results output from casa's fluxscale task (using scipy.optimize.leastsq). Currently, it also requires a listobs-generated ascii file as the first argument in order to determine the center frequencies of each spectral window. (To avoid the need for this file in the future, we have submitted an improvement request for fluxscale to also print these frequencies.) It runs a brief Monte-Carlo series of fits to determine the uncertainty on the fitted slope on the basis of the error bars on each flux density. Finally, it produces a plot summarizing the results. By default, it will use all spectral windows, but it will exclude those with an "INSUFFICIENT DATA" status from fluxscale (which can arise in high-frequency EVLA data if you have not split off the pointing spws). Note: spectralIndex is a camel-caps synonym for spectralindex.

Usage:

au.linfit().spectralindex(filename, yfilename, source="", verbose=False, maxpoints=0, trials=2000, spw="", help=False, plotdir=, labelspw=False, referenceFrame='TOPO')

   filename: contains a listobs output file
   yfilename: contains a fluxscale output file
   source: sourcename to choose from the (possibly) multi-source fluxscale file
   maxpoints: the maximum number of spws to select for the fit starting from the first one (0=no max)
   trials: number of Monte-Carlo fits to run to estimate the fit uncertainties
   spw: the spws to use, e.g. ""=all, "1~3,5,6~8"=[1,2,3,5,6,7,8]
   plotdir: the directory in which to write the plotfile (in case you don't have permission in the pwd)
   labelspw: draw spw numeric labels adjacent to each point
   referenceFrame: the frequency reference frame, if not 'TOPO'
 

Examples

# In CASA
au.linfit().spectralIndex('listobs.txt','fluxscale_d2_new.txt','J19')
Read 16 x values for J1924-2914 (avg=44125.000)
Read 16 y values for J1924-2914 (avg=13.359)
Completed 2000 Monte-Carlo error trials to estimate the standard deviation of the fitted parameters.
Error-weighted fit: Slope: -0.503+-0.088  Flux D. @ 42802.00MHz: 13.563+-2.569
   Un-weighted fit: Slope: -0.498         Flux D. @ 42802.00MHz: 13.561
Plot saved in fluxscale_d2_new.txt.J1924-2914.png

File formats

The listobs file should look like this. It is keying off the string "TOPO", so there can be any number of leading comment characters on each line, and any number of unrelated lines of text at the top.

 SpwID  #Chans Frame Ch1(MHz)    ChanWid(kHz)  TotBW(kHz)  Corrs
  0         128 TOPO  42738       1000          128000      RR  LL
  1         128 TOPO  42866       1000          128000      RR  LL
  2         128 TOPO  42994       1000          128000      RR  LL
  3         128 TOPO  43122       1000          128000      RR  LL
  4         128 TOPO  43250       1000          128000      RR  LL
  5         128 TOPO  43378       1000          128000      RR  LL
  6         128 TOPO  43506       1000          128000      RR  LL
  7         128 TOPO  43634       1000          128000      RR  LL
  8         128 TOPO  44488       1000          128000      RR  LL
  9         128 TOPO  44616       1000          128000      RR  LL
  10        128 TOPO  44744       1000          128000      RR  LL
  11        128 TOPO  44872       1000          128000      RR  LL
  12        128 TOPO  45000       1000          128000      RR  LL
  13        128 TOPO  45128       1000          128000      RR  LL
  14        128 TOPO  45256       1000          128000      RR  LL
  15        128 TOPO  45384       1000          128000      RR  LL

Similarly, the fluxscale file should look like this. It can contain the results for multiple sources. It is keying off of the string 'SpW', so there can be any number of leading comment characters on each line, and any number of unrelated lines of text at the top.

# Opening MS: 10C186_B_Q_d1_3s.ms for calibration.
# Found reference field(s): J1331+3030
# Found transfer field(s):  J1717-3342 J1924-2914
# Flux density for J1717 3342 in SpW=0 is: 2.33891 ± 0.0620232 (SNR = 37.7102, N= 44)
# Flux density for J1717-3342 in SpW=1 is: 2.33168 ± 0.0608224 (SNR = 38.3358, N= 44)
# Flux density for J1717-3342 in SpW=2 is: 2.33139 ± 0.0642111 (SNR = 36.3082, N= 44)
# Flux density for J1717-3342 in SpW=3 is: 2.33639 ± 0.0697579 (SNR = 33.4929, N= 44)
# Flux density for J1717-3342 in SpW=4 is: 2.31025 ± 0.0631668 (SNR = 36.5738, N= 44)
# Flux density for J1717-3342 in SpW=5 is: 2.32929 ± 0.0667446 (SNR = 34.8986, N= 44)
# Flux density for J1717-3342 in SpW=6 is: 2.35698 ± 0.0698231 (SNR = 33.7564, N= 44)
# Flux density for J1717-3342 in SpW=7 is: 2.32728 ± 0.0668059 (SNR = 34.8364, N= 44)
# Flux density for J1717-3342 in SpW=8 is: 2.23395 ± 0.0394774 (SNR = 56.588, N= 46)
# Flux density for J1717-3342 in SpW=9 is: 2.23898 ± 0.0404523 (SNR = 55.3487, N= 46)
# Flux density for J1717-3342 in SpW=10 is: 2.20212 ± 0.0408321 (SNR = 53.9311, N= 46)
# Flux density for J1717-3342 in SpW=11 is: 2.18275 ± 0.0392774 (SNR = 55.5727, N= 46)
# Flux density for J1717-3342 in SpW=12 is: 2.17859 ± 0.0388576 (SNR = 56.0659, N= 46)
# Flux density for J1717-3342 in SpW=13 is: 2.16182 ± 0.0405544 (SNR = 53.3066, N= 46)
# Flux density for J1717-3342 in SpW=14 is: 2.16303 ± 0.0413542 (SNR = 52.305, N= 46)
# Flux density for J1717-3342 in SpW=15 is: 2.19681 ± 0.0400311 (SNR = 54.8777, N= 46)
# Flux density for J1924-2914 in SpW=0 is: 14.6731 ± 0.138529 (SNR = 105.921, N= 44)
# Flux density for J1924-2914 in SpW=1 is: 14.5996 ± 0.136761 (SNR = 106.753, N= 44)
# Flux density for J1924-2914 in SpW=2 is: 14.6242 ± 0.146673 (SNR = 99.7061, N= 44)
# Flux density for J1924-2914 in SpW=3 is: 14.6802 ± 0.158394 (SNR = 92.6816, N= 44)
# Flux density for J1924-2914 in SpW=4 is: 14.5259 ± 0.141069 (SNR = 102.97, N= 44)
# Flux density for J1924-2914 in SpW=5 is: 14.6075 ± 0.151812 (SNR = 96.2206, N= 44)
# Flux density for J1924-2914 in SpW=6 is: 14.7261 ± 0.157892 (SNR = 93.2666, N= 44)
# Flux density for J1924-2914 in SpW=7 is: 14.5783 ± 0.14938 (SNR = 97.5919, N= 44)
# Flux density for J1924-2914 in SpW=8 is: 13.9264 ± 0.0748849 (SNR = 185.971, N= 46)
# Flux density for J1924-2914 in SpW=9 is: 13.9368 ± 0.0751502 (SNR = 185.452, N= 46)
# Flux density for J1924-2914 in SpW=10 is: 13.7826 ± 0.0785357 (SNR = 175.494, N= 46)
# Flux density for J1924-2914 in SpW=11 is: 13.7178 ± 0.0778214 (SNR = 176.273, N= 46)
# Flux density for J1924-2914 in SpW=12 is: 13.6833 ± 0.0748109 (SNR = 182.905, N= 46)
# Flux density for J1924-2914 in SpW=13 is: 13.6308 ± 0.0772038 (SNR = 176.555, N= 46)
# Flux density for J1924-2914 in SpW=14 is: 13.6372 ± 0.0792322 (SNR = 172.117, N= 46)
# Flux density for J1924-2914 in SpW=15 is: 13.7463 ± 0.0735882 (SNR = 186.8, N= 46)