增加了674个字符的身体
链接
埃里克
  • 2 k
  • 10
  • 11
进口numpy从scipy.interpolate np进口griddata进口xarray xr进口熊猫一样pd进口rioxarray进口netCDF4 nc4 matplotlib进口。pyplot作为plt从美观。几何进口点进口geopandas pyproj进口CRS加仑日CRS_3857 = CRS.from_epsg (3857) CRS_wkt = CRS_3857.to_wkt(相当= False)打印(CRS_wkt)# - - -输入数据....lat =(50.1, 50.2, 50.3, 50.4, 50.5, 62]朗= (8.1,8.2,8.3,8.4,8.5,12]temp = [1、2、3、4、5、6)#放入熊猫Dataframe df = pd。数据Frame( { 'latitude': lat, 'longitude': lon, 'temp': temp})#准备几何pointShp = [x (x, y),y在zip (df。经度,df.latitude)] pointGpd =加仑日。GeoDataFrame (df、几何= pointShp crs = EPSG: 4326) # Reproject point3857 = pointGpd.to_crs (EPSG: 3857) point3857 [x] = point3857。应用(λx: x.geometry.centroid。x轴= 1)point3857 [y] = point3857。应用(λx: x.geometry.centroid。y轴= 1)df = point3857 [[‘x’,‘y’,‘临时’]]朗=列表(df (' x ']) lat =列表(df [y]) temp =列表(df(临时的))# #开始你的源代码推荐- - - - - -是在规则的网格项目输入数据ξ= np。不等linspace(6.0分钟(朗),14.0马克斯(朗),0.1500年)易= np。不等linspace(48.0分钟(lat),64.0马克斯(lat),0.1500年),易建联= np。meshgrid (xi, yi)子= np.ones_like (xi, dtype = np.float32) * np。南#子= griddata((经度、纬度)、温度(xi, yi)方法=“线性”)我的范围(len(临时):idx = np。argmin (np。√(xi-lon[我])* * 2 + (yi-lat[我])* * 2)子(np)。unravel_index (idx xi.shape)] = temp[我]# - - -检查……= >看起来不错7)plt.figure (figsize = (15) plt.subplot plt (1、2、1)。散射(经度、纬度、临时、临时)plt.subplot plt (1、2、2)。pcolor(习,易,np.where(np.isnan(zi),0,zi)) plt.show() # --- Open NetCDF file to write on with nc4.Dataset('test.nc', 'w' , format='NETCDF3_CLASSIC') as ds: # --- Initialize the dimensions of the dataset dim_time = ds.createDimension('time', 0) dim_lat = ds.createDimension('lat', yi.shape[0]) dim_lon = ds.createDimension('lon', xi.shape[1]) # --- Create the corresponding variables for the dimensions time = ds.createVariable('time', np.float32, 'time') latitude = ds.createVariable('lat', np.float32, 'lat') latitude.units = ['degrees north'] latitude.axis = ['Y'] latitude.standard_name = ['latitude'] longitude = ds.createVariable('lon', np.float32, 'lon') longitude.units = ['degrees east'] longitude.axis = ['X'] longitude.standard_name = ['longitude'] # --- Fill with 1D (!) arrays of xi/yi, as the meshgrid returns 2D arrays... time[:] = 0 latitude[:] = yi[:,0] longitude[:] = xi[0,:] # --- Create a coordinate reference system crs = ds.createVariable(“WGS84”“CRS”crs,“c”)。spatial_ref =”““GEOGCS (“WGS 84”,基准面(“WGS_1984”, (“WGS球体84,6378137,298.257223563,权威[“EPSG”、“7030”]],权威[“EPSG”、“6326”]], PRIMEM[“格林威治”,0,权威[“EPSG”、“8901”]],单位(“学位”,0.01745329251994328,权威[“EPSG”、“9122”]],权威[“EPSG”、“4326”]]“”“CRS_wkt# - - -准备好了温度数据字段值= ds。createVariable(“温度”,np。float32(“时间”,“纬度”,“朗”)的价值。grid_mapping =“WGS84”“CRS”# crs变量名称的值。grid_mapping_name = ' latitude_longitude ' #——充满值值0::=子

在这里输入图像描述

在这里输入图像描述

