ARTS 2.5.11 (git: 725533f0)
m_sun.cc
Go to the documentation of this file.
1/*===========================================================================
2 === File description
3 ===========================================================================*/
4
5#include "matpack_concepts.h"
6#include "messages.h"
7#include "physics_funcs.h"
8#include "arts.h"
9#include "auto_md.h"
10#include "geodetic.h"
11#include "sun.h"
12#include <iostream>
13
14
28using Constant::pi;
29
30/*===========================================================================
31 === The functions
32 ===========================================================================*/
33
34/* Workspace method: Doxygen documentation will be auto-generated */
36 Index &suns_do,
37 // Inputs:
38 const Vector &f_grid,
39 const Index &stokes_dim,
40 const Numeric &radius,
41 const Numeric &distance,
42 const Numeric &temperature,
43 const Numeric &latitude,
44 const Numeric &longitude,
45 const Verbosity &) {
46
47 // some sanity checks
48 ARTS_USER_ERROR_IF (distance<radius,
49 "The distance to the center of the sun (",distance," m) \n"
50 " is smaller than the radius of the sun (", radius," m )")
51
52 Sun& new_sun = suns.emplace_back();
53
54 // spectrum
55 new_sun.spectrum=Matrix(f_grid.nelem(), stokes_dim,0. );
56
57 planck(new_sun.spectrum(joker,0), f_grid, temperature);
58 new_sun.spectrum *= pi ; // outgoing flux at the surface of the sun.
59
60
61 new_sun.description = "Blackbody sun" ;
62 new_sun.radius = radius;
63 new_sun.distance = distance;
64 new_sun.latitude = latitude;
65 new_sun.longitude = longitude;
66
67 // set flag
68 suns_do = 1;
69}
70
71/* Workspace method: Doxygen documentation will be auto-generated */
73 Index &suns_do,
74 // Inputs:
75 const Vector &f_grid,
76 const Index &stokes_dim,
77 const GriddedField2& sun_spectrum_raw,
78 const Numeric &radius,
79 const Numeric &distance,
80 const Numeric &temperature,
81 const Numeric &latitude,
82 const Numeric &longitude,
83 const String &description,
84 const Verbosity &verbosity) {
85
86 // some sanity checks
87 ARTS_USER_ERROR_IF (distance<radius,
88 "The distance to the center of the sun (",distance," m) \n"
89 " is smaller than the radius of the sun (", radius," m )")
90
91 // init sun
92 Sun& new_sun = suns.emplace_back();
93 new_sun.spectrum = regrid_sun_spectrum(sun_spectrum_raw, f_grid, stokes_dim, temperature, verbosity); // set spectrum
94 new_sun.description = description;
95 new_sun.radius = radius;
96 new_sun.distance = distance;
97 new_sun.latitude = latitude;
98 new_sun.longitude = longitude;
99
100 // set flag
101 suns_do = 1;
102
103}
104
105/* Workspace method: Doxygen documentation will be auto-generated */
107 ArrayOfSun &suns,
108 Index &suns_do,
109 // Inputs:
110 const Vector &f_grid,
111 const Index &stokes_dim,
112 const Vector &refellipsoid,
113 const GriddedField2 &sun_spectrum_raw,
114 const Numeric &radius,
115 const Numeric &distance,
116 const Numeric &temperature,
117 const Numeric &zenith,
118 const Numeric &azimuth,
119 const String &description,
120 const Numeric &location_latitude,
121 const Numeric &location_longitude,
122 const Numeric &location_altitude,
123 const Verbosity &verbosity) {
124
125 // some sanity checks
126 ARTS_USER_ERROR_IF (distance<radius,
127 "The distance to the center of the sun (",distance," m) \n"
128 "is smaller than the radius of the sun (", radius," m )")
129 ARTS_USER_ERROR_IF (location_altitude<0.,
130 "The altitude of the solar spectrum should be positiv,\n"
131 "but is ",location_altitude," m) ")
132
133 // from local position to global position
134 Numeric toa_altitude = location_altitude + refell2r(refellipsoid, location_latitude);
135
136 Numeric sun_altitude, sun_latitude, sun_longitude;
137 if (zenith < ANGTOL){
138 sun_altitude = distance + toa_altitude;
139 sun_latitude = location_latitude;
140 sun_longitude = location_longitude;
141 } else if (zenith > 180 - ANGTOL) {
142 sun_altitude = distance - toa_altitude;
143 sun_latitude = -location_latitude;
144 sun_longitude = location_longitude + 180 - 360.0 * Numeric(round((location_longitude - 0.0) / 360.0));
145 } else {
146 Numeric x, y, z, dx, dy, dz;
147 poslos2cart(x,
148 y,
149 z,
150 dx,
151 dy,
152 dz,
153 toa_altitude,
154 location_latitude,
155 location_longitude,
156 zenith,
157 azimuth);
158
159 cart2sph(sun_altitude,
160 sun_latitude,
161 sun_longitude,
162 x+distance*dx,
163 y+distance*dy,
164 z+distance*dz,
165 location_latitude,
166 location_longitude,
167 zenith, azimuth);
168 }
169
170
171 // Geometric scaling factor, scales the sun spectral irradiance at the given
172 // location to the spectral irradiance of the suns surface.
173 Numeric scale_factor = (radius*radius + distance*distance)/
174 (radius*radius);
175
176 // init sun
177 Sun& new_sun = suns.emplace_back();
178
179 new_sun.spectrum = regrid_sun_spectrum(sun_spectrum_raw, f_grid, stokes_dim, temperature, verbosity);
180 new_sun.spectrum *= scale_factor; // scale to sun surface
181
182 new_sun.description = description;
183 new_sun.radius = radius;
184 new_sun.distance = sun_altitude;
185 new_sun.latitude = sun_latitude;
186 new_sun.longitude = sun_longitude;
187
188 // set flag
189 suns_do = 1;
190
191}
192
193void sunsOff(Index &suns_do,
194 ArrayOfSun &suns,
195 const Verbosity &){
196
197 // set flag to False (default)
198 suns_do = 0;
199
200 // create empty Array of Matrix for the sun_spectrum
201 suns.resize(0);
202
203}
The global header file for ARTS.
This can be used to make arrays out of anything.
Definition array.h:31
#define ARTS_USER_ERROR_IF(condition,...)
Definition debug.h:137
void cart2sph(Numeric &r, Numeric &lat, Numeric &lon, const Numeric &x, const Numeric &y, const Numeric &z, const Numeric &lat0, const Numeric &lon0, const Numeric &za0, const Numeric &aa0)
cart2sph
Definition geodetic.cc:585
Numeric refell2r(ConstVectorView refellipsoid, const Numeric &lat)
refell2r
Definition geodetic.cc:1248
void poslos2cart(Numeric &x, Numeric &z, Numeric &dx, Numeric &dz, const Numeric &r, const Numeric &lat, const Numeric &za)
poslos2cart
Definition geodetic.cc:338
void sunsAddSingleBlackbody(ArrayOfSun &suns, Index &suns_do, const Vector &f_grid, const Index &stokes_dim, const Numeric &radius, const Numeric &distance, const Numeric &temperature, const Numeric &latitude, const Numeric &longitude, const Verbosity &)
WORKSPACE METHOD: sunsAddSingleBlackbody.
Definition m_sun.cc:35
void sunsAddSingleFromGridAtLocation(ArrayOfSun &suns, Index &suns_do, const Vector &f_grid, const Index &stokes_dim, const Vector &refellipsoid, const GriddedField2 &sun_spectrum_raw, const Numeric &radius, const Numeric &distance, const Numeric &temperature, const Numeric &zenith, const Numeric &azimuth, const String &description, const Numeric &location_latitude, const Numeric &location_longitude, const Numeric &location_altitude, const Verbosity &verbosity)
WORKSPACE METHOD: sunsAddSingleFromGridAtLocation.
Definition m_sun.cc:106
void sunsAddSingleFromGrid(ArrayOfSun &suns, Index &suns_do, const Vector &f_grid, const Index &stokes_dim, const GriddedField2 &sun_spectrum_raw, const Numeric &radius, const Numeric &distance, const Numeric &temperature, const Numeric &latitude, const Numeric &longitude, const String &description, const Verbosity &verbosity)
WORKSPACE METHOD: sunsAddSingleFromGrid.
Definition m_sun.cc:72
void sunsOff(Index &suns_do, ArrayOfSun &suns, const Verbosity &)
WORKSPACE METHOD: sunsOff.
Definition m_sun.cc:193
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:
Numeric planck(const Numeric &f, const Numeric &t)
planck
This file contains declerations of functions of physical character.
constexpr Numeric ANGTOL
Width of zenith and nadir directions.
Definition ppath.h:39
The structure to describe a propagation path and releated quantities.
Definition sun.h:38
String description
Sun description.
Definition sun.h:40
Matrix spectrum
Sun spectrum, monochrmatic radiance spectrum at the surface of the sun.
Definition sun.h:42
Numeric latitude
latitude of the sun in the sky of the planet
Definition sun.h:48
Numeric longitude
longitude of the sun in the sky of the planet
Definition sun.h:50
Numeric distance
distance from center of planet to center of sun
Definition sun.h:46
Numeric radius
Sun radius.
Definition sun.h:44
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
Definition sun.cc:446
Declaration of functions in star.cc.