20#include "matpack_data.h"
23#include "propagationmatrix.h"
37 os <<
" Radius: " << sun.
radius <<
"m ";
38 os <<
" Distance: " << sun.
distance <<
"m \n";
39 os <<
" Latitude: " << sun.
latitude <<
"° \n";
40 os <<
" Longitude: " << sun.
longitude <<
"° \n";
41 os <<
" Spectrum [W/m2/Hz]: \n" << sun.
spectrum ;
51 const Matrix& transmitted_sunlight,
52 const Vector& gas_scattering_los_in,
53 const Vector& gas_scattering_los_out,
54 const Agenda& gas_scattering_agenda) {
55 PropagationMatrix K_sca;
68 gas_scattering_los_in,
69 gas_scattering_los_out,
71 gas_scattering_agenda);
74 Index ns = transmitted_sunlight.ncols();
75 Index nf = f_grid.nelem();
80 Matrix mat_temp(1, ns,0.);
82 for (Index i_f = 0; i_f < nf; i_f++) {
83 mat_temp(0,joker) = transmitted_sunlight(i_f, joker);
84 scattered_sunlight_temp = mat_temp;
85 scattered_sunlight_temp.
leftMul(gas_scattering_mat);
87 for (Index j = 0; j < ns; j++) {
88 scattered_sunlight(i_f, j) =
89 scattered_sunlight_temp(0, j) * K_sca.Kjj(0, 0)[i_f] /(4*pi);
100 const Vector& f_grid,
101 const Index& stokes_dim,
102 const Index& atmosphere_dim,
103 const Vector& refellipsoid) {
104 const Index np = ppath.
np;
110 iy.resize(f_grid.nelem(), stokes_dim);
113 Vector rtp_pos, rtp_los;
114 rtp_pos.resize(atmosphere_dim);
115 rtp_pos = ppath.
pos(np - 1, Range(0, atmosphere_dim));
116 rtp_los.resize(ppath.
los.ncols());
117 rtp_los = ppath.
los(np - 1, joker);
120 for (Index i_sun = 0; i_sun < suns.
nelem(); i_sun++) {
121 get_sun_radiation(iy, suns_visible, suns[i_sun], rtp_pos, rtp_los, refellipsoid);
129 const Vector& rtp_pos,
130 const Vector& rtp_los,
131 const Vector& refellipsoid) {
135 const Numeric R_rte =
refell2r(refellipsoid, rtp_pos[1]) + rtp_pos[0];
138 Numeric r_sun_x, r_sun_y, r_sun_z;
139 Numeric r_rte_x, r_rte_y, r_rte_z;
140 Numeric r_los_x, r_los_y, r_los_z;
160 const Numeric r_ps_x = r_sun_x - r_rte_x;
161 const Numeric r_ps_y = r_sun_y - r_rte_y;
162 const Numeric r_ps_z = r_sun_z - r_rte_z;
166 sqrt(r_ps_x * r_ps_x + r_ps_y * r_ps_y + r_ps_z * r_ps_z);
169 const Numeric r_glos =
170 sqrt(r_los_x * r_los_x + r_los_y * r_los_y + r_los_z * r_los_z);
174 const Numeric cos_beta =
175 (r_ps_x * r_los_x + r_ps_y * r_los_y + r_ps_z * r_los_z) / (r_ps * r_glos);
176 const Numeric beta = acos(cos_beta);
179 const Numeric alpha = atan(sun.
radius / r_ps);
196 ArrayOfMatrix& direct_radiation,
197 ArrayOfArrayOfTensor3& ddirect_radiation_dx,
198 const Index& stokes_dim,
199 const Vector& f_grid,
200 const Index& atmosphere_dim,
201 const Vector& p_grid,
202 const Vector& lat_grid,
203 const Vector& lon_grid,
204 const Tensor3& t_field,
206 const Tensor4& vmr_field,
208 const Tensor3& wind_u_field,
209 const Tensor3& wind_v_field,
210 const Tensor3& wind_w_field,
211 const Tensor3& mag_u_field,
212 const Tensor3& mag_v_field,
213 const Tensor3& mag_w_field,
214 const Index& cloudbox_on,
216 const Index& gas_scattering_do,
217 const Index& irradiance_flag,
221 const Vector& refellipsoid,
222 const Tensor4& pnd_field,
223 const ArrayOfTensor4& dpnd_field_dx,
226 const Index& jacobian_do,
228 const Agenda& propmat_clearsky_agenda,
229 const Agenda& water_p_eq_agenda,
230 const Agenda& gas_scattering_agenda,
231 const Numeric& rte_alonglos_v,
237 ArrayOfMatrix iy_aux_dummy;
239 Vector ppvar_p_dummy;
240 Vector ppvar_t_dummy;
242 Matrix ppvar_vmr_dummy;
243 Matrix ppvar_wind_dummy;
244 Matrix ppvar_mag_dummy;
245 Matrix ppvar_pnd_dummy;
246 Matrix ppvar_f_dummy;
247 Tensor3 ppvar_iy_dummy;
248 Tensor4 ppvar_trans_cumulat_dummy;
249 Tensor4 ppvar_trans_partial_dummy;
251 direct_radiation.resize(suns.
nelem(),Matrix(f_grid.nelem(), stokes_dim, 0.));
253 Matrix radiation_toa;
254 Matrix radiation_trans;
255 ArrayOfTensor3 dradiation_trans;
256 Vector rtp_pos, rtp_los;
259 for (Index i_sun = 0; i_sun < suns.
nelem(); i_sun++) {
260 np = sun_ppaths[i_sun].np;
262 if (suns_visible[i_sun]) {
263 sun_pos = {suns[i_sun].distance,
264 suns[i_sun].latitude,
265 suns[i_sun].longitude};
271 atmosphere_dim, refellipsoid, lat_grid, lon_grid, sun_pos);
274 if (irradiance_flag) {
279 refell2r(refellipsoid, sun_ppaths[i_sun].pos(np - 1, 1)) +
280 sun_ppaths[i_sun].pos(np - 1, 0);
286 sun_ppaths[i_sun].pos(np - 1, 1),
287 sun_ppaths[i_sun].pos(np - 1, 2),
293 radiation_toa = suns[i_sun].spectrum;
294 radiation_toa *= suns[i_sun].radius * suns[i_sun].radius;
295 radiation_toa /= (suns[i_sun].radius * suns[i_sun].radius +
296 R_Sun2Toa * R_Sun2Toa);
301 rtp_pos.resize(atmosphere_dim);
302 rtp_pos = sun_ppaths[i_sun].pos(np - 1, Range(0, atmosphere_dim));
303 rtp_los.resize(sun_ppaths[i_sun].los.ncols());
304 rtp_los = sun_ppaths[i_sun].los(np - 1, joker);
306 radiation_toa.resize(f_grid.nelem(), stokes_dim);
310 get_sun_radiation(radiation_toa, visible, suns[i_sun], rtp_pos, rtp_los, refellipsoid);
327 ppvar_trans_cumulat_dummy,
328 ppvar_trans_partial_dummy,
355 propmat_clearsky_agenda,
357 gas_scattering_agenda,
363 if (jacobian_do && dradiation_trans.nelem()){
364 ddirect_radiation_dx[i_sun] = dradiation_trans;
366 direct_radiation[i_sun] = radiation_trans;
374 ArrayOfVector& sun_rte_los,
375 const Vector& rte_pos,
377 const Vector& f_grid,
378 const Index& atmosphere_dim,
379 const Vector& p_grid,
380 const Vector& lat_grid,
381 const Vector& lon_grid,
382 const Tensor3& z_field,
383 const Matrix& z_surface,
384 const Vector& refellipsoid,
385 const Numeric& ppath_lmax,
386 const Numeric& ppath_lraytrace,
387 const Agenda& ppath_step_agenda,
390 Vector sun_rte_los_isun(2);
391 Numeric ppath_lraytrace2 = ppath_lraytrace;
394 for (Index i_sun = 0; i_sun < suns.
nelem(); i_sun++) {
395 sun_pos = {suns[i_sun].distance,
396 suns[i_sun].latitude,
397 suns[i_sun].longitude};
403 atmosphere_dim, refellipsoid, lat_grid, lon_grid, sun_pos);
437 sun_ppaths[i_sun] = sun_ppath;
438 sun_rte_los[i_sun] = sun_rte_los_isun;
441 suns_visible[i_sun] =
447 const Vector &f_grid,
448 const Index &stokes_dim,
449 const Numeric &temperature,
453 const Index nf = f_grid.nelem();
455 const Numeric data_fmin = data_f_grid[0];
456 const Numeric data_fmax = data_f_grid[data_f_grid.nelem() - 1];
459 Matrix int_data(f_grid.nelem(), stokes_dim, 0.);
461 if (out3.sufficient_priority()) {
463 os <<
" f_grid: " << f_grid[0] <<
" - " << f_grid[nf - 1]
465 <<
" data_f_grid: " << data_fmin <<
" - " << data_fmax <<
" Hz\n";
469 const Numeric* f_grid_begin = f_grid.unsafe_data_handle();
470 const Numeric* f_grid_end = f_grid_begin + f_grid.nelem();
471 const Index i_fstart = std::distance(
472 f_grid_begin, std::lower_bound(f_grid_begin, f_grid_end, data_fmin));
473 const Index i_fstop =
476 std::upper_bound(f_grid_begin + i_fstart, f_grid_end, data_fmax)) -
480 if (i_fstart == nf || i_fstop == -1) {
481 out3 <<
"All frequencies are below or above the sun spectrum data";
484 const Index f_extent = i_fstop - i_fstart + 1;
486 if (out3.sufficient_priority()) {
488 os <<
" " << f_extent <<
" frequency extraction points starting at "
489 <<
"frequency index " << i_fstart <<
".\n";
497 out3 <<
"The entire data lies inbetween two f_grid points (So no f_grid"
498 <<
" point inside the data_f_grid)";
502 const ConstVectorView f_grid_active = f_grid[Range(i_fstart, f_extent)];
507 const Numeric f_grid_fmin = f_grid[i_fstart];
508 const Numeric f_grid_fmax = f_grid[i_fstop];
510 const Numeric* data_f_grid_begin = data_f_grid.unsafe_data_handle();
511 const Numeric* data_f_grid_end = data_f_grid_begin + data_f_grid.size() - 1;
512 const Index i_data_fstart =
515 std::upper_bound(data_f_grid_begin, data_f_grid_end, f_grid_fmin)) -
517 const Index i_data_fstop = std::distance(
520 data_f_grid_begin + i_data_fstart, data_f_grid_end, f_grid_fmax));
523 const Index data_f_extent = i_data_fstop - i_data_fstart + 1;
526 const Range active_range(i_data_fstart, data_f_extent);
527 const ConstVectorView data_f_grid_active = data_f_grid[active_range];
537 gridpos(f_gp, data_f_grid_active, f_grid_active, 0);
539 Matrix itw(f_gp.
nelem(), 2);
542 for(
int i=0; i < stokes_dim; i++){
543 interp(int_data(Range(i_fstart, f_extent),i), itw,
544 sun_spectrum_raw.
data(active_range, i), f_gp);
550 if (temperature == -1){
552 "f_grid is (partially) outside the sun spectrum data"
553 "Set temperature to zero to have a padding of "
554 "0 or a fitting effective temperature"
555 "For further information take a look at the "
556 "documentation for regrid_sun_spectrum")
558 if (temperature > 0){
559 for (
int i=0; i < i_fstart; i++){
560 int_data(i,0) =
planck(f_grid[i], temperature);
562 for (Index i=f_extent; i < nf; i++){
563 int_data(i,0) =
planck(f_grid[i], temperature);
Declarations for agendas.
The global header file for ARTS.
void gas_scattering_agendaExecute(Workspace &ws, PropagationMatrix &gas_scattering_coef, TransmissionMatrix &gas_scattering_mat, Vector &gas_scattering_fct_legendre, const Vector &f_grid, const Numeric rtp_pressure, const Numeric rtp_temperature, const Vector &rtp_vmr, const Vector &gas_scattering_los_in, const Vector &gas_scattering_los_out, const Index gas_scattering_output_type, const Agenda &input_agenda)
This can be used to make arrays out of anything.
Index nelem() const ARTS_NOEXCEPT
const Vector & get_numeric_grid(Index i) const
Get a numeric grid.
Helper macros for debugging.
#define ARTS_USER_ERROR(...)
void distance3D(Numeric &l, const Numeric &r1, const Numeric &lat1, const Numeric &lon1, const Numeric &r2, const Numeric &lat2, const Numeric &lon2)
distance3D
void sph2cart(Numeric &x, Numeric &y, Numeric &z, const Numeric &r, const Numeric &lat, const Numeric &lon)
sph2cart
Numeric refell2r(ConstVectorView refellipsoid, const Numeric &lat)
refell2r
Numeric pos2refell_r(const Index &atmosphere_dim, ConstVectorView refellipsoid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstVectorView rte_pos)
pos2refell_r
void poslos2cart(Numeric &x, Numeric &z, Numeric &dx, Numeric &dz, const Numeric &r, const Numeric &lat, const Numeric &za)
poslos2cart
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
void rte_losGeometricFromRtePosToRtePos2(Vector &rte_los, const Index &atmosphere_dim, const Vector &lat_grid, const Vector &lon_grid, const Vector &refellipsoid, const Vector &rte_pos, const Vector &rte_pos2, const Verbosity &)
WORKSPACE METHOD: rte_losGeometricFromRtePosToRtePos2.
void ppathFromRtePos2(Workspace &ws, Ppath &ppath, Vector &rte_los, Numeric &ppath_lraytrace, const Agenda &ppath_step_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &z_field, const Vector &f_grid, const Vector &refellipsoid, const Matrix &z_surface, const Vector &rte_pos, const Vector &rte_pos2, const Numeric &ppath_lmax, const Numeric &za_accuracy, const Numeric &pplrt_factor, const Numeric &pplrt_lowest, const Verbosity &verbosity)
WORKSPACE METHOD: ppathFromRtePos2.
void iyTransmissionStandard(Workspace &ws, Matrix &iy, ArrayOfMatrix &iy_aux, ArrayOfTensor3 &diy_dx, Vector &ppvar_p, Vector &ppvar_t, EnergyLevelMap &ppvar_nlte, Matrix &ppvar_vmr, Matrix &ppvar_wind, Matrix &ppvar_mag, Matrix &ppvar_pnd, Matrix &ppvar_f, Tensor3 &ppvar_iy, Tensor4 &ppvar_trans_cumulat, Tensor4 &ppvar_trans_partial, const Index &stokes_dim, const Vector &f_grid, const Index &atmosphere_dim, const Vector &p_grid, const Tensor3 &t_field, const EnergyLevelMap &nlte_field, const Tensor4 &vmr_field, const ArrayOfArrayOfSpeciesTag &abs_species, const Tensor3 &wind_u_field, const Tensor3 &wind_v_field, const Tensor3 &wind_w_field, const Tensor3 &mag_u_field, const Tensor3 &mag_v_field, const Tensor3 &mag_w_field, const Index &cloudbox_on, const ArrayOfIndex &cloudbox_limits, const Index &gas_scattering_do, const Tensor4 &pnd_field, const ArrayOfTensor4 &dpnd_field_dx, const ArrayOfString &scat_species, const ArrayOfArrayOfSingleScatteringData &scat_data, const ArrayOfString &iy_aux_vars, const Index &jacobian_do, const ArrayOfRetrievalQuantity &jacobian_quantities, const Ppath &ppath, const Matrix &iy_transmitter, const Agenda &propmat_clearsky_agenda, const Agenda &water_p_eq_agenda, const Agenda &gas_scattering_agenda, const Index &iy_agenda_call1, const Tensor3 &iy_transmittance, const Numeric &rte_alonglos_v, const Verbosity &)
WORKSPACE METHOD: iyTransmissionStandard.
Declarations having to do with the four output streams.
constexpr Numeric pi
The following mathematical constants are generated in python Decimal package by the code:
constexpr Numeric sigma
Stefan-Boltzmann constant convenience name [W/(K^4*m^2)].
Numeric planck(const Numeric &f, const Numeric &t)
planck
This file contains declerations of functions of physical character.
Index ppath_what_background(const Ppath &ppath)
Returns the case number for the radiative background.
The structure to describe a propagation path and releated quantities.
Matrix los
Line-of-sight at each ppath point.
Index np
Number of points describing the ppath.
Matrix pos
The distance between start pos and the last position in pos.
Radiation Vector for Stokes dimension 1-4.
void leftMul(const TransmissionMatrix &T)
Multiply radiation vector from the left.
The structure to describe a propagation path and releated quantities.
String description
Sun description.
Matrix spectrum
Sun spectrum, monochrmatic radiance spectrum at the surface of the sun.
Numeric latitude
latitude of the sun in the sky of the planet
Numeric longitude
longitude of the sun in the sky of the planet
Numeric distance
distance from center of planet to center of sun
Numeric radius
Sun radius.
Class to keep track of Transmission Matrices for Stokes Dim 1-4.
void get_direct_radiation(Workspace &ws, ArrayOfMatrix &direct_radiation, ArrayOfArrayOfTensor3 &ddirect_radiation_dx, const Index &stokes_dim, const Vector &f_grid, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &t_field, const EnergyLevelMap &nlte_field, const Tensor4 &vmr_field, const ArrayOfArrayOfSpeciesTag &abs_species, const Tensor3 &wind_u_field, const Tensor3 &wind_v_field, const Tensor3 &wind_w_field, const Tensor3 &mag_u_field, const Tensor3 &mag_v_field, const Tensor3 &mag_w_field, const Index &cloudbox_on, const ArrayOfIndex &cloudbox_limits, const Index &gas_scattering_do, const Index &irradiance_flag, const ArrayOfPpath &sun_ppaths, const ArrayOfSun &suns, const ArrayOfIndex &suns_visible, const Vector &refellipsoid, const Tensor4 &pnd_field, const ArrayOfTensor4 &dpnd_field_dx, const ArrayOfString &scat_species, const ArrayOfArrayOfSingleScatteringData &scat_data, const Index &jacobian_do, const ArrayOfRetrievalQuantity &jacobian_quantities, const Agenda &propmat_clearsky_agenda, const Agenda &water_p_eq_agenda, const Agenda &gas_scattering_agenda, const Numeric &rte_alonglos_v, const Verbosity &verbosity)
Calculates the transmitted sun radiation at the end position of the ppath.
std::ostream & operator<<(std::ostream &os, const Sun &sun)
void get_sun_ppaths(Workspace &ws, ArrayOfPpath &sun_ppaths, ArrayOfIndex &suns_visible, ArrayOfVector &sun_rte_los, const Vector &rte_pos, const ArrayOfSun &suns, const Vector &f_grid, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &z_field, const Matrix &z_surface, const Vector &refellipsoid, const Numeric &ppath_lmax, const Numeric &ppath_lraytrace, const Agenda &ppath_step_agenda, const Verbosity &verbosity)
Calculates the ppath towards the suns from a given position and indicates if sun is visible or not.
void get_sun_radiation(Matrix &iy, Index &suns_visible, const Sun &sun, const Vector &rtp_pos, const Vector &rtp_los, const Vector &refellipsoid)
Checks and adds sun radiance if sun is in line of sight.
Matrix regrid_sun_spectrum(const GriddedField2 &sun_spectrum_raw, const Vector &f_grid, const Index &stokes_dim, const Numeric &temperature, const Verbosity &verbosity)
regrid_sun_spectrum
void get_scattered_sunsource(Workspace &ws, RadiationVector &scattered_sunlight, const Vector &f_grid, const Numeric &p, const Numeric &T, const Vector &vmr, const Matrix &transmitted_sunlight, const Vector &gas_scattering_los_in, const Vector &gas_scattering_los_out, const Agenda &gas_scattering_agenda)
Calculates the radiance spectrum of sun which is scattered by the atmospheric gases.
void get_sun_background(Matrix &iy, Index &suns_visible, const ArrayOfSun &suns, const Ppath &ppath, const Vector &f_grid, const Index &stokes_dim, const Index &atmosphere_dim, const Vector &refellipsoid)
Gets the sun background for a given ppath.
Declaration of functions in star.cc.
This file contains the Workspace class.