Skip to content
Snippets Groups Projects
Commit 803f921e authored by Christoph Fischer's avatar Christoph Fischer
Browse files

kitweather run script modes

parent d7731288
No related branches found
No related tags found
No related merge requests found
......@@ -10,11 +10,13 @@ from datetime import timedelta
data_lat = (-35, 35)
data_lon = (-100, 45)
aew_clim_dir = '/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/' #
aew_clim_dir = '/home/iconeps/filter_scripts/aew_script/cv_clim_era5.nc' # '/home/christoph/phd/data/framework_example_ds/aew/' # '/project/meteo/w2w/C3/fischer/belanger/aew_clim/' #
aew_kitweather_ecmwf_dir = '/home/iconeps/ecmwf_data/model_data/ecmwf-hres/forecasts/'
in_files = '/home/christoph/phd/data/aew/cv/2008cv.nc' # '/home/christoph/phd/data/framework_example_ds/aew/cv_aug_08.nc'
out_dir = join(expanduser("~") + '/phd/data/aew/out/') # '/project/meteo/w2w/C3/fischer/belanger/out/'
plot_dir = join(expanduser("~") + '/phd/data/aew/plots/') # '/project/meteo/w2w/C3/fischer/belanger/plots/'
# out_dir = join(expanduser("~") + '/phd/data/aew/out/') # '/project/meteo/w2w/C3/fischer/belanger/out/'
plot_dir = join('/home/iconeps/plots/aew/') # '/project/meteo/w2w/C3/fischer/belanger/plots/'
cv_data_dir = '/project/meteo/w2w/C2/athul/data_athul/AEW_cv_data/' # reference where ALL cv data is (for clim calc.)
cv_data_ex = join(cv_data_dir, '*.nc')
......
......@@ -127,7 +127,7 @@ def plot_track(track, fn):
return figure_name
from collections import defaultdict
def plot_differences(set_graph, tracks, cv=None): # TODO CV too?
def plot_differences(set_graph, tracks, cv=None, plot_prefix=None):
# plot the differences of the total graph and the tracks
# so check which WTs are part of a track and which have been dropped.
......@@ -168,8 +168,13 @@ def plot_differences(set_graph, tracks, cv=None): # TODO CV too?
dates_list = list(dates)
dates_list.sort()
if plot_prefix is None:
plot_prefix = cfg.plot_dir
# create subdirs if needed
os.makedirs(plot_prefix, exist_ok=True)
for date in dates_list:
fig_name = cfg.plot_dir + "part_of_wave_" + date.replace(':', '_') + ".png"
fig_name = plot_prefix + "part_of_wave_" + date.replace(':', '_') + ".png"
cv_ss = cv.sel(time=date)
plot_ts_part_of_track(wts_in_tracks[date], wts_not_in_tracks[date], fig_name, cv_ss)
......
#!/usr/bin/env python
# Usage Example
from enstools.feature.pipeline import FeaturePipeline
from enstools.feature.identification.african_easterly_waves import AEWIdentification
......@@ -8,7 +10,7 @@ from os.path import expanduser, join
from enstools.feature.util.graph import DataGraph
from enstools.feature.identification.african_easterly_waves.plotting import plot_differences, plot_track, plot_track_in_ts, plot_timesteps_from_desc, plot_tracks_from_desc
import enstools.feature.identification.african_easterly_waves.configuration as cfg
import sys
import os, sys
from enstools.feature.util.data_utils import get_subset_by_description
pipeline = FeaturePipeline(african_easterly_waves_pb2, processing_mode='2d')
......@@ -22,11 +24,25 @@ pipeline = FeaturePipeline(african_easterly_waves_pb2, processing_mode='2d')
# if len(sys.argv) > 2:
# proc_month_of_year = int(sys.argv[2])
if len(sys.argv) >= 3 and sys.argv[1] == '-kw':
# TODO kitweather
# only -kw and infer directory from config
# also based on latest timestep?
in_file = sys.argv[2:]
if len(sys.argv) == 3 and sys.argv[1] == '-kw' and sys.argv[2] == 'ecmwf_fc':
# kitweather:
# get latest subdirectory time as what we choose
data_fc_root = cfg.aew_kitweather_ecmwf_dir
all_subdirs = [d[0] for d in os.walk(data_fc_root)]
latest_subdir = max(all_subdirs, key=os.path.getmtime)
# if len([name for name in latest_subdir if os.path.isfile(name)]) < 41: # should have 41 files
# print("Less than 41 files in newest directory " + latest_subdir)
# exit()
in_file = latest_subdir + "/*"
elif len(sys.argv) == 3 and sys.argv[1] == '-kw' and sys.argv[2] == 'ana':
# kitweather: make plots from available cached ecmwf analysis
data_fc_root = cfg.aew_kitweather_ecmwf_dir
in_file = data_fc_root + "*/*000h_tropicalvars.nc"
print("Executing for: " + in_file)
else:
in_file = cfg.in_files
out_dir = cfg.out_dir
......@@ -62,7 +78,13 @@ for trackable_set in od.sets:
ds = pipeline.get_data()
ds_set = get_subset_by_description(ds, trackable_set, '2d')
plot_differences(g, tracks, cv=ds_set.cv)
if len(sys.argv) == 3 and sys.argv[1] == '-kw' and sys.argv[2] == 'ecmwf_fc':
time_dir = os.path.basename(os.path.normpath(latest_subdir))
plot_differences(g, tracks, cv=ds_set.cv, plot_prefix=cfg.plot_dir + time_dir + "/")
elif len(sys.argv) == 3 and sys.argv[1] == '-kw' and sys.argv[2] == 'ana':
plot_differences(g, tracks, cv=ds_set.cv, plot_prefix=cfg.plot_dir + "ana/")
else:
plot_differences(g, tracks, cv=ds_set.cv)
# no out data besides plots on kitweather
if sys.argv[1] == '-kw':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment