Re: combing fits files and taking the median average [message #80892] |
Wed, 18 July 2012 03:06 |
Mandy Bailey
Messages: 3 Registered: July 2012
|
Junior Member |
|
|
On Tuesday, 17 July 2012 16:13:51 UTC+1, Craig Markwardt wrote:
> On Tuesday, July 17, 2012 10:45:33 AM UTC-4, Mandy Bailey wrote:
> > On Tuesday, 17 July 2012 15:24:07 UTC+1, Craig Markwardt wrote:
> > > On Tuesday, July 17, 2012 10:09:10 AM UTC-4, Mandy Bailey wrote:
> > > > I'm new to IDL but slowly getting the hang of things. I have four fits files, each being spectra of the same targets taken on consecutive nights. I would like to combine these into one file to analyse but I want the median average not just the average. For the latter I could simply add each file together and divide by 4 of course but I cannot see a way to take the median average when combining the files.
> > > >
> > > > The routine MEDIAN doesn't appear to work for combining multiple images as far as I can see.
> > > >
> > > > Any ideas gratefully received, thanks
> > > > Mandy
> > >
> > > You can stack the images into a 3D image, and then use the DIMENSION keyword of MEDIAN().
> > >
> > > Example,
> > > img_3d = dblarr(nx,ny,3)
> > > img_3d(*,*,0) = img_1
> > > img_3d(*,*,1) = img_2
> > > img_3d(*,*,2) = img_3
> > >
> > > img_med = median(img_3d, 3)
> > >
> > > You may have bigger problems though. If your images need to be registered then the problem becomes a lot harder.
> > >
> > > Craig
> >
> > Thanks Craig
> >
> > I'm not sure if the images need to be registered to be honest. Also each fits file actually contains the information from 400 separate fibres which I think is complicating things too. I have been able to read each fibre from the fits file and plot the individual spectra but I think I can improve my s/n in each spectrum by stacking the files and taking the median average which would be more accurate for my purposes than simply taking the average.
> >
> > I'll try what you suggest and see what happens though.
> >
> > Thanks, Mandy
>
> If it were me and I knew there were offsets - even small offsets - I would process each spectrum separately, align it to a common wavelength scale using a (hopefully) strong reference feature, then interpolate to a common grid, and finally do your stacking.
>
> But surely someone in your field has already done something like this?
>
> Craig
In the field yes, undoubtedly, in the department or easy to get hold of, find out how they did it etc., ....no! Anyway this is looking promising though as you say stacking as the last operation will be best.
Many thanks for your help and the pointer to 3D images!
Mandy
|
|
|
Re: combing fits files and taking the median average [message #80895 is a reply to message #80892] |
Tue, 17 July 2012 08:13  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Tuesday, July 17, 2012 10:45:33 AM UTC-4, Mandy Bailey wrote:
> On Tuesday, 17 July 2012 15:24:07 UTC+1, Craig Markwardt wrote:
> > On Tuesday, July 17, 2012 10:09:10 AM UTC-4, Mandy Bailey wrote:
> > > I'm new to IDL but slowly getting the hang of things. I have four fits files, each being spectra of the same targets taken on consecutive nights. I would like to combine these into one file to analyse but I want the median average not just the average. For the latter I could simply add each file together and divide by 4 of course but I cannot see a way to take the median average when combining the files.
> > >
> > > The routine MEDIAN doesn't appear to work for combining multiple images as far as I can see.
> > >
> > > Any ideas gratefully received, thanks
> > > Mandy
> >
> > You can stack the images into a 3D image, and then use the DIMENSION keyword of MEDIAN().
> >
> > Example,
> > img_3d = dblarr(nx,ny,3)
> > img_3d(*,*,0) = img_1
> > img_3d(*,*,1) = img_2
> > img_3d(*,*,2) = img_3
> >
> > img_med = median(img_3d, 3)
> >
> > You may have bigger problems though. If your images need to be registered then the problem becomes a lot harder.
> >
> > Craig
>
> Thanks Craig
>
> I'm not sure if the images need to be registered to be honest. Also each fits file actually contains the information from 400 separate fibres which I think is complicating things too. I have been able to read each fibre from the fits file and plot the individual spectra but I think I can improve my s/n in each spectrum by stacking the files and taking the median average which would be more accurate for my purposes than simply taking the average.
>
> I'll try what you suggest and see what happens though.
>
> Thanks, Mandy
If it were me and I knew there were offsets - even small offsets - I would process each spectrum separately, align it to a common wavelength scale using a (hopefully) strong reference feature, then interpolate to a common grid, and finally do your stacking.
But surely someone in your field has already done something like this?
Craig
|
|
|
Re: combing fits files and taking the median average [message #80896 is a reply to message #80895] |
Tue, 17 July 2012 07:45  |
Mandy Bailey
Messages: 3 Registered: July 2012
|
Junior Member |
|
|
On Tuesday, 17 July 2012 15:24:07 UTC+1, Craig Markwardt wrote:
> On Tuesday, July 17, 2012 10:09:10 AM UTC-4, Mandy Bailey wrote:
> > I'm new to IDL but slowly getting the hang of things. I have four fits files, each being spectra of the same targets taken on consecutive nights. I would like to combine these into one file to analyse but I want the median average not just the average. For the latter I could simply add each file together and divide by 4 of course but I cannot see a way to take the median average when combining the files.
> >
> > The routine MEDIAN doesn't appear to work for combining multiple images as far as I can see.
> >
> > Any ideas gratefully received, thanks
> > Mandy
>
> You can stack the images into a 3D image, and then use the DIMENSION keyword of MEDIAN().
>
> Example,
> img_3d = dblarr(nx,ny,3)
> img_3d(*,*,0) = img_1
> img_3d(*,*,1) = img_2
> img_3d(*,*,2) = img_3
>
> img_med = median(img_3d, 3)
>
> You may have bigger problems though. If your images need to be registered then the problem becomes a lot harder.
>
> Craig
Thanks Craig
I'm not sure if the images need to be registered to be honest. Also each fits file actually contains the information from 400 separate fibres which I think is complicating things too. I have been able to read each fibre from the fits file and plot the individual spectra but I think I can improve my s/n in each spectrum by stacking the files and taking the median average which would be more accurate for my purposes than simply taking the average.
I'll try what you suggest and see what happens though.
Thanks, Mandy
|
|
|
Re: combing fits files and taking the median average [message #80897 is a reply to message #80896] |
Tue, 17 July 2012 07:24  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Tuesday, July 17, 2012 10:09:10 AM UTC-4, Mandy Bailey wrote:
> I'm new to IDL but slowly getting the hang of things. I have four fits files, each being spectra of the same targets taken on consecutive nights. I would like to combine these into one file to analyse but I want the median average not just the average. For the latter I could simply add each file together and divide by 4 of course but I cannot see a way to take the median average when combining the files.
>
> The routine MEDIAN doesn't appear to work for combining multiple images as far as I can see.
>
> Any ideas gratefully received, thanks
> Mandy
You can stack the images into a 3D image, and then use the DIMENSION keyword of MEDIAN().
Example,
img_3d = dblarr(nx,ny,3)
img_3d(*,*,0) = img_1
img_3d(*,*,1) = img_2
img_3d(*,*,2) = img_3
img_med = median(img_3d, 3)
You may have bigger problems though. If your images need to be registered then the problem becomes a lot harder.
Craig
|
|
|