Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove .nc files found in OUTPUT_DIR depending on config file #710

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/output_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import glob
import io
import shutil
import yaml
from src import util, verify_links

import logging
Expand Down Expand Up @@ -264,6 +265,23 @@
for f in util.find_files(self.WORK_DIR, 'model/netCDF/*.nc'):
os.remove(f)

def cleanup_pp_data(self):
"""Removes nc files found in catalog if the ``save_pp_data`` data
is set to false.

This is done by looping through the ``case_info.yml`` file found in each
POD. If the .nc file exists, it is then deleted.
"""
if not self.save_nc:
for f in util.find_files(self.WORK_DIR, 'case_info.yml'):
case_info_yml = yaml.safe_load(open(f))
Dismissed Show dismissed Hide dismissed
for case in case_info_yml['CASE_LIST']:
for k in case_info_yml['CASE_LIST'][case]:
if k.endswith('FILE') or k.endswith('FILES'):
v = case_info_yml['CASE_LIST'][case][k]
if v != '' and os.path.exists(v) and v.endswith('.nc'):
os.remove(v)

def make_output(self, config: util.NameSpace):
"""Top-level method to make POD-specific output, post-init. Split off
into its own method to make subclassing easier.
Expand All @@ -281,6 +299,7 @@
self.convert_pod_figures(os.path.join('model', 'PS'), 'model')
self.convert_pod_figures(os.path.join('obs', 'PS'), 'obs')
self.cleanup_pod_files()
self.cleanup_pp_data()


class HTMLOutputManager(AbstractOutputManager,
Expand Down
Loading