-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotter.m
More file actions
170 lines (131 loc) · 3.93 KB
/
plotter.m
File metadata and controls
170 lines (131 loc) · 3.93 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
% This program plots the .spec files from LePHARE.
% This was needed to plot the spectras with the upper limits.
%
% Created by: Joao Aguas
clear all;
close all;
colors = ['k','m','b','r','g'];
% Opens the file... Hopefully... The operator is a schmuck, so, exit(0)
inputfile = input('Input file: ', 's')
fid = fopen(inputfile,'r')
if fid == -1
return
end
% Getting the data from the header.
buffer = fgets(fid);
buffer = fgets(fid);
buffer2 = sscanf(buffer,'%f');
gal_id=buffer2(1); zspec=buffer2(2); zphot=buffer2(3);
buffer = fgets(fid);
filterinfo = strsplit(buffer);
buffer = fgets(fid);
buffer2 = strsplit(buffer);
nfilters = str2num(buffer2{2});
buffer = fgets(fid);
buffer = fgets(fid);
buffer2 = strsplit(buffer);
pdfcount = str2num(buffer2{2});
buffer = fgets(fid);
solutions.header = strsplit(buffer);
buffer = fgets(fid);
for ii=1:6
buffer2 = strsplit(buffer);
solutions.head{ii}=buffer2{1}; solutions.soldata(ii,1) = ii;
for aa=2:17
solutions.soldata(ii,aa) = str2num(buffer2{aa});
end
buffer = fgets(fid);
end
% Getting the photometric data and the estimated SEDs.
% First the photometric points.
for ii=1:nfilters
buffer2 = strsplit(buffer);
for aa=2:8
filters(ii,aa-1) = str2num(buffer2{aa});
end
buffer = fgets(fid);
end
% Getting the PDF for the main solution.
for ii=1:pdfcount
buffer2 = strsplit(buffer);
pdfdata(ii,1)= str2num(buffer2{2}); pdfdata(ii,2)= str2num(buffer2{3});
buffer = fgets(fid);
end
% Getting SED solutions.
jj=1;
for ii=1:6
if solutions.soldata(ii,2) ~= 0
foundsol(ii)=solutions.soldata(ii,1);
for kk=1:solutions.soldata(ii,2)
buffer2 = strsplit(buffer);
solutions.sed(kk,1,ii) = str2num(buffer2{2}); solutions.sed(kk,2,ii) = str2num(buffer2{3});
buffer = fgets(fid);
end
%jj = jj + 1;
end
end
% Selection and detection of solutions in the spec file.
disp('The possible solutions and their assigned codes are: ')
disp('(1) GAL-1');
disp('(2) GAL-2');
disp('(3) GAL-FIR');
disp('(4) GAL-STOCH');
disp('(5) QSO');
disp('(6) STAR');
disp('The detected solutions were: ') ; disp(foundsol); disp(' ');
disp('Insert the SED choice inside bracket and separated by comma!')
disp('Example: [1,2,3]')
choice=input('Selection: ')
% Plotting the data. Finally!!! :)
figure(1)
hold on
set(gca, 'XScale', 'log');
set(gca, 'YDir', 'reverse');
xlabel('\lambda (\mum)');
ylabel('Mag');
sz=size(choice); sz=sz(2);
for ii=1:sz
plot(solutions.sed(:,1,choice(ii)),solutions.sed(:,2,choice(ii)),colors(ii));
end
sz = size(filters); sz = sz(1);
for ii=1:sz
if filters(ii,1) ~= -99
if filters(ii,2) == -1
scatter(filters(ii,3),filters(ii,1),'v','k');
else
scatter(filters(ii,3),filters(ii,1),'o','k');
erry = [filters(ii,1)-filters(ii,2) filters(ii,1)+filters(ii,2)];
xpos = [filters(ii,3) filters(ii,3)];
point=plot(xpos,erry,'k'); point.LineWidth = 1;
end
err = [filters(ii,3)-filters(ii,4)/2 filters(ii,3)+filters(ii,4)/2];
ypos = [filters(ii,1) filters(ii,1)];
point=plot(err,ypos,'k'); point.LineWidth = 1;
end
end
headerinfo = strcat('Id=',num2str(gal_id),', zspec=',num2str(zspec),', zphot=',num2str(zphot));
title(headerinfo);
% Checking the sizes... You know... sizes, weights... regular stuff. :-\
headsz = size(solutions.header); headsz = headsz(2);
% This next section composes the solutions information posted on the main
% plot.
for ii=2:headsz-1
solutions.found{1,ii-1}=solutions.header(ii);
end
% Filling the important fields.
jj=2;
for ii=1:6
if solutions.soldata(ii,2)~=0
solutions.found{jj,1}= solutions.head(ii);
for kk=2:headsz-2
solutions.found{jj,kk}=num2str(solutions.soldata(ii,kk));
end
jj=jj+1;
end
end
% figure(2);
% hold on;
% Plots the PDF for the first solution
figure(3)
hold on
plot(pdfdata(:,1),pdfdata(:,2))