siphon:如何获取美国实时雷达三级产品

2024-06-20 18:13:45 浏览数 (1)

前言

本项目基于siphon获取此时美国NEXRAD三级产品以此观测当地天气

什么是NEXRAD

NEXRAD (Next Generation Weather Radar) 是美国国家气象局(National Weather Service)部署的一种先进的天气雷达系统。它的主要用途是监测和预测天气状况,特别是用于检测和跟踪强风暴、降雨和其他大气现象。NEXRAD 系统使用 S 波段雷达技术,能够提供高分辨率的天气数据,以支持天气预报、气象研究和灾害管理等领域。

NEXRAD 雷达站点通过发射雷达波束来扫描天空并接收回波信号,然后利用这些信号生成雷达图像,显示出降雨、雷暴、飓风等天气系统的位置、强度和移动趋势。这些雷达图像可以用于监测降水强度、风暴的结构和演变、雷电活动等信息,对于预警和气象研究非常重要。

NEXRAD 系统在美国境内广泛部署,为气象预报员、气象学家、科学家和公众提供了关键的天气信息,以帮助应对极端天气事件和减轻其对人类和财产的影响。此外,NEXRAD 数据也在全球范围内用于气候研究和天气模型验证等领域。

评论

In [2]:

代码语言:javascript复制
代码语言:javascript复制
from datetime import datetime

import matplotlib.pyplot as plt
import numpy as np

from siphon.cdmr import Dataset
from siphon.radarserver import get_radarserver_datasets, RadarServer
代码语言:javascript复制

In [3]:

代码语言:javascript复制
代码语言:javascript复制
ds = get_radarserver_datasets('http://thredds.ucar.edu/thredds/')
print(list(ds))
代码语言:javascript复制
代码语言:javascript复制
['NEXRAD Level II Radar for Case Study CCS039', 'NEXRAD Level II Radar from IDD', 'NEXRAD Level III Radar for Case Study CCS039', 'NEXRAD Level III Radar from IDD', 'TDWR Level III Radar from IDD']

现在创建一个RadarServer实例,指向相应的 雷达服务器访问URL。这是从目录参考URL中提取的。

In [4]:

代码语言:javascript复制
代码语言:javascript复制
url = ds['NEXRAD Level III Radar from IDD'].follow().catalog_url
rs = RadarServer(url)
代码语言:javascript复制

查看此数据集中可用的变量

In [5]:

代码语言:javascript复制
代码语言:javascript复制
print(rs.variables)
代码语言:javascript复制
代码语言:javascript复制
{'N3U', 'NYK', 'DPR', 'NBQ', 'N0R', 'N2Q', 'NAC', 'NZM', 'NAQ', 'NZU', 'NXB', 'DOD', 'NYX', 'NXU', 'N2K', 'NZH', 'N3X', 'NBM', 'NAX', 'DTA', 'NXH', 'NYQ', 'N1C', 'DVL', 'NYH', 'NZX', 'NVL', 'N3K', 'NBC', 'N1Q', 'N3S', 'N3M', 'N2U', 'NST', 'N1M', 'NBB', 'NXC', 'NXG', 'NZC', 'N1X', 'N2H', 'NVW', 'N0G', 'DSP', 'NZB', 'NXX', 'NAU', 'DU6', 'NYU', 'DPA', 'N1S', 'NBU', 'NZG', 'N1K', 'N1U', 'N0U', 'NAK', 'DHR', 'N0V', 'N0M', 'NAH', 'N2X', 'NXM', 'HHC', 'N3C', 'OHA', 'N1G', 'N0B', 'NBX', 'NXK', 'NYC', 'NYB', 'NZK', 'NTP', 'NAM', 'EET', 'DU3', 'PTA', 'N3B', 'N2S', 'N0K', 'N1B', 'NZQ', 'NCR', 'N0Z', 'N2M', 'NET', 'NYG', 'NBH', 'NXQ', 'DAA', 'N0S', 'N0H', 'N1P', 'DSD', 'N0X', 'N0C', 'NMD', 'NYM', 'NAG', 'NAB', 'N2C', 'N1H', 'N3H', 'N0Q', 'NBK', 'N3Q', 'N2B'}

看看有哪些站点

In [80]:

代码语言:javascript复制
代码语言:javascript复制
rs.stations
代码语言:javascript复制

Out[80]:

