file_utils

class gwas_tools.utils.file_utils.YmlFile(yml_file=None)

Class for the yml output file.

Parameters:

yml_file (str, optional) – path to the yml file (default : None)

get_target_channel()

Target channel.

Returns:

target channel

Return type:

str

get_gps()

GPS time.

Returns:

GPS time

Return type:

int

get_seconds()

Duration of the analyzed period.

Returns:

duration of the analyzed period

Return type:

int

get_event_position()

Position of the event in the analyzed period.

Returns:

position of the event in the analyzed period

Return type:

str

get_sampling_frequency()

Sampling frequency.

Returns:

sampling frequency

Return type:

float

get_channels_list()

Channels list.

Returns:

path to channels list file

Return type:

str

get_output_path()

Output path.

Returns:

path to where output analysis was saved

Return type:

str

get_lowpass_frequency()

Lowpass frequency.

Returns:

lowpass frequency

Return type:

float

get_scattering_factor()

Scattering factor.

Returns:

scattering factor

Return type:

int

get_smoothing_window()

Smoothing window.

Returns:

smoothing window

Return type:

int

is_locked()

Lock info.

Returns:

lock info

Return type:

bool

get_imfs_count()

Get number of found imfs.

Returns:

number of found imfs

Return type:

int

get_channel_of_imf(imf, second_best=False)

Most correlated channel with imf imf.

Parameters:
  • imf (int) – imf number

  • second_best (bool) – if True, returns the value from the section for the second best culprit

Returns:

most correlated channel with imf imf

Return type:

str

get_corr_of_imf(imf, second_best=False)

Correlation of imf imf.

Parameters:
  • imf (int) – imf number

  • second_best (bool) – if True, returns the value from the section for the second best culprit

Returns:

correlation of imf imf

Return type:

float

get_mean_freq_of_imf(imf, second_best=False)

Mean frequency of imf imf.

Parameters:
  • imf (int) – imf number

  • second_best (bool) – if True, returns the value from the section for the second best culprit

Returns:

mean frequency of imf imf

Return type:

float

get_corr_of_combo_with_imf(imf)

Correlation of combo with imf imf.

Parameters:

imf (int) – imf number to be present in combo

Returns:

correlation of combo with imf imf

Return type:

float

get_channel_of_combo_with_imf(imf)

Most correlated channel with combo with imf imf.

Parameters:

imf (int) – imf number to be present in combo

Returns:

correlation of combo with imf imf

Return type:

float

write_parameters(gps, seconds, event, target_channel_name, channels_file, out_path, fs, f_lowpass, n_scattering, smooth_win)

Write parameters section to file.

Parameters:
  • gps (int) – gps time

  • seconds (int) – seconds analyzed

  • event (str) – position of gps in the analyzed period (start, center, or end)

  • target_channel_name (str) – target channel name

  • channels_file (str) – channels list file

  • out_path (str) – output path for results

  • fs (float) – sampling frequency

  • f_lowpass (float) – lowpass frequency

  • n_scattering (int) – scattered light bounces

  • smooth_win (int) – smoothing window

write_lock_info(locked)

Write lock info to file.

Parameters:

locked (bool) – if interferometers is locked

write_correlation_section(channels, corrs, mean_freqs)

Write correlation section to file.

Parameters:
  • channels (list[str]) – list of culprits for each imf

  • corrs (list[float]) – list of correlations for each imf

  • mean_freqs (list[float]) – list of mean frequencies for each imf

write_combo_section(imfs, channels, corrs)

Write combo section to file.

Parameters:
  • imfs (list[list[int]]) – list of imfs lists belonging to the same channel

  • channels (list[str]) – list of culprits for each combo

  • corrs (list[float]) – list of correlations for each combo

get_combos()

Get combos section.

write_seismic_channels(seismic_dict)

Write seismic channels values.

Parameters:

seismic_dict (dict) – seismic channels values (key : channel name, value : channel value)

get_seismic_channels()

Get seismic channels section.

write_2nd_best_correlation_section(channels, corrs, mean_freqs)

Write correlation section corresponding to the second best culprit of each imf to file.

Parameters:
  • channels (list[str]) – list of culprits for each imf

  • corrs (list[float]) – list of correlations for each imf

  • mean_freqs (list[float]) – list of mean frequencies for each imf

save(save_path)

Save file.

Parameters:

save_path (str) – path to the output file

gwas_tools.utils.file_utils.from_mat(mat_file, mat_col)

Get array from .mat file.

Parameters:
  • mat_file (str) – path to the .mat file

  • mat_col (int) – column of the array to get

Returns:

array from .mat

Return type:

numpy array

gwas_tools.utils.file_utils.yml_exists(yml_path)

