Skip to content

Commit

Permalink
Modified cosmo plugin, model lists added (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucR31 authored Dec 20, 2023
1 parent 6fc6a55 commit 6a6725f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
23 changes: 10 additions & 13 deletions aiida_flexpart/calculations/flexpart_cosmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def define(cls, spec):
help='Input file for the Lagrangian particle dispersion model FLEXPART. Nested output grid.'
)
spec.input('species', valid_type=orm.RemoteData, required=True)
spec.input('meteo_path', valid_type=orm.RemoteData,
spec.input('meteo_path', valid_type=orm.List,
required=True, help='Path to the folder containing the meteorological input data.')
spec.input('metadata.options.output_filename', valid_type=str, default='aiida.out', required=True)
spec.input_namespace('land_use', valid_type=orm.RemoteData, required=False, dynamic=True, help='#TODO')
Expand All @@ -62,22 +62,22 @@ def define(cls, spec):
@classmethod
def _deal_with_time(cls, command_dict):
"""Dealing with simulation times."""

#initial values
simulation_beginning_date = datetime.datetime.strptime(command_dict.pop('simulation_date'),'%Y-%m-%d %H:%M:%S')
age_class_time = datetime.timedelta(seconds=command_dict.pop('age_class'))
release_chunk = datetime.timedelta(seconds=command_dict.pop('release_chunk'))
release_duration = datetime.timedelta(seconds=command_dict.pop('release_duration'))

#releases start and end times
release_beginning_date=simulation_beginning_date
release_ending_date=release_beginning_date+release_duration

if command_dict['simulation_direction']>0: #forward
simulation_ending_date=release_ending_date+age_class_time
else: #backward
simulation_ending_date=release_ending_date
simulation_beginning_date-=age_class_time
simulation_ending_date=release_ending_date
simulation_beginning_date-=age_class_time

command_dict['simulation_beginning_date'] = [
f'{simulation_beginning_date:%Y%m%d}',
Expand All @@ -101,16 +101,13 @@ def prepare_for_submission(self, folder): # pylint: disable=too-many-locals
needed by the calculation.
:return: `aiida.common.datastructures.CalcInfo` instance
"""
meteo_string_list = ['./','./']
for path in self.inputs.meteo_path:
meteo_string_list.append(f'{path}{os.sep}')
meteo_string_list.append(f'{path}/AVAILABLE')

meteo_path = pathlib.Path(self.inputs.meteo_path.get_remote_path())
codeinfo = datastructures.CodeInfo()
codeinfo.cmdline_params = [
'./', # Folder containing the inputs.
'./', # Folder containing the outputs.
f'{meteo_path}{os.sep}',
str(meteo_path / 'AVAILABLE'),
# File that lists all the individual input files that are available and assigns them a date
]
codeinfo.cmdline_params = meteo_string_list
codeinfo.code_uuid = self.inputs.code.uuid
codeinfo.stdout_name = self.metadata.options.output_filename
codeinfo.withmpi = self.inputs.metadata.options.withmpi
Expand Down
12 changes: 5 additions & 7 deletions aiida_flexpart/parsers/flexpart_cosmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@ def parse(self, **kwargs):
files_retrieved, files_expected))
return self.exit_codes.ERROR_MISSING_OUTPUT_FILES

# check aiida.out content
# add output file
self.logger.info(f"Parsing '{output_filename}'")
with self.retrieved.open(output_filename, 'r') as handle:
content=handle.read()
output_node = SinglefileData(file=handle)
self.out('output_file', output_node)
content = handle.read()
if 'CONGRATULATIONS' not in content:
return ExitCode(1)
# add output file
self.logger.info("Parsing '{}'".format(output_filename))
with self.retrieved.open(output_filename, 'rb') as handle:
output_node = SinglefileData(file=handle)
self.out('output_file', output_node)

return ExitCode(0)

0 comments on commit 6a6725f

Please sign in to comment.