diff --git a/ush/plotObsMon.py b/ush/plotObsMon.py index d806837..0f8def7 100755 --- a/ush/plotObsMon.py +++ b/ush/plotObsMon.py @@ -9,12 +9,15 @@ from re import sub import yaml from om_data import OM_data +import datetime as dt from wxflow import parse_j2yaml, save_as_yaml from wxflow import add_to_datetime, to_timedelta, to_datetime from eva.eva_driver import eva from eva.utilities.logger import Logger +from datetime import timedelta +# -------------------------------------------------------------------------------------------- def genYaml(input_yaml, output_yaml, config): """ @@ -179,9 +182,10 @@ def loadConfig(satname, instrument, obstype, plot, cycle_tm, cycle_interval, instrument = inst.get('name') for plot in inst.get('plot_list'): + logger.info(f'plot: {plot}') + config = loadConfig(satname, instrument, obstype, plot, cycle_tm, cycle_interval, data_location, model, chan_dict) - plot_template = f"{config['PLOT_TEMPLATE']}.yaml" plot_yaml = f"{config['SENSOR']}_{config['SAT']}_{plot_template}" @@ -195,11 +199,17 @@ def loadConfig(satname, instrument, obstype, plot, cycle_tm, cycle_interval, os.chdir(plot_dir) config['DATA'] = plot_dir - genYaml(plot_template, plot_yaml, config) + try: + genYaml(plot_template, plot_yaml, config) + + plotData = OM_data(data_location, config, plot_yaml, logger) + eva(plot_yaml) +# os.remove(plot_yaml) - plotData = OM_data(data_location, config, plot_yaml, logger) - eva(plot_yaml) - os.remove(plot_yaml) + except Exception as e: + logger.info(f'Warning: unable to run genYaml() with plot_yaml file {plot_yaml} ' + + f'error: {e}') + continue if 'minimization' in mon_dict.keys(): satname = None diff --git a/ush/splitPlotYaml.py b/ush/splitPlotYaml.py index 67fe847..4d63dd0 100644 --- a/ush/splitPlotYaml.py +++ b/ush/splitPlotYaml.py @@ -29,6 +29,40 @@ def removeKey(d, keys): return r +def check_plotlist(type, logger, plot_list, sat=None, instr=None): + """ + """ + logger.info(f'--> check_plotlist') + sat_reqs = {'rad': ['plot', 'times', 'channels', 'component', 'run'], + 'ozn': ['plot', 'times', 'levels', 'component', 'run']} + + rtn_val = True + missing = [] + match type: + case 'sat': + if 'rad' in plot_list.get('plot'): + reqs = sat_reqs.get('rad') + else: + reqs = sat_reqs.get('ozn') + + for val in reqs: + if val not in plot_list: + missing.append(val) + plot_str = (f" {instr} {sat} {plot_list.get('plot')}") + +# case 'min': +# case 'obs': +# cast _: + + if missing: + logger.info(f'WARNING: YAML for plot {plot_str} is missing {missing}') + logger.info(f'WARNING: Requested plot will be SKIPPED.') + rtn_val = False + + return (rtn_val) + logger.info(f'<-- check_plotlist') + + if __name__ == "__main__": """ splitPlotYaml @@ -71,6 +105,7 @@ def removeKey(d, keys): data = mon_dict.get('data') if 'satellites' in mon_dict.keys(): + logger.info(f' split_plot, in satellites') sd = removeKey(mon_dict, ['minimization', 'observations']) for sat in mon_dict.get('satellites'): @@ -79,14 +114,19 @@ def removeKey(d, keys): for inst in sat.get('instruments'): iname = inst.get('name') plist = inst.get('plot_list') + for pl in inst.get('plot_list'): + if not check_plotlist('sat', logger, pl, sat=satname, instr=iname): + continue # -------------------------------------------------------------------- # For instruments with a large number of channels split the plot_list # channels = chan_dict.get(iname) + logger.info(f' channels: {channels}') nchans = 0 if channels is not None: nchans = len(channels.split(",")) + logger.info(f' nchans: {nchans}') if nchans > 100: ctr = 0 @@ -114,6 +154,11 @@ def removeKey(d, keys): if 'minimization' in mon_dict.keys(): md = removeKey(mon_dict, ['satellites', 'observations']) fname = f'OM_PLOT_minimization.yaml' + mm = md.get('minimization') + logger.info(f'mm: {mm}') + for m in mm.get('plot_list'): + logger.info(f'm: {m}') + file = open(fname, "w") yaml.dump(md, file) file.close()