Skip to content

Commit

Permalink
ECC-1818: Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed May 3, 2024
1 parent 4f577fe commit e152763
Showing 1 changed file with 43 additions and 22 deletions.
65 changes: 43 additions & 22 deletions tests/grib_grid_lamb_az_eq_area.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@

label="grib_grid_lamb_az_eq_area_test"

GRIB_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2
REF_FILE=grib_lamb_az_eq_area.ref
input=${data_dir}/regular_gaussian_pressure_level_constant.grib2
tempRef=grib_lamb_az_eq_area.ref

# Temporary files created for this test
FILTER_FILE=temp.$label.filter
GRIB_OUTFILE=temp.$label.grib2
DATA_OUTFILE=temp.$label.txt
rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE
tempFilt=temp.$label.filter
tempGrib=temp.$label.grib2
tempOut=temp.$label.txt
rm -f $tempFilt $tempGrib $tempOut

# --------------------
# Spherical Earth
# --------------------

# Create a filter
cat > $FILTER_FILE<<EOF
cat > $tempFilt<<EOF
set gridType = "lambert_azimuthal_equal_area";
set Nx = 10;
set Ny = 10;
Expand All @@ -47,26 +47,26 @@ write;
EOF

# Use this filter and the input GRIB to create a new GRIB
rm -f "$GRIB_OUTFILE"
${tools_dir}/grib_filter -o $GRIB_OUTFILE $FILTER_FILE $GRIB_INFILE
rm -f "$tempGrib"
${tools_dir}/grib_filter -o $tempGrib $tempFilt $input

# Now run the Geoiterator on the newly created GRIB file
${tools_dir}/grib_get_data $GRIB_OUTFILE > $DATA_OUTFILE
${tools_dir}/grib_get_data $tempGrib > $tempOut

# Compare output with reference. If the diff fails, script will immediately exit with status 1
diff $REF_FILE $DATA_OUTFILE
diff $tempRef $tempOut

grib_check_key_equals $GRIB_OUTFILE standardParallelInDegrees,centralLongitudeInDegrees '48 9'
grib_check_key_equals $GRIB_OUTFILE xDirectionGridLengthInMetres,yDirectionGridLengthInMetres '5000 5000'
grib_check_key_equals $tempGrib standardParallelInDegrees,centralLongitudeInDegrees '48 9'
grib_check_key_equals $tempGrib xDirectionGridLengthInMetres,yDirectionGridLengthInMetres '5000 5000'

# Nearest
${tools_dir}/grib_ls -l 67,-33,1 $GRIB_OUTFILE
${tools_dir}/grib_ls -l 67,-33,1 $tempGrib

# jPointsAreConsecutive
tempOutA=temp.$label.A.txt
tempOutB=temp.$label.B.txt
${tools_dir}/grib_get_data -s jPointsAreConsecutive=0 $GRIB_OUTFILE > $tempOutA
${tools_dir}/grib_get_data -s jPointsAreConsecutive=1 $GRIB_OUTFILE > $tempOutB
${tools_dir}/grib_get_data -s jPointsAreConsecutive=0 $tempGrib > $tempOutA
${tools_dir}/grib_get_data -s jPointsAreConsecutive=1 $tempGrib > $tempOutB
# Results should be different.
set +e
diff $tempOutA $tempOutB > /dev/null
Expand All @@ -80,7 +80,7 @@ rm -f $tempOutA $tempOutB
# Oblate spheroid
# --------------------

cat > $FILTER_FILE<<EOF
cat > $tempFilt<<EOF
set edition = 2;
set gridType = "lambert_azimuthal_equal_area";
set Nx = 10;
Expand All @@ -101,12 +101,33 @@ write;
EOF

# Use this filter and the input GRIB to create a new GRIB
rm -f "$GRIB_OUTFILE"
${tools_dir}/grib_filter -o $GRIB_OUTFILE $FILTER_FILE $GRIB_INFILE
rm -f "$tempGrib"
${tools_dir}/grib_filter -o $tempGrib $tempFilt $input

${tools_dir}/grib_get_data $GRIB_OUTFILE > $DATA_OUTFILE
${tools_dir}/grib_get_data $tempGrib > $tempOut

# ECC-1818
# ---------
cat > $tempFilt<<EOF
set gridType = "lambert_azimuthal_equal_area";
set shapeOfTheEarth = 5;
set numberOfPointsAlongXAxis = 432;
set numberOfPointsAlongYAxis = 432;
set latitudeOfFirstGridPoint = 16623926;
set longitudeOfFirstGridPoint = -135000000;
set standardParallelInMicrodegrees = 90000000;
set centralLongitudeInMicrodegrees = 0;
set xDirectionGridLengthInMillimetres = 25000000;
set yDirectionGridLengthInMillimetres = 25000000;
set values = 666;
set numberOfDataPoints = 186624;
set numberOfValues = 186624;
write;
EOF

${tools_dir}/grib_filter -o $tempGrib $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_get_data $tempGrib > $tempOut


# Clean up
rm -f $FILTER_FILE $DATA_OUTFILE
rm -f $GRIB_OUTFILE
rm -f $tempFilt $tempOut $tempGrib

0 comments on commit e152763

Please sign in to comment.