Commit 63477d5f authored by Modellers Operational's avatar Modellers Operational

Add hindcast file app

parent aab6d7a7
#!/bin/bash
ncks -d time,0,23 /data/sthenno1/scratch/modop/Model/FVCOM_rosa/output/2020-05-07/aqua_v16_0001.nc temp.nc
ncks --ppc default=4 temp.nc aqua_v16_2020-05-06.nc
mv aqua_v16_2020-05-06.nc /data/sthenno1/scratch/modop/Model/FVCOM_rosa/output/recent_archive//aqua_v16_2020-05-06.nc
rm temp.nc
import numpy as np
import datetime as dt
import sys
import PyFVCOM as pf
file_to_archive = sys.argv[1]
fvcom_grid_name = sys.argv[2]
archive_dir = sys.argv[3]
hindcast_days = int(sys.argv[4])
with open('make_daily_nc.sh', 'w') as f:
f.write('#!/bin/bash \n')
this_fr = pf.read.FileReader(file_to_archive)
first_date = this_fr.time.datetime[0]
time_ind = [0, np.argwhere(this_fr.time.datetime == this_fr.time.datetime[0] + dt.timedelta(hours=(24*hindcast_days)-1))]
this_out_filestr = '{}_{}.nc'.format(fvcom_grid_name, this_fr.time.datetime[0].strftime('%Y-%m-%d'))
this_archive_filestr = '{}/{}'.format(archive_dir, this_out_filestr)
with open('make_daily_nc.sh', 'a') as f:
f.write('ncks -d time,{},{} {} temp.nc \n'.format(np.squeeze(time_ind[0]), np.squeeze(time_ind[1]), file_to_archive))
f.write('ncks --ppc default=4 temp.nc {} \n'.format(this_out_filestr))
f.write('mv {} {}\n'.format(this_out_filestr, this_archive_filestr))
f.write('rm temp.nc \n')
[command]
default = FILE_TO_ARCHIVE=/${ARCHIVE_DIR}/${ARCHIVE_DATE}/${GRID_NAME}_0001.nc
TEMP_ARCHIVE=/${ARCHIVE_DIR}/recent_archive/
python3 make_ncks_script.py ${FILE_TO_ARCHIVE} ${GRID_NAME} ${TEMP_ARCHIVE} ${HINDCAST_DAYS}
bash ./make_daily_nc.sh
ln -s ${ARCHIVE_DIR}/${FORECAST_DAY}/${GRID_NAME}_0001.nc ${TEMP_ARCHIVE}/${GRID_NAME}_${START_DAY}.nc
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