From lisi.alborghetti at gmail.com Tue Feb 6 10:06:40 2024 From: lisi.alborghetti at gmail.com (Lisa Alborghetti) Date: Tue, 6 Feb 2024 16:06:40 +0100 Subject: [AstroPy] Image combination with sigma clipping Message-ID: Hi everybody, I?m new to AstroPy, and I have what I believe to be a very simple question: I have a .fits file, containing a series of 50 images that I want to combine to create a dark image of my CCD. Before averaging, I would like to perform a sigma_clipping using mad_std. I was trying with something like this: from astropy import units as u from astropy.nddata import CCDData from ccdproc import Combiner import numpy as np ccd = CCDData.read('Dark Current/minus_10/5_sec/Background_fits.fits', unit="adu") combiner = Combiner(ccd) combiner_clipped = combiner.sigma_clipping(low_thresh=2, high_thresh=5, func='median', dev_func='mad_std') combined_average = combiner_clipped.average_combine() But it doesn?t seem to be the right way to do it. In fact, I get: ---> 12 combined_average = combiner_clipped.average_combine() AttributeError: 'NoneType' object has no attribute ?average_combine? Can someone help me with this, please? Thank you! Lisa -------------- next part -------------- An HTML attachment was scrubbed... URL: From mcraig at mnstate.edu Tue Feb 6 10:15:49 2024 From: mcraig at mnstate.edu (Craig, Matthew W) Date: Tue, 6 Feb 2024 15:15:49 +0000 Subject: [AstroPy] Image combination with sigma clipping In-Reply-To: References: Message-ID: Hi Lisa, Just to make sure I understand, are the 50 images in different extensions in the same FITS file? Thanks, Matt Craig Schedule: http://physics.mnstate.edu/craig --- Professor, Department of Physics and Astronomy MSUM ________________________________ From: AstroPy on behalf of Lisa Alborghetti Sent: Tuesday, February 6, 2024 9:06 AM To: astropy at python.org Subject: [AstroPy] Image combination with sigma clipping CAUTION: This e-mail originated from outside the Minnesota State System. Only click links or open attachments from trusted sources. Please report suspicious messages using the "Report Message Button". Hi everybody, I?m new to AstroPy, and I have what I believe to be a very simple question: I have a .fits file, containing a series of 50 images that I want to combine to create a dark image of my CCD. Before averaging, I would like to perform a sigma_clipping using mad_std. I was trying with something like this: from astropy import units as u from astropy.nddata import CCDData from ccdproc import Combiner import numpy as np ccd = CCDData.read('Dark Current/minus_10/5_sec/Background_fits.fits', unit="adu") combiner = Combiner(ccd) combiner_clipped = combiner.sigma_clipping(low_thresh=2, high_thresh=5, func='median', dev_func='mad_std') combined_average = combiner_clipped.average_combine() But it doesn?t seem to be the right way to do it. In fact, I get: ---> 12 combined_average = combiner_clipped.average_combine() AttributeError: 'NoneType' object has no attribute ?average_combine? Can someone help me with this, please? Thank you! Lisa -------------- next part -------------- An HTML attachment was scrubbed... URL: From lisi.alborghetti at gmail.com Tue Feb 6 10:25:00 2024 From: lisi.alborghetti at gmail.com (Lisa Alborghetti) Date: Tue, 6 Feb 2024 16:25:00 +0100 Subject: [AstroPy] Image combination with sigma clipping In-Reply-To: References: Message-ID: Hi Matt, Yes, once I have imported the FITS file, I can access each image data by indexing the CCDData object with the extension number. (ccd[0].data, ccd[16].data etc.) Thanks, Lisa > On 6 Feb 2024, at 16:15, Craig, Matthew W via AstroPy wrote: > > Hi Lisa, > > Just to make sure I understand, are the 50 images in different extensions in the same FITS file? > > Thanks, > > Matt Craig > Schedule: http://physics.mnstate.edu/craig > --- > Professor, Department of Physics and Astronomy > MSUM > > From: AstroPy > on behalf of Lisa Alborghetti > > Sent: Tuesday, February 6, 2024 9:06 AM > To: astropy at python.org > > Subject: [AstroPy] Image combination with sigma clipping > > CAUTION: This e-mail originated from outside the Minnesota State System. Only click links or open attachments from trusted sources. Please report suspicious messages using the "Report Message Button". > Hi everybody, > I?m new to AstroPy, and I have what I believe to be a very simple question: I have a .fits file, containing a series of 50 images that I want to combine to create a dark image of my CCD. Before averaging, I would like to perform a sigma_clipping using mad_std. > I was trying with something like this: > > from astropy import units as u > from astropy.nddata import CCDData > from ccdproc import Combiner > import numpy as np > > ccd = CCDData.read('Dark Current/minus_10/5_sec/Background_fits.fits', unit="adu") > > combiner = Combiner(ccd) > > combiner_clipped = combiner.sigma_clipping(low_thresh=2, high_thresh=5, func='median', dev_func='mad_std') > > combined_average = combiner_clipped.average_combine() > > > But it doesn?t seem to be the right way to do it. In fact, I get: > > > ---> 12 > combined_average = > combiner_clipped.average_combine() > AttributeError: > 'NoneType' object has no attribute ?average_combine? > > Can someone help me with this, please? > Thank you! > > Lisa > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: From jslavin at cfa.harvard.edu Tue Feb 6 11:00:52 2024 From: jslavin at cfa.harvard.edu (Slavin, Jonathan) Date: Tue, 6 Feb 2024 11:00:52 -0500 Subject: [AstroPy] Image combination with sigma clipping In-Reply-To: References: Message-ID: Hi Lisa, Looks to me like the method sigma_clipping of the Combiner object acts on the data in place and has no return statement (and so returns None). If that's true then you want something like: combiner.sigma_clipping(low_thresh=2, high_thresh=5, func='median', dev_func='mad_std') combined_average = combiner.average_combine() Regards, Jon > Date: Tue, 6 Feb 2024 16:06:40 +0100 > From: Lisa Alborghetti > To: astropy at python.org > Subject: [AstroPy] Image combination with sigma clipping > Message-ID: > Content-Type: text/plain; charset="utf-8" > > Hi everybody, > I?m new to AstroPy, and I have what I believe to be a very simple > question: I have a .fits file, containing a series of 50 images that I want > to combine to create a dark image of my CCD. Before averaging, I would like > to perform a sigma_clipping using mad_std. > I was trying with something like this: > > from astropy import units as u > from astropy.nddata import CCDData > from ccdproc import Combiner > import numpy as np > > ccd = CCDData.read('Dark Current/minus_10/5_sec/Background_fits.fits', > unit="adu") > > combiner = Combiner(ccd) > > combiner_clipped = combiner.sigma_clipping(low_thresh=2, high_thresh=5, > func='median', dev_func='mad_std') > > combined_average = combiner_clipped.average_combine() > > > But it doesn?t seem to be the right way to do it. In fact, I get: > > > ---> 12 combined_average = combiner_clipped.average_combine() > > AttributeError: 'NoneType' object has no attribute ?average_combine? > > Can someone help me with this, please? > Thank you! > > Lisa > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lisi.alborghetti at gmail.com Wed Feb 7 01:33:42 2024 From: lisi.alborghetti at gmail.com (Lisa Alborghetti) Date: Wed, 7 Feb 2024 07:33:42 +0100 Subject: [AstroPy] Image combination with sigma clipping In-Reply-To: References: Message-ID: <4507BD4A-3FD4-4730-A8A0-5448FE49C3BE@gmail.com> Yes, I think it works now! Thank you very much. Lisa > On 6 Feb 2024, at 17:00, Slavin, Jonathan via AstroPy wrote: > > Hi Lisa, > > Looks to me like the method sigma_clipping of the Combiner object acts on the data in place and has no return statement (and so returns None). > If that's true then you want something like: > > combiner.sigma_clipping(low_thresh=2, high_thresh=5, func='median', dev_func='mad_std') > > combined_average = combiner.average_combine() > > Regards, > Jon > > >> Date: Tue, 6 Feb 2024 16:06:40 +0100 >> From: Lisa Alborghetti > >> To: astropy at python.org >> Subject: [AstroPy] Image combination with sigma clipping >> Message-ID: > >> Content-Type: text/plain; charset="utf-8" >> >> Hi everybody, >> I?m new to AstroPy, and I have what I believe to be a very simple question: I have a .fits file, containing a series of 50 images that I want to combine to create a dark image of my CCD. Before averaging, I would like to perform a sigma_clipping using mad_std. >> I was trying with something like this: >> >> from astropy import units as u >> from astropy.nddata import CCDData >> from ccdproc import Combiner >> import numpy as np >> >> ccd = CCDData.read('Dark Current/minus_10/5_sec/Background_fits.fits', unit="adu") >> >> combiner = Combiner(ccd) >> >> combiner_clipped = combiner.sigma_clipping(low_thresh=2, high_thresh=5, func='median', dev_func='mad_std') >> >> combined_average = combiner_clipped.average_combine() >> >> >> But it doesn?t seem to be the right way to do it. In fact, I get: >> >> >> ---> 12 combined_average = combiner_clipped.average_combine() >> >> AttributeError: 'NoneType' object has no attribute ?average_combine? >> >> Can someone help me with this, please? >> Thank you! >> >> Lisa > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: