Skip to content

Commit

Permalink
Update timeseries plots to resolve issue with some fields (#539)
Browse files Browse the repository at this point in the history
* Update the timeseries plots to accurately extract data from log files.  Also add an option to plot SST from the python plotting script.  This addresses issue #538

* Fix 2 typos

* Remove SST and arwt tot mass from list of fields to plot
  • Loading branch information
mattdturner authored Dec 7, 2020
1 parent f299b33 commit 40d3867
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 5 additions & 3 deletions configuration/scripts/timeseries.csh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ endif
set basename = `echo $1 | sed -e 's#/$##' | sed -e 's/^\.\///'`

# Set x-axis limits
# Manuallyl set x-axis limits
# Manually set x-axis limits
#set xrange = 'set xrange ["19980101":"19981231"]'
# Let gnuplot determine x-alis limits
# Let gnuplot determine x-axis limits
set xrange = ''

# Determine if BASELINE dataset exists
Expand Down Expand Up @@ -59,8 +59,10 @@ endif

# Loop through each field and create the plot
foreach field ($fieldlist:q)
# Add backslashes before (, ), and ^ for grep searches
set search_name = "`echo '$field' | sed 's/(/\\(/' | sed 's/)/\\)/' | sed 's/\^/\\^/'`"
set fieldname = `echo "$field" | sed -e 's/([^()]*)//g'`
set search = "'$fieldname'\|istep1"
set search = "'$search_name'\|istep1"
rm -f data.txt
foreach line ("`egrep $search $logfile`")
if ("$line" =~ *"istep1"*) then
Expand Down
7 changes: 4 additions & 3 deletions configuration/scripts/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_data(logfile,field):
# Build the regular expression to extract the data
field_regex = field.replace('(','\(').replace('^','\^').replace(')','\)')
number_regex = '[-+]?\d+\.?\d+([eE][-+]?\d+)?'
my_regex = '{}\s+=\s+({})\s+({})'.format(field_regex,number_regex,number_regex)
my_regex = '^{}\s+=\s+({})\s+({})'.format(field_regex,number_regex,number_regex)

dtg = []
arctic = []
Expand Down Expand Up @@ -95,9 +95,10 @@ def plot_timeseries(log, field, dtg, arctic, antarctic, expon, dtg_base=None, ar
Plot the timeseries data from the CICE log file
'''

casename = os.path.abspath(log).rstrip('/').rstrip('/logs').split('/')[-1]
import re
casename = re.sub(r"/logs", "", os.path.abspath(log).rstrip('/')).split('/')[-1]
if base_dir:
base_casename = os.path.abspath(base_dir).rstrip('/').rstrip('/logs').split('/')[-1]
base_casename = re.sub(r"/logs", "", os.path.abspath(base_dir).rstrip('/')).split('/')[-1]

# Load the plotting libraries, but set the logging level for matplotlib
# to WARNING so that matplotlib debugging info is not printed when running
Expand Down

0 comments on commit 40d3867

Please sign in to comment.