-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspec2lum.cpp
More file actions
70 lines (56 loc) · 1.25 KB
/
spec2lum.cpp
File metadata and controls
70 lines (56 loc) · 1.25 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
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <vector>
#include <stddef.h>
#include <math.h>
using namespace std;
char specfile[80];
char rcfile[80];
double rc[1900][2];
double response(double wl)
{
int i,j;
for(i=0;i<1900;i++)
if(rc[i][0] == wl) return rc[i][1];
return 0.0;
}
int main()
{
int fi,i,j,k;
double age,ageold,lambda,flux,dl=0,lum;
double d1,d2,d3,dummy;
strcpy(specfile,"spectra/spec.csv");
strcpy(rcfile,"spectra/rc.csv");
ifstream readspec;
ifstream readrc;
readrc.open(rcfile);
while(!readrc.eof()){
readrc >> d1 >> d2 >> d3;
rc[fi][0] = d1;
rc[fi][1] = d3;
fi++;
}
readrc.close();
readspec.open(specfile);
while(!readspec.eof()){
//Age(yr),lambda(ang),log Flux,Flux
readspec >> d1 >> d2 >> d3;
//printf("%3.2e %3.2e %3.2e\n",d1,d2,d3);
dl = d2-lambda;
age = d1;
if(age!=ageold) //new age
{
printf("%3.2e %3.2e\n",ageold,(19.5-2.5*log10(lum/(3.85e33))));
lum = 0.0;
dl = 1.0;
}
lambda = d2;
flux = pow(10.0,d3);
lum += flux*dl*response(lambda);
ageold = age;
}
readspec.close();
return 0;
}