36 static double ptmin, ptmax, se[
NZ], sz[
NZ], w, wmax, wsum2 = 1.0, var;
38 static int iarg, ids, idx, iz, sn;
45 ERRMSG(
"Give parameters: <ctl> <events.tab> <sens.tab> "
46 "<gps1.nc> [<gps2.nc> ...]");
49 printf(
"Write event data: %s\n", argv[2]);
50 if (!(out = fopen(argv[2],
"w")))
51 ERRMSG(
"Cannot create file!");
56 "# $2 = longitude [deg]\n"
57 "# $3 = latitude [deg]\n"
58 "# $4 = minimum perturbation [K]\n"
59 "# $5 = maximum perturbation [K]\n"
60 "# $6 = temperature variance [K^2]\n\n");
63 if (argv[3][0] !=
'-') {
64 read_shape(argv[3], sz, se, &sn);
66 ERRMSG(
"Too many data points!");
70 for (iarg = 4; iarg < argc; iarg++) {
73 if (!(in = fopen(argv[iarg],
"r")))
81 for (ids = 0; ids < gps->
nds; ids++) {
84 if (!gsl_finite(gps->
th[ids]))
88 if (argv[3][0] !=
'-') {
90 for (iz = 0; iz < gps->
nz[ids]; iz++) {
91 if (gps->
z[ids][iz] < sz[0] || gps->
z[ids][iz] > sz[sn - 1])
94 idx = locate_irr(sz, sn, gps->
z[ids][iz]);
96 LIN(sz[idx], se[idx], sz[idx + 1], se[idx + 1],
99 if (gsl_finite(gps->
t[ids][iz]) && gps->
pt[ids][iz]) {
100 gps->
pt[ids][iz] *= w;
101 wmax = GSL_MAX(w, wmax);
102 wsum2 += gsl_pow_2(w);
105 for (iz = 0; iz < gps->
nz[ids]; iz++)
106 gps->
pt[ids][iz] /= wmax;
107 wsum2 /= gsl_pow_2(wmax);
111 ptmin = ptmax = var = 0;
112 for (iz = 0; iz < gps->
nz[ids]; iz++)
113 if (gsl_finite(gps->
pt[ids][iz])) {
114 ptmin = GSL_MIN(ptmin, gps->
pt[ids][iz]);
115 ptmax = GSL_MAX(ptmax, gps->
pt[ids][iz]);
116 var += gsl_pow_2(gps->
pt[ids][iz]) / wsum2;
120 fprintf(out,
"%.2f %g %g %g %g %g\n", gps->
time[ids],
121 gps->
lon[ids][gps->
nz[ids] / 2],
122 gps->
lat[ids][gps->
nz[ids] / 2], ptmin, ptmax, var);
int main(int argc, char *argv[])
void read_gps(char *filename, gps_t *gps)
Read GPS-RO data file.
GPS Code Collection library declarations.
#define NZ
Maximum number of altitudes per GPS-RO profile.
double time[NDS]
Time (seconds since 2000-01-01T00:00Z).
double pt[NDS][NZ]
Temperature perturbation [K].
double t[NDS][NZ]
Temperature [K].
int nz[NDS]
Number of altitudes per profile.
double lon[NDS][NZ]
Longitude [deg].
int nds
Number of profiles.
double th[NDS]
Tropopause height [km].
double z[NDS][NZ]
Altitude [km].
double lat[NDS][NZ]
Latitude [deg].