代码语言:javascript复制
{'ABC': Station(id='ABC', elevation=49.0, latitude=60.78, longitude=-161.87, name='ANCHORAGE/Bethel'),
 'ABR': Station(id='ABR', elevation=397.0, latitude=45.45, longitude=-98.4, name='ABERDEEN/Aberdeen'),
 'ABX': Station(id='ABX', elevation=1789.0, latitude=35.13, longitude=-106.82, name='ALBUQUERQUE/Albuquerque'),
 'ACG': Station(id='ACG', elevation=63.0, latitude=56.85, longitude=-135.52, name='JUNEAU/Sitka'),
 'AEC': Station(id='AEC', elevation=16.0, latitude=64.5, longitude=-165.28, name='FAIRBANKS/Nome'),
 'AHG': Station(id='AHG', elevation=74.0, latitude=60.72, longitude=-151.35, name='ANCHORAGE/Nikiski'),
 'AIH': Station(id='AIH', elevation=20.0, latitude=59.45, longitude=-146.3, name='ANCHORAGE/Middleton_Island'),
 'AKC': Station(id='AKC', elevation=19.0, latitude=58.67, longitude=-156.62, name='ANCHORAGE/King_Salmon'),
 'AKQ': Station(id='AKQ', elevation=34.0, latitude=36.98, longitude=-77.0, name='WAKEFIELD/Wakefield'),
 'AMA': Station(id='AMA', elevation=1093.0, latitude=35.23, longitude=-101.7, name='AMARILLO/Amarillo'),
 'AMX': Station(id='AMX', elevation=4.0, latitude=25.6, longitude=-80.4, name='MIAMI/Miami'),
 'APD': Station(id='APD', elevation=790.0, latitude=65.03, longitude=-147.5, name='FAIRBANKS/Pedro_Dome'),
 'APX': Station(id='APX', elevation=446.0, latitude=44.9, longitude=-84.72, name='NORTH_CENTRAL_LOWER_MICHIGAN'),
 'ARX': Station(id='ARX', elevation=389.0, latitude=43.82, longitude=-91.18, name='LA_CROSSE/La_Crosse'),
 'ATX': Station(id='ATX', elevation=151.0, latitude=48.18, longitude=-122.48, name='SEATTLE/TACOMA/Camano_Island'),
 'BBX': Station(id='BBX', elevation=53.0, latitude=39.48, longitude=-121.62, name='SACRAMENTO/Oro_Dam_Blvd_West'),
 'BGM': Station(id='BGM', elevation=490.0, latitude=42.18, longitude=-75.98, name='BINGHAMTON/Binghamton'),
 'BHX': Station(id='BHX', elevation=732.0, latitude=40.48, longitude=-124.28, name='EUREKA/Humboldt_County'),
 'BIS': Station(id='BIS', elevation=505.0, latitude=46.77, longitude=-100.75, name='BISMARCK/Bismarck'),
 'BLX': Station(id='BLX', elevation=1097.0, latitude=45.85, longitude=-108.6, name='BILLINGS/Yellowstone_County'),
 'BMX': Station(id='BMX', elevation=197.0, latitude=33.17, longitude=-86.77, name='BIRMINGHAM/Alabaster'),
 'BOX': Station(id='BOX', elevation=36.0, latitude=41.95, longitude=-71.13, name='BOSTON/Taunton'),
 'BRO': Station(id='BRO', elevation=7.0, latitude=25.9, longitude=-97.42, name='BROWNSVILLE/Brownsville'),
 'BUF': Station(id='BUF', elevation=211.0, latitude=42.93, longitude=-78.73, name='BUFFALO/Cheektowaga'),
 'BYX': Station(id='BYX', elevation=2.0, latitude=24.58, longitude=-81.7, name='MIAMI/Boca_Chica_Key'),
 'CAE': Station(id='CAE', elevation=70.0, latitude=33.93, longitude=-81.12, name='COLUMBIA/Columbia'),
 'CBW': Station(id='CBW', elevation=227.0, latitude=46.03, longitude=-67.8, name='PORTLAND/Houlton'),
 'CBX': Station(id='CBX', elevation=933.0, latitude=43.48, longitude=-116.23, name='BOISE/Ada_County'),
 'CCX': Station(id='CCX', elevation=733.0, latitude=40.92, longitude=-78.0, name='CENTRAL_PENNSYLVANIA/Rush'),
 'CLE': Station(id='CLE', elevation=233.0, latitude=41.4, longitude=-81.85, name='CLEVELAND/Cleveland'),
 'CLX': Station(id='CLX', elevation=30.0, latitude=32.65, longitude=-81.03, name='CHARLESTON/Grays'),
 'CRP': Station(id='CRP', elevation=14.0, latitude=27.78, longitude=-97.5, name='CORPUS_CHRISTI/Corpus_Christ'),
 'CXX': Station(id='CXX', elevation=97.0, latitude=44.5, longitude=-73.17, name='BURLINGTON/Colchester'),
 'CYS': Station(id='CYS', elevation=1868.0, latitude=41.15, longitude=-104.8, name='CHEYENNE/Cheyenne'),
 'DAX': Station(id='DAX', elevation=9.0, latitude=38.5, longitude=-121.67, name='SACRAMENTO/Sacramento'),
 'DDC': Station(id='DDC', elevation=789.0, latitude=37.75, longitude=-99.97, name='DODGE_CITY/Dodge_City'),
 'DFX': Station(id='DFX', elevation=345.0, latitude=29.27, longitude=-100.27, name='AUSTIN/SAN_ANTONIO/US_Hwy_90'),
 'DGX': Station(id='DGX', elevation=186.0, latitude=32.17, longitude=-89.59, name='BRANDON/Jackson'),
 'DIX': Station(id='DIX', elevation=45.0, latitude=39.93, longitude=-74.4, name='PHILADELPHIA/Manchester'),
 'DLH': Station(id='DLH', elevation=435.0, latitude=46.83, longitude=-92.2, name='DULUTH/Duluth'),
 'DMX': Station(id='DMX', elevation=299.0, latitude=41.72, longitude=-93.72, name='DES_MOINES/Johnston'),
 'DOX': Station(id='DOX', elevation=15.0, latitude=38.82, longitude=-75.43, name='WAKEFIELD/Ellendale_State_Fo'),
 'DTX': Station(id='DTX', elevation=327.0, latitude=42.68, longitude=-83.47, name='DETROIT/White_Lake'),
 'DVN': Station(id='DVN', elevation=230.0, latitude=41.6, longitude=-90.57, name='QUAD_CITIES/Davenport'),
 'DYX': Station(id='DYX', elevation=462.0, latitude=32.53, longitude=-99.25, name='SAN_ANGELO/Shackelford_Count'),
 'EAX': Station(id='EAX', elevation=303.0, latitude=38.8, longitude=-94.25, name='KANSAS_CITY/PLEASANT_HILL/Pl'),
 'EMX': Station(id='EMX', elevation=1586.0, latitude=31.88, longitude=-110.62, name='TUCSON/Pima_County'),
 'ENX': Station(id='ENX', elevation=557.0, latitude=42.58, longitude=-74.05, name='ALBANY/East_Berne'),
 'EOX': Station(id='EOX', elevation=132.0, latitude=31.45, longitude=-85.45, name='BIRMINGHAM/Fort_Rucker'),
 'EPZ': Station(id='EPZ', elevation=1251.0, latitude=31.87, longitude=-106.68, name='EL_PASO/Santa_Teresa'),
 'ESX': Station(id='ESX', elevation=1483.0, latitude=35.7, longitude=-114.88, name='LAS_VEGAS/Nelson'),
 'EVX': Station(id='EVX', elevation=43.0, latitude=30.55, longitude=-85.92, name='TALLAHASSEE/Eglin_AFB'),
 'EWX': Station(id='EWX', elevation=193.0, latitude=29.7, longitude=-98.02, name='AUSTIN/SAN_ANTONIO/New_Braun'),
 'EYX': Station(id='EYX', elevation=840.0, latitude=35.08, longitude=-117.55, name='LAS_VEGAS/Edwards_AFB'),
 'FCX': Station(id='FCX', elevation=874.0, latitude=37.02, longitude=-80.27, name='ROANOKE/Floyd_County'),
 'FDR': Station(id='FDR', elevation=386.0, latitude=34.35, longitude=-98.97, name='OKLAHOMA_CITY/Altus_AFB'),
 'FDX': Station(id='FDX', elevation=1417.0, latitude=34.63, longitude=-103.62, name='ALBUQUERQUE/State_Rd_89'),
 'FFC': Station(id='FFC', elevation=262.0, latitude=33.35, longitude=-84.55, name='ATLANTA/Peachtree_City'),
 'FSD': Station(id='FSD', elevation=436.0, latitude=43.58, longitude=-96.72, name='SIOUX_FALLS/Sioux_Falls'),
 'FSX': Station(id='FSX', elevation=2261.0, latitude=34.57, longitude=-111.18, name='FLAGSTAFF/Coconino'),
 'FTG': Station(id='FTG', elevation=1675.0, latitude=39.78, longitude=-104.53, name='DENVER/BOULDER/Denver'),
 'FWS': Station(id='FWS', elevation=208.0, latitude=32.57, longitude=-97.3, name='DALLAS/FORT_WORTH/Fort_Worth'),
 'GGW': Station(id='GGW', elevation=694.0, latitude=48.2, longitude=-106.62, name='GLASGOW/Glasgow'),
 'GJX': Station(id='GJX', elevation=3045.0, latitude=39.05, longitude=-108.2, name='GRAND_JUNCTION/Mesa'),
 'GLD': Station(id='GLD', elevation=1113.0, latitude=39.37, longitude=-101.7, name='GOODLAND/Goodland'),
 'GRB': Station(id='GRB', elevation=208.0, latitude=44.48, longitude=-88.1, name='GREEN_BAY/Ashwaubenon'),
 'GRK': Station(id='GRK', elevation=164.0, latitude=30.72, longitude=-97.37, name='DALLAS/FORT_WORTH/Ft_Hood'),
 'GRR': Station(id='GRR', elevation=237.0, latitude=42.88, longitude=-85.53, name='GRAND_RAPIDS/Grand_Rapids'),
 'GSP': Station(id='GSP', elevation=287.0, latitude=34.88, longitude=-82.22, name='GREENVILLE/SPARTANBURG/Greer'),
 'GUA': Station(id='GUA', elevation=80.0, latitude=13.45, longitude=144.8, name='GUAM/Barrigada_Communication'),
 'GWX': Station(id='GWX', elevation=145.0, latitude=33.88, longitude=-88.32, name='MEMPHIS/MS_Hwy_8_and_US_Hwy_27'),
 'GYX': Station(id='GYX', elevation=125.0, latitude=43.88, longitude=-70.25, name='PORTLAND/Gray'),
 'HDX': Station(id='HDX', elevation=1287.0, latitude=33.07, longitude=-106.12, name='EL_PASO/White_Sands_Missile'),
 'HGX': Station(id='HGX', elevation=5.0, latitude=29.47, longitude=-95.07, name='HOUSTON/GALVESTON/Dickinson'),
 'HKI': Station(id='HKI', elevation=55.0, latitude=21.88, longitude=-159.55, name='HONOLULU/Kauai'),
 'HKM': Station(id='HKM', elevation=1162.0, latitude=20.12, longitude=-155.77, name='HONOLULU/Kohala'),
 'HMO': Station(id='HMO', elevation=415.0, latitude=21.12, longitude=-157.17, name='HONOLULU/Molokai'),
 'HNX': Station(id='HNX', elevation=74.0, latitude=36.3, longitude=-119.62, name='SAN_JOAQUIN_VALLEY/Hanford'),
 'HPX': Station(id='HPX', elevation=176.0, latitude=36.73, longitude=-87.28, name='PADUCAH/US_Hwy_41_N'),
 'HTX': Station(id='HTX', elevation=536.0, latitude=34.92, longitude=-86.08, name='BIRMINGHAM/Northeastern_AL'),
 'HWA': Station(id='HWA', elevation=421.0, latitude=19.08, longitude=-155.57, name='HONOLULU/Hawaii'),
 'ICT': Station(id='ICT', elevation=407.0, latitude=37.65, longitude=-97.43, name='WICHITA/Wichita'),
 'ICX': Station(id='ICX', elevation=3231.0, latitude=37.58, longitude=-112.85, name='SALT_LAKE_CITY/Cedar_City'),
 'ILN': Station(id='ILN', elevation=322.0, latitude=39.42, longitude=-83.82, name='CINCINNATI/Wilmington'),
 'ILX': Station(id='ILX', elevation=177.0, latitude=40.15, longitude=-89.33, name='CENTRAL_ILLINOIS/Lincoln'),
 'IND': Station(id='IND', elevation=241.0, latitude=39.7, longitude=-86.27, name='INDIANAPOLIS/Indianapolis'),
 'INX': Station(id='INX', elevation=204.0, latitude=36.17, longitude=-95.55, name='TULSA/Inola'),
 'IWA': Station(id='IWA', elevation=412.0, latitude=33.28, longitude=-111.67, name='PHOENIX/Mesa'),
 'IWX': Station(id='IWX', elevation=293.0, latitude=41.35, longitude=-85.7, name='NORTHERN_INDIANA/North_Webst'),
 'JAX': Station(id='JAX', elevation=10.0, latitude=30.48, longitude=-81.7, name='JACKSONVILLE/Jacksonville'),
 'JGX': Station(id='JGX', elevation=159.0, latitude=32.67, longitude=-83.35, name='ATLANTA/State_Hwy_96'),
 'JKL': Station(id='JKL', elevation=416.0, latitude=37.58, longitude=-83.3, name='JACKSON/Noctor'),
 'JUA': Station(id='JUA', elevation=931.0, latitude=18.12, longitude=-66.08, name='San_Juan/Puerta_Rico'),
 'KJK': Station(id='KJK', elevation=191.0, latitude=35.924, longitude=126.622, name='KOREA/Kunsan AFB'),
 'KSG': Station(id='KSG', elevation=1521.0, latitude=37.207, longitude=127.285, name='KOREA/Camp Humphreys'),
 'LBB': Station(id='LBB', elevation=993.0, latitude=33.65, longitude=-101.8, name='LUBBOCK/Lubbock'),
 'LCH': Station(id='LCH', elevation=4.0, latitude=30.12, longitude=-93.2, name='LAKE_CHARLES/Lake_Charles'),
 'LIX': Station(id='LIX', elevation=7.0, latitude=30.33, longitude=-89.82, name='NEW_ORLEANS/BATON_ROUGE/Slid'),
 'LNX': Station(id='LNX', elevation=905.0, latitude=41.95, longitude=-100.57, name='NORTH_PLATTE/Thedford'),
 'LOT': Station(id='LOT', elevation=202.0, latitude=41.6, longitude=-88.08, name='CHICAGO/Romeoville'),
 'LRX': Station(id='LRX', elevation=2056.0, latitude=40.73, longitude=-116.8, name='ELKO/Lander_County'),
 'LSX': Station(id='LSX', elevation=185.0, latitude=38.68, longitude=-90.67, name='ST._LOUIS/St_Charles'),
 'LTX': Station(id='LTX', elevation=20.0, latitude=33.98, longitude=-78.42, name='WILMINGTON/Shallotte'),
 'LVX': Station(id='LVX', elevation=219.0, latitude=37.97, longitude=-85.93, name='LOUISVILLE/Fort_Knox'),
 'LWX': Station(id='LWX', elevation=83.0, latitude=38.97, longitude=-77.47, name='BALTIMORE/WASH/Sterling'),
 'LZK': Station(id='LZK', elevation=173.0, latitude=34.83, longitude=-92.25, name='LITTLE_ROCK/N_Little_Rock'),
 'MAF': Station(id='MAF', elevation=874.0, latitude=31.93, longitude=-102.18, name='MIDLAND/ODESSA/Midland'),
 'MAX': Station(id='MAX', elevation=2290.0, latitude=42.07, longitude=-122.72, name='MEDFORD/Jackson_County'),
 'MBX': Station(id='MBX', elevation=455.0, latitude=48.38, longitude=-100.85, name='BISMARCK/McHenry_County'),
 'MHX': Station(id='MHX', elevation=9.0, latitude=34.77, longitude=-76.87, name='MOREHEAD_CITY/Newport'),
 'MKX': Station(id='MKX', elevation=292.0, latitude=42.97, longitude=-88.55, name='MILWAUKEE/Dousman'),
 'MLB': Station(id='MLB', elevation=11.0, latitude=28.1, longitude=-80.65, name='MELBOURNE/Melbourne'),
 'MOB': Station(id='MOB', elevation=63.0, latitude=30.67, longitude=-88.23, name='MOBILE/Mobile'),
 'MPX': Station(id='MPX', elevation=288.0, latitude=44.83, longitude=-93.55, name='MINNEAPOLIS/Chanhassen'),
 'MQT': Station(id='MQT', elevation=430.0, latitude=46.52, longitude=-87.53, name='MARQUETTE/Marquette'),
 'MRX': Station(id='MRX', elevation=408.0, latitude=36.17, longitude=-83.4, name='KNOXVILLE/TRI-CITIES/Morrist'),
 'MSX': Station(id='MSX', elevation=2394.0, latitude=47.03, longitude=-113.98, name='MISSOULA/Missoula_County'),
 'MTX': Station(id='MTX', elevation=1969.0, latitude=41.25, longitude=-112.43, name='SALT_LAKE_CITY/Elder_County'),
 'MUX': Station(id='MUX', elevation=1057.0, latitude=37.15, longitude=-121.88, name='SAN_FRANCISCO_BAY_AREA/Santa'),
 'MVX': Station(id='MVX', elevation=301.0, latitude=47.52, longitude=-97.32, name='EASTERN_NORTH_DAKOTA/Mayvill'),
 'MXX': Station(id='MXX', elevation=122.0, latitude=32.53, longitude=-85.78, name='BIRMINGHAM/Maxwell_AFB'),
 'NKX': Station(id='NKX', elevation=291.0, latitude=32.92, longitude=-117.03, name='SAN_DIEGO/San_Diego'),
 'NQA': Station(id='NQA', elevation=86.0, latitude=35.33, longitude=-89.87, name='MEMPHIS/Millington'),
 'OAX': Station(id='OAX', elevation=350.0, latitude=41.32, longitude=-96.37, name='OMAHA/Valley'),
 'ODN': Station(id='ODN', elevation=412.0, latitude=26.308, longitude=127.903, name='JAPAN/Kadena AFB'),
 'OHX': Station(id='OHX', elevation=176.0, latitude=36.23, longitude=-86.55, name='NASHVILLE/Old_Hickory'),
 'OKX': Station(id='OKX', elevation=26.0, latitude=40.85, longitude=-72.85, name='NEW_YORK_CITY/Upton'),
 'OTX': Station(id='OTX', elevation=727.0, latitude=47.67, longitude=-117.62, name='SPOKANE/Spokane'),
 'PAH': Station(id='PAH', elevation=119.0, latitude=37.07, longitude=-88.77, name='PADUCAH/Paducah'),
 'PBZ': Station(id='PBZ', elevation=361.0, latitude=40.52, longitude=-80.22, name='PITTSBURGH/Coraopolis'),
 'PDT': Station(id='PDT', elevation=462.0, latitude=45.68, longitude=-118.85, name='PENDLETON/Pendleton'),
 'POE': Station(id='POE', elevation=124.0, latitude=31.15, longitude=-92.97, name='LAKE_CHARLES/Fort_Polk'),
 'PUX': Station(id='PUX', elevation=1600.0, latitude=38.45, longitude=-104.17, name='PUEBLO/Pueblo_County'),
 'RAX': Station(id='RAX', elevation=106.0, latitude=35.65, longitude=-78.48, name='RALEIGH/DURHAM/Clayton'),
 'RGX': Station(id='RGX', elevation=2530.0, latitude=39.75, longitude=-119.45, name='RENO/Washoe_County'),
 'RIW': Station(id='RIW', elevation=1697.0, latitude=43.05, longitude=-108.47, name='RIVERTON/Riverton'),
 'RLX': Station(id='RLX', elevation=329.0, latitude=38.3, longitude=-81.72, name='CHARLESTON/Ruthdale'),
 'RTX': Station(id='RTX', elevation=479.0, latitude=45.7, longitude=-122.95, name='PORTLAND/Scappoose'),
 'SFX': Station(id='SFX', elevation=1364.0, latitude=43.1, longitude=-112.68, name='POCATELLO/IDAHO_FALLS/Spring'),
 'SGF': Station(id='SGF', elevation=390.0, latitude=37.23, longitude=-93.4, name='SPRINGFIELD/Springfield'),
 'SHV': Station(id='SHV', elevation=83.0, latitude=32.45, longitude=-93.83, name='SHREVEPORT/Shreveport'),
 'SJT': Station(id='SJT', elevation=576.0, latitude=31.37, longitude=-100.48, name='SAN_ANGELO/San_Angelo'),
 'SOX': Station(id='SOX', elevation=923.0, latitude=33.82, longitude=-117.63, name='SAN_DIEGO/Orange_County'),
 'SRX': Station(id='SRX', elevation=195.0, latitude=35.28, longitude=-94.35, name='TULSA/Western_Arkansas'),
 'TBW': Station(id='TBW', elevation=12.0, latitude=27.7, longitude=-82.4, name='TAMPA_BAY_AREA/Ruskin'),
 'TFX': Station(id='TFX', elevation=1132.0, latitude=47.45, longitude=-111.38, name='GREAT_FALLS/Great_Falls'),
 'TLH': Station(id='TLH', elevation=19.0, latitude=30.38, longitude=-84.32, name='TALLAHASSEE/Tallahassee'),
 'TLX': Station(id='TLX', elevation=370.0, latitude=35.32, longitude=-97.27, name='OKLAHOMA_CITY/Norman'),
 'TWX': Station(id='TWX', elevation=417.0, latitude=38.98, longitude=-96.22, name='TOPEKA/Alma'),
 'TYX': Station(id='TYX', elevation=562.0, latitude=43.76, longitude=-75.76, name='MONTAGUE/Fort_Drum'),
 'UDX': Station(id='UDX', elevation=919.0, latitude=44.12, longitude=-102.82, name='RAPID_CITY/New_Underwood'),
 'UEX': Station(id='UEX', elevation=602.0, latitude=40.32, longitude=-98.43, name='HASTINGS/Webster_County'),
 'VAX': Station(id='VAX', elevation=54.0, latitude=30.88, longitude=-83.0, name='TALLAHASSEE/State_Rd_129'),
 'VBX': Station(id='VBX', elevation=373.0, latitude=34.83, longitude=-120.38, name='LOS_ANGELES/Orcutt_Oil_Field'),
 'VNX': Station(id='VNX', elevation=369.0, latitude=36.73, longitude=-98.12, name='OKLAHOMA_CITY/Kegelman_Aux_F'),
 'VTX': Station(id='VTX', elevation=831.0, latitude=34.4, longitude=-119.17, name='LOS_ANGELES/Ventura_County'),
 'VWX': Station(id='VWX', elevation=190.0, latitude=38.27, longitude=-87.72, name='EVANSVILLE/Owensville'),
 'YUX': Station(id='YUX', elevation=53.0, latitude=32.48, longitude=-114.65, name='PHOENIX/Yuma')}

