-
Notifications
You must be signed in to change notification settings - Fork 6
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
PSF estimation #8
Comments
Hello, thanks for taking the time to look at the project! Yes, I did this project as part of my PhD thesis and had worked on some topics related on the PSF estimation, that unfortunately, did not found the time to put here. The original intention for this topic is to clarify the PSF as a mathematical function and later on, what is actually Properimage doing to calculate the PSF. I can put some effort on expanding this later this week if you can wait! Would like to have some feedback, so feel free to write more issues or add comments on this thread. |
That is great ! Of course I can wait. I finished reading the 2002 paper, the concept is looks pretty neat and effective :) I will try to use you code to see if I understoof the paper correctly, and see if I can build the estimation of the psf on my own to start with. Know I can get for each pixel, a reconstruction of the psf given the k first orthogonal vector. And of course, at the end, perform k instances of the richardson lucy deconvolution algorithm. In the meatime I will play with the code. Thanks agains for your help ! |
Edit: ok after a bit of testing, have more precise questions for you.
outputs:
As you can probably tell, I made the assumption that a_fields[0] was actually a scalar field (one coefficient per image pixel) although it looks like it is a polynomial model that need to be discretized. That is actually a very good design, because one can then choose a more or less coarse grid on which to evaluate the psf. I guess I'll found the discretization method inside the plot module. Very nice ! |
Ok, cool I think I managed to do what I was looking for, ie, fit a bivariate gaussian on reconstructed psf.
What is the inf_loss parameter ? can it be found automatically ? Thank you in advance for your help! |
Now I understand the limitations of my current approach: -It is not clear how the bouding box for start patch selection is chosen. On my test, the patch size was far to big, including sometimes multiple stars |
Hi! Basically the information loss parameter is a cut in the normalized sum of coefficients of the expansion. A simple article on this >> http://articles.adsabs.harvard.edu/pdf/2017BAAA...59..209S Its in spanish, but I can put the notebooks in the docs this weekend. |
I am so thankful ! thank you very much ! For the moment, I am using a simple method of moments to estimate the center ( My main problem is that the data used to compute the covariance matrix suffers from "outliers", ie pixels that are not actually part of the PSF. The patch I used is simply the reconstruction obtained from the basis vector * coefficients provided by your library. I tried a simple rule to threshold out pixels values lower than 5% of the maximum, but it doesn't really solve the issue. On the data I have, I end up with good examples: Overall, my FWHM estimation is not as usefull as it should be. |
Ok, looks like a good approach would be to compute the "goodness of fit" either based solely on the residual or using a statistical test (bayes factor ? something more advanced ?) to either reject some specific pixels or the entire patch. Thank you in advance for your help ! |
Well, I have put some work on the repo this weekend, although I didn't advanced much in PSF estimation. Will continue pushing this week. Regarding your question, you should select a group of stars that don't saturate the detector, and also, with a good S/N ratio. Also, reject those sources with blended neighbors, there are flags to do this in the extraction stage, I don't know if you use SExtractor or a similar soft, these should notify you somehow of blending issues. Also, try to smooth the wings of your star sample, by this I do not mean to smooth it straightforward, but you can have an educated guess of the best kernel size, and see if your wings fade low enough. I invite you to look at this part of the code best_sources where this selection is carried out. I also want to show you that I currently have a Lucy Richardson deconvolution routine in the Sorry for the incompleteness of my documentation, I will try to push this to make it better. |
I also added a last block of code in the documentation for advanced single image (tutorial 3 I think), and it performs a positional determination of PSF, using the variant estimation, and plots isophotes over the actual stars of the field. It is not perfect, but it kind of illustrates what is actually happening, and also you have in there the recipe for building the PSF anywhere in the image. |
Ok from what I saw from tutorial 3, I think I already managed to find the coefficient map and reconstruct the psf at arbitrary location following your tutorial or looking at the code before. I looked at sextractor/psfex a bit in the past, but I found those tools way to heavy and cumbersome to be used in my context. That is was I was actively looking for a code like yours for star detection / patch build... All the examples I showed before are taken out of a notebook I worked on based on you tutorials. What I was missing though is the background substraction, and it is definitely a very valuable feature I was missing from this code. I will try to use it asap and report my results here ! I am really looking forward to it. |
Ok, something I didn't mention from your previous comments is that the implementation looks like PCA on the pixels of the stamps, but it actually performs a Karhunen-Loeve decomposition which I think is a bit different (just a bit). |
Ok here is what I got checking few examples of source detection with tutorial 3 example. That correlates with what I was seeing in terms of reconstructed psf: There is definitely a problem in terms of src detection, the patch is way too big. I will take a look in the best_sources method you suggested: https://github.com/toros-astro/ProperImage/blob/5653dd2c99fd2b96a4f7bd4c1b371eaf613e07d4/properimage/single_image.py#L382 I'll try to see if the src detection/patch size estimation based on the background substracted image (this might help if not). |
Ok, this looks god, and bad. On the bright side, I see isophotes drawing your sources profile. On the bad side, it's fitting the noise, and this shouldn't be happening. I was discussing with a collaborator if the functionality would be worth to move to a standalone python package, and wanted to know if you would find this a better approach. |
This psf reconstruction is done using properimage single image class and methods? If it's properimage, I would ask to you if you can send me the image you are using so I can reproduce this behaviour. |
Ok I will document my trial. In the meantime, can you check the _bkg versus __bkg atteibute in single_image class ? In my understanding there might be a bug there. |
Hi, I am not sure of the bug situation. |
Ok I did not realized it was on purpose, I will check again then because at some point I saw that source detection was maybe not using background substraction beforehand. Anyway, if you have time, can you take a look at this image, it really shows the main issues I am experiencing with psf estimation with properImage: |
Hi, I will take a look at it. From visual inspection I guess this image has spherical aberration, and this may depend on the wavelength. This is the reason why stars look oval shaped, and at the same time their major axis pointing towards the center of the field. I would say this is a great example to modify the polinomials, and make them radial basis functions. That modification could improve this. Is this a stack of three images on three different bands? Could you send me the original files? |
Hi @BrunoSanchez and thank you for your feedback. Using a radial basis function is definitely NOT what I would like to do, because I would like to use this tool in order to diagnose wether the optical alignment of the system is good or not. A knn regressor might me much more efficient for what I am trying to do. But this is only part of the problem. I still need to fix the star patch sampling issue, that used way to big patches. |
I'm trying to load your image, but wanted to know exactly, which python package did you use for loading it into an array? Pillow? Scikit image? Besides, you can actually impose your own stamp shape, it is an option in the SingleImage class, and you should put there a tuple saying the pixel size in this format: |
from skimage import io |
Even when creating properImage with stamp_size, I get a "updating stamp shape to (15,15) |
https://gist.github.com/BrunoSanchez/f3f1b0a33890e98dabe5dcc92859e0c4 I got this far. Let me continue this tomorrow. |
I am investigating what information can be obtained from sep directly as well, as I did not really knew this module before (just read a bit about the big sextractor documentation). |
Coming back here just to mention that future plans for properimage project involve separating the PSF estimation to a separated module, and we would mantain both of them separatedly. |
Amazing, I was about to get back to this problem, as a friend advised me to tryout moffat vs gaussian. I'd be happy to check-out the future repo. Good luck |
Dear developer, thank you very much for this awesome project ! I started to read the mentionned paper (the 2002 one about spatially varying psf, and the newer ones about statistical hypothesis testing on differntial imaging).
It is really outstanding work ! Thank you very much for making it available here !
I am not done yet on reading the paper about the psf decomposition, but I was wondering if it was possible to get a reconstruction of the psf at various location of the image, such that one can then compute some quality metric maps across the image.
Which for instance would include:
-anisotropic gaussian matrix estimation
and from there:
-fwhm map
-ellipticity map
I was eager to see what will be in https://properimage.readthedocs.io/en/latest/topics/PSF.html
But there is nothing yet, what do you intend to put there ?
The text was updated successfully, but these errors were encountered: