@@ -1620,14 +1620,19 @@ def make_plot_rotary_spectra(dest_dir: str, data_filename, station: str, deploym
16201620
16211621 if do_tidal_annotation :
16221622 # keep or filling of nans does not affect result frequencies
1623- result = run_ttide (
1624- U = u ,
1625- V = v ,
1626- xin_units = 'm/s' ,
1627- time_lim = time_lim ,
1628- latitude = latitude ,
1629- constitnames = fnames
1630- )
1623+ try :
1624+ result = run_ttide (
1625+ U = u ,
1626+ V = v ,
1627+ xin_units = 'm/s' ,
1628+ time_lim = time_lim ,
1629+ latitude = latitude ,
1630+ constitnames = fnames
1631+ )
1632+ except ValueError as e :
1633+ print ('t_tide failed with error' , e )
1634+ return
1635+
16311636 # nameu might be in different order than fnames !!
16321637 for fname_S4 , fmark_cph in zip (result ['nameu' ], result ['fu' ]):
16331638 # Convert component name to string and remove any trailing whitespace
@@ -2532,15 +2537,16 @@ def create_westcoast_plots(
25322537 for bin_idx in single_bin_inds :
25332538 # Only proceed if the bin index is in range
25342539 if bin_idx < len (bin_depths_lim ):
2535- fnames_rot_spec .append (
2536- make_plot_rotary_spectra (
2537- dest_dir , ncdata .filename , ncdata .station , ncdata .deployment_number ,
2538- ncdata .instrument_depth .data , ncdata .instrument_serial_number .data ,
2539- bin_number = bin_idx , bin_depths_lim = bin_depths_lim , time_lim = time_lim ,
2540- ns_lim = ns_lim , ew_lim = ew_lim , latitude = ncdata .latitude .data ,
2541- resampled = resampled , axis = - 1
2542- )
2540+ # Add extra step in case the tidal analysis fails
2541+ plot_name = make_plot_rotary_spectra (
2542+ dest_dir , ncdata .filename , ncdata .station , ncdata .deployment_number ,
2543+ ncdata .instrument_depth .data , ncdata .instrument_serial_number .data ,
2544+ bin_number = bin_idx , bin_depths_lim = bin_depths_lim , time_lim = time_lim ,
2545+ ns_lim = ns_lim , ew_lim = ew_lim , latitude = ncdata .latitude .data ,
2546+ resampled = resampled , axis = - 1
25432547 )
2548+ if plot_name is not None :
2549+ fnames_rot_spec .append (plot_name )
25442550 else :
25452551 print (f'Warning: Bin index { bin_idx } for rotary spectra out of range of limited bins with '
25462552 f'length { len (bin_depths_lim )} ' )
0 commit comments