Skip to content

Commit

Permalink
Merge pull request #215 from NCAR/cam-fv_even_sphere
Browse files Browse the repository at this point in the history
Make even_sphere.m more general, add synth_obs_locs_to_seqs.csh
  • Loading branch information
kdraeder committed May 26, 2021
2 parents 86ab215 + cd7dd96 commit e743a1e
Show file tree
Hide file tree
Showing 29 changed files with 1,145 additions and 568 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ individual files.

The changes are now listed with the most recent at the top.

**May 18 2021 :: updated process to generate obs on a sphere. Tag: v9.10.5**

- Matlab scripts and new scripts for cam-fv make it simpler to
generate synthetic observations evenly spaced around the sphere.
- Moved create_sphere_obs into the even_sphere directory.

**May 10 2021 :: obs_info support for identity obs Tag: v9.10.4**

- programs/obs_utils/obs_info.f90 now supports reporting identity obs
Expand Down
2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
author = 'Data Assimilation Research Section'

# The full version, including alpha/beta/rc tags
release = '9.10.4'
release = '9.10.5'
master_doc = 'README'

# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions models/cam-fv/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ The indenting shows which scripts are used by, or associated with, another scrip
obs_seq_tool_series.csh Script to process a series of obs_seq.final files,
to change any of the properties available to obs_sequence_tool.
spinup_single_sst.25 Same as cesm2_1/spinup_single, but uses a high resolution SST dataset.
synth_obs_locs_to_seqs.csh Take text output from, e.g. even_sphere.m, and create obs_seq.in files
for use in perfect_model_obs.
The scripts in cesm#_# will handle, for that CESM version;

Expand Down
172 changes: 172 additions & 0 deletions models/cam-fv/shell_scripts/synth_obs_locs_to_seqs.csh
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#!/bin/tcsh
#
# DART software - Copyright UCAR. This open source software is provided
# by UCAR, "as is", without charge, subject to all terms of use at
# https://www2.cisl.ucar.edu/software/dart/download

# ==============================================================================
# Call create_obs_sequence to convert a text file of obs locations and types
# into a set_def.out file.
# Call create_fixed_network_seq to create separate files for each time period.
# This one makes multiple files/day. There's a single time in each file.
# 2 and 4 are the most common numbers of files/day.

# It requires only a few seconds to run a single date with ~100,000 observations,
# in which case it can be run interactively
# and the batch job directives can be ignored.

# (Copy to and) Submit from a case_dir, where there's
# + a text file of locations and types for input to create_obs_sequence,
# (The text file CAN NOT request identity obs unless
# suitable cam{input,_phis}.nc files are provided.)
# + in input.nml which was used to build the create_* programs.
# (minimize printed output by listing only the relevant obs types
# in assimilate_these_obs_types, or utilities_nml:write_nml = 'none').
# Caminput.nc and cam_phis.nc will be linked from the executable directory
# where create_* programs were created.
# The resolution is irrelevant because no identity obs will be requested.
# The time period must be within a calendar month.
# Edit the values below to change the dates and intervals.

# ==============================================================================
#PBS -N synth_obs_locs_to_seqs.csh
#PBS -A P86850054
#PBS -q casper
#PBS -l select=1:ncpus=1:mpiprocs=1
#PBS -l walltime=00:20:00
#PBS -o synth_obs_locs_to_seqs_2017-12.out
#PBS -k eod
#PBS -j oe

#----------------------------------------------------------------------------
#BSUB -J synth_obs_locs_to_seqs_2017-12
#BSUB -n 1
#BSUB -R "span[ptile=1]"
#BSUB -q shared_node_queue_for_this_setup_script
#BSUB -P your_account_there
#BSUB -W 2:00
#BSUB -u you@email.org
#BSUB -N
#BSUB -a poe
#BSUB -o synth_obs_locs_to_seqs_2017-12.out
#BSUB -e synth_obs_locs_to_seqs_2017-12.out
# ==============================================================================
# standard commands:

