From ee128dabf9f98f5576d7fecdc31a801e21fe76d5 Mon Sep 17 00:00:00 2001 From: bbakernoaa Date: Fri, 13 Sep 2024 12:48:17 +0000 Subject: [PATCH] pycodestyle fixes --- parm/prep/aero_emissions.yaml | 16 ++++----- scripts/exglobal_prep_emissions.py | 8 +++-- ush/compare_f90nml.py | 2 +- ush/python/pygfs/task/aero_emissions.py | 8 +++-- ush/python/pygfs/task/analysis.py | 2 +- workflow/rocoto/gfs_tasks.py | 43 +++++++------------------ workflow/rocoto/rocoto.py | 2 +- workflow/rocoto/tasks.py | 10 +++--- 8 files changed, 37 insertions(+), 54 deletions(-) diff --git a/parm/prep/aero_emissions.yaml b/parm/prep/aero_emissions.yaml index da6b7bbc1a5..909b4bd22f4 100644 --- a/parm/prep/aero_emissions.yaml +++ b/parm/prep/aero_emissions.yaml @@ -1,23 +1,23 @@ aero_emissions: config: debug: False - ratio: 0.95 # weighting ratio + ratio: 0.95 # weighting ratio emistype: 'QFED' # EMission Type, Valid answers: 'QFED, GBBEPx, HFED' - climfile_str: 'GBBEPx-all01GRID_v4r0_climMean' # climate file base string used for glob later - GBBEPx_version: 'v4r0' # gbbepx version - qfed_version: '006' # qfed version - species: [ 'so2','oc','bc' ] # species to be used - historical: False # set to true to just use true data for the given day + climfile_str: 'GBBEPx-all01GRID_v4r0_climMean' # climate file base string used for glob later + GBBEPx_version: 'v4r0' # gbbepx version + qfed_version: '006' # qfed version + species: [ 'so2','oc','bc' ] # species to be used + historical: False # set to true to just use true data for the given day data: mkdir: - "{{ DATA }}" - "{{ COMOUT_CHEM_HISTORY }}" - copy: + copy: - ["{{ AERO_INPUTS_DIR }}/nexus/QFED/{{ current_cycle | strftime('%Y/%m') }}/qfed2.emis_oc.006.{{ current_cycle | strftime('%Y%m%d') }}.nc4", "{{ DATA }}/"] - ["{{ AERO_INPUTS_DIR }}/nexus/QFED/{{ current_cycle | strftime('%Y/%m') }}/qfed2.emis_so2.006.{{ current_cycle | strftime('%Y%m%d') }}.nc4", "{{ DATA }}/"] - ["{{ AERO_INPUTS_DIR }}/nexus/QFED/{{ current_cycle | strftime('%Y/%m') }}/qfed2.emis_bc.006.{{ current_cycle | strftime('%Y%m%d') }}.nc4", "{{ DATA }}/"] {% for fdate in forecast_dates %} - - ["{{ AERO_INPUTS_DIR }}/nexus/GBBEPx/v4/climMean/GBBEPx-all01GRID_v4r0_climMean_{{ fdate | strftime('%m%d') }}.nc", "{{ DATA }}/"] # copy climo files + - ["{{ AERO_INPUTS_DIR }}/nexus/GBBEPx/v4/climMean/GBBEPx-all01GRID_v4r0_climMean_{{ fdate | strftime('%m%d') }}.nc", "{{ DATA }}/"] # copy climo files {% endfor %} data_out: copy: diff --git a/scripts/exglobal_prep_emissions.py b/scripts/exglobal_prep_emissions.py index 01d1235dd47..6511bce4f7c 100755 --- a/scripts/exglobal_prep_emissions.py +++ b/scripts/exglobal_prep_emissions.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 -# exglobal_prep_emissions.py -# This script creates a emissions object -# which perform the pre-processing for aerosol emissions + +""" +This script performs the emissions pre-processing for the GFS. +""" + import os from wxflow import Logger, AttrDict, cast_strdict_as_dtypedict diff --git a/ush/compare_f90nml.py b/ush/compare_f90nml.py index f3c5573a927..78a22b10820 100755 --- a/ush/compare_f90nml.py +++ b/ush/compare_f90nml.py @@ -76,7 +76,7 @@ def _print_diffs(diff_dict: Dict) -> None: print(f"{path}:") max_len = len(max(diff_dict[path], key=len)) for kk in diff_dict[path].keys(): - items = diff_dict[path][kk] + # items = diff_dict[path][kk] # This is never used in the code print( f"{kk:>{max_len+2}} : {' | '.join(map(str, diff_dict[path][kk]))}") diff --git a/ush/python/pygfs/task/aero_emissions.py b/ush/python/pygfs/task/aero_emissions.py index 77a3282f302..dfb190900ea 100644 --- a/ush/python/pygfs/task/aero_emissions.py +++ b/ush/python/pygfs/task/aero_emissions.py @@ -1,5 +1,9 @@ #!/usr/bin/env python3 +""" +This module provides functions and classes for working with aero emissions data. +""" + import os from logging import getLogger from typing import Dict, Any, Union @@ -17,7 +21,6 @@ Task, add_to_datetime, to_timedelta, - which, ) logger = getLogger(__name__.split(".")[-1]) @@ -312,7 +315,6 @@ def make_fire_emission( Returns: - list: A list of xarray.Dataset objects representing fire emissions data for each forecast day. """ - import pandas as pd import numpy as np # open fire emission @@ -349,7 +351,7 @@ def make_fire_emission( for v in g.data_vars: if not scale_climo: if tslice > 5: - kk = ratio * dset[v] + (1 - ratio) * climo[v].data[tslice, :, :] + # kk = ratio * dset[v] + (1 - ratio) * climo[v].data[tslice, :, :] dset[v].data = ( ratio * dset[v] + (1 - ratio) * climo[v].data[tslice, :, :] ) diff --git a/ush/python/pygfs/task/analysis.py b/ush/python/pygfs/task/analysis.py index 6f7d3dfc682..0cad58aebe4 100644 --- a/ush/python/pygfs/task/analysis.py +++ b/ush/python/pygfs/task/analysis.py @@ -29,7 +29,7 @@ def __init__(self, config: Dict[str, Any]) -> None: # Store location of GDASApp jinja2 templates self.gdasapp_j2tmpl_dir = os.path.join(self.task_config.PARMgfs, 'gdas') # fix ocnres - self.task_config.OCNRES = f"{self.task_config.OCNRES :03d}" + self.task_config.OCNRES = f"{self.task_config.OCNRES:03d}" def initialize(self) -> None: super().initialize() diff --git a/workflow/rocoto/gfs_tasks.py b/workflow/rocoto/gfs_tasks.py index 589d38bc157..44c60ccb314 100644 --- a/workflow/rocoto/gfs_tasks.py +++ b/workflow/rocoto/gfs_tasks.py @@ -147,7 +147,7 @@ def aerosol_init(self): deps.append(rocoto.add_dependency(dep_dict)) # Calculate offset based on RUN = gfs | gdas - interval = None + interval = 0 if self.run in ['gfs']: interval = self._base['INTERVAL_GFS'] elif self.run in ['gdas']: @@ -155,7 +155,7 @@ def aerosol_init(self): offset = timedelta_to_HMS(-interval) # Files from previous cycle - files = [f'@Y@m@d.@H0000.fv_core.res.nc'] + \ + files = ['@Y@m@d.@H0000.fv_core.res.nc'] + \ [f'@Y@m@d.@H0000.fv_core.res.tile{tile}.nc' for tile in range(1, self.n_tiles + 1)] + \ [f'@Y@m@d.@H0000.fv_tracer.res.tile{tile}.nc' for tile in range(1, self.n_tiles + 1)] @@ -431,27 +431,6 @@ def atmanlfinal(self): task = rocoto.create_task(task_dict) return task - - def prep_emissions(self): - deps = [] - dep_dict = {'type': 'task', 'name': f'stage_ic'} - deps.append(rocoto.add_dependency(dep_dict)) - dependencies = rocoto.create_dependency(dep=deps) - - resources = self.get_resource('prep_emissions') - task_name = 'prep_emissions' - task_dict = {'task_name': task_name, - 'resources': resources, - 'envars': self.envars, - 'cycledef': 'gefs', - 'command': f'{self.HOMEgfs}/jobs/rocoto/prep_emissions.sh', - 'job_name': f'{self.pslot}_{task_name}_@H', - 'log': f'{self.rotdir}/logs/@Y@m@d@H/{task_name}.log', - 'maxtries': '&MAXTRIES;' - } - task = rocoto.create_task(task_dict) - - return task def prepobsaero(self): deps = [] @@ -534,7 +513,7 @@ def aeroanlvar(self): deps = [] dep_dict = { - 'type': 'task', 'name': f'gdasaeroanlgenb', + 'type': 'task', 'name': 'gdasaeroanlgenb', 'offset': f"-{timedelta_to_HMS(self._base['cycle_interval'])}", } deps.append(rocoto.add_dependency(dep_dict)) @@ -635,9 +614,9 @@ def snowanl(self): def esnowrecen(self): deps = [] - dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf","")}prepsnowobs'} + dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf", "")}prepsnowobs'} deps.append(rocoto.add_dependency(dep_dict)) - dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf","")}snowanl'} + dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf", "")}snowanl'} deps.append(rocoto.add_dependency(dep_dict)) dep_dict = {'type': 'metatask', 'name': f'{self.run}epmn', 'offset': f"-{timedelta_to_HMS(self._base['cycle_interval'])}"} deps.append(rocoto.add_dependency(dep_dict)) @@ -897,7 +876,7 @@ def _fcst_forecast_only(self): self.run in self.app_config.aero_fcst_runs and \ not self._base['EXP_WARM_START']: # Calculate offset based on RUN = gfs | gdas - interval = None + interval = 0 if self.run in ['gfs']: interval = self._base['INTERVAL_GFS'] elif self.run in ['gdas']: @@ -2373,7 +2352,7 @@ def cleanup(self): # Start of ensemble tasks def eobs(self): deps = [] - dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf","")}prep'} + dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf", "")}prep'} deps.append(rocoto.add_dependency(dep_dict)) dep_dict = {'type': 'metatask', 'name': 'enkfgdasepmn', 'offset': f"-{timedelta_to_HMS(self._base['cycle_interval'])}"} deps.append(rocoto.add_dependency(dep_dict)) @@ -2483,7 +2462,7 @@ def eupd(self): def atmensanlinit(self): deps = [] - dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf","")}prepatmiodaobs'} + dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf", "")}prepatmiodaobs'} deps.append(rocoto.add_dependency(dep_dict)) dep_dict = {'type': 'metatask', 'name': 'enkfgdasepmn', 'offset': f"-{timedelta_to_HMS(self._base['cycle_interval'])}"} deps.append(rocoto.add_dependency(dep_dict)) @@ -2664,7 +2643,7 @@ def _get_ecengroups(): return grp, dep, lst deps = [] - dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf","")}analcalc'} + dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf", "")}analcalc'} deps.append(rocoto.add_dependency(dep_dict)) if self.app_config.do_jediatmens: dep_dict = {'type': 'task', 'name': f'{self.run}atmensanlfinal'} @@ -2710,7 +2689,7 @@ def esfc(self): # eupd_run = 'gdas' if 'gdas' in self.app_config.eupd_runs else 'gfs' deps = [] - dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf","")}analcalc'} + dep_dict = {'type': 'task', 'name': f'{self.run.replace("enkf", "")}analcalc'} deps.append(rocoto.add_dependency(dep_dict)) if self.app_config.do_jediatmens: dep_dict = {'type': 'task', 'name': f'{self.run}atmensanlfinal'} @@ -2788,7 +2767,7 @@ def echgres(self): self._is_this_a_gdas_task(self.run, 'echgres') deps = [] - dep_dict = {'type': 'metatask', 'name': f'{self.run.replace("enkf","")}fcst'} + dep_dict = {'type': 'metatask', 'name': f'{self.run.replace("enkf", "")}fcst'} deps.append(rocoto.add_dependency(dep_dict)) dep_dict = {'type': 'task', 'name': f'{self.run}fcst_mem001'} deps.append(rocoto.add_dependency(dep_dict)) diff --git a/workflow/rocoto/rocoto.py b/workflow/rocoto/rocoto.py index 2a20820da86..91a90c5d03f 100644 --- a/workflow/rocoto/rocoto.py +++ b/workflow/rocoto/rocoto.py @@ -349,7 +349,7 @@ def _add_sh_tag(dep_dict: Dict[str, Any]) -> str: command = dep_dict.get('command', 'echo "Hello World"') if '@' in command: - offset_string_b = f'' + offset_string_b = '' offset_string_e = '' else: offset_string_b = '' diff --git a/workflow/rocoto/tasks.py b/workflow/rocoto/tasks.py index df2b0467db7..0b8c812983d 100644 --- a/workflow/rocoto/tasks.py +++ b/workflow/rocoto/tasks.py @@ -180,16 +180,16 @@ def get_resource(self, task_name): account = task_config['ACCOUNT'] - walltime = task_config[f'walltime'] - ntasks = task_config[f'ntasks'] - ppn = task_config[f'tasks_per_node'] + walltime = task_config['walltime'] + ntasks = task_config['ntasks'] + ppn = task_config['tasks_per_node'] nodes = int(np.ceil(float(ntasks) / float(ppn))) - threads = task_config[f'threads_per_task'] + threads = task_config['threads_per_task'] # Memory is not required - memory = task_config.get(f'memory', None) + memory = task_config.get('memory', None) if scheduler in ['pbspro']: if task_config.get('prepost', False):