【python海洋专题四十九】500hpa位势高度异常场
# -*- coding: utf-8 -*-
# ---导入数据读取和处理的模块-------
import ast
import pandas as pd
from netCDF4 import Dataset
from pathlib import Path
import xarray as xr
from datetime import datetime
import numpy as np
# ------导入画图相关函数--------
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
import matplotlib.ticker as ticker
from cartopy import mpl
import cartopy.crs as ccrs
import cartopy.feature as feature
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
from pylab import *
# -----导入颜色包---------
# -----导入颜色包---------
filename = 'D:\matlab_work\函数名为colormore的颜色索引表制作\R_color_txt\R_color_single\\gray80.txt'
file = open(filename, 'r')
lines = file.readlines()
file.close()
data1 = []
for line in lines:
data1.append(float(line.strip()))
gray = np.array(data1)
# ---read_data---
fu = xr.open_dataset(r'D:\pycharm_work\data\hgt.nc')
lat = fu['lat'].data
lon = fu['lon'].data
hgt = fu['hgt'].data
time = fu['time'].data # 1948-01-01--2021-07-01
# time2 = fu.variables['time'][:]
# # print(type(time2))
level = fu['level'].data
# # ----画全球范围的500hpa的