python绘制地图地图cartopy_Python:如何在Cartopy地图上的特定点绘制散点图?

# Function that plots the time series and the data series from a .mat data file# (in the dB-direction based on the out-variable), that is associated with the observatory code (based on the sta-variable)# It also takes an optional argument 'showdatapoints' so its possible to show data points mainly for debuggingdefplotdata_stations(filename,sta,out,start,stop,*args):# Makes the function use one of the three columns (and thus directions of field) in the data series based on inputifout=='radial':dat=0elifout=='theta':dat=1elifout=='phi':dat=2# If the user inputs something else than one of these three, it returns an error and a hint to resolve the errorelse:print('\nError: Component '+"'"+out+"'"+' not recognized...')print('\nHint: Try using '+"'"+'radial'+"', "+"'"+'theta'+"' or "+"'"+'phi'+"'.")# Try to load file in case the file does not existtry:nam=DataLoad(filename,'obs_all')# If the file does not exist, it returns an error and a hint to resolve the errorexcept:print('\nError: File '+"'"+filename+"'"+' not recognized...')print('\nHint: Try putting your file in the same folder as this script.')# If the observatory code is not in the data file, it returns an error and a hint to resolve the errorifstanotinnamandsta!='all':print('\nError: Observatory Code '+"'"+sta+"'"+' not recognized...')print('\nHint: Try using an Observatory Code from the Observatory Locations map.')# Load data from specific station and direction of fielddat=dB_stations(filename,sta,dat)tim=t_stations(filename,sta)# If start is a string but not 'min' and stop is a string but not 'max', print errorif(isinstance(start,str)==Trueandstart!='min')or(isinstance(stop,str)==Trueandstop!='max'):print('\nError: Time range is out of bounds in regards to data set...')print('\nHint: Try using a time range that is included in data set or use '+"'"+'max'+"'"+' or '+"'"+'min'+"'.")# Set start and stop to min or max of time series of min or max is chosenifstart=='min':start=min(tim)ifstop=='max':stop=max(tim)# Print error if time range is out of bounds in regards to the data setifstartmax(tim):print('\nError: Time range is out of bounds in regards to data set...')print('\nHint: Try using a time range that is included in data set or use '+"'"+'max'+"'"+' or '+"'"+'min'+"'.")# Get all data associated with station in the specific time rangendat=[]ntim=[]forxinrange(0,len(tim)):ifstart<=tim[x]<=stop:ndat.append(dat[x])ntim.append(tim[x])# Sets up the data plot and shows itplt.figure(figsize=(9,5))plt.scatter(ntim,ndat,marker='.')plt.title('Observatory Data from '+sta+' in the dB_'+out+'-direction')plt.xlabel('Years')plt.ylabel('nT/yr')plt.show()# For optional argumentsforxinargs:# If the optional argument 'showdatapoints' is called it will print the data points bellow the plotifx=='showdatapoints':print('\nData series [nT/yr] in the dB_'+out+'-direction = \n')print(dB_stations(filename,sta,dat))print('\nTime series [Years] = \n')print(t_stations(filename,sta))# If the user inputs something else than 'showdatapoints', it returns an error and a hint to resolve the errorelse:print('\nError: Optional argument '+"'"+x+"'"+' not recognized...')print('\nHint: Try using '+"'"+'showdatapoints'+"' or deleting the argument.")

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值