我试图创建下拉菜单加载不同的卫星数据,但是当我嵌入代码,我的代码没有完全显示,但显示笔记本,是的我使用Visual studio代码
进口cartopy。crs cartopy ccr自己进口。从IPython cfeature特性。显示从ipywidgets进口进口显示下拉、交互、固定,选择从matplotlib进口patheffects matplotlib进口。pyplot metpy plt metpy进口。情节导入add_timestamp导入numpy虹吸np。目录导入TDSCatalog def open_dataset(日期、渠道idx、地区):“”“开放和返回一个netCDF数据集对象对于一个给定的日期,频道和图像从THREDDS GOES-16指数数据测试服务器。”““猫= TDSCatalog (' https://thredds.ucar.edu/thredds/catalog/satellite/goes/east/products/ ' f 'CloudAndMoistureImagery /{地区}/通道{频道:02 d} /{日期:Y % m % d %} / catalog.xml”) ds =猫。数据集[idx] ds = ds.remote_access (use_xarray = True)返回ds def plot_GOES16_channel(日期、idx通道、区域):““获取和阴谋是16数据ABI的乐队。”““ds = open_dataset(日期、渠道idx、地区)dat = ds.metpy.parse_cf (Sectorized_CMI)项目= dat.metpy。cartopy_crs x = dat [x] y = dat [y]无花果= plt。图(figsize = (10,10)) ax = fig.add_subplot(1, 1, 1,投影=项目)ax.add_feature (cfeature。海岸线,线宽= 2)ax.add_feature (cfeature。州,线型= ':' edgecolor = '黑色')ax.add_feature (cfeature。边界,线宽= 2,edgecolor = '黑色')ax的im。图片:im.remove () = ax化生。imshow(dat, extent=(x.min(), x.max(), y.min(), y.max()), origin='upper') timestamp = datetime.strptime(ds.start_date_time, '%Y%j%H%M%S') add_timestamp(ax, time=timestamp, high_contrast=True, pretext=f'GOES 16 Ch.{channel} - ', time_format='%d %B %Y %H%MZ', y=0.01, fontsize=18) display(fig) plt.close() channel_list = {u'1 - Blue Band 0.47 \u03BCm': 1, u'2 - Red Band 0.64 \u03BCm': 2, u'3 - Veggie Band 0.86 \u03BCm': 3, u'4 - Cirrus Band 1.37 \u03BCm': 4, u'5 - Snow/Ice Band 1.6 \u03BCm': 5, u'6 - Cloud Particle Size Band 2.2 \u03BCm': 6, u'7 - Shortwave Window Band 3.9 \u03BCm': 7, u'8 - Upper-Level Tropo. WV Band 6.2 \u03BCm': 8, u'9 - Mid-Level Tropo. WV Band 6.9 \u03BCm': 9, u'10 - Low-Level WV Band 7.3 \u03BCm': 10, u'11 - Cloud-Top Phase Band 8.4 \u03BCm': 11, u'12 - Ozone Band 9.6 \u03BCm': 12, u'13 - Clean IR Longwave Band 10.3 \u03BCm': 13, u'14 - IR Longwave Band 11.2 \u03BCm': 14, u'15 - Dirty Longwave Band 12.3 \u03BCm': 15, u'16 - CO2 Longwave IR 13.3 \u03BCm': 16} region = Select( options=['Mesoscale-1', 'Mesoscale-2', 'CONUS', 'PuertoRico', 'FullDisk'], description='Region:', ) channel = Dropdown( options=channel_list, value=9, description='Channel:', ) date = datetime.utcnow() interact(plot_GOES16_channel, date=fixed(date), idx=fixed(-2), channel=channel, region=region)```