Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 89.64 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. ##
  4. coding: utf - 8# In[2]: ##Library 로드하기
  5. import os
  6. import pandas as pd
  7. import numpy as np
  8. import sys
  9. import matplotlib.pyplot as plt from dplython
  10. import * #(
  11. DplyFrame,
  12. X,
  13. diamonds,
  14. select,
  15. sift,
  16. sample_n, #sample_frac,
  17. head,
  18. arrange,
  19. mutate,
  20. group_by,
  21. summarize,
  22. DelayFunction
  23. ) from scipy.stats
  24. import linregress from matplotlib
  25. import pyplot as plt from IPython.display
  26. import Image from mpl_toolkits.basemap
  27. import Basemap from matplotlib.colors
  28. import Normalize
  29. import matplotlib
  30. import matplotlib.cm as cm
  31. import seaborn as sns from scipy.stats
  32. import linregress from matplotlib
  33. import rcParams from netCDF4
  34. import Dataset
  35. import struct
  36. import binascii from mpl_toolkits.basemap
  37. import addcyclic from mpl_toolkits.basemap
  38. import shiftgrid from netCDF4
  39. import num2date,
  40. date2num,
  41. date2index
  42. import datetime from pyhdf.SD
  43. import SD,
  44. SDC
  45. import h5py
  46. import timeit from datetime
  47. import datetime from colormap
  48. import rgb2hex from matplotlib
  49. .colors
  50. import LinearSegmentedColormap from matplotlib
  51. import rc from mpl_toolkits
  52. .axes_grid1
  53. import make_axes_locatable
  54. import matplotlib
  55. .patches as patches from scipy
  56. .ndimage
  57. .filters
  58. import gaussian_filter from matplotlib
  59. .collections
  60. import PatchCollection from matplotlib
  61. .patches
  62. import Polygon
  63. import matplotlib
  64. .pyplot as plt from matplotlib
  65. .patches
  66. import PathPatch
  67. import shapefile# MATPLOTLIB 경고 무시
  68. import warnings warnings
  69. .filterwarnings("ignore") import gc gc
  70. .enable()# In[3]: #파일 인포 보기 start = timeit
  71. .default_timer() path = "D:/ocean_model_out/mohid_hydr"
  72. os
  73. .chdir(path) os
  74. .getcwd() ncfile_p = 'BS_MOHID_HYDR_2019021800.nc'
  75. ncfile = Dataset(ncfile_p) print(
  76. ncfile
  77. ) print(ncfile.variables.keys()) nc_value = ncfile
  78. .variables
  79. .keys()# In[4]: #모든 값 추출하기 lon = ncfile
  80. .variables[u 'lon'][: ] lat = ncfile
  81. .variables[u 'lat'][: ] time = ncfile
  82. .variables[u 'time'][: ] print('a') lat_staggered = ncfile
  83. .variables[u 'lat_staggered'][: ] lon_staggered = ncfile
  84. .variables[u 'lon_staggered'][: ] print('b') bathymetry = ncfile
  85. .variables[u 'bathymetry'][: ] mask = ncfile
  86. .variables[u 'mask'][: ] ssh = ncfile
  87. .variables[u 'ssh'][: ]# In[5]: #print('a')# lat_staggered = ncfile
  88. .variables[u 'lat_staggered'][: ]# lon_staggered = ncfile
  89. .variables[u 'lon_staggered'][: ]# print('b')# bathymetry = ncfile
  90. .variables[u 'bathymetry'][: ]# mask = ncfile
  91. .variables[u 'mask'][: ]# ssh = ncfile
  92. .variables[u 'ssh'][: ]# print('c')# U = ncfile
  93. .variables[u 'u'][: ]# V = ncfile
  94. .variables[u 'v'][: ]# VM = ncfile
  95. .variables[u 'vm'][: ]# print('d')# salinity = ncfile
  96. .variables[u 'salinity'][: ]# temperature = ncfile
  97. .variables[u 'temperature'][: ]# print('e')# mask_OpenPoints = ncfile
  98. .variables[u 'mask_OpenPoints'][: ]# print('f')# stop = timeit
  99. .default_timer()# print(stop - start)# In[6]: BS1_DIR = "D:/ocean_model_out/wave_ko/shpfile/BS_1Poly"
  100. BS1_FILE = "BS_1Poly"
  101. BS2_DIR = "D:/ocean_model_out/wave_ko/shpfile/BS_2Poly"
  102. BS2_FILE = "BS_2Poly"
  103. BS3_DIR = "D:/ocean_model_out/wave_ko/shpfile/BS_3Poly"
  104. BS3_FILE = "BS_3Poly"
  105. BS4_DIR = "D:/ocean_model_out/wave_ko/shpfile/BS_4Poly"
  106. BS4_FILE = "BS_4Poly"
  107. BSPOLY_DIR = "D:/ocean_model_out/wave_ko/shpfile/BSPoly"
  108. BSPOLY_FILE = "BSPoly"
  109. JPPOLY_DIR = "D:/ocean_model_out/wave_ko/shpfile/JPPoly"
  110. JPPOLY_FILE = "JPPoly"#
  111. In[7]: #;
  112. -- -- -- -- - Domain Setting-- -- -- - start - ::BS 1# bs = 0;
  113. 4;
  114. boundary space# Ls = bs + 110;
  115. bs + 0;
  116. lat start# Ms = bs + 1;
  117. bs + 0;
  118. lon start# Lm = Ls + 213;
  119. Lm - bs;
  120. lat end# Mm = Ms + 240;
  121. Mm - bs;
  122. lon end#;
  123. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --end - #lat = 660 lon = 836################### BS######################### minlon = min(
  124. lon
  125. ) maxlon = max(lon) minlat = min(lat) maxlat = max(lat)################### BS1######################## bs1 = 0 #4;
  126.  
  127. boundary space Ls1 = bs1 + 110#;
  128. bs + 0;
  129. lat start Ms1 = bs1 + 1#;
  130. bs + 0;
  131. lon start Lm1 = Ls1 + 213#;
  132. Lm - bs;
  133. lat end Mm1 = Ms1 + 240#;
  134. Mm - bs;
  135. lon end################### BS2######################## bs2 = 0 #4;
  136.  
  137. boundary space Ls2 = bs2 + 210#;
  138. bs + 0;
  139. lat start Ms2 = bs2 + 165#;
  140. bs + 0;
  141. lon start Lm2 = Ls2 + 200#;
  142. Lm - bs;
  143. lat end Mm2 = Ms2 + 240#;
  144. Mm - bs;
  145. lon end################### BS3######################## bs3 = 0 #4;
  146.  
  147. boundary space Ls3 = bs3 + 335#;
  148. bs + 0;
  149. lat start Ms3 = bs3 + 220#;
  150. bs + 0;
  151. lon start Lm3 = Ls3 + 210#;
  152. Lm - bs;
  153. lat end Mm3 = Ms3 + 240#;
  154. Mm - bs;
  155. lon end################### BS4######################## bs4 = 0 #4;
  156.  
  157. boundary space Ls4 = bs4 + 440#;
  158. bs + 0;
  159. lat start Ms4 = bs4 + 220#;
  160. bs + 0;
  161. lon start Lm4 = Ls4 + 219#;
  162. Lm - bs;
  163. lat end Mm4 = Ms4 + 300#;
  164. Mm - bs;
  165. lon end print(Ls1, Lm1, Ms1, Mm1) print(Ls2, Lm2, Ms2, Mm2) print(
  166. Ls3,
  167. Lm3,
  168. Ms3,
  169. Mm3
  170. ) print(Ls4, Lm4, Ms4, Mm4) MINLON_BS = min(lon) MAXLON_BS = max(lon) MINLAT_BS = min(
  171. lat
  172. ) MAXLAT_BS = max(lat) MINLON_BS1 = lon[Ms1] MAXLON_BS1 = lon[Mm1] MINLAT_BS1 = lat[Ls1] MAXLAT_BS1 = lat[Lm1] MINLON_BS2 = lon[Ms2] MAXLON_BS2 = lon[Mm2] MINLAT_BS2 = lat[Ls2] MAXLAT_BS2 = lat[Lm2] MINLON_BS3 = lon[Ms3] MAXLON_BS3 = lon[Mm3] MINLAT_BS3 = lat[Ls3] MAXLAT_BS3 = lat[Lm3] MINLON_BS4 = lon[Ms4] MAXLON_BS4 = lon[Mm4] MINLAT_BS4 = lat[Ls4] MAXLAT_BS4 = lat[Lm4]# In[8]: bsmap = Basemap(
  173. projection = 'merc',
  174. lon_0 = (MINLON_BS + MAXLON_BS) / 2.0,
  175. lat_0 = (MINLAT_BS + MAXLAT_BS) / 2.0,
  176. llcrnrlon = MINLON_BS,
  177. llcrnrlat = MINLAT_BS,
  178. urcrnrlon = MAXLON_BS,
  179. urcrnrlat = MAXLAT_BS,
  180. resolution = 'c'
  181. ) bsmap1 = Basemap(
  182. projection = 'merc',
  183. lon_0 = (MINLON_BS1 + MAXLON_BS1) / 2.0,
  184. lat_0 = (MINLAT_BS1 + MAXLAT_BS1) / 2.0,
  185. llcrnrlon = MINLON_BS1,
  186. llcrnrlat = MINLAT_BS1,
  187. urcrnrlon = MAXLON_BS1,
  188. urcrnrlat = MAXLAT_BS1,
  189. resolution = 'c'
  190. ) bsmap2 = Basemap(
  191. projection = 'merc',
  192. lon_0 = (MINLON_BS2 + MAXLON_BS2) / 2.0,
  193. lat_0 = (MINLAT_BS2 + MAXLAT_BS2) / 2.0,
  194. llcrnrlon = MINLON_BS2,
  195. llcrnrlat = MINLAT_BS2,
  196. urcrnrlon = MAXLON_BS2,
  197. urcrnrlat = MAXLAT_BS2,
  198. resolution = 'c'
  199. ) bsmap3 = Basemap(
  200. projection = 'merc',
  201. lon_0 = (MINLON_BS3 + MAXLON_BS3) / 2.0,
  202. lat_0 = (MINLAT_BS3 + MAXLAT_BS3) / 2.0,
  203. llcrnrlon = MINLON_BS3,
  204. llcrnrlat = MINLAT_BS3,
  205. urcrnrlon = MAXLON_BS3,
  206. urcrnrlat = MAXLAT_BS3,
  207. resolution = 'c'
  208. ) bsmap4 = Basemap(
  209. projection = 'merc',
  210. lon_0 = (MINLON_BS4 + MAXLON_BS4) / 2.0,
  211. lat_0 = (MINLAT_BS4 + MAXLAT_BS4) / 2.0,
  212. llcrnrlon = MINLON_BS4,
  213. llcrnrlat = MINLAT_BS4,
  214. urcrnrlon = MAXLON_BS4,
  215. urcrnrlat = MAXLAT_BS4,
  216. resolution = 'c'
  217. ) bsmap
  218. .readshapefile(BSPOLY_DIR, BSPOLY_FILE) bsmap1
  219. .readshapefile(BS1_DIR, BS1_FILE) bsmap2
  220. .readshapefile(BS2_DIR, BS2_FILE) bsmap3
  221. .readshapefile(BS3_DIR, BS3_FILE) bsmap4
  222. .readshapefile(BS4_DIR, BS4_FILE) bsmap
  223. .readshapefile(JPPOLY_DIR, JPPOLY_FILE) bsmap1
  224. .readshapefile(JPPOLY_DIR, JPPOLY_FILE) bsmap2
  225. .readshapefile(JPPOLY_DIR, JPPOLY_FILE) bsmap3
  226. .readshapefile(JPPOLY_DIR, JPPOLY_FILE) bsmap4
  227. .readshapefile(JPPOLY_DIR, JPPOLY_FILE)# In[9]: lon2D,
  228. lat2D = np.meshgrid(lon, lat) BS_X,
  229. BS_Y = bsmap(lon2D, lat2D) BS1_X,
  230. BS1_Y = bsmap1(lon2D, lat2D) BS2_X,
  231. BS2_Y = bsmap2(lon2D, lat2D) BS3_X,
  232. BS3_Y = bsmap3(lon2D, lat2D) BS4_X,
  233. BS4_Y = bsmap4(lon2D, lat2D)# In[10]: ##bln 파일 로드 blnFilePath1 = "D:/ocean_model_out/mohid_hydr/blue-line.bln"
  234. blnFilePath2 = "D:/ocean_model_out/mohid_hydr/deasan-habor-line.bln"
  235. blnFilePath3 = "D:/ocean_model_out/mohid_hydr/green-line.bln"
  236. blnFilePath4 = "D:/ocean_model_out/mohid_hydr/inchon-habor-line.bln"
  237. blnFilePath5 = "D:/ocean_model_out/mohid_hydr/KMA-habor-line.bln"
  238. blnFilePath6 = "D:/ocean_model_out/mohid_hydr/red-line.bln"
  239. blue_line = pd.read_csv(
  240. blnFilePath1,
  241. sep = '\s+',
  242. header = None
  243. ) deasan_habor_line = pd.read_csv(blnFilePath2, sep = '\s+', header = None) green_line = pd.read_csv(
  244. blnFilePath3,
  245. sep = '\s+',
  246. header = None
  247. ) inchon_habor_line = pd.read_csv(blnFilePath4, sep = '\s+', header = None) KMA_habor_line = pd.read_csv(
  248. blnFilePath5,
  249. sep = '\s+',
  250. header = None
  251. ) red_line = pd.read_csv(blnFilePath6, sep = '\s+', header = None) blue_linex = [
  252. []
  253. for i in range(0, 1000)
  254. ] blue_liney = [
  255. []
  256. for i in range(0, 1000)
  257. ] deasan_habor_linex = [
  258. []
  259. for i in range(0, 1000)
  260. ] deasan_habor_liney = [
  261. []
  262. for i in range(0, 1000)
  263. ] green_linex = [
  264. []
  265. for i in range(0, 1000)
  266. ] green_liney = [
  267. []
  268. for i in range(0, 1000)
  269. ] inchon_habor_linex = [
  270. []
  271. for i in range(0, 1000)
  272. ] inchon_habor_liney = [
  273. []
  274. for i in range(0, 1000)
  275. ] KMA_habor_linex = [
  276. []
  277. for i in range(0, 1000)
  278. ] KMA_habor_liney = [
  279. []
  280. for i in range(0, 1000)
  281. ] blue_linex = [
  282. []
  283. for i in range(0, 1000)
  284. ] blue_liney = [
  285. []
  286. for i in range(0, 1000)
  287. ] red_linex = [
  288. []
  289. for i in range(0, 1000)
  290. ] red_liney = [
  291. []
  292. for i in range(0, 1000)
  293. ] count_blue = 0
  294. for i in range(0, len(blue_line)): if (((blue_line[0][i] - blue_line[1][i]) % 1) != 0): blue_linex[count_blue].append(
  295. blue_line[0][i]
  296. ) blue_liney[count_blue].append(blue_line[1][i])
  297. else :count_blue += 1;
  298. count = 0
  299. for i in range(0, len(deasan_habor_line)): if (((deasan_habor_line[0][i] - deasan_habor_line[1][i]) % 1) != 0): deasan_habor_linex[count].append(
  300. deasan_habor_line[0][i]
  301. ) deasan_habor_liney[count].append(deasan_habor_line[1][i])
  302. else :count += 1;
  303. count_green = 0
  304. for i in range(0, len(green_line)): if (((green_line[0][i] - green_line[1][i]) % 1) != 0): green_linex[count_green].append(
  305. green_line[0][i]
  306. ) green_liney[count_green].append(green_line[1][i])
  307. else :count_green += 1;
  308. count = 0
  309. for i in range(0, len(inchon_habor_line)): if (((inchon_habor_line[0][i] - inchon_habor_line[1][i]) % 1) != 0): inchon_habor_linex[count].append(
  310. inchon_habor_line[0][i]
  311. ) inchon_habor_liney[count].append(inchon_habor_line[1][i])
  312. else :count += 1;
  313. count = 0
  314. for i in range(0, len(KMA_habor_line)): if (((KMA_habor_line[0][i] - KMA_habor_line[1][i]) % 1) != 0): KMA_habor_linex[count].append(
  315. KMA_habor_line[0][i]
  316. ) KMA_habor_liney[count].append(KMA_habor_line[1][i])
  317. else :count += 1;
  318. count_red = 0
  319. for i in range(0, len(red_line)): if (((red_line[0][i] - red_line[1][i]) % 1) != 0): red_linex[count_red].append(
  320. red_line[0][i]
  321. ) red_liney[count_red].append(red_line[1][i])
  322. else :count_red += 1;#
  323. In[15]: #[18, 16, 15, 13, 12]# Depth 값에 따른 마스크 setting 하기..##이것은 구조화를 위한 코드...bathymetry_0m_point = np.where(
  324. bathymetry > 0,
  325. 1.0,
  326. -999.0
  327. ) bathymetry_10m_point = np.where(bathymetry > 10, 1.0, -999.0) bathymetry_25m_point = np.where(
  328. bathymetry > 25,
  329. 1.0,
  330. -999.0
  331. ) bathymetry_50m_point = np.where(bathymetry > 50, 1.0, -999.0) bathymetry_75m_point = np.where(
  332. bathymetry > 75,
  333. 1.0,
  334. -999.0
  335. )# def clean_memory(): #del varU# del varV# del varVM# del
  336. var# del Q##
  337. return (
  338. 0
  339. ) def
  340. switch (value, index): if (index == 18): value = value * bathymetry_0m_point elif(
  341. index == 16
  342. ): value = value * bathymetry_10m_point elif(index == 15): value = value * bathymetry_25m_point elif(
  343. index == 13
  344. ): value = value * bathymetry_50m_point elif(index == 12): value = value * bathymetry_75m_point
  345. else :print(
  346. "인덱스에 없는 value입니다. 처음의 value 값이 반환되었습니다."
  347. ) return (value)# shp 파일 색칠하는 함수들..def BSPOLY(map_object): patches = []
  348. for info, shape in zip(map_object.BSPoly_info, map_object.BSPoly): patches.append(Polygon(np.array(shape), True)) return (patches) def BSPOLY1(map_object): patches = []
  349. for info, shape in zip(map_object.BS_1Poly_info, map_object.BS_1Poly): patches.append(Polygon(np.array(shape), True)) return (patches) def BSPOLY2(map_object): patches = []
  350. for info, shape in zip(map_object.BS_2Poly_info, map_object.BS_2Poly): patches.append(Polygon(np.array(shape), True)) return (patches) def BSPOLY3(map_object): patches = []
  351. for info, shape in zip(map_object.BS_3Poly_info, map_object.BS_3Poly): patches.append(Polygon(np.array(shape), True)) return (patches) def BSPOLY4(map_object): patches = []
  352. for info, shape in zip(map_object.BS_4Poly_info, map_object.BS_4Poly): patches.append(Polygon(np.array(shape), True)) return (patches) def JPPOLY(map_object): patches = []
  353. for info, shape in zip(map_object.JPPoly_info, map_object.JPPoly): patches.append(Polygon(np.array(shape), True)) return (patches) def greenline(map_object): for line in range(0, count_green, 1): #print(line) aa, bb = map_object(green_linex[line][: ], green_liney[line][: ]) plt.plot(aa, bb, color = 'green') return (0) def redline(map_object): for line in range(0, count_red, 1): #print(line) aa, bb = map_object(red_linex[line][: ], red_liney[line][: ]) plt.plot(aa, bb, color = 'red') return (0) def blueline(map_object): for line in range(0, count_blue, 1): #print(line) aa, bb = map_object(blue_linex[line][: ], blue_liney[line][: ]) plt.plot(aa, bb, color = 'blue') return (0)# In[11]: #시간 추출(UTC and KST) wet = 1104537600# start time = 2005 / 01 / 01 / 00 / 00 / 00 UTC print(lat.shape, lon.shape) print(time) timelen = len(time) times = [0] * timelen local_dt = [0] * timelen print(times) for i in range(0, timelen): times[i] = datetime.utcfromtimestamp(
  354. time[int(i)] + wet
  355. ).strftime('%Y-%m-%d %H')# to UTC local_dt[i] = datetime.fromtimestamp(
  356. time[int(i)] + wet
  357. ).strftime('%Y-%m-%d %H')# to KST print(times) print(local_dt)# In[12]: #ncl color table## 컬러바 만들기 color_table = [
  358. [
  359. 235, 255, 255, 1
  360. ],
  361. [
  362. 229, 255, 255
  363. ],
  364. [
  365. 211, 255, 255
  366. ],
  367. [
  368. 193, 255, 255
  369. ],
  370. [
  371. 175, 243, 255
  372. ],
  373. [
  374. 164, 225, 255
  375. ],
  376. [
  377. 157, 207, 255
  378. ],
  379. [
  380. 255, 255, 180
  381. ],
  382. [
  383. 255, 255, 160
  384. ],
  385. [
  386. 255, 255, 140
  387. ],
  388. [
  389. 255, 255, 120
  390. ],
  391. [
  392. 255, 255, 100
  393. ],
  394. [
  395. 255, 255, 50
  396. ],
  397. [
  398. 255, 255, 0
  399. ],
  400. [
  401. 255, 202, 108
  402. ],
  403. [
  404. 255, 184, 90
  405. ],
  406. [
  407. 255, 166, 72
  408. ],
  409. [
  410. 255, 148, 54
  411. ],
  412. [
  413. 255, 130, 36
  414. ],
  415. [
  416. 255, 112, 18
  417. ],
  418. [
  419. 255, 110, 0
  420. ],
  421. [
  422. 237, 94, 0
  423. ],
  424. [
  425. 255, 72, 72
  426. ],
  427. [
  428. 255, 54, 54
  429. ],
  430. [
  431. 255, 18, 18
  432. ],
  433. [
  434. 237, 0, 0
  435. ],
  436. [
  437. 219, 0, 0
  438. ],
  439. [
  440. 201, 0, 0
  441. ],
  442. [
  443. 165, 0, 0
  444. ],
  445. [
  446. 147, 0, 0
  447. ],
  448. [
  449. 129, 0, 0
  450. ],
  451. [
  452. 111, 0, 0
  453. ],
  454. [
  455. 93, 0, 0
  456. ]
  457. ];
  458. a = [0] * len(color_table) for i in range(0, len(color_table)): a[i] = rgb2hex(color_table[i][0], color_table[i][1], color_table[i][2]) b = ['#000000', '#000000'] c = [
  459. "#00007F",
  460. "blue",
  461. "#007FFF",
  462. "cyan",
  463. "#7FFF7F",
  464. "yellow",
  465. "#FF7F00",
  466. "red"
  467. ] cmap_jet = LinearSegmentedColormap.from_list('mycmap', a) vcmap = LinearSegmentedColormap.from_list('vcmap', b) cmap_jet1 = LinearSegmentedColormap.from_list('mycmap', c) cmap_jet.set_under('w') cmap_jet.set_over('#2F0000') cmap_jet.set_bad('w') cmap_jet1.set_under('#00007F') cmap_jet1.set_over('#FF0000') cmap_jet1.set_bad('w')# In[13]: yy = np.arange(0, len(lat), 20) xx = np.arange(0, len(lon), 20) points = np.meshgrid(yy, xx) cv_tick = np.linspace(0.0, 2.0, 31, endpoint = True) cv_cbar_tick = np.linspace(0.0, 2.0, 11, endpoint = True) tp_cbar_tick = np.linspace(0.0, 33.0, 12, endpoint = True) tp_conf_tick = np.linspace(0.0, 33.0, 64, endpoint = True) tp_cont_tick = np.linspace(0.0, 33.0, 34, endpoint = True) sa_cbar_tick = np.linspace(25.0, 35.0, 6, endpoint = True) sa_conf_tick = np.linspace(25.0, 35.0, 64, endpoint = True) sa_cont_tick = np.linspace(25.0, 35.0, 21, endpoint = True)# < h1 > BS_cv < /h1> # In[16]: arrow_magn=20.0 dep = [0,10,25,50,75] depnum = [18,16,15,13,12] #surface /
  468. 10 m / 25 m / 50 m / 75 m
  469. for i in range(0, timelen, 1): depcount = -1
  470. for j in depnum: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  471. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  472. plt.rcParams["font.weight"] = "bold"
  473. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  474. plt.rcParams["axes.titleweight"] = "bold"
  475. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  476. 'figure.autolayout': True
  477. })# vector extract varU = ncfile.variables[u 'u'][i, j,: ,: ] varV = ncfile.variables[u 'v'][i, j,: ,: ] varVM = ncfile.variables[u 'vm'][i, j,: ,: ] varVM =
  478. switch (
  479. varVM,
  480. j
  481. )# 마스크 계산 함수 호출...varVM = np.ma.array(varVM, mask = varVM <= 0.0) plt.contour(
  482. BS_X,
  483. BS_Y,
  484. varVM,
  485. cv_tick,
  486. linewidths = 0,
  487. color = 'k'
  488. ) bsmap.contourf(
  489. BS_X,
  490. BS_Y,
  491. varVM,
  492. cv_tick,
  493. cmap = cmap_jet,
  494. vmin = 0,
  495. vmax = 2,
  496. extend = 'both'
  497. )# color bar colorbar = bsmap.colorbar(
  498. location = 'right',
  499. size = 0.25,
  500. ticks = cv_cbar_tick,
  501. cmap = cmap_jet,
  502. extendrect = 'False'
  503. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# vector mapping meana = np.mean(
  504. varVM[points]
  505. ) Q = bsmap.quiver(
  506. lon2D[points],
  507. lat2D[points],
  508. varU[points],
  509. varV[points],
  510. varVM[points],
  511. pivot = 'middle',
  512. cmap = vcmap,
  513. latlon = True,
  514. scale_units = 'inches',
  515. scale = meana * arrow_magn,
  516. minlength = 0.1,
  517. headwidth = 4.0
  518. ) plt.quiverkey(
  519. Q,
  520. 0.1,
  521. 0.95,
  522. 1,
  523. '' + str(int(1)) + 'm/s',
  524. labelpos = 'N',
  525. fontproperties = {
  526. 'weight': 'bold',
  527. 'size': '12'
  528. },
  529. labelsep = 0.1
  530. ) plt.quiverkey(
  531. Q,
  532. 0.1,
  533. 0.95,
  534. 1,
  535. 'Reference Vector',
  536. labelpos = 'S',
  537. fontproperties = {
  538. 'weight': 'bold',
  539. 'size': '12'
  540. },
  541. labelsep = 0.1
  542. ) BSPATCH = BSPOLY(bsmap) JPPATCH = JPPOLY(bsmap) ax.add_collection(
  543. PatchCollection(
  544. BSPATCH,
  545. facecolor = 'lightgray',
  546. edgecolor = 'k',
  547. linewidths = 0.5,
  548. zorder = 1
  549. )
  550. ) ax.add_collection(PatchCollection(
  551. JPPATCH,
  552. facecolor = 'lightgray',
  553. edgecolor = 'k',
  554. linewidths = 0.5,
  555. zorder = 1
  556. ))# gray background bsmap.drawparallels(np.arange(-150, 120, 2), labels = [
  557. 0, 0, 0, 0
  558. ], dashes = [
  559. 2, 2
  560. ], color = 'lightgray') bsmap.drawmeridians(np.arange(-180, 180, 2), labels = [
  561. 0, 0, 0, 0
  562. ], dashes = [
  563. 2, 2
  564. ], color = 'lightgray') bsmap.drawmapboundary(fill_color = 'white') plt.title(
  565. 'Currend Vectors(m/s)',
  566. loc = 'left',
  567. size = 20
  568. ) plt.suptitle(
  569. '[depth : ' + str(int(dep[depcount])) + 'm]',
  570. x = 0.365,
  571. y = 0.86,
  572. size = 15
  573. )# lat label# plt.annotate(
  574. u '32\N{DEGREE SIGN}N',
  575. xy = (bsmap(123.0, 32.04)),
  576. color = 'lightgray',
  577. fontweight = 'bold',
  578. xycoords = 'data',
  579. horizontalalignment = 'center',
  580. verticalalignment = 'top',
  581. size = 9
  582. )# plt.annotate(
  583. u '34\N{DEGREE SIGN}N',
  584. xy = (bsmap(123.0, 34.04)),
  585. color = 'lightgray',
  586. fontweight = 'bold',
  587. xycoords = 'data',
  588. horizontalalignment = 'center',
  589. verticalalignment = 'top',
  590. size = 9
  591. )# plt.annotate(
  592. u '36\N{DEGREE SIGN}N',
  593. xy = (bsmap(123.0, 36.04)),
  594. color = 'lightgray',
  595. fontweight = 'bold',
  596. xycoords = 'data',
  597. horizontalalignment = 'center',
  598. verticalalignment = 'top',
  599. size = 9
  600. )# plt.annotate(
  601. u '38\N{DEGREE SIGN}N',
  602. xy = (bsmap(123.0, 38.04)),
  603. color = 'lightgray',
  604. fontweight = 'bold',
  605. xycoords = 'data',
  606. horizontalalignment = 'center',
  607. verticalalignment = 'top',
  608. size = 9
  609. )# plt.annotate(
  610. u '40\N{DEGREE SIGN}N',
  611. xy = (bsmap(123.0, 40.04)),
  612. color = 'lightgray',
  613. fontweight = 'bold',
  614. xycoords = 'data',
  615. horizontalalignment = 'center',
  616. verticalalignment = 'top',
  617. size = 9
  618. )# lon label# plt.annotate(
  619. u '124\N{DEGREE SIGN}E',
  620. xy = (bsmap(124.3, 30.90)),
  621. color = 'lightgray',
  622. fontweight = 'bold',
  623. xycoords = 'data',
  624. horizontalalignment = 'center',
  625. verticalalignment = 'top',
  626. size = 9
  627. )# plt.annotate(
  628. u '126\N{DEGREE SIGN}E',
  629. xy = (bsmap(126.3, 30.90)),
  630. color = 'lightgray',
  631. fontweight = 'bold',
  632. xycoords = 'data',
  633. horizontalalignment = 'center',
  634. verticalalignment = 'top',
  635. size = 9
  636. )# plt.annotate(
  637. u '128\N{DEGREE SIGN}E',
  638. xy = (bsmap(128.3, 30.90)),
  639. color = 'lightgray',
  640. fontweight = 'bold',
  641. xycoords = 'data',
  642. horizontalalignment = 'center',
  643. verticalalignment = 'top',
  644. size = 9
  645. )# plt.annotate(
  646. u '130\N{DEGREE SIGN}E',
  647. xy = (bsmap(130.3, 30.90)),
  648. color = 'lightgray',
  649. fontweight = 'bold',
  650. xycoords = 'data',
  651. horizontalalignment = 'center',
  652. verticalalignment = 'top',
  653. size = 9
  654. )# plt.annotate(
  655. u '132\N{DEGREE SIGN}E',
  656. xy = (bsmap(132.3, 30.90)),
  657. color = 'lightgray',
  658. fontweight = 'bold',
  659. xycoords = 'data',
  660. horizontalalignment = 'center',
  661. verticalalignment = 'top',
  662. size = 9
  663. )# time label plt.annotate(
  664. 'VALID :' + times[i] + ' UTC',
  665. xy = (0.0, -0.035),
  666. color = 'red',
  667. fontweight = 'bold',
  668. textcoords = 'axes fraction',
  669. verticalalignment = 'left',
  670. xycoords = 'data',
  671. size = 15
  672. ) plt.annotate(
  673. local_dt[i] + ' KST',
  674. xy = (0.092, -0.065),
  675. color = 'black',
  676. fontweight = 'bold',
  677. textcoords = 'axes fraction',
  678. verticalalignment = 'left',
  679. xycoords = 'data',
  680. size = 15
  681. ) plt.annotate(
  682. 'TIME :' + times[0] + ' UTC',
  683. xy = (0.7, -0.035),
  684. color = 'red',
  685. fontweight = 'bold',
  686. textcoords = 'axes fraction',
  687. verticalalignment = 'left',
  688. xycoords = 'data',
  689. size = 15
  690. ) plt.annotate(
  691. local_dt[0] + ' KST',
  692. xy = (0.780, -0.065),
  693. color = 'black',
  694. fontweight = 'bold',
  695. textcoords = 'axes fraction',
  696. verticalalignment = 'left',
  697. xycoords = 'data',
  698. size = 15
  699. ) plt.savefig(
  700. 'BS_cv' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  701. ) print(
  702. 'BS_cv_' + times[i] + 'h_' + str(int(dep[depcount])) +
  703. 'm_layer.png SUCCESS!!'
  704. )# plt.show()# < h1 > BS_ST < /h1> # In[] : # In[15] : dep = [0, 10, 25, 50, 75] depnum = [18, 16, 15, 13, 12] #surface /
  705. 10 m / 25 m / 50 m / 75 m
  706. for i in range(0, timelen, 1): depcount = -1
  707. for j in depnum: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  708. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  709. plt.rcParams["font.weight"] = "bold"
  710. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  711. plt.rcParams["axes.titleweight"] = "bold"
  712. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  713. 'figure.autolayout': True
  714. })# vector extract
  715. var = ncfile.variables[u 'temperature'][i, j,: ,: ]
  716. var =
  717. switch (var, j)# 마스크 계산 함수 호출...
  718. var = np.ma.array(var, mask =
  719. var <= 0.0) cc = plt.contour(
  720. BS_X,
  721. BS_Y,
  722. var,
  723. tp_cont_tick,
  724. linewidths = 1,
  725. cmap = vcmap
  726. ) bsmap.contourf(
  727. BS_X,
  728. BS_Y,
  729. var,
  730. tp_conf_tick,
  731. cmap = cmap_jet1,
  732. vmin = 0.0,
  733. vmax = 33.0,
  734. extend = 'both'
  735. ) plt.clabel(
  736. cc,
  737. inline = True,
  738. fontsize = 12,
  739. fmt = '%2i',
  740. colors = 'k',
  741. inline_spacing = 3.0
  742. )# FILL POLYGON COLOR AND PLOT BOUNDATY LINE BSPATCH = BSPOLY(bsmap) JPPATCH = JPPOLY(
  743. bsmap
  744. ) ax.add_collection(PatchCollection(
  745. BSPATCH,
  746. facecolor = 'lightgray',
  747. edgecolor = 'k',
  748. linewidths = 0.5,
  749. zorder = 1
  750. )) ax.add_collection(PatchCollection(
  751. JPPATCH,
  752. facecolor = 'lightgray',
  753. edgecolor = 'k',
  754. linewidths = 0.5,
  755. zorder = 1
  756. ))# color bar colorbar = bsmap.colorbar(
  757. location = 'right',
  758. size = 0.25,
  759. ticks = tp_cbar_tick,
  760. cmap = cmap_jet1,
  761. extendrect = 'False'
  762. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# white background gray fill contin bsmap.drawparallels(
  763. np.arange(-150, 120, 2),
  764. labels = [
  765. 0, 0, 0, 0
  766. ],
  767. dashes = [
  768. 2, 2
  769. ],
  770. color = 'lightgray'
  771. ) bsmap.drawmeridians(np.arange(-180, 180, 2), labels = [
  772. 0, 0, 0, 0
  773. ], dashes = [
  774. 2, 2
  775. ], color = 'lightgray') bsmap.drawmapboundary(fill_color = 'white') plt.title(
  776. 'Currend Vectors(m/s)',
  777. loc = 'left',
  778. size = 20
  779. ) plt.suptitle(
  780. '[depth : ' + str(int(dep[depcount])) + 'm]',
  781. x = 0.365,
  782. y = 0.863,
  783. size = 15
  784. )# lat label# plt.annotate(
  785. u '32\N{DEGREE SIGN}N',
  786. xy = (bsmap(123.0, 32.04)),
  787. color = 'lightgray',
  788. fontweight = 'bold',
  789. xycoords = 'data',
  790. horizontalalignment = 'center',
  791. verticalalignment = 'top',
  792. size = 9
  793. )# plt.annotate(
  794. u '34\N{DEGREE SIGN}N',
  795. xy = (bsmap(123.0, 34.04)),
  796. color = 'lightgray',
  797. fontweight = 'bold',
  798. xycoords = 'data',
  799. horizontalalignment = 'center',
  800. verticalalignment = 'top',
  801. size = 9
  802. )# plt.annotate(
  803. u '36\N{DEGREE SIGN}N',
  804. xy = (bsmap(123.0, 36.04)),
  805. color = 'lightgray',
  806. fontweight = 'bold',
  807. xycoords = 'data',
  808. horizontalalignment = 'center',
  809. verticalalignment = 'top',
  810. size = 9
  811. )# plt.annotate(
  812. u '38\N{DEGREE SIGN}N',
  813. xy = (bsmap(123.0, 38.04)),
  814. color = 'lightgray',
  815. fontweight = 'bold',
  816. xycoords = 'data',
  817. horizontalalignment = 'center',
  818. verticalalignment = 'top',
  819. size = 9
  820. )# plt.annotate(
  821. u '40\N{DEGREE SIGN}N',
  822. xy = (bsmap(123.0, 40.04)),
  823. color = 'lightgray',
  824. fontweight = 'bold',
  825. xycoords = 'data',
  826. horizontalalignment = 'center',
  827. verticalalignment = 'top',
  828. size = 9
  829. )# lon label# plt.annotate(
  830. u '124\N{DEGREE SIGN}E',
  831. xy = (bsmap(124.3, 30.90)),
  832. color = 'lightgray',
  833. fontweight = 'bold',
  834. xycoords = 'data',
  835. horizontalalignment = 'center',
  836. verticalalignment = 'top',
  837. size = 9
  838. )# plt.annotate(
  839. u '126\N{DEGREE SIGN}E',
  840. xy = (bsmap(126.3, 30.90)),
  841. color = 'lightgray',
  842. fontweight = 'bold',
  843. xycoords = 'data',
  844. horizontalalignment = 'center',
  845. verticalalignment = 'top',
  846. size = 9
  847. )# plt.annotate(
  848. u '128\N{DEGREE SIGN}E',
  849. xy = (bsmap(128.3, 30.90)),
  850. color = 'lightgray',
  851. fontweight = 'bold',
  852. xycoords = 'data',
  853. horizontalalignment = 'center',
  854. verticalalignment = 'top',
  855. size = 9
  856. )# plt.annotate(
  857. u '130\N{DEGREE SIGN}E',
  858. xy = (bsmap(130.3, 30.90)),
  859. color = 'lightgray',
  860. fontweight = 'bold',
  861. xycoords = 'data',
  862. horizontalalignment = 'center',
  863. verticalalignment = 'top',
  864. size = 9
  865. )# plt.annotate(
  866. u '132\N{DEGREE SIGN}E',
  867. xy = (bsmap(132.3, 30.90)),
  868. color = 'lightgray',
  869. fontweight = 'bold',
  870. xycoords = 'data',
  871. horizontalalignment = 'center',
  872. verticalalignment = 'top',
  873. size = 9
  874. )# time label plt.annotate(
  875. 'VALID :' + times[i] + ' UTC',
  876. xy = (0.0, -0.03),
  877. color = 'red',
  878. fontweight = 'bold',
  879. textcoords = 'axes fraction',
  880. verticalalignment = 'left',
  881. xycoords = 'data',
  882. size = 15
  883. ) plt.annotate(
  884. local_dt[i] + ' KST',
  885. xy = (0.092, -0.055),
  886. color = 'black',
  887. fontweight = 'bold',
  888. textcoords = 'axes fraction',
  889. verticalalignment = 'left',
  890. xycoords = 'data',
  891. size = 15
  892. ) plt.annotate(
  893. 'TIME :' + times[0] + ' UTC',
  894. xy = (0.7, -0.03),
  895. color = 'red',
  896. fontweight = 'bold',
  897. textcoords = 'axes fraction',
  898. verticalalignment = 'left',
  899. xycoords = 'data',
  900. size = 15
  901. ) plt.annotate(
  902. local_dt[0] + ' KST',
  903. xy = (0.780, -0.055),
  904. color = 'black',
  905. fontweight = 'bold',
  906. textcoords = 'axes fraction',
  907. verticalalignment = 'left',
  908. xycoords = 'data',
  909. size = 15
  910. ) plt.savefig(
  911. 'BS_temp' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  912. ) print(
  913. 'BS_temp_' + times[i] + 'h_' + str(int(dep[depcount])) +
  914. 'm_layer.png SUCCESS!!'
  915. )# plt.show()# < h1 > BS_SA < /h1> # In[16] : dep = [0, 10, 25, 50, 75] depnum = [18, 16, 15, 13, 12] #surface /
  916. 10 m / 25 m / 50 m / 75 m
  917. for i in range(0, timelen, 1): depcount = -1
  918. for j in depnum: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  919. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  920. plt.rcParams["font.weight"] = "bold"
  921. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  922. plt.rcParams["axes.titleweight"] = "bold"
  923. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  924. 'figure.autolayout': True
  925. })# vector extract
  926. var = ncfile.variables[u 'salinity'][i, j,: ,: ]
  927. var =
  928. switch (var, j)# 마스크 계산 함수 호출...
  929. var = np.ma.array(var, mask =
  930. var <= 0.0) cc = plt.contour(
  931. BS_X,
  932. BS_Y,
  933. var,
  934. sa_cont_tick,
  935. linewidths = 1,
  936. cmap = vcmap
  937. ) bsmap.contourf(
  938. BS_X,
  939. BS_Y,
  940. var,
  941. sa_conf_tick,
  942. cmap = cmap_jet1,
  943. vmin = 25.0,
  944. vmax = 35.0,
  945. extend = 'both'
  946. ) plt.clabel(
  947. cc,
  948. inline = True,
  949. fontsize = 12,
  950. fmt = '%2.1f',
  951. colors = 'k',
  952. inline_spacing = 3.0
  953. )# FILL POLYGON COLOR AND PLOT BOUNDATY LINE BSPATCH = BSPOLY(bsmap) JPPATCH = JPPOLY(
  954. bsmap
  955. ) ax.add_collection(PatchCollection(
  956. BSPATCH,
  957. facecolor = 'lightgray',
  958. edgecolor = 'k',
  959. linewidths = 0.5,
  960. zorder = 1
  961. )) ax.add_collection(PatchCollection(
  962. JPPATCH,
  963. facecolor = 'lightgray',
  964. edgecolor = 'k',
  965. linewidths = 0.5,
  966. zorder = 1
  967. ))# color bar colorbar = bsmap.colorbar(
  968. location = 'right',
  969. size = 0.25,
  970. ticks = sa_cbar_tick,
  971. cmap = cmap_jet1,
  972. extendrect = 'False'
  973. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# white background gray fill contin bsmap.drawparallels(
  974. np.arange(-150, 120, 2),
  975. labels = [
  976. 0, 0, 0, 0
  977. ],
  978. dashes = [
  979. 2, 2
  980. ],
  981. color = 'lightgray'
  982. ) bsmap.drawmeridians(np.arange(-180, 180, 2), labels = [
  983. 0, 0, 0, 0
  984. ], dashes = [
  985. 2, 2
  986. ], color = 'lightgray') bsmap.drawmapboundary(fill_color = 'white') plt.title(
  987. 'Salinity(psu)',
  988. loc = 'left',
  989. size = 20
  990. ) plt.suptitle(
  991. '[depth : ' + str(int(dep[depcount])) + 'm]',
  992. x = 0.255,
  993. y = 0.863,
  994. size = 15
  995. )# lat label# plt.annotate(
  996. u '32\N{DEGREE SIGN}N',
  997. xy = (bsmap(123.0, 32.04)),
  998. color = 'lightgray',
  999. fontweight = 'bold',
  1000. xycoords = 'data',
  1001. horizontalalignment = 'center',
  1002. verticalalignment = 'top',
  1003. size = 9
  1004. )# plt.annotate(
  1005. u '34\N{DEGREE SIGN}N',
  1006. xy = (bsmap(123.0, 34.04)),
  1007. color = 'lightgray',
  1008. fontweight = 'bold',
  1009. xycoords = 'data',
  1010. horizontalalignment = 'center',
  1011. verticalalignment = 'top',
  1012. size = 9
  1013. )# plt.annotate(
  1014. u '36\N{DEGREE SIGN}N',
  1015. xy = (bsmap(123.0, 36.04)),
  1016. color = 'lightgray',
  1017. fontweight = 'bold',
  1018. xycoords = 'data',
  1019. horizontalalignment = 'center',
  1020. verticalalignment = 'top',
  1021. size = 9
  1022. )# plt.annotate(
  1023. u '38\N{DEGREE SIGN}N',
  1024. xy = (bsmap(123.0, 38.04)),
  1025. color = 'lightgray',
  1026. fontweight = 'bold',
  1027. xycoords = 'data',
  1028. horizontalalignment = 'center',
  1029. verticalalignment = 'top',
  1030. size = 9
  1031. )# plt.annotate(
  1032. u '40\N{DEGREE SIGN}N',
  1033. xy = (bsmap(123.0, 40.04)),
  1034. color = 'lightgray',
  1035. fontweight = 'bold',
  1036. xycoords = 'data',
  1037. horizontalalignment = 'center',
  1038. verticalalignment = 'top',
  1039. size = 9
  1040. )# lon label# plt.annotate(
  1041. u '124\N{DEGREE SIGN}E',
  1042. xy = (bsmap(124.3, 30.90)),
  1043. color = 'lightgray',
  1044. fontweight = 'bold',
  1045. xycoords = 'data',
  1046. horizontalalignment = 'center',
  1047. verticalalignment = 'top',
  1048. size = 9
  1049. )# plt.annotate(
  1050. u '126\N{DEGREE SIGN}E',
  1051. xy = (bsmap(126.3, 30.90)),
  1052. color = 'lightgray',
  1053. fontweight = 'bold',
  1054. xycoords = 'data',
  1055. horizontalalignment = 'center',
  1056. verticalalignment = 'top',
  1057. size = 9
  1058. )# plt.annotate(
  1059. u '128\N{DEGREE SIGN}E',
  1060. xy = (bsmap(128.3, 30.90)),
  1061. color = 'lightgray',
  1062. fontweight = 'bold',
  1063. xycoords = 'data',
  1064. horizontalalignment = 'center',
  1065. verticalalignment = 'top',
  1066. size = 9
  1067. )# plt.annotate(
  1068. u '130\N{DEGREE SIGN}E',
  1069. xy = (bsmap(130.3, 30.90)),
  1070. color = 'lightgray',
  1071. fontweight = 'bold',
  1072. xycoords = 'data',
  1073. horizontalalignment = 'center',
  1074. verticalalignment = 'top',
  1075. size = 9
  1076. )# plt.annotate(
  1077. u '132\N{DEGREE SIGN}E',
  1078. xy = (bsmap(132.3, 30.90)),
  1079. color = 'lightgray',
  1080. fontweight = 'bold',
  1081. xycoords = 'data',
  1082. horizontalalignment = 'center',
  1083. verticalalignment = 'top',
  1084. size = 9
  1085. )# time label plt.annotate(
  1086. 'VALID :' + times[i] + ' UTC',
  1087. xy = (0.0, -0.03),
  1088. color = 'red',
  1089. fontweight = 'bold',
  1090. textcoords = 'axes fraction',
  1091. verticalalignment = 'left',
  1092. xycoords = 'data',
  1093. size = 15
  1094. ) plt.annotate(
  1095. local_dt[i] + ' KST',
  1096. xy = (0.092, -0.055),
  1097. color = 'black',
  1098. fontweight = 'bold',
  1099. textcoords = 'axes fraction',
  1100. verticalalignment = 'left',
  1101. xycoords = 'data',
  1102. size = 15
  1103. ) plt.annotate(
  1104. 'TIME :' + times[0] + ' UTC',
  1105. xy = (0.7, -0.03),
  1106. color = 'red',
  1107. fontweight = 'bold',
  1108. textcoords = 'axes fraction',
  1109. verticalalignment = 'left',
  1110. xycoords = 'data',
  1111. size = 15
  1112. ) plt.annotate(
  1113. local_dt[0] + ' KST',
  1114. xy = (0.780, -0.055),
  1115. color = 'black',
  1116. fontweight = 'bold',
  1117. textcoords = 'axes fraction',
  1118. verticalalignment = 'left',
  1119. xycoords = 'data',
  1120. size = 15
  1121. ) plt.savefig(
  1122. 'BS_sa' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  1123. ) print(
  1124. 'BS_sa_' + times[i] + 'h_' + str(int(dep[depcount])) +
  1125. 'm_layer.png SUCCESS!!'
  1126. )# plt.show()# del fig# del ax# del bsmap# < h1 > BS1 CV < /h1> del varU del varV del varVM del var del Q yy = np.arange(
  1127. 0,
  1128. len(lat),
  1129. 9
  1130. ) xx = np.arange(0, len(lon), 9) points = np.meshgrid(yy, xx)# In[18]: arrow_magn = 10.0 dep = [0, 10, 25, 50, 75] depnum = [18, 16]# surface / 10 m / 25 m / 50 m / 75 m
  1131. for i in range(0, timelen, 1): depcount = -1
  1132. for j in depnum: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  1133. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  1134. plt.rcParams["font.weight"] = "bold"
  1135. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  1136. plt.rcParams["axes.titleweight"] = "bold"
  1137. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  1138. 'figure.autolayout': True
  1139. })# vector extract varU = ncfile.variables[u 'u'][i, j,: ,: ] varV = ncfile.variables[u 'v'][i, j,: ,: ] varVM = ncfile.variables[u 'vm'][i, j,: ,: ] varVM =
  1140. switch (
  1141. varVM,
  1142. j
  1143. )# 마스크 계산 함수 호출...varVM = np.ma.array(varVM, mask = varVM <= 0.0) plt.contour(
  1144. BS1_X,
  1145. BS1_Y,
  1146. varVM,
  1147. cv_tick,
  1148. linewidths = 0,
  1149. color = 'k'
  1150. ) bsmap1.contourf(
  1151. BS1_X,
  1152. BS1_Y,
  1153. varVM,
  1154. cv_tick,
  1155. cmap = cmap_jet,
  1156. vmin = 0,
  1157. vmax = 2,
  1158. extend = 'both'
  1159. )# color bar colorbar = bsmap1.colorbar(
  1160. location = 'right',
  1161. size = 0.25,
  1162. ticks = cv_cbar_tick,
  1163. cmap = cmap_jet,
  1164. extendrect = 'False'
  1165. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# vector mapping meana = np.mean(
  1166. varVM[points]
  1167. ) Q = bsmap1.quiver(
  1168. lon2D[points],
  1169. lat2D[points],
  1170. varU[points],
  1171. varV[points],
  1172. varVM[points],
  1173. pivot = 'middle',
  1174. cmap = vcmap,
  1175. latlon = True,
  1176. scale_units = 'inches',
  1177. scale = meana * arrow_magn,
  1178. minlength = 0.1,
  1179. headwidth = 4.0
  1180. ) plt.quiverkey(
  1181. Q,
  1182. 0.1,
  1183. 0.95,
  1184. 1,
  1185. '' + str(int(1)) + 'm/s',
  1186. labelpos = 'N',
  1187. fontproperties = {
  1188. 'weight': 'bold',
  1189. 'size': '14'
  1190. },
  1191. labelsep = 0.1
  1192. ) plt.quiverkey(
  1193. Q,
  1194. 0.1,
  1195. 0.95,
  1196. 1,
  1197. 'Reference Vector',
  1198. labelpos = 'S',
  1199. fontproperties = {
  1200. 'weight': 'bold',
  1201. 'size': '14'
  1202. },
  1203. labelsep = 0.1
  1204. )# ADD POLYGON BSPATCH = BSPOLY1(bsmap1) JPPATCH = JPPOLY(bsmap1)# plot bln line redline(
  1205. bsmap1
  1206. ) blueline(bsmap1) greenline(bsmap1) ax.add_collection(PatchCollection(
  1207. BSPATCH,
  1208. facecolor = 'lightgray',
  1209. edgecolor = 'k',
  1210. linewidths = 0.5,
  1211. zorder = 1
  1212. )) ax.add_collection(PatchCollection(
  1213. JPPATCH,
  1214. facecolor = 'lightgray',
  1215. edgecolor = 'k',
  1216. linewidths = 0.5,
  1217. zorder = 1
  1218. ))# gray background bsmap1.drawparallels(np.arange(-150, 120, 2), labels = [
  1219. 0, 0, 0, 0
  1220. ], dashes = [
  1221. 2, 2
  1222. ], color = 'lightgray') bsmap1.drawmeridians(np.arange(-180, 180, 2), labels = [
  1223. 0, 0, 0, 0
  1224. ], dashes = [
  1225. 2, 2
  1226. ], color = 'lightgray') bsmap1.drawmapboundary(fill_color = 'white') plt.title(
  1227. 'Currend Vectors(m/s)',
  1228. loc = 'left',
  1229. size = 20
  1230. ) plt.suptitle(
  1231. '[depth : ' + str(int(dep[depcount])) + 'm]',
  1232. x = 0.365,
  1233. y = 0.900,
  1234. size = 15
  1235. )# time label plt.annotate(
  1236. 'VALID :' + times[i] + ' UTC',
  1237. xy = (0.0, -0.035),
  1238. color = 'red',
  1239. fontweight = 'bold',
  1240. textcoords = 'axes fraction',
  1241. verticalalignment = 'left',
  1242. xycoords = 'data',
  1243. size = 15
  1244. ) plt.annotate(
  1245. local_dt[i] + ' KST',
  1246. xy = (0.092, -0.065),
  1247. color = 'black',
  1248. fontweight = 'bold',
  1249. textcoords = 'axes fraction',
  1250. verticalalignment = 'left',
  1251. xycoords = 'data',
  1252. size = 15
  1253. ) plt.annotate(
  1254. 'TIME :' + times[0] + ' UTC',
  1255. xy = (0.7, -0.035),
  1256. color = 'red',
  1257. fontweight = 'bold',
  1258. textcoords = 'axes fraction',
  1259. verticalalignment = 'left',
  1260. xycoords = 'data',
  1261. size = 15
  1262. ) plt.annotate(
  1263. local_dt[0] + ' KST',
  1264. xy = (0.780, -0.065),
  1265. color = 'black',
  1266. fontweight = 'bold',
  1267. textcoords = 'axes fraction',
  1268. verticalalignment = 'left',
  1269. xycoords = 'data',
  1270. size = 15
  1271. ) plt.savefig(
  1272. 'BS1_cv' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  1273. ) print(
  1274. 'BS1_cv_' + times[i] + 'h_' + str(int(dep[depcount])) +
  1275. 'm_layer.png SUCCESS!!'
  1276. )# plt.show()## BS1 TP# In[]: dep = [0, 10, 25, 50, 75] depnum = [18, 16, 15, 13, 12]# surface / 10 m / 25 m / 50 m / 75 m
  1277. for i in range(0, timelen, 1): depcount = -1
  1278. for j in [18, 16]: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  1279. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  1280. plt.rcParams["font.weight"] = "bold"
  1281. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  1282. plt.rcParams["axes.titleweight"] = "bold"
  1283. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  1284. 'figure.autolayout': True
  1285. })# vector extract
  1286. var = ncfile.variables[u 'temperature'][i, j,: ,: ]
  1287. var =
  1288. switch (var, j)# 마스크 계산 함수 호출...
  1289. var = np.ma.array(var, mask =
  1290. var <= 0.0) cc = plt.contour(
  1291. BS1_X,
  1292. BS1_Y,
  1293. var,
  1294. tp_cont_tick,
  1295. linewidths = 1,
  1296. cmap = vcmap
  1297. ) bsmap1.contourf(
  1298. BS1_X,
  1299. BS1_Y,
  1300. var,
  1301. tp_conf_tick,
  1302. cmap = cmap_jet1,
  1303. vmin = 0.0,
  1304. vmax = 33.0,
  1305. extend = 'both'
  1306. ) plt.clabel(
  1307. cc,
  1308. inline = True,
  1309. fontsize = 12,
  1310. fmt = '%2i',
  1311. colors = 'k',
  1312. inline_spacing = 3.0
  1313. )# FILL POLYGON COLOR AND PLOT BOUNDATY LINE BSPATCH = BSPOLY1(bsmap1) JPPATCH = JPPOLY(
  1314. bsmap1
  1315. ) redline(bsmap1) blueline(bsmap1) greenline(bsmap1) ax.add_collection(
  1316. PatchCollection(
  1317. BSPATCH,
  1318. facecolor = 'lightgray',
  1319. edgecolor = 'k',
  1320. linewidths = 0.5,
  1321. zorder = 1
  1322. )
  1323. ) ax.add_collection(PatchCollection(
  1324. JPPATCH,
  1325. facecolor = 'lightgray',
  1326. edgecolor = 'k',
  1327. linewidths = 0.5,
  1328. zorder = 1
  1329. ))# color bar colorbar = bsmap1.colorbar(
  1330. location = 'right',
  1331. size = 0.25,
  1332. ticks = tp_cbar_tick,
  1333. cmap = cmap_jet1,
  1334. extendrect = 'False'
  1335. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# white background gray fill contin bsmap1.drawparallels(
  1336. np.arange(-150, 120, 2),
  1337. labels = [
  1338. 0, 0, 0, 0
  1339. ],
  1340. dashes = [
  1341. 2, 2
  1342. ],
  1343. color = 'lightgray'
  1344. ) bsmap1.drawmeridians(np.arange(-180, 180, 2), labels = [
  1345. 0, 0, 0, 0
  1346. ], dashes = [
  1347. 2, 2
  1348. ], color = 'lightgray') bsmap1.drawmapboundary(fill_color = 'white') plt.title(
  1349. 'Currend Vectors(m/s)',
  1350. loc = 'left',
  1351. size = 20
  1352. ) plt.suptitle(
  1353. '[depth : ' + str(int(dep[depcount])) + 'm]',
  1354. x = 0.365,
  1355. y = 0.900,
  1356. size = 15
  1357. )# time label plt.annotate(
  1358. 'VALID :' + times[i] + ' UTC',
  1359. xy = (0.0, -0.03),
  1360. color = 'red',
  1361. fontweight = 'bold',
  1362. textcoords = 'axes fraction',
  1363. verticalalignment = 'left',
  1364. xycoords = 'data',
  1365. size = 15
  1366. ) plt.annotate(
  1367. local_dt[i] + ' KST',
  1368. xy = (0.092, -0.055),
  1369. color = 'black',
  1370. fontweight = 'bold',
  1371. textcoords = 'axes fraction',
  1372. verticalalignment = 'left',
  1373. xycoords = 'data',
  1374. size = 15
  1375. ) plt.annotate(
  1376. 'TIME :' + times[0] + ' UTC',
  1377. xy = (0.7, -0.03),
  1378. color = 'red',
  1379. fontweight = 'bold',
  1380. textcoords = 'axes fraction',
  1381. verticalalignment = 'left',
  1382. xycoords = 'data',
  1383. size = 15
  1384. ) plt.annotate(
  1385. local_dt[0] + ' KST',
  1386. xy = (0.780, -0.055),
  1387. color = 'black',
  1388. fontweight = 'bold',
  1389. textcoords = 'axes fraction',
  1390. verticalalignment = 'left',
  1391. xycoords = 'data',
  1392. size = 15
  1393. ) plt.savefig(
  1394. 'BS1_temp' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  1395. )# plt.savefig('AAAAA.png') print(
  1396. 'BS1_temp_' + times[i] + 'h_' + str(int(dep[depcount])) +
  1397. 'm_layer.png SUCCESS!!'
  1398. )# plt.show()# < h1 > BS1 SA < /h1> # In[] : dep = [0, 10, 25, 50, 75] depnum = [18, 16, 15, 13, 12] #surface /
  1399. 10 m / 25 m / 50 m / 75 m
  1400. for i in range(0, timelen, 1): depcount = -1
  1401. for j in [18, 16]: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  1402. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  1403. plt.rcParams["font.weight"] = "bold"
  1404. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  1405. plt.rcParams["axes.titleweight"] = "bold"
  1406. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  1407. 'figure.autolayout': True
  1408. })# vector extract
  1409. var = ncfile.variables[u 'salinity'][i, j,: ,: ]
  1410. var =
  1411. switch (var, j)# 마스크 계산 함수 호출...
  1412. var = np.ma.array(var, mask =
  1413. var <= 0.0) cc = plt.contour(
  1414. BS1_X,
  1415. BS1_Y,
  1416. var,
  1417. sa_cont_tick,
  1418. linewidths = 1,
  1419. cmap = vcmap
  1420. ) bsmap1.contourf(
  1421. BS1_X,
  1422. BS1_Y,
  1423. var,
  1424. sa_conf_tick,
  1425. cmap = cmap_jet1,
  1426. vmin = 25.0,
  1427. vmax = 35.0,
  1428. extend = 'both'
  1429. ) plt.clabel(
  1430. cc,
  1431. inline = True,
  1432. fontsize = 12,
  1433. fmt = '%2.1f',
  1434. colors = 'k',
  1435. inline_spacing = 3.0
  1436. )# FILL POLYGON COLOR AND PLOT BOUNDATY LINE BSPATCH = BSPOLY1(bsmap1) JPPATCH = JPPOLY(
  1437. bsmap1
  1438. ) redline(bsmap1) blueline(bsmap1) greenline(bsmap1) ax.add_collection(
  1439. PatchCollection(
  1440. BSPATCH,
  1441. facecolor = 'lightgray',
  1442. edgecolor = 'k',
  1443. linewidths = 0.5,
  1444. zorder = 1
  1445. )
  1446. ) ax.add_collection(PatchCollection(
  1447. JPPATCH,
  1448. facecolor = 'lightgray',
  1449. edgecolor = 'k',
  1450. linewidths = 0.5,
  1451. zorder = 1
  1452. ))# color bar colorbar = bsmap1.colorbar(
  1453. location = 'right',
  1454. size = 0.25,
  1455. ticks = sa_cbar_tick,
  1456. cmap = cmap_jet1,
  1457. extendrect = 'False'
  1458. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# white background gray fill contin bsmap1.drawparallels(
  1459. np.arange(-150, 120, 2),
  1460. labels = [
  1461. 0, 0, 0, 0
  1462. ],
  1463. dashes = [
  1464. 2, 2
  1465. ],
  1466. color = 'lightgray'
  1467. ) bsmap1.drawmeridians(np.arange(-180, 180, 2), labels = [
  1468. 0, 0, 0, 0
  1469. ], dashes = [
  1470. 2, 2
  1471. ], color = 'lightgray') bsmap1.drawmapboundary(fill_color = 'white') plt.title(
  1472. 'Salinity(psu)',
  1473. loc = 'left',
  1474. size = 20
  1475. ) plt.suptitle(
  1476. '[depth : ' + str(int(dep[depcount])) + 'm]',
  1477. x = 0.255,
  1478. y = 0.900,
  1479. size = 15
  1480. )# time label plt.annotate(
  1481. 'VALID :' + times[i] + ' UTC',
  1482. xy = (0.0, -0.03),
  1483. color = 'red',
  1484. fontweight = 'bold',
  1485. textcoords = 'axes fraction',
  1486. verticalalignment = 'left',
  1487. xycoords = 'data',
  1488. size = 15
  1489. ) plt.annotate(
  1490. local_dt[i] + ' KST',
  1491. xy = (0.092, -0.055),
  1492. color = 'black',
  1493. fontweight = 'bold',
  1494. textcoords = 'axes fraction',
  1495. verticalalignment = 'left',
  1496. xycoords = 'data',
  1497. size = 15
  1498. ) plt.annotate(
  1499. 'TIME :' + times[0] + ' UTC',
  1500. xy = (0.7, -0.03),
  1501. color = 'red',
  1502. fontweight = 'bold',
  1503. textcoords = 'axes fraction',
  1504. verticalalignment = 'left',
  1505. xycoords = 'data',
  1506. size = 15
  1507. ) plt.annotate(
  1508. local_dt[0] + ' KST',
  1509. xy = (0.780, -0.055),
  1510. color = 'black',
  1511. fontweight = 'bold',
  1512. textcoords = 'axes fraction',
  1513. verticalalignment = 'left',
  1514. xycoords = 'data',
  1515. size = 15
  1516. ) plt.savefig(
  1517. 'BS1_sa' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  1518. ) print(
  1519. 'BS1_sa_' + times[i] + 'h_' + str(int(dep[depcount])) +
  1520. 'm_layer.png SUCCESS!!'
  1521. )# plt.show()## BS2 CV del varU del varV del varVM del
  1522. var del Q arrow_magn = 10.0 dep = [0, 10, 25, 50, 75] depnum = [18, 16]# surface / 10 m / 25 m / 50 m / 75 m
  1523. for i in range(0, timelen, 1): depcount = -1
  1524. for j in depnum: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  1525. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  1526. plt.rcParams["font.weight"] = "bold"
  1527. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  1528. plt.rcParams["axes.titleweight"] = "bold"
  1529. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  1530. 'figure.autolayout': True
  1531. })# vector extract varU = ncfile.variables[u 'u'][i, j,: ,: ] varV = ncfile.variables[u 'v'][i, j,: ,: ] varVM = ncfile.variables[u 'vm'][i, j,: ,: ] varVM =
  1532. switch (
  1533. varVM,
  1534. j
  1535. )# 마스크 계산 함수 호출...varVM = np.ma.array(varVM, mask = varVM <= 0.0) plt.contour(
  1536. BS2_X,
  1537. BS2_Y,
  1538. varVM,
  1539. cv_tick,
  1540. linewidths = 0,
  1541. color = 'k'
  1542. ) bsmap2.contourf(
  1543. BS2_X,
  1544. BS2_Y,
  1545. varVM,
  1546. cv_tick,
  1547. cmap = cmap_jet,
  1548. vmin = 0,
  1549. vmax = 2,
  1550. extend = 'both'
  1551. )# color bar colorbar = bsmap2.colorbar(
  1552. location = 'right',
  1553. size = 0.25,
  1554. ticks = cv_cbar_tick,
  1555. cmap = cmap_jet,
  1556. extendrect = 'False'
  1557. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# vector mapping meana = np.mean(
  1558. varVM[points]
  1559. ) Q = bsmap2.quiver(
  1560. lon2D[points],
  1561. lat2D[points],
  1562. varU[points],
  1563. varV[points],
  1564. varVM[points],
  1565. pivot = 'middle',
  1566. cmap = vcmap,
  1567. latlon = True,
  1568. scale_units = 'inches',
  1569. scale = meana * arrow_magn,
  1570. minlength = 0.1,
  1571. headwidth = 4.0
  1572. ) plt.quiverkey(
  1573. Q,
  1574. 0.1,
  1575. 0.95,
  1576. 1,
  1577. '' + str(int(1)) + 'm/s',
  1578. labelpos = 'N',
  1579. fontproperties = {
  1580. 'weight': 'bold',
  1581. 'size': '14'
  1582. },
  1583. labelsep = 0.1
  1584. ) plt.quiverkey(
  1585. Q,
  1586. 0.1,
  1587. 0.95,
  1588. 1,
  1589. 'Reference Vector',
  1590. labelpos = 'S',
  1591. fontproperties = {
  1592. 'weight': 'bold',
  1593. 'size': '14'
  1594. },
  1595. labelsep = 0.1
  1596. )# ADD POLYGON BSPATCH = BSPOLY2(bsmap2) JPPATCH = JPPOLY(bsmap2)# plot bln line redline(
  1597. bsmap2
  1598. ) blueline(bsmap2) greenline(bsmap2) ax.add_collection(PatchCollection(
  1599. BSPATCH,
  1600. facecolor = 'lightgray',
  1601. edgecolor = 'k',
  1602. linewidths = 0.5,
  1603. zorder = 1
  1604. )) ax.add_collection(PatchCollection(
  1605. JPPATCH,
  1606. facecolor = 'lightgray',
  1607. edgecolor = 'k',
  1608. linewidths = 0.5,
  1609. zorder = 1
  1610. ))# gray background bsmap2.drawparallels(np.arange(-150, 120, 2), labels = [
  1611. 0, 0, 0, 0
  1612. ], dashes = [
  1613. 2, 2
  1614. ], color = 'lightgray') bsmap2.drawmeridians(np.arange(-180, 180, 2), labels = [
  1615. 0, 0, 0, 0
  1616. ], dashes = [
  1617. 2, 2
  1618. ], color = 'lightgray') bsmap2.drawmapboundary(fill_color = 'white') plt.title(
  1619. 'Currend Vectors(m/s)',
  1620. loc = 'left',
  1621. size = 20
  1622. ) plt.suptitle(
  1623. '[depth : ' + str(int(dep[depcount])) + 'm]',
  1624. x = 0.365,
  1625. y = 0.880,
  1626. size = 15
  1627. )# time label plt.annotate(
  1628. 'VALID :' + times[i] + ' UTC',
  1629. xy = (0.0, -0.035),
  1630. color = 'red',
  1631. fontweight = 'bold',
  1632. textcoords = 'axes fraction',
  1633. verticalalignment = 'left',
  1634. xycoords = 'data',
  1635. size = 15
  1636. ) plt.annotate(
  1637. local_dt[i] + ' KST',
  1638. xy = (0.092, -0.065),
  1639. color = 'black',
  1640. fontweight = 'bold',
  1641. textcoords = 'axes fraction',
  1642. verticalalignment = 'left',
  1643. xycoords = 'data',
  1644. size = 15
  1645. ) plt.annotate(
  1646. 'TIME :' + times[0] + ' UTC',
  1647. xy = (0.7, -0.035),
  1648. color = 'red',
  1649. fontweight = 'bold',
  1650. textcoords = 'axes fraction',
  1651. verticalalignment = 'left',
  1652. xycoords = 'data',
  1653. size = 15
  1654. ) plt.annotate(
  1655. local_dt[0] + ' KST',
  1656. xy = (0.780, -0.065),
  1657. color = 'black',
  1658. fontweight = 'bold',
  1659. textcoords = 'axes fraction',
  1660. verticalalignment = 'left',
  1661. xycoords = 'data',
  1662. size = 15
  1663. ) plt.savefig(
  1664. 'BS2_cv' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  1665. ) print(
  1666. 'BS2_cv_' + times[i] + 'h_' + str(int(dep[depcount])) +
  1667. 'm_layer.png SUCCESS!!'
  1668. )# plt.show()## BS2 - TP# In[]: dep = [0, 10, 25, 50, 75] depnum = [18, 16, 15, 13, 12]# surface / 10 m / 25 m / 50 m / 75 m
  1669. for i in range(0, timelen, 1): depcount = -1
  1670. for j in [18, 16]: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  1671. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  1672. plt.rcParams["font.weight"] = "bold"
  1673. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  1674. plt.rcParams["axes.titleweight"] = "bold"
  1675. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  1676. 'figure.autolayout': True
  1677. })# vector extract
  1678. var = ncfile.variables[u 'temperature'][i, j,: ,: ]
  1679. var =
  1680. switch (var, j)# 마스크 계산 함수 호출...
  1681. var = np.ma.array(var, mask =
  1682. var <= 0.0) cc = plt.contour(
  1683. BS2_X,
  1684. BS2_Y,
  1685. var,
  1686. tp_cont_tick,
  1687. linewidths = 1,
  1688. cmap = vcmap
  1689. ) bsmap2.contourf(
  1690. BS2_X,
  1691. BS2_Y,
  1692. var,
  1693. tp_conf_tick,
  1694. cmap = cmap_jet1,
  1695. vmin = 0.0,
  1696. vmax = 33.0,
  1697. extend = 'both'
  1698. ) plt.clabel(
  1699. cc,
  1700. inline = True,
  1701. fontsize = 12,
  1702. fmt = '%2i',
  1703. colors = 'k',
  1704. inline_spacing = 3.0
  1705. )# FILL POLYGON COLOR AND PLOT BOUNDATY LINE BSPATCH = BSPOLY2(bsmap2) JPPATCH = JPPOLY(
  1706. bsmap2
  1707. ) redline(bsmap2) blueline(bsmap2) greenline(bsmap2) ax.add_collection(
  1708. PatchCollection(
  1709. BSPATCH,
  1710. facecolor = 'lightgray',
  1711. edgecolor = 'k',
  1712. linewidths = 0.5,
  1713. zorder = 1
  1714. )
  1715. ) ax.add_collection(PatchCollection(
  1716. JPPATCH,
  1717. facecolor = 'lightgray',
  1718. edgecolor = 'k',
  1719. linewidths = 0.5,
  1720. zorder = 1
  1721. ))# color bar colorbar = bsmap2.colorbar(
  1722. location = 'right',
  1723. size = 0.25,
  1724. ticks = tp_cbar_tick,
  1725. cmap = cmap_jet1,
  1726. extendrect = 'False'
  1727. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# white background gray fill contin bsmap2.drawparallels(
  1728. np.arange(-150, 120, 2),
  1729. labels = [
  1730. 0, 0, 0, 0
  1731. ],
  1732. dashes = [
  1733. 2, 2
  1734. ],
  1735. color = 'lightgray'
  1736. ) bsmap2.drawmeridians(np.arange(-180, 180, 2), labels = [
  1737. 0, 0, 0, 0
  1738. ], dashes = [
  1739. 2, 2
  1740. ], color = 'lightgray') bsmap2.drawmapboundary(fill_color = 'white') plt.title(
  1741. 'Salinity(psu)',
  1742. loc = 'left',
  1743. size = 20
  1744. ) plt.suptitle(
  1745. '[depth : ' + str(int(dep[depcount])) + 'm]',
  1746. x = 0.255,
  1747. y = 0.880,
  1748. size = 15
  1749. )# time label plt.annotate(
  1750. 'VALID :' + times[i] + ' UTC',
  1751. xy = (0.0, -0.03),
  1752. color = 'red',
  1753. fontweight = 'bold',
  1754. textcoords = 'axes fraction',
  1755. verticalalignment = 'left',
  1756. xycoords = 'data',
  1757. size = 15
  1758. ) plt.annotate(
  1759. local_dt[i] + ' KST',
  1760. xy = (0.092, -0.055),
  1761. color = 'black',
  1762. fontweight = 'bold',
  1763. textcoords = 'axes fraction',
  1764. verticalalignment = 'left',
  1765. xycoords = 'data',
  1766. size = 15
  1767. ) plt.annotate(
  1768. 'TIME :' + times[0] + ' UTC',
  1769. xy = (0.7, -0.03),
  1770. color = 'red',
  1771. fontweight = 'bold',
  1772. textcoords = 'axes fraction',
  1773. verticalalignment = 'left',
  1774. xycoords = 'data',
  1775. size = 15
  1776. ) plt.annotate(
  1777. local_dt[0] + ' KST',
  1778. xy = (0.780, -0.055),
  1779. color = 'black',
  1780. fontweight = 'bold',
  1781. textcoords = 'axes fraction',
  1782. verticalalignment = 'left',
  1783. xycoords = 'data',
  1784. size = 15
  1785. ) plt.savefig(
  1786. 'BS2_temp' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  1787. )# plt.savefig('AAAAA.png') print(
  1788. 'BS2_temp_' + times[i] + 'h_' + str(int(dep[depcount])) +
  1789. 'm_layer.png SUCCESS!!'
  1790. )# plt.show()## BS2 - SA# In[]: dep = [0, 10, 25, 50, 75] depnum = [18, 16, 15, 13, 12]# surface / 10 m / 25 m / 50 m / 75 m
  1791. for i in range(0, timelen, 1): depcount = -1
  1792. for j in [18, 16]: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  1793. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  1794. plt.rcParams["font.weight"] = "bold"
  1795. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  1796. plt.rcParams["axes.titleweight"] = "bold"
  1797. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  1798. 'figure.autolayout': True
  1799. })# vector extract
  1800. var = ncfile.variables[u 'salinity'][i, j,: ,: ]
  1801. var =
  1802. switch (var, j)# 마스크 계산 함수 호출...
  1803. var = np.ma.array(var, mask =
  1804. var <= 0.0) cc = plt.contour(
  1805. BS2_X,
  1806. BS2_Y,
  1807. var,
  1808. sa_cont_tick,
  1809. linewidths = 1,
  1810. cmap = vcmap
  1811. ) bsmap2.contourf(
  1812. BS2_X,
  1813. BS2_Y,
  1814. var,
  1815. sa_conf_tick,
  1816. cmap = cmap_jet1,
  1817. vmin = 25.0,
  1818. vmax = 35.0,
  1819. extend = 'both'
  1820. ) plt.clabel(
  1821. cc,
  1822. inline = True,
  1823. fontsize = 12,
  1824. fmt = '%2.1f',
  1825. colors = 'k',
  1826. inline_spacing = 3.0
  1827. )# FILL POLYGON COLOR AND PLOT BOUNDATY LINE BSPATCH = BSPOLY2(bsmap2) JPPATCH = JPPOLY(
  1828. bsmap2
  1829. ) redline(bsmap2) blueline(bsmap2) greenline(bsmap2) ax.add_collection(
  1830. PatchCollection(
  1831. BSPATCH,
  1832. facecolor = 'lightgray',
  1833. edgecolor = 'k',
  1834. linewidths = 0.5,
  1835. zorder = 1
  1836. )
  1837. ) ax.add_collection(PatchCollection(
  1838. JPPATCH,
  1839. facecolor = 'lightgray',
  1840. edgecolor = 'k',
  1841. linewidths = 0.5,
  1842. zorder = 1
  1843. ))# color bar colorbar = bsmap2.colorbar(
  1844. location = 'right',
  1845. size = 0.25,
  1846. ticks = sa_cbar_tick,
  1847. cmap = cmap_jet1,
  1848. extendrect = 'False'
  1849. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# white background gray fill contin bsmap2.drawparallels(
  1850. np.arange(-150, 120, 2),
  1851. labels = [
  1852. 0, 0, 0, 0
  1853. ],
  1854. dashes = [
  1855. 2, 2
  1856. ],
  1857. color = 'lightgray'
  1858. ) bsmap2.drawmeridians(np.arange(-180, 180, 2), labels = [
  1859. 0, 0, 0, 0
  1860. ], dashes = [
  1861. 2, 2
  1862. ], color = 'lightgray') bsmap2.drawmapboundary(fill_color = 'white') plt.title(
  1863. u 'Seawater Temperature(\N{DEGREE SIGN}C)',
  1864. loc = 'left',
  1865. size = 20
  1866. ) plt.suptitle(
  1867. '[depth : ' + str(int(dep[depcount])) + 'm]',
  1868. x = 0.435,
  1869. y = 0.880,
  1870. size = 15
  1871. )# time label plt.annotate(
  1872. 'VALID :' + times[i] + ' UTC',
  1873. xy = (0.0, -0.03),
  1874. color = 'red',
  1875. fontweight = 'bold',
  1876. textcoords = 'axes fraction',
  1877. verticalalignment = 'left',
  1878. xycoords = 'data',
  1879. size = 15
  1880. ) plt.annotate(
  1881. local_dt[i] + ' KST',
  1882. xy = (0.092, -0.055),
  1883. color = 'black',
  1884. fontweight = 'bold',
  1885. textcoords = 'axes fraction',
  1886. verticalalignment = 'left',
  1887. xycoords = 'data',
  1888. size = 15
  1889. ) plt.annotate(
  1890. 'TIME :' + times[0] + ' UTC',
  1891. xy = (0.7, -0.03),
  1892. color = 'red',
  1893. fontweight = 'bold',
  1894. textcoords = 'axes fraction',
  1895. verticalalignment = 'left',
  1896. xycoords = 'data',
  1897. size = 15
  1898. ) plt.annotate(
  1899. local_dt[0] + ' KST',
  1900. xy = (0.780, -0.055),
  1901. color = 'black',
  1902. fontweight = 'bold',
  1903. textcoords = 'axes fraction',
  1904. verticalalignment = 'left',
  1905. xycoords = 'data',
  1906. size = 15
  1907. ) plt.savefig(
  1908. 'BS2_temp' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  1909. ) print(
  1910. 'BS2_temp_' + times[i] + 'h_' + str(int(dep[depcount])) +
  1911. 'm_layer.png SUCCESS!!'
  1912. )# plt.show()## BS3 - CV del varU del varV del varVM del
  1913. var del Q arrow_magn = 10.0 dep = [0, 10, 25, 50, 75] depnum = [18, 16]# surface / 10 m / 25 m / 50 m / 75 m
  1914. for i in range(0, timelen, 1): depcount = -1
  1915. for j in depnum: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  1916. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  1917. plt.rcParams["font.weight"] = "bold"
  1918. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  1919. plt.rcParams["axes.titleweight"] = "bold"
  1920. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  1921. 'figure.autolayout': True
  1922. })# vector extract varU = ncfile.variables[u 'u'][i, j,: ,: ] varV = ncfile.variables[u 'v'][i, j,: ,: ] varVM = ncfile.variables[u 'vm'][i, j,: ,: ] varVM =
  1923. switch (
  1924. varVM,
  1925. j
  1926. )# 마스크 계산 함수 호출...varVM = np.ma.array(varVM, mask = varVM <= 0.0) plt.contour(
  1927. BS3_X,
  1928. BS3_Y,
  1929. varVM,
  1930. cv_tick,
  1931. linewidths = 0,
  1932. color = 'k'
  1933. ) bsmap3.contourf(
  1934. BS3_X,
  1935. BS3_Y,
  1936. varVM,
  1937. cv_tick,
  1938. cmap = cmap_jet,
  1939. vmin = 0,
  1940. vmax = 2,
  1941. extend = 'both'
  1942. )# color bar colorbar = bsmap3.colorbar(
  1943. location = 'right',
  1944. size = 0.25,
  1945. ticks = cv_cbar_tick,
  1946. cmap = cmap_jet,
  1947. extendrect = 'False'
  1948. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# vector mapping meana = np.mean(
  1949. varVM[points]
  1950. ) Q = bsmap3.quiver(
  1951. lon2D[points],
  1952. lat2D[points],
  1953. varU[points],
  1954. varV[points],
  1955. varVM[points],
  1956. pivot = 'middle',
  1957. cmap = vcmap,
  1958. latlon = True,
  1959. scale_units = 'inches',
  1960. scale = meana * arrow_magn,
  1961. minlength = 0.1,
  1962. headwidth = 4.0
  1963. ) plt.quiverkey(
  1964. Q,
  1965. 0.1,
  1966. 0.95,
  1967. 1,
  1968. '' + str(int(1)) + 'm/s',
  1969. labelpos = 'N',
  1970. fontproperties = {
  1971. 'weight': 'bold',
  1972. 'size': '14'
  1973. },
  1974. labelsep = 0.1
  1975. ) plt.quiverkey(
  1976. Q,
  1977. 0.1,
  1978. 0.95,
  1979. 1,
  1980. 'Reference Vector',
  1981. labelpos = 'S',
  1982. fontproperties = {
  1983. 'weight': 'bold',
  1984. 'size': '14'
  1985. },
  1986. labelsep = 0.1
  1987. )# ADD POLYGON BSPATCH = BSPOLY3(bsmap3) JPPATCH = JPPOLY(bsmap3)# plot bln line redline(
  1988. bsmap3
  1989. ) blueline(bsmap3) greenline(bsmap3) ax.add_collection(PatchCollection(
  1990. BSPATCH,
  1991. facecolor = 'lightgray',
  1992. edgecolor = 'k',
  1993. linewidths = 0.5,
  1994. zorder = 1
  1995. )) ax.add_collection(PatchCollection(
  1996. JPPATCH,
  1997. facecolor = 'lightgray',
  1998. edgecolor = 'k',
  1999. linewidths = 0.5,
  2000. zorder = 1
  2001. ))# gray background bsmap3.drawparallels(np.arange(-150, 120, 2), labels = [
  2002. 0, 0, 0, 0
  2003. ], dashes = [
  2004. 2, 2
  2005. ], color = 'lightgray') bsmap3.drawmeridians(np.arange(-180, 180, 2), labels = [
  2006. 0, 0, 0, 0
  2007. ], dashes = [
  2008. 2, 2
  2009. ], color = 'lightgray') bsmap3.drawmapboundary(fill_color = 'white') plt.title(
  2010. 'Currend Vectors(m/s)',
  2011. loc = 'left',
  2012. size = 20
  2013. ) plt.suptitle(
  2014. '[depth : ' + str(int(dep[depcount])) + 'm]',
  2015. x = 0.365,
  2016. y = 0.900,
  2017. size = 15
  2018. )# time label plt.annotate(
  2019. 'VALID :' + times[i] + ' UTC',
  2020. xy = (0.0, -0.035),
  2021. color = 'red',
  2022. fontweight = 'bold',
  2023. textcoords = 'axes fraction',
  2024. verticalalignment = 'left',
  2025. xycoords = 'data',
  2026. size = 15
  2027. ) plt.annotate(
  2028. local_dt[i] + ' KST',
  2029. xy = (0.092, -0.065),
  2030. color = 'black',
  2031. fontweight = 'bold',
  2032. textcoords = 'axes fraction',
  2033. verticalalignment = 'left',
  2034. xycoords = 'data',
  2035. size = 15
  2036. ) plt.annotate(
  2037. 'TIME :' + times[0] + ' UTC',
  2038. xy = (0.7, -0.035),
  2039. color = 'red',
  2040. fontweight = 'bold',
  2041. textcoords = 'axes fraction',
  2042. verticalalignment = 'left',
  2043. xycoords = 'data',
  2044. size = 15
  2045. ) plt.annotate(
  2046. local_dt[0] + ' KST',
  2047. xy = (0.780, -0.065),
  2048. color = 'black',
  2049. fontweight = 'bold',
  2050. textcoords = 'axes fraction',
  2051. verticalalignment = 'left',
  2052. xycoords = 'data',
  2053. size = 15
  2054. ) plt.savefig(
  2055. 'BS3_cv' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  2056. ) print(
  2057. 'BS3_cv_' + times[i] + 'h_' + str(int(dep[depcount])) +
  2058. 'm_layer.png SUCCESS!!'
  2059. )# plt.show()## BS3 - TP# In[]: dep = [0, 10, 25, 50, 75] depnum = [18, 16, 15, 13, 12]# surface / 10 m / 25 m / 50 m / 75 m
  2060. for i in range(0, timelen, 1): depcount = -1
  2061. for j in [18, 16]: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  2062. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  2063. plt.rcParams["font.weight"] = "bold"
  2064. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  2065. plt.rcParams["axes.titleweight"] = "bold"
  2066. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  2067. 'figure.autolayout': True
  2068. })# vector extract
  2069. var = ncfile.variables[u 'temperature'][i, j,: ,: ]
  2070. var =
  2071. switch (var, j)# 마스크 계산 함수 호출...
  2072. var = np.ma.array(var, mask =
  2073. var <= 0.0) cc = plt.contour(
  2074. BS3_X,
  2075. BS3_Y,
  2076. var,
  2077. tp_cont_tick,
  2078. linewidths = 1,
  2079. cmap = vcmap
  2080. ) bsmap3.contourf(
  2081. BS3_X,
  2082. BS3_Y,
  2083. var,
  2084. tp_conf_tick,
  2085. cmap = cmap_jet1,
  2086. vmin = 0.0,
  2087. vmax = 33.0,
  2088. extend = 'both'
  2089. ) plt.clabel(
  2090. cc,
  2091. inline = True,
  2092. fontsize = 12,
  2093. fmt = '%2i',
  2094. colors = 'k',
  2095. inline_spacing = 3.0
  2096. )# FILL POLYGON COLOR AND PLOT BOUNDATY LINE BSPATCH = BSPOLY3(bsmap3) JPPATCH = JPPOLY(
  2097. bsmap3
  2098. ) redline(bsmap3) blueline(bsmap3) greenline(bsmap3) ax.add_collection(
  2099. PatchCollection(
  2100. BSPATCH,
  2101. facecolor = 'lightgray',
  2102. edgecolor = 'k',
  2103. linewidths = 0.5,
  2104. zorder = 1
  2105. )
  2106. ) ax.add_collection(PatchCollection(
  2107. JPPATCH,
  2108. facecolor = 'lightgray',
  2109. edgecolor = 'k',
  2110. linewidths = 0.5,
  2111. zorder = 1
  2112. ))# color bar colorbar = bsmap3.colorbar(
  2113. location = 'right',
  2114. size = 0.25,
  2115. ticks = tp_cbar_tick,
  2116. cmap = cmap_jet1,
  2117. extendrect = 'False'
  2118. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# white background gray fill contin bsmap3.drawparallels(
  2119. np.arange(-150, 120, 2),
  2120. labels = [
  2121. 0, 0, 0, 0
  2122. ],
  2123. dashes = [
  2124. 2, 2
  2125. ],
  2126. color = 'lightgray'
  2127. ) bsmap3.drawmeridians(np.arange(-180, 180, 2), labels = [
  2128. 0, 0, 0, 0
  2129. ], dashes = [
  2130. 2, 2
  2131. ], color = 'lightgray') bsmap3.drawmapboundary(fill_color = 'white') plt.title(
  2132. u 'Seawater Temperature(\N{DEGREE SIGN}C)',
  2133. loc = 'left',
  2134. size = 20
  2135. ) plt.suptitle(
  2136. '[depth : ' + str(int(dep[depcount])) + 'm]',
  2137. x = 0.435,
  2138. y = 0.900,
  2139. size = 15
  2140. )# time label plt.annotate(
  2141. 'VALID :' + times[i] + ' UTC',
  2142. xy = (0.0, -0.03),
  2143. color = 'red',
  2144. fontweight = 'bold',
  2145. textcoords = 'axes fraction',
  2146. verticalalignment = 'left',
  2147. xycoords = 'data',
  2148. size = 15
  2149. ) plt.annotate(
  2150. local_dt[i] + ' KST',
  2151. xy = (0.092, -0.055),
  2152. color = 'black',
  2153. fontweight = 'bold',
  2154. textcoords = 'axes fraction',
  2155. verticalalignment = 'left',
  2156. xycoords = 'data',
  2157. size = 15
  2158. ) plt.annotate(
  2159. 'TIME :' + times[0] + ' UTC',
  2160. xy = (0.7, -0.03),
  2161. color = 'red',
  2162. fontweight = 'bold',
  2163. textcoords = 'axes fraction',
  2164. verticalalignment = 'left',
  2165. xycoords = 'data',
  2166. size = 15
  2167. ) plt.annotate(
  2168. local_dt[0] + ' KST',
  2169. xy = (0.780, -0.055),
  2170. color = 'black',
  2171. fontweight = 'bold',
  2172. textcoords = 'axes fraction',
  2173. verticalalignment = 'left',
  2174. xycoords = 'data',
  2175. size = 15
  2176. ) plt.savefig(
  2177. 'BS3_temp' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  2178. )# plt.savefig('AAAAA.png') print(
  2179. 'BS3_temp_' + times[i] + 'h_' + str(int(dep[depcount])) +
  2180. 'm_layer.png SUCCESS!!'
  2181. )# plt.show()## BS3 - SA# In[]: dep = [0, 10, 25, 50, 75] depnum = [18, 16, 15, 13, 12]# surface / 10 m / 25 m / 50 m / 75 m
  2182. for i in range(0, timelen, 1): depcount = -1
  2183. for j in [18, 16]: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  2184. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  2185. plt.rcParams["font.weight"] = "bold"
  2186. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  2187. plt.rcParams["axes.titleweight"] = "bold"
  2188. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  2189. 'figure.autolayout': True
  2190. })# vector extract
  2191. var = ncfile.variables[u 'salinity'][i, j,: ,: ]
  2192. var =
  2193. switch (var, j)# 마스크 계산 함수 호출...
  2194. var = np.ma.array(var, mask =
  2195. var <= 0.0) cc = plt.contour(
  2196. BS3_X,
  2197. BS3_Y,
  2198. var,
  2199. sa_cont_tick,
  2200. linewidths = 1,
  2201. cmap = vcmap
  2202. ) bsmap3.contourf(
  2203. BS3_X,
  2204. BS3_Y,
  2205. var,
  2206. sa_conf_tick,
  2207. cmap = cmap_jet1,
  2208. vmin = 25.0,
  2209. vmax = 35.0,
  2210. extend = 'both'
  2211. ) plt.clabel(
  2212. cc,
  2213. inline = True,
  2214. fontsize = 12,
  2215. fmt = '%2.1f',
  2216. colors = 'k',
  2217. inline_spacing = 3.0
  2218. )# FILL POLYGON COLOR AND PLOT BOUNDATY LINE BSPATCH = BSPOLY3(bsmap3) JPPATCH = JPPOLY(
  2219. bsmap3
  2220. ) redline(bsmap3) blueline(bsmap3) greenline(bsmap3) ax.add_collection(
  2221. PatchCollection(
  2222. BSPATCH,
  2223. facecolor = 'lightgray',
  2224. edgecolor = 'k',
  2225. linewidths = 0.5,
  2226. zorder = 1
  2227. )
  2228. ) ax.add_collection(PatchCollection(
  2229. JPPATCH,
  2230. facecolor = 'lightgray',
  2231. edgecolor = 'k',
  2232. linewidths = 0.5,
  2233. zorder = 1
  2234. ))# color bar colorbar = bsmap3.colorbar(
  2235. location = 'right',
  2236. size = 0.25,
  2237. ticks = sa_cbar_tick,
  2238. cmap = cmap_jet1,
  2239. extendrect = 'False'
  2240. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# white background gray fill contin bsmap3.drawparallels(
  2241. np.arange(-150, 120, 2),
  2242. labels = [
  2243. 0, 0, 0, 0
  2244. ],
  2245. dashes = [
  2246. 2, 2
  2247. ],
  2248. color = 'lightgray'
  2249. ) bsmap3.drawmeridians(np.arange(-180, 180, 2), labels = [
  2250. 0, 0, 0, 0
  2251. ], dashes = [
  2252. 2, 2
  2253. ], color = 'lightgray') bsmap3.drawmapboundary(fill_color = 'white') plt.title(
  2254. 'Salinity(psu)',
  2255. loc = 'left',
  2256. size = 20
  2257. ) plt.suptitle(
  2258. '[depth : ' + str(int(dep[depcount])) + 'm]',
  2259. x = 0.255,
  2260. y = 0.880,
  2261. size = 15
  2262. )# time label plt.annotate(
  2263. 'VALID :' + times[i] + ' UTC',
  2264. xy = (0.0, -0.03),
  2265. color = 'red',
  2266. fontweight = 'bold',
  2267. textcoords = 'axes fraction',
  2268. verticalalignment = 'left',
  2269. xycoords = 'data',
  2270. size = 15
  2271. ) plt.annotate(
  2272. local_dt[i] + ' KST',
  2273. xy = (0.092, -0.055),
  2274. color = 'black',
  2275. fontweight = 'bold',
  2276. textcoords = 'axes fraction',
  2277. verticalalignment = 'left',
  2278. xycoords = 'data',
  2279. size = 15
  2280. ) plt.annotate(
  2281. 'TIME :' + times[0] + ' UTC',
  2282. xy = (0.7, -0.03),
  2283. color = 'red',
  2284. fontweight = 'bold',
  2285. textcoords = 'axes fraction',
  2286. verticalalignment = 'left',
  2287. xycoords = 'data',
  2288. size = 15
  2289. ) plt.annotate(
  2290. local_dt[0] + ' KST',
  2291. xy = (0.780, -0.055),
  2292. color = 'black',
  2293. fontweight = 'bold',
  2294. textcoords = 'axes fraction',
  2295. verticalalignment = 'left',
  2296. xycoords = 'data',
  2297. size = 15
  2298. ) plt.savefig(
  2299. 'BS3_sa' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  2300. ) print(
  2301. 'BS3_sa_' + times[i] + 'h_' + str(int(dep[depcount])) +
  2302. 'm_layer.png SUCCESS!!'
  2303. )# plt.show()## BS4 - CV del varU del varV del varVM del
  2304. var del Q arrow_magn = 10.0 dep = [0, 10, 25, 50, 75] depnum = [18, 16]# surface / 10 m / 25 m / 50 m / 75 m
  2305. for i in range(0, timelen, 1): depcount = -1
  2306. for j in depnum: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  2307. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  2308. plt.rcParams["font.weight"] = "bold"
  2309. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  2310. plt.rcParams["axes.titleweight"] = "bold"
  2311. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  2312. 'figure.autolayout': True
  2313. })# vector extract varU = ncfile.variables[u 'u'][i, j,: ,: ] varV = ncfile.variables[u 'v'][i, j,: ,: ] varVM = ncfile.variables[u 'vm'][i, j,: ,: ] varVM =
  2314. switch (
  2315. varVM,
  2316. j
  2317. )# 마스크 계산 함수 호출...varVM = np.ma.array(varVM, mask = varVM <= 0.0) plt.contour(
  2318. BS4_X,
  2319. BS4_Y,
  2320. varVM,
  2321. cv_tick,
  2322. linewidths = 0,
  2323. color = 'k'
  2324. ) bsmap4.contourf(
  2325. BS4_X,
  2326. BS4_Y,
  2327. varVM,
  2328. cv_tick,
  2329. cmap = cmap_jet,
  2330. vmin = 0,
  2331. vmax = 2,
  2332. extend = 'both'
  2333. )# color bar colorbar = bsmap4.colorbar(
  2334. location = 'right',
  2335. size = 0.25,
  2336. ticks = cv_cbar_tick,
  2337. cmap = cmap_jet,
  2338. extendrect = 'False'
  2339. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# vector mapping meana = np.mean(
  2340. varVM[points]
  2341. ) Q = bsmap4.quiver(
  2342. lon2D[points],
  2343. lat2D[points],
  2344. varU[points],
  2345. varV[points],
  2346. varVM[points],
  2347. pivot = 'middle',
  2348. cmap = vcmap,
  2349. latlon = True,
  2350. scale_units = 'inches',
  2351. scale = meana * arrow_magn,
  2352. minlength = 0.1,
  2353. headwidth = 4.0
  2354. ) plt.quiverkey(
  2355. Q,
  2356. 0.1,
  2357. 0.95,
  2358. 1,
  2359. '' + str(int(1)) + 'm/s',
  2360. labelpos = 'N',
  2361. fontproperties = {
  2362. 'weight': 'bold',
  2363. 'size': '14'
  2364. },
  2365. labelsep = 0.1
  2366. ) plt.quiverkey(
  2367. Q,
  2368. 0.1,
  2369. 0.95,
  2370. 1,
  2371. 'Reference Vector',
  2372. labelpos = 'S',
  2373. fontproperties = {
  2374. 'weight': 'bold',
  2375. 'size': '14'
  2376. },
  2377. labelsep = 0.1
  2378. )# ADD POLYGON BSPATCH = BSPOLY4(bsmap4) JPPATCH = JPPOLY(bsmap4)# plot bln line redline(
  2379. bsmap4
  2380. ) blueline(bsmap4) greenline(bsmap4) ax.add_collection(PatchCollection(
  2381. BSPATCH,
  2382. facecolor = 'lightgray',
  2383. edgecolor = 'k',
  2384. linewidths = 0.5,
  2385. zorder = 1
  2386. )) ax.add_collection(PatchCollection(
  2387. JPPATCH,
  2388. facecolor = 'lightgray',
  2389. edgecolor = 'k',
  2390. linewidths = 0.5,
  2391. zorder = 1
  2392. ))# gray background bsmap4.drawparallels(np.arange(-150, 120, 2), labels = [
  2393. 0, 0, 0, 0
  2394. ], dashes = [
  2395. 2, 2
  2396. ], color = 'lightgray') bsmap4.drawmeridians(np.arange(-180, 180, 2), labels = [
  2397. 0, 0, 0, 0
  2398. ], dashes = [
  2399. 2, 2
  2400. ], color = 'lightgray') bsmap4.drawmapboundary(fill_color = 'white') plt.title(
  2401. 'Currend Vectors(m/s)',
  2402. loc = 'left',
  2403. size = 20
  2404. ) plt.suptitle(
  2405. '[depth : ' + str(int(dep[depcount])) + 'm]',
  2406. x = 0.365,
  2407. y = 0.840,
  2408. size = 15
  2409. )# time label plt.annotate(
  2410. 'VALID :' + times[i] + ' UTC',
  2411. xy = (0.0, -0.035),
  2412. color = 'red',
  2413. fontweight = 'bold',
  2414. textcoords = 'axes fraction',
  2415. verticalalignment = 'left',
  2416. xycoords = 'data',
  2417. size = 15
  2418. ) plt.annotate(
  2419. local_dt[i] + ' KST',
  2420. xy = (0.092, -0.065),
  2421. color = 'black',
  2422. fontweight = 'bold',
  2423. textcoords = 'axes fraction',
  2424. verticalalignment = 'left',
  2425. xycoords = 'data',
  2426. size = 15
  2427. ) plt.annotate(
  2428. 'TIME :' + times[0] + ' UTC',
  2429. xy = (0.7, -0.035),
  2430. color = 'red',
  2431. fontweight = 'bold',
  2432. textcoords = 'axes fraction',
  2433. verticalalignment = 'left',
  2434. xycoords = 'data',
  2435. size = 15
  2436. ) plt.annotate(
  2437. local_dt[0] + ' KST',
  2438. xy = (0.780, -0.065),
  2439. color = 'black',
  2440. fontweight = 'bold',
  2441. textcoords = 'axes fraction',
  2442. verticalalignment = 'left',
  2443. xycoords = 'data',
  2444. size = 15
  2445. ) plt.savefig(
  2446. 'BS4_cv' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  2447. ) print(
  2448. 'BS4_cv_' + times[i] + 'h_' + str(int(dep[depcount])) +
  2449. 'm_layer.png SUCCESS!!'
  2450. )# plt.show()## BS4 - TE# In[]: dep = [0, 10, 25, 50, 75] depnum = [18, 16, 15, 13, 12]# surface / 10 m / 25 m / 50 m / 75 m
  2451. for i in range(0, timelen, 1): depcount = -1
  2452. for j in [18, 16]: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  2453. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  2454. plt.rcParams["font.weight"] = "bold"
  2455. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  2456. plt.rcParams["axes.titleweight"] = "bold"
  2457. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  2458. 'figure.autolayout': True
  2459. })# vector extract
  2460. var = ncfile.variables[u 'temperature'][i, j,: ,: ]
  2461. var =
  2462. switch (var, j)# 마스크 계산 함수 호출...
  2463. var = np.ma.array(var, mask =
  2464. var <= 0.0) cc = plt.contour(
  2465. BS4_X,
  2466. BS4_Y,
  2467. var,
  2468. tp_cont_tick,
  2469. linewidths = 1,
  2470. cmap = vcmap
  2471. ) bsmap4.contourf(
  2472. BS4_X,
  2473. BS4_Y,
  2474. var,
  2475. tp_conf_tick,
  2476. cmap = cmap_jet1,
  2477. vmin = 0.0,
  2478. vmax = 33.0,
  2479. extend = 'both'
  2480. ) plt.clabel(
  2481. cc,
  2482. inline = True,
  2483. fontsize = 12,
  2484. fmt = '%2i',
  2485. colors = 'k',
  2486. inline_spacing = 3.0
  2487. )# FILL POLYGON COLOR AND PLOT BOUNDATY LINE BSPATCH = BSPOLY4(bsmap4) JPPATCH = JPPOLY(
  2488. bsmap4
  2489. ) redline(bsmap4) blueline(bsmap4) greenline(bsmap4) ax.add_collection(
  2490. PatchCollection(
  2491. BSPATCH,
  2492. facecolor = 'lightgray',
  2493. edgecolor = 'k',
  2494. linewidths = 0.5,
  2495. zorder = 1
  2496. )
  2497. ) ax.add_collection(PatchCollection(
  2498. JPPATCH,
  2499. facecolor = 'lightgray',
  2500. edgecolor = 'k',
  2501. linewidths = 0.5,
  2502. zorder = 1
  2503. ))# color bar colorbar = bsmap4.colorbar(
  2504. location = 'right',
  2505. size = 0.25,
  2506. ticks = tp_cbar_tick,
  2507. cmap = cmap_jet1,
  2508. extendrect = 'False'
  2509. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# white background gray fill contin bsmap4.drawparallels(
  2510. np.arange(-150, 120, 2),
  2511. labels = [
  2512. 0, 0, 0, 0
  2513. ],
  2514. dashes = [
  2515. 2, 2
  2516. ],
  2517. color = 'lightgray'
  2518. ) bsmap4.drawmeridians(np.arange(-180, 180, 2), labels = [
  2519. 0, 0, 0, 0
  2520. ], dashes = [
  2521. 2, 2
  2522. ], color = 'lightgray') bsmap4.drawmapboundary(fill_color = 'white') plt.title(
  2523. u 'Seawater Temperature(\N{DEGREE SIGN}C)',
  2524. loc = 'left',
  2525. size = 20
  2526. ) plt.suptitle(
  2527. '[depth : ' + str(int(dep[depcount])) + 'm]',
  2528. x = 0.435,
  2529. y = 0.840,
  2530. size = 15
  2531. )# time label plt.annotate(
  2532. 'VALID :' + times[i] + ' UTC',
  2533. xy = (0.0, -0.03),
  2534. color = 'red',
  2535. fontweight = 'bold',
  2536. textcoords = 'axes fraction',
  2537. verticalalignment = 'left',
  2538. xycoords = 'data',
  2539. size = 15
  2540. ) plt.annotate(
  2541. local_dt[i] + ' KST',
  2542. xy = (0.092, -0.055),
  2543. color = 'black',
  2544. fontweight = 'bold',
  2545. textcoords = 'axes fraction',
  2546. verticalalignment = 'left',
  2547. xycoords = 'data',
  2548. size = 15
  2549. ) plt.annotate(
  2550. 'TIME :' + times[0] + ' UTC',
  2551. xy = (0.7, -0.03),
  2552. color = 'red',
  2553. fontweight = 'bold',
  2554. textcoords = 'axes fraction',
  2555. verticalalignment = 'left',
  2556. xycoords = 'data',
  2557. size = 15
  2558. ) plt.annotate(
  2559. local_dt[0] + ' KST',
  2560. xy = (0.780, -0.055),
  2561. color = 'black',
  2562. fontweight = 'bold',
  2563. textcoords = 'axes fraction',
  2564. verticalalignment = 'left',
  2565. xycoords = 'data',
  2566. size = 15
  2567. ) plt.savefig(
  2568. 'BS4_temp' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  2569. )# plt.savefig('AAAAA.png') print(
  2570. 'BS4_temp_' + times[i] + 'h_' + str(int(dep[depcount])) +
  2571. 'm_layer.png SUCCESS!!'
  2572. )# plt.show()## BS4 - SA# In[]: dep = [0, 10, 25, 50, 75] depnum = [18, 16, 15, 13, 12]# surface / 10 m / 25 m / 50 m / 75 m
  2573. for i in range(0, timelen, 1): depcount = -1
  2574. for j in [18, 16]: #print(j) depcount += 1# fig Size fig = plt.figure(figsize = (10, 12.5)) ax = fig.add_subplot(111)# style plt.style.use('seaborn-darkgrid')# define font size plt.rc("font", size = 15) plt.rcParams['font.family'] = 'sans-serif'
  2575. plt.rcParams['font.sans-serif'] = 'New Century Schoolbook'
  2576. plt.rcParams["font.weight"] = "bold"
  2577. plt.rcParams['axes.labelsize'] = 26 plt.rcParams['xtick.labelsize'] = 26 plt.rcParams['ytick.labelsize'] = 26 plt.rcParams["axes.labelweight"] = "bold"
  2578. plt.rcParams["axes.titleweight"] = "bold"
  2579. plt.rcParams['contour.corner_mask'] = False plt.rcParams.update({
  2580. 'figure.autolayout': True
  2581. })# vector extract
  2582. var = ncfile.variables[u 'salinity'][i, j,: ,: ]
  2583. var =
  2584. switch (var, j)# 마스크 계산 함수 호출...
  2585. var = np.ma.array(var, mask =
  2586. var <= 0.0) cc = plt.contour(
  2587. BS4_X,
  2588. BS4_Y,
  2589. var,
  2590. sa_cont_tick,
  2591. linewidths = 1,
  2592. cmap = vcmap
  2593. ) bsmap4.contourf(
  2594. BS4_X,
  2595. BS4_Y,
  2596. var,
  2597. sa_conf_tick,
  2598. cmap = cmap_jet1,
  2599. vmin = 25.0,
  2600. vmax = 35.0,
  2601. extend = 'both'
  2602. ) plt.clabel(
  2603. cc,
  2604. inline = True,
  2605. fontsize = 12,
  2606. fmt = '%2.1f',
  2607. colors = 'k',
  2608. inline_spacing = 3.0
  2609. )# FILL POLYGON COLOR AND PLOT BOUNDATY LINE BSPATCH = BSPOLY4(bsmap4) JPPATCH = JPPOLY(
  2610. bsmap4
  2611. ) redline(bsmap4) blueline(bsmap4) greenline(bsmap4) ax.add_collection(
  2612. PatchCollection(
  2613. BSPATCH,
  2614. facecolor = 'lightgray',
  2615. edgecolor = 'k',
  2616. linewidths = 0.5,
  2617. zorder = 1
  2618. )
  2619. ) ax.add_collection(PatchCollection(
  2620. JPPATCH,
  2621. facecolor = 'lightgray',
  2622. edgecolor = 'k',
  2623. linewidths = 0.5,
  2624. zorder = 1
  2625. ))# color bar colorbar = bsmap4.colorbar(
  2626. location = 'right',
  2627. size = 0.25,
  2628. ticks = sa_cbar_tick,
  2629. cmap = cmap_jet1,
  2630. extendrect = 'False'
  2631. ) colorbar.ax.set_yticklabels(colorbar.ax.get_yticklabels(), fontsize = 11)# white background gray fill contin bsmap4.drawparallels(
  2632. np.arange(-150, 120, 2),
  2633. labels = [
  2634. 0, 0, 0, 0
  2635. ],
  2636. dashes = [
  2637. 2, 2
  2638. ],
  2639. color = 'lightgray'
  2640. ) bsmap4.drawmeridians(np.arange(-180, 180, 2), labels = [
  2641. 0, 0, 0, 0
  2642. ], dashes = [
  2643. 2, 2
  2644. ], color = 'lightgray') bsmap4.drawmapboundary(fill_color = 'white') plt.title(
  2645. 'Salinity(psu)',
  2646. loc = 'left',
  2647. size = 20
  2648. ) plt.suptitle(
  2649. '[depth : ' + str(int(dep[depcount])) + 'm]',
  2650. x = 0.255,
  2651. y = 0.840,
  2652. size = 15
  2653. )# time label plt.annotate(
  2654. 'VALID :' + times[i] + ' UTC',
  2655. xy = (0.0, -0.03),
  2656. color = 'red',
  2657. fontweight = 'bold',
  2658. textcoords = 'axes fraction',
  2659. verticalalignment = 'left',
  2660. xycoords = 'data',
  2661. size = 15
  2662. ) plt.annotate(
  2663. local_dt[i] + ' KST',
  2664. xy = (0.092, -0.055),
  2665. color = 'black',
  2666. fontweight = 'bold',
  2667. textcoords = 'axes fraction',
  2668. verticalalignment = 'left',
  2669. xycoords = 'data',
  2670. size = 15
  2671. ) plt.annotate(
  2672. 'TIME :' + times[0] + ' UTC',
  2673. xy = (0.7, -0.03),
  2674. color = 'red',
  2675. fontweight = 'bold',
  2676. textcoords = 'axes fraction',f
  2677. verticalalignment = 'left',
  2678. xycoords = 'data',
  2679. size = 15
  2680. ) plt.annotate(
  2681. local_dt[0] + ' KST',
  2682. xy = (0.780, -0.055),
  2683. color = 'black',
  2684. fontweight = 'bold',
  2685. textcoords = 'axes fraction',
  2686. verticalalignment = 'left',
  2687. xycoords = 'data',
  2688. size = 15
  2689. ) plt.savefig(
  2690. 'BS4_sa' + times[i] + 'h _' + str(int(dep[depcount])) + 'm_layer.png'
  2691. ) print(
  2692. 'BS_sa_' + times[i] + 'h_' + str(int(dep[depcount])) +
  2693. 'm_layer.png SUCCESS!!'
  2694. )# plt.show() stop = timeit.default_timer() print(stop - start)# In[]:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement