-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add linting test and update README.md * update copyright year, add tool to update.
- Loading branch information
Showing
33 changed files
with
6,641 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
set noparent | ||
linelength=100 | ||
filter=+build,-build/include_alpha,-build/c++11,+legal,+readability,+runtime,+whitespace,-runtime/references |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,78 @@ | ||
nemo-feedback | ||
============= | ||
|
||
![CI](https://github.com/MetOffice/nemo-feedback/actions/workflows/ci.yml/badge.svg) | ||
[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) | ||
© British Crown Copyright 2024 Met Office. All rights reserved. | ||
|
||
# nemo-feedback | ||
|
||
JEDI UFO filter extension for writing NEMO ocean model NetCDF feedback file format data from the UK Met Office. | ||
|
||
## Description | ||
|
||
_nemo-feedback_ is a small code snippet that is compiled with UFO to add an additional filter for direct output in NEMO feedback file format. It was developed at the Met Office to interface with the JEDI framework and the [_orca-jedi_](https://github.com/MetOffice/nemo-feedback) JEDI "psuedomodel". These tools are built as a bridge between NEMO/NEMOVAR and the JEDI framework - rather than interfacing directly with NEMO or NEMOVAR, the model state is derived from input files, and the quality controlled observations are written to feedback file for ingestion by the NEMOVAR executable. It is anticipated that _nemo-feedback_ will become obsolete, either through adoption of a standard observation file format across Met Office systems (ODB), or through further integration of Met Office Ocean workflows into the JEDI framework. | ||
|
||
## Getting Started | ||
|
||
### Dependencies | ||
|
||
* [cmake](https://cmake.org/) | ||
* [Unidata/netcdf-cxx4](https://github.com/Unidata/netcdf-cxx4) | ||
* [ecmwf/ecbuild](https://github.com/ecmwf/ecbuild) | ||
* [ecmwf/eckit](https://github.com/ecmwf/eckit) | ||
* [JCSDA/oops](https://github.com/JCSDA/oops) | ||
* [JCSDA/ufo](https://github.com/JCSDA/ufo) | ||
|
||
### Installing | ||
|
||
_nemo-feedback_ meant to be built with UFO as part of [mo-bundle](https://github.com/MetOffice/mo-bundle) at the Met Office - see the README in that project for details on how to build. | ||
|
||
Otherwise, it is possible to build _nemo-feedback_ within a custom JEDI bundle. For details about JEDI, including installation instructions see the [jedi-docs](http://jedi-docs.jcsda.org/). A small example of this is part of the continuous integration in this repository. | ||
|
||
These bundles are built, made and installed via cmake, and tested with ctest. All code should be documented at the source level for processing using doxygen. | ||
|
||
### Using the interface | ||
|
||
The jedi configuration is documented in the main jedi documentation. Settings for Met Office operational numerical weather prediction workflows are held internally by the Met Office, however there are some example configurations in the ``examples`` directory as well as the ctest tests inputs (``src/tests/testinputs``). The _nemo-feedback_ filter will work both serially or when using MPI. | ||
|
||
The parameters for _nemo-feedback_ are documented in code in the parameters class. When the program is compiled, these are exported to a yaml schema json file, that can be used in conjunction with your editor to highlight any issues with your configuration. An example yaml configuration would look something like: | ||
|
||
```yaml | ||
... | ||
observations: | ||
... | ||
- obs space: | ||
... | ||
obs filters: | ||
... | ||
- filter: NEMO Feedback Writer | ||
reference date: # eckit::DateTime reference date for the julian day observation time in the file | ||
filename: # path to output file | ||
observation alias file: # mapping between observation and model names inside UFO | ||
variables: # List of variables to write | ||
- name: # UFO observation variable name | ||
nemo name: # feedback file variable name | ||
long name: # long name in the netcdf file | ||
units: # units attribute in the netcdf file | ||
extra variable: # optional, if true don't make the normal set of sub-variables (e.g for mean-dynamic-topography) | ||
additional variables: # "additional" variables (these are extra sub-variables of a variable) | ||
- name: # UFO observation variable name | ||
feedback suffix: # suffix for this additional variable name (i.e <nemo name>_<feedback suffix>) | ||
ioda group: # IODA group to extract this variable from | ||
... | ||
``` | ||
|
||
## Help | ||
|
||
See the JEDI documentation for help. Additional debugging/trace output is available when: | ||
``` | ||
OOPS_DEBUG=true | ||
OOPS_TRACE=true | ||
``` | ||
|
||
## Authors | ||
|
||
The current lead maintainer is [@twsearle](https://github.com/twsearle) along with a large amount of help from Met Office contributors (see the "Contributors" page on github). | ||
|
||
JEDI UFO filter for writing NEMO ocean model NetCDF feedback file format data from the UK Met Office. | ||
## Working practices | ||
|
||
Installation | ||
------------ | ||
Please see the [JEDI working principles](https://jointcenterforsatellitedataassimilation-jedi-docs.readthedocs-hosted.com/en/latest/working-practices/index.html) for current working practises. There are also templates for issues and PRs should you wish to contribute. | ||
|
||
The NEMO feedback file filter is built with UFO and orca-jedi using the orca-bundle. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# (C) British Crown Copyright 2024 Met Office | ||
|
||
add_subdirectory(nemo-feedback) | ||
add_subdirectory(tests) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* (C) British Crown Copyright 2023 Met Office | ||
* (C) British Crown Copyright 2024 Met Office | ||
*/ | ||
|
||
#pragma once | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* (C) British Crown Copyright 2023 Met Office | ||
* (C) British Crown Copyright 2024 Met Office | ||
*/ | ||
|
||
#pragma once | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* (C) British Crown Copyright 2023 Met Office | ||
* (C) British Crown Copyright 2024 Met Office | ||
*/ | ||
|
||
#pragma once | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* (C) British Crown Copyright 2023 Met Office | ||
* (C) British Crown Copyright 2024 Met Office | ||
*/ | ||
|
||
#pragma once | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* (C) British Crown Copyright 2023 Met Office | ||
* (C) British Crown Copyright 2024 Met Office | ||
*/ | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* (C) British Crown Copyright 2023 Met Office | ||
* (C) British Crown Copyright 2024 Met Office | ||
*/ | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* (C) British Crown Copyright 2023 Met Office | ||
* (C) British Crown Copyright 2024 Met Office | ||
*/ | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* (C) British Crown Copyright 2023 Met Office | ||
* (C) British Crown Copyright 2024 Met Office | ||
*/ | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* (C) British Crown Copyright 2023 Met Office | ||
* (C) British Crown Copyright 2024 Met Office | ||
*/ | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* (C) British Crown Copyright 2023 Met Office | ||
* (C) British Crown Copyright 2024 Met Office | ||
*/ | ||
|
||
#pragma once | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# (C) British Crown Copyright 2024 Met Office | ||
|
||
list( APPEND nemofeedback_test_data | ||
hofx_sic_obs.nc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# (C) British Crown Copyright 2024 Met Office | ||
|
||
list( APPEND fdbk_writer_test_input | ||
hofx_sic_writer.yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Replace the copyright year in the copyright string on all matching files | ||
""" | ||
|
||
|
||
import sys | ||
import re | ||
from datetime import datetime as dt | ||
import pathlib | ||
|
||
|
||
def replace_copyright_year(path, old_copyright_year, new_copyright_year): | ||
with open(path, "r") as fp: | ||
content = fp.read() | ||
|
||
if re.search(old_copyright_year, content): | ||
print("Copyright line found") | ||
corrected_content = re.sub(old_copyright_year, new_copyright_year, content) | ||
|
||
with open(path, "w") as fp: | ||
fp.write(corrected_content) | ||
|
||
|
||
def main(): | ||
old_copyright = re.escape("British Crown Copyright ") + ".... Met Office" | ||
|
||
new_year = dt.now().year | ||
new_copyright = "British Crown Copyright {new_year:d} Met Office".format( | ||
new_year=new_year | ||
) | ||
print("Old Copyright regex: ", old_copyright) | ||
print("New Copyright will be: ", new_copyright) | ||
|
||
# walk all files starting from current directory | ||
root = pathlib.Path() | ||
|
||
files = ( | ||
[fl for fl in root.glob("**/*.txt") if fl.is_file()] | ||
+ [fl for fl in root.glob("**/*.md") if fl.is_file()] | ||
+ [fl for fl in root.glob("**/*.yaml") if fl.is_file()] | ||
+ [fl for fl in root.glob("**/*.cc") if fl.is_file()] | ||
+ [fl for fl in root.glob("**/*.h") if fl.is_file()] | ||
) | ||
|
||
for file_path in files: | ||
print(f"Replacing copyright year in: {file_path}") | ||
replace_copyright_year(file_path, old_copyright, new_copyright) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.