基于Python的气象时空数据分析教程

阅读: 评论:0

2024年1月26日发(作者:)

基于Python的气象时空数据分析教程

f = t('/home/mw/input/metos8969/metos/OMI-Aura_L3-OMTO3e_2017m0105_5')data = ['HDFEOS'].groups['GRIDS'].groups['OMI Column Amount O3'].groups['Data Fields'].variables['ColumnAmountO3'](data)()()f = t('/home/mw/input/metos8969/metos/_')data = les['topog'](data)()()读取GeoTIFF数据datafile = ('/home/mw/input/metos8969/metos/Southern_Norway_and_')print( "Driver: ",ver().ShortName, ver().LongName)print( "Size is ", XSize, YSize)print( "Bands = ", Count)print( "Coordinate System is:", jectionRef ())print( "GetGeoTransform() = ", Transform ())print( "GetMetadata() = ", adata ())绘制GeoTIFF数据

fig = (figsize=[12,15]) # a new figure windowax = _subplot(1, 1, 1) # specify (nrows, ncols, axnum)_title('Cities in Norway', fontsize=14)map = Basemap(llcrnrlon=-1.0,urcrnrlon=40.,llcrnrlat=55.,urcrnrlat=75., resolution='i', projection='lcc', lat_1=65., lon_0=5.)pboundary(fill_color='aqua')ntinents(color='#ffe2ab',lake_color='aqua')astlines()shapedata = ('/home/mw/input/metos8969/metos/Norway_places')layer = er()for i in range(tureCount()): feature = ture(i) name = ld("NAME") type = ld("TYPE") if type == 'city': geometry = metryRef() lon = nt()[0] lat = nt()[1] x,y = map(lon,lat) (x, y, marker='o', color='red', markersize=8, markeredgewidth=2) te(name, (x, y), color='blue', fontsize=14)()

fig = (figsize=[12,15]) # a new figure windowax = _subplot(1, 1, 1) # specify (nrows, ncols, axnum)map = Basemap(llcrnrlon=-1.0,urcrnrlon=40.,llcrnrlat=55.,urcrnrlat=75., resolution='i', projection='lcc', lat_1=65., lon_0=5.)pboundary(fill_color='aqua')ntinents(color='#ffe2ab',lake_color='aqua')astlines()norway_roads= apefile('/home/mw/input/metos8969/metos/Norway_roads/roads', 'roads')()

la = ('/home/mw/input/metos8969/metos/la_n')nblayer = erCount()print("Number of layers: ", nblayer)layer = er()cities_us = []for i in range(tureCount()): feature = ture(i) name = ld("NAME") geometry = metryRef() cities_([i,name,metryName(), nts()])print(cities_us)

shapedata = ('/home/mw/input/metos8969/metos/NOR_adm')nblayer = erCount()print("Number of layers: ", nblayer)layer = er()nor_adm = []for i in range(tureCount()): feature = ture(i) name_1 = ld("NAME_1") id_1 = ld("ID_1") geometry = metryRef() nor_([i,name_1,id_1, metryName(), id().ExportToWkt()])for i in range(0,len(nor_adm),20): print(nor_adm[i])fig = (figsize=[12,15])ax = _subplot(111)map = Basemap(llcrnrlon=-1.0,urcrnrlon=40.,llcrnrlat=55.,urcrnrlat=75., resolution='i', projection='lcc', lat_1=65., lon_0=5.)pboundary(fill_color='white')ntinents(color='#ffe2ab', zorder=0, ax=ax)astlines()apefile('/home/mw/input/metos8969/metos/NOR_adm/NOR_adm', 'NOR_adm', drawbounds = False)patches = []color_values = (len(_adm))for i, info, shape in zip(range(len(_adm_info)),_adm_info, _adm): ( Polygon((shape), True)) color_values[i] = info['ID_1']col = PatchCollection(patches, linewidths=1., zorder=2)(array=color_values, cmap='jet')_collection(col)

((1000,2000))f = t('/home/mw/input/metos8969/metos/tpw_v07r01_', 'r')lats = les['latitude'][:]lons = les['longitude'][:]pw = les['precipitable_water'][0,:,:]()# Flatten image to get line of valuesflatraster = n() = Falseflatraster = # In first subplot add original imagefig, (ax1, ax2, ax3) = ts(3, sharex=True)# Create figure to receive _figheight(20)_figwidth(15)le('K-Means Clustering')('off')_title('Original ImagenMonthly Average Precipitable Watern over Ice-Free Oceans (kg m-2)')original=(pw, cmap='rainbow', interpolation='nearest', aspect='auto', origin='lower')ar(original, cmap='rainbow', ax=ax1, orientation='vertical')# In remaining subplots add k-means clustered images# Define colormaplist_colors=['blue','orange', 'green', 'magenta', 'cyan', 'gray', 'red', 'yellow']print("Calculate k-means with 6 clusters.")

#This scipy code classifies k-mean, code has same length as flattened# raster and defines which cluster the value corresponds tocentroids, variance = kmeans((float), 6)code, distance = vq(flatraster, centroids)

#Since code contains the clustered values, reshape into SAR dimensionscodeim = e([0], [1])

#Plot the subplot with 4th ('off')xlabel = '6 clusters'_title(xlabel)bounds=range(0,6)cmap = Colormap(list_colors[0:6])kmp=(codeim, interpolation='nearest', aspect='auto', cmap=cmap, origin='lower')

ar(kmp, cmap=cmap, ticks=bounds, ax=ax2, orientation='vertical')#####################################thresholded = ()thresholded[codeim==3]=1thresholded[codeim==4]=2#Plot only values == ('off')xlabel = 'Keep the fifth cluster only'_title(xlabel)bounds=range(0,2)cmap = Colormap(['white', 'green', 'cyan'])kmp=(thresholded, interpolation='nearest', aspect='auto', cmap=cmap, origin='lower')ar(kmp, cmap=cmap, ticks=bounds, ax=ax3, orientation='vertical')()

基于Python的气象时空数据分析教程

本文发布于:2024-01-26 04:01:56,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/1706212916718.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:数据   气象   时空   教程   读取
留言与评论(共有 0 条评论)
   
验证码:
排行榜

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23