Code Monkey home page Code Monkey logo

fitroom's Introduction

fitroom's People

Contributors

blehmaks avatar corentingrimaldi avatar erwanp avatar vbaillard avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

fitroom's Issues

Benchmark/Accelerate total calculations

An example based on @BlehMaks 's test case . I use print_perf_profile for each slab, scaled on the max of all spectra.

for s in slabsTool.slabs.values(): 
    s.print_perf_profile(precision=int(16*s.conditions["calculation_time"]/max([si.conditions["calculation_time"] for si in slabsTool.slabs.values()])))

I get:

slbPlasmaCO2 profiler :
    spectrum_calculation      0.908s ████████████████
        check_line_databank             0.000s 
        check_non_eq_param              0.000s 
        reinitialize                    0.036s 
            copy_database                   0.036s 
            memory_usage_warning            0.000s 
            reset_population                0.000s 
        calc_noneq_population           0.645s ███████████
            part_function                   0.363s ██████
            others                          0.282s ████
        scaled_non_eq_linestrength      0.006s 
            map_part_func                   0.002s 
            corrected_population_se         0.004s 
        calc_emission_integral          0.018s 
        calc_lineshift                  0.001s 
        calc_hwhm                       0.015s 
        generate_wavenumber_arrays      0.001s 
        calc_line_broadening            0.164s ██
            precompute_DLM_lineshapes       0.008s 
            DLM_Initialized_vectors         0.000s 
            DLM_closest_matching_line       0.009s 
            DLM_Distribute_lines            0.007s 
            DLM_convolve                    0.140s ██
        calc_other_spectral_quan        0.004s 
        generate_spectrum_obj           0.001s 
        others                          0.299s █████
slbPlasmaCO profiler :
    spectrum_calculation      0.188s ███
        check_line_databank             0.000s 
        check_non_eq_param              0.001s 
        reinitialize                    0.008s 
            copy_database                   0.005s 
            memory_usage_warning            0.003s 
            reset_population                0.000s 
        calc_noneq_population           0.032s 
            part_function                   0.017s 
            others                          0.015s 
        scaled_non_eq_linestrength      0.003s 
            map_part_func                   0.000s 
            corrected_population_se         0.003s 
        calc_emission_integral          0.012s 
        calc_lineshift                  0.001s 
        calc_hwhm                       0.012s 
        generate_wavenumber_arrays      0.001s 
        calc_line_broadening            0.105s █
            precompute_DLM_lineshapes       0.005s 
            DLM_Initialized_vectors         0.000s 
            DLM_closest_matching_line       0.001s 
            DLM_Distribute_lines            0.001s 
            DLM_convolve                    0.097s █
            others                          0.001s 
        calc_other_spectral_quan        0.004s 
        generate_spectrum_obj           0.001s 
        others                          0.025s 
slbShellCO2 profiler :
    spectrum_calculation      0.159s ██
        check_line_databank             0.001s 
        reinitialize                    0.032s 
            copy_database                   0.029s 
            memory_usage_warning            0.003s 
            reset_population                0.000s 
        scaled_eq_linestrength          0.007s 
        calc_lineshift                  0.000s 
        calc_hwhm                       0.015s 
        generate_wavenumber_arrays      0.001s 
        calc_line_broadening            0.088s █
            precompute_DLM_lineshapes       0.008s 
            DLM_Initialized_vectors         0.000s 
            DLM_closest_matching_line       0.005s 
            DLM_Distribute_lines            0.003s 
            DLM_convolve                    0.071s 
            others                          0.001s 
        calc_other_spectral_quan        0.002s 
        generate_spectrum_obj           0.000s 
        others                          0.014s 
slbShellCO profiler :
    spectrum_calculation      0.099s █
        check_line_databank             0.000s 
        reinitialize                    0.005s 
            copy_database                   0.002s 
            memory_usage_warning            0.003s 
            reset_population                0.000s 
        scaled_eq_linestrength          0.003s 
        calc_lineshift                  0.001s 
        calc_hwhm                       0.022s 
        generate_wavenumber_arrays      0.002s 
        calc_line_broadening            0.052s 
            precompute_DLM_lineshapes       0.004s 
            DLM_Initialized_vectors         0.000s 
            DLM_closest_matching_line       0.000s 
            DLM_Distribute_lines            0.001s 
            DLM_convolve                    0.045s 
            others                          0.002s 
        calc_other_spectral_quan        0.001s 
        generate_spectrum_obj           0.001s 
        others                          0.014s 
slbRoomCO2 profiler :
    spectrum_calculation      0.151s ██
        check_line_databank             0.001s 
        reinitialize                    0.035s 
            copy_database                   0.032s 
            memory_usage_warning            0.003s 
            reset_population                0.000s 
        scaled_eq_linestrength          0.005s 
        calc_lineshift                  0.001s 
        calc_hwhm                       0.015s 
        generate_wavenumber_arrays      0.001s 
        calc_line_broadening            0.083s █
            precompute_DLM_lineshapes       0.009s 
            DLM_Initialized_vectors         0.000s 
            DLM_closest_matching_line       0.004s 
            DLM_Distribute_lines            0.003s 
            DLM_convolve                    0.067s 
        calc_other_spectral_quan        0.003s 
        generate_spectrum_obj           0.001s 
        others                          0.006s 

So here more than half of the computation time is spent on calculation non-eq . Can be improved by activating parsum_mode='tabulation' radis/radis#316 if not stuck on Windows (radis/radis#338)

NeQ dependency was not removed from slit_tool.py

Dear fitroom team,
I found out that for me test_fitroom.py works not perfectly. It gives me an error message about NeQ module, that it is not found:

An error occured during selectTool callback
Traceback (most recent call last):
  File "c:\users\blekhshtein\fitroom\fitroom\selection_tool.py", line 266, in line_select_callback self.update_action(xmin, xmax, ymin, ymax)
  File "c:\users\blekhshtein\fitroom\fitroom\selection_tool.py", line 222, in update_action self.fitroom.update([xmin, xcen, xmax], [ymin, ycen, ymax])
  File "c:\users\blekhshtein\fitroom\fitroom\room.py", line 149, in update self.slitTool.update_figure()  # in case
  File "c:\users\blekhshtein\fitroom\fitroom\slit_tool.py", line 203, in update_figure self.plot_slit(wslit, Islit, waveunit=plot_unit, plot_unit=plot_unit,
  File "c:\users\blekhshtein\fitroom\fitroom\slit_tool.py", line 235, in plot_slit from neq.plot.toolbar import add_tools
ModuleNotFoundError: No module named 'neq'
Traceback (most recent call last):
  File "C:\Users\Blekhshtein\anaconda3\envs\radis-env\lib\site-packages\matplotlib\cbook\__init__.py", line 270, in process func(*args, **kwargs)
  File "C:\Users\Blekhshtein\anaconda3\envs\radis-env\lib\site-packages\matplotlib\widgets.py", line 1841, in release self._release(event)
  File "C:\Users\Blekhshtein\anaconda3\envs\radis-env\lib\site-packages\matplotlib\widgets.py", line 2396, in _release self.onselect(self.eventpress, self.eventrelease)
  File "c:\users\blekhshtein\fitroom\fitroom\selection_tool.py", line 266, in line_select_callback self.update_action(xmin, xmax, ymin, ymax)
  File "c:\users\blekhshtein\fitroom\fitroom\selection_tool.py", line 222, in update_action self.fitroom.update([xmin, xcen, xmax], [ymin, ycen, ymax])
  File "c:\users\blekhshtein\fitroom\fitroom\room.py", line 149, in update self.slitTool.update_figure()  # in case
  File "c:\users\blekhshtein\fitroom\fitroom\slit_tool.py", line 203, in update_figure self.plot_slit(wslit, Islit, waveunit=plot_unit, plot_unit=plot_unit,
  File "c:\users\blekhshtein\fitroom\fitroom\slit_tool.py", line 235, in plot_slit from neq.plot.toolbar import add_tools
ModuleNotFoundError: No module named 'neq'

So there is an attempt to import something from NeQ in the following line, I do not know if it is expected behaviour or not.

from neq.plot.toolbar import add_tools

conda can not find a neq module in its channels.

Also the panel where visualization of slit function should be looks a bit empty for me:
InkedCapture_LI

Is there something that I could do?

Thank you in advance!

Add: tool to visualize Line-of-sight

Idea : add a new tool with a Flowchart to show the line-of-sight being computed.

Would make the config function more obvious. :

Let's say we have :

def config(**slabs):
        return SerialSlabs(MergeSlabs(slabs['sPlasmaCO'], slabs['sPlasmaCO2']), slabs['sPostCO2'], slabs['sRoomCO2'])

We would get something like : :

image

(not sure about the eye 👁️ :) )

Clicking on the Spectra would return the current Spectrum conditions (easy to embed in a .svg with Spectrum.get_conditions()), but that would be asking for a lot already!

Implementation Idea

Graphviz produces light .svg files that can even be made interactive. Good example here (but should be horizontal ?).

We may require the "inspect" module to parse the code given by the user in the Config function ; or add another way to input the line-of-sight; maybe a class that would retain the relationships between the different spectra of the line-of-sight in a graph, be able to plot itself, and compute the resulting line-of-sight spectrum on demand (and recompute if some spectrum of the graph are updated with new entries).

Selection tool and slit tool fails during the update of properties

Dear Fitroom team,

After solution of the problem #7 and #8 it appeared that there are some more places to edit on this topic.
When I try to re-select new area in SelectTool or when I am trying to update SlitTool after the first loop is finished, some errors appear:

  1. If I reselect something in selection tool, the problem is still present (I updated and reinstalled fitroom). So traceback:
An error occured during selectTool callback
Traceback (most recent call last):
  File "c:\users\blekhshtein\fitroom\fitroom\selection_tool.py", line 266, in line_select_callback
    self.update_action(xmin, xmax, ymin, ymax)
  File "c:\users\blekhshtein\fitroom\fitroom\selection_tool.py", line 222, in update_action
    self.fitroom.update([xmin, xcen, xmax], [ymin, ycen, ymax])
  File "c:\users\blekhshtein\fitroom\fitroom\room.py", line 149, in update
    self.slitTool.update_figure()  # in case
  File "c:\users\blekhshtein\fitroom\fitroom\slit_tool.py", line 154, in update_figure
    w = s._q['wavespace']
KeyError: 'wavespace'
Traceback (most recent call last):
  File "C:\Users\Blekhshtein\anaconda3\envs\radis-env\lib\site-packages\matplotlib\cbook\__init__.py", line 270, in process
    func(*args, **kwargs)
  File "C:\Users\Blekhshtein\anaconda3\envs\radis-env\lib\site-packages\matplotlib\widgets.py", line 1841, in release
    self._release(event)
  File "C:\Users\Blekhshtein\anaconda3\envs\radis-env\lib\site-packages\matplotlib\widgets.py", line 2396, in _release
    self.onselect(self.eventpress, self.eventrelease)
  File "c:\users\blekhshtein\fitroom\fitroom\selection_tool.py", line 266, in line_select_callback
    self.update_action(xmin, xmax, ymin, ymax)
  File "c:\users\blekhshtein\fitroom\fitroom\selection_tool.py", line 222, in update_action
    self.fitroom.update([xmin, xcen, xmax], [ymin, ycen, ymax])
  File "c:\users\blekhshtein\fitroom\fitroom\room.py", line 149, in update
    self.slitTool.update_figure()  # in case
  File "c:\users\blekhshtein\fitroom\fitroom\slit_tool.py", line 154, in update_figure
    w = s._q['wavespace']
KeyError: 'wavespace'

Can this be caused by incompatible units?
2. When I change slit through the slitTool error also appears, saying that there is nothing for slit application, Traceback:

Traceback (most recent call last):
  File "C:\Users\Blekhshtein\anaconda3\envs\radis-env\lib\site-packages\matplotlib\cbook\__init__.py", line 270, in process
    func(*args, **kwargs)
  File "C:\Users\Blekhshtein\anaconda3\envs\radis-env\lib\site-packages\matplotlib\widgets.py", line 530, in <lambda>
    return self._observers.connect('changed', lambda val: func(val))
  File "c:\users\blekhshtein\fitroom\fitroom\slit_tool.py", line 345, in update_slider
    slabsTool.update_slit()
  File "c:\users\blekhshtein\fitroom\fitroom\multislab_tool.py", line 159, in update_slit
    s.apply_slit(slit_function, **slit_options)
  File "c:\users\blekhshtein\radis\radis\spectrum\spectrum.py", line 2174, in apply_slit
    raise AssertionError(
AssertionError: No variables to apply slit on. Variable names to be convolved should end with _noslit

Switching from SpectrumDatabase to on-fly spectra calculation

Dear @erwanp and @CorentinGrimaldi,

I am trying to adapt an example from the fit-room for my purposes. I added some new slabs to calculate the total spectrum and now I would like to switch from using precomputed spectra from SpectrumDatabase to on fly calculation. Could you please explain me, what changes should be done?

I changed in the solver 'database' to 'calculate'. Also I described SpectrumFactories for each molecule in the body of test_start_fitroom function and added corresponding factory key to each slab dictionary and removed 'db' field. After that I changed dbInteractx = Slablist[slbInteractx]['db'] to dbInteractx = Slablist[slbInteractx]['factory'] (and the same for y parameter). But after these changes I got an error:

File "C:\Users\Blekhshtein\fitroom\test\fitroom_exp_spec.py", line 378, in <module>
    print(('Test fitroom:', test_start_fitroom()))  
File "C:\Users\Blekhshtein\fitroom\test\fitroom_exp_spec.py", line 341, in test_start_fitroom
    selectTool = CaseSelector(dbInteractx, dbInteracty, xparam, yparam,  
File "c:\users\blekhshtein\fitroom\fitroom\selection_tool.py", line 99, in __init__
    fig, ax = self._plot_db_params()  
File "c:\users\blekhshtein\fitroom\fitroom\selection_tool.py", line 170, in _plot_db_params
    if len(dbInteractx.df) == 0:
AttributeError: 'SpectrumFactory' object has no attribute 'df'

I guess I did something wrong, could you help me please to proceed further or may be to give a working example?
Also, @erwanp I saw, that you posted here https://radis-radiation.slack.com/archives/C01GCVBUCAH/p1607477526010400 an example with 7 slabs. Do you have an example with this code? And if so, could you please show it?

Thank you in advance!

Add ruler tool

Now available in Radis dev version (and future 0.9.30)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.