SCALE-Analysis
Loading...
Searching...
No Matches
Functions | Variables
Amedas Namespace Reference

アメダスデータ取得・描画 More...

Functions

 ll2dist (lat1, lon1, lat2, lon2)
 

Variables

bool savefig = True
 
str dir_out = "./fig/"
 
bool by_target_pos = True
 
float lon0 = 140.1115746
 
float lat0 = 36.0827355
 
bool by_target_name = not by_target_pos
 
str tname = "東京"
 
int year = 2007
 
int month = 7
 
int day = 15
 
str datatype0 = "hourly"
 
str url = 'https://www.data.jma.go.jp/obd/stats/etrn/select/prefecture00.php?prec_no=&block_no=&year=&month=&day=&view='
 
 html = urllib.request.urlopen(url)
 
 soup = BeautifulSoup(html, 'html.parser')
 
 elements = soup.find_all('area')
 
list area_list = [element['alt'] for element in elements]
 
list area_link_list = [element['href'] for element in elements]
 
list total_station_list = []
 
list total_station_link_list = []
 
list total_station_etc_list = []
 
int ind = 0
 
list station_etc_list = []
 
list station_list = []
 
list station_link_list = []
 
list total_station_list_flatten = [tmp1 for tmp2 in total_station_list for tmp1 in tmp2]
 
list total_station_link_list_flatten = [tmp1 for tmp2 in total_station_link_list for tmp1 in tmp2]
 
list total_station_etc_list_flatten = [tmp1 for tmp2 in total_station_etc_list for tmp1 in tmp2]
 
list total_station_type_list_flatten = [etc.split("javascript:viewPoint(")[1].split(",")[0][1] for etc in total_station_etc_list_flatten]
 
list total_station_lat_list_flatten = [float(etc.split("javascript:viewPoint(")[1].split(",")[4][1:-1]) + float(etc.split("javascript:viewPoint(")[1].split(",")[5][1:-1])/60 for etc in total_station_etc_list_flatten]
 
list total_station_lon_list_flatten = [float(etc.split("javascript:viewPoint(")[1].split(",")[6][1:-1]) + float(etc.split("javascript:viewPoint(")[1].split(",")[7][1:-1])/60 for etc in total_station_etc_list_flatten]
 
 stype = np.array(total_station_type_list_flatten)
 
 lat = np.array(total_station_lat_list_flatten)
 
 lon = np.array(total_station_lon_list_flatten)
 
 dist = ll2dist(lat0,lon0,lat,lon)
 
 argmin_dist = np.argmin(dist)
 
 station_index = argmin_dist
 
list station = total_station_list_flatten[station_index]
 
list station_link = total_station_link_list_flatten[station_index]
 
 stype0 = stype[station_index]
 
 lon_target = lon[station_index]
 
 lat_target = lat[station_index]
 
list block_no_str = station_link.split("block_no=")[1].split("&")[0]
 
str datatype = datatype0 + f"_{stype0}1.php?"
 
 fig
 
 ax = axes[1]
 
 figsize
 
 s
 
 table = pd.read_html(url)
 
 df = table[0]
 
 time = df["時"].values[:,0]
 
list jstdatetimelist = [datetime.datetime(year,month,day) + datetime.timedelta(hours=tmp) for tmp in time]
 
list utcdatetimelist = [tmp-datetime.timedelta(hours=9) for tmp in jstdatetimelist]
 
list time_target = jstdatetimelist[0].strftime("%Y-%m-%d ")
 
str varname_j = "降水量 (mm)"
 
str varname = "PREC"
 
str varunit = "(mm)"
 
 prec = df[varname_j].values[:,0]
 
 axes
 
 marker
 
str fnamelabel = f"Amedas_{varname}_{time_target}_lon{lon_target}_lat{lat_target}_{station}"
 

Detailed Description

アメダスデータ取得・描画

指定した水平地点の近くのアメダスデータを取得し時系列を描画

Author
Tomoro Yanase, Team SCALE
Note
Reference

https://www.dpac.dpri.kyoto-u.ac.jp/enomoto/pymetds/index.html

Function Documentation

◆ ll2dist()

ll2dist ( lat1,
lon1,
lat2,
lon2 )

