Skip to content

Commit 142f1e7

Browse files
Add files via upload
3 files added which will run the plotting using GMT6 installed on Windows WSL Ubuntu.
1 parent d57944e commit 142f1e7

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/sh
2+
#
3+
# Steven J Gibbons
4+
# 2023-11-10
5+
# Rough script to make a png output from a BingCLAW fort output file
6+
# Requires GMT installed.
7+
# (Converted to assume GMT6 and that the program gmt is in the path)
8+
#
9+
latmin=62.00
10+
latmax=66.00
11+
lonmin=-2.00
12+
lonmax=7.00
13+
proj=-JM12
14+
reg=-R${lonmin}/${lonmax}/${latmin}/${latmax}
15+
#
16+
gmt gmtset BASEMAP_TYPE FANCY LABEL_FONT_SIZE 12 \
17+
LABEL_FONT 1 D_FORMAT %.12lg \
18+
PLOT_DEGREE_FORMAT +D
19+
#
20+
scriptname=./gmt6_one_fortfile_2_png.sh
21+
if [ $# != 1 ]
22+
then
23+
echo
24+
echo "USAGE: "
25+
echo "$scriptname ../fort.q0179 "
26+
echo
27+
exit 1
28+
fi
29+
#
30+
fortfile=$1
31+
if test ! -r ${fortfile}
32+
then
33+
echo No file ${fortfile} found ...
34+
exit 1
35+
fi
36+
claw2file3=./claw2file3.py
37+
if test ! -r ${claw2file3}
38+
then
39+
echo No file ${claw2file3} found ...
40+
exit 1
41+
fi
42+
convertpy=./format3.py
43+
if test ! -r ${convertpy}
44+
then
45+
echo No file ${convertpy} found ...
46+
exit 1
47+
fi
48+
shortfile=`basename $fortfile`
49+
stem=`echo $shortfile | sed 's/fort.//g'`
50+
number=`echo $stem | sed 's/q//g'`
51+
# minutes=`multiply $number 2.0 f6.1 `
52+
minutes=`echo $number 2.0 | awk '{printf("%6.1f\n",$1*$2)}' `
53+
timestring="Time: $minutes minutes"
54+
ncfile=${stem}.nc
55+
python3 ${claw2file3} -c1 -f ${fortfile} -s ${ncfile}
56+
mindepth=0.0
57+
maxdepth=450.0
58+
incdepth=25.0
59+
elevinca=100.0
60+
elevincf=50.0
61+
if test ! -r depth.cpt
62+
then
63+
gmt makecpt -Chot -T${mindepth}/${maxdepth}/${incdepth} -I > depth.cpt
64+
fi
65+
echo $stem
66+
fil=${stem}.ps
67+
gmt grdimage $ncfile -Cdepth.cpt $reg $proj -P -K -V > $fil
68+
gmt pscoast $reg $proj -Df -N1/2/0/0/0 -Ba2g2/a1g1/neWS -V \
69+
-G120/120/120 -O -K >> $fil
70+
echo " -1.8 65.8 18 0 1 ML $timestring" | gmt pstext $reg $proj -O -K >> $fil
71+
gmt psscale -D0.65/2.5/4.0/0.6 -Cdepth.cpt \
72+
-Ba${elevinca}f${elevincf}::/:"depth(m)": -O >> $fil
73+
gmt psconvert $fil -TG -A
74+
pngfile=${stem}.png
75+
if test ! -d png_files
76+
then
77+
mkdir png_files
78+
fi
79+
if test -r ${pngfile}
80+
then
81+
mv ${pngfile} png_files
82+
fi
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
for fortfile in ../fort.q*
3+
do
4+
sh ./gmt6_one_fortfile_2_png.sh ${fortfile}
5+
done
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import PIL
2+
from PIL import Image
3+
import numpy as np
4+
5+
scenario = "png_files"
6+
image_frames = []
7+
8+
steps = np.arange( 1, 180, 1 )
9+
10+
for k in steps:
11+
stepstring = "{:04}".format( k )
12+
filename = "./" + scenario + "/" + "q" + stepstring + ".png"
13+
print ( filename )
14+
newimage = PIL.Image.open(r'' + filename)
15+
image_frames.append( newimage )
16+
##DONOTUSE! newimage.show()
17+
18+
outfile = "./" + "BingCLAW" + ".gif"
19+
image_frames[0].save( outfile, format = 'GIF',
20+
append_images = image_frames[1:],
21+
save_all = True, duration = 90, loop = 0 )
22+

0 commit comments

Comments
 (0)