Compute standard atmosphere pressure given altitude. More...
#include <utils.h>
Go to the source code of this file.
Defines | |
#define | NLAYERS 7 |
Functions | |
void | alt_to_press (double *pres, double *alt, int ni, int nj) |
Compute standard atmosphere pressure given altitude. |
Compute standard atmosphere pressure given altitude.
Definition in file alt_to_press.c.
void alt_to_press | ( | double * | pres, | |
double * | alt, | |||
int | ni, | |||
int | nj | |||
) |
Compute standard atmosphere pressure given altitude.
[out] | pres | Standard pressure in hPa |
[in] | alt | Input 2D altitude in meters |
[in] | ni | First dimension |
[in] | nj | Second dimension |
Definition at line 58 of file alt_to_press.c.
References K_GMR.
Referenced by output_downscaled_analog().
00058 { 00059 00067 /* 00068 ; Convert an array of (pressure-) altitudes (m) into an array of 00069 ; pressures (hPa) using the ICAO standard atmosphere definition 00070 ; 00071 ; See <A HREF="http://www.pdas.com/coesa.htm">exact definition 00072 ; here<\A> 00073 ; 00074 ; The 7 layers of the US standard atmosphere are: 00075 ; 00076 ; h1 h2 dT/dh h1,h2 geopotential alt in km 00077 ; 0 11 -6.5 dT/dh in K/km 00078 ; 11 20 0.0 00079 ; 20 32 1.0 00080 ; 32 47 2.8 00081 ; 47 51 0.0 00082 ; 51 71 -2.8 00083 ; 71 84.852 -2.0 00084 */ 00085 00086 #define NLAYERS 7 00088 int i; /* Loop counter */ 00089 int layr; /* Loop counter */ 00090 00091 double limits[NLAYERS+1]; 00092 double lapse_rate[NLAYERS]; 00093 int isoth[NLAYERS]; 00094 double presb[NLAYERS]; 00095 double tb[NLAYERS]; 00096 00097 int layer = 0; 00098 00099 /* Layer boundaries in m */ 00100 limits[0] = 0.0; 00101 limits[1] = 11.0 * 1000.0; 00102 limits[2] = 20.0 * 1000.0; 00103 limits[3] = 32.0 * 1000.0; 00104 limits[4] = 47.0 * 1000.0; 00105 limits[5] = 51.0 * 1000.0; 00106 limits[6] = 71.0 * 1000.0; 00107 limits[7] = 84.852 * 1000.0; 00108 00109 /* Lapse rates in each layer (9 means 0) */ 00110 lapse_rate[0] = -6.5 / 1000.0; 00111 lapse_rate[1] = 9.0; 00112 lapse_rate[2] = 1.0 / 1000.0; 00113 lapse_rate[3] = 2.8 / 1000.0; 00114 lapse_rate[4] = 9.0; 00115 lapse_rate[5] = -2.8 / 1000.0; 00116 lapse_rate[6] = -2.0 / 1000.0; 00117 00118 /* Flag for isothermal layers */ 00119 isoth[0] = 0; 00120 isoth[1] = 1; 00121 isoth[2] = 0; 00122 isoth[3] = 0; 00123 isoth[4] = 1; 00124 isoth[5] = 0; 00125 isoth[6] = 0; 00126 00127 presb[0] = 1013.25; 00128 tb[0] = 288.15; 00129 00130 /* Loop over layers and get pressures and temperatures at level tops */ 00131 for (i=0; i<(NLAYERS-1); i++) { 00132 tb[i+1] = tb[i] + (1-isoth[i]) * lapse_rate[i] * (limits[i+1] - limits[i]); 00133 presb[i+1] = (1-isoth[i]) * presb[i] * exp(log(tb[i]/tb[i+1]) * K_GMR / lapse_rate[i]) + 00134 isoth[i] * presb[i] * exp(-K_GMR * (limits[i+1]-limits[i]) / tb[i]); 00135 } 00136 00137 for (i=0; i<(ni*nj); i++) { 00138 /* Now calculate which layer each value belongs to */ 00139 for (layr=0; layr<NLAYERS; layr++) { 00140 if ( (limits[layr] - alt[i]) > 0.0 ) { 00141 layer = layr - 1; 00142 layr = NLAYERS + 1; 00143 } 00144 } 00145 if (layer < 0) layer = 0; 00146 if (layer > (NLAYERS-1)) layer = NLAYERS - 1; 00147 00148 /* Corresponding pressure */ 00149 pres[i] = isoth[layer] * presb[layer] * exp(-K_GMR * (alt[i] - limits[layer]) / tb[layer]) + 00150 (1-isoth[layer]) * presb[layer] * pow( ( tb[layer] / ( tb[layer] + lapse_rate[layer] * 00151 (alt[i] - limits[layer]) ) ), (K_GMR/lapse_rate[layer]) ); 00152 } 00153 00154 }