Variable Documentation

◆ area_link_list

list area_link_list = [element['href'] for element in elements]

◆ area_list

list area_list = [element['alt'] for element in elements]

◆ argmin_dist

argmin_dist = np.argmin(dist)

◆ ax

ax = axes[1]

◆ axes

axes

◆ block_no_str

list block_no_str = station_link.split("block_no=")[1].split("&")[0]

◆ by_target_name

bool by_target_name = not by_target_pos

◆ by_target_pos

bool by_target_pos = True

◆ datatype

str datatype = datatype0 + f"_{stype0}1.php?"

◆ datatype0

str datatype0 = "hourly"

◆ day

int day = 15

◆ df

df = table[0]

◆ dir_out

str dir_out = "./fig/"

◆ dist

dist = ll2dist(lat0,lon0,lat,lon)

◆ elements

elements = soup.find_all('area')

◆ fig

fig

◆ figsize

figsize

◆ fnamelabel

str fnamelabel = f"Amedas_{varname}_{time_target}_lon{lon_target}_lat{lat_target}_{station}"

◆ html

html = urllib.request.urlopen(url)

◆ ind

int ind = 0

◆ jstdatetimelist

list jstdatetimelist = [datetime.datetime(year,month,day) + datetime.timedelta(hours=tmp) for tmp in time]

◆ lat

◆ lat0

float lat0 = 36.0827355

◆ lat_target

lat_target = lat[station_index]

◆ lon

◆ lon0

float lon0 = 140.1115746

◆ lon_target

lon_target = lon[station_index]

◆ marker

marker

◆ month

int month = 7

◆ prec

prec = df[varname_j].values[:,0]

◆ s

s

◆ savefig

bool savefig = True

◆ soup

soup = BeautifulSoup(html, 'html.parser')

◆ station

◆ station_etc_list

list station_etc_list = []

◆ station_index

list station_index = argmin_dist

◆ station_link

◆ station_link_list

list station_link_list = []

◆ station_list

list station_list = []

◆ stype

◆ stype0

stype0 = stype[station_index]

◆ table

table = pd.read_html(url)

◆ time

time = df["時"].values[:,0]

◆ time_target

list time_target = jstdatetimelist[0].strftime("%Y-%m-%d ")

◆ tname

str tname = "東京"

◆ total_station_etc_list

list total_station_etc_list = []

◆ total_station_etc_list_flatten

list total_station_etc_list_flatten = [tmp1 for tmp2 in total_station_etc_list for tmp1 in tmp2]

◆ total_station_lat_list_flatten

list total_station_lat_list_flatten = [float(etc.split("javascript:viewPoint(")[1].split(",")[4][1:-1]) + float(etc.split("javascript:viewPoint(")[1].split(",")[5][1:-1])/60 for etc in total_station_etc_list_flatten]

◆ total_station_link_list

list total_station_link_list = []

◆ total_station_link_list_flatten

list total_station_link_list_flatten = [tmp1 for tmp2 in total_station_link_list for tmp1 in tmp2]

◆ total_station_list

list total_station_list = []

◆ total_station_list_flatten

list total_station_list_flatten = [tmp1 for tmp2 in total_station_list for tmp1 in tmp2]

◆ total_station_lon_list_flatten

list total_station_lon_list_flatten = [float(etc.split("javascript:viewPoint(")[1].split(",")[6][1:-1]) + float(etc.split("javascript:viewPoint(")[1].split(",")[7][1:-1])/60 for etc in total_station_etc_list_flatten]

◆ total_station_type_list_flatten

list total_station_type_list_flatten = [etc.split("javascript:viewPoint(")[1].split(",")[0][1] for etc in total_station_etc_list_flatten]

◆ url

str url = 'https://www.data.jma.go.jp/obd/stats/etrn/select/prefecture00.php?prec_no=&block_no=&year=&month=&day=&view='

◆ utcdatetimelist

list utcdatetimelist = [tmp-datetime.timedelta(hours=9) for tmp in jstdatetimelist]

◆ varname

str varname = "PREC"

◆ varname_j

str varname_j = "降水量 (mm)"

◆ varunit

str varunit = "(mm)"

◆ year

int year = 2007