GPS Code Collection
map.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 /* Allocate... */
37 ALLOC(gps, gps_t, 1);
38
39 /* Check arguments... */
40 if (argc < 4)
41 ERRMSG("Give parameters: <ctl> <gps.nc> <map.tab>");
42
43 /* Get control parameters... */
44 const double z = scan_ctl(argc, argv, "Z", -1, "20", NULL);
45
46 /* Read gps data... */
47 read_gps(argv[2], gps);
48
49 /* Create output file... */
50 printf("Write map data: %s\n", argv[3]);
51 if (!(out = fopen(argv[3], "w")))
52 ERRMSG("Cannot create file!");
53
54 /* Write header... */
55 fprintf(out,
56 "# $1 = time [sec]\n"
57 "# $2 = altitude [km]\n"
58 "# $3 = longitude [deg]\n"
59 "# $4 = latitude [deg]\n"
60 "# $5 = pressure [hPa]\n"
61 "# $6 = temperature [K]\n"
62 "# $7 = water vapor vmr [ppm]\n"
63 "# $8 = temperature perturbation [K]\n"
64 "# $9 = tropopause height [km]\n\n");
65
66 /* Write data... */
67 for (int ids = 0; ids < gps->nds; ids++)
68 for (int iz = 0; iz < gps->nz[ids]; iz++)
69 if (fabs(gps->z[ids][iz] - z) < 0.01) {
70 fprintf(out, "%.2f %g %g %g %g %g %g %g %g\n",
71 gps->time[ids], gps->z[ids][iz], gps->lon[ids][iz],
72 gps->lat[ids][iz], gps->p[ids][iz], gps->t[ids][iz],
73 gps->wv[ids][iz], gps->pt[ids][iz], gps->th[ids]);
74 break;
75 }
76
77 /* Close file... */
78 fclose(out);
79
80 /* Free... */
81 free(gps);
82
83 return EXIT_SUCCESS;
84}
void read_gps(char *filename, gps_t *gps)
Read GPS-RO data file.
Definition: libgps.c:632
GPS Code Collection library declarations.
int main(int argc, char *argv[])
Definition: map.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