File: writemodel.h

package info (click to toggle)
wsclean 3.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,296 kB
  • sloc: cpp: 129,246; python: 22,066; sh: 360; ansic: 230; makefile: 185
file content (59 lines) | stat: -rw-r--r-- 2,137 bytes parent folder | download | duplicates (2)
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
#ifndef WSCLEAN_MODEL_WRITEMODEL_H_
#define WSCLEAN_MODEL_WRITEMODEL_H_

#include <fstream>
#include <boost/filesystem/operations.hpp>
#include <aocommon/radeccoord.h>
#include <aocommon/uvector.h>

namespace wsclean::model {

inline void WriteHeaderForSpectralTerms(std::ostream& stream,
                                        double reference_frequency) {
  stream.precision(15);
  stream << "Format = Name, Type, Ra, Dec, I, SpectralIndex, LogarithmicSI, "
            "ReferenceFrequency='"
         << reference_frequency << "', MajorAxis, MinorAxis, Orientation\n";
}

inline void AddSiTerms(std::ostream& stream,
                       const std::vector<float>& si_terms) {
  assert(!si_terms.empty());
  stream << si_terms.front() << ",[";
  if (si_terms.size() >= 2) {
    stream << si_terms[1];
    for (size_t i = 2; i != si_terms.size(); ++i) {
      stream << ',' << si_terms[i];
    }
  }
  stream << ']';
}

inline void WritePolynomialPointComponent(
    std::ostream& stream, const std::string& name, long double ra,
    long double dec, bool use_log_si,
    const std::vector<float>& polarization_terms,
    double reference_frequency_hz) {
  stream << name << ",POINT," << aocommon::RaDecCoord::RAToString(ra, ':')
         << ',' << aocommon::RaDecCoord::DecToString(dec, '.') << ',';
  AddSiTerms(stream, polarization_terms);
  stream << "," << (use_log_si ? "true" : "false") << ","
         << reference_frequency_hz << ",,,\n";
}

inline void WritePolynomialGaussianComponent(
    std::ostream& stream, const std::string& name, long double ra,
    long double dec, bool use_log_si,
    const std::vector<float>& polarization_terms, double reference_frequency_hz,
    double maj, double min, double position_angle) {
  stream << name << ",GAUSSIAN," << aocommon::RaDecCoord::RAToString(ra, ':')
         << ',' << aocommon::RaDecCoord::DecToString(dec, '.') << ',';
  AddSiTerms(stream, polarization_terms);
  stream << "," << (use_log_si ? "true" : "false") << ","
         << reference_frequency_hz << "," << maj << ',' << min << ','
         << position_angle << "\n";
}

}  // namespace wsclean::model

#endif