vlf4ions.class_definition
Created on Tue Apr 22 14:10:40 2025
@author: pteysseyre
Functions
|
Classes
|
Alerts sent in case of flare detection, antenna problems or such |
|
Characteristics of the receiver (for plotting purposes mainly and for sending alerts) |
|
Characteristics of the transmitter. |
- class vlf4ions.class_definition.receiver(name, lat, lon, threshold=0.5, nb_error=0, file_endings=['_100A', '_100B', '_101A', '_101B'])[source]
Bases:
objectCharacteristics of the receiver (for plotting purposes mainly and for sending alerts)
- Parameters:
name – Name of the receiver. Must match the name in the VLF data file names
lat – Latitude of the receiver (for plotting)
lon – Longitude of the receiver (for plotting)
threshold – Amplitude threshold bellow which we declare a station not transmitting (default: 0.5)
nb_errors – Number of reading errors, we keep track of them to alert in case of malfunction
file_endings – List of strings found at the end of the data files. Default (for AWESOME): [“_100A”, “_100B”, “_101A”, “_101B”]
- class vlf4ions.class_definition.email_alerts(subject, body, sender, password, recipients, threshold=0, files=[], sent_last_time=0, send_each_change=False)[source]
Bases:
objectAlerts sent in case of flare detection, antenna problems or such
- Parameters:
subject – Subject of the email alert
body – Body of the email alert
sender – Email adress of the sender
password – Password of the email address of the sender
recipiends – Recipients of the email alert (must be a list of strings)
threshold – Flux threshold. If the probability of the flux being above this threshold is 10% or more, the alert will be sent (default: 0)
files – List of files to include as attachment (default: empty)
send_last_time – Computed internally; used to keep track of alerts already sent to avoid spamming people
send_each_change – Boolean. If true, the recipients will receive an alert each time the flux estimation changes, as long as there is at least a 10% probability of the flux being above the threshold
- update_detection_body(callsign, p1)[source]
Just updates the body of the email with the relevant informations in case of flare detection
- get_path_to_fluxestimate(path)[source]
Get the path to the file used by the ‘craft_newsletter’ function bellow
- Parameters:
path – Path to the flux estimate recap
- Returns:
filename, full name and path of the file with the flux estimations
- craft_newsletter(filename, completenamegiven=False)[source]
Craft a newsletter based on the recapitulative file indicated by `filename’. It should include the highest flux estimated, its time, and each time the estimated flux was above M2 (with start, end time and peak times).
- Parameters:
filename – Path to the recapitulative file created with the ‘write_fluxestimate’ function. It can be found by calling the ‘get_path_to_fileestimate’ method just before
completenamegiven – Boolean (default: False). If it is false, it assumes that the filename given is the path to the folder, and that the true filename must be computed (because it depends on the date)
- Returns:
max_flux: List of peak fluxes for each flare detected during the day
max_times: List of each time of peak flux previously returned
starts: Start times of each detected flare (quiet < 1)
ends: End times of each detected flare (quiet == 1)
- class vlf4ions.class_definition.station(name, lat, lon, freq, detection_threshold, reading_time, Cal_NS=0.14, Cal_EW=0.08, df=0, time_average=60, delta=0.1, nb_data_points=0, nb_error=0, Ne=100000000.0, DP=0, DA=0, p1=0, quiet=1, flag=0, mu=-6, sigma=1, orientation=2, sza=0, sza_threshold=85, last_time_problem=-1)[source]
Bases:
objectCharacteristics of the transmitter.
- Parameters:
name – call-sign (e.g. ‘GVT’)
lat – latitude of the transmitter
lon – latitude of the transmitter
freq – Frequency (kHz)
detection_threshold – Phase slope above which we detect a solar flare
reading_time – second after the minute at which we read the data. NOTE: They should be unique for each station
time_average – Time resolution of the smoothed signal (default: 60 s)
delta – Delta parameter of the incremental algorithm (Guralnik & Srivastava, 1999. Default:0.1)
nb_data_points – number of data points last time the file was read (default : 0, used for flagging)
Ne – Average electron density computed in the path (not done yet, but I needed this for data analysis)
DA/DP – Computed internally, variations of the amplitude and phase compared to quiet times
mu/sigma – This is computed internally, and is the average and std of the flux probability density function given DA and DP
orientation – Is 1 if the phase considered is E/W, 0 if it is N/S. The idea is that the phase can be much noisier in one direction, so the optimal orientation is left as a choice for the user. If it is set to 2, the polarisation start phase is used to combine both orientations. (Default:2)
sza – Solar zenith angle (in °) at the middle of the path. Updated in the code automatically
sza_threshold – Solar zenith angle threshold below which it is daytime (Default: 85°)
Re-written under current format in April 2025
- update_df(this_receiver, path_to_data, epsilon=5, nb_days=30)[source]
Updates the value of df for the station, as it depends on the transmitter and may vary in time
- Parameters:
receiver – Receiver class instance
path_to_data – Path to the data files
epsilon – Maximum phase jump (in °) that we allow on average (default: 5)
nb_days – Number of days on which we want to compute df (default: 30)
- update_breakpoints(path_breakpoint, path_mau, path_sunrise, alerts_antenna, alerts_detection, this_receiver)[source]
Checks the phase and detects perturbations due to flares. If needed, send alerts to users
- Parameters:
path_breakpoint – path to the files where the breakpoints are stores
path_mau – path to the data being written
path_sunrise – path to the files with precomputed sunrise and sunset times
alerts_antenna – instance of ‘alert’ class, alert to send if the antenna is down
alerts_detection – instance of ‘alert’ class, alert to send if there is a detection
this_receiver – Receiver class instance
- get_pdf_coeff(path_to_probas)[source]
Returns the mu and sigma coefficients, defining a gaussian probabiility distribution function associated to a station and a value of DP
- Parameters:
path_to_probas – path to the files containing the mu and sigma values for the porbability computations
- compute_DA_DP(path_breakpoint, la_date, amp, phase, this_receiver)[source]
This function computes the values of DA and DP. Before this was only done in case of a new breakpoint, but that actually should be done as soon as quiet==0
- Parameters:
path_breakpoint – Path to the breakpoint file
la_date – Date, in the ‘yyyy_mm_dd’ format
amp – Median amplitude over the last minute (given by flag.flags)
phase – Phase array
this_receiver – Receiver class instance