Commit a18e76c3 authored by renzo's avatar renzo

llamada a telemac aparte

parent d7fcdd9b
import subprocess
import datetime
import os
import metadata
def run_model(source):
if source == "hycom":
os.chdir(metadata.telemac_dir)
for filename in os.listdir(metadata.hycom["output_path"]):
date = filename[:8]
try:
datetime.strptime(date, '%Y%m%d')
if not [dir for dir in os.listdir(metadata.telemac_dir + "/RESULTS") if dir[7:15] == date and "HYCOM_" in dir]:
subprocess.run(metadata.telemac_script + " 'HYCOM' " + date + " " + date + " 1 8", shell=True, check=True)
except:
pass # file is not valid
if __name__ == "__main__":
run_model("hycom")
\ No newline at end of file
......@@ -55,22 +55,8 @@ def process(source, args):
os.chdir(data_dir)
matlab_call = create_matlab_call(script, source, args)
subprocess.run(matlab_call, shell=True, check=True, stderr=sys.stderr, stdout=sys.stdout)
run_model(source)
clean(metadata.tmp_path)
def run_model(source):
if source == "hycom":
os.chdir(metadata.telemac_dir)
for filename in os.listdir(metadata.hycom["output_path"]):
date = filename[:8]
try:
datetime.strptime(date, '%Y%m%d')
if not [dir for dir in os.listdir(metadata.telemac_dir + "/RESULTS") if dir[7:15] == date and "HYCOM_" in dir]:
subprocess.run(metadata.telemac_script + " 'HYCOM' " + date + " " + date + " 1 8", shell=True, check=True)
except:
pass # file is not valid
def clean(root):
delete = []
for path, dirnames, filenames in os.walk(root):
......@@ -91,7 +77,4 @@ def clean(root):
# Remove locks
for filename in os.listdir(root):
if filename[-4:] == "lock" and path.split("/")[-1] in filename:
os.remove(os.path.join(root, filename))
if __name__ == "__main__":
run_model("hycom")
os.remove(os.path.join(root, filename))
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment