11 bool do_plane_parallel,
12 const blitz::Array<double, 1>& sza_values,
15 straightline_geometry(do_plane_parallel, rearth, heights, sza_values, chapmanfactors_, toa_nadir_szangles_, toa_entry_szangles_);
20 const blitz::Array<double, 1>& sza_values,
24 refractive_geometry(rearth, heights, refr_index, sza_values, chapmanfactors_, toa_nadir_szangles_, toa_entry_szangles_);
33 Array<double, 1> sza_values(1);
36 std::vector<boost::shared_ptr<AtmRefractiveIndex> > refr_index_arr;
37 refr_index_arr.push_back(refr_index);
39 refractive_geometry(rearth, heights, refr_index_arr, sza_values, chapmanfactors_, toa_nadir_szangles_, toa_entry_szangles_);
45 Array<AutoDerivative<double>, 1> trans(chapmanfactors_.extent(secondDim));
46 for(
int ib = 0; ib < chapmanfactors_.extent(secondDim); ib++) {
47 trans(ib) = transmittance(extinction, ib);
56 for(
int n = 0; n < chapmanfactors_.extent(firstDim); n++) {
59 if ( arg < 32.0e0 ) tr = exp ( - arg );
70 bool do_plane_parallel,
73 const blitz::Array<double, 1>& sza_values,
81 int nlayers = heights.extent(firstDim)-1;
82 int nbeams = sza_values.extent(firstDim);
85 chapmanfactors.resize(nlayers,nbeams);
86 toa_nadir_szangles.resize(nbeams);
87 toa_entry_szangles.resize(nbeams);
89 Array<AutoDerivative<double>, 1> radii(nlayers+1);
92 toa_nadir_szangles = 0.0e0;
93 toa_entry_szangles = 0.0e0;
94 chapmanfactors = 0.0e0;
97 double dtr = atan(1.0e0)/45.0e0;
100 for(
int n = 0; n < nlayers+1; n++)
101 radii(n) = rearth + heights(n);
105 for(
int ibeam = 0; ibeam < nbeams; ibeam++) {
108 double xboa = sza_values(ibeam);
109 toa_nadir_szangles(ibeam) = xboa;
110 double xboa_r = xboa * dtr;
111 double mu_boa = cos(xboa_r);
113 if ( do_plane_parallel ) {
116 toa_entry_szangles (ibeam) = xboa;
117 for(
int k = 0; k < nlayers; k++)
118 chapmanfactors(k,ibeam) = 1.0e0 / mu_boa;
124 double gm_boa = sqrt(1.0e0 - mu_boa*mu_boa);
127 toa_entry_szangles(ibeam) = sth1 / dtr;
130 for(
int k = 0; k < nlayers; k++) {
138 chapmanfactors(k,ibeam) = dist / delz;
155 const blitz::Array<double, 1>& sza_values,
162 int nlayers = heights.extent(firstDim)-1;
163 int nbeams = sza_values.extent(firstDim);
165 if((
int) refr_index.size() != nbeams) {
167 err <<
"Number of refractive index objects: " << refr_index.size()
168 <<
" does not match number of solar zenith angles: " << nbeams;
175 chapmanfactors.resize(nlayers,nbeams);
176 toa_nadir_szangles.resize(nbeams);
177 toa_entry_szangles.resize(nbeams);
185 double changeheight = 20.0e0;
188 int max_nquads = 100;
191 Array<AutoDerivative<double>, 2> rtimesn(nlayers+1,nbeams);
192 Array<AutoDerivative<double>, 1> radii(nlayers+1);
195 Array<int, 1> nquad(nlayers);
198 Array<AutoDerivative<double>, 2> fineweight (nlayers,max_nquads);
199 Array<AutoDerivative<double>, 2> fineradii (nlayers,max_nquads);
200 Array<AutoDerivative<double>, 3> finersqnsq (nlayers,max_nquads,nbeams);
203 toa_nadir_szangles = 0.0e0;
204 toa_entry_szangles = 0.0e0;
205 chapmanfactors = 0.0e0;
206 Range ra = Range::all();
209 double dtr = atan(1.0e0)/45.0e0;
212 for (
int i = 0; i <= nlayers; i++) {
213 radii(i) = rearth + heights(i);
214 for(
int ibeam = 0; ibeam < nbeams; ibeam++)
215 rtimesn(i, ibeam) = radii(i) * refr_index[ibeam]->at_level(i);
220 ( rearth, nlower, nupper, changeheight, heights, refr_index,
221 fineweight, fineradii, finersqnsq, nquad );
225 for(
int ibeam = 0; ibeam < nbeams; ibeam++) {
228 double xboa = sza_values(ibeam);
231 Array<AutoDerivative<double>, 1> distances(nlayers);
234 ( nlayers, xboa, dtr, rtimesn(ra, ibeam), nquad,
235 fineweight, fineradii, finersqnsq(ra, ra, ibeam),
236 distances, alpha, xtoa );
239 toa_nadir_szangles (ibeam) = xtoa;
240 toa_entry_szangles (ibeam) = alpha;
241 for(
int k = nlayers-1; k >= 0; k--) {
243 chapmanfactors(k,ibeam) = distances(k) / delz;
255 const blitz::Array<int, 1>& nquad,
267 int nlayers = rtimesn.extent(firstDim)-1;
270 distances.resize(nlayers);
277 double theta_r = theta*dtr;
278 double sintheta = sin(theta_r);
281 alpha = asin(raycons/rtimesn(0))/dtr;
284 for(
int i = start_lay-1; i >= 0; i--) {
286 for(
int k = 0; k < nquad(i); k++) {
290 sum = sum + fineweight(i,k) * Xik;
297 for(
int i = start_lay-1; i >= 0; i--) {
299 for(
int k = 0; k < nquad(i); k++) {
301 sum = sum + fineweight(i,k)/help/fineradii(i,k);
303 phi_rad = phi_rad + sum;
310 anglefunc = phicum + alpha;
328 blitz::Array<int, 1>& nquad)
335 int nlayers = heights.extent(firstDim)-1;
336 int max_nquads = fineweight.extent(secondDim);
345 for(
int i = 0; i < nlayers; i++) {
347 if (heights(i) > changeheight)
351 Array<AutoDerivative<double>, 1> xgrid(max_nquads);
352 Array<AutoDerivative<double>, 1> wgrid(max_nquads);
355 for(
int i = 0; i < nlayers; i++) {
356 rf_gauleg(heights(i+1), heights(i), xgrid, wgrid, nquad(i));
358 for(
int k = 0; k < nquad(i); k++) {
359 fineradii(i,k) = rearth + xgrid(k);
360 fineweight(i,k) = wgrid(k);
362 for(
int beam_idx = 0; beam_idx < finersqnsq.extent(thirdDim); beam_idx++) {
364 finersqnsq(i,k,beam_idx) =
pow(fineradii(i,k), 2) *
pow(fn, 2);
void refractive_geometry(double rearth, const blitz::Array< AutoDerivative< double >, 1 > &heights, const std::vector< boost::shared_ptr< AtmRefractiveIndex > > &refr_index, const blitz::Array< double, 1 > &sza_values, blitz::Array< AutoDerivative< double >, 2 > &chapmanfactors, blitz::Array< AutoDerivative< double >, 1 > &toa_nadir_szangles, blitz::Array< AutoDerivative< double >, 1 > &toa_entry_szangles)
void rf_gauleg(AutoDerivative< double > X1, AutoDerivative< double > X2, blitz::Array< AutoDerivative< double >, 1 > &X, blitz::Array< AutoDerivative< double >, 1 > &W, int KNUM)
void full_gridding(double rearth, int nlower, int nupper, double changeheight, const blitz::Array< AutoDerivative< double >, 1 > &heights, const std::vector< boost::shared_ptr< AtmRefractiveIndex > > &refr_index, blitz::Array< AutoDerivative< double >, 2 > &fineweight, blitz::Array< AutoDerivative< double >, 2 > &fineradii, blitz::Array< AutoDerivative< double >, 3 > &finersqnsq, blitz::Array< int, 1 > &nquad)
Output partial and whole layer fine gridding: nquad
This is the base of the exception hierarchy for Full Physics code.
void straightline_geometry(bool do_plane_parallel, double rearth, const blitz::Array< AutoDerivative< double >, 1 > &heights, const blitz::Array< double, 1 > &sza_values, blitz::Array< AutoDerivative< double >, 2 > &chapmanfactors, blitz::Array< AutoDerivative< double >, 1 > &toa_nadir_szangles, blitz::Array< AutoDerivative< double >, 1 > &toa_entry_szangles)
Free functions translated from Fortran.
Apply value function to a blitz array.
void refractive_bending(int start_lay, double theta, double dtr, const blitz::Array< AutoDerivative< double >, 1 > &rtimesn, const blitz::Array< int, 1 > &nquad, const blitz::Array< AutoDerivative< double >, 2 > &fineweight, const blitz::Array< AutoDerivative< double >, 2 > &fineradii, const blitz::Array< AutoDerivative< double >, 2 > &finersqnsq, blitz::Array< AutoDerivative< double >, 1 > &distances, AutoDerivative< double > &alpha, AutoDerivative< double > &anglefunc)
Unit pow(const Unit &Dunit, const boost::rational< int > &Exponent)
ChapmanBOA(double rearth, bool do_plane_parallel, const blitz::Array< double, 1 > &sza_values, const blitz::Array< AutoDerivative< double >, 1 > &heights)
Straight line geometry constructor.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
const blitz::Array< AutoDerivative< double >, 1 > transmittance(const blitz::Array< AutoDerivative< double >, 1 > &extinction) const
Compute transmittance using molecular extinction and pre-computed angles.