set VERBOSE = '-v'
set MOVE = '/usr/bin/mv'
set COPY = '/usr/bin/cp --preserve=timestamps'
set LINK = '/usr/bin/ln -s'
set LIST = '/usr/bin/ls'
set REMOVE = '/usr/bin/rm'

set nonomatch # suppress "rm" warnings if wildcard does not match anything

# ==============================================================================
# User set parameters

@ year = 2017
@ month = 12
@ day = 25
@ day_last = 31
@ hour_incr = 6

# case_dir = Directory from which this script is submitted,
# where job diagnostics will go.
# obs_text_file = Text file of obs locations which will be fed to create_obs_sequence.
# obs_out_dir = Directory where obs_seq.in files will be created.
# exec_dir = Directory where create_* programs were built. It is the location
# of the default input files needed by cam-fv's static_init_model.

set case_dir = `pwd`
set obs_text_file = ${case_dir}/even_create_input_all
set obs_out_dir = /glade/p/cisl/dares/Observations/Synthetic/UVTRadiosonde_3456
set exec_dir = /glade/u/home/raeder/DART/reanalysis_git/models/cam-fv/work

# This section could be modified to include running even_sphere.m as part of a single job
# to generate synthetic observations evenly distributed on the sphere.
# \rm -rf matlab_input.m
#
# cat >> matlab_input.m << EndOfInput
#
# nprofiles = 30;
# levels = [1000 850 500 300 200 100];
# T_error_var = [1.44 0.64 0.64 0.81 1.44 0.64];
# W_error_var = [1.96 2.25 4.41 9.00 7.29 4.41];
# even_sphere(nprofiles, 'levels', levels, ...
# 'T_error_var', T_error_var, 'W_error_var', W_error_var)
# fname = sprintf('even_sphere_%d_profiles',nprofiles);
# orient landscape
# print(fname,'-dpdf')
#
# EndOfInput
#
# matlab -nosplash -nodesktop -r "try; cd $PWD; matlab_input; catch; end; exit";

# ==============================================================================

if (! -d $obs_out_dir) mkdir $obs_out_dir
cd $obs_out_dir

# Link to files needed by CAM's static_init_model subroutine,
# which is used by create_fixed_network_seq.
if (-f input.nml) $MOVE input.nml input.nml.$$
$COPY ${case_dir}/input.nml .

if (-f ${case_dir}/caminput.nc) then
$COPY ${case_dir}/caminput.nc .
else
echo "ERROR: failed to find ${case_dir}/caminput.nc"
exit 10
endif

if (-f ${case_dir}/cam_phis.nc) then
$COPY ${case_dir}/cam_phis.nc .
else
echo "ERROR: failed to find ${case_dir}/cam_phis.nc"
exit 20
endif

# Transform the raw obs location data into a set_def.out file
if (! -f set_def.out) then
${exec_dir}/create_obs_sequence < $obs_text_file > /dev/null
if ($status != 0) then
echo "create_obs_sequence failed"
exit 30
endif
endif

# Tranform the set_def.out into a series of obs_seq.in files
# whose names have the CESM date string format in them,
# for use by cam-fv/shell_scripts/assimilate.csh.
while($day <= $day_last)
@ hour = 0
while ($hour < 24)
# cam-fv's perfect_model.csh wants to see this form.
set fstring = `printf obs_seq%04d%02d%02d%02d $year $month $day $hour`
if (-f $fstring) then
echo "$fstring exists: move it and try again"
exit 40
endif

# Create the file which will be input to create_fixed_network_seq
echo "set_def.out" >! create_fixed_input
echo 1 >> create_fixed_input
echo 1 >> create_fixed_input
echo $year $month $day $hour 0 0 >> create_fixed_input
echo '0 0' >> create_fixed_input
echo $fstring >> create_fixed_input

# Create an obs_seq.in file
${exec_dir}/create_fixed_network_seq < create_fixed_input

@ hour += $hour_incr
end

@ day++
end

rm create_fixed_input

exit 0

0 comments on commit e743a1e

Please sign in to comment.