karllark / dust_extinction Goto Github PK
View Code? Open in Web Editor NEWAstronomical Dust Extinction
Home Page: http://dust-extinction.readthedocs.io
License: BSD 3-Clause "New" or "Revised" License
Astronomical Dust Extinction
Home Page: http://dust-extinction.readthedocs.io
License: BSD 3-Clause "New" or "Revised" License
astropy needs a fairly current numpy to work.
Uber model encompassing the UV to NIR for MW, LMC, SMC
2 parameters: R(V) and f_A
Rieke, Rieke, & Paul
Peters & Tielins PixieDust
Would be good to have such code to replicate the functionality of ccm_unred (and fm_unred) as some general users are likely familiar with this way of using dust extinction curve.
Likely would be good to have it a bit more general where the extinction model could be picked as part of the call. Otherwise, would need one such convenience function for each extinction model. But maybe this would be good (as well as the general unred function).
New models and new docs. Time for a new release?
Remember to update CHANGES.rst.
A "Quick Start" section in index.rst
(main page) would be nice for someone who just discovered this package and would like to know its usage at a glance.
If simultaneously fitting the stellar and extinction, it would be good to do this with a composite model.
For example, assume a blackbody for the stellar and one of the dust_extinction models. Need a way to have the extinguishing factors as a model so then the model to fit is just, for example (BlackBody1D | ExtFactor | CCM89).
Not sure why there are these two base classes. They look identical.
Would be cool to have a logo.
Astropy and other logos often have a snake (python) in them.
One idea: a snake in the rough outline of the MW NIR/optical/UV extinction curve.
Other ideas?
This package provides extinction curves. Extinction curves describe the effects of dust for the specific geometry of a single star behind a screen of dust. Extinction is due to dust absorption and scattering out of the line-of-sight.
All other geometries require attenuation curves that include radiative transfer effects. Radiative transfer effects include having significant dust scattered light in the measurement and mixing stars and dust together. Examples are galaxies or regions of galaxies and circumstellar dust.
Formally:
All extinction curves are attenuation curves, but not all attenuation curves are extinction curves.
A separate package (dust_attenuation?) could/should be created to provide attenuation curves. E.g., averages (e.g., Calzetti starburst law), results of dust radiative transfer models (e.g. DirtyGrid), and various literature proposed shape models (e.g., Fall & Charlot).
O'Donnell (1994, ApJ, 422, 158)
"updated" CCM89?
Got an email about this use case. Email below and my response. Need to add docs for this use case. (Note name of user removed on purpose as I have not asked if they are ok having it in public).
Hi Karl,
I recently installed your dust_extinction package (thanks for coding this by the way!), but I think I am misunderstanding how to use it. I simply want to get the extinction in magnitudes of a given wavelength. I was using Fitzpatrick '99 and could not get the program to reproduce the A(lambda) "anchor points" published.
For example when I run the following code:
ext = F99(Rv=3.1)
ext(0.377)
I get the value of 0.08537820792950197. The Fitzpatrick paper says I should get 0.265.
I think that your code returns values in A(lambda)/A(V) and Fitzpatrick uses A(lambda)/E(B-V). Is there a built in switch I could use to get the published version instead of A(lambda)/A(V)?
Thank you so much for your time,
XXXXXX
Hi XXXX,
Glad you found and (may) use the dust_extinction package. The issue is that if you do not have units on the input x values, you need to input x as inverse microns. So, it should work if you use
ext(1.0/0.377)
if you would like the extinction at 0.377 microns. Alternatively, you can do
import astropy.units as u
ext(0.377*u.micron)
and that should work as well.
You will get the result in A(lambda)/A(V), so will need to multiply by the A(V) desired. Of course, if you have E(B-V) instead of A(V), then just multiply by R(V)*E(B-V).
Your question is a good one and I have opened an issue to add documentation for this use case.
Thanks,
Karl.
Meant to be used in a composite model.
Need an example showing how to do this.
Adding S07 extinction curve from PAHFIT (Smith et al. 2007)
I am working on adding this and the Maiz Apellaniz model in #38
Now that dust_extinction is in pypi, need to update docs to say how to install. Docs need to point to latest stable version as well. And add pypi badge to readme.
It would be nice to have the built-in functionality to feed in a filter bandpass (wavelength & transmission) and either A_V or E(B-V) to get the total extinction for a given extinction law.
The situation that made me think of this: going from E(B-V) of galactic foreground to the extinction in each of my filters.
Now an official affiliated package. Should change the text and add a link to the affiliated package list.
Need more examples of how to use and such examples in juypter notebooks would be ideal.
An R(V) dependent extinction model for sources in the LMC near 30 Dor.
Hi,
I installed the package in a conda environment by first active that environment and then
"pip install dust_extinction", the output of install process are print as follow:
(sci) ➜ ~ pip install dust_extinction
Collecting dust_extinction
Downloading https://files.pythonhosted.org/packages/43/99/709405d47967296abd6b7f477231d533c85d516363825a9f06463fb4ffc8/dust_extinction-0.6.tar.gz (164kB)
100% |████████████████████████████████| 174kB 76kB/s
Requirement already satisfied: astropy in /anaconda3/envs/sci/lib/python3.6/site-packages (from dust_extinction) (3.0.5)
Requirement already satisfied: scipy in /anaconda3/envs/sci/lib/python3.6/site-packages (from dust_extinction) (1.1.0)
Requirement already satisfied: numpy>=1.10.0 in /anaconda3/envs/sci/lib/python3.6/site-packages (from astropy->dust_extinction) (1.15.3)
Building wheels for collected packages: dust-extinction
Running setup.py bdist_wheel for dust-extinction ... done
Stored in directory: /Users/kyika/Library/Caches/pip/wheels/73/44/f7/b7629459b119cee574a89b01c1712bb7ef56bb77c1cd31687a
Successfully built dust-extinction
Installing collected packages: dust-extinction
Successfully installed dust-extinction-0.6
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 from dust_extinction.averages import G03_SMCBar
ModuleNotFoundError: No module named 'dust_extinction.averages'
What had happened here? Didn't I install a full-version of dust-extinction?
Any help and suggestion is grateful.
Add full references for all the curves.
Need to provide a model that takes as input one of the dust_extinction model and parameters and outputs the values needed to extinguish(redden) or unextinguish(deredden) a spectrum.
G16 model has R(V)_A and f_A as inputs. From these, the R(V) of the G16 mixture model can be calculated.
Maybe also add in the inverse with a way to designated when a value of R(V) is not allowed. This happens for f_A < 1 as R(V)_B is fixed (f_A = 0 model).
If I look at http://dust-extinction.readthedocs.io/en/latest/dust_extinction/extinguish.html it is extremely useful for understanding how to use the various models (and hence should not be removed even if the "high-level" functions are added)... But it also seems like it has a certain amount of repetitive work required to handle wavelengths.
So what I would like to see is the following:
import specutils
import dust_extinction
spec = specutils.Spectrum1D.read(...wherever my spectrum file is...)
ext = CCM89(Rv=3.1)
extspec = ext.extinguish(spec, EBmV=0.5)
and have extspec
be a Spectrum1D
. It's debatable whether this should be the actual extinguish
method - maybe an extinguish_spectrum
would make more sense... but I think it's one of the most straightforward use cases I can see with real data.
Caveat: the specutils APE was just merged last month. I believe Spectrum1D
is compatible enough already that you could do this now, but it might be one more specutils
release is required before it's worth putting in the effort to make this method.
It may be there are some other areas where this sort of "high-level" function/method might be useful, too (particularly given the package-scope discussion f #47), but this is the immediately obvious case that I saw.
Just listened to Arfon Smith's talk at Python in Astronomy 2018 on getting credit for software in astronomy. Publishing a citable paper is one way. The Journal of Open Source Software (JOSS; https://joss.theoj.org/) looks like a good fit for this package. And not too much work. :-)
This package has been reviewed by the Astropy coordination committee for inclusion in the Astropy affiliated package ecosystem.
We have adopted a review process for affiliated package that includes assigning quantitative ‘scores’ (red/orange/green) for different categories of review. You can read up more about this process here. (This document, currently in Google Docs, will be moved to the documentation in the near future.) For each of the categories below we have listed the score and have included some comments when the score is not green.
Other comments
A great example of use of the package-template to speed development of a fundamentally science-based code.
Summary/Decision: Things are looking good! There are a few areas where things could be improved as described above. However, these aren't critical and this package still meets the criteria to be an affiliated package. Keep up the good work!
If you agree with the above review, please feel free to close this issue. If you have any follow-up questions or disagree with any of the comments above, leave a comment and we can discuss it here. At any point in future you can request a re-review of the package if you believe any of the scores should be updated - contact the coordination committee, and we’ll do a new review. Note that we are in the process of redesigning the http://affiliated.astropy.org page to show these scores (but not the comments). Finally, please keep the title of this issue as-is (“Astropy Affiliated Package Review”) to make it easy to search for affiliated package reviews in future.
Need to create documentation with examples.
How to extinguish a data/model. Unextinguish data/model.
How to fit extinction curves.
There's a nice generalization of CCM89 in the Appendix of Conroy+10 that varies the bump strength. Is adding that (either as its own function or within CCM89
) within the scope of this package?
How to name models:
1-3 authors, initials of last names (e.g., CCM89, FM90)
3+ authors, initials of 1st author last name (e.g., G03)
Hi,
I installed the package in a conda environment by first active that environment and then
"pip install dust_extinction", the output of install process are print as follow:
(sci) ➜ ~ pip install dust_extinction
Collecting dust_extinction
Downloading https://files.pythonhosted.org/packages/43/99/709405d47967296abd6b7f477231d533c85d516363825a9f06463fb4ffc8/dust_extinction-0.6.tar.gz (164kB)
100% |████████████████████████████████| 174kB 76kB/s
Requirement already satisfied: astropy in /anaconda3/envs/sci/lib/python3.6/site-packages (from dust_extinction) (3.0.5)
Requirement already satisfied: scipy in /anaconda3/envs/sci/lib/python3.6/site-packages (from dust_extinction) (1.1.0)
Requirement already satisfied: numpy>=1.10.0 in /anaconda3/envs/sci/lib/python3.6/site-packages (from astropy->dust_extinction) (1.15.3)
Building wheels for collected packages: dust-extinction
Running setup.py bdist_wheel for dust-extinction ... done
Stored in directory: /Users/kyika/Library/Caches/pip/wheels/73/44/f7/b7629459b119cee574a89b01c1712bb7ef56bb77c1cd31687a
Successfully built dust-extinction
Installing collected packages: dust-extinction
Successfully installed dust-extinction-0.6
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
I think that it is successuful. However, when I using ipython or jupyter-notebook to import this package by:
from dust_extinction.averages import G03_SMCBar
I get an error:
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 from dust_extinction.averages import G03_SMCBar
ModuleNotFoundError: No module named 'dust_extinction.averages'
What had happened here? Didn't I install a full-version of dust-extinction?
Any help and suggestion is grateful.
Maybe create a new class in between that is BaseExtRvfAModel in anticipation of additional such models.
Draine models at least
Others?: Clayton, Zubko, Jones? Too many and confusing?
FM07 models includes a 7th parameter for the star of the far-UV curvature term.
Might also consider the option to tie c1 and c2 as these are completely correlated by all measures.
If AxAvToExv only used in a compound model with other models, the analytic derivative code will never be used. Probably better to remove it as it is not tested nor used.
Tests are failing with the astropy lts version with python 2.7.
The issue is the use of the 'validator' option for checking the input Rv values. The 'validator' is not present for the lts python 2.7 version.
By default, enforce the limits on wavelength that are set by the range over which a model has been defined. Allow overrides, but only with explicit setting of a keyword.
@krislars : In looking over the newly build documentation, I noticed that there is a 2nd bump in the UV for the M14 model for the Rv=5.5 plot. Have a look in the model_flavors documentation (URL below) and tell me what you think. I'm pretty sure this is not right, but you are the expert on M14.
https://dust-extinction.readthedocs.io/en/latest/dust_extinction/model_flavors.html
All the module code is currently contained in the single dust_extinction.py file. This makes for a fairly large file. It would be more readable to have smaller, potentially one for each models. The idea for a single file was that if it was ever incorporated into the astropy core, a single file would be what is needed. Given the growth of this package, it does not seem likely that a move to astropy core will ever happen. Hence, I am proposing that we split the large file into one per model and one with the classes that each model inherits.
Comments welcome!
Should increase the speed and accuracy.
Also may fix the decrease in coverage when the AxAvtoElv function was added. Used in conjunction with P92 to solve simultaneously for A(V). Test coverage not hitting the analytic derivative of AxAvtoElv when used with P92. Maybe due to P92 not have analytic derivatives?
Need to add the derivative function
Get it in the right packaging format!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.