GPS Code Collection
prof.c
Go to the documentation of this file.
1/*
2 This file is part of the GPS Code Collection.
3
4 the GPS Code Collections is free software: you can redistribute it
5 and/or modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation, either version 3 of
7 the License, or (at your option) any later version.
8
9 The GPS Code Collection is distributed in the hope that it will be
10 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with the GPS Code Collection. If not, see
16 <http://www.gnu.org/licenses/>.
17
18 Copyright (C) 2019-2025 Forschungszentrum Juelich GmbH
19*/
20
26#include "libgps.h"
27
28int main(
29 int argc,
30 char *argv[]) {
31
32 gps_t *gps;
33
34 FILE *out;
35
36 int ids, iz;
37
38 /* Allocate... */
39 ALLOC(gps, gps_t, 1);
40
41 /* Check arguments... */
42 if (argc < 4)
43 ERRMSG("Give parameters: <ctl> <gps.nc> <prof.tab>");
44
45 /* Get control parameters... */
46 ids = (int) scan_ctl(argc, argv, "IDS", -1, "0", NULL);
47
48 /* Read gps data... */
49 read_gps(argv[2], gps);
50
51 /* Check profile number... */
52 if (ids < 0 || ids > gps->nds)
53 ERRMSG("Profile not available!");
54
55 /* Create output file... */
56 printf("Write profile data: %s\n", argv[3]);
57 if (!(out = fopen(argv[3], "w")))
58 ERRMSG("Cannot create file!");
59
60 /* Write header... */
61 fprintf(out,
62 "# $1 = time [sec]\n"
63 "# $2 = altitude [km]\n"
64 "# $3 = longitude [deg]\n"
65 "# $4 = latitude [deg]\n"
66 "# $5 = pressure [hPa]\n"
67 "# $6 = temperature [K]\n"
68 "# $7 = water vapor vmr [ppm]\n"
69 "# $8 = temperature perturbation [K]\n"
70 "# $9 = tropopause height [km]\n\n");
71
72 /* Write data... */
73 for (iz = 0; iz < gps->nz[ids]; iz++)
74 if (gps->z[ids][iz] > 0)
75 fprintf(out, "%.2f %g %g %g %g %g %g %g %g\n",
76 gps->time[ids], gps->z[ids][iz], gps->lon[ids][iz],
77 gps->lat[ids][iz], gps->p[ids][iz], gps->t[ids][iz],
78 gps->wv[ids][iz], gps->pt[ids][iz], gps->th[ids]);
79
80 /* Close file... */
81 fclose(out);
82
83 /* Free... */
84 free(gps);
85
86 return EXIT_SUCCESS;
87}
void read_gps(char *filename, gps_t *gps)
Read GPS-RO data file.
Definition: libgps.c:611
GPS Code Collection library declarations.
int main(int argc, char *argv[])
Definition: prof.c:28
GPS-RO profile data.
Definition: libgps.h:153
double time[NDS]
Time (seconds since 2000-01-01T00:00Z).
Definition: libgps.h:162
double pt[NDS][NZ]
Temperature perturbation [K].
Definition: libgps.h:183
double t[NDS][NZ]
Temperature [K].
Definition: libgps.h:177
double wv[NDS][NZ]
Water vapor volume mixing ratio [ppm].
Definition: libgps.h:180
int nz[NDS]
Number of altitudes per profile.
Definition: libgps.h:159
double lon[NDS][NZ]
Longitude [deg].
Definition: libgps.h:168
int nds
Number of profiles.
Definition: libgps.h:156
double p[NDS][NZ]
Pressure [hPa].
Definition: libgps.h:174
double th[NDS]
Tropopause height [km].
Definition: libgps.h:186
double z[NDS][NZ]
Altitude [km].
Definition: libgps.h:165
double lat[NDS][NZ]
Latitude [deg].
Definition: libgps.h:171