Commit bd19269
authored
Frequency detec (#123)
* Implement temporal frequency detection and validation
Features:
- Add lazy frequency detection from temporal coordinates using xarray/Dask
- Validate frequency consistency across concatenated input files
- Configurable validation with tolerance settings for slight differences
- Custom FrequencyMismatchError for clear error reporting
- integrate validation into all CMORiser classes with user control
- Comprehensive unit tests covering various frequency scenarios
This prevents issues when concatenating files with different temporal
frequencies and provides early detection of data inconsistencies without
loading full datasets into memory. The implementation is performance-oriented
using lazy evaluation to check only the first few time points of each file.
Usage:
- Validation enabled by default: ACCESS_ESM_CMORiser(...)
- Disable validation: ACCESS_ESM_CMORiser(..., validate_frequency=False)
- Tolerance configurable via validate_consistent_frequency() function
Files modified:
- utilities.py: Core frequency detection functions
- base.py: Integration with load_dataset method
- driver.py: User-facing validate_frequency parameter
- ocean.py: Updated constructor to pass through parameter
- tests/unit/test_frequency_detection.py: Comprehensive test suite
* Enhance CMIP6 frequency validation with compound name support and add new utility functions for frequency parsing and compatibility checks
* Enhance temporal frequency detection and resampling functionality
- Added support for detecting temporal frequency from CF-compliant time bounds in `detect_time_frequency_lazy`.
- Implemented a new utility function `_detect_frequency_from_bounds` for improved frequency detection.
- Introduced `validate_and_resample_if_needed` to validate dataset frequency and resample if necessary for CMIP6 compatibility.
- Enhanced `resample_dataset_temporal` to handle various resampling methods based on variable metadata.
- Updated tests to cover new frequency detection and resampling features, including edge cases for single time points and bounds detection.
- Created a new test suite for temporal resampling functionality, ensuring robust validation and error handling.
* Add ACCESS frequency metadata parsing and detection functions
* Implement smart tolerance for frequency validation and add tests for calendar month variations
* Enhance frequency compatibility validation for monthly data, allowing for calendar month variations. Implement helper functions to validate monthly files and adjust compatibility checks in CMIP6 frequency validation.
* Enhance frequency compatibility validation to handle monthly data without resampling. Special handling for calendar month variations added to improve accuracy in CMIP6 frequency checks.
* Implement efficient frequency detection for monthly files using concatenation; add fallback to individual file analysis. Remove outdated test scripts for exact error simulation and monthly calendar variations.
* Set default validate_frequency to False in CMIP6_CMORiser constructor
* Fix tests
* Fix pre-commit
* Remove codacy
* Revert "Remove codacy"
This reverts commit 936f1c6.
* Add compound_name parameter to CMIP6_CMORiser and update tests
* Refactor CMIP6_CMORiser to extract cmor_name from compound_name and update related tests
* Remove unused import and simplify print statement in CMIP6_CMORiser
* Refactor load_filtered_variables to support model-specific mappings and update integration tests accordingly
* Fix pre-commit
* Fix push trigger in CI workflow to include main branch1 parent 32f7149 commit bd19269
10 files changed
Lines changed: 2819 additions & 38 deletions
File tree
- .github/workflows
- src/access_moppy
- tests
- integration
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
10 | 18 | | |
11 | 19 | | |
12 | 20 | | |
| |||
20 | 28 | | |
21 | 29 | | |
22 | 30 | | |
23 | | - | |
24 | 31 | | |
25 | 32 | | |
| 33 | + | |
26 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
27 | 38 | | |
28 | 39 | | |
29 | 40 | | |
30 | 41 | | |
31 | 42 | | |
32 | | - | |
| 43 | + | |
| 44 | + | |
33 | 45 | | |
34 | 46 | | |
35 | 47 | | |
36 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
37 | 53 | | |
38 | 54 | | |
39 | 55 | | |
| |||
50 | 66 | | |
51 | 67 | | |
52 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
53 | 76 | | |
54 | 77 | | |
55 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
56 | 107 | | |
57 | 108 | | |
58 | 109 | | |
| |||
64 | 115 | | |
65 | 116 | | |
66 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
67 | 149 | | |
68 | 150 | | |
69 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
48 | 57 | | |
49 | 58 | | |
50 | 59 | | |
| |||
75 | 84 | | |
76 | 85 | | |
77 | 86 | | |
78 | | - | |
| 87 | + | |
79 | 88 | | |
80 | 89 | | |
81 | 90 | | |
82 | 91 | | |
83 | | - | |
84 | 92 | | |
85 | 93 | | |
| 94 | + | |
86 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
87 | 99 | | |
88 | 100 | | |
89 | 101 | | |
90 | 102 | | |
91 | 103 | | |
92 | | - | |
93 | 104 | | |
94 | 105 | | |
| 106 | + | |
95 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
96 | 111 | | |
97 | 112 | | |
98 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | 21 | | |
23 | 22 | | |
| 23 | + | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
29 | | - | |
30 | 32 | | |
31 | 33 | | |
| 34 | + | |
32 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
| |||
0 commit comments