笔者有朋友在波士顿,想要看看那边的天气 波士顿的编号是BOX,于是我们检索那边的雷达

In [92]:

代码语言:javascript复制
query = rs.query()
query.stations('BOX').time(datetime(2024, 2, 18, 10)).variables('N3U')

Out[92]:

代码语言:javascript复制
var=N3U&time=2024-02-18T10:00:00&stn=BOX

In [94]:

代码语言:javascript复制
代码语言:javascript复制
catalog = rs.get_catalog(query)
print(catalog.datasets)
代码语言:javascript复制

我们可以从字典中提取该数据集,并查看可用的访问URL。 我们看到了OPeNDAP、CDMRemote和HTTPServer的URL(直接下载)。

In [96]:

代码语言:javascript复制
代码语言:javascript复制
ds = list(catalog.datasets.values())[0]
print(ds.access_urls)
代码语言:javascript复制
代码语言:javascript复制
{'OPENDAP': 'https://thredds.ucar.edu/thredds/dodsC/nexrad/level3/IDD/N3U/OKX/20240218/Level3_OKX_N3U_20240218_0957.nids', 'HTTPServer': 'https://thredds.ucar.edu/thredds/fileServer/nexrad/level3/IDD/N3U/OKX/20240218/Level3_OKX_N3U_20240218_0957.nids', 'CdmRemote': 'https://thredds.ucar.edu/thredds/cdmremote/nexrad/level3/IDD/N3U/OKX/20240218/Level3_OKX_N3U_20240218_0957.nids'}

