Commit d7fcdd9b authored by Renzo Marini's avatar Renzo Marini

mend

parent edd03ed8
......@@ -23,6 +23,8 @@ nctoolbox_path = "/home/rmarini2/.matlab/nctoolbox-1.1.3/setup_nctoolbox.m"
matlab_scripts = root_path + "/process/matlab_scripts"
logs_path = root_path + "/logs"
tmp_path = root_path + "/tmp"
telemac_dir = "/export/flyma/PronosticoRPFM/MODELO/PROTOTIPO_01/TELEMAC"
telemac_script = telemac_dir + "/launcher_MESH21_091.sh"
output_root_path = "/export/flyma/PronosticoRPFM/DATOS"
# Debug paths
# root_path = "/home/renzo/Desktop/automatizacion-de-bajadas"
......@@ -67,7 +69,7 @@ shn["message"] = "Se considera un fallo cuando el script intenta descargar los d
+ str(shn["max_tries"]) + " veces, a lo largo de " + str(mins) \
+ " minutos. La pérdida se datos en este script se da cuando falla 7 veces consecutivas. "
anp = {"max_tries": 20, "wait": 1800}
anp = {"max_tries": 2, "wait":1}#20, "wait": 1800}
mins = (anp["wait"] * anp["max_tries"]) / 60
anp["download"] = download_anp
anp["process"] = ["filtro_Uruguay"]
......@@ -108,4 +110,4 @@ copernicus["message"] = "Este mensaje se envía únicamente cuando el script int
current_module = __import__(__name__)
output_dirs = [getattr(current_module, source)["output_path"] for source in sources]
for path in [root_path, matlab_scripts, logs_path, tmp_path] + output_dirs:
Path(path).mkdir(parents=True, exist_ok=True)
\ No newline at end of file
Path(path).mkdir(parents=True, exist_ok=True)
......@@ -61,11 +61,15 @@ def process(source, args):
def run_model(source):
if source == "hycom":
os.chdir(metadata.telemac_dir)
for filename in os.listdir(metadata.hycom["output_path"]):
date = filename[:8]
if not [dir for dir in os.listdir(metadata.telemac_dir) if dir[7:15] == date]:
subprocess.run(metadata.telemac_script + " 'HYCOM' " + date + " " + date + " 1 8", shell=True, check=True)
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 = []
......@@ -87,4 +91,7 @@ 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))
\ No newline at end of file
os.remove(os.path.join(root, filename))
if __name__ == "__main__":
run_model("hycom")
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