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

New test for diagnostics on model levels. #69

Merged
merged 18 commits into from
Apr 8, 2022
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
38 changes: 35 additions & 3 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ jobs:
gunzip ${OUTPATH}
cd driver/data/outputs/UKMO
md5sum -c cosp2_output_um.gfortran.kgo.$KGO_VERSION.nc.md5
cd ${GITHUB_WORKSPACE}
GDFILE='https://docs.google.com/uc?export=download&id=1z7WtSWRNVKHPe09KXtiUmKUAGPDMQbgh'
OUTPATH=driver/data/outputs/UKMO/cosp2_output.um_global_model_levels.gfortran.kgo.$KGO_VERSION.nc.gz
wget --no-check-certificate $GDFILE -O $OUTPATH
gunzip ${OUTPATH}
cd driver/data/outputs/UKMO
md5sum -c cosp2_output.um_global_model_levels.gfortran.kgo.$KGO_VERSION.nc.md5
###############################################################################
# Run COSP2 tests. We could run both tests in one step, but
# doing it this way the output is easier to interpret.
Expand All @@ -220,6 +227,15 @@ jobs:
source /opt/intel/oneapi/setvars.sh || true
cd driver/run
./cosp2_test cosp2_input_nl.um_global.txt
# 3. UM global snapshot. Diagnostics on model levels.
- name: UM global snapshot. Diagnostics on model levels.
run: |
if [[ "${F90}" = 'gfortran' ]]; then
cd driver/run
./cosp2_test cosp2_input_nl.um_global_model_levels.txt cosp2_output_nl.um_global_model_levels.txt
else
echo "Test is only run for gfortran compiler."
fi
###############################################################################
# Compare results against known good outputs. As above,
# we split it in as many steps as tests.
Expand Down Expand Up @@ -254,23 +270,39 @@ jobs:
--noerror=True --stats_file=${OUTTST}
diff ${OUTKGO} ${OUTTST}
fi
# 3. UM global snapshot. Diagnostics on model levels. Only gfortran.
- name: UM global on model levels against known good output (KGO)
run: |
cd driver
KGO=data/outputs/UKMO/cosp2_output.um_global_model_levels.gfortran.kgo.$KGO_VERSION.nc
TST=data/outputs/UKMO/cosp2_output.um_global_model_levels.nc
if [[ "${F90}" = 'gfortran' ]]; then
python compare_to_kgo.py ${KGO} ${TST} --atol=${ATOL} --rtol=${RTOL}
else
echo "Test only run for gfortran compiler."
fi
###############################################################################
# Produce plots when it fails during global snapshot test,
# Produce plots when it fails during global snapshot tests,
# and create a tarball with outputs.
###############################################################################
- name: Produce plots and create tarball
if: failure()
run: |
TST_MLEV=data/outputs/UKMO/cosp2_output.um_global_model_levels.nc
cd driver
if [[ -e data/outputs/UKMO/cosp2_output.um_global.nc ]]; then
python plot_test_outputs.py
fi
if [[ -e data/outputs/UKMO/cosp2_output.um_global_model_levels.nc ]]; then
python plot_test_outputs.py --tst_file=$TST_MLEV
fi
cd data/outputs/UKMO
tar --ignore-failed-read -czf outputs.UKMO.tgz cosp2_output.um_global.nc \
cosp2_output_um.nc *.png cosp2_output.um_global.out
cosp2_output_um.nc cosp2_output.um_global_model_levels.nc *.png \
cosp2_output.um_global.out
ls -lh
###############################################################################
# Make output files available any test fails
# Make output files available if any test fails
###############################################################################
- name: Upload output file if test fails
if: failure()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2ce8e2ffc41e932cefba275bc2243b2c cosp2_output.um_global_model_levels.gfortran.kgo.v001.nc
4 changes: 2 additions & 2 deletions driver/download_test_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ md5sum -c cosp_input.um_global.nc.md5
# KGO: global UM
cd ${DRIVER_DIR}
GDFILE='https://docs.google.com/uc?export=download&id=1uQBPUEXlniQWEp2nU3iC6d8CO3GM9cvP'
OUTPATH=driver/data/outputs/UKMO/cosp2_output.um_global.gfortran.kgo.$KGO_VERSION.nc.gz
OUTPATH=data/outputs/UKMO/cosp2_output.um_global.gfortran.kgo.$KGO_VERSION.nc.gz
wget --no-check-certificate $GDFILE -O $OUTPATH
gunzip ${OUTPATH}
cd data/outputs/UKMO
md5sum -c cosp2_output.um_global.gfortran.kgo.$KGO_VERSION.nc.md5
# KGO: UM
cd ${DRIVER_DIR}
GDFILE='https://docs.google.com/uc?export=download&id=1gSEdJJpqhfElsFNcTF_r4A_0vIMEWGla'
OUTPATH=driver/data/outputs/UKMO/cosp2_output_um.gfortran.kgo.$KGO_VERSION.nc.gz
OUTPATH=data/outputs/UKMO/cosp2_output_um.gfortran.kgo.$KGO_VERSION.nc.gz
wget --no-check-certificate $GDFILE -O $OUTPATH
gunzip ${OUTPATH}
cd data/outputs/UKMO
Expand Down
41 changes: 25 additions & 16 deletions driver/plot_test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,15 @@ def collapse_dimensions_for_plotting(longitude, latitude, vname, vx, vd, dims):
yticks = y
ylabel = 'Liquid particle size (micron)'
if vd['yaxis_type'] == 'levStat':
y = 480*np.arange(41)
if not dims['levStat'].any():
# For diagnostics on model levels, all elements in levStat
# are set to zero. Keep vertical coordinate as level index.
ylabel = 'Model level'
else:
y = np.concatenate(([0.0], dims['levStat'][::-1] + dims['levStat'][-1]))
ylabel = 'Altitude (m)'
yticks = y[0::4]
yticks_labels = None
ylabel = 'Altitude (m)'
yflip = True
if vd['yaxis_type'] == 'lev':
yticks = y[0::4]
Expand Down Expand Up @@ -297,21 +302,25 @@ def variable2D_metadata(var_list, fname):
zcs_dims = (('levStat','loc'), ('lev','loc'))
f_id = netCDF4.Dataset(fname, 'r')
vmeta = {}
print("=== Processing variables in output file:\n {}".format(fname))
for vname in var_list:
x = f_id.variables[vname]
# Standard map
if x.dimensions in map_dims:
vmeta[vname] = {'plot_type':'map', 'reshape':True}
# 2D histograms
if x.dimensions in hist2D_dims:
vmeta[vname] = {'plot_type':'2Dhist', 'reshape':False,
'xaxis_type': x.dimensions[1],
'yaxis_type': x.dimensions[0]}
# Zonal cross section
if x.dimensions in zcs_dims:
vmeta[vname] = {'plot_type':'zonal_cross_section', 'reshape':True,
'xaxis_type': 'latitude',
'yaxis_type': x.dimensions[0]}
try:
x = f_id.variables[vname]
# Standard map
if x.dimensions in map_dims:
vmeta[vname] = {'plot_type':'map', 'reshape':True}
# 2D histograms
if x.dimensions in hist2D_dims:
vmeta[vname] = {'plot_type':'2Dhist', 'reshape':False,
'xaxis_type': x.dimensions[1],
'yaxis_type': x.dimensions[0]}
# Zonal cross section
if x.dimensions in zcs_dims:
vmeta[vname] = {'plot_type':'zonal_cross_section', 'reshape':True,
'xaxis_type': 'latitude',
'yaxis_type': x.dimensions[0]}
except:
print("Skipping {}, not found in output file.".format(vname))
f_id.close()
return vmeta

