forked from flashlxy/PyMICAPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicapsFile.py
58 lines (54 loc) · 2.22 KB
/
MicapsFile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-
#
# Author: Liu xianyao
# Email: [email protected]
# Update: 2017-04-06
# Copyright: ©江西省气象台 2017
# Version: 1.1.20170406
from __future__ import print_function
import os
from matplotlib.font_manager import FontProperties
from Contour import Contour
from File import File
from Legend import Legend
from Title import Title
import matplotlib.pyplot as plt
from UV import UV
class MicapsFile:
def __init__(self, leaf):
self.file = File(leaf)
self.legend = Legend(leaf)
self.contour = Contour(leaf)
self.title = Title(leaf)
self.uv = UV(leaf)
@staticmethod
def DrawTitle(m, title, headtxt):
if m is plt:
if title.mtitleposition is None:
for desc in title.descs:
fontfile = r"C:\WINDOWS\Fonts\{0}".format(desc.font['family'])
if not os.path.exists(fontfile):
font = FontProperties(size=desc.font['fontsize'], weight=desc.font['weight'])
else:
font = FontProperties(fname=fontfile, size=desc.font['fontsize'], weight=desc.font['weight'])
plt.text(desc.pos[0], desc.pos[1], desc.text,
# size=desc.font['fontsize'], weight=desc.font['weight'],
color=desc.font['color'],
fontdict=desc.font,
fontproperties=font,
rotation=0,
ha='left', va='top')
else:
if title.mtitleposition == [0, 0]:
plt.title(headtxt, fontdict={'fontsize': 14})
else:
plt.text(title.mtitleposition[0], title.mtitleposition[1], headtxt,
size=14,
weight='bold',
# color='blue',
# fontdict=desc.font,
# fontproperties=font,
rotation=0,
ha='left', va='top')
else:
plt.title(headtxt)