11 #include <configure.hpp>
18 #include <athena/athena.hpp>
31 for (
int i = 0; i < 3; ++i) {
32 os <<
"Axis " << i <<
" = " << ab.
len_[i] << std::endl;
34 os <<
"Minimum value = "
35 << *std::min_element(ab.
axis_.begin(), ab.
axis_.begin() + ab.
len_[i])
37 os <<
"Maximum value = "
38 << *std::max_element(ab.
axis_.begin(), ab.
axis_.begin() + ab.
len_[i])
41 os <<
"Minimum value = "
42 << *std::min_element(ab.
axis_.begin() + ab.
len_[i - 1],
45 os <<
"Maximum value = "
46 << *std::max_element(ab.
axis_.begin() + ab.
len_[i - 1],
51 os <<
"No. of kcoeff = " << ab.
kcoeff_.size() << std::endl;
52 os <<
"Minimum value = "
53 << *std::min_element(ab.
kcoeff_.begin(), ab.
kcoeff_.end()) << std::endl;
54 os <<
"Maximum value = "
55 << *std::max_element(ab.
kcoeff_.begin(), ab.
kcoeff_.end()) << std::endl;
61 int jl = -1, ju = nlevel, jm;
73 if (ju == nlevel) ju = nlevel - 1;
74 if (jl == ju)
return refatm_(IDN, jl);
77 Real result = log(
refatm_(IPR, jl) / pres) * log(
refatm_(IDN, ju)) +
85 int fileid, dimid, varid, err;
87 nc_open(fname.c_str(), NC_NETCDF4, &fileid);
89 nc_inq_dimid(fileid,
"Wavenumber", &dimid);
90 nc_inq_dimlen(fileid, dimid,
len_);
91 nc_inq_dimid(fileid,
"Pressure", &dimid);
92 nc_inq_dimlen(fileid, dimid,
len_ + 1);
93 snprintf(tname,
sizeof(tname),
"%s",
"T_");
94 snprintf(tname,
sizeof(tname),
"%s%s", tname,
GetName().c_str());
95 nc_inq_dimid(fileid, tname, &dimid);
96 nc_inq_dimlen(fileid, dimid,
len_ + 2);
100 nc_inq_varid(fileid,
"Wavenumber", &varid);
101 nc_get_var_double(fileid, varid,
axis_.data());
102 err = nc_inq_varid(fileid,
"Pressure", &varid);
103 if (err != NC_NOERR)
throw std::runtime_error(nc_strerror(err));
104 err = nc_get_var_double(fileid, varid,
axis_.data() +
len_[0]);
105 if (err != NC_NOERR)
throw std::runtime_error(nc_strerror(err));
106 nc_inq_varid(fileid, tname, &varid);
107 nc_get_var_double(fileid, varid,
axis_.data() +
len_[0] +
len_[1]);
110 nc_inq_varid(fileid,
"Temperature", &varid);
111 nc_get_var_double(fileid, varid,
temp);
114 for (
int i = 0; i <
len_[1]; i++) {
120 nc_inq_varid(fileid,
GetName().c_str(), &varid);
121 nc_get_var_double(fileid, varid,
kcoeff_.data());
130 Real val, coord[3] = {wave1, var.
w[IPR], var.
w[IDN] -
getRefTemp(var.
w[IPR])};
136 for (
int n = 1; n <= NVAPOR; ++n) x0 -= var.
w[n];
140 return 1.E-3 * exp(val) * dens * x0;
std::vector< Real > axis_
std::vector< Real > kcoeff_
void LoadCoefficient(std::string fname, size_t bid=0) override
Load absorption coefficient from file.
Real GetAttenuation(Real wave1, Real wave2, AirParcel const &var) const override
Get attenuation coefficient [1/m].
Real getRefTemp(Real pres) const
AthenaArray< Real > refatm_
std::string GetName() const
int GetSpeciesIndex(int n) const
std::ostream & operator<<(std::ostream &os, HitranAbsorber const &ab)
void interpn(double *val, double const *coor, double const *data, double const *axis, size_t const *len, int ndim, int nval)