Skip to content
Snippets Groups Projects

Revert "Bugfix: Remove outtmp_path, replace with outfile_path (from .env)"

Merged Tor-Einar Skog requested to merge revert-b9aede7d into main
1 file
+ 6
5
Compare changes
  • Side-by-side
  • Inline
+ 6
5
@@ -22,6 +22,7 @@ config.read("NAERSTADMO.cfg")
infile_path = os.getenv("WEATHER_DATA_DIR")
outfile_path = os.getenv("DATA_DIR")
outtmp_path = "out/"
tmpfile_path = "tmp/"
bg_filename = (f'{tmpfile_path}background_data.nc')
@@ -37,7 +38,7 @@ def create_dataset():
# Find the latest file from previous run to create a start date
last_final_date = None
list_of_files = glob.glob(f"{outfile_path}final_2[0-9][0-9][0-9]-[01][0-9]-[0123][0-9].nc", recursive=True)
list_of_files = glob.glob(f"{outtmp_path}final_2[0-9][0-9][0-9]-[01][0-9]-[0123][0-9].nc", recursive=True)
print(list_of_files)
if list_of_files:
latest_file = max(list_of_files,key=os.path.getctime)
@@ -71,7 +72,7 @@ def create_dataset():
subprocess.run(f'cdo -f nc2 mergetime {file} {tmpfile_path}tmpfile.nc {tmpfile_path}weather_data.nc', shell=True)
subprocess.run(f'rm {tmpfile_path}tmpfile.nc',shell=True)
subprocess.run(f'rm {outfile_path}final_*',shell=True)
subprocess.run(f'rm {outtmp_path}final_*',shell=True)
create_saturation()
create_pressure()
@@ -195,10 +196,10 @@ def create_matrix():
subprocess.run(f'cdo -expr,"TSWH=(WHS==0)?0:sumWHTM;IR=(TSWH>=40?1:0);RISK=(IR==1?(TSWH/40)*VRS:0);VRS=(VRS==0?0:VRS);" {tmpfile_path}bg_final_{str(time)}.nc {tmpfile_path}final_{str(date)}_{str(hour)}.nc' , shell=True)
if (str(hour) == '00' or time == 1):
subprocess.run(f'cp {tmpfile_path}final_{str(date)}_{str(hour)}.nc {outfile_path}final_{str(date)}.nc', shell=True)
subprocess.run(f'cp {tmpfile_path}final_{str(date)}_{str(hour)}.nc {outtmp_path}final_{str(date)}.nc', shell=True)
else:
subprocess.run(f'cp {outfile_path}final_{str(date)}.nc {tmpfile_path}tmp_{str(date)}.nc', shell=True)
subprocess.run(f'cdo -O -mergetime {tmpfile_path}tmp_{str(date)}.nc {tmpfile_path}final_{str(date)}_{str(hour)}.nc {outfile_path}final_{str(date)}.nc', shell=True)
subprocess.run(f'cp {outtmp_path}final_{str(date)}.nc {tmpfile_path}tmp_{str(date)}.nc', shell=True)
subprocess.run(f'cdo -O -mergetime {tmpfile_path}tmp_{str(date)}.nc {tmpfile_path}final_{str(date)}_{str(hour)}.nc {outtmp_path}final_{str(date)}.nc', shell=True)
subprocess.run(f'rm {tmpfile_path}tmp_{str(date)}.nc {tmpfile_path}final_{str(date)}_{str(hour)}.nc', shell=True)
# Create last hour values
Loading