From kellecruz at gmail.com Tue Jun 2 11:52:37 2020 From: kellecruz at gmail.com (Kelle Cruz) Date: Tue, 2 Jun 2020 11:52:37 -0400 Subject: [AstroPy] Statement of support Message-ID: Hi Everyone, The Astropy Project acknowledges that the racist acts that have unfolded in the United States over the last few weeks are deeply upsetting, and that many members of our community are struggling as a result. As disturbing as these recent events are, they are familiar to our Black friends and colleagues, who continue to experience and witness acts of racism and violence toward their friends, family members, coworkers, classmates, and colleagues. The Astropy community is committed to supporting diversity and inclusion and absolutely does not tolerate racism. Let this be a reminder that those of us who are in positions of privilege and power have a responsibility to support and advocate for the Black members of our community. This includes engaging with current events that are impacting our society and actively seeking out anti-racism resources. This compilation of links may be a helpful starting point. In Solidarity, Tom Aldcroft, Tom Robitaille, Erik Tollerud, Kelle Cruz (the Coordination Committee), Steve Crawford (Ombuds) Adrian Price-Whelan -- Kelle Cruz, PhD 917.837.9748 ? Hunter: x16486 ? AMNH: x7930 Pronouns: she/her and they/them -------------- next part -------------- An HTML attachment was scrubbed... URL: From pdzwig at summaventures.com Sat Jun 13 07:45:07 2020 From: pdzwig at summaventures.com (Peter Dzwig) Date: Sat, 13 Jun 2020 12:45:07 +0100 Subject: [AstroPy] Recovering and interpolating contents of a Spectrum1D spectrum Message-ID: <28132db8-ab9c-9287-67dc-8bf6b6f3f79b@summaventures.com> All, I have to work with a Spectrum1D object, spectrum, which I have "inherited" (think of it as legacy-ware): spectrum = Spectrum1D(spectral_axis= wavelength, flux=field_strength) I need to recover the wavelengths and field_strength to standard numpy arrays because I need to interpolate between the points in the available (probably less than first-class) dataset. It would be great if I could do the interpolation within Spectrum1D but as far as I can see specutils doesn't provide a tool to do so. Hence, I have to extract the data - and subsequently create a new Spectrum1D object containing the interpolated data. I know what the units are already, so am not concerned about preserving units while extracting the datapoints. Many thanks for any suggestions. -- Dr. Peter Dzwig From derek at astro.physik.uni-goettingen.de Sat Jun 13 09:13:34 2020 From: derek at astro.physik.uni-goettingen.de (Derek Homeier) Date: Sat, 13 Jun 2020 15:13:34 +0200 Subject: [AstroPy] Recovering and interpolating contents of a Spectrum1D spectrum In-Reply-To: <28132db8-ab9c-9287-67dc-8bf6b6f3f79b@summaventures.com> References: <28132db8-ab9c-9287-67dc-8bf6b6f3f79b@summaventures.com> Message-ID: Hi Peter, > > I have to work with a Spectrum1D object, spectrum, which I have > "inherited" (think of it as legacy-ware): > > spectrum = Spectrum1D(spectral_axis= wavelength, flux=field_strength) > > I need to recover the wavelengths and field_strength to standard numpy > arrays because I need to interpolate between the points in the available > (probably less than first-class) dataset. It would be great if I could > do the interpolation within Spectrum1D but as far as I can see > specutils doesn't provide a tool to do so. > > Hence, I have to extract the data - and subsequently create a new > Spectrum1D object containing the interpolated data. > > I know what the units are already, so am not concerned about preserving > units while extracting the datapoints. spectral_axis and flux are Quantity objects, and can be accessed as arrays via spectrum.spectral_axis.value, spectrum.flux.value However as subclasses of ndarray many numpy operations are also directly supported on quantities, e.g. flux_intp = np.interp(wl_array * spectrum.spectral_axis.unit, spectrum.spectral_axis, spectrum.flux) should work as well (preserving units!). That said specutils.manipulation provides also some of its own resampling/rebinning methods offering different choices for flux conservation etc. :) https://specutils.readthedocs.io/en/latest/manipulation.html#resampling HTH Derek From pdzwig at summaventures.com Sun Jun 14 09:52:51 2020 From: pdzwig at summaventures.com (Peter Dzwig) Date: Sun, 14 Jun 2020 14:52:51 +0100 Subject: [AstroPy] Recovering and interpolating contents of a Spectrum1D spectrum In-Reply-To: References: <28132db8-ab9c-9287-67dc-8bf6b6f3f79b@summaventures.com> Message-ID: <17e99592-a701-1f28-015c-8cdcfc597589@summaventures.com> All, that looks to be the solution. When I went to the specutils webpages - as Derek kindly suggested - and did (for example) import numpy as np import astropy.units as u from specutils import Spectrum1D from specutils.manipulation import FluxConservingResampler input_spectra = Spectrum1D( flux=np.array([1, 3, 7, 6, 20]) * u.mJy, spectral_axis=np.array([2, 4, 12, 16, 20]) * u.nm) resample_grid = [1, 5, 9, 13, 14, 17, 21, 22, 23] *u.nm fluxc_resample = FluxConservingResampler() output_spectrum1D = fluxc_resample(input_spectra, resample_grid) (which is their demonstration case) I get: --------------------------------------------------------------------------- ImportError Traceback (most recent call last) in 2 import astropy.units as u 3 from specutils import Spectrum1D ----> 4 from specutils.manipulation import FluxConservingResampler 5 input_spectra = Spectrum1D( 6 flux=np.array([1, 3, 7, 6, 20]) * u.mJy, ImportError: cannot import name 'FluxConservingResampler' similarly for the other resamplers: SplineInterpolatedResampler and LinearInterpolatedResampler. Is there a specutils issue? Peter On 13/06/2020 14:13, Derek Homeier wrote: > Hi Peter, >> >> I have to work with a Spectrum1D object, spectrum, which I have >> "inherited" (think of it as legacy-ware): >> >> spectrum = Spectrum1D(spectral_axis= wavelength, flux=field_strength) >> >> I need to recover the wavelengths and field_strength to standard numpy >> arrays because I need to interpolate between the points in the available >> (probably less than first-class) dataset. It would be great if I could >> do the interpolation within Spectrum1D but as far as I can see >> specutils doesn't provide a tool to do so. >> >> Hence, I have to extract the data - and subsequently create a new >> Spectrum1D object containing the interpolated data. >> >> I know what the units are already, so am not concerned about preserving >> units while extracting the datapoints. > > spectral_axis and flux are Quantity objects, and can be accessed as arrays via > spectrum.spectral_axis.value, spectrum.flux.value > > However as subclasses of ndarray many numpy operations are also directly supported on quantities, e.g. > > flux_intp = np.interp(wl_array * spectrum.spectral_axis.unit, spectrum.spectral_axis, spectrum.flux) > > should work as well (preserving units!). > > That said specutils.manipulation provides also some of its own resampling/rebinning methods > offering different choices for flux conservation etc. :) > > https://specutils.readthedocs.io/en/latest/manipulation.html#resampling > > HTH > Derek > -- Dr. Peter Dzwig From mshieldsdunn at gmail.com Sun Jun 14 14:30:00 2020 From: mshieldsdunn at gmail.com (Matthew Dunn) Date: Sun, 14 Jun 2020 14:30:00 -0400 Subject: [AstroPy] specutils: Possible whitespace issue causing ImportError Message-ID: All: Apologies in advance, as I am new to this package and to the study of Astronomy. The following represents the results of a brief effort to uncover why another user was having issues with named imports in the specutils package. More specifically, it appears as if the following code is generating an ImportError: from specutils.manipulation import FluxConservingResampler An examination of the source of __init__.py in the specutils.manipulation package indicates that there is an extra space before the last import, which is exactly the import referencing in which FluxConversingResampler is defined (see https://github.com/astropy/specutils/blob/master/specutils/manipulation/__init__.py, line 6 and https://github.com/astropy/specutils/blob/master/specutils/manipulation/resample.py line 50). Given that Python is whitespace sensitive, I am wondering if it is simply failing to do the proper import, causing the import error. I would be more than happy to prepare a PR if that resolves the issue. And again, I apologize as I am new to the package and new to the discipline. I subscribe to this list out of curiosity more than anything and this particular error piqued my interest. -Matthew -------------- next part -------------- An HTML attachment was scrubbed... URL: From derek at astro.physik.uni-goettingen.de Mon Jun 15 09:51:35 2020 From: derek at astro.physik.uni-goettingen.de (Derek Homeier) Date: Mon, 15 Jun 2020 15:51:35 +0200 Subject: [AstroPy] specutils: Possible whitespace issue causing ImportError In-Reply-To: References: Message-ID: <72082781-C77E-4C45-9836-72311DB60B60@astro.physik.uni-goettingen.de> Hi Matthew, thanks for reporting this issue. > > Apologies in advance, as I am new to this package and to the study of Astronomy. The following represents the results of a brief effort to uncover why another user was having issues with named imports in the specutils package. More specifically, it appears as if the following code is generating an ImportError: > > from specutils.manipulation import FluxConservingResampler > > An examination of the source of __init__.py in the specutils.manipulation package indicates that there is an extra space before the last import, which is exactly the import referencing in which FluxConversingResampler is defined (see https://github.com/astropy/specutils/blob/master/specutils/manipulation/__init__.py, line 6 and https://github.com/astropy/specutils/blob/master/specutils/manipulation/resample.py line 50). Given that Python is whitespace sensitive, I am wondering if it is simply failing to do the proper import, causing the import error. > I can confirm the excess space in `from .resample import *` both in Github master and v1.0, but this is not causing any problems in importing the module with either version, and it should not, since *internal* whitespace is generally uncritical for the Python interpreter. I.e. syntactically it makes no difference if there is one, two or ten spaces between two items (or even zero in the case of binary operators like `+` or `=`). The style guide asks for a single space, so it should be corrected, but I am not sure if this justifies a pull request on its own. Could you post the error message raised when trying to import from the module? This should provide more specific pointers to the reason of the failure. E.g. if I move the extra space to the *beginning* of the line, I see this error: >>> from specutils.manipulation import FluxConservingResampler Traceback (most recent call last): File "", line 1, in File "/Users/derek/lib/python3.7/site-packages/specutils/manipulation/__init__.py", line 6 from .resample import * ^ IndentationError: unexpected indent as the indentation level *is* syntactically relevant. Do you have a similar reference to which part of the code you import is failing in? Cheers, Derek From derek at astro.physik.uni-goettingen.de Mon Jun 15 10:09:10 2020 From: derek at astro.physik.uni-goettingen.de (Derek Homeier) Date: Mon, 15 Jun 2020 16:09:10 +0200 Subject: [AstroPy] Recovering and interpolating contents of a Spectrum1D spectrum In-Reply-To: <17e99592-a701-1f28-015c-8cdcfc597589@summaventures.com> References: <28132db8-ab9c-9287-67dc-8bf6b6f3f79b@summaventures.com> <17e99592-a701-1f28-015c-8cdcfc597589@summaventures.com> Message-ID: <63B9684D-9FA9-45CA-9CA4-E9AEA93AFE1A@astro.physik.uni-goettingen.de> On 14 Jun 2020, at 3:52 pm, Peter Dzwig wrote: > > ImportError Traceback (most recent call last) > in > 2 import astropy.units as u > 3 from specutils import Spectrum1D > ----> 4 from specutils.manipulation import FluxConservingResampler > 5 input_spectra = Spectrum1D( > 6 flux=np.array([1, 3, 7, 6, 20]) * u.mJy, > > ImportError: cannot import name 'FluxConservingResampler' > > > similarly for the other resamplers: SplineInterpolatedResampler and > LinearInterpolatedResampler. > > Is there a specutils issue? Hmm, the error indicates there exist no such classes in specutils.manipulation. What is your installed version of specutils? Some of the functionality has been evolving fairly rapidly, but the manipulation utilities have been in at least since v0.6 as far as I can see. Cheers, Derek From pdzwig at summaventures.com Mon Jun 15 12:16:04 2020 From: pdzwig at summaventures.com (Peter Dzwig) Date: Mon, 15 Jun 2020 17:16:04 +0100 Subject: [AstroPy] Recovering and interpolating contents of a Spectrum1D spectrum In-Reply-To: <63B9684D-9FA9-45CA-9CA4-E9AEA93AFE1A@astro.physik.uni-goettingen.de> References: <28132db8-ab9c-9287-67dc-8bf6b6f3f79b@summaventures.com> <17e99592-a701-1f28-015c-8cdcfc597589@summaventures.com> <63B9684D-9FA9-45CA-9CA4-E9AEA93AFE1A@astro.physik.uni-goettingen.de> Message-ID: <901fcf54-ff92-eaaa-d489-6692236821e4@summaventures.com> All, It turns out that I was running Specutils 0.5, which FWIW, is what shipped with Ubuntu 19.10 which is what I run. Watch out for that!! {Python is 3.6.9] I ran >>>pip install --upgrade specutils and got astropy 4.0.1-post1, specutils-1.0 and upgrades to asdf, gwcs as part of the upgrade. The demos on the specutils site for resampling now run fine. I am posting this in case anyone else runs into similar problems! Peter PS Just in passing it may be that the upgrade to gwcs may have some bearing on issues I saw people experiencing on GitHub when looking for solutions last week to my problem. On 15/06/2020 15:09, Derek Homeier wrote: > On 14 Jun 2020, at 3:52 pm, Peter Dzwig wrote: >> >> ImportError Traceback (most recent call last) >> in >> 2 import astropy.units as u >> 3 from specutils import Spectrum1D >> ----> 4 from specutils.manipulation import FluxConservingResampler >> 5 input_spectra = Spectrum1D( >> 6 flux=np.array([1, 3, 7, 6, 20]) * u.mJy, >> >> ImportError: cannot import name 'FluxConservingResampler' >> >> >> similarly for the other resamplers: SplineInterpolatedResampler and >> LinearInterpolatedResampler. >> >> Is there a specutils issue? > > Hmm, the error indicates there exist no such classes in specutils.manipulation. > What is your installed version of specutils? Some of the functionality has been > evolving fairly rapidly, but the manipulation utilities have been in at least since > v0.6 as far as I can see. > > Cheers, > Derek > -- Dr. Peter Dzwig From aishri0208 at gmail.com Fri Jun 19 15:18:42 2020 From: aishri0208 at gmail.com (AISHRILA MAZUMDER) Date: Sat, 20 Jun 2020 00:48:42 +0530 Subject: [AstroPy] Fits image from a fits catalogue table Message-ID: Hello, If I have a catalogue with a number of sources along with their flux densities as well as astrometric information is it possible to create a fits image file out of them? Of course we need to create an image with required size first. If I have such an image is it possible to inject the sources from the catalogues into it? -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.shemuni at gmail.com Mon Jun 22 14:02:04 2020 From: m.shemuni at gmail.com (Mohammad Shameoni Niaei) Date: Mon, 22 Jun 2020 21:02:04 +0300 Subject: [AstroPy] Fits image from a fits catalogue table In-Reply-To: References: Message-ID: Hello Aishrila Since no one better than me answered, You'll need to: 1. Calculate FWHM of a given flux 1. Generate a gaussian distribution (2D) 2. Calculate the x, y positions of right ascension and declinations on CCD on Telescopes focal plane. 3. Create a numpy array and add sources to the array 4. Add noise (Bias like) Here you can find a file to generate 350 sources with a random position on CCD and random fluxes. PS: image in the attachments resized. On Fri, Jun 19, 2020 at 10:19 PM AISHRILA MAZUMDER wrote: > Hello, > > If I have a catalogue with a number of sources along with their flux > densities as well as astrometric information is it possible to create a > fits image file out of them? Of course we need to create an image with > required size first. If I have such an image is it possible to inject the > sources from the catalogues into it? > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -- Mohammad SHAMEONI NIAEI Astronomer / Software Specialist Astrofizik Ara?t?rma ve Uygulama Merkezi (ATASAM), Yakutiye, ERZURUM/T?RK?YE -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: main.py Type: text/x-python Size: 2258 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: out.jpg Type: image/jpeg Size: 27331 bytes Desc: not available URL: From aishri0208 at gmail.com Mon Jun 22 15:13:23 2020 From: aishri0208 at gmail.com (AISHRILA MAZUMDER) Date: Tue, 23 Jun 2020 00:43:23 +0530 Subject: [AstroPy] Fits image from a fits catalogue table In-Reply-To: References: Message-ID: Dear Mohammad, Thank you very much for your reply. I'll try out as suggested and let you know. best, Aishrila On Mon, Jun 22, 2020 at 11:33 PM Mohammad Shameoni Niaei < m.shemuni at gmail.com> wrote: > Hello Aishrila > Since no one better than me answered, > You'll need to: > > 1. Calculate FWHM of a given flux > 1. Generate a gaussian distribution (2D) > 2. Calculate the x, y positions of right ascension and declinations on > CCD on Telescopes focal plane. > 3. Create a numpy array and add sources to the array > 4. Add noise (Bias like) > > Here you can find a file to generate 350 sources with a random position on > CCD and random fluxes. > PS: image in the attachments resized. > > > On Fri, Jun 19, 2020 at 10:19 PM AISHRILA MAZUMDER > wrote: > >> Hello, >> >> If I have a catalogue with a number of sources along with their flux >> densities as well as astrometric information is it possible to create a >> fits image file out of them? Of course we need to create an image with >> required size first. If I have such an image is it possible to inject the >> sources from the catalogues into it? >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at python.org >> https://mail.python.org/mailman/listinfo/astropy >> > > > -- > Mohammad SHAMEONI NIAEI > Astronomer / Software Specialist > Astrofizik Ara?t?rma ve Uygulama Merkezi (ATASAM), > Yakutiye, ERZURUM/T?RK?YE > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nathaniel.j.livesey at jpl.nasa.gov Sat Jun 27 19:40:03 2020 From: nathaniel.j.livesey at jpl.nasa.gov (Livesey, Nathaniel J (US 3290)) Date: Sat, 27 Jun 2020 23:40:03 +0000 Subject: [AstroPy] Help with negative-dex type unit Message-ID: <86A79BD0-B371-4F56-BB56-D06EF486C5B6@jpl.nasa.gov> Dear all, Apologies if this first post from an Earth Atmospheric scientist using (and really appreciating) astropy somehow fails in etiquette. In atmospheric science, zeta=-log10(pressure/hPa) is a common vertical coordinate. I?m finding it hard to implement the negation part (which lets ?up? be in the positive direction) in astropy.units. The following clearly misses the mark: import astropy.units as units # The following is OKish, it decreases with altitude rather than increases zhPaTrial = units.dex(units.hPa) print ((3.0*zhPaTrial).physical) Gives: 1000.0 hPa # What I want is something like: zhPaGoal = -units.dex(units.hPa) print ((-3.0*zhPaGoal).physical) Gives: 0.001 1 / hPa Clearly, I?ve misunderstood ?dex?. Having ended up with 0.001 1/hPa rather than 1000hPa in the second example. Might I have to define my own unit some other way, perhaps using ?RegularFunctionUnit?, the way dBs are define in the astropy.units library? Any pointers most welcome, and sorry if this is in the documentation and I missed it. Yours, Nathaniel Nathaniel Livesey Mail Stop 183-701, Jet Propulsion Laboratory 4800 Oak Grove Drive, Pasadena, California 91109. Phone: +1 818 354-4214 Fax: +1 818 393-5065 -------------- next part -------------- An HTML attachment was scrubbed... URL: From derek at astro.physik.uni-goettingen.de Mon Jun 29 18:25:48 2020 From: derek at astro.physik.uni-goettingen.de (Derek Homeier) Date: Tue, 30 Jun 2020 00:25:48 +0200 Subject: [AstroPy] Help with negative-dex type unit In-Reply-To: <86A79BD0-B371-4F56-BB56-D06EF486C5B6@jpl.nasa.gov> References: <86A79BD0-B371-4F56-BB56-D06EF486C5B6@jpl.nasa.gov> Message-ID: <7093EB26-A835-4061-BC5D-D9CB92C68581@astro.physik.uni-goettingen.de> Hi Nathaniel, > Apologies if this first post from an Earth Atmospheric scientist using (and really appreciating) astropy somehow fails in etiquette. In atmospheric science, zeta=-log10(pressure/hPa) is a common vertical coordinate. I?m finding it hard to implement the negation part (which lets ?up? be in the positive direction) in astropy.units. The following clearly misses the mark: (sub)stellar Atmospheric scientist here; although the closest I typically come to Earth atmosphere is Jupiter?s, that sounds like a useful unit. ;-) > # What I want is something like: > zhPaGoal = -units.dex(units.hPa) > print ((-3.0*zhPaGoal).physical) > Gives: 0.001 1 / hPa > > Clearly, I?ve misunderstood ?dex?. Having ended up with 0.001 1/hPa rather than 1000hPa in the second example. Might I have to define my own unit some other way, perhaps using ?RegularFunctionUnit?, the way dBs are define in the astropy.units library? > Yes, the problem is that -units.dex() will create a DexUnit of your inverse physical_unit rather than the unit on a negative log scale, so creating a custom logarithmic unit type indeed seems the way to go, e.g. ndex = units.function.mixin.RegularFunctionUnit(['ndex'], -units.dex) ndex._function_unit_class = units.function.logarithmic.DexUnit zhPa = ndex(units.hPa) should behave as desired, though I?d let others chime in if they know of a more convenient way to define this. HTH Derek From nathaniel.j.livesey at jpl.nasa.gov Mon Jun 29 23:34:05 2020 From: nathaniel.j.livesey at jpl.nasa.gov (Livesey, Nathaniel J (US 3290)) Date: Tue, 30 Jun 2020 03:34:05 +0000 Subject: [AstroPy] [EXTERNAL] Help with negative-dex type unit In-Reply-To: <7093EB26-A835-4061-BC5D-D9CB92C68581@astro.physik.uni-goettingen.de> References: <86A79BD0-B371-4F56-BB56-D06EF486C5B6@jpl.nasa.gov> <7093EB26-A835-4061-BC5D-D9CB92C68581@astro.physik.uni-goettingen.de> Message-ID: <32A53D9C-8514-4092-A2C7-0B24AE5CBA9D@jpl.nasa.gov> Hi Derek, Many thanks indeed, that did exactly what I had in mind. Much appreciated! Yours, Nathaniel Nathaniel Livesey Mail Stop 183-701, Jet Propulsion Laboratory 4800 Oak Grove Drive, Pasadena, California 91109. Phone: +1 818 354-4214 Fax: +1 818 393-5065 > On Jun 29, 2020, at 3:25 PM, Derek Homeier wrote: > > Hi Nathaniel, > >> Apologies if this first post from an Earth Atmospheric scientist using (and really appreciating) astropy somehow fails in etiquette. In atmospheric science, zeta=-log10(pressure/hPa) is a common vertical coordinate. I?m finding it hard to implement the negation part (which lets ?up? be in the positive direction) in astropy.units. The following clearly misses the mark: > > (sub)stellar Atmospheric scientist here; although the closest I typically come to Earth atmosphere is Jupiter?s, > that sounds like a useful unit. ;-) > >> # What I want is something like: >> zhPaGoal = -units.dex(units.hPa) >> print ((-3.0*zhPaGoal).physical) >> Gives: 0.001 1 / hPa >> >> Clearly, I?ve misunderstood ?dex?. Having ended up with 0.001 1/hPa rather than 1000hPa in the second example. Might I have to define my own unit some other way, perhaps using ?RegularFunctionUnit?, the way dBs are define in the astropy.units library? >> > Yes, the problem is that -units.dex() will create a DexUnit of your inverse physical_unit rather than the unit > on a negative log scale, so creating a custom logarithmic unit type indeed seems the way to go, e.g. > > ndex = units.function.mixin.RegularFunctionUnit(['ndex'], -units.dex) > ndex._function_unit_class = units.function.logarithmic.DexUnit > zhPa = ndex(units.hPa) > > should behave as desired, though I?d let others chime in if they know of a more convenient way to define this. > > HTH > Derek > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy