New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add: SpecDatabase Example in Gallery #315
Conversation
Hello !! Nice to see SpecDatabase being advertised. A few things to make it great :
|
@gugzy and @CorentinGrimaldi , adding you for Review as you use the SpecDatabases ; if you think of features / use cases that should appear on the example gallery ! |
Codecov Report
@@ Coverage Diff @@
## develop #315 +/- ##
===========================================
+ Coverage 74.30% 74.36% +0.05%
===========================================
Files 122 122
Lines 14830 14837 +7
===========================================
+ Hits 11020 11034 +14
+ Misses 3810 3803 -7 |
radis/tools/database.py
Outdated
@@ -1686,7 +1688,7 @@ def plot_cond(self, cond_x, cond_y, z_value=None, nfig=None): | |||
|
|||
# Overlay color | |||
if z_value is not None: | |||
assert (len(z_value)) == len(self.df) | |||
assert (len(self.df[z_value])) == len(self.df) | |||
|
|||
z = np.array(z_value) ** 0.5 # because the lower the better |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erwanp I believe the above line assert (len(z_value)) == len(self.df)
needs to be changed into assert (len(self.df[z_value])) == len(self.df)
because z_value is just the column name.
Also the above below gives error:
z = np.array(z_value) ** 0.5 # because the lower the better
TypeError: ufunc 'power' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looks like that z_value could be used as an external array. What about :
- if z_value is a
str
; and a column name, then usez_value = self.df[z_value]
- else let it as it is (so the user can still use an external array of any kind)
np.array(z_value) ** 0.5
looks like something added for specific (old) purposes, it could be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I use it to plot the residuals in Fitroom, if you had a look at it. So the area is what we want. Let's use it : maybe compute small matrix of Tgas and wstep (15-20 spectra max, but larger ranges, like up to 3000 K to show some differences) , and plot the calculation time as the Z_label?
It's just to inspire people, no need to spend much time here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny changes, looks great!!
With the 2 graphs, which one appear in the list of galleries ? It should be the one from plot_cond.
( I don't think we need to plot the spectra anyway. There are already many Gallery examples with spectra)
radis/tools/database.py
Outdated
@@ -1686,7 +1688,7 @@ def plot_cond(self, cond_x, cond_y, z_value=None, nfig=None): | |||
|
|||
# Overlay color | |||
if z_value is not None: | |||
assert (len(z_value)) == len(self.df) | |||
assert (len(self.df[z_value])) == len(self.df) | |||
|
|||
z = np.array(z_value) ** 0.5 # because the lower the better |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looks like that z_value could be used as an external array. What about :
- if z_value is a
str
; and a column name, then usez_value = self.df[z_value]
- else let it as it is (so the user can still use an external array of any kind)
np.array(z_value) ** 0.5
looks like something added for specific (old) purposes, it could be removed.
Merging to see if it works on the online docs! |
Hello @anandxkumar ; the docs build failed :
Can you use relative links to build the database ? Also; can you use the new PR to build a (wstep, Tgas) matrix of spectra rather than 25 spectra with different Tgas. Will be good-looking with plot_cond. |
Description
This pull request adds example of SpecDatabase in Gallery.