我们将在Sipon中使用CDMRemote阅读器,并将其传递给适当的访问URL。

In [122]:

代码语言:javascript复制
代码语言:javascript复制
data = Dataset(ds.access_urls['CdmRemote'])
data
代码语言:javascript复制

Out[122]:

代码语言:javascript复制
https://thredds.ucar.edu/thredds/cdmremote/nexrad/level3/IDD/N3U/OKX/20240218/Level3_OKX_N3U_20240218_0957.nids
Dimensions:
<class 'siphon.cdmr.dataset.Dimension'> name = azimuth, size = 360
<class 'siphon.cdmr.dataset.Dimension'> name = gate, size = 1162
Variables:
<class 'siphon.cdmr.dataset.Variable'>
float32 elevation(azimuth)
	_CoordinateAxisType: RadialElevation
	units: degrees
	long_name: elevation angle in degres: 0 = parallel to pedestal base, 90 = perpendicular
shape = 360
<class 'siphon.cdmr.dataset.Variable'>
float32 azimuth(azimuth)
	_CoordinateAxisType: RadialAzimuth
	units: degrees
	long_name: azimuth angle in degrees: 0 = true north, 90 = east
shape = 360
<class 'siphon.cdmr.dataset.Variable'>
float32 gate(gate)
	_CoordinateAxisType: RadialDistance
	units: meters
	long_name: Radial distance to the start of gate
