source: trunk/MagicSoft/Simulation/Detector/Starfield/parameters.cxx@ 341

Last change on this file since 341 was 341, checked in by petry, 25 years ago
First version of the Starfield Generator in this repository. Fully functional version using the SKY2000 star catalog.
File size: 4.1 KB
Line 
1#include "parameters.h"
2
3parameters::parameters(){ // constructor (put invalid values)
4 ct_ra_h = -999.;
5 ct_dec_deg = -999.;
6 ct_ra_rad = -999.;
7 ct_dec_rad = -999.;
8 catalog_fov_deg = -999.;
9 integtime_s = -999.;
10 mirr_radius_m = -999.;
11 sprintf(datapath, ".");
12 verbose = 0;
13}
14
15int parameters::readparameters(ifstream *in){ // read the parameter file
16 int ira_hours, ira_min, ira_sec;
17 int idec_degrees, idec_arcmin;
18 float dec_arcsec;
19 char dummy[160];
20
21 in->ipfx(1); // tell the io system that we are reading formatted
22
23 in->getline(dummy, sizeof(dummy), '\n');
24 cout << dummy << "\n";
25 if(in->eof()) return(in->good());
26
27 in->getline(dummy, sizeof(dummy), '\n');
28 if(verbose) cout << dummy << "\n";
29 if(in->eof()) return(in->good());
30
31 in->getline(dummy, sizeof(dummy), '\n');
32 if(verbose) cout << dummy << "\n";
33 sscanf(dummy, "%d %d %d %d %d %f", &ira_hours , &ira_min, &ira_sec,
34 &idec_degrees, &idec_arcmin, &dec_arcsec);
35 cout << "Position RA DEC: "<< ira_hours << " " << ira_min << " " << ira_sec << " " <<
36 idec_degrees << " " << idec_arcmin << " " << dec_arcsec << "\n";
37 if(in->eof()) return(in->good());
38
39 in->getline(dummy, sizeof(dummy), '\n');
40 if(verbose) cout << dummy << "\n";
41 if(in->eof()) return(in->good());
42
43 in->getline(dummy, sizeof(dummy), '\n');
44 if(verbose) cout << dummy << "\n";
45 sscanf(dummy, "%f", &catalog_fov_deg);
46 cout << "FOV Radius:" << catalog_fov_deg << " degrees\n";
47 if(in->eof()) return(in->good());
48
49 in->getline(dummy, sizeof(dummy), '\n');
50 if(verbose) cout << dummy << "\n";
51 if(in->eof()) return(in->good());
52
53 in->getline(dummy, sizeof(dummy), '\n');
54 if(verbose) cout << dummy << "\n";
55 sscanf(dummy, "%f", &integtime_s);
56 cout << "Integration Time:" << integtime_s << " s\n";
57 if(in->eof()) return(in->good());
58
59 in->getline(dummy, sizeof(dummy), '\n');
60 if(verbose) cout << dummy << "\n";
61 if(in->eof()) return(in->good());
62
63 in->getline(dummy, sizeof(dummy), '\n');
64 if(verbose) cout << dummy << "\n";
65 sscanf(dummy, "%f", &mirr_radius_m);
66 cout << "Mirror Radius:" << mirr_radius_m << " m\n";
67 if(in->eof()) return(in->good());
68
69 in->getline(dummy, sizeof(dummy), '\n');
70 if(verbose) cout << dummy << "\n";
71 if(in->eof()) return(in->good());
72
73 in->getline(dummy, sizeof(dummy), '\n');
74 if(verbose) cout << dummy << "\n";
75 sscanf( dummy, "%s", datapath);
76 cout << "Catalog Data Path: " << datapath << "\n";
77 if(in->eof()) return(in->good());
78
79 in->getline(dummy, sizeof(dummy), '\n');
80 if(verbose) cout << dummy << "\n";
81 if(in->eof()) return(in->good());
82
83 in->getline(dummy, sizeof(dummy), '\n');
84 if(verbose) cout << dummy << "\n";
85 sscanf( dummy, "%d", &verbose);
86 cout << "Verbosity: " << verbose << "\n";
87
88 ct_ra_h = ira_hours + ira_min/60. + ira_sec/3600.;
89 ct_dec_deg = idec_degrees + idec_arcmin/60. + dec_arcsec/3600.;
90 ct_ra_rad = ct_ra_h * PI / 12.;
91 ct_dec_rad = ct_dec_deg * PI / 180.;
92
93 return(in->good());
94}
95
96void parameters::usage(ostream *out){
97 *out << "Starfield Generator Parameters, Date: ......, Comment: ....\n";
98 *out << "Center of FOV: ira_hours ira_min ira_sec idec_degrees idec_arcmin dec_arcsec:\n";
99 *out << "05 34 32 +22 00 52.1 \n";
100 *out << "Radius of the FOV for the catalog readout (degrees):\n";
101 *out << "2.0\n";
102 *out << "Integration time for the calculation of the number of photons (seconds):\n";
103 *out << "50e-9\n";
104 *out << "Mirror radius for the generation of random impact points (meters):\n";
105 *out << "10.0\n";
106 *out << "Path inside which the star catalog data can be found:\n";
107 *out << "/usr/users/xy/stardata\n";
108 *out << "Verbosity level (0 = not verbose, 1 = verbose, 2 = very verbose, 3 = very very ...):\n";
109 *out << "0\n";
110 return;
111}
112
113int parameters::printparameters(ostream *out){ // write the parameters to the stream
114 out->setf(ios::adjustfield);
115 out->width(PRINTWIDTH);
116 *out << "optical axis RA (h)" << ct_ra_h; out->width(PRINTWIDTH);
117 *out << "optical axis DEC (deg)" << ct_dec_deg; out->width(PRINTWIDTH);
118 *out << "\n";
119 return(0);
120}
121// reminder:
122// some of the things from star.h should go into the parameters file
123
124
Note: See TracBrowser for help on using the repository browser.