Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
LucR31 committed Nov 7, 2023
1 parent dcc9fdf commit 0bc5c6f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
13 changes: 7 additions & 6 deletions aiida_flexpart/workflows/multi_dates_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def define(cls, spec):
help='Dictionary of locations properties.')

#meteo related inputs
spec.input('meteo_inputs', valid_type=orm.Dict,
spec.input('meteo_inputs', valid_type=orm.Dict,required=False,
help='Meteo models input params.')
spec.input('meteo_inputs_offline', valid_type=orm.Dict,required=False,
help='Meteo models input params.')
spec.input('meteo_path', valid_type=orm.RemoteData,
required=True, help='Path to the folder containing the meteorological input data.')
required=False, help='Path to the folder containing the meteorological input data.')
spec.input('meteo_path_offline', valid_type=orm.RemoteData,
required=False, help='Path to the folder containing the meteorological input data.')
spec.input('gribdir', valid_type=orm.Str, required=True)
Expand Down Expand Up @@ -130,17 +130,18 @@ def run_ifs(self):
return True if self.inputs.model in ECMWF_models else False

def run_offline(self):
if self.inputs.model_offline in ECMWF_models and self.inputs.model is not None:
if self.inputs.model_offline in ECMWF_models and self.inputs.model != '':
self.ctx.index-=1
return True
elif self.inputs.model_offline in ECMWF_models and self.inputs.model is None:
elif self.inputs.model_offline in ECMWF_models and self.inputs.model == '':
return True
return False

def setup(self):
"""Prepare a simulation."""

self.report(f'starting setup')
self.report(f'model: {self.inputs.model.value}, model_offline: {self.inputs.model_offline.value}')

self.ctx.index = 0
self.ctx.simulation_dates = self.inputs.simulation_dates
Expand Down Expand Up @@ -261,12 +262,12 @@ def run_ifs_simulation(self):
#changes in the command file
new_dict = self.ctx.command.get_dict()
new_dict['simulation_date'] = self.ctx.simulation_dates[self.ctx.index]

if self.inputs.model_offline in ECMWF_models:
new_dict['age_class'] = self.ctx.offline_integration_time * 3600
new_dict['dumped_particle_data'] = True

if self.inputs.model is not None:
if self.inputs.model != '':
self.ctx.parent_calc_folder = self.ctx.calculations[-1].outputs.remote_folder
self.report(f'starting from: {self.ctx.parent_calc_folder}')
else:
Expand Down
23 changes: 12 additions & 11 deletions examples/example_workflow_combi.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def simulation_dates_parser(date_list: list) -> list:
def test_run(flexpart_code):
"""Run workflow."""

simulation_dates = simulation_dates_parser(['2021-01-07, 2021-01-08'])
model = 'cosmo7'
simulation_dates = simulation_dates_parser(['2021-01-07,2021-01-08'])
model = None
model_offline = 'IFS_GL_05'
username='lfernand'
users_address=f'/users/{username}/resources/flexpart/'
Expand Down Expand Up @@ -98,15 +98,16 @@ def test_run(flexpart_code):
#meteo realted settings
builder.model = orm.Str(model)
builder.model_offline = orm.Str(model_offline)

meteo_path = orm.RemoteData(
remote_path=scratch_address+model+'/',
computer = flexpart_code.computer)
builder.meteo_path = meteo_path
builder.meteo_inputs = orm.Dict(
dict=read_yaml_data('inputs/meteo_inputs.yaml', names=[
model,
])[model])

if model is not None:
meteo_path = orm.RemoteData(
remote_path=scratch_address+model+'/',
computer = flexpart_code.computer)
builder.meteo_path = meteo_path
builder.meteo_inputs = orm.Dict(
dict=read_yaml_data('inputs/meteo_inputs.yaml', names=[
model,
])[model])

if model_offline is not None:
meteo_path_offline = orm.RemoteData(
Expand Down

0 comments on commit 0bc5c6f

Please sign in to comment.