GPS Code Collection
Functions
perturbation.c File Reference

Extract gravity wave perturbations. More...

#include "libgps.h"

Go to the source code of this file.

Functions

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

Detailed Description

Extract gravity wave perturbations.

Definition in file perturbation.c.

Function Documentation

◆ main()

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

Definition at line 32 of file perturbation.c.

34 {
35
36 gps_t *gps;
37
38 FILE *in;
39
40 char metbase[LEN];
41
42 double dt_met, gauss_dx, gauss_dy, grid_zmin, grid_zmax, ham_dz, ham_dz2,
43 poly_zmax, poly_zmin;
44
45 int grid_nz, iarg, poly_dim;
46
47 /* Allocate... */
48 ALLOC(gps, gps_t, 1);
49
50 /* Check arguments... */
51 if (argc < 4)
52 ERRMSG("Give parameters: <ctl> <out.nc> <gps1.nc> [<gps2.nc> ...]");
53
54 /* Get control parameters... */
55 dt_met = scan_ctl(argc, argv, "DT_MET", -1, "21600", NULL);
56 gauss_dx = scan_ctl(argc, argv, "GAUSS_DX", -1, "-999", NULL);
57 gauss_dy = scan_ctl(argc, argv, "GAUSS_DY", -1, "-999", NULL);
58 grid_zmin = scan_ctl(argc, argv, "GRID_ZMIN", -1, "0", NULL);
59 grid_zmax = scan_ctl(argc, argv, "GRID_ZMAX", -1, "40", NULL);
60 grid_nz = (int) scan_ctl(argc, argv, "GRID_NZ", -1, "-1", NULL);
61 ham_dz = scan_ctl(argc, argv, "HAM_DZ", -1, "-999", NULL);
62 ham_dz2 = scan_ctl(argc, argv, "HAM_DZ2", -1, "-999", NULL);
63 scan_ctl(argc, argv, "METBASE", -1, "", metbase);
64 poly_dim = (int) scan_ctl(argc, argv, "POLY_DIM", -1, "5", NULL);
65 poly_zmin = scan_ctl(argc, argv, "POLY_ZMIN", -1, "0", NULL);
66 poly_zmax = scan_ctl(argc, argv, "POLY_ZMAX", -1, "40", NULL);
67
68 /* Read individual GPS-RO data files... */
69 for (iarg = 3; iarg < argc; iarg++)
70 if (!(in = fopen(argv[iarg], "r")))
71 continue;
72 else {
73 fclose(in);
74 read_gps_prof(argv[iarg], gps);
75 }
76
77 /* Check number of profiles... */
78 if (gps->nds <= 0)
79 ERRMSG("No profiles found!");
80
81 /* Grid profile... */
82 if (grid_nz > 0)
83 grid_gps(gps, grid_zmin, grid_zmax, grid_nz);
84
85 /* Get tropopause... */
86 tropopause(gps);
87
88 /* Get perturbations from horizontal Gaussian mean... */
89 if (gauss_dx > 0 && gauss_dy > 0)
90 gauss(gps, gauss_dx, gauss_dy);
91
92 /* Get perturbations from vertical Hamming filter... */
93 if (ham_dz > 0)
94 hamming_low_pass(gps, ham_dz);
95
96 /* Use vertical Hamming filter to reduce noise... */
97 if (ham_dz2 > 0)
98 hamming_high_pass(gps, ham_dz2);
99
100 /* Use meteo data for detrending... */
101 if (metbase[0] != '-')
102 detrend_met(gps, metbase, dt_met);
103
104 /* Remove polynomial fit from perturbation profile... */
105 if (poly_dim > 0)
106 poly(gps, poly_dim, poly_zmin, poly_zmax);
107
108 /* Write GPS-RO data file... */
109 write_gps(argv[2], gps);
110
111 /* Free... */
112 free(gps);
113
114 return EXIT_SUCCESS;
115}
void write_gps(char *filename, gps_t *gps)
Write GPS-RO data file.
Definition: libgps.c:1060
void gauss(gps_t *gps, double dx, double dy)
Calculate horizontal Gaussian mean to extract perturbations.
Definition: libgps.c:95
void poly(gps_t *gps, int dim, double zmin, double zmax)
Remove polynomial fit from perturbation profile.
Definition: libgps.c:435
void grid_gps(gps_t *gps, double zmin, double zmax, int nz)
Interpolate GPS data to regular altitude grid.
Definition: libgps.c:133
void hamming_low_pass(gps_t *gps, double dz)
Apply vertical Hamming filter to extract perturbations.
Definition: libgps.c:325
void detrend_met(gps_t *gps, char *metbase, double dt_met)
Detrending by means of meteo data.
Definition: libgps.c:57
void read_gps_prof(char *filename, gps_t *gps)
Read GPS-RO profile.
Definition: libgps.c:520
void hamming_high_pass(gps_t *gps, double dz)
Apply vertical Hamming filter to reduce noise.
Definition: libgps.c:382
void tropopause(gps_t *gps)
Find tropopause height.
Definition: libgps.c:886
GPS-RO profile data.
Definition: libgps.h:153
int nds
Number of profiles.
Definition: libgps.h:156
Here is the call graph for this function: