dt_list_hr = timelib.dt_range(dt1, dt2, dt_int) dt_list_hr_o = timelib.dt2o(dt_list_hr) dt_list_hr_mat = [timelib.dt2mat(dt) for dt in dt_list_hr] print "Running tide model for %i timestamps" % len(dt_list_hr_mat) tide_a_hr = matlab.tmd_tide_pred('%s' % model, dt_list_hr_mat, lat, lon, 'z') print "Writing out" out = zip(dt_list_hr, dt_list_hr_o, tide_a_hr) out_fn = os.path.splitext(out_fn)[0]+'_hr.csv' with open(out_fn, 'w') as f: f.write('date,date_o,tide\n') f.write('\n'.join('%s,%0.6f,%0.2f' % x for x in out)) import re #idx = np.array([bool(re.search('atm|lvis|glas',fn)) for fn in fn_list]) idx = np.array([bool(re.search('glas',fn)) for fn in fn_list]) fig, ax = plt.subplots() ax.plot_date(dt_list[~idx], tide_a[~idx], color='b', label='WV, SPIRIT, ATM, LVIS') ax.plot_date(dt_list[idx], tide_a[idx], color='b', fillstyle='none', label='GLAS') pltlib.fmt_date_ax(ax) pltlib.pad_xaxis(ax) ax.axhline(0, color='k') ax.set_ylabel('Tide z (m)') ax.set_title('CATS2008A Tidal Amplitude for PIG shelf DEMs (%s, %s)' % (lat, lon)) plt.legend() outfig_fn = os.path.splitext(out_fn)[0]+'.pdf' plt.savefig(outfig_fn) #plt.show()
axa[1].set_ylabel('Inv. Barometer (m)') axa[2].plot_date(tide_full['date_o'], combined, marker=None, linestyle='-', linewidth=0.5, color='r', alpha=0.5) axa[2].plot_date(ib['date_o'], tide['tide'] + ib['IB'], marker='o', markersize=4, color='r') axa[2].set_ylabel('Combined (m)') axa[0].set_xlim(ib['date_o'].min(), ib['date_o'].max()) pltlib.fmt_date_ax(axa[0]) pltlib.fmt_date_ax(axa[1]) pltlib.fmt_date_ax(axa[2]) pltlib.pad_xaxis(axa[2]) plt.savefig(out_fn, dpi=300) plt.show() #pairs, out = find_pairs(dem_stack, tide['tide']+ib['IB'], max_dt=timedelta(180)) #Want to subtract this from WGS84 elevation #mdt = -1.1 mdt = 0 geoid = 0 ds = dem_stack.get_ds() geoid_fn = os.path.splitext(dem_stack_fn)[0] + '_geoidoffset.tif'