# run dir rundir = basedir + 'run_' + name + '/' # subdir with diagnostics diagdir = rundir + 'diags/' # location where diag files are saved savedir = basedir + "diag/" + name \ + "/double_track_{:04d}_{:04d}_{:04d}/".format(int(lon), int(lat0), int(lat1)) # create output dir if it doesn't exist yet if start == 1 and not os.path.isdir(savedir): os.mkdir(savedir) # get grid info XC, YC, XG, YG = utils.get_x_y(rundir) DXC, DYC, DXG, DYG = utils.get_dx_dy(rundir) # find index of nearest model point (c, fx, fy) in rotated orientation dist = (XC - lon)**2 + (YC - lat0)**2 dist[np.isnan(dist)] = 999 iy0c, ixc = np.unravel_index(np.argmin(dist), dist.shape) dist = (XC - lon)**2 + (YC - lat1)**2 dist[np.isnan(dist)] = 999 iy1c, ixc = np.unravel_index(np.argmin(dist), dist.shape) # make sure correct location was chosen print XC[iy0c:iy1c + 1, ixc:ixc + 2] print YC[iy0c:iy1c + 1, ixc]
# run dir rundir = basedir + 'run_' + name + '/' # subdir with diagnostics diagdir = rundir + 'diags/' # location where diag files are saved savedir = basedir + "diag/" + name \ + "/mooring_{:04d}_{:04d}/".format(int(lon),int(lat)) # create output dir if it doesn't exist yet if not os.path.isdir(savedir): os.mkdir(savedir) # get grid info XC, YC, XG, YG = utils.get_x_y(rundir, do_rearrange=False) z = rdmds(rundir + "RC")[:, 0, 0] # save diag depths to file np.save(savedir + "depths.npy", z[utils.diag_lev]) # find index of nearest model point (c, fx, fy) in original orientation dist = (XC - lon)**2 + (YC - lat)**2 dist[np.isnan(dist)] = 999 iyc, ixc = np.unravel_index(np.argmin(dist), dist.shape) dist = (XG - lon)**2 + (YC - lat)**2 dist[np.isnan(dist)] = 999 iyfx, ixfx = np.unravel_index(np.argmin(dist), dist.shape)