You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.9 KiB

import os
# Tools
from utils.tools import make_dir
# Paths
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SAVE_DIR = "/tmp/grib/" # don't forget to create it!
MAX_FORECAST_HOUR = 5 # 0-384 beware, each file is 500mb
# Base URL
GFS_BASE_URL = "https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs"
# Globals with variable names and comments how to get them
"""
has_height_attr_names = {
"V-component of wind", #1
"U-component of wind", #1
"Temperature", #4
"Relative humidity", #5
"Pressure reduced to MSL", #7
}
surface_attr_names = {
"Wind speed (gust)", #2
"Total precipitation", #3
"Visibility", # 6
}
level_type_names = {
"Specified height level above ground (m)",
"Mean sea level (Pa)"
}
grib_names = []
for v in ds_atmos:
if ds_atmos[v].attrs["long_name"] in surface_attr_names:
print("{}, {}, {}".format(v,
ds_atmos[v].attrs["long_name"],
ds_atmos[v].attrs["units"]))
grib_names.append(v)
if "level_type" not in ds_atmos[v].attrs:
continue
if ds_atmos[v].attrs["level_type"] not in level_type_names:
continue
if ds_atmos[v].attrs["long_name"] in has_height_attr_names:
print("{}, {}, {}".format(v,
ds_atmos[v].attrs["long_name"],
ds_atmos[v].attrs["units"]))
grib_names.append(v)
height_param_names = {}
for name in grib_names:
non_coord_params = [a for a in ds_atmos[name].dims if a != "lat_0" and a != "lon_0"]
if len(non_coord_params) > 0:
height_param, = non_coord_params
print(name, height_param)
height_param_names[name] = height_param
atmos_param_names = [name for name in grib_names if name not in height_param_names]
surface_attr_names = {
"Significant height of combined wind waves and swell", #8
"Significant height of wind waves", #8
"Significant height of swell waves", #8
"Direction of wind waves", #9
"Direction of Swell Waves", #9
"Mean period of swell waves", #10
"Mean period of wind waves", #10
}
grib_names = []
for v in ds_wave:
if ds_wave[v].attrs["long_name"] in surface_attr_names:
print("{}, {}, {}".format(v,
ds_wave[v].attrs["long_name"],
ds_wave[v].attrs["units"]))
grib_names.append(v)
"""
HEIGHT_PARAM_NAMES = {
"UGRD_P0_L103_GLL0": "lv_HTGL7", # 1
"VGRD_P0_L103_GLL0": "lv_HTGL7", # 1
"TMP_P0_L103_GLL0": "lv_HTGL2", # 4
}
ATMOS_PARAM_NAMES = [
"GUST_P0_L1_GLL0", # 2
"APCP_P8_L1_GLL0_acc", # 3 # only appears after 000 h
"RH_P0_L103_GLL0", # 5
"VIS_P0_L1_GLL0", # 6
"PRMSL_P0_L101_GLL0", # 7
]
WIND_HEIGHT = 10.0
TEMPERATURE_HEIGHT = 2.0
WAVE_PARAM_NAMES = [
"HTSGW_P0_L1_GLL0", # 8
"WVHGT_P0_L1_GLL0", # 8
"SWDIR_P0_L241_GLL0", # 9
"WVDIR_P0_L1_GLL0", # 9
"WVPER_P0_L1_GLL0", # 10
"SWPER_P0_L241_GLL0", # 10
]