3. PolData class - HeloiseS/FUSS GitHub Wiki

This class is used to handle linear spectropolarimetric data, facilitate isp removal and q-u plot making.

Initialisation

PolData('name', data , *args)

Parameters

  • data (string or Array): If string is given: name of the file containing the polarisation data. Same format as the files output by lin_specpol. If array is given, should contain 9 columns containing the following values (in the following order): wavelength bins, p, Δp, q, Δq, u, Δu,θ, Δθ.
  • name (string, optional): Name of the data set
  • wlmin (int/float, optional): Minimum wavelength cutoff. Default = None
  • wlmax (int/float, optional): Maximum wavelength cutoff. Default = None

Attributes

Core

The core parameters are given a value at initialisation:

  • name: The name given at initialisation
  • wlp: Wavelength bins of the polarisation data
  • p: degree of polarisation p
  • pr: Δp
  • q: Stokes q
  • qr: Δq
  • u: Stokes u
  • ur: Δu
  • a: θ
  • ar: Δθ

Optional

  • wlf: Wavelength bins of the flux data
  • f: Flux
  • fr: ΔFLux
  • qisp, qispr, uisp, uispr, aisp, aispr: Stokes parameters and P.A of ISP
  • p0, p0r, q0, ... , a0r : Original polarisation data before ISP correction. Defined when ISP is removed and p, pr, ..., ar are updated.

Methods

Adding Flux data

Because spectropolarimetric data is often used in conjunction with spectroscopic data, and instance of PolDatacan also hold the unpolarised flux (Stokes I) information.

add_flux_data('filename', *args)

Parameters

  • filename (string): Name of the file containing the flux data. Same format as the files output by lin_specpol.
  • wlmin (int/float, optional): Minimum wavelength cutoff. Default = None
  • wlmax (int/float, optional): Maximum wavelength cutoff. Default = 100000
  • err (boolean, optional): If there is a column for error in the input file, set to True . Default = False , wlmin = None, wlmax = 1000000, err = False):

Initialises wlf, f and fr (the wavelength bins of the flux spectrum, the flux spectrum and the errors on the flux).

Interstellar Polarisation (ISP)

find_isp(wlmin, wlmax)

One way to find the ISP from the spectropolarimetric data is to assume complete intrinsic depolarisation within a wavelength range [wlmin, wlmax] - e.g due to line blanketting.

Parameters

  • wlmin (int/float): Minimum wavelength cutoff.
  • wlmax (int/float): Maximum wavelength cutoff.

Initialises qisp, qispr, uisp and uispr (i.e the Stokes parameters of the ISP and their errors)

add_isp(constisp_params, linearisp_params)

If the ISP is known, this allows to initialise the ISP attributes.

Parameters

  • constisp_params (Array, optional): If the ISP is constant, provide its Stokes parameters here in an array of the form: [qisp, qisp error, uisp , uisp error]. Default is None.
  • linear_params (Array, optional): If the ISP changes linearly with wavelength, give the parameters of the linear dependency of q and u here. If qisp = grad_q * lambda + intercept_q (and similar equation for u) write: linearisp_params = [ [grad_q, grad_q error], [intercept_q, intercept_q error], [grad_u, grad_u error],[intercept_u, intercept_u error] ]. Default is None.

rmv_isp()

Removes the ISP from the polarisation data. Updates p, pr, q, qr, u, ur, a and ar with ISP corrected values. Initialises p0, p0r, q0, ... a0r, which contain the original non-ISP corrected polarisation data.

Plotting

flu_n_pol(*warg)

This plots p, q, u, &#952, and the flux. If the flux information has not been provided the plots will still be created (but the subplot corresponding to the flux spectrum will be empty).

Parameters

  • save (boolean, optional): If True the plots will be saved as [name*]_fnp.png. Default is False.

*Here [name] is the name attribute given to the instance of PolData at initialisation.

qu_plt(*args)

Before using the following methods it is good to pre-define a figure in matplotlib (e.g f = plt.figure (figsize = (12,10)). One can also use GridSpec (e.g gs1 = gridspec.GridSpec(2,2)). Also you must call plt.show() after using the following methods as, although they create the plots, they do not show them automatically (maybe should add an option to do that...).

qu_plt() returns the axis it is plotting on so that you can use that outside of the QUplot instance if you want to add something to the q − u plot.

Side note: Even when using hspace = 0 or wspace = 0, the size of the graph has a strong influence on how much space there will be between the pot, it is just a matter of fine tuning.

Parameters

  • subplot_loc (_ - , optional_): 3 digit int representing subplot location or, if using GridSpec, gridspec located (e.g gs1[0]). Default = 111.
  • wlmin (int/float, optional): Minimum wavelength cutoff. Default = None
  • wlmax (int/float, optional): Maximum wavelength cutoff. Default = 100000
  • qlim (array, optional): Limits of the q axis. Default = [-3, 3]
  • ulim (array, optional): Limits of the u axis. Default = [-3, 3]
  • textloc (array, optional): Location of the name (which is given by the name attribute of the instance of PolData). Default = [-2.7, 2.7]
  • cisp (string, optional): Colour of the ISP marker. Default = 'k'
  • fs (int, optional): Fontsize of the axis labels. Default = 16.
  • ls (int, optional): Tick label size (i.e size of the numbers on the axes). Default = 14.
  • isp (boolean, optional): Whether to plot ISP or not. If True, qisp, qispr, uisp and uispr must have been initialised. Default = False.
  • colorbar (boolean, optional): Whether to plot the colorbar. Default is True.
  • colorbar_labelsize (boolean, optional): Size of the colorbar labels. Default is 15.
  • wlrest (_int, optional): Rest wavelength of spectral feature of interest. Will change the colour scale from wavelength to velocity. Default is None.
  • size_clbar (float, optional): Changes the size of the colorbar. Oddly enough seems to sometimes change the size of the plot too??. Default = 0.05
  • line_color (string, optional): Makes the lines between the markers the chosen color. The color codes are the same as in matplotlib. Default makes lines cycle through rainbow colors to match the color of the point they are associated with.
  • marker (string, optional): Type of marker to be used (same codes as matplotlib). Default = '.'
  • lambda_xshift (float, optional): To help the placement of the colorbar label. The x position of the label will be qmax + lambda xshift, where qmax is the upper limit given by qlim. Default = 1.7
  • fit (boolean, optional): Whether to plot the dominant axis fit to the data or not. The fit wil always be calculated and the best values returned even if fit is False. Default = True
  • qlab_vis (boolean, optional): Whether to make the q axis label visible. Default = True
  • ulab_vis (boolean, optional): Whether to make the u axis label visible. Default = True
  • qticks_vis (boolean, optional): Whether to make the q ticks labels visible. Default = True
  • uticks_vis (boolean, optional): Whether to make the u ticks labels visible. Default = True

Return

  • The Axis the plot is being plotted on.