Closed ehsan-asali closed 2 years ago
hey, i have to look deeper into this. the last error means that te file is not read properly and that some parts are not converted. i have to assume that this is due to some version error that has to do with python 3.10 until i have found the problem you could try with a local environment that runs python 3.8 or 3.9. i did not get any problems with that in the past. If you don't know how to do that then better don't try and i will verify and fix. best jens
hey, so the problem in tutorial2 is actually something unexpected. The Filter function does drop the bad times automatically. turns out that in the latest version of the data we uploaded we had a blue fraction in the light that completely failed. When you run the ta.Filter_data you get the warning:
attention, more than 20% of the data was removed by this filter. Please check with if the spectal borders contain regions without light (and high noise) Setting a bordercut and scattercut before the filtering might be useful
so you need to either set ta.bordercut=[307,785] or use the option ta.Filter_data(value=20,replace_bad_values=0) I have changed this now in the distributed tutorial2, sorry for the problem. could you please provide me with more details on your problem with saving the files
Hi,
I am running your code on my local system (Windows 10, with Python 3.10) and I have already installed the package using 'pip install kimopack' without facing any errors.
I could successfully run 'KiMoPack_tutorial_1_Fitting-1' except that while running sections that save the project, I get an error.
After that, I ran 'KiMoPack_tutorial_2_Fitting-2' notebook and I am getting the following error in section 4 with the following code:
code:
%matplotlib qt
ta.rel_time=[0.5,1.5,20,100,1000] # certain delay times for TA spectra plot ta.rel_wave=[350,440,520,600] # certain probe wavelengths for kinetic traces plot ta.timelimits=[-1,1400] # plotted delay time range ta.bordercut=[320,770] # plotted probe wavelength range ta.intensity_range=[-55e-3,55e-3] # plotted intensity range ta.scattercut=[378,407] # ignored probe wavelength region (set to zero) ta.time_width_percent=5 # number in percent defining a delay time region
plotted in the TA spectra
ta.Plot_RAW(title='Kinetic traces at selected probe wavelengths', plotting=1) ta.Plot_RAW(title='TA spectra at selected delay-times', plotting=2) ta.Plot_RAW(title='2D-Plot', plotting=0)
Error:
ValueError Traceback (most recent call last) File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\KiMoPack\plot_func.py:538, in Frame_golay(df, window, order, transpose) 537 try: --> 538 df.loc[:,col]=savitzky_golay(df.loc[:,col].values, window, order) 539 except:
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\KiMoPack\plot_func.py:503, in savitzky_golay(y, window_size, order, deriv, rate) 502 '''Ported from a previous function''' --> 503 return savgol_filter(x=y, window_length=window_size, polyorder=order, deriv=deriv, delta=rate)
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy\signal_savitzky_golay.py:344, in savgol_filter(x, window_length, polyorder, deriv, delta, axis, mode, cval) 343 if window_length > x.size: --> 344 raise ValueError("If mode is 'interp', window_length must be less " 345 "than or equal to the size of x.") 347 # Do not pad. Instead, for the elements within
window_length // 2
348 # of the ends of the sequence, use the polynomial that is fitted to 349 # the lastwindow_length
elements.ValueError: If mode is 'interp', window_length must be less than or equal to the size of x.
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last) Input In [4], in <cell line: 12>() 9 ta.time_width_percent=5 # number in percent defining a delay time region 10 # plotted in the TA spectra ---> 12 ta.Plot_RAW(title='Kinetic traces at selected probe wavelengths', plotting=1) 13 ta.Plot_RAW(title='TA spectra at selected delay-times', plotting=2) 14 ta.Plot_RAW(title='2D-Plot', plotting=0)
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\KiMoPack\plot_func.py:6000, in TA.Plot_RAW(self, plotting, title, scale_type, times, cmap, filename, path, savetype, print_click_position, plot_second_as_energy, ds) 5998 else: 5999 title=filename -> 6000 plot_raw(ds=ds, plotting=plotting, cmap=cmap, title=title, path=path, filename=filename, 6001 intensity_range=self.intensity_range, log_scale=self.log_scale, baseunit=self.baseunit, 6002 timelimits=self.timelimits, scattercut=self.scattercut, bordercut=self.bordercut, 6003 wave_nm_bin=self.wave_nm_bin, rel_wave=self.rel_wave, width=self.wavelength_bin, 6004 time_width_percent=self.time_width_percent, ignore_time_region=self.ignore_time_region, 6005 time_bin=self.time_bin, rel_time=self.rel_time, save_figures_to_folder=self.save_figures_to_folder, 6006 savetype=savetype,plot_type=scale_type,lintresh=self.lintresh, times=times, 6007 print_click_position = print_click_position, data_type = self.data_type, 6008 plot_second_as_energy = plot_second_as_energy, units=self.units, equal_energy_bin = self.equal_energy_bin)
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\KiMoPack\plot_func.py:2673, in plot_raw(ds, plotting, title, intensity_range, baseunit, timelimits, scattercut, bordercut, wave_nm_bin, width, rel_wave, rel_time, time_width_percent, ignore_time_region, time_bin, cmap, color_offset, log_scale, plot_type, lintresh, times, save_figures_to_folder, savetype, path, filename, print_click_position, data_type, plot_second_as_energy, units, return_plots, equal_energybin) 2667 fig2,ax2=plt.subplots(figsize=(10,6),dpi=100) 2669 = plot1d(ds = ds, ax = ax2, subplot = True, cmap = cmap, width = width, wavelength = rel_wave, 2670 title = title, lines_are = 'data' , plot_type = plot_type, lintresh = lintresh, 2671 timelimits = timelimits, intensity_range = intensity_range, scattercut = scattercut, 2672 ignore_time_region = ignore_time_region, baseunit = baseunit, data_type = datatype, units = units) -> 2673 = plot1d(ds = ds, ax = ax2, subplot = False, cmap = cmap, width = width, wavelength = rel_wave, 2674 title = title, lines_are = 'smoothed', plot_type = plot_type, lintresh = lintresh, 2675 timelimits = timelimits, intensity_range = intensity_range, scattercut = scattercut, 2676 ignore_time_region = ignore_time_region, baseunit = baseunit, data_type = data_type, units = units ) 2677 if debug:print('plotted kinetics') 2678 if 2 in plotting:#Spectra
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\KiMoPack\plot_func.py:3153, in plot1d(ds, wavelength, width, ax, subplot, title, intensity_range, baseunit, timelimits, scattercut, bordercut, cmap, plot_type, lintresh, text_in_legend, lines_are, color_offset, ignore_time_region, linewidth, data_type, units, from_fit) 3151 if 'smoothed' in lines_are: 3152 if ignore_time_region is None: -> 3153 smoothed=Frame_golay(ds, window = 5, order = 3) 3154 smoothed.plot(ax = ax1, style = '-', color = colors, legend = False, lw = linewidth) 3155 elif isinstance(ignore_time_region[0], numbers.Number):
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\KiMoPack\plot_func.py:540, in Frame_golay(df, window, order, transpose) 538 df.loc[:,col]=savitzky_golay(df.loc[:,col].values, window, order) 539 except: --> 540 print(col + 'was not smoothed') 541 if transpose: 542 df=df.T
TypeError: unsupported operand type(s) for +: 'float' and 'str'
Could you please help me with running the code successfully?