import re
import os
import pandas as pd
import subprocess
start_date = pd.DatetimeIndex(["2016-03-29"])[0]
end_date = pd.DatetimeIndex(["2016-04-18"])[0]
atmospheric_source_dir = "/results/forcing/atmospheric/GEM2.5/operational/"
open_bounds_source_dir = "orcinus:/home/sallen/MEOPAR/NEMO-forcing/open_boundaries/west/ssh/"
rivers_source_dir = "/results/forcing/rivers/"
atmospheric_dest_dir = "jasper:/home/jpetrie/MEOPAR/NEMO-forcing/atmospheric/"
open_bounds_dest_dir = "jasper:/home/jpetrie/MEOPAR/NEMO-forcing/open_boundaries/west/ssh/"
rivers_dest_dir = "jasper:/home/jpetrie/MEOPAR/NEMO-forcing/rivers/"
def numStrLength2(num):
if(num < 10):
return("0" + str(num))
else:
return(str(num))
def toFileDateFormat(dt_date):
return("y" + str(dt_date.year) + "m" + numStrLength2(dt_date.month) + "d" + numStrLength2(dt_date.day))
def copyRiver(src_dir, dest_dir, date_str):
rfce_file = "RFraserCElse_" + date_str + ".nc"
rlfce_file = "RLonFraCElse_" + date_str + ".nc"
files = [rfce_file, rlfce_file]
for f in files:
src = src_dir + f
subprocess.check_call(["scp", src, dest_dir])
def copyAtmospheric(src_dir, dest_dir, date_str):
ops_file = "ops_" + date_str + ".nc"
src = src_dir + ops_file
subprocess.check_call(["scp", src, dest_dir])
def copyOpenBounds(src_dir, dest_dir, date_str):
ssh_file = "ssh_" + date_str + ".nc"
src = src_dir + ssh_file
subprocess.check_call(["scp", src, dest_dir])
current_date = start_date
while(current_date <= end_date):
date_str = toFileDateFormat(current_date)
try:
copyRiver(rivers_source_dir, rivers_dest_dir, date_str)
copyAtmospheric(atmospheric_source_dir, atmospheric_dest_dir, date_str)
copyOpenBounds(open_bounds_source_dir, open_bounds_dest_dir, date_str)
print("Copied files for: " + date_str)
except Exception as e:
print("Couldn't copy files for: " + date_str)
print(e)
current_date = current_date + pd.Timedelta(days = 1)
print("Done")
Copied files for: y2016m03d29 Copied files for: y2016m03d30 Copied files for: y2016m03d31 Copied files for: y2016m04d01 Copied files for: y2016m04d02 Copied files for: y2016m04d03 Copied files for: y2016m04d04 Copied files for: y2016m04d05 Copied files for: y2016m04d06 Copied files for: y2016m04d07 Copied files for: y2016m04d08 Copied files for: y2016m04d09 Copied files for: y2016m04d10 Copied files for: y2016m04d11 Copied files for: y2016m04d12 Copied files for: y2016m04d13 Copied files for: y2016m04d14 Copied files for: y2016m04d15 Copied files for: y2016m04d16 Copied files for: y2016m04d17 Copied files for: y2016m04d18