Skip to content

Commit

Permalink
Fix problems with plotting VALNA min/max streamfunction and MLD diagn…
Browse files Browse the repository at this point in the history
…ostics with python 3.

Need to copy fix from VALSO - remove valid_min, valid_max attributes which are set to strange values
and which get taken more seriously at python 3. Issue #6.
  • Loading branch information
DaveStorkey committed Jan 2, 2025
1 parent e4fb0be commit 60a2eb9
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 145 deletions.
65 changes: 0 additions & 65 deletions SCRIPT/#mk_psi_NA.bash#

This file was deleted.

1 change: 0 additions & 1 deletion SCRIPT/.#mk_psi_NA.bash

This file was deleted.

3 changes: 2 additions & 1 deletion SCRIPT/mk_mxl_NA.bash
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ fi
ijbox=$($CDFPATH/cdffindij -c mesh.nc -w -60.000 -50.000 55.000 62.000 | tail -2 | head -1)
echo ijbox
$CDFPATH/cdfmean -f $FILEOUT -v 'somxl030' -p T -w ${ijbox} 0 0 -minmax -o tmp_LAB_MXL_$FILEOUT
#-minmax computes & outputs the min and max in .nc file
# this step needed because cdfmean sets a strange value for valid_max and that messes up the plotting routines.
ncatted -a valid_max,mean_somxl030,d,, tmp_LAB_MXL_$FILEOUT

# mv output file
if [[ $? -eq 0 ]]; then
Expand Down
6 changes: 2 additions & 4 deletions SCRIPT/mk_mxl_SO.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ if [ ! -f $FILE ] ; then echo "$FILE is missing; exit"; echo "E R R O R in : ./m
FILEOUT=WMXL_nemo_${RUN_NAME}o_${FREQ}_${TAG}_grid-${GRID}.nc
ijbox=$($CDFPATH/cdffindij -c mesh.nc -p T -w -31.250 37.500 -66.500 -60.400 | tail -2 | head -1)
$CDFPATH/cdfmean -f $FILE -v '|somxzint1|sokaraml|' -p T -w ${ijbox} 0 0 -minmax -o tmp_$FILEOUT
# this step needed because cdfmean sets a strange value for valid_max and that messes up the plotting routines.
ncatted -a valid_max,max_somxzint1,d,, tmp_$FILEOUT

# mv output file
if [[ $? -eq 0 ]]; then
Expand All @@ -34,7 +36,3 @@ else
echo "error when running cdfmxl; exit"; echo "E R R O R in : ./mk_mxl.bash $@ (see SLURM/${RUNID}/mxl_${FREQ}_${TAG}.out)" >> ${EXEPATH}/ERROR.txt ; exit 1
fi

# this step needed because cdfmean sets a strange value for valid_max and that messes up the plotting routines.
ncatted -a valid_max,max_somxzint1,d,, $FILEOUT

#
2 changes: 2 additions & 0 deletions SCRIPT/mk_psi_NA.bash
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ $CDFPATH/cdfmean -f $FILEOUT -v sobarstf -p T -w ${ijbox} 0 0 -minmax -o BSF_NA_
# a horizontal mean for each level is also given. If a 2D spatial window
# is specified, the mean value is computed only in this window.
if [ $? -ne 0 ] ; then echo "error when running cdfmean (WG)"; echo "E R R O R in : ./mk_psi.bash $@ (see ${JOBOUT_PATH}/mk_psi_${FREQ}_${TAG}.out)" >> ${EXEPATH}/ERROR.txt ; fi
# this step needed because cdfmean sets a strange value for valid max and that messes up the plotting routines.
ncatted -a valid_min,min_sobarstf,d,, -a valid_max,min_sobarstf,d,, BSF_NA_$FILEOUT
72 changes: 0 additions & 72 deletions SCRIPT/mk_psi_NA.bash~

This file was deleted.

2 changes: 2 additions & 0 deletions SCRIPT/plot_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,13 @@ def main():

run_lst[irun].load_time_series(cfile, cvar)
ts_lst[irun] = run_lst[irun].ts
print("run_lst[irun] min/max : ",run_lst[irun].min,run_lst[irun].max)
lg = ts_lst[irun].plot(ax=ax[ivar], legend=False, style=run_lst[irun].line,color=run_lst[irun].color,label=run_lst[irun].name, x_compat=True, linewidth=2, rot=0)
#
# limit of time axis
mintime=min([mintime,ts_lst[irun].index[0].to_pydatetime().date()])
maxtime=max([maxtime,ts_lst[irun].index[-1].to_pydatetime().date()])
print("mintime, maxtime : ",mintime,maxtime)

# set title
if (args.title):
Expand Down
2 changes: 0 additions & 2 deletions run_plot_VALNA.bash
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ echo ' '

# NA subpolar gyre max strength
echo 'plot NA subpolar gyre strength time series'
# note python2.7 is deliberately stated otherwise fails to plot
python SCRIPT/plot_time_series.py -noshow -runid $RUNIDS -f *BSF_NA*${FREQ}*psi_NA.nc -var min_sobarstf -title "SPG max strength (Sv)" -dir ${DATPATH} -o ${KEY}_BSF -sf -0.000001 #-obs OBS/SUBP_PSI_obs.txt
#-sf is scale factor i.e. m3/s to Sv
#using min and negative scale factor because streamf is negative in subpolar gyre
Expand All @@ -40,7 +39,6 @@ if [[ $? -ne 0 ]]; then exit 42; fi

# mean MXL depth in Lab Sea in March (averaged in small region)
echo 'plot mean MXL depth in Lab Sea time series'
# note python2.7 is deliberately stated rather than just python otherwise error: attributes of masked are not writeable
python SCRIPT/plot_time_series.py -noshow -runid $RUNIDS -f *LAB_MXL*1m*0301*T*003*.nc -var mean_somxl030 -title "Mean MXL in Lab Sea in March (m)" -dir ${DATPATH} -o ${KEY}_MXL_LAB_MEAN -sf -1 -obs OBS/MXL_lab_mean_obs.txt
if [[ $? -ne 0 ]]; then exit 42; fi

Expand Down
Binary file removed test_valna_20Dec.png
Binary file not shown.
Binary file removed test_valso_20Dec.png
Binary file not shown.
Binary file removed test_valtrans_20Dec.png
Binary file not shown.

0 comments on commit 60a2eb9

Please sign in to comment.