Skip to content

Commit

Permalink
Added test case for perturbation data.
Browse files Browse the repository at this point in the history
  • Loading branch information
lars2015 committed Feb 5, 2025
1 parent ff366a2 commit 3455a60
Show file tree
Hide file tree
Showing 15 changed files with 42,243 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ src/sampling
src/spec2tab
src/variance
src/volcano
tests/data/SNDR*nc
tests/data/cris_l1b_full.zip
tests/pert_test/data/
21 changes: 20 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Executables...
EXC = day2doy doy2day map_pert map_rad noise_pert perturbation sampling spec2tab variance volcano

# Tests...
TESTS = pert_test

# Installation directory...
DESTDIR ?= ../bin

Expand All @@ -26,6 +29,9 @@ INFO ?= 0
# Compile for profiling...
PROF ?= 0

# Compile for coverage testing...
COV ?= 0

# -----------------------------------------------------------------------------
# Set flags for GNU compiler...
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -53,6 +59,11 @@ ifeq ($(PROF),1)
CFLAGS += -pg
endif

# Compile for coverage testing...
ifeq ($(COV),1)
CFLAGS += --coverage
endif

# Static compilation...
ifeq ($(STATIC),1)
CFLAGS += -static
Expand All @@ -76,6 +87,14 @@ libcris.o: libcris.c libcris.h Makefile
jurassic.o: jurassic.c jurassic.h Makefile
$(CC) $(CFLAGS) -c -o jurassic.o jurassic.c

check: $(TESTS)

$(TESTS): all
@(echo "\n===== Running \"$@\" ... =====") ; \
cd ../tests/$@ ; ./run.sh \
&& (echo "\n===== Test \"$@\" passed! =====") \
|| (echo "\n===== Test \"$@\" failed! =====" ; exit 1)

clean:
rm -rf $(EXC) *.o *.gcda *.gcno *.gcov coverage* *~

Expand All @@ -89,7 +108,7 @@ cppcheck:

dist:
cd .. && tar cvfz cris_$(VERSION).tgz bin/* \
docs/Doxyfile example/* libs/build.sh libs/*gz src/*
docs/Doxyfile example/* libs/build.sh libs/*gz src/* tests/*

doxygen:
cd ../docs && doxygen
Expand Down
Binary file added tests/data/cris_l1b.z01
Binary file not shown.
Binary file added tests/data/cris_l1b.zip
Binary file not shown.
12,206 changes: 12,206 additions & 0 deletions tests/pert_test/data.ref/map_15mu_high.tab

Large diffs are not rendered by default.

12,206 changes: 12,206 additions & 0 deletions tests/pert_test/data.ref/map_15mu_low.tab

Large diffs are not rendered by default.

12,206 changes: 12,206 additions & 0 deletions tests/pert_test/data.ref/map_4mu.tab

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions tests/pert_test/data.ref/noise_15mu_high.tab
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# $1 = longitude [deg]
# $2 = latitude [deg]
# $3 = mean brightness temperature [K]
# $4 = noise estimate [K]

6.83922 -56.997 262.576 0.294744
6 changes: 6 additions & 0 deletions tests/pert_test/data.ref/noise_15mu_low.tab
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# $1 = longitude [deg]
# $2 = latitude [deg]
# $3 = mean brightness temperature [K]
# $4 = noise estimate [K]

6.83922 -56.997 239.119 0.0764632
6 changes: 6 additions & 0 deletions tests/pert_test/data.ref/noise_4mu.tab
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# $1 = longitude [deg]
# $2 = latitude [deg]
# $3 = mean brightness temperature [K]
# $4 = noise estimate [K]

6.83922 -56.997 252.844 0.0665062
Binary file added tests/pert_test/data.ref/pert.nc
Binary file not shown.
1,847 changes: 1,847 additions & 0 deletions tests/pert_test/data.ref/var_15mu_high.tab

Large diffs are not rendered by default.

1,847 changes: 1,847 additions & 0 deletions tests/pert_test/data.ref/var_15mu_low.tab

Large diffs are not rendered by default.

1,847 changes: 1,847 additions & 0 deletions tests/pert_test/data.ref/var_4mu.tab

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions tests/pert_test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! /bin/bash

# Set environment...
export LD_LIBRARY_PATH=../../libs/build/lib:$LD_LIBRARY_PATH
export OMP_NUM_THREADS=4

# Setup...
cris=../../src

# Uncompress test data...
cd ../data \
&& zip -s 0 cris_l1b.zip --out cris_l1b_full.zip \
&& unzip -o cris_l1b_full.zip \
&& cd - || exit

# Create directory...
rm -rf data && mkdir -p data || exit

# Create perturbation file...
$cris/perturbation - data/pert.nc \
../data/SNDR.SNPP.CRIS.20220115T0000.m06.g001.L1B.std.v03_08.G.220115064421.nc

# Loop over channel sets...
for pert in 4mu 15mu_low 15mu_high ; do

# Get map data...
$cris/map_pert - data/pert.nc data/map_$pert.tab PERTNAME $pert

# Estimate noise...
$cris/noise_pert - data/pert.nc data/noise_$pert.tab PERTNAME $pert

# Get variance...
$cris/variance - data/var_$pert.tab data/pert.nc PERTNAME $pert NX 60 NY 30

done

# Compare files...
echo -e "\nCompare results..."
error=0
for f in $(ls data.ref/*.nc data.ref/*.tab) ; do
diff -q -s data/"$(basename "$f")" "$f" || error=1
done
exit $error

0 comments on commit 3455a60

Please sign in to comment.