shape = 1162
<class 'siphon.cdmr.dataset.Variable'>
float32 latitude(azimuth)
	_CoordinateAxisType: Lat
	units: degrees
	long_name: Latitude of the instrument
shape = 360
<class 'siphon.cdmr.dataset.Variable'>
float32 longitude(azimuth)
	_CoordinateAxisType: Lon
	units: degrees
	long_name: Longitude of the instrument
shape = 360
<class 'siphon.cdmr.dataset.Variable'>
float32 altitude(azimuth)
	_CoordinateAxisType: Height
	units: meters
	long_name: Altitude in meters (asl) of the instrument
shape = 360
<class 'siphon.cdmr.dataset.Variable'>
float64 rays_time(azimuth)
	_CoordinateAxisType: Time
	units: milliseconds since 1970-01-01 00:00 UTC
	long_name: rays time
shape = 360
<class 'siphon.cdmr.dataset.Variable'>
uint8 BaseVelocityDV_RAW(azimuth, gate)
	units: m/s
	_CoordinateAxes: elevation azimuth gate rays_time latitude longitude altitude
shape = (360, 1162)
<class 'siphon.cdmr.dataset.Variable'>
float32 BaseVelocityDV(azimuth, gate)
	long_name: HighResolution: Base Velocity
	units: m/s
	_CoordinateAxes: elevation azimuth gate rays_time latitude longitude altitude
