nakametpy.util module
- nakametpy.util.anom_levels(levs)[source]
Return minus ans plus levels.
- Parameters:
levs (list`or`np.ndarray) –
- Returns:
anom levels
- Return type:
np.ndarray
Examples
>>> levs = [0.5, 1., 2.] >>> print(anom_levels(levs)) [-2. -1. -0.5 0.5 1. 2. ]
- nakametpy.util.check_tar_content(file)[source]
tar ファイルの中身のファイル名を表示する関数
Print the content name of the tar file.
- Parameters:
file (str) – file path ファイルのPATH
- nakametpy.util.concat_array(*arr, sort=True)[source]
Return concatenated array in numpy.ndarray.
- Parameters:
arr (some of list`or`np.ndarray) –
- Returns:
concat_ndarray
- Return type:
np.ndarray
Examples
>>> levs = concat_array(np.arange(0.5, 2., 0.5), np.arange(2., 5.1, 1.)) >>> print(levs) [0.5 1. 1.5 2. 2.5 3. 3.5 4. 4.5 5. ]
- nakametpy.util.dt_ymdhm(date, opt=1)[source]
datetime.datetime から year, month, day, hour, minute の set を返す関数
opt = 1 : string
opt = 0 : int
Return the set of year, month, day, hour, minute from datetime.datetime.
- Parameters:
date (datetime.datetime) – datetime
opt (int) – return string or not
- Returns:
`set`
- Return type:
(year, month, day, hour, minute)
- nakametpy.util.dt_yyyymmdd(date, fmt='yyyymmdd')[source]
datetime.datetime を yyyymmdd 形式の文字列で返す関数
Return yyyymmdd format string from datetime.
- Parameters:
date (datetime.datetime) – datetime
fmt (str) – yyyymmdd format. Default is yyyymmdd
- Returns:
`str`
- Return type:
string in fmt.
Examples
>>> dt = datetime.datetime(2024, 10, 18, 19, 11, 21) >>> dt_yyyymmdd(dt, "hoge-yyyymmdd_HHMMSS.png") "hoge-20241018_191121.png"
- nakametpy.util.get_grib2_latlon(file, tar_flag=False, tar_contentname=None)[source]
気象庁解析雨量やレーダー雨量の緯度/経度を返す関数
欠損値は負の値として表現される. ファイルはgrib2, tar, gz(gzip)を受け付ける
- Parameters:
file (str) –
file path
ファイルのPATH
tar_flag (bool) – file type are GRIB2, tar and gz(gzip).
tar_contentname (str) – content name in tar file.
- Returns:
latlon – (Latitude, Longitude)
- Return type:
set(numpy.ma.MaskedArray, numpy.ma.MaskedArray)
- nakametpy.util.get_jmara_lat(mesh: int = None)[source]
解析雨量の緯度を返す関数
- Parameters:
mesh (int) – resolution in meter.
- Returns:
lat
- Return type:
numpy.ndarray
- nakametpy.util.get_jmara_lon(mesh: int = None)[source]
解析雨量の経度を返す関数
- Parameters:
mesh (int) – resolution in meter.
- Returns:
lon
- Return type:
numpy.ndarray
- nakametpy.util.get_jmarlev_lat()[source]
レーダーエコー頂高度の緯度を返す関数
- Returns:
lat
- Return type:
numpy.ndarray
- nakametpy.util.get_jmarlev_lon()[source]
レーダーエコー頂高度の経度を返す関数
- Returns:
lon
- Return type:
numpy.ndarray
- nakametpy.util.load_jmanowc_grib2(file, tidx=0)[source]
気象庁ナウキャストを返す関数
欠損値は負の値として表現される. ファイルはgrib2.binを受け付ける.
- Parameters:
file (str) –
file path
ファイルのPATH
tidx (int) – tidx x 5 mins forecast.
- Returns:
rain – Units(単位) [mm/h]
- Return type:
numpy.ma.MaskedArray
Note
jma_rain_lat
,jma_rain_lon
はそれぞれ返り値に対応する. np.ndarray 型の緯度/経度である.Examples
>>> nowc_1000 = load_jmanowc_grib2(path_to_file) >>> lon_1000 = get_jmara_lon(1000) # get 1000m mesh longitude array >>> lat_1000 = get_jmara_lat(1000) # get 1000m mesh latitude array >>> >>> plot_1000 = ax.contourf(lon_1000, lat_1000, nowc_1000)
- nakametpy.util.load_jmara250m_grib2(file: str, only250: bool = False)[source]
5分毎250mメッシュ全国合成レーダー降水強度GPVを返す関数
欠損値は負の値として表現される. ファイルはbin, bin.gzを受け付ける. 高解像度ナウキャストにも対応している.
- Parameters:
file (str) –
file path
ファイルのPATH
only250 (bool) –
ignore 1000m mesh or not
1000mメッシュ領域を無視するかどうかのフラグ
- Returns:
rain – Units(単位) [mm/h]
- Return type:
numpy.ma.MaskedArray
Examples
>>> radar_0250, radar_1000 = load_jmara250m_grib2(path_to_file) >>> lon_0250 = get_jmara_lon(250) # get 250m mesh longitude array >>> lat_0250 = get_jmara_lat(250) # get 250m mesh latitude array >>> lon_1000 = get_jmara_lon(1000) # get 1000m mesh longitude array >>> lat_1000 = get_jmara_lat(1000) # get 1000m mesh latitude array >>> >>> plot_1000 = ax.contourf(lon_1000, lat_1000, radar_1000) >>> plot_0250 = ax.contourf(lon_0250, lat_0250, radar_0250)
- nakametpy.util.load_jmara_grib2(file, tar_flag=False, tar_contentname=None)[source]
気象庁解析雨量やレーダー雨量を返す関数
欠損値は負の値として表現される. ファイルはbin, tar, gz(gzip)を受け付ける
- Parameters:
file (str) –
file path
ファイルのPATH
tar_flag (bool) – file type are GRIB2, tar and gz(gzip).
tar_contentname (str) – content name in tar file.
- Returns:
rain – Units(単位) [mm/h]
- Return type:
numpy.ma.MaskedArray
Note
jma_rain_lat
,jma_rain_lon
はそれぞれ返り値に対応する. np.ndarray 型の緯度/経度である.
- nakametpy.util.myglob(path, reverse=False)[source]
Return sorted glob results.
- Parameters:
path (str) –
reverse (bool) –
- Returns:
result_list
- Return type:
list