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++) {
74 if (!(in = fopen(argv[iarg],
"r")))
82 for (ids = 0; ids < gps->
nds; ids++) {
85 if (!gsl_finite(gps->
th[ids]))
89 if (argv[3][0] !=
'-') {
91 for (iz = 0; iz < gps->
nz[ids]; iz++) {
92 if (gps->
z[ids][iz] < sz[0] || gps->
z[ids][iz] > sz[sn - 1])
95 idx = locate_irr(sz, sn, gps->
z[ids][iz]);
97 LIN(sz[idx], se[idx], sz[idx + 1], se[idx + 1],
100 if (gsl_finite(gps->
t[ids][iz]) && gps->
pt[ids][iz]) {
101 gps->
pt[ids][iz] *= w;
102 wmax = GSL_MAX(w, wmax);
103 wsum2 += gsl_pow_2(w);
106 for (iz = 0; iz < gps->
nz[ids]; iz++)
107 gps->
pt[ids][iz] /= wmax;
108 wsum2 /= gsl_pow_2(wmax);
112 ptmin = ptmax = var = 0;
113 for (iz = 0; iz < gps->
nz[ids]; iz++)
114 if (gsl_finite(gps->
pt[ids][iz])) {
115 ptmin = GSL_MIN(ptmin, gps->
pt[ids][iz]);
116 ptmax = GSL_MAX(ptmax, gps->
pt[ids][iz]);
117 var += gsl_pow_2(gps->
pt[ids][iz]) / wsum2;
121 fprintf(out,
"%.2f %g %g %g %g %g\n", gps->
time[ids],
122 gps->
lon[ids][gps->
nz[ids] / 2],
123 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].