进口numpy从scipy.interpolate np进口griddata进口xarray xr进口熊猫一样pd进口rioxarray进口netCDF4 nc4 matplotlib进口。.... pyplot plt # - - -输入数据lat =(50.1, 50.2, 50.3, 50.4, 50.5, 62]朗= (8.1,8.2,8.3,8.4,8.5,12]temp =[1、2、3、4、5、6] # - - -项目输入数据在规则的网格ξ= np。不等(6.0,14.0,0.1)易= np。不等(48.0,64.0,0.1),易建联= np。meshgrid (xi, yi)子= np.ones_like (xi, dtype = np.float32) * np。南#子= griddata((经度、纬度)、温度(xi, yi)方法=“线性”)我的范围(len(临时):idx = np。argmin (np。√(xi-lon[我])* * 2 + (yi-lat[我])* * 2)子(np)。unravel_index (idx xi.shape)] = temp[我]# - - -检查……7)plt.figure (figsize = (15) plt.subplot plt (1、2、1)。散射(经度、纬度、临时、临时)plt.subplot plt (1、2、2)。pcolor(习,易,np.where(np.isnan(zi),0,zi)) plt.show() # --- Open NetCDF file to write on with nc4.Dataset('test.nc', 'w' , format='NETCDF3_CLASSIC') as ds: # --- Initialize the dimensions of the dataset dim_time = ds.createDimension('time', 0) dim_lat = ds.createDimension('lat', yi.shape[0]) dim_lon = ds.createDimension('lon', xi.shape[1]) # --- Create the corresponding variables for the dimensions time = ds.createVariable('time', np.float32, 'time') latitude = ds.createVariable('lat', np.float32, 'lat') latitude.units = ['degrees north'] latitude.axis = ['Y'] latitude.standard_name = ['latitude'] longitude = ds.createVariable('lon', np.float32, 'lon') longitude.units = ['degrees east'] longitude.axis = ['X'] longitude.standard_name = ['longitude'] # --- Fill with 1D (!) arrays of xi/yi, as the meshgrid returns 2D arrays... time[:] = 0 latitude[:] = yi[:,0] longitude[:] = xi[0,:] # --- Create a coordinate reference system crs = ds.createVariable(“WGS84”crs,“c”)。spatial_ref =”““GEOGCS (“WGS 84”,基准面(“WGS_1984”, (“WGS球体84,6378137,298.257223563,权威[“EPSG”、“7030”]],权威[“EPSG”、“6326”]], PRIMEM[“格林威治”,0,权威[“EPSG”、“8901”]],单位(“学位”,0.01745329251994328,权威[“EPSG”、“9122”]],权威[“EPSG”、“4326”]]“”“# - - -准备好了温度数据字段值= ds。createVariable(“温度”,np。float32(“时间”,“纬度”,“朗”)的价值。grid_mapping =“WGS84”# crs变量名称的值。grid_mapping_name = ' latitude_longitude ' #——充满值值0::=子

在这里输入图像描述

