Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update develop-ref after #1835. #1846

Merged
merged 8 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/jobs/build_documentation.sh
Original file line number Diff line number Diff line change
@@ -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
22 changes: 6 additions & 16 deletions .github/workflows/main.yml → .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: MET CI/CD Workflow
name: Documentation
on:
push:
branches:
Expand All @@ -7,6 +7,8 @@ on:
- feature_*
- main_*
- bugfix_*
paths:
- met/docs/**
pull_request:
types: [opened, reopened, synchronize]

Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions met/src/basic/vx_log/file_fxns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions met/src/basic/vx_util/data_plane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion met/src/basic/vx_util/data_plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
63 changes: 42 additions & 21 deletions met/src/tools/other/point2grid/point2grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<from_lon_cnt; xIdx++) {
for (int yIdx=0; yIdx<from_lat_cnt; yIdx++) {
int offset = fr_dp.two_to_one(xIdx,yIdx);
int offset = fr_dp.two_to_one(xIdx,yIdx,is_to_north);
from_data[offset] = fr_dp.get(xIdx,yIdx);
}
}
Expand Down Expand Up @@ -1313,7 +1313,6 @@ void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf,
int offset = to_dp.two_to_one(xIdx,yIdx);
cellArray = cellMapping[offset];
if (0 < cellArray.n()) {
int valid_cnt = 0;
dataArray.clear();
dataArray.extend(cellArray.n());
for (int dIdx=0; dIdx<cellArray.n(); dIdx++) {
Expand All @@ -1330,14 +1329,13 @@ void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf,
if (from_min_value > 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();
Expand All @@ -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 {
Expand Down Expand Up @@ -1685,7 +1694,7 @@ void check_lat_lon(int data_size, float *latitudes, float *longitudes) {
for (int idx=0; idx<data_size; idx++) {
if (cnt_printed < 10 && latitudes[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++;
}
Expand Down Expand Up @@ -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;
Expand All @@ -1807,11 +1817,14 @@ static void get_grid_mapping_latlon(
for (int xIdx=0; xIdx<to_size; xIdx++) to_cell_counts[xIdx] = 0;
for (int xIdx=0; xIdx<data_size; xIdx++) mapping_indices[xIdx] = bad_data_int;

to_grid.xy_to_latlon(0, 0, to_ll_lat, to_ll_lon);
mlog << Debug(5) << method_name << " to_grid ll corner: (" << to_ll_lon << ", " << to_ll_lat << ")\n";

//Count the number of cells to be mapped to TO_GRID
//Following the logic at DataPlane::two_to_one(int x, int y) n = y*Nx + x;
for (int xIdx=0; xIdx<from_lat_count; xIdx++) {
for (int yIdx=0; yIdx<from_lon_count; yIdx++) {
int coord_offset = from_dp.two_to_one(yIdx, xIdx);
for (int yIdx=0; yIdx<from_lat_count; yIdx++) {
for (int xIdx=0; xIdx<from_lon_count; xIdx++) {
int coord_offset = from_dp.two_to_one(xIdx, yIdx, to_north);
if( skip_times != 0 && skip_times[coord_offset] ) continue;
lat = latitudes[coord_offset];
lon = longitudes[coord_offset];
Expand All @@ -1824,6 +1837,12 @@ static void get_grid_mapping_latlon(
mapping_indices[coord_offset] = to_offset;
to_cell_counts[to_offset] += 1;
count_in_grid++;
if(mlog.verbosity_level() >= 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";
}
}
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions scripts/installation/config/install_met_env.kiowa
Original file line number Diff line number Diff line change
Expand Up @@ -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

#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}