GPS Code Collection
Functions
prof.c File Reference

Extract vertical profiles. More...

#include "libgps.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

Extract vertical profiles.

Definition in file prof.c.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 28 of file prof.c.

30 {
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-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
Here is the call graph for this function: