__main__.py 1.08 KB
Newer Older
1
"""
Eva Börgens's avatar
Eva Börgens committed
2
3
4
This is the main file to invoke the regional tws uncertainty routines.
"""

5
6
7
from .io import read_netcdf, read_ascii, save_results
from .covariance import get_timeseries, compute_covariance
from .input_arguments import arg_parser
Eva Börgens's avatar
Eva Börgens committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

parsed_command_line_input = arg_parser()

filename = parsed_command_line_input.filename.name
region_filename = parsed_command_line_input.region.name
out_filename = parsed_command_line_input.output
flag_matrix = parsed_command_line_input.matrix
flag_uncertainty = parsed_command_line_input.uncertainty
flag_timeseries = parsed_command_line_input.timeseries

region_coords = read_ascii(region_filename)

grid, grid_std, lon, lat, time = read_netcdf(filename)


if flag_timeseries:
Eva Börgens's avatar
Eva Börgens committed
24
25
26
    timeseries, flag_timeseries = get_timeseries(grid, lon, lat, region_coords)
else:
    timeseries = None
Eva Börgens's avatar
Eva Börgens committed
27

28
if flag_uncertainty or flag_matrix:
Eva Börgens's avatar
Eva Börgens committed
29
30
31
    results = compute_covariance(region_coords, grid_std, flag_uncertainty, flag_matrix)
else:
    results = None
Eva Börgens's avatar
Eva Börgens committed
32
33


Eva Börgens's avatar
Eva Börgens committed
34
35
save_results(out_filename, filename, results, region_coords, timeseries,
             flag_uncertainty, flag_matrix, flag_timeseries )