The songlib module

The songlib module#

Additionnally to its power spectrum managing and peakbagging tools, apollinaire provides a reduction pipeline for data obtained with the Solar-SONG instrument (Grundahl et al. 2007, Pallé et al. 2016, Fredslund Andersen et al. 2019, Breton et al. in prep).

apollinaire.songlib.standard_correction(dir_velocity, dir_corrected, dir_flux_out=None, dir_long=None, dir_flux=None, clean_directories=False, iSONG=False, dt=20.0, pop_end=0, pop_beginning=0, save=False, correct=True, test=False, test_length=2, weighted=True, perf_lowess=False, remove_interval_manually=True, plot_flux=False, cut_rising=12000, sigma_box=[3.0, 2.5], size_neighborhood=50, sigma_neighborhood=[3.5, 3.0], sigma_global=[4.0, 3.0], scatter_min=3.0, scatter_max=1000.0, thresh=2, n_filtering=1, plot_final=False, plot_intermediate=False, plot_response=False, harmonics=False, s_comp=None, v_comp=None, origin=0, origin_comp=0)#

Read raw daily velocity files into their repertory, save corrected daily file and return the concatenated corrected series.

Parameters:
  • dir_velocity (string) – name of the repertory where to read velocity files (saved in text format if iSONG is True, in hdf5 otherwise)

  • dir_corrected (string) – name of the repertory where to write corrected velocity files

  • dir_long (string.) – name of the repertory where to write the concatenated series files if save set to True. Optional, default None.

  • dir_flux (string) – name of the repertory where to read flux files. Needs to be specified if iSONG is False. Optional, default None.

  • dir_flux_out (string) – name of the repertory where to write output flux files of plot_flux is set to True. Optional, default None.

  • clean_directories (bool) – if set to True, will clean the output directories before reducing any data. Optional, default False.

  • iSONG (bool) – set to True if the data to use are outputs (with chunks already integrated) from the iSONG pipeline. Optional, default False.

  • dt (float) – time sampling of the wanted corrected timeseries. Optional, default 20. Caution: 86400/dt must be an integer.

  • pop_beginning (int) – number of daily files to remove at the beginning of the list from the files read in dir_velocity.

  • pop_end (int) – number of daily files to remove at the end of the list from the files read in dir_velocity.

  • save (bool) – if set to True, the final corrected concatenated series will be saved in dir_long. Optional, default False.

  • correct (bool.) – if set to True, the full correction pipeline will be executed. If set to False, the function will only read preexisting daily files in dir_corrected and create the concatenated timeseries. Optional, default True.

  • test (bool) – if set to True, will only perform corrections on the first files to correct. The number of files to correct is given by test_length. Optional, default False.

  • test_length (int) – number of daily files to correct when test is set to True. Optional, default 2.

  • weighted (bool) – if set to True, the weighting process will be applied when integrating chunks. Not weighting the chunks will give an output result with a much more important level of noise. Optional, default True.

  • perf_lowess (bool.) – set to True to remove low frequency trends in the timeseries before flagging the outliers that will be removed by the neighborhood cleaning. Stay aware that the LOWESS process is not used to remove low-frequency trends in the timeseries. Optional, default False.

  • remove_interval_manually (bool) – if set to True, some pre-determined noisy interval will be set to 0 at the end of the correction process. Optional, default True.

  • plot_flux – if set to True flux arrays (only read if iSONG is True, integrated from chunks otherwise) will be saved in dir_flux_out in order to plot the concatenated final array with the concatenated timeseries.

  • plot_final (bool) – set to True to plot the full corrected timeseries at the end of the correction process Optional, default False.

  • plot_intermediate (bool) – For each daily series, plot velocity before reboxing steps and shows the outliers points that will be removed by the nighborhood cleaning. Optional, default False.

  • plot_response (bool) – if set to True, plot the response function of the high pass filter used. Optional, default False.

  • size_neighborhood (int) – number of box to use before and after considered box to flag local outliers. Default None.

  • sigma_neighborhood (array_like of size 2.) – sigma values used to remove outliers in the neighborhood defined by size_neighborhood. Optional, default [8, 6].

  • cut_rising – velocity values with corresponding flux values inferior to cut_rising will be removed. Optional, default 12000. Those values corresponds most of the time to measurements taken at the beginning of the day while the sun is rising.

  • sigma_box (array_like of size 2.) – the two successive sigma values to use to exclude outliers in each box. Optional, default [3, 2.5].

  • tresh – minimum number of non-zero values in a box. If the number of non-zero values in the box is below thresh, the whole box value will be linearly interpolated with its neighbors and the box will be flagged in the interpolation mask. Optional, default None.

  • sigma_global (array_like of size 2.) – sigma values used to remove outliers in the whole series. Optional, default [3.5, 3.].

  • scatter_min (float) – Chunks with scatter below this limit will not be used for the integration of global velocity value.

  • scatter_max (float) – Chunks with scatter below this limit will not be used for the integration of global velocity value.

  • n_filtering (int) – number of time the filter will be applied. Optional, default 1.

  • harmonics (bool) – if set to True, harmonics due to residual Earth rotation signal will be spotted by vertical lines.

  • s_comp (ndarray) – Julian day timestamps of the series to compare with. Optional, default None.

  • v_comp (ndarray) – 1d velocity vector of the series to compare with. Optional, default None.

  • origin (float) – origin to consider for the s time stamps. On the plot, the first point of the timeseries s, v will be represented at the abscisse s[0] - origin. Optional, default 0.

Origin_comp:

origin to consider for the s_comp time stamps. On the plot, the first point of the timeseries s_comp, v_comp will be represented at the abscisse s_comp[0] - origin_comp. Optional, default 0.

Returns:

timestamps and velocity vector of the final corrected and concatenated timeseries.

Return type:

tuple of ndarray