Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #4
0
    yrange=(180, 280))
dst_grd = pyroms.grid.get_ROMS_grid('CCS')

for filein in filelst:
    tag = filein.replace('soda3.3.1_5dy_ocean_reg_', '').replace('.nc', '')
    print('\nBuild OBC file for time %s' % filein)
    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,
Beispiel #5
0
#    lst = commands.getoutput('ls ' + data_dir + 'HYCOM_GLBa0.08_' + year + '*')
    lst = commands.getoutput('ls ' + data_dir + 'HYCOM_GLBa0.08_' + year + '_2*')
#    lst = commands.getoutput('ls ' + data_dir + 'HYCOM_GLBa0.08_' + year + '_0[4-9]*')
    lst = lst.split()
    lst_file = lst_file + lst

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) 
Beispiel #6
0
filelst = subprocess.check_output(['ls', data_dir_year]).replace('/n',' ').split()

src_grd = pyroms_toolbox.BGrid_GFDL.get_nc_BGrid_GFDL(data_dir + 'grid/SODA3_0.5deg_grid.nc', name='SODA3.3.1', xrange=(400, 500), yrange=(180, 280) )
dst_grd = pyroms.grid.get_ROMS_grid('CCS')

for filein in filelst:
    tag=filein.replace('soda3.3.1_5dy_ocean_reg_','').replace('.nc','')
    print '\nBuild OBC file for time %s' %filein
    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
Beispiel #7
0
pyroms.remapping.compute_remap_weights(grid1_file, grid2_file, \
              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)