18 inline double sqr(
double x) {
return x * x;}
62 const double d2r=3.14159265/180;
63 const double gm=3.9862216e+14;
64 const double omega=7.292116E-05;
65 const double con=.006738;
66 const double shc=1.6235e-03;
67 const double eqrad=6378178;
68 const double ge=gm/
sqr(eqrad);
71 gclat=atan(tan(d2r*gdlat)/(1+con));
72 radius=1000*altit+eqrad/sqrt(1.+con*
sqr(sin(gclat)));
75 return (ge*(1-shc*(3*
sqr(sin(gclat))-1)/ff)/ff-hh*
sqr(cos(gclat)))
76 *(1+0.5*
sqr(sin(gclat)*cos(gclat)*(hh/ge+2*shc/
sqr(ff))));
93 void AltitudeHydrostatic::altitude_calc
105 Array<AutoDerivative<double>, 1> pg(press_grid.
convert(
units::Pa).value.to_array());
116 altv(altv.rows() - 1) = (surface_height.value < 0 ? 0 :
117 surface_height.convert(
units::km).value);
120 for(
int lev_idx = pg.rows() - 1; lev_idx > 0; lev_idx--) {
124 for(
int sub_count = 0; sub_count < num_sublayer; sub_count++) {
125 int sub_idx = (lev_idx-1) * num_sublayer + num_sublayer - sub_count - 1;
127 psublayer(sub_idx) = plo + 0.5 * dp;
133 gravv(sub_idx) = gravity_calc(latitude.convert(
units::deg).value, zlo);
135 gravv(sub_idx) = gravity_calc(latitude.convert(
units::deg).value, zlo+0.5*dz);
138 altv(lev_idx-1) = zlo;
141 std::vector<AutoDerivative<double> > plevlist;
142 std::vector<AutoDerivative<double> > altlist;
143 for(
int i = 0; i < pg.rows(); ++i) {
144 plevlist.push_back(pg(i));
145 altlist.push_back(altv(i));
147 std::vector<AutoDerivative<double> > playlist;
148 std::vector<AutoDerivative<double> > glist;
149 for(
int i = 0; i < psublayer.rows(); ++i) {
150 playlist.push_back(psublayer(i));
151 glist.push_back(gravv(i));
153 alt.reset(
new lin_type(plevlist.begin(), plevlist.end(), altlist.begin()));
154 grav.reset(
new lin_type(playlist.begin(), playlist.end(), glist.begin()));
165 : cache_is_stale(
true),
167 surface_height(Surface_height),
170 num_sublayer(Num_sublayer)
172 p->add_observer(*
this);
173 t->add_observer(*
this);
185 void AltitudeHydrostatic::calc_alt_and_grav()
const 191 Array<AutoDerivative<double>, 1> tgrid(pgrid.rows());
192 for(
int i = 0; i < tgrid.rows(); ++i)
196 cache_is_stale =
false;
ArrayAdWithUnit< T, D > convert(const Unit &R) const
Convert to the given units.
The class handles the calculation of the altitude and gravity constants.
This class handles the calculation of the altitude an gravity constants, automatically updating with ...
const Unit Pa("Pa", N/(m *m))
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
AltitudeHydrostatic(const boost::shared_ptr< Pressure > &P, const boost::shared_ptr< Temperature > &T, const DoubleWithUnit &Latitude, const DoubleWithUnit &Surface_height, const int Num_sublayer=10)
Constructor.
Apply value function to a blitz array.
int number_variable() const
const Unit K("K", 1.0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)
const double molar_weight_dry_air
Molar weight of dry air, in g mol^-1.
We frequently have a double with units associated with it.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
#define REGISTER_LUA_END()
const Unit km("km", 1e3 *m)
virtual boost::shared_ptr< Altitude > clone() const
Clone an Altitude object.
const Unit deg("deg", pi/180.0 *rad)
const double gas_constant
Gas constant from the ideal gas law, in J mol-1 K-1.