Expand Down
96 changes: 96 additions & 0 deletions driver/run/cosp2_input_nl.um_global_model_levels.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
! (c) British Crown Copyright 2022, the Met Office.
! All rights reserved.
!
! Redistribution and use in source and binary forms, with or without modification, are permitted
! provided that the following conditions are met:
!
! * Redistributions of source code must retain the above copyright notice, this list
! of conditions and the following disclaimer.
! * Redistributions in binary form must reproduce the above copyright notice, this list
! of conditions and the following disclaimer in the documentation and/or other materials
! provided with the distribution.
! * Neither the name of the Met Office nor the names of its contributors may be used
! to endorse or promote products derived from this software without specific prior written
! permission.
!
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


! Namelist that sets up the main COSP options
&COSP_INPUT
NPOINTS=1728, ! 1728,6912
NPOINTS_IT=1000,! Max number of gridpoints to be processed in one iteration
NCOLUMNS=20, ! Number of subcolumns
NLEVELS=54, ! Number of model levels
USE_VGRID=.false., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr)
NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.)
CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs.
! USE_VGRID needs also be .true.)
DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files.
! Leave blank ('') if you are using the full path in FINPUT.
FINPUT='../data/inputs/UKMO/cosp_input.um_global.nc', ! List input NetCDF files
FOUTPUT='../data/outputs/UKMO/cosp2_output.um_global_model_levels.nc',
!----------------------------------------------------------------------------------
!--------------- Inputs related to radar simulations
!----------------------------------------------------------------------------------
cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz)
SURFACE_RADAR=0, ! surface=1, spaceborne=0
cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0
cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0
cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default
use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm
cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment'
!----------------------------------------------------------------------------------
!---------------- Inputs related to lidar simulations
!----------------------------------------------------------------------------------
lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical)
OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand
!----------------------------------------------------------------------------------
!---------------- Inputs related to ISCCP simulator
!----------------------------------------------------------------------------------
ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed
! infrared brightness temperature and the visible
! optical depth to adjust cloud top pressure. Note
! that this calculation is most appropriate to compare
! to ISCCP data during sunlit hours.
! 2 = do not adjust top height, that is cloud top
! pressure is the actual cloud top pressure
! in the model
! 3 = adjust top height using only the computed
! infrared brightness temperature. Note that this
! calculation is most appropriate to compare to ISCCP
! IR only algortihm (i.e. you can compare to nighttime
! ISCCP data with this option)
ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level
! with interpolated temperature equal to the radiance
! determined cloud-top temperature
! 1 = find the *lowest* altitude (highest pressure) level
! with interpolated temperature equal to the radiance
! determined cloud-top temperature
! 2 = find the *highest* altitude (lowest pressure) level
! with interpolated temperature equal to the radiance
! determined cloud-top temperature. This is the
! default value since V4.0 of the ISCCP simulator.
! ONLY APPLICABLE IF top_height EQUALS 1 or 3
!----------------------------------------------------------------------------------
!-------------- RTTOV inputs
!----------------------------------------------------------------------------------
rttov_Platform=1, ! satellite platform
rttov_Satellite=15, ! satellite
rttov_Instrument=5, ! instrument
rttov_Nchannels=3, ! Number of channels to be computed
rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels)
rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels)
rttov_ZenAng=50.0, ! Satellite Zenith Angle
CO2=5.241e-04, ! Mixing ratios of trace gases
CH4=9.139e-07,
N2O=4.665e-07,
CO=2.098e-07
/
Loading