-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathMetFunction.hpp
More file actions
85 lines (65 loc) · 3.32 KB
/
MetFunction.hpp
File metadata and controls
85 lines (65 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* */
/* Aircraft Plume Chemistry, Emission and Microphysics Model */
/* (APCEMM) */
/* */
/* MetFunction Header File */
/* */
/* Author : Thibaud M. Fritz */
/* Time : 11/2/2018 */
/* File : MetFunction.hpp */
/* */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
#ifndef METFUNCTION_H_INCLUDED
#define METFUNCTION_H_INCLUDED
#include <cmath>
#include "ForwardDecl.hpp"
#define ABS(x) ( ((x) >= 0 ) ?(x):(-x) )
namespace met
{
/* Defined meteorological functions */
/* International Standard Atmosphere (ISA) */
const double ISA_LAPSERATE = 6.5E-03;
const double ISA_HTS = 1.1E+04;
const double ISA_HTP = 2.0E+04;
const double ISA_RHO0 = 1.225E+00;
const double ISA_P0 = 101325;
const double ISA_T0 = 288.15;
void ISA( const double &z, double &pressure, \
double &temperature );
void ISA( const Vector_1D &z, Vector_1D &pressure, \
Vector_1D &temperature );
void ISA( const double &z, double &pressure );
void ISA( const Vector_1D &z, Vector_1D &pressure );
void ISA_pAlt( double &z, const double &pressure );
void ISA_pAlt( Vector_1D &z, const Vector_1D &pressure );
double ComputeLapseRate( const double TEMP, const double RHi, \
const double DEPTH );
std::size_t nearestNeighbor( const Vector_1D& xq, double x);
double linearInterp( const Vector_1D& xq, const Vector_1D& yq, double x );
double linearInterp( double x1, double y1, double x2, double y2, double xq, bool support_extrapolation = false);
double linInterpMetData(const Vector_1D& altitude_init, const Vector_1D& metVar_init, double altitude_query);
double satdepth_calc( const Vector_1D& RHi, const Vector_1D& alt, int iFlight, double YLIM_DOWN);
inline double rhiCorrection( double rhi, double a = 0.9779, double b = 1.635 ) {
/*
@param: rhi - Relative humidity wrt ice in %
@return: "Corrected" rhi to be biased in favor of ISSRs in %
Source: Teoh et al (2022)
"Aviation contrail climate effects in the North Atlantic from 2016 to 2021"
Atmospheric Chemistry and Physics
https://doi.org/10.5194/acp-22-10919-2022
*/
double rhi_abs = rhi * 0.01;
double rhi_abs_a = rhi_abs / a;
double rhi_corr = (rhi_abs_a) <= 1
? rhi_abs_a
: std::min(std::pow(rhi_abs_a, b), 1.65);
return rhi_corr * 100.0;
}
struct newXCoordsPair {
Vector_1D x0_new;
Vector_1D dx_new;
};
newXCoordsPair calcNewXCoords(const Vector_1D& dy_old, const Vector_1D& dy_new, const Vector_1D& x0_old, const Vector_1D& dx_old, int nx);
}
#endif /* METFUNCTION_H_INCLUDED */