import scipy.optimize as op import gsw import os from scipy.interpolate import griddata from scipy.integrate import cumtrapz import scipy.signal as sig import sandwell import emapex import plotting_functions as pf try: print("Floats {} and {} exist!.".format(E76.floatID, E77.floatID)) except NameError: E76 = emapex.load(4976) E77 = emapex.load(4977) plot_dir = '../figures/large_wave_analysis' ftype = 'png' bwr = plt.get_cmap('bwr') bwr1 = mcolors.LinearSegmentedColormap.from_list(name='red_white_blue', colors=[(0, 0, 1), (1, 1, 1), (1, 0, 0)], N=40) def my_savefig(fid, fname): fname = str(fid) + '_' + fname fname = os.path.join(plot_dir, fname) + '.' + ftype
fsdir = '../figures/all_fit_specs' if not os.path.exists(fsdir): os.makedirs(fsdir) psdir = '../processed_data/' if not os.path.exists(psdir): os.makedirs(psdir) # Universal figure font size. matplotlib.rc('font', **{'size': 8}) parser = argparse.ArgumentParser(description='Run w fitting on a float.') parser.add_argument('--floatID', type=int, help='EM-APEX float ID number') args = parser.parse_args() Float = emapex.load(args.floatID, apply_w=False, apply_strain=False, apply_iso=False, verbose=False) # %% Test # Ballast information provided to me by James Girton was contain in a matlab # file called float_ballast.m. I have converted it into a dictionary and # converted the unit of mass (last two columns) to kg from g. ballast_info = { 1632: [1, 1000., 5.102, 34.878, 31., 2.72e-6, 1.156, 27.885, 0.], 1633: [1, 1000., 5.102, 34.878, 31., 2.72e-6, 1.156, 28.008, 0.], 1634: [1, 1000., 5.102, 34.878, 31., 2.72e-6, 1.156, 27.948, 0.], 1635: [1, 1000., 5.102, 34.878, 31., 2.72e-6, 1.156, 27.964, 0.], 1636: [1, 1000., 5.102, 34.878, 31., 2.72e-6, 1.156, 27.948, 0.], 3304: [1, 1500., 3.0, 34.6, 16., 3.67e-6, 1.156, 26.988, 0.],
# Figure save path. sdir = os.path.join('..', 'figures', 'vertical_velocity_analysis') if not os.path.exists(sdir): os.makedirs(sdir) # Universal figure font size. matplotlib.rc('font', **{'size': 9}) ############################################################################### try: print("Floats {} and {} exist!".format(E76.floatID, E77.floatID)) except NameError: E76 = emapex.load(4976, apply_w=False) E77 = emapex.load(4977, apply_w=False) # %% ########################################################################## #cf_key = 'diffsq' #params0 = np.array([3e-2, 5e-2, 3e-6, 4e+2, 1e-6, 16., 27.179]) #fixed = [None, None, None, None, None, None, None] #wfi = vvf.fitter(E76, params0, fixed, model=model, profiles='all', # cf_key=cf_key) #E76.apply_w_model(wfi) #vvf.assess_w_fit(E76, str(E76.floatID)) #print(E76.__wfi.p) # #cf_key = 'diffsq' #params0 = np.array([3e-2, 5e-2, 3e-6, 4e+2, 1e-6, 16., 27.179])
om = gw.omega(N, k, m, l, f) p = gw.phi(x, y, z, t, phi_0, k, l, m, om, U=U, V=V, phase_0=phase_0) return pscale*p def full_model(params, data): return np.hstack((u_model(params, data), v_model(params, data), w_model(params, data), b_model(params, data), p_model(params, data))) Float = emapex.load(args.floatID) Float.calculate_pressure_perturbation() time, z = Float.get_timeseries([args.hpid], 'z') timeef, U = Float.get_timeseries([args.hpid], 'U_abs') __, V = Float.get_timeseries([args.hpid], 'V_abs') __, W = Float.get_timeseries([args.hpid], 'Ww') __, B = Float.get_timeseries([args.hpid], 'b') __, N2 = Float.get_timeseries([args.hpid], 'N2_ref') __, x = Float.get_timeseries([args.hpid], 'x_ctd') __, y = Float.get_timeseries([args.hpid], 'y_ctd') __, PP = Float.get_timeseries([args.hpid], 'Pprime') # Correct for sign error in pp for downward profiles with large aspect # ratio. w is proxy for aspect. if (np.max(np.abs(W)) > 0.05) and (args.hpid % 2 != 0.):