Skip to content
Snippets Groups Projects
Commit 213b8aa0 authored by RIETTE Sébastien's avatar RIETTE Sébastien
Browse files

check_commit_mesonh comparison updated

shebang for compare.py
Use of diff instead of cmp
Final message print
parent c583256e
No related branches found
No related tags found
No related merge requests found
......@@ -186,14 +186,19 @@ if [ $run -ge 1 ]; then
fi
if [ $check -eq 1 ]; then
allt=0
echo "### Check commit $commit against commit $reference"
echo "Compare with python..."
# Compare variable of both Synchronous and Diachronic files with printing difference
set +e
if [ "$reference" == "" ]; then
python3 $PHYEXTOOLSDIR/compare.py $commit ref
$PHYEXTOOLSDIR/compare.py $commit ref
else
python3 $PHYEXTOOLSDIR/compare.py $commit $reference
$PHYEXTOOLSDIR/compare.py $commit $reference
fi
t=$?
set -e
allt=$(($allt+$t))
#Check bit-repro after date of creation of Synchronous file from ncdump of all values (pb with direct .nc file checks)
file1=$REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_$commit/16JAN.1.12B18.001.nc
......@@ -203,9 +208,17 @@ if [ $check -eq 1 ]; then
file2=$REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_$reference/16JAN.1.12B18.001.nc
fi
echo "Compare with ncdump..."
ncdump $file1 > dump_$commit
ncdump $file2 > dump_$reference
cmp -n 62000 dump_$commit dump_$reference
rm -f dump_$commit dump_$reference
echo "...comparison done"
set +e
diff <(ncdump $file1 | head -c 62889) <(ncdump $file2 | head -c 62889)
t=$?
set -e
allt=$(($allt+$t))
#rm -f dump_$commit dump_$reference
if [ $allt -eq 0 ]; then
status="OK"
else
status="Files are different"
fi
echo "...comparison done: $status"
fi
compare.py 100644 → 100755
import xarray as xr
import os
#REFDIR a renseigner
#REFDIR="/home/rodierq/"
REFDIR = os.environ['REFDIR']
def compareFiles(file1,file2):
path_user=REFDIR+'MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_'+file1
if file2 == "ref":
path_ref=REFDIR+'MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2'
else:
path_ref=REFDIR+'MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_'+file2
filen='16JAN.1.12B18.001.nc'
da = xr.open_dataset(path_user+'/'+filen)
da2 = xr.open_dataset(path_ref+'/'+filen)
variables=list(da.keys())
for var in variables:
try:
ecart_min=float(da2[var].min())-float(da[var].min())
ecart_moy=float(da2[var].mean())-float(da[var].mean())
ecart_max=float(da2[var].max())-float(da[var].max())
if (ecart_min !=0 or ecart_moy !=0 or ecart_max !=0):
print(var,ecart_min,ecart_moy,ecart_max)
except:
pass
filen='16JAN.1.12B18.000.nc'
da = xr.open_dataset(path_user+'/'+filen)
da2 = xr.open_dataset(path_ref+'/'+filen)
variables=list(da.keys())
for var in variables:
try:
ecart_min=float(da2[var].min())-float(da[var].min())
ecart_moy=float(da2[var].mean())-float(da[var].mean())
ecart_max=float(da2[var].max())-float(da[var].max())
if (ecart_min !=0 or ecart_moy !=0 or ecart_max !=0):
print(var,ecart_min,ecart_moy,ecart_max)
except:
pass
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description='Compare toutes les variables si trouvées dans les deux fichiers')
value = argparse.ArgumentParser()
parser.add_argument('file1', metavar='file1', type=str, help="file1 user ")
parser.add_argument('file2', metavar='file2', type=str, help="file2 reference; ref for MNH-V5-5-0 reference")
args = parser.parse_args()
compareFiles(args.file1,args.file2)
#!/usr/bin/env python3
import xarray as xr
import os
REFDIR = os.environ['REFDIR']
def compareFiles(file1, file2):
status = 0
path_user = REFDIR + 'MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_' + file1
if file2 == "ref":
path_ref = REFDIR + 'MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2'
else:
path_ref = REFDIR + 'MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_' + file2
filen = '16JAN.1.12B18.001.nc'
da = xr.open_dataset(path_user + '/' + filen)
da2 = xr.open_dataset(path_ref + '/' + filen)
variables = list(da.keys())
for var in variables:
try:
ecart_min = float(da2[var].min())-float(da[var].min())
ecart_moy = float(da2[var].mean())-float(da[var].mean())
ecart_max = float(da2[var].max())-float(da[var].max())
if (ecart_min !=0 or ecart_moy !=0 or ecart_max !=0):
status += 1
print(var, ecart_min, ecart_moy, ecart_max)
except:
pass
filen = '16JAN.1.12B18.000.nc'
da = xr.open_dataset(path_user + '/' + filen)
da2 = xr.open_dataset(path_ref + '/' + filen)
variables = list(da.keys())
for var in variables:
try:
ecart_min = float(da2[var].min())-float(da[var].min())
ecart_moy = float(da2[var].mean())-float(da[var].mean())
ecart_max = float(da2[var].max())-float(da[var].max())
if (ecart_min !=0 or ecart_moy !=0 or ecart_max !=0):
status += 1
print(var, ecart_min, ecart_moy, ecart_max)
except:
pass
return status
if __name__ == "__main__":
import argparse
import sys
parser = argparse.ArgumentParser(description='Compare toutes les variables si trouvées dans les deux fichiers')
value = argparse.ArgumentParser()
parser.add_argument('file1', metavar='file1', type=str, help="file1 user ")
parser.add_argument('file2', metavar='file2', type=str, help="file2 reference; ref for MNH-V5-5-0 reference")
args = parser.parse_args()
sys.exit(compareFiles(args.file1, args.file2))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment