DSimonne / thorondor

Repository of thorondor python package, used for data analysis in X-ray absorption spectroscopy
GNU General Public License v3.0
2 stars 0 forks source link

getting started with THORONDOR #1

Open danahmedkhan opened 2 years ago

danahmedkhan commented 2 years ago

Hello,

I have some XAS data which I am trying to process. I went ahead and installed the package thorondor using pip install thorondor. I am now having a little difficulty in running it on jupyter notebook. I was wondering if you can help me step by step figure out how to get it running (GUI or widgets)? Thanks a bunch!

DSimonne commented 2 years ago

Hi, yes of course, there is an example file here: https://github.com/DSimonne/thorondor/blob/main/thorondor/Example/TestGUI.ipynb

What is your data format ?

To begin, put all your data into a folder named for example "Data", then open a Notebook in the parent directory.

Import thorondor

from thorondor import *

Create a new cell and run:

example = gui.Interface()

Then in the folder, type "Data", and choose the right kind of data.

If you want you can call me on Discord or send me a zoom link =)

danahmedkhan commented 2 years ago

Hello Simonne

We were, later, able to get it worked. Actually, there was small spelling mistake in the code 'Doniach model' was spelled as 'Donaich Model'. So what we did was, we went into the main code and fixed the spelling and it worked. Also, I am using it on Windows OS, just few lines I had to change. I guess, the main example code is based on LINUX/Mac. Not a big deal. Thank you so much. If there is anything else, I'd need help with, I'll let you know.

Thank you. Best regards Danish

DSimonne commented 2 years ago

