Skip to content

Commit

Permalink
pycodestyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bbakernoaa committed Sep 13, 2024
1 parent 819d59d commit ee128da
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 54 deletions.
16 changes: 8 additions & 8 deletions parm/prep/aero_emissions.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
8 changes: 5 additions & 3 deletions scripts/exglobal_prep_emissions.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion ush/compare_f90nml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))}")

Expand Down
8 changes: 5 additions & 3 deletions ush/python/pygfs/task/aero_emissions.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,7 +21,6 @@
Task,
add_to_datetime,
to_timedelta,
which,
)

logger = getLogger(__name__.split(".")[-1])
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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, :, :]
)
Expand Down
2 changes: 1 addition & 1 deletion ush/python/pygfs/task/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
43 changes: 11 additions & 32 deletions workflow/rocoto/gfs_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ 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']:
interval = self._base['INTERVAL']
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)]

Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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']:
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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'}
Expand Down Expand Up @@ -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'}
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion workflow/rocoto/rocoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'<cyclestr>'
offset_string_b = '<cyclestr>'
offset_string_e = '</cyclestr>'
else:
offset_string_b = ''
Expand Down
10 changes: 5 additions & 5 deletions workflow/rocoto/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ee128da

Please sign in to comment.