-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRead_K2.m
More file actions
53 lines (41 loc) · 2.13 KB
/
Read_K2.m
File metadata and controls
53 lines (41 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
%%Author: Ekaterina Vydra
%%File for reading through all files in the k2 folder and making EB triggers
%%Reads K2 pipeline output file format only
function [Output] = Read_K2(FileNamesFile)
%If folder containing k2 processed files is not named k2, change this line to the folder name
%Make sure file list has been created (in terminal -> ls * > 'fileList.txt')
addpath('k2')
mkdir 'Matlab_Processed'
%Imports the filenames file:
fileNames = importdata(FileNamesFile);
fileOutHeader = fopen('Matlab_Processed/Star_Data.txt','a');
fprintf(fileOutHeader, '%s\n\n', 'Filename: max_amp, lower_amp, max_amp2, lower_amp2, max_freq, lower_freq, Variable_Star, Potential_EB, Visual_Followup');
fileOutHeader = fclose(fileOutHeader);
%Existence check for the files in fileName variable and further processing:
for i = 1:numel(fileNames)
exist_check = exist(fileNames{i}, 'file');
disp((i/numel(fileNames))*100)
disp('% complete')
%Operations made if file exists:
if exist_check ~= 0
%Prepare the fits file matrix for manipulation:
fileNames_open = fopen(fileNames{i});
for k = 1
fgetl(fileNames_open);
end
%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
fitsFile = textscan(fileNames_open, '%f,%f,%f,%f,%f,%f,%f,%f');
%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
fclose(fileNames_open);
[max_amp, amp, max_amp2, amp2, max_freq, max_freq2, Variable, EB, SP] = EBDetection(fitsFile);
%Opens the new file and starts appending information to it:
fileOutHeader = fopen('Matlab_Processed/Star_Data.txt','a');
fprintf(fileOutHeader, '%s %f %f %f %f %f %f %i %i %i\n\n', fileNames{i},max_amp, amp, max_amp2, amp2, max_freq, max_freq2, Variable, EB, SP);
fileOutHeader = fclose(fileOutHeader);
%End of operations if files exist.
%end
%If file does not exist:
elseif exist_check == 0
disp(fileName{i}) %Shows me the file that doesnt exist.
end
end