diff --git a/.github/jobs/build_documentation.sh b/.github/jobs/build_documentation.sh new file mode 100755 index 0000000000..c6b73500a2 --- /dev/null +++ b/.github/jobs/build_documentation.sh @@ -0,0 +1,25 @@ +#! /bin/bash + +# path to docs directory relative to top level of repository +# $GITHUB_WORKSPACE is set if the actions/checkout@v2 action is run first + +DOCS_DIR=${GITHUB_WORKSPACE}/met/docs + +# run Make to build the documentation and return to previous directory +cd ${DOCS_DIR} +make clean html +cd - + +# copy HTML output into directory to create an artifact +mkdir -p artifact/documentation +cp -r ${DOCS_DIR}/_build/html/* artifact/documentation + +# check if the warnings.log file is empty +# Copy it into the artifact and documentation directories +# so it will be available in the artifacts +warning_file=${DOCS_DIR}/_build/warnings.log +if [ -s $warning_file ]; then + cp -r ${DOCS_DIR}/_build/warnings.log artifact/doc_warnings.log + cp artifact/doc_warnings.log artifact/documentation + exit 1 +fi diff --git a/.github/workflows/main.yml b/.github/workflows/documentation.yml similarity index 59% rename from .github/workflows/main.yml rename to .github/workflows/documentation.yml index d959c9e411..62c284aded 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/documentation.yml @@ -1,4 +1,4 @@ -name: MET CI/CD Workflow +name: Documentation on: push: branches: @@ -7,6 +7,8 @@ on: - feature_* - main_* - bugfix_* + paths: + - met/docs/** pull_request: types: [opened, reopened, synchronize] @@ -24,26 +26,14 @@ jobs: python -m pip install --upgrade python-dateutil requests sphinx \ sphinx-gallery Pillow sphinx_rtd_theme - name: Build docs - continue-on-error: true - run: | - DOCS_DIR=${GITHUB_WORKSPACE}/met/docs - cd ${DOCS_DIR} - make clean html - cd ${GITHUB_WORKSPACE} - warning_file=${DOCS_DIR}/_build/warnings.log - mkdir -p artifact/documentation - cp -r ${DOCS_DIR}/_build/html/* artifact/documentation - if [ -s $warning_file ]; then - cp -r ${DOCS_DIR}/_build/warnings.log artifact/doc_warnings.log - cp artifact/doc_warnings.log artifact/documentation - else - rm ${warning_file} - fi + run: ./.github/jobs/build_documentation.sh - uses: actions/upload-artifact@v2 + if: always() with: name: documentation path: artifact/documentation - uses: actions/upload-artifact@v2 + if: failure() with: name: documentation_warnings.log path: artifact/doc_warnings.log diff --git a/met/src/basic/vx_log/file_fxns.cc b/met/src/basic/vx_log/file_fxns.cc index 16a98ce261..49a5fec382 100644 --- a/met/src/basic/vx_log/file_fxns.cc +++ b/met/src/basic/vx_log/file_fxns.cc @@ -28,8 +28,7 @@ using namespace std; bool is_regular_file(const char *path) { struct stat path_stat; - stat(path, &path_stat); - return(S_ISREG(path_stat.st_mode)); + return(!stat(path, &path_stat) && S_ISREG(path_stat.st_mode)); } //////////////////////////////////////////////////////////////////////// diff --git a/met/src/basic/vx_util/data_plane.cc b/met/src/basic/vx_util/data_plane.cc index 043e1d7c7b..c855b2a1d5 100644 --- a/met/src/basic/vx_util/data_plane.cc +++ b/met/src/basic/vx_util/data_plane.cc @@ -410,7 +410,7 @@ return; /////////////////////////////////////////////////////////////////////////////// -int DataPlane::two_to_one(int x, int y) const { +int DataPlane::two_to_one(int x, int y, bool to_north) const { int n; if((x < 0) || (x >= Nx) || (y < 0) || (y >= Ny)) { @@ -420,7 +420,7 @@ int DataPlane::two_to_one(int x, int y) const { exit(1); } - n = y*Nx + x; // don't change this! lots of downstream code depends on this! + n = (to_north ? y : (Ny-1-y))*Nx + x; // don't change this! lots of downstream code depends on this! return(n); } diff --git a/met/src/basic/vx_util/data_plane.h b/met/src/basic/vx_util/data_plane.h index 54e3606b55..650d62b226 100644 --- a/met/src/basic/vx_util/data_plane.h +++ b/met/src/basic/vx_util/data_plane.h @@ -109,7 +109,7 @@ class DataPlane { void replace_bad_data(const double value); - int two_to_one(int x, int y) const; + int two_to_one(int x, int y, bool to_north=true) const; void one_to_two(int n, int &x, int &y) const; bool s_is_on(int x, int y) const; diff --git a/met/src/tools/other/point2grid/point2grid.cc b/met/src/tools/other/point2grid/point2grid.cc index 6402fff121..8f718b0e2a 100644 --- a/met/src/tools/other/point2grid/point2grid.cc +++ b/met/src/tools/other/point2grid/point2grid.cc @@ -328,7 +328,6 @@ void process_command_line(int argc, char **argv) { //////////////////////////////////////////////////////////////////////// void process_data_file() { - DataPlane fr_dp; Grid fr_grid, to_grid; GrdFileType ftype; ConcatString run_cs; @@ -1282,10 +1281,11 @@ void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, exit(1); } else { + bool is_to_north = !fr_grid.get_swap_to_north(); float *from_data = new float[from_data_size]; for (int xIdx=0; xIdx data_value) from_min_value = data_value; if (from_max_value < data_value) from_max_value = data_value; } - - valid_cnt++; } - + if (0 < dataArray.n()) { - int data_cnt = dataArray.n(); float to_value; - if (RGInfo.method == InterpMthd_Min) to_value = dataArray.min(); + int data_cnt = dataArray.n(); + if (1 == data_cnt) to_value = dataArray[0]; + else if (RGInfo.method == InterpMthd_Min) to_value = dataArray.min(); else if (RGInfo.method == InterpMthd_Max) to_value = dataArray.max(); else if (RGInfo.method == InterpMthd_Median) { dataArray.sort_array(); @@ -1349,12 +1347,23 @@ void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, to_dp.set(to_value, xIdx, yIdx); to_cell_cnt++; - mlog << Debug(9) << method_name - << "max: " << dataArray.max() - << ", min: " << dataArray.min() - << ", mean: " << dataArray.sum()/data_cnt - << " from " << valid_cnt << " out of " - << data_cnt << " data values.\n"; + if(mlog.verbosity_level() >= 9) { + double to_lat, to_lon; + to_grid.xy_to_latlon(xIdx,yIdx, to_lat, to_lon); + to_lon *= -1; + if (1 == data_cnt) + mlog << Debug(9) << method_name + << "value: " << to_value << " to (" << to_lon << ", " << to_lat + << ") from offset " << from_index << ".\n"; + else + mlog << Debug(9) << method_name + << "value: " << to_value + << ", max: " << dataArray.max() + << ", min: " << dataArray.min() + << ", mean: " << dataArray.sum()/data_cnt + << " from " << data_cnt << " (out of " << cellArray.n() + << ") data values to (" << to_lon << ", " << to_lat << ").\n"; + } } } else { @@ -1685,7 +1694,7 @@ void check_lat_lon(int data_size, float *latitudes, float *longitudes) { for (int idx=0; idx MISSING_LATLON && longitudes[idx] > MISSING_LATLON) { - mlog << Debug(7) << method_name << "index: " << idx << " lat: " + mlog << Debug(11) << method_name << "index: " << idx << " lat: " << latitudes[idx] << ", lon: " << longitudes[idx] << "\n"; cnt_printed++; } @@ -1790,8 +1799,9 @@ static bool get_grid_mapping(Grid to_grid, IntArray *cellMapping, static void get_grid_mapping_latlon( DataPlane from_dp, DataPlane to_dp, Grid to_grid, IntArray *cellMapping, float *latitudes, float *longitudes, - int from_lat_count, int from_lon_count, bool *skip_times) { + int from_lat_count, int from_lon_count, bool *skip_times, bool to_north) { double x, y; + double to_ll_lat, to_ll_lon; float lat, lon; int idx_x, idx_y, to_offset; int count_in_grid = 0; @@ -1807,11 +1817,14 @@ static void get_grid_mapping_latlon( for (int xIdx=0; xIdx= 15) { + double to_lat, to_lon; + to_grid.xy_to_latlon(idx_x, idx_y, to_lat, to_lon); + mlog << Debug(15) << method_name << " [" << xIdx << "," << yIdx << "] to " << coord_offset + << " (" << lon << ", " << lat << ") to (" << (to_lon*-1) << ", " << to_lat << ")\n"; + } } } } @@ -1918,7 +1937,8 @@ static bool get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, if( status ) { get_grid_mapping_latlon(from_dp, to_dp, to_grid, cellMapping, latitudes, longitudes, from_lat_count, - from_lon_count, skip_times); + from_lon_count, skip_times, + !fr_grid.get_swap_to_north()); } if( latitudes ) delete [] latitudes; if( longitudes ) delete [] longitudes; @@ -2129,7 +2149,8 @@ void get_grid_mapping(Grid fr_grid, Grid to_grid, IntArray *cellMapping, else { check_lat_lon(data_size, latitudes, longitudes); get_grid_mapping_latlon(from_dp, to_dp, to_grid, cellMapping, latitudes, - longitudes, from_lat_count, from_lon_count, 0); + longitudes, from_lat_count, from_lon_count, 0, + !fr_grid.get_swap_to_north()); } if (latitudes_buf) delete [] latitudes_buf; diff --git a/scripts/installation/config/install_met_env.kiowa b/scripts/installation/config/install_met_env.kiowa index e063cea272..7ff69f7ef8 100644 --- a/scripts/installation/config/install_met_env.kiowa +++ b/scripts/installation/config/install_met_env.kiowa @@ -11,13 +11,13 @@ export SET_D64BIT=FALSE export CFLAGS="-Wall -g" export CXXFLAGS="-Wall -g" -#If you've already compiled these and don't need to compile them again, set the following +# If you've already compiled these and don't need to compile them again, set the following; +# Otherwise, if you do need to install these libraries, comment out the variables below export EXTERNAL_LIBS=/d1/personal/jpresto/MET/MET_testing/mod_script/external_libs -export MET_GRIB2CLIB=${EXTERNAL_LIBS}/lib -export MET_GRIB2CINC=${EXTERNAL_LIBS}/include -export GRIB2CLIB_NAME=-lgrib2c -export MET_BUFRLIB=${EXTERNAL_LIBS}/lib -export BUFRLIB_NAME=-lbufr -export MET_NETCDF=${EXTERNAL_LIBS}/lib -# Also, don't forget to set the following options to zero within the compile script if you've already compiled those libraries as well: COMPILE_GSL, COMPILE_HDF, COMPILE_HDFEOS, COMPILE_CAIRO, COMPILE_FREETYPE - \ No newline at end of file +#export MET_GRIB2CLIB=${EXTERNAL_LIBS}/lib +#export MET_GRIB2CINC=${EXTERNAL_LIBS}/include +#export GRIB2CLIB_NAME=-lgrib2c +#export MET_BUFRLIB=${EXTERNAL_LIBS}/lib +#export BUFRLIB_NAME=-lbufr +#export MET_NETCDF=${EXTERNAL_LIBS} +