-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyse_data.py
executable file
·70 lines (51 loc) · 2.73 KB
/
analyse_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python3
import os
import glob
import matplotlib.pylab as plt
from astropy.io import fits
from argparse import ArgumentParser, RawTextHelpFormatter
from functions.distribution_merra2 import *
from functions.distribution_era5 import *
from functions.seasonal_maps import *
if __name__ == '__main__':
parser = ArgumentParser(fromfile_prefix_chars='@')
parser.add_argument("site", type=str, help="Site name")
parser.add_argument('-p', '--path', default=".", type=str, help="Data Directory")
parser.add_argument('-o', '--out_file', default="weather.fits", type=str, help="Output File")
parser.add_argument('-ps', '--pix_size', type=float, default=0.35, help='Select the pixel size of your reanalysis')
parser.add_argument('-npix', '--num_pix', default=1, type=int, help="Number of pixel")
parser.add_argument('-m', '--seasonal_maps', action='store_true', help="Return the seasonal maps ")
parser.add_argument('-var', '--variable', default="TQV", type=str, help="Atmospheric Variable")
parser.add_argument('-ra', '--reanalysis', default='merra2', type=str, help='Select the reanalysis type of your data')
parser.add_argument('-d', '--debug', action='store_true')
args = parser.parse_args()
if args.debug:
for _, value in parser.parse_args()._get_kwargs():
print(value)
print("Site Name : {}".format(args.site))
print("Out File : {}".format(args.out_file))
print("Working Path: {}".format(args.path))
print("Seas. Maps : {}".format(args.seasonal_maps))
print("Spatial AVG : {}".format(args.num_pix))
if args.seasonal_maps:
print("Atm. Var : {}".format(args.variable))
if args.reanalysis == "merra2":
try:
file_list = sorted(glob.glob(args.path+"m*"))
print("Num of files:\t", len(file_list))
except FileNotFoundError as FnF:
print("Error Number {0}; {1}".format(FnF.errno, FnF.strerror))
if args.seasonal_maps:
make_maps_merra2(args.site, args.path, file_list, args.out_file, args.num_pix, args.variable)
else:
distr = cumulative_distribution_merra2(args.site, args.path, file_list, args.out_file, args.num_pix)
if args.reanalysis == "era5":
try:
file_list = sorted(glob.glob(args.path+"m*"))
print("Num of files:\t", len(file_list))
except FileNotFoundError as FnF:
print("Error Number {0}; {1}".format(FnF.errno, FnF.strerror))
if args.seasonal_maps:
make_maps_era5(args.site, args.path, file_list, args.out_file, args.num_pix, args.variable)
else:
distr = cumulative_distribution_era5(args.site, args.path, file_list, args.out_file, args.num_pix)