进口numpy从scipy.interpolate np进口griddata进口xarray xr进口熊猫一样pd进口rioxarray进口netCDF4 nc4 matplotlib进口。pyplot作为plt从美观。几何进口点进口geopandas pyproj进口CRS加仑日CRS_3857 = CRS.from_epsg (3857) CRS_wkt = CRS_3857.to_wkt(相当= False)打印(CRS_wkt)# - - -输入数据....lat =(50.1, 50.2, 50.3, 50.4, 50.5, 62]朗= (8.1,8.2,8.3,8.4,8.5,12]temp = [1、2、3、4、5、6)#放入熊猫Dataframe df = pd。数据Frame( { 'latitude': lat, 'longitude': lon, 'temp': temp})#准备几何pointShp = [x (x, y),y在zip (df。经度,df.latitude)] pointGpd =加仑日。GeoDataFrame (df、几何= pointShp crs = EPSG: 4326) # Reproject point3857 = pointGpd.to_crs (EPSG: 3857) point3857 [x] = point3857。应用(λx: x.geometry.centroid。x轴= 1)point3857 [y] = point3857。应用(λx: x.geometry.centroid。y轴= 1)df = point3857 [[‘x’,‘y’,‘临时’]]朗=列表(df (' x ']) lat =列表(df [y]) temp =列表(df(临时的))# #开始你的源代码推荐- - - - - -是在规则的网格项目输入数据ξ= np。linspace(分钟(朗),马克斯(朗),500年)易= np。linspace(分钟(lat),马克斯(lat),500年),易建联= np。meshgrid (xi, yi)子= np.ones_like (xi, dtype = np.float32) * np。南#子= griddata((经度、纬度)、温度(xi, yi)方法=“线性”)我的范围(len(临时):idx = np。argmin (np。√(xi-lon[我])* * 2 + (yi-lat[我])* * 2)子(np)。unravel_index (idx xi.shape)] = temp[我]# - - -检查……= >看起来不错7)plt.figure (figsize = (15) plt.subplot plt (1、2、1)。散射(经度、纬度、临时、临时)plt.subplot plt (1、2、2)。pcolor(习,易,np.where(np.isnan(zi),0,zi)) plt.show() # --- Open NetCDF file to write on with nc4.Dataset('test.nc', 'w' , format='NETCDF3_CLASSIC') as ds: # --- Initialize the dimensions of the dataset dim_time = ds.createDimension('time', 0) dim_lat = ds.createDimension('lat', yi.shape[0]) dim_lon = ds.createDimension('lon', xi.shape[1]) # --- Create the corresponding variables for the dimensions time = ds.createVariable('time', np.float32, 'time') latitude = ds.createVariable('lat', np.float32, 'lat') latitude.units = ['degrees north'] latitude.axis = ['Y'] latitude.standard_name = ['latitude'] longitude = ds.createVariable('lon', np.float32, 'lon') longitude.units = ['degrees east'] longitude.axis = ['X'] longitude.standard_name = ['longitude'] # --- Fill with 1D (!) arrays of xi/yi, as the meshgrid returns 2D arrays... time[:] = 0 latitude[:] = yi[:,0] longitude[:] = xi[0,:] # --- Create a coordinate reference system crs = ds.createVariable(“CRS”crs,“c”)。spatial_ref =CRS_wkt# - - -准备好了温度数据字段值= ds。createVariable(“温度”,np。float32(“时间”,“纬度”,“朗”)的价值。grid_mapping =“CRS”# crs变量名称的值。grid_mapping_name = ' latitude_longitude ' #——充满值值0::=子

在这里输入图像描述

在这里输入图像描述

添加1字符的身体
链接
埃里克
  • 2 k
  • 10
  • 11