Hi, Yes I noticed that recently and changed but did not push it, it was a problem with lmfit. (https://github.com/lmfit/lmfit-py/issues/634) I'll change the naming. Thanks! The example is a Jupyter Notebook and should be usable from the any OS. Also don't hesitate to fork the repo and add your changes !

I haven't used the main branch in a while but there is another branch, Diamond that tries to focus on XPS data that I am currently using =) You could get ideas from that.

3u63n10 commented 1 year ago

Hi Simone, am having problems running Thorondor in Windows 11. I am following the TestGUI.ipynb I run: ! pip install thorondor -U from thorondor import * %%javascript IPython.OutputArea.prototype._should_scroll = function(lines) { return false; } When I run start_example = gui.Interface() using Data folder as Data or my ExampleData folder C:\Users\myself\anaconda3\Lib\site-packages\thorondor\Example\ExampleData and click on Start working! I get this error:


IndexError Traceback (most recent call last) File ~\anaconda3\lib\site-packages\ipywidgets\widgets\interaction.py:239, in interactive.update(self, *args) 237 value = widget.get_interact_value() 238 self.kwargs[widget._kwarg] = value --> 239 self.result = self.f(**self.kwargs) 240 show_inline_matplotlib_plots() 241 if self.auto_display and self.result is not None:


IndexError Traceback (most recent call last) File ~\anaconda3\lib\site-packages\ipywidgets\widgets\interaction.py:239, in interactive.update(self, *args) 237 value = widget.get_interact_value() 238 self.kwargs[widget._kwarg] = value --> 239 self.result = self.f(**self.kwargs) 240 show_inline_matplotlib_plots() 241 if self.auto_display and self.result is not None:

File ~\anaconda3\lib\site-packages\thorondor\gui.py:2740, in Interface.class_list_init(self, data_folder, fix_name, create_folders, data_type, delimiter_type, decimal_separator, marker, initial_marker, final_marker, delete, work) 2733 # except IndexError: 2734 # print("Empty folder") 2735 2736 # except (TypeError, pd.errors.EmptyDataError, pd.errors.ParserError, UnboundLocalError): 2737 # print("Wrong data_type/delimiter/marker ! This may also be due to the use of colon as the decimal separator in your data, refer to ReadMe.") 2739 except Exception as e: -> 2740 raise e

File ~\anaconda3\lib\site-packages\thorondor\gui.py:2655, in Interface.class_list_init(self, data_folder, fix_name, create_folders, data_type, delimiter_type, decimal_separator, marker, initial_marker, final_marker, delete, work) 2651 df = pd.DataFrame( 2652 f_nxs.root.NXentry.NXdata.data[:]).abs() 2653 else: 2654 df = pd.read_csv( -> 2655 self.file_locations[0], sep=delimiter_type, decimal=decimal_separator).abs() 2657 if marker: 2658 # The file needs to be rewriten 2659 # Open all the files individually and saves its content in a variable 2660 # Only on txt, csv or dat files 2661 for file in self.file_locations:

IndexError: list index out of range

Any idea? Best regards

DSimonne commented 1 year ago
IndexError Traceback (most recent call last)
File ~\anaconda3\lib\site-packages\ipywidgets\widgets\interaction.py:239, in interactive.update(self, *args)
237 value = widget.get_interact_value()
238 self.kwargs[widget._kwarg] = value
--> 239 self.result = self.f(**self.kwargs)
240 show_inline_matplotlib_plots()
241 if self.auto_display and self.result is not None:

IndexError Traceback (most recent call last)
File ~\anaconda3\lib\site-packages\ipywidgets\widgets\interaction.py:239, in interactive.update(self, *args)
237 value = widget.get_interact_value()
238 self.kwargs[widget._kwarg] = value
--> 239 self.result = self.f(**self.kwargs)
240 show_inline_matplotlib_plots()
241 if self.auto_display and self.result is not None:

File ~\anaconda3\lib\site-packages\thorondor\gui.py:2740, in Interface.class_list_init(self, data_folder, fix_name, create_folders, data_type, delimiter_type, decimal_separator, marker, initial_marker, final_marker, delete, work)
2733 # except IndexError:
2734 # print("Empty folder")
2735
2736 # except (TypeError, pd.errors.EmptyDataError, pd.errors.ParserError, UnboundLocalError):
2737 # print("Wrong data_type/delimiter/marker ! This may also be due to the use of colon as the decimal separator in your data, refer to ReadMe.")
2739 except Exception as e:
-> 2740 raise e

File ~\anaconda3\lib\site-packages\thorondor\gui.py:2655, in Interface.class_list_init(self, data_folder, fix_name, create_folders, data_type, delimiter_type, decimal_separator, marker, initial_marker, final_marker, delete, work)
2651 df = pd.DataFrame(
2652 f_nxs.root.NXentry.NXdata.data[:]).abs()
2653 else:
2654 df = pd.read_csv(
-> 2655 self.file_locations[0], sep=delimiter_type, decimal=decimal_separator).abs()
2657 if marker:
2658 # The file needs to be rewriten
2659 # Open all the files individually and saves its content in a variable
2660 # Only on txt, csv or dat files
2661 for file in self.file_locations:

IndexError: list index out of range

The list that holds the paths to the file is empty, so he probably cannot find the data.

For the ExampleData folder, did you follow the commands that are here: https://github.com/DSimonne/thorondor/blob/main/thorondor/Example/TestGUI.ipynb ?

3u63n10 commented 1 year ago

Dear Simmone, Thaks for your prompt answer I was following the TestGUI.ipynb file skipping the colab part. ! pip install thorondor -U from thorondor import * %%javascript IPython.OutputArea.prototype._should_scroll = function(lines) { return false; } start_example = gui.Interface() The example files I an see them in the windows explorer. So the path is correct.

  1. Run the two cells <- This part is not clear to me what to do.

  2. DataFolder, replace ExampleData <- Users\myself\anaconda3\Lib\site-packages\thorondor\Example\ExampleData

  3. Fix name

  4. click Create/Check

  5. Example data is in .txt

  6. click start working <- Here comes the error

The Initial marker: and Final marker:, I left them as they are.

Best regards

DSimonne commented 1 year ago

image It works for me, do you have the same for the cell with

%%bash
ls -la
3u63n10 commented 1 year ago

Dear Simonne, that is the problem. The cd is not changing the folder, I checked it with pwd. Solutions? Best regards

DSimonne commented 1 year ago

You cannot cd in the notebook you have to do it in the terminal, the notebook must be in the same directory as the data directory: work_dir/ ExampleData/ TestGui.ipynb

3u63n10 commented 1 year ago

Dear Simonne, working! Thanks! Best regards