Skip to content
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

Initial port of tynt to filter_parameterization subpackage #257

Merged
merged 7 commits into from
May 24, 2022

Conversation

pllim
Copy link
Contributor

@pllim pllim commented Apr 27, 2020

Based on bmorris3/tynt#8 . This would be the foundation for #38 .

Co-authored-by: @bmorris3

cc @perrygreenfield

TODO

  • Move relevant tests over from tynt.
  • Move relevant documentation over from tynt.
  • Fix test failure against older Numpy.
  • Add tips to improve results? See Initial port of tynt to filter_parameterization subpackage #257 (comment)
  • Make sure code support Quantity natively.
  • Make sure "to FFT" and "from FFT" round-trips.
  • Add tests to increase coverage, if needed.
  • Add more user facing documentation, if applicable.
  • Include an initial FFT table as package data with a small sample of generic filters? If we do this, should regenerate the table with the code here and compare to the one in tynt, if applicable. Let's not do that this round. Maybe for the future.

@pllim
Copy link
Contributor Author

pllim commented May 5, 2020

@bmorris3 , I tried to parameterize a filter I have at hand and the result doesn't look as good as what you have over at tynt. Any tips to improve the results? Thanks!

filter_par-1

@pllim pllim force-pushed the tynt-poc branch 4 times, most recently from e471801 to dfb3ca4 Compare May 6, 2020 00:54
@bmorris3
Copy link
Contributor

bmorris3 commented May 6, 2020

@bmorris3 , I tried to parameterize a filter I have at hand and the result doesn't look as good as what you have over at tynt. Any tips to improve the results? Thanks!

Sure happy to help/iterate. Two things are most important for getting accurate representations of the transmittance curves:

  • the central wavelength should be at the center of your wavelength grid
  • there should be as little extra wavelength coverage as possible at small transmittances on either end of the bandpass

The ringing that you see red- and blue-ward of the bandpass is an inevitable artifact of the truncated Fourier series used to represent the bandpass, and you can get better approximations off of the bandpass if you clip the wavelength grid liberally. If you're looking to do this agnostically/algorithmically, perhaps clip the wavelength grid to anywhere where the transmittance is greater than 0.1% – I bet that will help with minimal side-effects on the synthetic photometry.

@pllim
Copy link
Contributor Author

pllim commented May 6, 2020

@bmorris3 , thanks! It looks much better now. 😄

Figure_1

@pllim pllim changed the title [WIP] Initial port of tynt to filter_parameterization subpackage Initial port of tynt to filter_parameterization subpackage May 7, 2020
@pllim
Copy link
Contributor Author

pllim commented May 7, 2020

@bmorris3 , I think I am done porting over what I think is relevant for now. Would you mind reviewing it? Thank you!

@pllim pllim removed this from the 0.3.1 milestone Jul 17, 2020
@pllim pllim added this to the 1.1.0 milestone Jul 31, 2020
@pllim
Copy link
Contributor Author

pllim commented Feb 3, 2021

Status update: I rebased to remove conflict. Still awaiting final review from @bmorris3 and @eteq .

@codecov
Copy link

codecov bot commented Feb 3, 2021

Codecov Report

Merging #257 (7fc2381) into master (5662d6f) will increase coverage by 0.16%.
The diff coverage is 97.93%.

@@            Coverage Diff             @@
##           master     #257      +/-   ##
==========================================
+ Coverage   94.29%   94.46%   +0.16%     
==========================================
  Files          14       17       +3     
  Lines        1999     2096      +97     
==========================================
+ Hits         1885     1980      +95     
- Misses        114      116       +2     
Impacted Files Coverage Δ
synphot/filter_parameterization/filter_fft.py 96.72% <96.72%> (ø)
synphot/compat.py 80.00% <100.00%> (+2.22%) ⬆️
synphot/filter_parameterization/__init__.py 100.00% <100.00%> (ø)
...t/filter_parameterization/tests/test_filter_fft.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5662d6f...7fc2381. Read the comment docs.

Copy link
Contributor

@bmorris3 bmorris3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. I just looked it over again and I don't see anything amiss. Thanks again for giving me credit here and there 😄

@pllim
Copy link
Contributor Author

pllim commented Feb 3, 2021

Thanks, @bmorris3 ! I'll hold it open a bit longer to see if @eteq has anything to say, as Project Scientist for DATB.

@pllim pllim modified the milestones: 1.1.0, 1.2.0 Jun 23, 2021
Copy link
Contributor

@eteq eteq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I like this! A few typos/rewordings inline, and two suggestions that can either be done now or made into issues for follow-on PRs.

docs/synphot/filter_par.rst Outdated Show resolved Hide resolved
docs/synphot/filter_par.rst Outdated Show resolved Hide resolved
docs/synphot/filter_par.rst Outdated Show resolved Hide resolved
Comment on lines +16 to +17
it is up to you to decide whether the results are good enough for your
use cases or not.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to add an issue after this is merged to update this with a bit more useful guidance on what use cases it's good for? E.g. "approximating filter X with N coefficients yields a curve that is Y% as good as the full data set." It's a minor project to actually do that for a few filters though, so I think it's fine if we have this be a follow-on issue instead of blocking this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened issue at #332

Comment on lines +100 to +101
For this particular example using HST ACS/HRC F555W filter, perhaps 10
parameters are not quite sufficient. Therefore, caution needs to be exercised
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there should be one more snippet below that shows a reconstruction with more than 10 fft coefficients? That would also demonstrate how to actually do that for the user (I know it's in the API, but since it's coming up, might as well show it here).

Copy link
Contributor Author

@pllim pllim May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll chuck this as follow-up issue because I have no idea what you mean anymore. I haven't thought about this for 2 years. 😆 See #333

fft_table['lambda_0'].unit = wave_unit
fft_table['delta_lambda'].unit = wave_unit

return fft_table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it also makes sense to add a convenience function filter_table_to_models function that takes a table and returns a dictionary of models for all of the table rows? This could also be a follow-on PR, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened issue at #334

@pllim pllim force-pushed the tynt-poc branch 2 times, most recently from a99b253 to e54107c Compare May 24, 2022 21:21
TST: Fix flake8 warning
@pllim
Copy link
Contributor Author

pllim commented May 24, 2022

Better late than never. Thanks, all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants