Program Listing for File flt.h
↰ Return to documentation for file (src/lib/flt.h)
/*
10/11/2014
Class to store one filter
*/
// avoid multiple def of the same class
#ifndef FLT_H // check that this keyword has been set already
#define FLT_H // define the keyword to be checked
#include <fstream> // print output file
#include <iostream> // print standard file
#include <string>
#include <vector>
#include "globals.h"
#include "oneElLambda.h"
using namespace std;
class flt {
private:
void trans();
void clean();
public:
vector<oneElLambda> lamb_trans;
int id;
string name;
int transtyp, calibtyp;
double leff, lmean, dwidth, ab, tg, veg, msun, fcorr, tpeak;
flt() {
leff = -999999.;
lmean = -999999.;
dwidth = -999999.;
ab = -99.;
tg = -99.;
veg = -99.;
msun = -99.;
fcorr = -99.;
}
flt(const int k, string cname, const int transt, const int calibt) : flt() {
id = k;
transtyp = transt;
calibtyp = calibt;
// if cname is a path
if (cname.find_first_of("/") != string::npos) {
// path is relative
if (cname.at(0) != '/' && cname.at(0) != '.') {
cname = lepharedir + "/filt/" + cname;
}
}
name = cname;
read(cname);
compute_all();
}
flt(const int k, ifstream &cname, const int transt, const int calibt)
: flt() {
id = k;
transtyp = transt;
calibtyp = calibt;
read(cname);
compute_all();
}
flt(const double lmin, const double lmax, const int nsteps) : flt() {
id = 0;
transtyp = 0;
calibtyp = 0;
// Generate a heavyside filter. Transmission at 1. Not renormalized.
// Delta lambda
double dlamb = (lmax - lmin) / double(nsteps);
// First element at T=0
oneElLambda litBeg(lmin - 1, 0, 0);
lamb_trans.push_back(litBeg);
for (int k = 0; k <= nsteps; k++) {
double lamb = lmin + double(k) * dlamb;
oneElLambda litOne(lamb, 1, 0);
lamb_trans.push_back(litOne);
}
// Last element at T=0
oneElLambda litFin(lmax + 1, 0, 0);
lamb_trans.push_back(litFin);
}
/* MP: erase all entries in lamb_trans */
~flt() { lamb_trans.clear(); }
// Prototype of the functions declared in flt.cpp
void read(const string &fltFile);
void read(ifstream &sfiltIn);
double lambdaMean();
double width();
double peak();
double lambdaEff();
double lambdaEff2();
double magsun();
double vega();
double fcorrec();
double abcorr();
double tgcorr();
double lmin() const { return lamb_trans.front().lamb; }
double lmax() const { return lamb_trans.back().lamb; }
void compute_all();
};
void write_output_filter(string &filtfile, string &filtdoc, vector<flt> vecFlt);
vector<flt> read_doc_filters(const string filtFile);
#endif