进口numpy从scipy.interpolate np进口griddata进口xarray xr进口熊猫一样pd进口rioxarray进口netCDF4 nc4 matplotlib进口。.... pyplot plt # - - -输入数据lat =(50.1, 50.2, 50.3, 50.4, 50.5, 62]朗= (8.1,8.2,8.3,8.4,8.5,12]temp =[1、2、3、4、5、6] # - - -项目输入数据在规则的网格ξ= np.arange(6.0, 14.0, 0.1)易= np.arange(48.0, 64.0, 0.1),易= np。meshgrid (xi, yi)子= np。zeros_likeones_like(xi, dtype = np.float32) *-999年np.NaN#子= griddata((经度、纬度)、温度(xi, yi)方法=“线性”)我的范围(len(临时):idx = np。argmin (np。√(xi-lon[我])* * 2 + (yi-lat[我])* * 2)子(np)。unravel_index (idx xi.shape)] = temp[我]# - - -检查……7)plt.figure (figsize = (15) plt.subplot plt (1、2、1)。散射(经度、纬度、临时、临时)plt.subplot plt (1、2、2)。pcolor(习,易,np.where(np.isnan(zi),0,zi)) plt.show() # --- Open NetCDF file to write on with nc4.Dataset('test.nc', 'w' , format='NETCDF3_CLASSIC') as ds: # --- Initialize the dimensions of the dataset dim_time = ds.createDimension('time', 0) dim_lat = ds.createDimension('lat', yi.shape[0]) dim_lon = ds.createDimension('lon', xi.shape[1]) # --- Create the corresponding variables for the dimensions time = ds.createVariable('time', np.float32, 'time') latitude = ds.createVariable('lat', np.float32, 'lat') latitude.units = ['degrees north'] latitude.axis = ['Y'] latitude.standard_name = ['latitude'] longitude = ds.createVariable('lon', np.float32, 'lon') longitude.units = ['degrees east'] longitude.axis = ['X'] longitude.standard_name = ['longitude'] # --- Fill with 1D (!) arrays of xi/yi, as the meshgrid returns 2D arrays... time[:] = 0 latitude[:] = yi[:,0] longitude[:] = xi[0,:] # --- Create a coordinate reference system crs = ds.createVariable('WGS84', 'c') crs.spatial_ref = """GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]""" # --- Ready the Temperature data field value = ds.createVariable('temperature', np.float32, ('time','lat','lon')) value.grid_mapping = 'WGS84' # the crs variable name value.grid_mapping_name = 'latitude_longitude' # --- Fill with values value[0,:,:] = zi
进口numpy从scipy.interpolate np进口griddata进口xarray xr进口熊猫一样pd进口rioxarray进口netCDF4 nc4 matplotlib进口。.... pyplot plt # - - -输入数据lat =(50.1, 50.2, 50.3, 50.4, 50.5, 62]朗= (8.1,8.2,8.3,8.4,8.5,12]temp =[1、2、3、4、5、6] # - - -项目输入数据在规则的网格ξ= np.arange(6.0, 14.0, 0.1)易= np.arange(48.0, 64.0, 0.1),易= np。meshgrid (xi, yi)子= np。zeros_like(xi, dtype = np.float32) *-999年#子= griddata((经度、纬度)、温度(xi, yi)方法=“线性”)我的范围(len(临时):idx = np。argmin (np。√(xi-lon[我])* * 2 + (yi-lat[我])* * 2)子(np)。unravel_index (idx xi.shape)] = temp[我]# - - -检查……7)plt.figure (figsize = (15) plt.subplot plt (1、2、1)。散射(经度、纬度、临时、临时)plt.subplot plt (1、2、2)。pcolor(习,易,np.where(np.isnan(zi),0,zi)) plt.show() # --- Open NetCDF file to write on with nc4.Dataset('test.nc', 'w' , format='NETCDF3_CLASSIC') as ds: # --- Initialize the dimensions of the dataset dim_time = ds.createDimension('time', 0) dim_lat = ds.createDimension('lat', yi.shape[0]) dim_lon = ds.createDimension('lon', xi.shape[1]) # --- Create the corresponding variables for the dimensions time = ds.createVariable('time', np.float32, 'time') latitude = ds.createVariable('lat', np.float32, 'lat') latitude.units = ['degrees north'] latitude.axis = ['Y'] latitude.standard_name = ['latitude'] longitude = ds.createVariable('lon', np.float32, 'lon') longitude.units = ['degrees east'] longitude.axis = ['X'] longitude.standard_name = ['longitude'] # --- Fill with 1D (!) arrays of xi/yi, as the meshgrid returns 2D arrays... time[:] = 0 latitude[:] = yi[:,0] longitude[:] = xi[0,:] # --- Create a coordinate reference system crs = ds.createVariable('WGS84', 'c') crs.spatial_ref = """GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]""" # --- Ready the Temperature data field value = ds.createVariable('temperature', np.float32, ('time','lat','lon')) value.grid_mapping = 'WGS84' # the crs variable name value.grid_mapping_name = 'latitude_longitude' # --- Fill with values value[0,:,:] = zi
进口numpy从scipy.interpolate np进口griddata进口xarray xr进口熊猫一样pd进口rioxarray进口netCDF4 nc4 matplotlib进口。.... pyplot plt # - - -输入数据lat =(50.1, 50.2, 50.3, 50.4, 50.5, 62]朗= (8.1,8.2,8.3,8.4,8.5,12]temp =[1、2、3、4、5、6] # - - -项目输入数据在规则的网格ξ= np.arange(6.0, 14.0, 0.1)易= np.arange(48.0, 64.0, 0.1),易= np。meshgrid (xi, yi)子= np。ones_like(xi, dtype = np.float32) *np.NaN#子= griddata((经度、纬度)、温度(xi, yi)方法=“线性”)我的范围(len(临时):idx = np。argmin (np。√(xi-lon[我])* * 2 + (yi-lat[我])* * 2)子(np)。unravel_index (idx xi.shape)] = temp[我]# - - -检查……7)plt.figure (figsize = (15) plt.subplot plt (1、2、1)。散射(经度、纬度、临时、临时)plt.subplot plt (1、2、2)。pcolor(习,易,np.where(np.isnan(zi),0,zi)) plt.show() # --- Open NetCDF file to write on with nc4.Dataset('test.nc', 'w' , format='NETCDF3_CLASSIC') as ds: # --- Initialize the dimensions of the dataset dim_time = ds.createDimension('time', 0) dim_lat = ds.createDimension('lat', yi.shape[0]) dim_lon = ds.createDimension('lon', xi.shape[1]) # --- Create the corresponding variables for the dimensions time = ds.createVariable('time', np.float32, 'time') latitude = ds.createVariable('lat', np.float32, 'lat') latitude.units = ['degrees north'] latitude.axis = ['Y'] latitude.standard_name = ['latitude'] longitude = ds.createVariable('lon', np.float32, 'lon') longitude.units = ['degrees east'] longitude.axis = ['X'] longitude.standard_name = ['longitude'] # --- Fill with 1D (!) arrays of xi/yi, as the meshgrid returns 2D arrays... time[:] = 0 latitude[:] = yi[:,0] longitude[:] = xi[0,:] # --- Create a coordinate reference system crs = ds.createVariable('WGS84', 'c') crs.spatial_ref = """GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]""" # --- Ready the Temperature data field value = ds.createVariable('temperature', np.float32, ('time','lat','lon')) value.grid_mapping = 'WGS84' # the crs variable name value.grid_mapping_name = 'latitude_longitude' # --- Fill with values value[0,:,:] = zi
增加了198个字符的身体
链接
埃里克
  • 2 k
  • 10
  • 11
