### Install Library Files Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Installs the 'fes' library, its headers, and runtime components to their designated locations within the installation prefix. ```cmake install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/fes DESTINATION include) install( TARGETS fes LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin INCLUDES DESTINATION include) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) ``` -------------------------------- ### Initialize FESSettings with Fourier Inference Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/theory/admittance_inference.rst Initializes FESSettings to use the Fourier method for admittance inference. Ensure pyfes is installed and imported. ```python settings = pyfes.FESSettings().with_inference_type(pyfes.FOURIER) ``` -------------------------------- ### Install PyFES pre-release builds from TestPyPI Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/getting_started.rst Install pre-release versions of PyFES from TestPyPI. Requires specifying both TestPyPI and PyPI as sources. ```bash pip install --index-url https://test.pypi.org/simple/ \ --extra-index-url https://pypi.org/simple/ pyfes ``` -------------------------------- ### Install PyFES using pip Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/getting_started.rst Install the PyFES package from PyPI using pip. This is the recommended method for most users. ```bash pip install pyfes ``` -------------------------------- ### Install PyFES from source Source: https://github.com/cnes/aviso-fes/blob/main/README.md Install PyFES from its source code repository. This requires a C++14 compiler and CMake. It clones the repository, navigates into the directory, and then installs the package in editable mode. ```bash git clone https://github.com/CNES/aviso-fes.git cd aviso-fes pip install -e . ``` -------------------------------- ### FESSettings Example Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/api/settings.rst Demonstrates the usage of FESSettings with a fluent builder interface to configure prediction settings, including the number of threads and time tolerance. ```APIDOC ## FESSettings Usage ### Description This example shows how to instantiate and configure `pyfes.FESSettings` using its fluent builder interface. You can chain method calls to set various parameters. ### Method Instantiate and configure settings object. ### Code Example ```python settings = pyfes.FESSettings() \ .with_num_threads(4) \ .with_time_tolerance(3600) ``` ### Parameters - `with_num_threads(num_threads)`: Sets the number of threads to use for parallel processing. - `with_time_tolerance(tolerance)`: Sets the time tolerance for calculations. ``` -------------------------------- ### Configuration File Engine Parameter Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/changelog.rst Example of a YAML configuration file showing the addition of the 'engine' parameter to specify the prediction engine. ```yaml tide: lgp: engine: fes # or 'perth5' for GOT models, default is 'fes' path: ${FES_DATA}/ocean_tide.nc # ... other parameters ``` -------------------------------- ### Set RPATH for Build and Install Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Configures CMake to use the origin of the executable/library for RPATH when building and to use the installation prefix for RPATH when installing. ```cmake set(CMAKE_BUILD_RPATH_USE_ORIGIN ON) if(APPLE) list(APPEND CMAKE_INSTALL_RPATH "@loader_path") elseif(UNIX) list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN") endif() ``` -------------------------------- ### XDO Notation Examples Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/theory/harmonic_development.rst Illustrates the conversion of tidal constituents to their Extended Doodson Ordering (XDO) alphabetical representations. ```text M_2 with coefficients (2, 0, 0, 0, 0, 0, 0) becomes BZZZZZ S_2 with coefficients (2, 2, -2, 0, 0, 0, 0) becomes BCXZZZZ ``` -------------------------------- ### Ocean Tide Prediction Example Source: https://github.com/cnes/aviso-fes/blob/main/docs/main_page.dox Example demonstrating how to predict ocean tides at a single location. This involves loading the ocean-tide model (LGP2 mesh) with specified constituents. ```cpp #include #include #include "fes/darwin/constituent.hpp" #include "fes/settings.hpp" #include "fes/tidal_model/cartesian.hpp" #include "fes/tidal_model/lgp2.hpp" #include "fes/tide.hpp" int main() { // --- 1. Load the ocean-tide model (LGP2 mesh) ------------------------- auto ocean = fes::tidal_model::LGP2>(); ocean.load("/path/to/fes2022b/ocean_tide.nc", {fes::darwin::kM2, fes::darwin::kS2, fes::darwin::kN2, fes::darwin::kK2, fes::darwin::kK1, fes::darwin::kO1, fes::darwin::kP1, fes::darwin::kQ1}); // --- 2. Load the radial (loading) tide model (Cartesian grid) ---------- auto radial = fes::tidal_model::Cartesian>(); // ... add constituents from individual NetCDF files ... ``` -------------------------------- ### Install PyFES from conda-forge Source: https://github.com/cnes/aviso-fes/blob/main/README.md Use this command to install the PyFES library using the conda package manager from the conda-forge channel. ```bash conda install -c conda-forge pyfes ``` -------------------------------- ### Custom Runtime Settings for PERTH/Doodson Engine Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/changelog.rst Example of setting custom runtime parameters for the PERTH/Doodson prediction engine using the PerthSettings class. ```python # PERTH/Doodson engine settings = ( pyfes.PerthSettings() .with_group_modulations(True) .with_inference_type(pyfes.InterpolationType.LINEAR_ADMITTANCE) .with_astronomic_formulae(pyfes.Formulae.IERS) .with_num_threads(0) ) ``` -------------------------------- ### Find NetCDF C++ Dependencies for Tide Prediction Example Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Attempts to find the NetCDF C++ library using PkgConfig or by checking the CONDA_PREFIX environment variable. If found, it configures the 'tide_prediction' executable to link against NetCDF and other necessary libraries. ```cmake # Try to find the prerequisites to compile the tide prediction example. If not # found, skip it without error. find_package(PkgConfig) if(PkgConfig_FOUND) pkg_check_modules(NETCDF_CXX netcdf-cxx4) endif() if(NOT NETCDF_CXX_FOUND AND DEFINED ENV{CONDA_PREFIX}) set(NETCDF_CXX_INCLUDE_DIRS "$ENV{CONDA_PREFIX}/include") find_library( NETCDF_CXX_LIBRARIES NAMES netcdf-cxx4 netcdf_c++4 HINTS "$ENV{CONDA_PREFIX}/lib") if(NETCDF_CXX_LIBRARIES) add_executable(tide_prediction ${CMAKE_CURRENT_SOURCE_DIR}/examples/prediction.cpp) target_compile_features(tide_prediction PRIVATE cxx_std_20) target_link_libraries(tide_prediction fes ${NETCDF_CXX_LIBRARIES} Boost::boost) target_include_directories( tide_prediction PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${EIGEN3_INCLUDE_DIR} ${NETCDF_CXX_INCLUDE_DIRS}) endif() endif() ``` -------------------------------- ### PyFES configuration using environment variables Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/getting_started.rst Example of a PyFES YAML configuration file that uses environment variables for specifying paths to tidal constituent NetCDF files. ```yaml engine: darwin tide: cartesian: paths: M2: ${FES_DATA}/M2_tide.nc ``` -------------------------------- ### Upgrade PyFES using pip Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/getting_started.rst Upgrade an existing PyFES installation to the latest release from PyPI. ```bash pip install -U pyfes ``` -------------------------------- ### Custom Runtime Settings for FES/Darwin Engine Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/changelog.rst Example of setting custom runtime parameters for the FES/Darwin prediction engine using the FESSettings class. ```python # FES/Darwin engine settings = ( pyfes.FESSettings() .with_astronomic_formulae(pyfes.Formulae.SCHUREMAN_ORDER_1) .with_time_tolerance(3600.0) .with_num_threads(0) ) ``` -------------------------------- ### CMake Integration for Tide Prediction Project Source: https://github.com/cnes/aviso-fes/blob/main/docs/main_page.dox This CMakeLists.txt snippet shows how to set up a C++ project that uses Eigen and Boost, which are prerequisites for the FES tide prediction library. Ensure these packages are installed on your system. ```cmake cmake_minimum_required(VERSION 3.20) project(tide_prediction LANGUAGES CXX) find_package(Eigen3 REQUIRED) find_package(Boost REQUIRED) ``` -------------------------------- ### Predict tides from a tidal atlas using YAML configuration Source: https://github.com/cnes/aviso-fes/blob/main/README.md This Python code snippet demonstrates how to load a YAML configuration file for tidal models and then predict tidal heights and currents for specific dates, longitudes, and latitudes. It combines the predicted tide and long-period tide to get the total tide. ```yaml engine: darwin tide: cartesian: paths: M2: ${FES_DATA}/M2_tide.nc S2: ${FES_DATA}/S2_tide.nc K1: ${FES_DATA}/K1_tide.nc O1: ${FES_DATA}/O1_tide.nc ``` ```python import numpy as np import pyfes config = pyfes.config.load('ocean_tide.yaml') dates = np.arange( np.datetime64('2024-01-01'), np.datetime64('2024-01-02'), np.timedelta64(1, 'h'), ) lons = np.full(dates.shape, -7.688) lats = np.full(dates.shape, 59.195) tide, lp, flags = pyfes.evaluate_tide( config.models['tide'], dates, lons, lats, settings=config.settings, ) total_tide = tide + lp # in the same units as the tidal atlas ``` -------------------------------- ### Initializing and Customizing FESSettings Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/user_guide.rst Demonstrates how to initialize PyFES runtime settings using the FESSettings class and customize individual settings using builder methods. ```python import pyfes # Start from engine defaults settings = pyfes.FESSettings() # Customise individual settings settings = ( ``` -------------------------------- ### Build PyFES from source with custom options (setup.py) Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/getting_started.rst Build PyFES from source using setup.py, specifying custom build options like the CMake generator and IERS constants. ```bash python setup.py build_ext --generator=Ninja --iers --inplace pip install -e . --no-build-isolation ``` -------------------------------- ### Build PyFES from source with custom options (pip) Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/getting_started.rst Build PyFES from source using pip with custom build options passed via --config-settings. This method is equivalent to using setup.py directly. ```bash pip install -e . --no-build-isolation \ --config-settings=--build-option=build_ext \ --config-settings=--build-option=--generator=Ninja \ --config-settings=--build-option=--iers ``` -------------------------------- ### Generate Version Files Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Executes the setup.py script to refresh version files if they haven't been generated in the current build context. Includes safeguards against recursion and uses a timeout to prevent hangs. ```cmake if(NOT DEFINED ENV{FES_VERSION_FILES_GENERATED} # cmake-lint: disable=W0106 AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git" AND Python3_Interpreter_FOUND) set(ENV{FES_GENERATE_VERSION_ONLY} 1) # cmake-lint: disable=W0106 execute_process( COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/setup.py" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" TIMEOUT 30) unset(ENV{FES_GENERATE_VERSION_ONLY}) # cmake-lint: disable=W0106 endif() ``` -------------------------------- ### Initialize WaveTable for Harmonic Analysis Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/user_guide.rst Instantiate a WaveTable object to support harmonic analysis. Choose between 'pyfes.darwin.WaveTable()' or 'pyfes.perth.WaveTable()' based on your needs. ```python wt = pyfes.darwin.WaveTable() # or pyfes.perth.WaveTable() ``` -------------------------------- ### Configure Perth Settings with Spline Inference Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/user_guide.rst Demonstrates using the SPLINE inference mode with the Perth engine, showing engine-generic behavior. ```python settings = pyfes.PerthSettings().with_inference_type(pyfes.SPLINE) ``` -------------------------------- ### Direct Compilation with g++ Source: https://github.com/cnes/aviso-fes/blob/main/docs/main_page.dox This command shows how to compile the main.cpp file directly using g++, specifying include paths, library paths, and the libraries to link against. ```sh g++ -O2 -std=c++17 main.cpp \ -I/path/to/include -I/path/to/eigen3 \ -L/path/to/lib -lfes -lnetcdf-cxx4 -lnetcdf \ -o tide_prediction ``` -------------------------------- ### Configure FESSettings with Chained Calls Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/api/settings.rst Instantiate FESSettings and chain method calls to configure parameters like the number of threads and time tolerance. ```python settings = pyfes.FESSettings() \ .with_num_threads(4) \ .with_time_tolerance(3600) ``` -------------------------------- ### YAML Configuration with Environment Variable Interpolation Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/user_guide.rst Demonstrates how to use environment variables within paths in a YAML configuration file for dynamic path resolution. ```yaml paths: M2: ${FES_DATA}/M2_tide.nc ``` -------------------------------- ### Selecting Admittance Inference Modes Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/theory/admittance_inference.rst Demonstrates how to configure PyFES settings to use different admittance inference modes, with recommendations for FES and GOT atlases. ```python settings = pyfes.FESSettings().with_inference_type(pyfes.SPLINE) settings = pyfes.PerthSettings().with_inference_type(pyfes.LINEAR) settings = pyfes.FESSettings().with_inference_type(pyfes.ZERO) settings = pyfes.FESSettings().with_inference_type(pyfes.FOURIER) ``` -------------------------------- ### Create a Wave Table Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/api/wave_system.rst Creates a wave table using the DARWIN engine. This is the initial step to access wave data and perform operations. ```python wt = pyfes.wave_table_factory(pyfes.EngineType.DARWIN) ``` -------------------------------- ### Configure Library Include Directories Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Sets public include directories for the 'fes' library, distinguishing between build-time and install-time paths. ```cmake target_include_directories( fes PUBLIC $ $) ``` -------------------------------- ### Configure Perth Settings with Inference Type Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/user_guide.rst Sets up Perth settings using LINEAR inference. This is recommended for GOT atlases. ```python settings = pyfes.PerthSettings().with_inference_type(pyfes.LINEAR) ``` -------------------------------- ### Display FES Configuration Summary Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Prints a summary of the FES build configuration to the console. This includes details about the version, build type, library type, enabled features, and compiler flags. ```cmake message(STATUS "") message( STATUS "====================[ FES Configuration Summary ]=====================") message(STATUS "Version : ${FES_VERSION}.${FES_VERSION_TYPE}") if(FES_VERSION_TYPE MATCHES "dev") message(STATUS "Release Type : Development") else() message(STATUS "Release Type : Release") endif() message(STATUS "Build Type : ${CMAKE_BUILD_TYPE}") if(BUILD_SHARED_LIBS) message(STATUS "Library Type : Shared") else() message(STATUS "Library Type : Static") endif() if(FES_USE_IERS_CONSTANTS) message(STATUS "Constants : IERS 2010") else() message(STATUS "Constants : Schureman 1958") endif() message(STATUS "Python Bindings : ${FES_BUILD_PYTHON_BINDINGS}") message(STATUS "Clang-Tidy : ${FES_ENABLE_CLANG_TIDY}") message(STATUS "Unit Tests : ${FES_ENABLE_TEST}") message(STATUS "Code Coverage : ${FES_ENABLE_COVERAGE}") message(STATUS "C++ Standard : ${CMAKE_CXX_STANDARD}") message(STATUS "C++ Standard Required : ${CMAKE_CXX_STANDARD_REQUIRED}") message(STATUS "C++ Extensions : ${CMAKE_CXX_EXTENSIONS}") message(STATUS "Position Independent : ${CMAKE_POSITION_INDEPENDENT_CODE}") message(STATUS "CXX Flags : ${CMAKE_CXX_FLAGS}") message(STATUS "Install RPATH : ${CMAKE_INSTALL_RPATH}") message( STATUS "=======================================================================") message(STATUS "") ``` -------------------------------- ### Basic Tide Evaluation Migration Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/changelog.rst Demonstrates the migration from the old API (2025.9.0) to the new API (2026.2.0) for basic tide evaluation. ```python # Old code (2025.9.0) import pyfes import pyfes.config as config_handler config = config_handler.load('config.yaml') tide, lp, flags = pyfes.evaluate_tide( config['tide'], dates, leap_secons, lon, lat, settings, num_threads=0 ) ``` ```python # New code (2026.2.0) import pyfes config = pyfes.config.load('config.yaml') tide, lp, flags = pyfes.evaluate_tide( config.models['tide'], dates, lon, lat, settings=config.settings, ) ``` -------------------------------- ### Forwarding raw CMake options during build Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/getting_started.rst Build PyFES from source while forwarding raw CMake arguments, such as specifying the Boost root directory and build type. ```bash python setup.py build_ext \ --cmake-args="-DBOOST_ROOT=/opt/boost -DCMAKE_BUILD_TYPE=Release" ``` -------------------------------- ### Define Project Options Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Defines various build options for the project, such as enabling Python bindings, clang-tidy, position-independent code, optimization, tests, coverage, and IERS constants. These control features and build behavior. ```cmake option(FES_BUILD_PYTHON_BINDINGS "Build Python bindings" OFF) option(FES_ENABLE_CLANG_TIDY "Enable clang-tidy" OFF) option(FES_ENABLE_FPIC "Enable position independent code" ON) option(FES_ENABLE_OPTIMIZATION "Enable optimization" ON) option(FES_ENABLE_TEST "Build unit tests" OFF) option(FES_ENABLE_COVERAGE "Enable coverage" OFF) option(FES_USE_IERS_CONSTANTS "Use IERS 2010 constants" OFF) ``` -------------------------------- ### Find and Verify Boost Dependency Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Attempts to find the Boost library using find_package. If not found, it falls back to manually resolving the include directory and checking the version using helper functions. This ensures Boost is available and meets the minimum version requirement. ```cmake find_package(Boost 1.79 QUIET) if(NOT Boost_FOUND) resolve_boost_include_dir(Boost_INCLUDE_DIRS) if(NOT Boost_INCLUDE_DIRS) message( FATAL_ERROR "Boost not found with find_package, and boost/version.hpp was not " "found in Boost_INCLUDE_DIRS/CMAKE_PREFIX_PATH.") endif() message(STATUS "Boost headers: ${Boost_INCLUDE_DIRS}") check_boost_version("${Boost_INCLUDE_DIRS}" "1.79.0") endif() include_directories(${Boost_INCLUDE_DIRS}) ``` -------------------------------- ### Load PyFES model and define prediction parameters Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/getting_started.rst Python code snippet demonstrating how to load a PyFES configuration from a YAML file and prepare for tide prediction. ```python import numpy as np import pyfes # Load the tidal model and settings from the YAML file config = pyfes.config.load('ocean_tide.yaml') # Define the prediction coordinates and times ``` -------------------------------- ### Add Test Cases Source: https://github.com/cnes/aviso-fes/blob/main/tests/library/CMakeLists.txt Calls the ADD_TESTCASE macro to define and add multiple test cases to the build system. Each call compiles a corresponding C++ file and sets it up for testing. ```cmake add_testcase(axis fes) add_testcase(darwin) add_testcase(delta_time) add_testcase(inference fes) add_testcase(long_period_equilibrium fes) add_testcase(tide fes) add_testcase(xdo) ``` -------------------------------- ### Settings Classes Source: https://github.com/cnes/aviso-fes/blob/main/docs/main_page.dox Classes for configuring tide prediction engines. ```APIDOC ## fes::Settings ### Description Base class for controlling tunable parameters in tide prediction. ### Builder Methods - `with_inference_type(InferenceType type)`: Sets the inference type (`kZero`, `kLinear`, `kSpline`, `kFourier`). - `with_astronomic_formulae(AstronomicalFormulae formulae)`: Sets the astronomical formulae (`kSchuremanOrder1`, `kSchuremanOrder3`, `kMeeus`, `kIERS`). - `with_time_tolerance(int seconds)`: Sets the time tolerance in seconds for caching astronomical angles. - `with_group_modulations(bool enable)`: Enables or disables group nodal corrections (PERTH engine only). - `with_compute_long_period_equilibrium(bool enable)`: Includes long-period equilibrium in the result. - `with_num_threads(int num_threads)`: Sets the number of threads for computation (0 for auto-detect). ``` ```APIDOC ## fes::FESSettings ### Description Convenience subclass of `fes::Settings` with sensible defaults for FES atlases (Darwin notation). ### Usage Example ```cpp auto fes_settings = fes::FESSettings(); ``` ``` ```APIDOC ## fes::PerthSettings ### Description Convenience subclass of `fes::Settings` with sensible defaults for GOT atlases (Doodson notation). ### Usage Example ```cpp auto got_settings = fes::PerthSettings(); ``` ``` -------------------------------- ### Configure FES Settings with Astronomic Formulae Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/user_guide.rst Sets up FES settings using the MEEUS astronomic formulae for high-precision tidal predictions. ```python settings = pyfes.FESSettings().with_astronomic_formulae( pyfes.Formulae.MEEUS ) ``` -------------------------------- ### FES and GOT Settings Configuration Source: https://github.com/cnes/aviso-fes/blob/main/docs/main_page.dox Configure settings for FES (Darwin notation) or GOT (Doodson notation) atlases. These convenience subclasses provide sensible defaults for inference type, astronomical formulae, and other parameters. ```cpp // FES atlas — uses Darwin notation, Schureman angles, spline inference auto fes = fes::FESSettings(); // GOT atlas — uses Doodson notation, IERS angles, linear inference auto got = fes::PerthSettings(); ``` -------------------------------- ### Configure Python Interpreter Strategy Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Sets the strategy for finding the Python interpreter to LOCATION. This ensures that the specified Python executable is used, respecting hints from setup.py. ```cmake set(Python3_FIND_STRATEGY LOCATION) # cmake-lint: disable=C0103 set(Python_FIND_STRATEGY LOCATION) # cmake-lint: disable=C0103 if(DEFINED Python3_EXECUTABLE AND NOT DEFINED Python_EXECUTABLE) set(Python_EXECUTABLE "${Python3_EXECUTABLE}") # cmake-lint: disable=C0103 endif() ``` -------------------------------- ### Configure FES Engine and Evaluate Tide Source: https://github.com/cnes/aviso-fes/blob/main/docs/main_page.dox This snippet demonstrates how to configure the FES engine with specific settings, prepare coordinate data, and then evaluate both ocean and radial tides. Ensure you have the necessary libraries and data files. ```cpp // --- 3. Configure the engine ------------------------------------------- auto settings = fes::FESSettings() .with_num_threads(0) // auto .with_inference_type(fes::InferenceType::kSpline) // default .with_time_tolerance(3600.0); // 1 h cache // --- 4. Prepare coordinates -------------------------------------------- Eigen::VectorXd epoch(1), lon(1), lat(1); epoch(0) = 1577836800.0; // 2020-01-01T00:00:00Z lon(0) = -7.688; lat(0) = 59.195; // --- 5. Evaluate ------------------------------------------------------- auto [tide, lp, quality] = fes::evaluate_tide(&ocean, epoch, lon, lat, settings); auto [load, load_lp, load_quality] = fes::evaluate_tide(&radial, epoch, lon, lat, settings); std::cout << "Ocean tide : " << tide(0) + lp(0) << '\n'; std::cout << "Radial tide: " << load(0) << '\n'; return 0; } ``` -------------------------------- ### Loading PyFES Configuration Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/user_guide.rst Loads a PyFES tidal model configuration from a YAML file. Optionally, a bounding box can be provided to load only a regional subset of the model. ```python import pyfes config = pyfes.config.load('ocean_tide.yaml') # Access the models and settings tide_model = config.models['tide'] settings = config.settings # Optionally load only a regional subset config = pyfes.config.load('ocean_tide.yaml', bbox=(-10, 40, 10, 60)) ``` -------------------------------- ### Minimal PyFES configuration for Cartesian grids Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/getting_started.rst A basic YAML configuration file for PyFES specifying the 'darwin' engine and paths to Cartesian tidal constituent NetCDF files. ```yaml engine: darwin tide: cartesian: paths: M2: /path/to/M2_tide.nc S2: /path/to/S2_tide.nc K1: /path/to/K1_tide.nc O1: /path/to/O1_tide.nc # ... additional constituents ``` -------------------------------- ### Check Boost Version Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt A helper function to verify the Boost version by reading 'boost/version.hpp'. It checks if the detected Boost version meets the minimum required version. ```cmake function(check_boost_version boost_include_dir min_version) if(NOT EXISTS "${boost_include_dir}/boost/version.hpp") message(FATAL_ERROR "Boost version.hpp not found at " "${boost_include_dir}/boost/version.hpp") endif() file(READ "${boost_include_dir}/boost/version.hpp" BOOST_VERSION_CONTENT) string(REGEX MATCH "BOOST_LIB_VERSION \"([0-9_]+)\"" _ "${BOOST_VERSION_CONTENT}") set(boost_version_string "${CMAKE_MATCH_1}") message(STATUS "Boost version: ${boost_version_string}") string(REPLACE "_" "." BOOST_VERSION_FORMATTED "${boost_version_string}") if(BOOST_VERSION_FORMATTED VERSION_LESS "${min_version}") message(FATAL_ERROR "Boost version must be at least ${min_version}, " "found ${BOOST_VERSION_FORMATTED}") endif() endfunction() ``` -------------------------------- ### Load Tidal Model with Bounding Box Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/getting_started.rst Loads a tidal model configuration, but restricts the loaded region to a specified bounding box. This is efficient for working with large global atlases. ```python config = pyfes.config.load( 'ocean_tide.yaml', bbox=(-10, 40, 10, 60), # (min_lon, min_lat, max_lon, max_lat) ) ``` -------------------------------- ### Find BLAS Library Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Attempts to find the BLAS library, prioritizing Intel MKL dynamic library. If not found, it tries the MKL lp64 sequential model. If MKL is not found, it iterates through a list of other vendors (Apple, OpenBLAS, Generic). ```cmake set(BLA_VENDOR Intel10_64_dyn) find_package(BLAS) if(NOT BLAS_FOUND) # Otherwise try to use MKL lp64 model with sequential code set(BLA_VENDOR Intel10_64lp_seq) find_package(BLAS) endif() if(BLAS_FOUND) # MKL if(DEFINED ENV{MKLROOT}) find_path( MKL_INCLUDE_DIR NAMES mkl.h HINTS $ENV{MKLROOT}/include) if(MKL_INCLUDE_DIR) add_definitions(-DEIGEN_USE_MKL_ALL) add_definitions(-DMKL_LP64) include_directories(${MKL_INCLUDE_DIR}) endif() endif() else() set(BLA_VENDOR_LIST "Apple" "OpenBLAS" "Generic") foreach(item IN LISTS BLA_VENDOR_LIST) set(BLA_VENDOR ${item}) find_package(BLAS) if(BLAS_FOUND) break() endif() endforeach() if(BLAS_FOUND) add_definitions(-DEIGEN_USE_BLAS) else() message( WARNING "No BLAS library has been found. Eigen will use its own BLAS " "implementation.") endif() endif() ``` -------------------------------- ### Enable CTest and Clang-Tidy Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Includes the CTest module if Google Test is found or if Clang-Tidy analysis is enabled. ```cmake if(GTest_FOUND OR FES_ENABLE_CLANG_TIDY) include(CTest) endif() ``` -------------------------------- ### Darwin Module WaveTable and Wave Classes Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/api/engine_modules.rst The pyfes.darwin module provides WaveTable and Wave classes for 99 constituents in Darwin notation with Schureman's nodal corrections. These classes are useful for inspecting constituent definitions and engine-specific behavior. ```APIDOC ## Darwin Module Classes ### Description Provides the 99 constituents expressed in Darwin notation with Schureman's nodal corrections. Useful for inspecting constituent definitions and engine-specific behavior. ### Classes - **pyfes.darwin.WaveTable** - **pyfes.darwin.Wave** ``` -------------------------------- ### pyfes.wave_table_factory Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/api/wave_system.rst Creates a wave table for a specified engine type. This is the entry point for accessing the wave table functionalities. ```APIDOC ## pyfes.wave_table_factory ### Description Creates a wave table for a specified engine type. This function is used to instantiate a `WaveTableInterface` object, which allows for bulk operations on tidal constituents. ### Function Signature `pyfes.wave_table_factory(engine_type: pyfes.EngineType)` ### Parameters #### Arguments - **engine_type** (`pyfes.EngineType`) - Required - The type of engine to use for the wave table (e.g., `pyfes.EngineType.DARWIN`). ### Returns - `pyfes.WaveTableInterface` - An instance of the wave table. ### Example ```python import pyfes wt = pyfes.wave_table_factory(pyfes.EngineType.DARWIN) ``` ``` -------------------------------- ### Enable Compiler Warnings Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Enables common compiler warnings like -Wall and -Wpedantic for C++ code on non-Windows systems. This helps in catching potential issues during development. ```cmake if(NOT WIN32) if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall$") string(APPEND CMAKE_CXX_FLAGS " -Wall") endif() if(NOT CMAKE_CXX_COMPILER MATCHES "icpc$" AND NOT CMAKE_CXX_FLAGS MATCHES "-Wpedantic$") string(APPEND CMAKE_CXX_FLAGS " -Wpedantic") endif() endif() ``` -------------------------------- ### Configure FES Settings with Inference Type Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/user_guide.rst Sets up FES settings using SPLINE inference. This is recommended for FES atlases. ```python settings = pyfes.FESSettings().with_inference_type(pyfes.SPLINE) ``` -------------------------------- ### Find Python and Pybind11 Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Finds Python 3.8 (Interpreter and Development components) and configures Pybind11 for building Python bindings. It then adds the Pybind11 subdirectory. ```cmake if(FES_BUILD_PYTHON_BINDINGS) find_package(Python3 3.8 COMPONENTS Interpreter Development) set(PYBIND11_FINDPYTHON ON) set(PYBIND11_USE_SMART_HOLDER ON) add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/third_party/pybind11") endif() ``` -------------------------------- ### Resolve Boost Include Directory Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt A helper function to find the Boost include directory. It searches in Boost_INCLUDE_DIRS and CMAKE_PREFIX_PATH, looking for 'boost/version.hpp'. This is useful when find_package(Boost) fails. ```cmake function(resolve_boost_include_dir out_var) set(boost_search_hints) if(Boost_INCLUDE_DIRS) list(APPEND boost_search_hints "${Boost_INCLUDE_DIRS}") endif() foreach(prefix IN LISTS CMAKE_PREFIX_PATH) list(APPEND boost_search_hints "${prefix}/include" "${prefix}") endforeach() find_path( _BOOST_INCLUDE_DIR NAMES boost/version.hpp HINTS ${boost_search_hints}) set(${out_var} "${_BOOST_INCLUDE_DIR}" PARENT_SCOPE) endfunction() ``` -------------------------------- ### Add Subdirectories Source: https://github.com/cnes/aviso-fes/blob/main/tests/library/CMakeLists.txt Includes subdirectories into the build. Each subdirectory likely contains its own CMakeLists.txt file to define targets and configurations for specific modules. ```cmake add_subdirectory(angle) add_subdirectory(detail) add_subdirectory(geometry) add_subdirectory(mesh) add_subdirectory(darwin) add_subdirectory(perth) add_subdirectory(tidal_model) ``` -------------------------------- ### Configure RPATH for Shared Libraries Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Sets the CMAKE_INSTALL_RPATH based on the operating system to ensure shared libraries can be found at runtime. ```cmake if(APPLE) list(APPEND CMAKE_INSTALL_RPATH "@loader_path") elseif(UNIX) list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN") endif() ``` -------------------------------- ### YAML Configuration with Dynamic Constituents Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/user_guide.rst Includes a 'dynamic' key in the YAML configuration to list constituents that are part of the atlas but not stored as grid files, affecting calculations and inference. ```yaml tide: cartesian: dynamic: - A5 paths: M2: /path/to/M2.nc ``` -------------------------------- ### Solve Least-Squares Problem for Harmonic Analysis Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/user_guide.rst Perform harmonic analysis by solving the observation equation using least squares. This method requires observed sea level (h), nodal factors (f), and V+u phases (vu) to compute complex amplitudes for each constituent. ```python # h: observed sea level [n_times, n_positions] # f: nodal factors [n_times, n_constituents] # vu: V+u phases [n_times, n_constituents] amplitudes = pyfes.WaveTableInterface.harmonic_analysis(h, f, vu) ``` -------------------------------- ### Configure Sanitizers for GCC/Clang Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Sets up AddressSanitizer (ASan) and UndefinedBehaviorSanitizer (UBSan) for GCC and Clang compilers. Includes LeakSanitizer for Unix-like systems. This is typically used for debugging memory errors. ```cmake if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") set(SANITIZE "address,undefined") if(UNIX AND NOT APPLE) set(SANITIZE "${SANITIZE},leak") endif() set(CMAKE_C_FLAGS_ASAN "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fsanitize=${SANITIZE} \ -fno-omit-frame-pointer -fno-common" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_ASAN "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fsanitize=${SANITIZE} \ -fno-omit-frame-pointer -fno-common" CACHE STRING "" FORCE) set(CMAKE_EXE_LINKER_FLAGS_ASAN "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} -fsanitize=${SANITIZE}" CACHE STRING "" FORCE) set(CMAKE_SHARED_LINKER_FLAGS_ASAN "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} -fsanitize=${SANITIZE}" CACHE STRING "" FORCE) set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel" "Asan") endif() ``` -------------------------------- ### pyfes.generate_markdown_table Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/api/utilities.rst Generates a Markdown table of known tidal constituents. ```APIDOC ## pyfes.generate_markdown_table ### Description Generates a Markdown table of known tidal constituents. ### Returns str: A string containing the Markdown formatted table. ``` -------------------------------- ### Extract Project Version from Header Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Reads version definitions (MAJOR, MINOR, PATCH) from the version.hpp header file using regular expressions. It then processes the patch version to handle development suffixes. ```cmake file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/fes/version.hpp" fes_version_defines REGEX "#define FES_VERSION_(MAJOR|MINOR|PATCH) ") foreach(item ${fes_version_defines}) if(item MATCHES [[#define FES_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$]]) set(FES_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}") endif() endforeach() if(FES_VERSION_PATCH MATCHES [[[0-9]*\.?(dev[0-9]+)]]) set(FES_VERSION_TYPE "${CMAKE_MATCH_1}") endif() string(REGEX MATCH "^[0-9]+" FES_VERSION_PATCH "${FES_VERSION_PATCH}") ``` -------------------------------- ### Configure Visibility for Shared Libraries Source: https://github.com/cnes/aviso-fes/blob/main/CMakeLists.txt Sets C++ visibility options for PIC (Position Independent Code) when building shared libraries or Python bindings, ensuring symbols are hidden by default. ```cmake if((FES_ENABLE_FPIC OR FES_BUILD_PYTHON_BINDINGS) AND NOT BUILD_SHARED_LIBS) set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() ``` -------------------------------- ### Wave Table Factory Function Source: https://github.com/cnes/aviso-fes/blob/main/docs/main_page.dox Create a wave table for a specified engine type using the wave_table_factory function. The wave table provides access to individual waves, nodal correction computation, harmonic analysis, and wave selection. ```cpp auto wt = fes::wave_table_factory(fes::EngineType::kDarwin); ``` -------------------------------- ### Default Settings for FES/Darwin Engine Source: https://github.com/cnes/aviso-fes/blob/main/docs/source/engines.rst This snippet shows how to initialize the FES/Darwin settings class. The default inference type is SPLINE and default astronomic formulae is SCHUREMAN_ORDER_1. Group modulations are disabled by default. ```python settings = pyfes.FESSettings() # Defaults: # inference_type = SPLINE # astronomic_formulae = SCHUREMAN_ORDER_1 # group_modulations = False ``` -------------------------------- ### Wave Table Factory Source: https://github.com/cnes/aviso-fes/blob/main/docs/main_page.dox Factory function to create a wave table interface. ```APIDOC ## fes::wave_table_factory() ### Description Creates a wave table interface for a given engine type. ### Parameters - `engine_type` (fes::EngineType): The type of engine (e.g., `fes::EngineType::kDarwin`). ### Returns A `fes::WaveTableInterface` object. ### Methods on WaveTableInterface - `compute_nodal_corrections()`: Computes nodal corrections. - `harmonic_analysis()`: Performs harmonic analysis. - `select_waves_for_analysis()`: Selects waves for analysis based on the Rayleigh criterion. ```