diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yaml similarity index 100% rename from .github/workflows/_build.yml rename to .github/workflows/_build.yaml diff --git a/.github/workflows/_build_doc.yml b/.github/workflows/_build_doc.yaml similarity index 100% rename from .github/workflows/_build_doc.yml rename to .github/workflows/_build_doc.yaml diff --git a/.github/workflows/_build_docker.yml b/.github/workflows/_build_docker.yaml similarity index 100% rename from .github/workflows/_build_docker.yml rename to .github/workflows/_build_docker.yaml diff --git a/.github/workflows/_pre_commit.yml b/.github/workflows/_pre_commit.yaml similarity index 100% rename from .github/workflows/_pre_commit.yml rename to .github/workflows/_pre_commit.yaml diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yaml similarity index 100% rename from .github/workflows/_test.yml rename to .github/workflows/_test.yaml diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml new file mode 100644 index 0000000..ee7e208 --- /dev/null +++ b/.github/workflows/cicd.yaml @@ -0,0 +1,56 @@ +## Checks the code logic, style and more +# -*- coding: utf-8 -*- +# Copyright (C) 2023 Benjamin Thomas Schwertfeger +# Github: https://github.com/btschwertfeger +# +# Workflow to apply pre-commit, build, test and upload the docker +# image(s). + +name: CI/CD + +on: + push: + branches: + - "**" + +concurrency: + group: CICD-${{ github.ref }} + cancel-in-progress: true + +jobs: + ## Run the pre-commit content + Pre-Commit: + uses: ./.github/workflows/_pre_commit.yaml + + ## Build the BiasAdjustCXX command-line tool + ## + Build: + needs: [Pre-Commit] + uses: ./.github/workflows/_build.yaml + + ## Build the documentation + ## + Build-Doc: + needs: [Pre-Commit] + uses: ./.github/workflows/_build_doc.yaml + with: + os: "ubuntu-latest" + python-version: "3.11" + + ## Build the test suite and run the unit tests + ## + Test: + needs: [Pre-Commit] + uses: ./.github/workflows/_test.yaml + + ## Create and upload a docker image + ## + Docker: + if: success() && github.ref == 'refs/heads/dev' + needs: [Build, Test] + uses: ./.github/workflows/_build_docker.yaml + with: + TAG: ${{ github.ref_name }} + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/cicd.yml b/.github/workflows/release.yaml similarity index 68% rename from .github/workflows/cicd.yml rename to .github/workflows/release.yaml index 68c0f7f..b158ea5 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/release.yaml @@ -4,35 +4,34 @@ # Github: https://github.com/btschwertfeger # # Workflow to apply pre-commit, build, test and upload the docker -# image(s). +# image. This job is only triggered during a release. -name: CI/CD +name: Release on: - push: - branches: - - "**" + release: + types: [created] concurrency: - group: CICD-${{ github.ref }} + group: Release-${{ github.ref }} cancel-in-progress: true jobs: ## Run the pre-commit content Pre-Commit: - uses: ./.github/workflows/_pre_commit.yml + uses: ./.github/workflows/_pre_commit.yaml ## Build the BiasAdjustCXX command-line tool ## Build: needs: [Pre-Commit] - uses: ./.github/workflows/_build.yml + uses: ./.github/workflows/_build.yaml ## Build the documentation ## Build-Doc: needs: [Pre-Commit] - uses: ./.github/workflows/_build_doc.yml + uses: ./.github/workflows/_build_doc.yaml with: os: "ubuntu-latest" python-version: "3.11" @@ -41,14 +40,13 @@ jobs: ## Test: needs: [Pre-Commit] - uses: ./.github/workflows/_test.yml + uses: ./.github/workflows/_test.yaml - ## Create and upload a docker image + ## Create and upload the tagged docker image ## - Docker: - if: success() && github.ref == 'refs/heads/dev' + Docker-tag: needs: [Build, Test] - uses: ./.github/workflows/_build_docker.yml + uses: ./.github/workflows/_build_docker.yaml with: TAG: ${{ github.ref_name }} secrets: @@ -59,8 +57,7 @@ jobs: ## Docker-latest: needs: [Build, Test] - if: success() && github.ref == 'refs/heads/master' - uses: ./.github/workflows/_build_docker.yml + uses: ./.github/workflows/_build_docker.yaml with: TAG: latest secrets: diff --git a/.gitignore b/.gitignore index f6cc977..58fb108 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ .ipynb_checkpoints build/ output/ +.vscode/ *tmp* qdm_result.nc del/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 50ab3ba..87a46ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [Unreleased](https://github.com/btschwertfeger/BiasAdjustCXX/tree/HEAD) + +[Full Changelog](https://github.com/btschwertfeger/BiasAdjustCXX/compare/v1.9.0...HEAD) + +**Merged pull requests:** + +- Add release workflow [\#27](https://github.com/btschwertfeger/BiasAdjustCXX/pull/27) ([btschwertfeger](https://github.com/btschwertfeger)) +- Clarified difference between stochastic and non-stochastic climate variables in doc and readme [\#26](https://github.com/btschwertfeger/BiasAdjustCXX/pull/26) ([btschwertfeger](https://github.com/btschwertfeger)) +- Added more checks during testing [\#25](https://github.com/btschwertfeger/BiasAdjustCXX/pull/25) ([btschwertfeger](https://github.com/btschwertfeger)) + ## [v1.9.0](https://github.com/btschwertfeger/BiasAdjustCXX/tree/v1.9.0) (2023-04-20) [Full Changelog](https://github.com/btschwertfeger/BiasAdjustCXX/compare/v1.8.1...v1.9.0) diff --git a/CMakeLists.txt b/CMakeLists.txt index 639be6a..c2d3cd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,10 +31,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") include(FindNetCDFCxx) if(netCDFCxx_FOUND) - message (STATUS "NetCDFCxx found!") + message (STATUS "NetCDFCXX found!") include_directories(${NetCDFCxx_INCLUDE_DIRS}) else() - message (FATAL_ERROR "Cannot find NetCDFCxx!") + message (FATAL_ERROR "Cannot find NetCDFCXX. Make sure that `ncxx4-config` is globally executable!") endif() add_subdirectory(src) diff --git a/README.rst b/README.rst index 8957523..90e35b7 100644 --- a/README.rst +++ b/README.rst @@ -29,7 +29,7 @@ BiasAdjustCXX command-line tool for the application of fast and efficient bias c .. |DOI badge| image:: https://zenodo.org/badge/495881923.svg :target: https://zenodo.org/badge/latestdoi/495881923 -.. |Publication bage| image:: https://img.shields.io/badge/Publication-doi.org%2F10.1016%2Fj.softx.2023.101379-blue +.. |Publication badge| image:: https://img.shields.io/badge/Publication-doi.org%2F10.1016%2Fj.softx.2023.101379-blue :target: https://doi.org/10.1016/j.softx.2023.101379 .. LINKS @@ -82,7 +82,7 @@ BiasAdjustCXX command-line tool for the application of fast and efficient bias c |GitHub badge| |License badge| |C++ badge| |CICD badge| |Docker pulls badge| |GCC badge| |CMake badge| -|Release date badge| |Release tag badge| |DOI badge| |Publication bage| +|Release date badge| |Release tag badge| |DOI badge| |Publication badge| **The documentation can be found here: https://biasadjustcxx.readthedocs.io/en/latest.** @@ -186,7 +186,7 @@ Notes regarding the scaling-based techniques match the techniques described by `Teutschbein et al. (2012)`_ and `Beyer et al. (2020)`_. On the other hand the long-term 31-day interval procedures are customized variations and prevent disproportionately high differences in the long-term mean values at the monthly transitions. - Thats why the long-term 31-day interval variant is the preferred method and is enabled by + That's why the long-term 31-day interval variant is the preferred method and is enabled by default for all scaling-based techniques. @@ -204,6 +204,7 @@ the BiasAdjustCXX command-line tool. - NetCDF-4 C++ library (`How to install NetCDF-4 C++`_) - CMake v3.10+ (`How to install CMake`_) +- GNU Make (see https://www.gnu.org/software/make/) - [optional] Climate Data Operators (`How to install cdo`_) Please have a look at the following code blocks that demonstrate how to download, build and install @@ -228,6 +229,9 @@ The tool can be uninstalled using the following command within the project direc After the installation, the tool can be executed using the command listed below. This repository also serves example data to test this. See the documentation for more information (https://biasadjustcxx.readthedocs.io/en/latest). +If the netcdf-cxx4 libraries cannot be found - make sure that ``ncxx4-config`` is globally executable, since this tool is used +to determine the location of these libraries. + .. code:: bash BiasAdjustCXX \ @@ -244,7 +248,7 @@ also serves example data to test this. See the documentation for more informatio Docker 🐳 ~~~~~~~~~~~~~~~ -The execution of BiasAdjustCXX is also possiblie within a Docker container. +The execution of BiasAdjustCXX is also possible within a Docker container. This is the preferred option when the installation of `NetCDF-4 C++`_, `CMake`_ or `BiasAdjustCXX`_ on the local system is not desired. It also makes easier to access this tool since Docker container can run on nearly every operating system. diff --git a/src/CMethods.cxx b/src/CMethods.cxx index 01bcc0d..e4f5c04 100644 --- a/src/CMethods.cxx +++ b/src/CMethods.cxx @@ -124,7 +124,7 @@ std::vector> CMethods::get_long_term_dayofyear(std::vector This is required to compute the bin boundaries for the Probability Density and Cumulative Distribution Funtion. - * -> Used by Quantile and Quantile Delta Mapping by invoking this funtion to get the bins based on the time + * -> This is required to compute the bin boundaries for the Probability Density and Cumulative Distribution Function. + * -> Used by Quantile and Quantile Delta Mapping by invoking this function to get the bins based on the time * series of the control period. * * @param a time series @@ -534,7 +534,7 @@ void CMethods::Quantile_Mapping( MathUtils::interpolate(v_xbins, contr_cdf, (double)v_scenario[ts], false) ); // Eq. 1 - // ? Invert in inversed CDF and return + // ? Invert in invers CDF and return for (unsigned ts = 0; ts < v_scenario.size(); ts++) v_output[ts] = (float)MathUtils::interpolate(ref_cdf, v_xbins, cdf_values[ts], false); // Eq. 1 @@ -544,7 +544,7 @@ void CMethods::Quantile_Mapping( cdf_values.push_back((y >= 0) ? y : 0); } - // ? Invert in inversed CDF and return + // ? Invert in invers CDF and return for (unsigned ts = 0; ts < v_scenario.size(); ts++) { float y = (float)MathUtils::interpolate(ref_cdf, v_xbins, cdf_values[ts], true); // Eq. 1 v_output[ts] = (y >= 0) ? y : 0; @@ -621,7 +621,7 @@ void CMethods::Quantile_Delta_Mapping( for (unsigned ts = 0; ts < v_scenario.size(); ts++) QDM1.push_back(MathUtils::interpolate(ref_cdf, v_xbins, epsilon[ts], false)); // Eq. 1.2 - // ? Invert, insert in inversed CDF and return + // ? Invert, insert in invers CDF and return if (isAdd) { for (unsigned ts = 0; ts < v_scenario.size(); ts++) v_output[ts] = (float)(QDM1[ts] + v_scenario[ts] - MathUtils::interpolate(contr_cdf, v_xbins, epsilon[ts], false)); // Eq. 1.3f. diff --git a/src/MathUtils.cxx b/src/MathUtils.cxx index a54dbab..10e3ed2 100644 --- a/src/MathUtils.cxx +++ b/src/MathUtils.cxx @@ -65,7 +65,7 @@ MathUtils::~MathUtils() {} /** * Returns the pointer to a function based on `name` * - * @param name name of the desired funtion + * @param name name of the desired function * @return point to desired funciton */ Func_one MathUtils::get_method_for_1_ds(std::string name) { @@ -81,8 +81,8 @@ Func_one MathUtils::get_method_for_1_ds(std::string name) { /** * Returns the pointer to a function based on `name` * - * @param name name of the desired funtion - * @return point to desired funciton + * @param name name of the desired function + * @return point to desired function */ Func_two MathUtils::get_method_for_2_ds(std::string name) { if (name == "rmse") diff --git a/src/main.cxx b/src/main.cxx index 14760e6..83202d3 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -54,7 +54,7 @@ */ /** - * Command-line output of the duraton between a start time + * Command-line output of the duration between a start time * * @param start_time start time to calculate the duration */