forked from rmgarnett/gp_dla_detection
-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_ascii_catalog.m
83 lines (67 loc) · 2.8 KB
/
generate_ascii_catalog.m
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
% generate_ascii_catalog: generates ASCII catalog of results of DLA
% search
catalog = load(sprintf('%s/catalog', processed_directory(release)));
load(sprintf('%s/dla_samples', processed_directory(training_release)));
load(sprintf('%s/processed_qsos_%s', processed_directory(release), test_set_name));
fid = fopen(sprintf('%s/%s_dla_samples.dat', ...
processed_directory(release), ...
test_set_name), ...
'w');
for i = 1:numel(offset_samples)
fprintf(fid, '%06f %09f\n', ...
offset_samples(i), ...
log_nhi_samples(i));
end
fclose(fid);
fid = fopen(sprintf('%s/%s_spectra.dat', ...
processed_directory(release), ...
test_set_name), ...
'w');
for i = 1:numel(catalog.z_qsos)
fprintf(fid, ...
'%09i %-18s %04i %05i %04i %011.7f %+011.7f %06.4f %08.4f %i%i%i%i\n', ...
catalog.thing_ids(i), ...
deblank(catalog.sdss_names{i}), ...
catalog.plates(i), ...
catalog.mjds(i), ...
catalog.fiber_ids(i), ...
catalog.ras(i), ...
catalog.decs(i), ...
catalog.z_qsos(i), ...
catalog.snrs(i), ...
bitget(catalog.filter_flags(i), 1), ...
bitget(catalog.filter_flags(i), 2), ...
bitget(catalog.filter_flags(i), 3), ...
bitget(catalog.filter_flags(i), 4) ...
);
end
fclose(fid);
fid = fopen(sprintf('%s/%s_results.dat', ...
processed_directory(release), ...
test_set_name), ...
'w');
searched_ind = find(test_ind);
for i = 1:numel(searched_ind)
catalog_ind = searched_ind(i);
fprintf(fid, '%09i %-18s ', catalog.thing_ids(catalog_ind));
fprintf(fid, ...
'%06.4f %06.4f %8.5f %8.5f %12.5e %12.5e %s %s ', ...
min_z_dlas(i), ...
max_z_dlas(i), ...
log_priors_no_dla(i), ...
log_priors_dla(i), ...
log_likelihoods_no_dla(i), ...
log_likelihoods_dla(i), ...
regexprep(sprintf('%0.5e', model_posteriors(i, 1)), ...
'e([+-])(\d\d)$', 'e$10$2'), ...
regexprep(sprintf('%0.5e', model_posteriors(i, 2)), ...
'e([+-])(\d\d)$', 'e$10$2') ...
);
[~, map_ind] = nanmax(sample_log_likelihoods_dla(i, :));
map_z_dla = min_z_dlas(i) + ...
(max_z_dlas(i) - min_z_dlas(i)) * offset_samples(map_ind);
fprintf(fid, '%06.4f %07.4f\n', ...
map_z_dla, ...
log_nhi_samples(map_ind));
end
fclose(fid);