Skip to content

Commit

Permalink
Delegate to pantry the generation of the eccodes target file name pat…
Browse files Browse the repository at this point in the history
…tern. refs: #42
  • Loading branch information
spanezz committed Dec 6, 2021
1 parent 49404c9 commit f05f1b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions arkimapslib/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ def generate(self, pantry: "pantry.DiskPantry"):
grib_filter_rules = os.path.join(pantry.data_root, f"{self.pantry_basename}.grib_filter_rules")
with open(grib_filter_rules, "wt") as fd:
print('print "s:[year],[month],[day],[hour],[minute],[second],[endStep]";', file=fd)
print(f'write "{pantry.data_root}/{self.pantry_basename}'
'_[year]_[month]_[day]_[hour]_[minute]_[second]+[endStep].grib";', file=fd)
print(f'write "{pantry.get_eccodes_fullname(self)}";', file=fd)

# We could pipe the output of vg6d_transform directly into grib_filter,
# but grib_filter errors in case of empty input with the same exit code
Expand Down
6 changes: 4 additions & 2 deletions arkimapslib/pantry.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def get_input_file(self, inp: "inputs.Input", instant: "inputs.Instant", fmt="gr
"""
return inputs.InputFile(self.get_fullname(inp, instant, fmt=fmt), inp, instant)

def get_eccodes_fullname(self, inp: "inputs.Input", fmt="grib") -> str:
return f"{self.data_root}/{inp.pantry_basename}_[year]_[month]_[day]_[hour]_[minute]_[second]+[endStep].{fmt}"

def get_instants(self, input_name: str) -> Dict[Optional[inputs.Instant], "inputs.InputFile"]:
"""
Return the instants available in the pantry for the input with the given
Expand Down Expand Up @@ -308,8 +311,7 @@ def fill(self, path: Optional[str] = None):
print(f"if ( {eccodes} ) {{", file=f)
print(f' print "s:{inp.model or ""},{inp.name},'
'[year],[month],[day],[hour],[minute],[second],[endStep]";', file=f)
print(f' write "{self.data_root}/{inp.pantry_basename}'
'_[year]_[month]_[day]_[hour]_[minute]_[second]+[endStep].grib";', file=f)
print(f' write "{self.get_eccodes_fullname(inp)}";', file=f)
print("}", file=f)

if self.grib_input:
Expand Down

0 comments on commit f05f1b2

Please sign in to comment.