ARTS 2.5.10 (git: 2f1c442c)
m_sun.cc
Go to the documentation of this file.
1/* Copyright (C) 2021
2 Jon Petersen <jon.petersen@studium.uni-hamburg.de>
3 Manfred Brath <manfred.brath@uni-hamburg.de>
4
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
8 later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 USA. */
19
20/*===========================================================================
21 === File description
22 ===========================================================================*/
23
24#include "matpack.h"
25#include "messages.h"
26#include "physics_funcs.h"
27#include "arts.h"
28#include "auto_md.h"
29#include "geodetic.h"
30#include "sun.h"
31#include <iostream>
32
33
47using Constant::pi;
48
49/*===========================================================================
50 === The functions
51 ===========================================================================*/
52
53/* Workspace method: Doxygen documentation will be auto-generated */
55 Index &suns_do,
56 // Inputs:
57 const Vector &f_grid,
58 const Index &stokes_dim,
59 const Numeric &radius,
60 const Numeric &distance,
61 const Numeric &temperature,
62 const Numeric &latitude,
63 const Numeric &longitude,
64 const Verbosity &) {
65
66 // some sanity checks
67 ARTS_USER_ERROR_IF (distance<radius,
68 "The distance to the center of the sun (",distance," m) \n"
69 " is smaller than the radius of the sun (", radius," m )")
70
71 Sun& new_sun = suns.emplace_back();
72
73 // spectrum
74 new_sun.spectrum=Matrix(f_grid.nelem(), stokes_dim,0. );
75
76 planck(new_sun.spectrum(joker,0), f_grid, temperature);
77 new_sun.spectrum *= pi ; // outgoing flux at the surface of the sun.
78
79
80 new_sun.description = "Blackbody sun" ;
81 new_sun.radius = radius;
82 new_sun.distance = distance;
83 new_sun.latitude = latitude;
84 new_sun.longitude = longitude;
85
86 // set flag
87 suns_do = 1;
88}
89
90/* Workspace method: Doxygen documentation will be auto-generated */
92 Index &suns_do,
93 // Inputs:
94 const Vector &f_grid,
95 const Index &stokes_dim,
96 const GriddedField2& sun_spectrum_raw,
97 const Numeric &radius,
98 const Numeric &distance,
99 const Numeric &temperature,
100 const Numeric &latitude,
101 const Numeric &longitude,
102 const String &description,
103 const Verbosity &verbosity) {
104
105 // some sanity checks
106 ARTS_USER_ERROR_IF (distance<radius,
107 "The distance to the center of the sun (",distance," m) \n"
108 " is smaller than the radius of the sun (", radius," m )")
109
110 // init sun
111 Sun& new_sun = suns.emplace_back();
112 new_sun.spectrum = regrid_sun_spectrum(sun_spectrum_raw, f_grid, stokes_dim, temperature, verbosity); // set spectrum
113 new_sun.description = description;
114 new_sun.radius = radius;
115 new_sun.distance = distance;
116 new_sun.latitude = latitude;
117 new_sun.longitude = longitude;
118
119 // set flag
120 suns_do = 1;
121
122}
123
124/* Workspace method: Doxygen documentation will be auto-generated */
126 ArrayOfSun &suns,
127 Index &suns_do,
128 // Inputs:
129 const Vector &f_grid,
130 const Index &stokes_dim,
131 const Vector &refellipsoid,
132 const GriddedField2 &sun_spectrum_raw,
133 const Numeric &radius,
134 const Numeric &distance,
135 const Numeric &temperature,
136 const Numeric &zenith,
137 const Numeric &azimuth,
138 const String &description,
139 const Numeric &location_latitude,
140 const Numeric &location_longitude,
141 const Numeric &location_altitude,
142 const Verbosity &verbosity) {
143
144 // some sanity checks
145 ARTS_USER_ERROR_IF (distance<radius,
146 "The distance to the center of the sun (",distance," m) \n"
147 "is smaller than the radius of the sun (", radius," m )")
148 ARTS_USER_ERROR_IF (location_altitude<0.,
149 "The altitude of the solar spectrum should be positiv,\n"
150 "but is ",location_altitude," m) ")
151
152 // from local position to global position
153 Numeric toa_altitude = location_altitude + refell2r(refellipsoid, location_latitude);
154
155 Numeric sun_altitude, sun_latitude, sun_longitude;
156 if (zenith < ANGTOL){
157 sun_altitude = distance + toa_altitude;
158 sun_latitude = location_latitude;
159 sun_longitude = location_longitude;
160 } else if (zenith > 180 - ANGTOL) {
161 sun_altitude = distance - toa_altitude;
162 sun_latitude = -location_latitude;
163 sun_longitude = location_longitude + 180 - 360.0 * Numeric(round((location_longitude - 0.0) / 360.0));
164 } else {
165 Numeric x, y, z, dx, dy, dz;
166 poslos2cart(x,
167 y,
168 z,
169 dx,
170 dy,
171 dz,
172 toa_altitude,
173 location_latitude,
174 location_longitude,
175 zenith,
176 azimuth);
177
178 cart2sph(sun_altitude,
179 sun_latitude,
180 sun_longitude,
181 x+distance*dx,
182 y+distance*dy,
183 z+distance*dz,
184 location_latitude,
185 location_longitude,
186 zenith, azimuth);
187 }
188
189
190 // Geometric scaling factor, scales the sun spectral irradiance at the given
191 // location to the spectral irradiance of the suns surface.
192 Numeric scale_factor = (radius*radius + distance*distance)/
193 (radius*radius);
194
195 // init sun
196 Sun& new_sun = suns.emplace_back();
197
198 new_sun.spectrum = regrid_sun_spectrum(sun_spectrum_raw, f_grid, stokes_dim, temperature, verbosity);
199 new_sun.spectrum *= scale_factor; // scale to sun surface
200
201 new_sun.description = description;
202 new_sun.radius = radius;
203 new_sun.distance = sun_altitude;
204 new_sun.latitude = sun_latitude;
205 new_sun.longitude = sun_longitude;
206
207 // set flag
208 suns_do = 1;
209
210}
211
212void sunsOff(Index &suns_do,
213 ArrayOfSun &suns,
214 const Verbosity &){
215
216 // set flag to False (default)
217 suns_do = 0;
218
219 // create empty Array of Matrix for the sun_spectrum
220 suns.resize(0);
221
222}
The global header file for ARTS.
This can be used to make arrays out of anything.
Definition: array.h:48
Index nelem() const noexcept
Returns the number of elements.
Definition: matpackI.h:547
The Matrix class.
Definition: matpackI.h:1285
The Vector class.
Definition: matpackI.h:910
#define ARTS_USER_ERROR_IF(condition,...)
Definition: debug.h:153
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:603
Numeric refell2r(ConstVectorView refellipsoid, const Numeric &lat)
refell2r
Definition: geodetic.cc:1266
void poslos2cart(Numeric &x, Numeric &z, Numeric &dx, Numeric &dz, const Numeric &r, const Numeric &lat, const Numeric &za)
poslos2cart
Definition: geodetic.cc:356
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:54
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:125
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:91
void sunsOff(Index &suns_do, ArrayOfSun &suns, const Verbosity &)
WORKSPACE METHOD: sunsOff.
Definition: m_sun.cc:212
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
const Joker joker
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:56
The structure to describe a propagation path and releated quantities.
Definition: sun.h:58
String description
Sun description.
Definition: sun.h:60
Matrix spectrum
Sun spectrum, monochrmatic radiance spectrum at the surface of the sun.
Definition: sun.h:62
Numeric latitude
latitude of the sun in the sky of the planet
Definition: sun.h:68
Numeric longitude
longitude of the sun in the sky of the planet
Definition: sun.h:70
Numeric distance
distance from center of planet to center of sun
Definition: sun.h:66
Numeric radius
Sun radius.
Definition: sun.h:64
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:466
Declaration of functions in star.cc.