进口numpy从scipy.interpolate np进口griddata进口xarray xr进口熊猫一样pd进口rioxarray进口netCDF4 nc4 matplotlib进口。.... pyplot plt # - - -输入数据lat =(50.1, 50.2, 50.3, 50.4, 50.5, 62]朗= (8.1,8.2,8.3,8.4,8.5,12]temp =[1、2、3、4、5、6] # - - -项目输入数据在规则的网格ξ= np.arange(6.0, 14.0, 0.1)易= np.arange(48.0, 64.0, 0.1),易= np。meshgrid (xi, yi)子=np.zeros_like (xi, dtype = np.float32) * -999 #子=griddata((经度、纬度)、温度(xi, yi)方法=“线性”)我的范围(len(临时):idx = np。argmin (np。√(xi-lon[我])* * 2 + (yi-lat[我])* * 2))子(np。unravel_index (idx xi.shape)] = temp[我]# - - -检查……7)plt.figure (figsize = (15) plt.subplot plt (1、2、1)。散射(经度、纬度、临时、临时)plt.subplot plt (1、2、2)。pcolor(习,易,np.where(np.isnan(zi),0,zi)) plt.show() # --- Open NetCDF file to write on with nc4.Dataset('test.nc', 'w' , format='NETCDF3_CLASSIC') as ds: # --- Initialize the dimensions of the dataset dim_time = ds.createDimension('time', 0) dim_lat = ds.createDimension('lat', yi.shape[0]) dim_lon = ds.createDimension('lon', xi.shape[1]) # --- Create the corresponding variables for the dimensions time = ds.createVariable('time', np.float32, 'time') latitude = ds.createVariable('lat', np.float32, 'lat') latitude.units =(“degrees_north”)(“度”)纬度。轴= [Y]纬度。standard_name =[“纬度”]经度= ds。createVariable(经度,np。经度float32,“朗”)。单位=(“degrees_east”)(“度”)经度。轴= [X]经度。standard_name =[经度的]#——充满1 d (!) / yj数组,meshgrid返回二维数组…时间纬度[:][:]= 0 =易[:0]经度[:]= xi(0:) # - - -创建一个坐标参考系统crs = ds.createVariable (“WGS84”,'c') crs.spatial_ref = """GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]""" # --- Ready the Temperature data field value = ds.createVariable('temperature', np.float32, ('time','lat',“朗”)的价值。grid_mapping =“WGS84”# crs变量名称的值。grid_mapping_name = ' latitude_longitude ' #——充满值值0::=子

时,产生一个地标图片加载到QGIS(我减少了你的步长值,使pcolor步骤多一点性能;但是你可以改变它回到您的代码)。在这里输入图像描述

在这里输入图像描述

