Esempio n. 1
0
def do_file(file):
    zeta = remap_bdry(file, 'ssh', src_grd, dst_grd, dst_dir=dst_dir)
    dst_grd2 = pyroms.grid.get_ROMS_grid('ARCTIC2', zeta=zeta)
    remap_bdry(file, 'temp', src_grd, dst_grd2, dst_dir=dst_dir)
    remap_bdry(file, 'salt', src_grd, dst_grd2, dst_dir=dst_dir)
#    pdb.set_trace()
    remap_bdry_uv(file, src_grd, dst_grd2, dst_dir=dst_dir)

    # merge file
    bdry_file = dst_dir + file.rsplit('/')[-1][:-3] + '_bdry_' + dst_grd.name + '.nc'

    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_ssh_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-O', out_file, bdry_file) 
    subprocess.check_call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_temp_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file) 
    subprocess.check_call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_salt_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file) 
    subprocess.check_call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_u_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file) 
    subprocess.check_call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_v_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file) 
    subprocess.check_call(command)
    os.remove(out_file)
Esempio n. 2
0
def do_file(file, src_grd, dst_grd):
    zeta = remap_bdry(file, 'ssh', src_grd, dst_grd, dst_dir=dst_dir)
    dst_grd = pyroms.grid.get_ROMS_grid('GOM_Copernicus', zeta=zeta)
    remap_bdry(file, 'temp', src_grd, dst_grd, dst_dir=dst_dir)
    remap_bdry(file, 'salt', src_grd, dst_grd, dst_dir=dst_dir)
    #    pdb.set_trace()
    remap_bdry_uv(file, src_grd, dst_grd, dst_dir=dst_dir)
Esempio n. 3
0
def do_file(file, src_grd, dst_grd):
    dst_dir='./SODA/'

    zeta = remap_bdry(file, 'ssh', src_grd, dst_grd, dst_dir=dst_dir)
    dst_grd = pycnal.grid.get_ROMS_grid('ARCTIC2', zeta=zeta)
    remap_bdry(file, 'temp', src_grd, dst_grd, dst_dir=dst_dir)
    remap_bdry(file, 'salt', src_grd, dst_grd, dst_dir=dst_dir)
    remap_bdry_uv(file, src_grd, dst_grd, dst_dir=dst_dir)

    # merge file
    bdry_file = dst_dir + file.rsplit('/')[-1][:-4] + '_bdry_' + dst_grd.name + '.nc'

    out_file = dst_dir + file.rsplit('/')[-1][:-4] + '_ssh_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-O', out_file, bdry_file) 
#    subprocess.check_call(command)
    subprocess.call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-4] + '_temp_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file) 
#    subprocess.check_call(command)
    subprocess.call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-4] + '_salt_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file) 
#    subprocess.check_call(command)
    subprocess.call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-4] + '_u_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file) 
#    subprocess.check_call(command)
    subprocess.call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-4] + '_v_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file) 
#    subprocess.check_call(command)
    subprocess.call(command)
    os.remove(out_file)
Esempio n. 4
0
    # regrid temp, salt and velocities
    remap_bdry('temp',
               data_dir_year + filein,
               src_grd,
               dst_grd,
               temp_dst_file,
               dst_dir=dst_dir)
    remap_bdry('salt',
               data_dir_year + filein,
               src_grd,
               dst_grd,
               salt_dst_file,
               dst_dir=dst_dir)
    remap_bdry_uv(data_dir_year + filein,
                  src_grd,
                  dst_grd,
                  u_dst_file,
                  v_dst_file,
                  dst_dir=dst_dir)

    # merge file
    bdry_file = dst_dir + dst_grd.name + '_bdry_' + tag + '_' + src_grd.name + '.nc'

    command1 = 'mv ' + zeta_dst_file + ' ' + bdry_file
    command2 = 'ncks -A ' + temp_dst_file + ' -o ' + bdry_file
    command3 = 'ncks -A ' + salt_dst_file + ' -o ' + bdry_file
    command4 = 'ncks -A ' + u_dst_file + ' -o ' + bdry_file
    command5 = 'ncks -A ' + v_dst_file + ' -o ' + bdry_file

    subprocess.call(command1, shell=True)
    subprocess.call(command2, shell=True)
    subprocess.call(command3, shell=True)
Esempio n. 5
0
print 'Build OBC file from the following file list:'
print lst_file
print ' '

src_grd_file = data_dir + '../HYCOM_GLBa0.08_North_grid2.nc'
src_grd = pyroms_toolbox.Grid_HYCOM.get_nc_Grid_HYCOM(src_grd_file)
dst_grd = pyroms.grid.get_ROMS_grid('ARCTIC2')

for file in lst_file:
    zeta = remap_bdry(file, 'ssh', src_grd, dst_grd, dst_dir=dst_dir)
    dst_grd = pyroms.grid.get_ROMS_grid('ARCTIC2', zeta=zeta)
    remap_bdry(file, 'temp', src_grd, dst_grd, dst_dir=dst_dir)
    remap_bdry(file, 'salt', src_grd, dst_grd, dst_dir=dst_dir)