shape = (360, 1162)
Attributes:
	title: Nexrad Level 3 Data
	keywords: WSR-88D; NIDS
	creator_name: NOAA/NWS
	creator_url: http://www.ncdc.noaa.gov/oa/radar/radarproducts.html
	naming_authority: NOAA/NCDC
	Divider: -1
	RadarLatitude: 40.865
	RadarLongitude: -72.864
	RadarAltitude: 60.3504
	ProductStation: OKX
	ProductStationName: New York City/Upton,NY,US
	OperationalMode: 1
	VolumeCoveragePatternName: 35
	SequenceNumber: 3215
	VolumeScanNumber: 43
	DateCreated: 2024-02-18T10:04:47Z
	ElevationNumber: 7
	NumberOfMaps: 0
	summary: Nexrad level 3 data are WSR-88D radar products.N3U is a radial image of base velocity field and its range 124 nm
	keywords_vocabulary: N3U
	conventions: _Coordinates
	format: Level3/NIDS
	geospatial_lat_min: 38.79981994628906
	geospatial_lat_max: 42.930179595947266
	geospatial_lon_min: -70.13048553466797
	geospatial_lon_max: -75.59751892089844
	geospatial_vertical_min: 60.350399017333984
	geospatial_vertical_max: 60.350399017333984
	RadarElevationNumber: 31
	time_coverage_start: 2024-02-18T09:57:29Z
	time_coverage_end: 2024-02-18T09:57:29Z
	data_min: 0.0
	data_max: -32682.0
	isRadial: 1
	cdm_data_type: RADIAL