进口numpy从scipy.interpolate np进口griddata进口xarray xr进口熊猫一样pd进口rioxarray进口netCDF4 nc4 matplotlib进口。.... pyplot plt # - - -输入数据lat =(50.1, 50.2, 50.3, 50.4, 50.5, 62]朗= (8.1,8.2,8.3,8.4,8.5,12]temp =[1、2、3、4、5、6] # - - -项目输入数据在规则的网格ξ= np.arange(6.0, 14.0, 0.1)易= np.arange(48.0, 64.0, 0.1),易= np。meshgrid (xi, yi)子= griddata((经度、纬度)、温度(xi, yi)方法=“线性”)#——检查……7)plt.figure (figsize = (15) plt.subplot plt (1、2、1)。散射(经度、纬度、临时、临时)plt.subplot plt (1、2、2)。pcolor(习,易,np.where(np.isnan(zi),0,zi)) plt.show() # --- Open NetCDF file to write on with nc4.Dataset('test.nc', 'w' , format='NETCDF3_CLASSIC') as ds: # --- Initialize the dimensions of the dataset dim_time = ds.createDimension('time', 0) dim_lat = ds.createDimension('lat', yi.shape[0]) dim_lon = ds.createDimension('lon', xi.shape[1]) # --- Create the corresponding variables for the dimensions time = ds.createVariable('time', np.float32, 'time') latitude = ds.createVariable('lat', np.float32, 'lat') latitude.units =(“degrees_north”)纬度。轴= [Y]纬度。standard_name =[“纬度”]经度= ds。createVariable(经度,np。经度float32,“朗”)。单位=(“degrees_east”)经度。轴= [X]经度。standard_name =[经度的]#——充满1 d (!) / yj数组,meshgrid返回二维数组…时间纬度[:][:]= 0 =易[:0]经度[:]= xi(0:) # - - -创建一个坐标参考系统crs = ds.createVariable (“WGS84”,'c') crs.spatial_ref = """GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]""" # --- Ready the Temperature data field value = ds.createVariable('temperature', np.float32, ('time','lat',“朗”)的价值。grid_mapping =“WGS84”# crs变量名称的值。grid_mapping_name = ' latitude_longitude ' #——充满值值0::=子

时,产生一个地标图片加载到QGIS(我减少了你的步长值,使pcolor步骤多一点性能;但是你可以改变它回到您的代码)。在这里输入图像描述

进口numpy从scipy.interpolate np进口griddata进口xarray xr进口熊猫一样pd进口rioxarray进口netCDF4 nc4 matplotlib进口。.... pyplot plt # - - -输入数据lat =(50.1, 50.2, 50.3, 50.4, 50.5, 62]朗= (8.1,8.2,8.3,8.4,8.5,12]temp =[1、2、3、4、5、6] # - - -项目输入数据在规则的网格ξ= np.arange(6.0, 14.0, 0.1)易= np.arange(48.0, 64.0, 0.1),易= np。meshgrid (xi, yi)子=np.zeros_like (xi, dtype = np.float32) * -999 #子=griddata((经度、纬度)、温度(xi, yi)方法=“线性”)我的范围(len(临时):idx = np。argmin (np。√(xi-lon[我])* * 2 + (yi-lat[我])* * 2))子(np。unravel_index (idx xi.shape)] = temp[我]# - - -检查……7)plt.figure (figsize = (15) plt.subplot plt (1、2、1)。散射(经度、纬度、临时、临时)plt.subplot plt (1、2、2)。pcolor(习,易,np.where(np.isnan(zi),0,zi)) plt.show() # --- Open NetCDF file to write on with nc4.Dataset('test.nc', 'w' , format='NETCDF3_CLASSIC') as ds: # --- Initialize the dimensions of the dataset dim_time = ds.createDimension('time', 0) dim_lat = ds.createDimension('lat', yi.shape[0]) dim_lon = ds.createDimension('lon', xi.shape[1]) # --- Create the corresponding variables for the dimensions time = ds.createVariable('time', np.float32, 'time') latitude = ds.createVariable('lat', np.float32, 'lat') latitude.units =(“度”)纬度。轴= [Y]纬度。standard_name =[“纬度”]经度= ds。createVariable(经度,np。经度float32,“朗”)。单位=(“度”)经度。轴= [X]经度。standard_name =[经度的]#——充满1 d (!) / yj数组,meshgrid返回二维数组…时间纬度[:][:]= 0 =易[:0]经度[:]= xi(0:) # - - -创建一个坐标参考系统crs = ds.createVariable (“WGS84”,'c') crs.spatial_ref = """GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]""" # --- Ready the Temperature data field value = ds.createVariable('temperature', np.float32, ('time','lat','lon')) value.grid_mapping = 'WGS84' # the crs variable name value.grid_mapping_name = 'latitude_longitude' # --- Fill with values value[0,:,:] = zi

时,产生一个地标图片加载到QGIS(我减少了你的步长值,使pcolor步骤多一点性能;但是你可以改变它回到您的代码)。

在这里输入图像描述

链接
埃里克
  • 2 k
  • 10
  • 11
加载
Baidu
map