Check if yml file exists.

Parameters:

yml_path (str) – path to yml file

Returns:

yml existence

Return type:

bool

gwas_tools.utils.file_utils.imfs_exists(imfs_path)

Check if imfs file exists.

Parameters:

imfs_path (str) – path to imfs file

Returns:

imfs existence

Return type:

bool

gwas_tools.utils.file_utils.predictors_exists(predictors_path)

Check if predictors file exists.

Parameters:

predictors_path (str) – path to predictors file

Returns:

predictors existence

Return type:

bool

gwas_tools.utils.file_utils.load_ias(ia_path)

Load imfs’ instantaneous amplitudes file.

Parameters:

ia_path (str) – path to imfs’ instantaneous amplitudes file

Returns:

imfs’ instantaneous amplitudes file

Return type:

numpy ndarray

gwas_tools.utils.file_utils.load_imfs(imfs_path)

Load imfs file.

Parameters:

imfs_path (str) – path to imfs file

Returns:

imfs file

Return type:

numpy ndarray

gwas_tools.utils.file_utils.load_predictors(predictors_path)

Load predictors file.

Parameters:

predictors_path (str) – path to predictors file

Returns:

predictors file

Return type:

numpy ndarray

gwas_tools.utils.file_utils.get_results_folders(results_path, sort=True, must_include=None, filter_non_valid=True)

Get list of folders with results from one or multiple analyses.

Parameters:
  • results_path (str) – path to results folders

  • sort (bool, optional) – sort folders (default : True)

  • must_include (list[str], optional) – patterns of files that must be present in a folder, otherwise it is discarded. Ignored if filter_non_valid is False (default : None)

  • filter_non_valid (bool, optional) – whether or not exclude non valid folders (default : True)

Returns:

list of folders paths

Return type:

list[str]

gwas_tools.utils.file_utils.is_valid_folder(folder)

Check if all required files are present in folder.

Parameters:

folder (str) – path to the folder to validate

Returns:

True if folder is valid

Return type:

bool

gwas_tools.utils.file_utils.save_predictors(preds, file_name, out_path)

Save predictors to binary file.

Parameters:
  • preds (numpy ndarray) – predictors

  • file_name (str) – name of the file

  • out_path (str) – where to save the file

gwas_tools.utils.file_utils.save_envelopes(envelopes, file_name, out_path)

Save imfs’ instantaneous amplitudes to binary file.

Parameters:
  • envelopes (numpy ndarray) – imfs’ instantaneous amplitudes

  • file_name (str) – name of the file

  • out_path (str) – where to save the file

gwas_tools.utils.file_utils.save_imfs(imfs, file_name, out_path)

Save imfs to binary file.

Parameters:
  • imfs (numpy ndarray) – imfs

  • file_name (str) – name of the file

  • out_path (str) – where to save the file

gwas_tools.utils.file_utils.summary_table(folders, comparison, table_name, second_best=False)

Comparison plots of results.

Parameters:
  • folders (list[str]) – paths to the files needed for the plots

  • comparison (list[int]) – imfs for comparison

  • table_name (str) – name of the output csv

  • second_best (bool) – if True, writes the values from the section for the second best culprit

gwas_tools.utils.file_utils.omegagram_plot_name(imf, ext)

Name of the omegagram plots.

Parameters:
  • imf (int) – imf to which the omegagram corresponds

  • ext (str) – plot extension

Returns:

plot_name – plot name

Return type:

str

gwas_tools.utils.file_utils.culprit_plot_name(imf, ext)

Name of the culprit plots.

Parameters:
  • imf (int) – imf to which the culprit corresponds

  • ext (str) – plot extension

Returns:

plot_name – plot name

Return type:

str

gwas_tools.utils.file_utils.combo_plot_name(imf_list, ext)

Name of the combo plots.

Parameters:
  • imf_list (list[int], list[str]) – list of imfs to which the culprit corresponds

  • ext (str) – plot extension

Returns:

plot_name – plot name

Return type:

str

gwas_tools.utils.file_utils.seismic_plot_name(ext)

Name of the seismic plots.

Parameters:

ext (str) – plot extension

Returns:

plot_name – plot name

Return type:

str

gwas_tools.utils.file_utils.summary_freq_plot_name(ext)

Name of the summary plot by frequency.

Parameters:

ext (str) – plot extension

Returns:

plot_name – plot name

Return type:

str

gwas_tools.utils.file_utils.summary_chamber_plot_name(ext)

Name of the summary plot by chamber.

Parameters:

ext (str) – plot extension

Returns:

plot_name – plot name

Return type:

str

gwas_tools.utils.file_utils.create_comparison_folder(where)

Create folder for comparison files.

Parameters:

where (str) – where to create the folder