Utility scripts

data_export

photo_SaveInfo(path, data_fits)

Stores information related to the photometric run.

In specific:
  • which file was used
  • mask type
  • detect mode
  • background grid
  • all star related info
Parameters:
  • path – path in which the file will be stored
  • data_fitsData object.

For details on the functions that write to disk refer to Section Structure of the outputs.

factors_handler

noise_metrics

CDPP(flux_vals, times, sized=41, winlen=10, win=30, outl=True)

Ported version of the K2 CDPP algorithm, implemented by Pedro Silva

Parameters:
  • flux_vals – flux values
  • times – time array
  • sized – Since we are calculating the CDPP for 1 hour. Window for the Savgol filter
  • winlen – Convolution window
  • win – Time over which we want to calculate the CDPP
  • outl – Remove the outliers.
Interpolate(time, mask, y)

Masks certain elements in the array y and linearly interpolates over them, returning an array y’ of the same length.

Parameters:
  • time (array_like) – The time array
  • mask (array_like) – The indices to be interpolated over
  • y (array_like) – The dependent array
SavGol(y, win=49)

Subtracts a second order Savitsky-Golay filter with window size win and returns the result. This acts as a high pass filter.

Scatter(y, win=13, remove_outliers=False)

Return the scatter in ppm based on the median running standard deviation for a window size of win = 13 cadences (for K2, this is ~6.5 hours, as in VJ14).

Parameters:
  • y (ndarray) – The array whose CDPP is to be computed
  • win (int) – The window size in cadences. Default 13
  • remove_outliers (bool) – Clip outliers at 5 sigma before computing the CDPP? Default False
Smooth(x, window_len=100, window='hanning')

Smooth data by convolving on a given timescale.

Parameters:
  • x (ndarray) – The data array
  • window_len (int) – The size of the smoothing window. Default 100
  • window (str) – The window type. Default hanning

optimization

optimizer(value_range, max_process, func, data_f, file_path, to_disable=[], **kwargs)

Decides which factors will be used in each process that it spawns. After the processes are done, extracts the resulting data from the Queue and parses it, in order to find the noise values and mask factors. Writes to a .txt file the resulting values for each factor. Take note that the values are not guaranteed to be in order, since they are saved in the order “imposed” by the processes. :param value_range: Lower and upper limit of the values to be tested :param max_process: Maximum number of processes that can be launched during this routine :param func: function that launches the photometric process :param data_f: pyarchi.main.initial_loads.Data object with all the stars information inside :param file_path: Path in which run time information shall be stored :param kwargs:

Returns:
  • min_cvs – list with the minimum noise found
  • optimized_dict – Dictionary in which the keys are the star numbers and the values are the optimal factors
run_function(queue, func, factors, data_f, to_disable=[], **kwargs)

Run each interaction of the function and returns the results ordered on a dictionary

Parameters:
  • queue
  • func
  • factors
circular_tuner(best_values, max_process, func, data_f, file_path, to_disable=[], **kwargs)

Decides which factors will be used in each process that it spawns. After the processes are done, extracts the resulting data from the Queue and parses it, in order to find the noise values and mask factors. Writes to a .txt file the resulting values for each factor. Take note that the values are not guaranteed to be in order, since they are saved in the order “imposed” by the processes. :param value_range: Lower and upper limit of the values to be tested :param max_process: Maximum number of processes that can be launched during this routine :param func: function that launches the photometric process :param data_f: pyarchi.main.initial_loads.Data object with all the stars information inside :param file_path: Path in which run time information shall be stored :param kwargs:

Returns:
  • min_cvs – list with the minimum noise found
  • optimized_dict – Dictionary in which the keys are the star numbers and the values are the optimal factors
run_function(queue, func, factors, data_f, to_disable=[], **kwargs)

Run each interaction of the function and returns the results ordered on a dictionary

Parameters:
  • queue
  • func
  • factors
general_optimizer(func, data_f, job_number, max_process, **kwargs)

Responsible for setting up the variables used during the optimization process.

If the factor determined to be the best one is near the upper limit, then the range of values is extended and a new search for minimum noise starts. If the determined factor is inside a “safe” distance away from the highest possible value then the star is disabled and no further studies are made on it.

Also responsible for creating .txt files with all the relevant information :param func: function that launches the photometric process :param data_f: pyarchi.main.initial_loads.Data object with all the stars information inside :param job_number: JOb number assigned by the SLURM workload manager :param max_process: Maximum number of processes that can be launched during this routine

Returns:Dictionary in which the keys are the star numbers and the values are the optimal factors
Return type:optimized_dict

misc

parameters_validator(**kwargs)

Loads the configuration parameters from the .yaml file. After loading, it checks some of the parameters to see if they have valid values.

Parameters:parameters
path_finder(mode, off_curve=None, **kwargs)

Searches inside the base folder for the desired files

Parameters:
  • mode
    • subarray: retrieves the subarray file path
    • default: default lightcurve
    • stars : path for the Star catalogue file
  • kwargs
    • config values
matrix_clockwise(angle)

Creates a rotation matrix for clockwise rotations. Expects an angle in degrees

Parameters:angle – rotation angle, in degrees.
Returns:counter clockwise rotation matrix
matrix_cnter_clock(angle)

Creates a rotation matrix for counter clockwise rotations. Expects an angle in degrees

Parameters:angle – rotation angle, in degrees.
Returns:counter clockwise rotation matrix
my_timer(orig_func)

Decorator to measure the time spent on the function :param orig_func: FUnction to be analysed