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

Update timeseries plots to resolve issue with some fields #539

Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 7 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 @@ -44,6 +44,8 @@ set fieldlist=("total ice area (km^2)" \
"total ice extent(km^2)" \
"total ice volume (m^3)" \
"total snw volume (m^3)" \
"sst (C) " \
"arwt tot mass (kg) " \
"rms ice speed (m/s)" )

# Get the filename for the latest log
Expand All @@ -59,8 +61,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
16 changes: 12 additions & 4 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 Expand Up @@ -215,6 +216,8 @@ def main():
volume?', action='store_true')
parser.add_argument('--speed', dest='speed', help='Create a plot for rms ice speed?', \
action='store_true')
parser.add_argument('--sst', dest='sst', help='Create a plot for sst?', \
action='store_true')
parser.add_argument('--grid',dest='grid', help='Add grid lines to the figures?', \
action='store_true')

Expand All @@ -225,17 +228,20 @@ def main():
parser.set_defaults(ice_volume=False)
parser.set_defaults(snow_volume=False)
parser.set_defaults(speed=False)
parser.set_defaults(sst=False)
parser.set_defaults(grid=False)

args = parser.parse_args()

# If no fields are passed, plot all fields
if not ( args.area or args.extent or args.ice_volume or args.snow_volume or args.speed ):
if not ( args.area or args.extent or args.ice_volume or args.snow_volume or args.speed \
args.sst ):
args.area = True
args.extent = True
args.ice_volume = True
args.snow_volume = True
args.speed = True
args.sst = True

# Build the fieldlist based on which fields are passed
fieldlist = []
Expand All @@ -249,6 +255,8 @@ def main():
fieldlist.append('total snw volume (m^3)')
if args.speed:
fieldlist.append('rms ice speed (m/s)')
if args.sst:
fieldlist.append('sst (C) ')

# Setup the logger
global logger
Expand Down