|
11 | 11 | from pkg_resources import resource_filename |
12 | 12 | from aodntools import __version__ |
13 | 13 | import aodntools.timeseries_products.aggregated_timeseries as utils |
| 14 | +from aodntools.timeseries_products.velocity_aggregated_timeseries import check_file |
14 | 15 |
|
15 | 16 | import xarray as xr |
16 | 17 | import pandas as pd |
|
19 | 20 | TEMPLATE_JSON = resource_filename(__name__, 'velocity_hourly_timeseries_template.json') |
20 | 21 |
|
21 | 22 |
|
22 | | -def check_file(nc, site_code): |
23 | | - """ |
24 | | - Return list of errors found in the file: |
25 | | - Variables of interest are present |
26 | | - TIME, DEPTH, LATITUDE, LONGITUDE, is present |
27 | | - NOMINAL_DEPTH is not present as variable or attribute |
28 | | - file_version is not FV01 |
29 | | - if LATITUDE or LONIGITUDE dimension has length >1 |
30 | | -
|
31 | | - :param nc: xarray dataset |
32 | | - :param site_code: code of the mooring site |
33 | | - :return: dictionary with the file name and list of failed tests |
34 | | - """ |
35 | | - |
36 | | - attributes = list(nc.attrs) |
37 | | - variables = list(nc.variables) |
38 | | - allowed_dimensions = ['TIME', 'LATITUDE', 'LONGITUDE', 'HEIGHT_ABOVE_SENSOR'] |
39 | | - required_variables = ['UCUR', 'VCUR', 'WCUR', 'DEPTH'] |
40 | | - error_list = [] |
41 | | - |
42 | | - if nc.site_code != site_code: |
43 | | - error_list.append('Wrong site_code: ' + nc.site_code) |
44 | | - |
45 | | - if 'Level 1' not in nc.file_version: |
46 | | - error_list.append('Wrong file version: ' + nc.file_version) |
47 | | - if 'DEPTH' not in variables: |
48 | | - error_list.append('DEPTH variable missing') |
49 | | - if 'DEPTH' not in variables and 'HEIGHT_ABOVE_SENSOR' not in variables: |
50 | | - error_list.append('DEPTH and HEIGHT_ABOVE_SENSOR missing') |
51 | | - if 'TIME' not in variables: |
52 | | - error_list.append('TIME variable missing') |
53 | | - if 'LATITUDE' not in variables: |
54 | | - error_list.append('LATITUDE variable missing') |
55 | | - if 'LONGITUDE' not in variables: |
56 | | - error_list.append('LONGITUDE variable missing') |
57 | | - |
58 | | - for variable in required_variables: |
59 | | - if variable not in variables: |
60 | | - error_list.append(variable + ' variable missing') |
61 | | - else: |
62 | | - VoIdimensions = list(nc[variable].dims) |
63 | | - if 'TIME' not in VoIdimensions: |
64 | | - error_list.append('TIME is not a dimension for ' + variable) |
65 | | - if 'LATITUDE' in VoIdimensions and len(nc.LATITUDE) > 1: |
66 | | - error_list.append('more than one LATITUDE for ' + variable) |
67 | | - if 'LONGITUDE' in VoIdimensions and len(nc.LONGITUDE) > 1: |
68 | | - error_list.append('more than one LONGITUDE for ' + variable) |
69 | | - for dim in VoIdimensions: |
70 | | - if dim not in allowed_dimensions: |
71 | | - error_list.append('not allowed dimension: ' + dim) |
72 | | - |
73 | | - if 'NOMINAL_DEPTH' not in variables and 'instrument_nominal_depth' not in attributes: |
74 | | - error_list.append('no NOMINAL_DEPTH') |
75 | | - |
76 | | - return error_list |
77 | | - |
78 | 23 | def cell_velocity_resample(df, binning_function, is_WCUR): |
79 | 24 | """ |
80 | 25 | Resample a dataset to a specific time_interval. |
|
0 commit comments