这是一个 Nexrad Level 3 数据,包含以下变量:

  • elevation: 雷达仰角数组,包含 360 个元素,表示每个仰角的角度值。
  • azimuth: 雷达方位角数组,包含 360 个元素,表示每个方位角的角度值。
  • gate: 雷达距离门限数组,包含 1162 个元素,表示每个门限的距离值。
  • latitude: 雷达所在纬度数组,包含 360 个元素,表示每个方位角对应的纬度值。
  • longitude: 雷达所在经度数组,包含 360 个元素,表示每个方位角对应的经度值。
  • altitude: 雷达所在高度数组,包含 360 个元素,表示每个方位角对应的高度值。
  • rays_time: 雷达扫描时间数组,包含 360 个元素,表示每个扫描时刻与 1970 年 1 月 1 日 00:00 UTC 的毫秒数。
  • BaseVelocityDV_RAW: 原始的雷达径向速度数据,是一个 360x1162 的二维数组。
  • BaseVelocityDV: 经过处理后的雷达径向速度数据,是一个 360x1162 的二维数组。

该数据还包含以下属性:

  • title: 数据标题为 Nexrad Level 3 Data。
  • keywords: 关键词包括 WSR-88D 和 NIDS。
  • creator_name: 创建者为美国国家气象局(NOAA)和国家气象服务局(NWS)。
  • creator_url: 创建者网站为 http://www.ncdc.noaa.gov/oa/radar/radarproducts.html。
  • naming_authority: 命名机构为 NOAA/NCDC。
  • Divider: 分隔符为 -1。
  • RadarLatitude: 雷达的纬度为 40.865 度。
  • RadarLongitude: 雷达的经度为 -72.864 度。
  • RadarAltitude: 雷达的高度为 60.3504 米。
  • ProductStation: 产品站点为 OKX。
  • ProductStationName: 产品站点名称为 New York City/Upton,NY,US。
  • OperationalMode: 运行模式为 1。
  • VolumeCoveragePatternName: 体扫模式名称为 35。
  • SequenceNumber: 序列号为 3215。
  • VolumeScanNumber: 体扫序号为 43。
  • DateCreated: 数据创建日期为 2024 年 2 月 18 日 10:04:47 UTC。
  • ElevationNumber: 仰角编号为 7。
  • NumberOfMaps: 地图数量为 0。
  • summary: 数据摘要为 Nexrad Level 3 数据是 WSR-88D 雷达产品,N3U 是反射率强度图像,其范围为 124 英里。
  • keywords_vocabulary: 关键词词汇为 N3U。
  • conventions: 数据遵循 _Coordinates 约定。
  • format: 数据格式为 Level3/NIDS。
  • geospatial_lat_min: 数据覆盖的最小纬度为 38.79981994628906 度。
  • geospatial_lat_max: 数据覆盖的最大纬度为 42.930179595947266 度。
  • geospatial_lon_min: 数据覆盖的最小经度为 -70.13048553466797 度。
  • geospatial_lon_max: 数据覆盖的最大经度为 -75.59751892089844 度。
  • geospatial_vertical_min: 数据覆盖的最小垂直高度为 60.350399017333984 米。
  • geospatial_vertical_max: 数据覆盖的最大垂直高度为 60.350399017333984 米。
  • RadarElevationNumber: 雷达仰角编号为 31。
  • time_coverage_start: 数据开始时间为 2024 年 2 月 18 日 09:57:29 UTC。
  • time_coverage_end: 数据结束时间为 2024 年 2 月 18 日 09:57:29 UTC。
  • data_min: 数据最小值为 -32682.0。
  • data_max: 数据最大值为 0.0。
  • isRadial: 是否是雷达径向数据,此处取值为 1。
  • cdm_data_type: 数据类型为 RADIAL。

