Newer
Older
Christoph Fischer
committed
#!/usr/bin/env python
from os.path import expanduser, join
from datetime import timedelta
import numpy as np
Christoph Fischer
committed
# data area
# latN = 35
# latS = -35
# lonW = -100
# lonE = 45
Christoph Fischer
committed
data_lon = (-100, 45)
aew_clim_dir = '/home/ws/he7273/phd_all/data/aew/clim/cv_clim_era5.nc' # '/project/meteo/w2w/C3/fischer/belanger/aew_clim/cv_clim_era5.nc' # '/lsdf/MOD/Gruppe_Transregio/Gruppe_Knippertz/kitweather/data/era5/cv_clim_era5.nc' 'C:\\Users\\Christoph\\phd\\data\\enstools-feature\\cv_clim_era5.nc' # '/home/christoph/phd/data/aew/clim/cv_clim_era5.nc' # '/home/christoph/phd/data/framework_example_ds/aew/' # '/project/meteo/w2w/C3/fischer/belanger/aew_clim/' #
in_files = '/home/ws/he7273/phd_all/data/coll_oper/jjaso2021.nc' # '/project/meteo/w2w/C3/fischer/data/jja2022.nc' # '/home/ws/he7273/phd_all/data/coll_oper/jja2021/jja2021.nc' # 'C:\\Users\\Christoph\\phd\\data\\enstools-feature\\2008_sum_uv.nc' # '/home/christoph/phd/data/framework_example_ds/aew/cv_aug_08.nc'
out_dir = '/home/ws/he7273/phd_all/data/coll_oper/' # '/project/meteo/w2w/C3/fischer/belanger/out/' # join('/home/ws/he7273/phd_all/data/aew/out/') # '/project/meteo/w2w/C3/fischer/belanger/out/'
out_json_path = out_dir + 'jjaso2021.json'
plot_dir = '/home/ws/he7273/phd_all/data/coll_oper/' # '/project/meteo/w2w/C3/fischer/belanger/plots/' # join('/home/ws/he7273/phd_all/data/aew/plots/') # '/project/meteo/w2w/C3/fischer/belanger/plots/'
timedelta_ana = np.timedelta64(7, 'D')
# aew_kitweather_ecmwf_dir = '/lsdf/MOD/Gruppe_Transregio/Gruppe_Knippertz/kitweather/data/ecmwf-hres/forecasts/'
# num_files_ecmwf = 41 # files in finished forecast data
# file_prefix_ecmwf = 'ecmwf-hres_latlon_1.0deg_'
# file_prefix_ecmwf_rain = 'ecmwf-hres_latlon_0.4deg_'
# aew_kitweather_icon_dir = '/lsdf/MOD/Gruppe_Transregio/Gruppe_Knippertz/kitweather/data/icon-global-det/forecasts/'
# num_files_icon = 31 # files in finished forecast data
# file_prefix_icon = 'icon-global-det_latlon_1.0deg_'
# file_prefix_icon_rain = 'icon-global-det_latlon_0.25deg_'
plot_dir_ecmwf = '/home/iconeps/plots/aew/ecmwf-hres/' # '/project/meteo/w2w/C3/fischer/belanger/plots/'
plot_dir_ecmwf_prefix = 'aew_ecmwf-hres_'
plot_dir_ecmwf_ens = '/home/iconeps/plots/aew/ecmwf-ens/' # '/project/meteo/w2w/C3/fischer/belanger/plots/'
plot_dir_ecmwf_ens_prefix = 'aew_ecmwf-ens_'
plot_dir_icon = '/home/iconeps/plots/aew/icon-global-det/' # '/project/meteo/w2w/C3/fischer/belanger/plots/'
plot_dir_icon_prefix = 'aew_icon-global-det_'
plot_dir_gfs = '/home/iconeps/plots/aew/gfs/'
plot_dir_gfs_prefix = 'aew_gfs_'
plot_dir_gfs_ens = '/home/iconeps/plots/aew/gefs/' # '/project/meteo/w2w/C3/fischer/belanger/plots/'
plot_dir_gfs_ens_prefix = 'aew_gefs_'
ens_rain_threshold = 1.0 # display prob of exceeding X mm hr-1
latest_run_dir = '/home/iconeps/plots/aew/'
latest_run_info_file_name = 'latest_aew_run.txt'
# out_dir = join(expanduser("~") + '/phd/data/aew/out/') # '/project/meteo/w2w/C3/fischer/belanger/out/'
cv_data_dir = '/project/meteo/w2w/C2/athul/data_athul/AEW_cv_data/' # reference where ALL cv data is (only for clim calc.)
cv_data_ex = join(cv_data_dir, '*.nc')
Christoph Fischer
committed
def get_clim_file():
#fn = (aew_clim_dir + "cv_clim_" + str(abs(data_lat[1])) + ('N' if data_lat[1] > 0 else 'S') + "_"
# + str(abs(data_lat[0])) + ('N' if data_lat[0] > 0 else 'S') + "_"
# + str(abs(data_lon[0])) + ('E' if data_lon[0] > 0 else 'W') + "_"
# + str(abs(data_lon[1])) + ('E' if data_lon[1] > 0 else 'W')) + ".nc"
Christoph Fischer
committed
return fn
# wave area to be extracted: at least one point of trough needs to be in this range
wave_filter_lat = (-5, 30) # TODO see bottom method -> more adaptive on lons.
Christoph Fischer
committed
wave_filter_lon = (-110, 55)
Christoph Fischer
committed
# time of interest, if None all
start_date = None # '2022-08-01T00:00' # None # '2008-08-01T00:00' # # '2008-08-01T00:00'
end_date = None # '2022-08-15T00:00' # None # '2008-08-15T00:00' # None # '2008-08-03T00:00'
Christoph Fischer
committed
# Algorithm parameters
# max u wind (m/s) (0 = only keep west-propagating). Belanger: 2.5; Berry: 0.0
max_u_thresh = 0.0 # m/s
# CV anomaly percentile
# NOTE: this is precomputed from the climatology, so delete climatology file and change this after to be re-executed.
cv_percentile = 66 # 66% percentile of PV anomalies as reference on what areas to consider
# need positive 2nd time derivative
second_advection_min_thr = 0.0
### FILTERING
# spatial filtering: if wave to small, discard
# threshold in degrees of wave length (sum of wave segments)
degree_len_thr = 5
Christoph Fischer
committed
### TRACKING
duration_threshold = timedelta(days=2)
# max time allowed between detected waves
max_cmp_delta = timedelta(hours=12)
Christoph Fischer
committed
Christoph.Fischer
committed
# duration of min avg speed
avg_speed_t = timedelta(hours=36)
avg_speed_min_m_per_s = -3 # min abs, so faster than 3 to west
Christoph.Fischer
committed
avg_speed_min_deg_per_h = avg_speed_min_m_per_s * 3.6 * 0.00914
Christoph Fischer
committed
# speed range of AEWs
# at 10°N we have in longitude direction 0.00914 degrees/km (360/(40,000*cos(10deg)))
speed_range_m_per_s = [3.0, 12.0] # [5,10], but be more gentle with polygons.
Christoph Fischer
committed
speed_deg_per_h = [-m_per_s * 3.6 * 0.00914 for m_per_s in speed_range_m_per_s] # negative -> westward [-5, -10]
def is_point_in_area(lon, lat):
if lon < -65:
if 5 < lat < 28:
return True
elif lon < -50:
if 3 < lat < 27:
return True
else:
if 0 < lat < 26:
return True