#    pdb.set_trace()
    remap_bdry_uv(file, src_grd, dst_grd, dst_dir=dst_dir)

    # merge file
    bdry_file = dst_dir + file.rsplit('/')[-1][:-3] + '_bdry_' + dst_grd.name + '.nc'

    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_ssh_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-O', out_file, bdry_file) 
    subprocess.check_call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_temp_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file) 
    subprocess.check_call(command)
    os.remove(out_file)
    out_file = dst_dir + file.rsplit('/')[-1][:-3] + '_salt_bdry_' + dst_grd.name + '.nc'
    command = ('ncks', '-a', '-A', out_file, bdry_file) 
    subprocess.check_call(command)
Esempio n. 6
0
    zeta_dst_file = dst_dir + dst_grd.name + '_bdry_zeta_' + tag + '_' + src_grd.name + '.nc'
    temp_dst_file = dst_dir + dst_grd.name + '_bdry_temp_' + tag + '_' + src_grd.name + '.nc'
    salt_dst_file = dst_dir + dst_grd.name + '_bdry_salt_' + tag + '_' + src_grd.name + '.nc'
    u_dst_file    = dst_dir + dst_grd.name + '_bdry_u_'    + tag + '_' + src_grd.name + '.nc'
    v_dst_file    = dst_dir + dst_grd.name + '_bdry_v_'    + tag + '_' + src_grd.name + '.nc'

    # remap ssh
    zeta = remap_bdry('ssh', data_dir_year + filein, src_grd, dst_grd, zeta_dst_file, dst_dir=dst_dir)

    # reload grid with zeta (more accurate)
    dst_grd = pyroms.grid.get_ROMS_grid('CCS', zeta=zeta)

    # regrid temp, salt and velocities
    remap_bdry('temp',data_dir_year + filein, src_grd, dst_grd, temp_dst_file, dst_dir=dst_dir)
    remap_bdry('salt',data_dir_year + filein, src_grd, dst_grd, salt_dst_file, dst_dir=dst_dir)
    remap_bdry_uv(data_dir_year + filein, src_grd, dst_grd, u_dst_file, v_dst_file, dst_dir=dst_dir)

    # merge file
    bdry_file = dst_dir + dst_grd.name + '_bdry_' + tag + '_' + src_grd.name + '.nc'

    command1 = 'mv '      + zeta_dst_file + ' '    + bdry_file
    command2 = 'ncks -A ' + temp_dst_file + ' -o ' + bdry_file
    command3 = 'ncks -A ' + salt_dst_file + ' -o ' + bdry_file
    command4 = 'ncks -A ' + u_dst_file    + ' -o ' + bdry_file
    command5 = 'ncks -A ' + v_dst_file    + ' -o ' + bdry_file

    subprocess.call(command1,shell=True)
    subprocess.call(command2,shell=True)
    subprocess.call(command3,shell=True)
    subprocess.call(command4,shell=True)
    subprocess.call(command5,shell=True)
Esempio n. 7
0
    # regrid temp, salt and velocities
    remap_bdry('temp',
               filein,
               src_grd,
               dst_grd,
               temp_dst_file,
               dst_dir=dst_dir)
    remap_bdry('salt',
               filein,
               src_grd,
               dst_grd,
               salt_dst_file,
               dst_dir=dst_dir)
    remap_bdry_uv(filein,
                  src_grd,
                  dst_grd,
                  u_dst_file,
                  v_dst_file,
                  dst_dir=dst_dir)

    # merge file
    bdry_file = dst_dir + dst_grd.name + '_bdry_' + tag + '_' + src_grd.name + '.nc'

    command1 = 'mv ' + zeta_dst_file + ' ' + bdry_file
    command2 = 'ncks -A ' + temp_dst_file + ' -o ' + bdry_file
    command3 = 'ncks -A ' + salt_dst_file + ' -o ' + bdry_file
    command4 = 'ncks -A ' + u_dst_file + ' -o ' + bdry_file
    command5 = 'ncks -A ' + v_dst_file + ' -o ' + bdry_file

    subprocess.call(command1, shell=True)
    subprocess.call(command2, shell=True)
    subprocess.call(command3, shell=True)
Esempio n. 8
0
              interp_file1, interp_file2, map1_name, \
              map2_name, num_maps, map_method)

# load the grid
src_grd = get_nc_Grid_HYCOM(src_grd_file)
dst_grd = pyroms.grid.get_ROMS_grid(grid_name)

# Triggering of variables remapping

#zero=731;l_time=735
zero = 731
l_time = 831  #l_time=1827

remap_bdry(zero, l_time, file, 'votemper', src_grd, dst_grd, grid_name)
remap_bdry(zero, l_time, file, 'vosaline', src_grd, dst_grd, grid_name)
remap_bdry_uv(zero, l_time, file, src_grd, dst_grd, grid_name)
#####remap_bdry_uv_zeros(zero,l_time, file,  src_grd, dst_grd, grid_name)
remap_bdry(zero, l_time, file, 'ssh', src_grd, dst_grd, grid_name)

#For merging of files you have to install nco library: sudo aptitude install nco

# merge file
ic_file = '/home/eivanov/coawst_data_prrocessing/Temporal/Input_files_to_ROMS/Boundary_ParentRiver_100_days.nc'

out_file = 'votemper_bdry.nc'
command = ('ncks', '-a', '-A', out_file, ic_file)
subprocess.check_call(command)
os.remove(out_file)

out_file = 'vosaline_bdry.nc'
command = ('ncks', '-a', '-A', out_file, ic_file)