CDMRemote阅读器提供了一个与通常的python几乎相同的接口 NetCDF接口。我们提取出方位角和距离所需的变量,以及 数据本身。

In [99]:

代码语言:javascript复制
代码语言:javascript复制
rng = data.variables['gate'][:] / 1000.
az = data.variables['azimuth'][:]
ref = data.variables['BaseVelocityDV'][:]
代码语言:javascript复制

然后将极坐标转换为笛卡尔坐标

In [100]:

代码语言:javascript复制
代码语言:javascript复制
x = rng * np.sin(np.deg2rad(az))[:, None]
y = rng * np.cos(np.deg2rad(az))[:, None]
ref = np.ma.array(ref, mask=np.isnan(ref))
代码语言:javascript复制

绘图

In [121]:

代码语言:javascript复制
代码语言:javascript复制
%matplotlib inline
import matplotlib.pyplot as plt
import cartopy
import cartopy.feature as cfeature
from metpy.plots import ctables  # For NWS colortable

# Create projection centered on the radar. This allows us to use x
# and y relative to the radar.
proj = cartopy.crs.LambertConformal(central_longitude=data.RadarLongitude,
                                    central_latitude=data.RadarLatitude)

# New figure with specified projection
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(1, 1, 1, projection=proj)

ax.add_feature(cfeature.STATES.with_scale('50m'), linewidth=2)

# Get the NWS typical reflectivity color table, along with an appropriate norm that
# starts at 5 dBz and has steps in 5 dBz increments
norm, cmap = ctables.registry.get_with_steps('NWSReflectivity', 5, 5)
mesh = ax.pcolormesh(x, y, ref, cmap=cmap, norm=norm, zorder=0)

# Add title
plt.title('Radar Reflectivity')
# Add colorbar
cb = plt.colorbar(mesh, ax=ax, orientation='vertical', pad=0.05)
cb.set_label('Reflectivity (dBz)')

# Set x and y labels
ax.set_xlabel('Longitude')
ax.set_ylabel('Latitude')

# Add gridlines
ax.gridlines(draw_labels=True)

# Adjust font size
plt.rcParams['font.size'] = 12

# Convert the time to text and add as the title
time = data.variables["rays_time"][:][0] / 1000.
title = datetime.fromtimestamp(time).isoformat()
ax.set_title(title)
plt.show()
代码语言:javascript复制
代码语言:javascript复制
/opt/conda/lib/python3.9/site-packages/cartopy/mpl/geoaxes.py:1781: UserWarning: The input coordinates to pcolormesh are interpreted as cell centers, but are not monotonically increasing or decreasing. This may lead to incorrectly calculated cell edges, in which case, please supply explicit cell edges to pcolormesh.
  result = super().pcolormesh(*args, **kwargs)

此时的波士顿万里晴空 注意事项

  1. 不是所有城市所有产品都可以实时获取,如获取的list为空列表请换城市
  2. 作图还可继续优化,例如叠加地形或山体阴影,手头没有美国的地形数据,还请读者自行测试 可参考总集篇!三种山体阴影绘制方法

0 人点赞