From jimmyboysingh at gmail.com Fri Apr 2 01:23:04 2021 From: jimmyboysingh at gmail.com (Jim Singh) Date: Fri, 2 Apr 2021 16:23:04 +1100 Subject: [AstroPy] Question re objects within radius of given co-ordinates Message-ID: Hi, I am a beginner astropy user. What I'd like to be able to do is obtain the names and RA and Dec of all objects above a certain Magnitude, within a given angular FOV centered on a given named object. If I try this for example... from astropy.coordinates import SkyCoord from astroquery.vo_conesearch import ConeSearch c = SkyCoord.from_name('hadar') print(c) result = ConeSearch.query_region(c, '0.1 deg') result.sort('Mag') print(result) ...I get 2670 rows back. Assuming this is the right basic approach to begin with, is there any way to constrain the search to just those rows with 'Mag'>8 for instance? Only a handful of records would qualify in this case. My typical search radius would be a couple of degrees, so if the query were to return everything like above, it would take forever to execute. Also, how to get the name of each qualifying object? Would it entail a separate lookup on the column 'objID'? Thanks for your help! Regards, Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: From ejensen1 at swarthmore.edu Fri Apr 2 14:26:04 2021 From: ejensen1 at swarthmore.edu (Eric Jensen) Date: Fri, 2 Apr 2021 14:26:04 -0400 Subject: [AstroPy] Question re objects within radius of given co-ordinates In-Reply-To: References: Message-ID: <58E25AFC-31E2-4C4C-8E04-FC7410C49DF7@swarthmore.edu> Hi Jim, If you?re primarily interested in bright stars, and in names of objects, then the VO search probably isn?t the best bet. As you?ve found, it has lots of objects, and no common names for them. I?d suggest querying one of the catalogs from Vizier (https://vizier.u-strasbg.fr/viz-bin/VizieR), for example the Bright Star Catalogue. Here?s a query that will do a 2-degree-radius search around Hadar for stars brighter than V=6: from astroquery.vizier import Vizier result = Vizier.query_region("Hadar", radius="02d00m00s", catalog=?V/50', column_filters={"Vmag":"<6"}) print(result[0]) which prints: HR Name HD ADS VarID RAJ2000 DEJ2000 Vmag B-V SpType NoteFlag "h:m:s" "d:m:s" mag mag ---- ------- ------ --- ------- ---------- --------- ----- ----- ------ -------- 5267 Bet Cen 122451 Bet Cen 14 03 49.4 -60 22 23 0.61 -0.23 B1III * The reason you have to use ?print(result[0])? rather than just ?print(result)? is that the query returns a *list* of tables, though in this case the list only has one element. The string ?V/50? is the Vizier code for the Yale Bright Star Catalogue. You can find other suitable catalogs to query by searching Vizier and noting down the code, typically a Roman numeral followed by some digits. Each catalog will have different column names, so you may have to adapt your ?column_filters? argument above to the names of columns actually present in the catalog, or it won?t have any effect. Hope this helps, Eric > On Apr 2, 2021, at 1:23 AM, Jim Singh wrote: > > Hi, > I am a beginner astropy user. What I'd like to be able to do is obtain the names and RA and Dec of all objects above a certain Magnitude, within a given angular FOV centered on a given named object. If I try this for example... > > from astropy.coordinates import SkyCoord > from astroquery.vo_conesearch import ConeSearch > c = SkyCoord.from_name('hadar') > print(c) > result = ConeSearch.query_region(c, '0.1 deg') > result.sort('Mag') > print(result) > > ...I get 2670 rows back. Assuming this is the right basic approach to begin with, is there any way to constrain the search to just those rows with 'Mag'>8 for instance? Only a handful of records would qualify in this case. My typical search radius would be a couple of degrees, so if the query were to return everything like above, it would take forever to execute. Also, how to get the name of each qualifying object? Would it entail a separate lookup on the column 'objID'? > > Thanks for your help! > > Regards, > Jim > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4388 bytes Desc: not available URL: From jimmyboysingh at gmail.com Sat Apr 3 07:20:45 2021 From: jimmyboysingh at gmail.com (Jim Singh) Date: Sat, 3 Apr 2021 22:20:45 +1100 Subject: [AstroPy] Question re objects within radius of given co-ordinates In-Reply-To: <58E25AFC-31E2-4C4C-8E04-FC7410C49DF7@swarthmore.edu> References: <58E25AFC-31E2-4C4C-8E04-FC7410C49DF7@swarthmore.edu> Message-ID: Thanks so much for your response Eric, yes this helps tremendously! I did some additional filtering and formatting (to enable direct comparison of returned results with a star map on the phone), and they match up nicely. However, as can be seen below, some rows are without names - this is expected? from astroquery.vizier import Vizier import astropy.units as u v = Vizier(columns=['Name','_RAJ2000', '_DEJ2000', 'Vmag'],column_filters={"Vmag":"<8"}) result = v.query_region("rigel", radius="02d00m00s", catalog="V/50") for table_name in result.keys(): table = result[table_name] table['_RAJ2000'] = table['_RAJ2000'].to(u.hourangle) table['_RAJ2000'].info.format = '10.3f' print(table) Name _RAJ2000 _DEJ2000 Vmag hourangle deg mag --------- ---------- ---------- ----- 5.139 -8.665000 5.78 69Lam Eri 5.152 -8.754167 4.27 5.226 -8.147778 6.37 19Bet Ori 5.242 -8.201667 0.12 20Tau Ori 5.293 -6.844444 3.60 Also, presumably another Vizier DB contains a mapping of 'common name' (where one exists) to the Bayer name? I tried for example the online form for IV/22 "Common Name Cross Index" and although for our first example it found 'BET CEN' when given the RA and Dec of Hadar, it did not return anything in the 'name' field (where I'd expected 'Hadar' to appear): *RAJ2000"h:m:s"* *DEJ2000"d:m:s"* *Vmagmag* BFno name 14 03 49.408 -60 22 22.79 0.61 BET CEN Regards, Jim On Sat, Apr 3, 2021 at 5:26 AM Eric Jensen wrote: > Hi Jim, > > If you?re primarily interested in bright stars, and in names of objects, > then the VO search probably isn?t the best bet. As you?ve found, it has > lots of objects, and no common names for them. > > I?d suggest querying one of the catalogs from Vizier ( > https://vizier.u-strasbg.fr/viz-bin/VizieR), for example the Bright Star > Catalogue. > > Here?s a query that will do a 2-degree-radius search around Hadar for > stars brighter than V=6: > > from astroquery.vizier import Vizier > result = Vizier.query_region("Hadar", radius="02d00m00s", > catalog=?V/50', > column_filters={"Vmag":"<6"}) > print(result[0]) > > which prints: > > HR Name HD ADS VarID RAJ2000 DEJ2000 Vmag B-V SpType NoteFlag > "h:m:s" "d:m:s" mag mag > ---- ------- ------ --- ------- ---------- --------- ----- ----- ------ -------- > 5267 Bet Cen 122451 Bet Cen 14 03 49.4 -60 22 23 0.61 -0.23 B1III * > > > The reason you have to use ?print(result[0])? rather than just > ?print(result)? is that the query returns a *list* of tables, though in > this case the list only has one element. The string ?V/50? is the Vizier > code for the Yale Bright Star Catalogue. You can find other suitable > catalogs to query by searching Vizier and noting down the code, typically a > Roman numeral followed by some digits. Each catalog will have different > column names, so you may have to adapt your ?column_filters? argument above > to the names of columns actually present in the catalog, or it won?t have > any effect. > > Hope this helps, > > Eric > > On Apr 2, 2021, at 1:23 AM, Jim Singh wrote: > > Hi, > I am a beginner astropy user. What I'd like to be able to do is obtain the > names and RA and Dec of all objects above a certain Magnitude, within a > given angular FOV centered on a given named object. If I try this for > example... > > from astropy.coordinates import SkyCoord > from astroquery.vo_conesearch import ConeSearch > c = SkyCoord.from_name('hadar') > print(c) > result = ConeSearch.query_region(c, '0.1 deg') > result.sort('Mag') > print(result) > > ...I get 2670 rows back. Assuming this is the right basic approach to > begin with, is there any way to constrain the search to just those rows > with 'Mag'>8 for instance? Only a handful of records would qualify in this > case. My typical search radius would be a couple of degrees, so if the > query were to return everything like above, it would take forever to > execute. Also, how to get the name of each qualifying object? Would it > entail a separate lookup on the column 'objID'? > > Thanks for your help! > > Regards, > Jim > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pdzwig at summaventures.com Sat Apr 3 11:59:05 2021 From: pdzwig at summaventures.com (Peter Dzwig) Date: Sat, 3 Apr 2021 16:59:05 +0100 Subject: [AstroPy] Question re objects within radius of given co-ordinates In-Reply-To: References: <58E25AFC-31E2-4C4C-8E04-FC7410C49DF7@swarthmore.edu> Message-ID: I can't speak to your specific point, but I am doing a similar operation trying to cross-correlate two datasets from publications. To cut a long story short, it appears that there are some inconsistencies among naming across various DBs, :-( which may go some way to explaining what you see. Peter On 03/04/2021 12:20, Jim Singh wrote: > Thanks so much for your response Eric, yes this helps tremendously! > > I did some additional filtering and formatting (to enable direct > comparison of returned results with a star map on the phone), and they > match up nicely.? > However, as can be seen below, some rows are without names - this is > expected?? > > from astroquery.vizier import Vizier > import astropy.units as u > v = Vizier(columns=['Name','_RAJ2000', '_DEJ2000', > 'Vmag'],column_filters={"Vmag":"<8"}) > result = v.query_region("rigel", radius="02d00m00s", catalog="V/50") > for table_name in result.keys(): > ? ? table = result[table_name] > ? ? table['_RAJ2000'] = table['_RAJ2000'].to(u.hourangle) > ? ? table['_RAJ2000'].info.format = '10.3f' > ? ? print(table) > > Name ? ?_RAJ2000 ? _DEJ2000 ? Vmag > ? ? ? ? ? ? ? ? hourangle ? ? deg ? ? ?mag > --------- ---------- ---------- ----- > ? ? ? ? ? ? ? ?5.139 ?-8.665000 ?5.78 > 69Lam Eri ? ? ?5.152 ?-8.754167 ?4.27 > ? ? ? ? ? ? ? ?5.226 ?-8.147778 ?6.37 > 19Bet Ori ? ? ?5.242 ?-8.201667 ?0.12 > 20Tau Ori ? ? ?5.293 ?-6.844444 ?3.60 > > Also, presumably another Vizier DB contains a mapping of 'common name' > (where one exists) to the Bayer name? I tried for example the online > form for IV/22 "Common Name Cross Index" and although for our first > example it found 'BET CEN' when given the RA and Dec of Hadar, it did > not return anything in the 'name' field (where I'd expected 'Hadar' to > appear): > > *RAJ2000 > "h:m:s"* *DEJ2000 > "d:m:s"* *Vmag > mag* BFno name > 14 03 49.408 -60 22 22.79 0.61 ? ? ? ? BET CEN ? > > > ? > Regards, > Jim > > On Sat, Apr 3, 2021 at 5:26 AM Eric Jensen > wrote: > > Hi Jim,? > > If you?re primarily interested in bright stars, and in names of > objects, then the VO search probably isn?t the best bet.? As you?ve > found, it has lots of objects, and no common names for them.? > > I?d suggest querying one of the catalogs from Vizier > (https://vizier.u-strasbg.fr/viz-bin/VizieR > ), for example the > Bright Star Catalogue. ? > > Here?s a query that will do a 2-degree-radius search around Hadar > for stars brighter than V=6: > > from astroquery.vizier import Vizier > result = Vizier.query_region("Hadar", radius="02d00m00s",? > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?catalog=?V/50', > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?column_filters={"Vmag":"<6"}) > print(result[0]) > > which prints:? > > HR Name HD ADS VarID RAJ2000 DEJ2000 Vmag B-V SpType NoteFlag > "h:m:s" "d:m:s" mag mag > ---- ------- ------ --- ------- ---------- --------- ----- ----- ------ -------- > 5267 Bet Cen 122451 Bet Cen 14 03 49.4 -60 22 23 0.61 -0.23 B1III * > > > The reason you have to use ?print(result[0])? rather than just > ?print(result)? is that the query returns a *list* of tables, though > in this case the list only has one element.? The string ?V/50? is > the Vizier code for the Yale Bright Star Catalogue.? You can find > other suitable catalogs to query by searching Vizier and noting down > the code, typically a Roman numeral followed by some digits.? Each > catalog will have different column names, so you may have to adapt > your ?column_filters? argument above to the names of columns > actually present in the catalog, or it won?t have any effect.? > > Hope this helps,? > > Eric > >> On Apr 2, 2021, at 1:23 AM, Jim Singh > > wrote: >> >> Hi, >> I am a beginner astropy user. What I'd like to be able to do is >> obtain the names and RA and Dec of all objects above a certain >> Magnitude, within a given angular FOV centered on a given named >> object. If I try this for example... >> >> from astropy.coordinates import SkyCoord >> from astroquery.vo_conesearch import ConeSearch >> c = SkyCoord.from_name('hadar') >> print(c) >> result = ConeSearch.query_region(c, '0.1 deg') >> result.sort('Mag') >> print(result) >> >> ...I get 2670 rows back. Assuming this is the right basic approach >> to begin with, is there any way to constrain the search to just >> those rows with 'Mag'>8 for instance? Only a handful of records >> would qualify in this case. My typical search radius would be a >> couple of degrees, so if the query were to return everything like >> above, it would take forever to execute. Also, how to get the name >> of each qualifying object? Would it entail a separate lookup on >> the column 'objID'? >> >> Thanks for your help! >> >> Regards, >> Jim >> _______________________________________________ >> AstroPy mailing list >> AstroPy at python.org >> https://mail.python.org/mailman/listinfo/astropy >> > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > > > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -- Dr. Peter Dzwig From ejensen1 at swarthmore.edu Sat Apr 3 14:24:42 2021 From: ejensen1 at swarthmore.edu (Eric Jensen) Date: Sat, 3 Apr 2021 14:24:42 -0400 Subject: [AstroPy] Question re objects within radius of given co-ordinates In-Reply-To: References: <58E25AFC-31E2-4C4C-8E04-FC7410C49DF7@swarthmore.edu> Message-ID: Hi Jim, Glad it?s working for you. Astronomical naming is a messy topic - not every star has a ?common name? in the way you?re thinking of, but at the same time, every bright star has *many* identifiers (usually associated with various catalogs) that can be used to refer to it. If you want to look up names, querying Simbad will give you the most systematic, comprehensive answer, but then you?ll have to work out some kind of rubric for how to choose which name you want to use from the many provided. For example, the Bright Star Catalogue objects all have ?HR? numbers (confusingly, for "Harvard Revised? photometry in the Yale Bright Star Catalogue...). If we add ?HR? to the list of columns returned in your example, you get this: _RAJ2000 _DEJ2000 Vmag HR Name hourangle deg mag ---------- ---------- ----- ---- --------- 5.139 -8.665000 5.78 1671 5.152 -8.754167 4.27 1679 69Lam Eri 5.226 -8.147778 6.37 1704 5.242 -8.201667 0.12 1713 19Bet Ori 5.293 -6.844444 3.60 1735 20Tau Ori So the stars with missing names could be referred to as ?HR 1671? and ?HR 1704?. Those are perfectly good star names. If you want to go further, here?s a query to fetch all the names from Simbad for those stars with blanks in the ?Name? column from your previous query: from astroquery.simbad import Simbad for obj in result[0]: if obj['Name'] == '': hr_name = 'HR ' + str(obj['HR']) print("No name for {}, fetching from Simbad.".format(hr_name)) s = Simbad.query_objectids(hr_name) print("Found {} identifiers:".format(len(s))) print(s, "\n") which yields this: No name for HR 1671, fetching from Simbad. Found 29 identifiers: ID ---------------------------- TIC 425213211 2MASS J05082019-0839552 ADS 3722 A BD-08 1037 CCDM J05083-0839A CEL 543 CSI-08 1037 1 GC 6281 GCRV 55873 GEN# +1.00033224A ... SKY# 8076 TD1 4085 UBV 4941 UBV M 10659 YZ 98 1353 uvby98 100033224 A WDS J05083-0840A TYC 5330-1722-1 ** STF 649A WEB 4664 Gaia DR2 3182907530429025280 Length = 29 rows No name for HR 1704, fetching from Simbad. Found 23 identifiers: ID ---------------------------- TIC 231305489 2MASS J05133327-0808520 BD-08 1059 CEL 574 GC 6392 GEN# +1.00033948 GSC 05330-01720 HD 33948 HERZ 11718 HR 1704 N30 1119 PPM 187818 SAO 131887 SKY# 8229 SRS 6242 TD1 4233 TYC 5330-1720-1 UBV 5002 UBV M 10732 YZ 98 1387 [HFE83] 362 uvby98 100033948 Gaia DR2 3206914301671368960 From there you could decide which name you want to use? If you?re looking specifically for the common names, those are formatted as ?NAME X? in Simbad (e.g. ?NAME Polaris?), and Bayer or Flamsteed designations have a single ?*? at the start, e.g. ?* alf UMi? and ?* 1 UMi? for Polaris (where the ?UMi? is the constellation abbreviation, Ursa Minor in this case). Again, not every star will have a name like that, but you could check the list if you?re trying to prioritize names of that type. Best, Eric P.S. Regarding Peter Dzwig?s point regarding matching across catalogues, using coordinates for matching is always the safest way to go, rather than names. > On Apr 3, 2021, at 7:20 AM, Jim Singh wrote: > > Thanks so much for your response Eric, yes this helps tremendously! > > I did some additional filtering and formatting (to enable direct comparison of returned results with a star map on the phone), and they match up nicely. > However, as can be seen below, some rows are without names - this is expected? > > from astroquery.vizier import Vizier > import astropy.units as u > v = Vizier(columns=['Name','_RAJ2000', '_DEJ2000', 'Vmag'],column_filters={"Vmag":"<8"}) > result = v.query_region("rigel", radius="02d00m00s", catalog="V/50") > for table_name in result.keys(): > table = result[table_name] > table['_RAJ2000'] = table['_RAJ2000'].to(u.hourangle) > table['_RAJ2000'].info.format = '10.3f' > print(table) > > Name _RAJ2000 _DEJ2000 Vmag > hourangle deg mag > --------- ---------- ---------- ----- > 5.139 -8.665000 5.78 > 69Lam Eri 5.152 -8.754167 4.27 > 5.226 -8.147778 6.37 > 19Bet Ori 5.242 -8.201667 0.12 > 20Tau Ori 5.293 -6.844444 3.60 > > Also, presumably another Vizier DB contains a mapping of 'common name' (where one exists) to the Bayer name? I tried for example the online form for IV/22 "Common Name Cross Index" and although for our first example it found 'BET CEN' when given the RA and Dec of Hadar, it did not return anything in the 'name' field (where I'd expected 'Hadar' to appear): > > RAJ2000 <> > "h:m:s" <> DEJ2000 <> > "d:m:s" <> Vmag <> > mag <> BFno <> name <> > 14 03 49.408 -60 22 22.79 0.61 BET CEN > > > Regards, > Jim > > On Sat, Apr 3, 2021 at 5:26 AM Eric Jensen > wrote: > Hi Jim, > > If you?re primarily interested in bright stars, and in names of objects, then the VO search probably isn?t the best bet. As you?ve found, it has lots of objects, and no common names for them. > > I?d suggest querying one of the catalogs from Vizier (https://vizier.u-strasbg.fr/viz-bin/VizieR ), for example the Bright Star Catalogue. > > Here?s a query that will do a 2-degree-radius search around Hadar for stars brighter than V=6: > > from astroquery.vizier import Vizier > result = Vizier.query_region("Hadar", radius="02d00m00s", > catalog=?V/50', > column_filters={"Vmag":"<6"}) > print(result[0]) > > which prints: > > HR Name HD ADS VarID RAJ2000 DEJ2000 Vmag B-V SpType NoteFlag > "h:m:s" "d:m:s" mag mag > ---- ------- ------ --- ------- ---------- --------- ----- ----- ------ -------- > 5267 Bet Cen 122451 Bet Cen 14 03 49.4 -60 22 23 0.61 -0.23 B1III * > > The reason you have to use ?print(result[0])? rather than just ?print(result)? is that the query returns a *list* of tables, though in this case the list only has one element. The string ?V/50? is the Vizier code for the Yale Bright Star Catalogue. You can find other suitable catalogs to query by searching Vizier and noting down the code, typically a Roman numeral followed by some digits. Each catalog will have different column names, so you may have to adapt your ?column_filters? argument above to the names of columns actually present in the catalog, or it won?t have any effect. > > Hope this helps, > > Eric > >> On Apr 2, 2021, at 1:23 AM, Jim Singh > wrote: >> >> Hi, >> I am a beginner astropy user. What I'd like to be able to do is obtain the names and RA and Dec of all objects above a certain Magnitude, within a given angular FOV centered on a given named object. If I try this for example... >> >> from astropy.coordinates import SkyCoord >> from astroquery.vo_conesearch import ConeSearch >> c = SkyCoord.from_name('hadar') >> print(c) >> result = ConeSearch.query_region(c, '0.1 deg') >> result.sort('Mag') >> print(result) >> >> ...I get 2670 rows back. Assuming this is the right basic approach to begin with, is there any way to constrain the search to just those rows with 'Mag'>8 for instance? Only a handful of records would qualify in this case. My typical search radius would be a couple of degrees, so if the query were to return everything like above, it would take forever to execute. Also, how to get the name of each qualifying object? Would it entail a separate lookup on the column 'objID'? >> >> Thanks for your help! >> >> Regards, >> Jim >> _______________________________________________ >> AstroPy mailing list >> AstroPy at python.org >> https://mail.python.org/mailman/listinfo/astropy > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4388 bytes Desc: not available URL: From jimmyboysingh at gmail.com Sun Apr 4 08:31:32 2021 From: jimmyboysingh at gmail.com (Jim Singh) Date: Sun, 4 Apr 2021 22:31:32 +1000 Subject: [AstroPy] Question re objects within radius of given co-ordinates In-Reply-To: References: <58E25AFC-31E2-4C4C-8E04-FC7410C49DF7@swarthmore.edu> Message-ID: Well this has certainly been an education - thank you so much for taking the time to explain! I can see now that even pseudo code like: If NAME is not blank, *name*=NAME ElseIf * is not blank, *name*=* Else *name*=HR Code would not be sufficient, because there can be multiple * entries (eg *bet Ori, *19 Ori, *bet Ori A), just as there can be multiple NAMEs (eg NAME Loadstar, NAME Polaris, NAME North Star), so I will need additional logic to choose from such occurrences. It'd be no fun if this was too straightforward :-) Thanks again Regards, Jim On Sun, Apr 4, 2021 at 4:24 AM Eric Jensen wrote: > Hi Jim, > > Glad it?s working for you. > > Astronomical naming is a messy topic - not every star has a ?common name? > in the way you?re thinking of, but at the same time, every bright star has > *many* identifiers (usually associated with various catalogs) that can be > used to refer to it. > > If you want to look up names, querying Simbad will give you the most > systematic, comprehensive answer, but then you?ll have to work out some > kind of rubric for how to choose which name you want to use from the many > provided. > > For example, the Bright Star Catalogue objects all have ?HR? numbers > (confusingly, for "Harvard Revised? photometry in the Yale Bright Star > Catalogue...). If we add ?HR? to the list of columns returned in your > example, you get this: > > _RAJ2000 _DEJ2000 Vmag HR Name > hourangle deg mag > ---------- ---------- ----- ---- --------- > 5.139 -8.665000 5.78 1671 > 5.152 -8.754167 4.27 1679 69Lam Eri > 5.226 -8.147778 6.37 1704 > 5.242 -8.201667 0.12 1713 19Bet Ori > 5.293 -6.844444 3.60 1735 20Tau Ori > > > So the stars with missing names could be referred to as ?HR 1671? and ?HR > 1704?. Those are perfectly good star names. > > If you want to go further, here?s a query to fetch all the names from > Simbad for those stars with blanks in the ?Name? column from your previous > query: > > from astroquery.simbad import Simbad > for obj in result[0]: > if obj['Name'] == '': > hr_name = 'HR ' + str(obj['HR']) > print("No name for {}, fetching from Simbad.".format(hr_name)) > s = Simbad.query_objectids(hr_name) > print("Found {} identifiers:".format(len(s))) > print(s, "\n") > > which yields this: > > No name for HR 1671, fetching from Simbad. > Found 29 identifiers: > ID > ---------------------------- > TIC 425213211 > 2MASS J05082019-0839552 > ADS 3722 A > BD-08 1037 > CCDM J05083-0839A > CEL 543 > CSI-08 1037 1 > GC 6281 > GCRV 55873 > GEN# +1.00033224A > ... > SKY# 8076 > TD1 4085 > UBV 4941 > UBV M 10659 > YZ 98 1353 > uvby98 100033224 A > WDS J05083-0840A > TYC 5330-1722-1 > ** STF 649A > WEB 4664 > Gaia DR2 3182907530429025280 > Length = 29 rows > > No name for HR 1704, fetching from Simbad. > Found 23 identifiers: > ID > ---------------------------- > TIC 231305489 > 2MASS J05133327-0808520 > BD-08 1059 > CEL 574 > GC 6392 > GEN# +1.00033948 > GSC 05330-01720 > HD 33948 > HERZ 11718 > HR 1704 > N30 1119 > PPM 187818 > SAO 131887 > SKY# 8229 > SRS 6242 > TD1 4233 > TYC 5330-1720-1 > UBV 5002 > UBV M 10732 > YZ 98 1387 > [HFE83] 362 > uvby98 100033948 > Gaia DR2 3206914301671368960 > > From there you could decide which name you want to use? If you?re > looking specifically for the common names, those are formatted as ?NAME X? > in Simbad (e.g. ?NAME Polaris?), and Bayer or Flamsteed designations have a > single ?*? at the start, e.g. ?* alf UMi? and ?* 1 UMi? for Polaris (where > the ?UMi? is the constellation abbreviation, Ursa Minor in this case). > Again, not every star will have a name like that, but you could check the > list if you?re trying to prioritize names of that type. > > Best, > > Eric > > P.S. Regarding Peter Dzwig?s point regarding matching across catalogues, > using coordinates for matching is always the safest way to go, rather than > names. > > > On Apr 3, 2021, at 7:20 AM, Jim Singh wrote: > > Thanks so much for your response Eric, yes this helps tremendously! > > I did some additional filtering and formatting (to enable direct > comparison of returned results with a star map on the phone), and they > match up nicely. > However, as can be seen below, some rows are without names - this is > expected? > > from astroquery.vizier import Vizier > import astropy.units as u > v = Vizier(columns=['Name','_RAJ2000', '_DEJ2000', > 'Vmag'],column_filters={"Vmag":"<8"}) > result = v.query_region("rigel", radius="02d00m00s", catalog="V/50") > for table_name in result.keys(): > table = result[table_name] > table['_RAJ2000'] = table['_RAJ2000'].to(u.hourangle) > table['_RAJ2000'].info.format = '10.3f' > print(table) > > Name _RAJ2000 _DEJ2000 Vmag > hourangle deg mag > --------- ---------- ---------- ----- > 5.139 -8.665000 5.78 > 69Lam Eri 5.152 -8.754167 4.27 > 5.226 -8.147778 6.37 > 19Bet Ori 5.242 -8.201667 0.12 > 20Tau Ori 5.293 -6.844444 3.60 > > Also, presumably another Vizier DB contains a mapping of 'common name' > (where one exists) to the Bayer name? I tried for example the online form > for IV/22 "Common Name Cross Index" and although for our first example it > found 'BET CEN' when given the RA and Dec of Hadar, it did not return > anything in the 'name' field (where I'd expected 'Hadar' to appear): > > > *RAJ2000"h:m:s"* > *DEJ2000"d:m:s"* > *Vmagmag* BFno name > 14 03 49.408 -60 22 22.79 0.61 BET CEN > > Regards, > Jim > > On Sat, Apr 3, 2021 at 5:26 AM Eric Jensen > wrote: > >> Hi Jim, >> >> If you?re primarily interested in bright stars, and in names of objects, >> then the VO search probably isn?t the best bet. As you?ve found, it has >> lots of objects, and no common names for them. >> >> I?d suggest querying one of the catalogs from Vizier ( >> https://vizier.u-strasbg.fr/viz-bin/VizieR), for example the Bright Star >> Catalogue. >> >> Here?s a query that will do a 2-degree-radius search around Hadar for >> stars brighter than V=6: >> >> from astroquery.vizier import Vizier >> result = Vizier.query_region("Hadar", radius="02d00m00s", >> catalog=?V/50', >> column_filters={"Vmag":"<6"}) >> print(result[0]) >> >> which prints: >> >> HR Name HD ADS VarID RAJ2000 DEJ2000 Vmag B-V SpType NoteFlag >> "h:m:s" "d:m:s" mag mag >> ---- ------- ------ --- ------- ---------- --------- ----- ----- ------ -------- >> 5267 Bet Cen 122451 Bet Cen 14 03 49.4 -60 22 23 0.61 -0.23 B1III * >> >> >> The reason you have to use ?print(result[0])? rather than just >> ?print(result)? is that the query returns a *list* of tables, though in >> this case the list only has one element. The string ?V/50? is the Vizier >> code for the Yale Bright Star Catalogue. You can find other suitable >> catalogs to query by searching Vizier and noting down the code, typically a >> Roman numeral followed by some digits. Each catalog will have different >> column names, so you may have to adapt your ?column_filters? argument above >> to the names of columns actually present in the catalog, or it won?t have >> any effect. >> >> Hope this helps, >> >> Eric >> >> On Apr 2, 2021, at 1:23 AM, Jim Singh wrote: >> >> Hi, >> I am a beginner astropy user. What I'd like to be able to do is obtain >> the names and RA and Dec of all objects above a certain Magnitude, within a >> given angular FOV centered on a given named object. If I try this for >> example... >> >> from astropy.coordinates import SkyCoord >> from astroquery.vo_conesearch import ConeSearch >> c = SkyCoord.from_name('hadar') >> print(c) >> result = ConeSearch.query_region(c, '0.1 deg') >> result.sort('Mag') >> print(result) >> >> ...I get 2670 rows back. Assuming this is the right basic approach to >> begin with, is there any way to constrain the search to just those rows >> with 'Mag'>8 for instance? Only a handful of records would qualify in this >> case. My typical search radius would be a couple of degrees, so if the >> query were to return everything like above, it would take forever to >> execute. Also, how to get the name of each qualifying object? Would it >> entail a separate lookup on the column 'objID'? >> >> Thanks for your help! >> >> Regards, >> Jim >> _______________________________________________ >> AstroPy mailing list >> AstroPy at python.org >> https://mail.python.org/mailman/listinfo/astropy >> >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at python.org >> https://mail.python.org/mailman/listinfo/astropy >> > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From didrik.nilsen at live.no Wed Apr 7 20:14:15 2021 From: didrik.nilsen at live.no (Didrik Nilsen) Date: Thu, 8 Apr 2021 00:14:15 +0000 Subject: [AstroPy] Plotting .fits data using filters Message-ID: I am doing a research project in Astronomy where I am supposed to analyze three different pictures. I am using several different packages to extract the data from every pixel in every picture. To make sure that my data is reliable I am dividing one picture of one galaxy by another picture of the same galaxy, but the second picture is an error picture. To make sure my data is reliable I am dividing the two arrays by each other to get a ratio in order to plot and calculate the median with proper data. I think I have gotten the median right, but my plots are not. There are far too many plots based on the elements in the ratio array which is 23. Please help me. Here is my code. I can supply more info about the project if needed. glx_list = os.listdir(r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\H2_Maps-20210201T082125Z-001\H2_Maps') hello = 0 for i in glx_list: image_data_dg = 0 print(i) map_gau = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\SiVI_Maps-20210201T084648Z-001\SiVI_Maps' + '\\' + i + '\\SiVI\\Spat3\\map_gau.fits' map_gau_err = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\SiVI_Maps-20210201T084648Z-001\SiVI_Maps' + '\\' + i + '\\SiVI\\Spat3\\map_gau_err.fits' disp_gau = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\H2_Maps-20210201T082125Z-001\H2_Maps' + '\\' + i + '\\H2\\Spat3\\disp_gau.fits' image_data_dg = fits.open(disp_gau) image_data_mg = fits.open(map_gau) image_data_err = fits.open(map_gau_err) dshape = image_data_mg[0].data.shape dshape = np.subtract(dshape, (1, 1)) y, x = dshape data_mg = image_data_mg[0].data[0:x, 0:y].astype('float') data_err = image_data_err[0].data[0:x, 0:y].astype('float') data_dg = image_data_dg[0].data[0:x, 0:y].astype('float') data_mg[data_mg == 0] = 'nan' data_err[data_err == 0] = 'nan' data_dg[data_dg == 0] = 'nan' ratio = np.divide(data_mg[0:x, 0:y], data_err[0:x, 0:y]) low_snr = (ratio < 2) bad_pixel = (ratio == np.nan) mask = ~(low_snr & bad_pixel) counter1 = 0 for i in ratio: counter2 = 0 for j in i: if j < 2: data_mg[counter1][counter2] = 'nan' data_dg[counter1][counter2] = 'nan' elif j == 'nan': data_mg[counter1][counter2] = 'nan' data_dg[counter1][counter2] = 'nan' counter1 = counter1 + 1 plt.scatter(data_mg, data_dg) plt.xlim(0, .2) plt.ylim(0, 500) #plt.savefig('plot' + str(hello)) hello = hello + 1 plt.show() if hello == 1: break plt.clf() data_mg = np.ndarray.flatten(data_mg) data_mg = data_mg[np.logical_not(np.isnan(data_mg))] data_dg = np.ndarray.flatten(data_dg) data_dg = data_dg[np.logical_not(np.isnan(data_dg))] b = np.where(np.array(data_dg > 100)) median = np.median(data_mg[b]) print('Flux median at dispersion > 100 km/s is ' + str(median)) a = np.where(data_dg <= 100) median1 = np.median(data_mg[a]) print('Flux median at dispersion <= 100 km/s is ' + str(median1)) Best regards, Didrik Langmoen Nilsen University of Alaska Anchorage Ski Team BBA Global Logistics & Supply Chain Managment C | +1 (907) 301 5507 E | dlnilsen at alaska.edu -------------- next part -------------- An HTML attachment was scrubbed... URL: From erik.m.bray at gmail.com Fri Apr 9 07:11:41 2021 From: erik.m.bray at gmail.com (E. Madison Bray) Date: Fri, 9 Apr 2021 13:11:41 +0200 Subject: [AstroPy] Plotting .fits data using filters In-Reply-To: References: Message-ID: Hi Didrik, I wonder what this part of your code is supposed to do: counter1 = 0 for i in ratio: counter2 = 0 for j in i: if j < 2: data_mg[counter1][counter2] = 'nan' data_dg[counter1][counter2] = 'nan' elif j == 'nan': data_mg[counter1][counter2] = 'nan' data_dg[counter1][counter2] = 'nan' counter1 = counter1 + 1 I'm curious, because I see you never advance "counter2" It is always 0. If I had to guess, you want to set every row in data_mg and data_dg to NaN where any value in the row is either less than 2 or NaN. But instead it is only setting the first element of each such row to NaN. Assuming I guessed correctly, here's a way you can do that with a bit of Numpy: This will give the row indexes for rows containing a value < 2 or NaN: >>> filt = np.where(np.any((ratio < 2) | np.isnan(ratio), axis=1)) You can use this to set the corresponding rows in data_mg and data_dg: >>> data_mg[filt] = np.nan >>> data_dg[filt] = np.nan Hope that helps, though I'm not sure if that's what you want. Please follow up with clarification otherwise. On Thu, Apr 8, 2021 at 2:14 AM Didrik Nilsen wrote: > > I am doing a research project in Astronomy where I am supposed to analyze three different pictures. I am using several different packages to extract the data from every pixel in every picture. To make sure that my data is reliable I am dividing one picture of one galaxy by another picture of the same galaxy, but the second picture is an error picture. To make sure my data is reliable I am dividing the two arrays by each other to get a ratio in order to plot and calculate the median with proper data. I think I have gotten the median right, but my plots are not. There are far too many plots based on the elements in the ratio array which is 23. Please help me. Here is my code. I can supply more info about the project if needed. > > glx_list = os.listdir(r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\H2_Maps-20210201T082125Z-001\H2_Maps') > > hello = 0 > > for i in glx_list: > > image_data_dg = 0 > > print(i) > > map_gau = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\SiVI_Maps-20210201T084648Z-001\SiVI_Maps' + '\\' + i + '\\SiVI\\Spat3\\map_gau.fits' > > map_gau_err = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\SiVI_Maps-20210201T084648Z-001\SiVI_Maps' + '\\' + i + '\\SiVI\\Spat3\\map_gau_err.fits' > > disp_gau = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\H2_Maps-20210201T082125Z-001\H2_Maps' + '\\' + i + '\\H2\\Spat3\\disp_gau.fits' > > image_data_dg = fits.open(disp_gau) > > image_data_mg = fits.open(map_gau) > > image_data_err = fits.open(map_gau_err) > > dshape = image_data_mg[0].data.shape > > dshape = np.subtract(dshape, (1, 1)) > > y, x = dshape > > data_mg = image_data_mg[0].data[0:x, 0:y].astype('float') > > data_err = image_data_err[0].data[0:x, 0:y].astype('float') > > data_dg = image_data_dg[0].data[0:x, 0:y].astype('float') > > data_mg[data_mg == 0] = 'nan' > > data_err[data_err == 0] = 'nan' > > data_dg[data_dg == 0] = 'nan' > > ratio = np.divide(data_mg[0:x, 0:y], data_err[0:x, 0:y]) > > low_snr = (ratio < 2) > > bad_pixel = (ratio == np.nan) > > mask = ~(low_snr & bad_pixel) > > counter1 = 0 > > for i in ratio: > > counter2 = 0 > > for j in i: > > if j < 2: > > data_mg[counter1][counter2] = 'nan' > > data_dg[counter1][counter2] = 'nan' > > elif j == 'nan': > > data_mg[counter1][counter2] = 'nan' > > data_dg[counter1][counter2] = 'nan' > > counter1 = counter1 + 1 > > plt.scatter(data_mg, data_dg) > > plt.xlim(0, .2) > > plt.ylim(0, 500) > > #plt.savefig('plot' + str(hello)) > > hello = hello + 1 > > plt.show() > > if hello == 1: > > break > > plt.clf() > > > > > > data_mg = np.ndarray.flatten(data_mg) > > data_mg = data_mg[np.logical_not(np.isnan(data_mg))] > > data_dg = np.ndarray.flatten(data_dg) > > data_dg = data_dg[np.logical_not(np.isnan(data_dg))] > > > > b = np.where(np.array(data_dg > 100)) > > > > median = np.median(data_mg[b]) > > print('Flux median at dispersion > 100 km/s is ' + str(median)) > > a = np.where(data_dg <= 100) > > median1 = np.median(data_mg[a]) > > print('Flux median at dispersion <= 100 km/s is ' + str(median1)) > > > > > > Best regards, > > > > Didrik Langmoen Nilsen > > University of Alaska Anchorage Ski Team > > BBA Global Logistics & Supply Chain Managment > > > > C | +1 (907) 301 5507 > > E | dlnilsen at alaska.edu > > > > > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy From didrik.nilsen at live.no Sun Apr 11 00:22:35 2021 From: didrik.nilsen at live.no (Didrik Nilsen) Date: Sun, 11 Apr 2021 04:22:35 +0000 Subject: [AstroPy] Plotting .fits data using filters In-Reply-To: References: Message-ID: Hi Madison, Thanks for the feedback. I kind of understand what you mean with the code, but I am not sure what to replace it with. This is a little bit of a long shot, but is there any way you would be able to help me with this over zoom? Didrik -----Original Message----- From: AstroPy On Behalf Of E. Madison Bray Sent: Friday, April 9, 2021 3:12 AM To: Astronomical Python mailing list Subject: Re: [AstroPy] Plotting .fits data using filters Hi Didrik, I wonder what this part of your code is supposed to do: counter1 = 0 for i in ratio: counter2 = 0 for j in i: if j < 2: data_mg[counter1][counter2] = 'nan' data_dg[counter1][counter2] = 'nan' elif j == 'nan': data_mg[counter1][counter2] = 'nan' data_dg[counter1][counter2] = 'nan' counter1 = counter1 + 1 I'm curious, because I see you never advance "counter2" It is always 0. If I had to guess, you want to set every row in data_mg and data_dg to NaN where any value in the row is either less than 2 or NaN. But instead it is only setting the first element of each such row to NaN. Assuming I guessed correctly, here's a way you can do that with a bit of Numpy: This will give the row indexes for rows containing a value < 2 or NaN: >>> filt = np.where(np.any((ratio < 2) | np.isnan(ratio), axis=1)) You can use this to set the corresponding rows in data_mg and data_dg: >>> data_mg[filt] = np.nan >>> data_dg[filt] = np.nan Hope that helps, though I'm not sure if that's what you want. Please follow up with clarification otherwise. On Thu, Apr 8, 2021 at 2:14 AM Didrik Nilsen wrote: > > I am doing a research project in Astronomy where I am supposed to analyze three different pictures. I am using several different packages to extract the data from every pixel in every picture. To make sure that my data is reliable I am dividing one picture of one galaxy by another picture of the same galaxy, but the second picture is an error picture. To make sure my data is reliable I am dividing the two arrays by each other to get a ratio in order to plot and calculate the median with proper data. I think I have gotten the median right, but my plots are not. There are far too many plots based on the elements in the ratio array which is 23. Please help me. Here is my code. I can supply more info about the project if needed. > > glx_list = os.listdir(r'C:\Users\didri\Documents\Spring2021\PHYS481 > Individual Research\H2_Maps-20210201T082125Z-001\H2_Maps') > > hello = 0 > > for i in glx_list: > > image_data_dg = 0 > > print(i) > > map_gau = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\SiVI_Maps-20210201T084648Z-001\SiVI_Maps' + '\\' + i + '\\SiVI\\Spat3\\map_gau.fits' > > map_gau_err = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\SiVI_Maps-20210201T084648Z-001\SiVI_Maps' + '\\' + i + '\\SiVI\\Spat3\\map_gau_err.fits' > > disp_gau = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\H2_Maps-20210201T082125Z-001\H2_Maps' + '\\' + i + '\\H2\\Spat3\\disp_gau.fits' > > image_data_dg = fits.open(disp_gau) > > image_data_mg = fits.open(map_gau) > > image_data_err = fits.open(map_gau_err) > > dshape = image_data_mg[0].data.shape > > dshape = np.subtract(dshape, (1, 1)) > > y, x = dshape > > data_mg = image_data_mg[0].data[0:x, 0:y].astype('float') > > data_err = image_data_err[0].data[0:x, 0:y].astype('float') > > data_dg = image_data_dg[0].data[0:x, 0:y].astype('float') > > data_mg[data_mg == 0] = 'nan' > > data_err[data_err == 0] = 'nan' > > data_dg[data_dg == 0] = 'nan' > > ratio = np.divide(data_mg[0:x, 0:y], data_err[0:x, 0:y]) > > low_snr = (ratio < 2) > > bad_pixel = (ratio == np.nan) > > mask = ~(low_snr & bad_pixel) > > counter1 = 0 > > for i in ratio: > > counter2 = 0 > > for j in i: > > if j < 2: > > data_mg[counter1][counter2] = 'nan' > > data_dg[counter1][counter2] = 'nan' > > elif j == 'nan': > > data_mg[counter1][counter2] = 'nan' > > data_dg[counter1][counter2] = 'nan' > > counter1 = counter1 + 1 > > plt.scatter(data_mg, data_dg) > > plt.xlim(0, .2) > > plt.ylim(0, 500) > > #plt.savefig('plot' + str(hello)) > > hello = hello + 1 > > plt.show() > > if hello == 1: > > break > > plt.clf() > > > > > > data_mg = np.ndarray.flatten(data_mg) > > data_mg = data_mg[np.logical_not(np.isnan(data_mg))] > > data_dg = np.ndarray.flatten(data_dg) > > data_dg = data_dg[np.logical_not(np.isnan(data_dg))] > > > > b = np.where(np.array(data_dg > 100)) > > > > median = np.median(data_mg[b]) > > print('Flux median at dispersion > 100 km/s is ' + str(median)) > > a = np.where(data_dg <= 100) > > median1 = np.median(data_mg[a]) > > print('Flux median at dispersion <= 100 km/s is ' + str(median1)) > > > > > > Best regards, > > > > Didrik Langmoen Nilsen > > University of Alaska Anchorage Ski Team > > BBA Global Logistics & Supply Chain Managment > > > > C | +1 (907) 301 5507 > > E | dlnilsen at alaska.edu > > > > > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy _______________________________________________ AstroPy mailing list AstroPy at python.org https://mail.python.org/mailman/listinfo/astropy From jimmyboysingh at gmail.com Sun Apr 11 09:08:05 2021 From: jimmyboysingh at gmail.com (Jim Singh) Date: Sun, 11 Apr 2021 23:08:05 +1000 Subject: [AstroPy] Query for Messier objects in a given region Message-ID: Hi, I've put together a sky simulation using mathplotlib to display and name the bright stars (size based on magnitude) within a certain radius of a given planet. I convert the RA/Dec of each object to Alt/Az based on my location and current time, and then flip the Az axis so that the field plot matches the sky through my finderscope. What I'd like to finally do is include and label any Messier catalog object in the same FOV of the plot. So is there an online catalog you would suggest that can be queried by region to return the following for objects in said region: -Messier Number -Apparent Magnitude (preferable but not essential) -RA/Dec I see SIMBAD supports query for a specified Messier object like this: result_table = Simbad.query_object("m83") and there's also Simbad.query_region and Simbad.query_criteria but I am not sure how they might be used for the stated objective (if at all)? Regards, Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: From ejensen1 at swarthmore.edu Sun Apr 11 10:40:29 2021 From: ejensen1 at swarthmore.edu (Eric Jensen) Date: Sun, 11 Apr 2021 10:40:29 -0400 Subject: [AstroPy] Query for Messier objects in a given region In-Reply-To: References: Message-ID: <865D3011-BC21-4155-A35A-7A76C091937C@swarthmore.edu> Hi Jim, The total number of Messier objects is small, so I think you might just want to download and store locally a table of their coordinates and properties (e.g. in a spreadsheet) that you could read into your code each time. Then in your Python code you could do something like this: - read spreadsheet to pandas data frame (pandas.read_excel) - convert to astropy table (Table.from_pandas) - use astropy coordinate routines to calculate angular distance from your field center to each object in the table - apply a filter to keep only those objects within a given angular distance. This would have the advantage that you could edit that Messier list to tweak it however you wanted, e.g. to combine columns from different sources if one has coords and another has magnitudes. If you can?t find a suitable Messier list, you could even write a one-time routine to loop over Simbad calls to build and store it, but I bet you can find most/all of what you need already formatted somewhere. Astropy docs will help you with specific syntax, but this should get you started. Eric > On Apr 11, 2021, at 9:08 AM, Jim Singh wrote: > > ? > Hi, I've put together a sky simulation using mathplotlib to display and name the bright stars (size based on magnitude) within a certain radius of a given planet. I convert the RA/Dec of each object to Alt/Az based on my location and current time, and then flip the Az axis so that the field plot matches the sky through my finderscope. What I'd like to finally do is include and label any Messier catalog object in the same FOV of the plot. > So is there an online catalog you would suggest that can be queried by region to return the following for objects in said region: > -Messier Number > -Apparent Magnitude (preferable but not essential) > -RA/Dec > I see SIMBAD supports query for a specified Messier object like this: > result_table = Simbad.query_object("m83") > and there's also Simbad.query_region and Simbad.query_criteria > but I am not sure how they might be used for the stated objective (if at all)? > Regards, > Jim > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2483 bytes Desc: not available URL: From jimmyboysingh at gmail.com Sun Apr 11 20:22:24 2021 From: jimmyboysingh at gmail.com (Jim Singh) Date: Mon, 12 Apr 2021 10:22:24 +1000 Subject: [AstroPy] Query for Messier objects in a given region In-Reply-To: <865D3011-BC21-4155-A35A-7A76C091937C@swarthmore.edu> References: <865D3011-BC21-4155-A35A-7A76C091937C@swarthmore.edu> Message-ID: Thanks Eric! What you suggest is certainly an option, but in the first instance I wanted to see if I could get away without having to download and store any reference data locally. Also, do not RA/Dec values drift over time, so real-time DB access assures the latest for one's plots? Noticed the following query from SIMBAD seems to return rows for all 110 Messier objects and executes fast, so I suppose I can now apply the last couple of steps you mention: - use astropy coordinate routines to calculate angular distance from your field center to each object in the table - apply a filter to keep only those objects within a given angular distance result_table = Simbad.query_object("m *",wildcard=True) print(result_table) On Mon, Apr 12, 2021 at 12:41 AM Eric Jensen wrote: > Hi Jim, > > The total number of Messier objects is small, so I think you might just > want to download and store locally a table of their coordinates and > properties (e.g. in a spreadsheet) that you could read into your code each > time. Then in your Python code you could do something like this: > > - read spreadsheet to pandas data frame (pandas.read_excel) > - convert to astropy table (Table.from_pandas) > - use astropy coordinate routines to calculate angular distance from your > field center to each object in the table > - apply a filter to keep only those objects within a given angular > distance. > > This would have the advantage that you could edit that Messier list to > tweak it however you wanted, e.g. to combine columns from different sources > if one has coords and another has magnitudes. > > If you can?t find a suitable Messier list, you could even write a one-time > routine to loop over Simbad calls to build and store it, but I bet you can > find most/all of what you need already formatted somewhere. > > Astropy docs will help you with specific syntax, but this should get you > started. > > Eric > > > > On Apr 11, 2021, at 9:08 AM, Jim Singh wrote: > > > > ? > > Hi, I've put together a sky simulation using mathplotlib to display and > name the bright stars (size based on magnitude) within a certain radius of > a given planet. I convert the RA/Dec of each object to Alt/Az based on my > location and current time, and then flip the Az axis so that the field plot > matches the sky through my finderscope. What I'd like to finally do is > include and label any Messier catalog object in the same FOV of the plot. > > > So is there an online catalog you would suggest that can be queried by > region to return the following for objects in said region: > > -Messier Number > > -Apparent Magnitude (preferable but not essential) > > -RA/Dec > > I see SIMBAD supports query for a specified Messier object like this: > > result_table = Simbad.query_object("m83") > > and there's also Simbad.query_region and Simbad.query_criteria > > but I am not sure how they might be used for the stated objective (if at > all)? > > Regards, > > Jim > > > > _______________________________________________ > > AstroPy mailing list > > AstroPy at python.org > > https://mail.python.org/mailman/listinfo/astropy > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jimmyboysingh at gmail.com Sun Apr 11 20:24:43 2021 From: jimmyboysingh at gmail.com (Jim Singh) Date: Mon, 12 Apr 2021 10:24:43 +1000 Subject: [AstroPy] Query for Messier objects in a given region In-Reply-To: <865D3011-BC21-4155-A35A-7A76C091937C@swarthmore.edu> References: <865D3011-BC21-4155-A35A-7A76C091937C@swarthmore.edu> Message-ID: Thanks Eric! What you suggest is certainly an option, but in the first instance I wanted to see if I could get away without having to download and store any reference data locally. Also, do not RA/Dec values drift over time, so real-time DB access assures the latest for one's plots? Noticed the following query from SIMBAD seems to return rows for all 110 Messier objects and executes fast, so I suppose I can now apply the last couple of steps you mention: *- use astropy coordinate routines to calculate angular distance from your field center to each object in the table- apply a filter to keep only those objects within a given angular distance * result_table = Simbad.query_object("m *",wildcard=True) print(result_table) MAIN_ID RA DEC ... COO_WAVELENGTH COO_BIBCODE "h:m:s" "d:m:s" ... --------- ------------- ------------- ... -------------- ------------------- M 1 05 34 31.94 +22 00 52.2 ... R 2011A&A...533A..10L M 2 21 33 27.02 -00 49 23.7 ... O 2010AJ....140.1830G M 3 13 42 11.62 +28 22 38.2 ... O 2010AJ....140.1830G M 4 16 23 35.22 -26 31 32.7 ... O 2010AJ....140.1830G M 5 15 18 33.22 +02 04 51.7 ... O 2010AJ....140.1830G NGC 6405 17 40 20 -32 15.2 ... O 2009MNRAS.399.2146W NGC 6475 17 53 51 -34 47.6 ... O 2009MNRAS.399.2146W M 8 18 03 37 -24 23.2 ... M 9 17 19 11.78 -18 30 58.5 ... 2002MNRAS.332..441F M 10 16 57 09.05 -04 06 01.1 ... O 2010AJ....140.1830G ... ... ... ... ... ... M 101 14 03 12.583 +54 20 55.50 ... I 2006AJ....131.1163S M 102 15 06 29.561 +55 45 47.91 ... I 2006AJ....131.1163S M 103 01 33 23 +60 39.0 ... O 2009MNRAS.399.2146W M 104 12 39 59.4318 -11 37 22.995 ... R 2004AJ....127.3587F M 105 10 47 49.600 +12 34 53.87 ... I 2006AJ....131.1163S M 106 12 18 57.620 +47 18 13.39 ... I 2006AJ....131.1163S M 107 16 32 31.86 -13 03 13.6 ... O 2010AJ....140.1830G M 108 11 11 30.967 +55 40 26.84 ... I 2006AJ....131.1163S M 109 11 57 35.984 +53 22 28.27 ... I 2006AJ....131.1163S M 110 00 40 22.0544 +41 41 07.496 ... O 2018yCat.1345....0G Length = 110 rows Regards, Jim On Mon, Apr 12, 2021 at 12:41 AM Eric Jensen wrote: > Hi Jim, > > The total number of Messier objects is small, so I think you might just > want to download and store locally a table of their coordinates and > properties (e.g. in a spreadsheet) that you could read into your code each > time. Then in your Python code you could do something like this: > > - read spreadsheet to pandas data frame (pandas.read_excel) > - convert to astropy table (Table.from_pandas) > - use astropy coordinate routines to calculate angular distance from your > field center to each object in the table > - apply a filter to keep only those objects within a given angular > distance. > > This would have the advantage that you could edit that Messier list to > tweak it however you wanted, e.g. to combine columns from different sources > if one has coords and another has magnitudes. > > If you can?t find a suitable Messier list, you could even write a one-time > routine to loop over Simbad calls to build and store it, but I bet you can > find most/all of what you need already formatted somewhere. > > Astropy docs will help you with specific syntax, but this should get you > started. > > Eric > > > > On Apr 11, 2021, at 9:08 AM, Jim Singh wrote: > > > > ? > > Hi, I've put together a sky simulation using mathplotlib to display and > name the bright stars (size based on magnitude) within a certain radius of > a given planet. I convert the RA/Dec of each object to Alt/Az based on my > location and current time, and then flip the Az axis so that the field plot > matches the sky through my finderscope. What I'd like to finally do is > include and label any Messier catalog object in the same FOV of the plot. > > > So is there an online catalog you would suggest that can be queried by > region to return the following for objects in said region: > > -Messier Number > > -Apparent Magnitude (preferable but not essential) > > -RA/Dec > > I see SIMBAD supports query for a specified Messier object like this: > > result_table = Simbad.query_object("m83") > > and there's also Simbad.query_region and Simbad.query_criteria > > but I am not sure how they might be used for the stated objective (if at > all)? > > Regards, > > Jim > > > > _______________________________________________ > > AstroPy mailing list > > AstroPy at python.org > > https://mail.python.org/mailman/listinfo/astropy > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ejensen1 at swarthmore.edu Mon Apr 12 08:23:33 2021 From: ejensen1 at swarthmore.edu (Eric Jensen) Date: Mon, 12 Apr 2021 08:23:33 -0400 Subject: [AstroPy] Query for Messier objects in a given region In-Reply-To: References: Message-ID: Hi Jim, > On Apr 11, 2021, at 8:25 PM, Jim Singh wrote: > > What you suggest is certainly an option, but in the first instance I wanted to see if I could get away without having to download and store any reference data locally. Also, do not RA/Dec values drift over time, so real-time DB access assures the latest for one's plots? The direction of Earth?s pole is constantly changing due to precession, but the coordinates of objects in catalogs are tabulated at a fixed reference date (called the *equinox* of the coordinates, currently usually the year 2000). So you won?t get ?fresher? coordinates by downloading them each time - they will always be the same. (And it will always be slower to download the list than to read it from a local file.). Also, precession doesn?t change the positions of objects *relative to each other* - it just slowly moves the grid. For high-proper-motion objects (like asteroids or other solar system objects) you do need to update coordinates for the current date (to correct for the objects? intrinsic space motion rather than the slow drift of the pole), but that?s not an issue for Messier objects or bright stars - those objects? proper motions are negligible for your purposes. Eric -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2483 bytes Desc: not available URL: From dburke.gw at gmail.com Mon Apr 12 14:42:25 2021 From: dburke.gw at gmail.com (Doug Burke) Date: Mon, 12 Apr 2021 14:42:25 -0400 Subject: [AstroPy] Query for Messier objects in a given region In-Reply-To: References: Message-ID: Jim, I second Eric's suggestion that you store the database contents for searches/queries that are not likely to change if possible. I know of one person who recently had to take down a really useful Astronomy-based web service because they were being flooded with requests for data just like the Messier catalog - i.e. something that doesn't change often - which ended up causing the hosting service to stop supporting it. There's also the environmental cost of repeatedly requesting information that doesn't change (something I know my code should be more aware of). Doug On Mon, Apr 12, 2021 at 8:24 AM Eric Jensen wrote: > Hi Jim, > > > On Apr 11, 2021, at 8:25 PM, Jim Singh wrote: > > > > What you suggest is certainly an option, but in the first instance I > wanted to see if I could get away without having to download and store any > reference data locally. Also, do not RA/Dec values drift over time, so > real-time DB access assures the latest for one's plots? > > The direction of Earth?s pole is constantly changing due to precession, > but the coordinates of objects in catalogs are tabulated at a fixed > reference date (called the *equinox* of the coordinates, currently usually > the year 2000). So you won?t get ?fresher? coordinates by downloading them > each time - they will always be the same. (And it will always be slower to > download the list than to read it from a local file.). Also, precession > doesn?t change the positions of objects *relative to each other* - it just > slowly moves the grid. > > For high-proper-motion objects (like asteroids or other solar system > objects) you do need to update coordinates for the current date (to correct > for the objects? intrinsic space motion rather than the slow drift of the > pole), but that?s not an issue for Messier objects or bright stars - those > objects? proper motions are negligible for your purposes. > > Eric > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jimmyboysingh at gmail.com Tue Apr 13 09:28:12 2021 From: jimmyboysingh at gmail.com (Jim Singh) Date: Tue, 13 Apr 2021 23:28:12 +1000 Subject: [AstroPy] Query for Messier objects in a given region In-Reply-To: References: Message-ID: Thanks Eric and Doug, as a 'proof of concept' I believe I've got the real time plotting of both Bright stars and M objects around a given planet, working now. However, in practice I will access a local Messier table like you suggest, for the reasons you mention. I am fetching the RA,Dec of a given planet thusly: planetName = "Neptune" c = (get_body(planetName, Time(datetime.utcnow()), location=None, ephemeris=None) planetRA = c3.ra.hourangle planetDec = c3.dec.deg So far the planet-neighbourhood patterns match (within acceptable bounds) what I'm seeing through the finderscope (at least for the planets currently visible), and with the SkEye app. My understanding from what you've said is that if I keep using the RA and Dec of stars and M objects based on the equinox 'J2000' reference (per the _RAJ2000', '_DEJ2000' Bright Star catalog columns and downloaded coords columns from SIMBAD), then years from now for this particular use case the agreement between the observed and plot will remain as sound as it is today. Regards, Jim On Tue, Apr 13, 2021 at 4:43 AM Doug Burke wrote: > > Jim, > > I second Eric's suggestion that you store the database contents for > searches/queries that are not likely to change if possible. I know of one > person who recently had to take down a really useful Astronomy-based web > service because they were being flooded with requests for data just like > the Messier catalog - i.e. something that doesn't change often - which > ended up causing the hosting service to stop supporting it. There's also > the environmental cost of repeatedly requesting information that doesn't > change (something I know my code should be more aware of). > > Doug > > On Mon, Apr 12, 2021 at 8:24 AM Eric Jensen > wrote: > >> Hi Jim, >> >> > On Apr 11, 2021, at 8:25 PM, Jim Singh wrote: >> > >> > What you suggest is certainly an option, but in the first instance I >> wanted to see if I could get away without having to download and store any >> reference data locally. Also, do not RA/Dec values drift over time, so >> real-time DB access assures the latest for one's plots? >> >> The direction of Earth?s pole is constantly changing due to precession, >> but the coordinates of objects in catalogs are tabulated at a fixed >> reference date (called the *equinox* of the coordinates, currently usually >> the year 2000). So you won?t get ?fresher? coordinates by downloading them >> each time - they will always be the same. (And it will always be slower to >> download the list than to read it from a local file.). Also, precession >> doesn?t change the positions of objects *relative to each other* - it just >> slowly moves the grid. >> >> For high-proper-motion objects (like asteroids or other solar system >> objects) you do need to update coordinates for the current date (to correct >> for the objects? intrinsic space motion rather than the slow drift of the >> pole), but that?s not an issue for Messier objects or bright stars - those >> objects? proper motions are negligible for your purposes. >> >> Eric >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at python.org >> https://mail.python.org/mailman/listinfo/astropy >> > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erik.m.bray at gmail.com Thu Apr 15 02:42:04 2021 From: erik.m.bray at gmail.com (E. Madison Bray) Date: Thu, 15 Apr 2021 08:42:04 +0200 Subject: [AstroPy] Plotting .fits data using filters In-Reply-To: References: Message-ID: Hi Didrik, Perhaps before doing that you could just explain more about exactly what you're trying to do with this code. I wrote: > If I had to guess, you want to set every row in data_mg and data_dg to NaN where any value in the row is either less than 2 or NaN. But instead it is only setting the first element of each such row to NaN. Is that correct? Or not? On Sun, Apr 11, 2021 at 6:22 AM Didrik Nilsen wrote: > > Hi Madison, > > Thanks for the feedback. I kind of understand what you mean with the code, but I am not sure what to replace it with. This is a little bit of a long shot, but is there any way you would be able to help me with this over zoom? > > Didrik > > -----Original Message----- > From: AstroPy On Behalf Of E. Madison Bray > Sent: Friday, April 9, 2021 3:12 AM > To: Astronomical Python mailing list > Subject: Re: [AstroPy] Plotting .fits data using filters > > Hi Didrik, > > I wonder what this part of your code is supposed to do: > > counter1 = 0 > for i in ratio: > counter2 = 0 > for j in i: > if j < 2: > data_mg[counter1][counter2] = 'nan' > data_dg[counter1][counter2] = 'nan' > elif j == 'nan': > data_mg[counter1][counter2] = 'nan' > data_dg[counter1][counter2] = 'nan' > > counter1 = counter1 + 1 > > I'm curious, because I see you never advance "counter2" It is always 0. > > If I had to guess, you want to set every row in data_mg and data_dg to NaN where any value in the row is either less than 2 or NaN. But instead it is only setting the first element of each such row to NaN. > > Assuming I guessed correctly, here's a way you can do that with a bit of Numpy: > > This will give the row indexes for rows containing a value < 2 or NaN: > > >>> filt = np.where(np.any((ratio < 2) | np.isnan(ratio), axis=1)) > > You can use this to set the corresponding rows in data_mg and data_dg: > > >>> data_mg[filt] = np.nan > >>> data_dg[filt] = np.nan > > Hope that helps, though I'm not sure if that's what you want. Please follow up with clarification otherwise. > > On Thu, Apr 8, 2021 at 2:14 AM Didrik Nilsen wrote: > > > > I am doing a research project in Astronomy where I am supposed to analyze three different pictures. I am using several different packages to extract the data from every pixel in every picture. To make sure that my data is reliable I am dividing one picture of one galaxy by another picture of the same galaxy, but the second picture is an error picture. To make sure my data is reliable I am dividing the two arrays by each other to get a ratio in order to plot and calculate the median with proper data. I think I have gotten the median right, but my plots are not. There are far too many plots based on the elements in the ratio array which is 23. Please help me. Here is my code. I can supply more info about the project if needed. > > > > glx_list = os.listdir(r'C:\Users\didri\Documents\Spring2021\PHYS481 > > Individual Research\H2_Maps-20210201T082125Z-001\H2_Maps') > > > > hello = 0 > > > > for i in glx_list: > > > > image_data_dg = 0 > > > > print(i) > > > > map_gau = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\SiVI_Maps-20210201T084648Z-001\SiVI_Maps' + '\\' + i + '\\SiVI\\Spat3\\map_gau.fits' > > > > map_gau_err = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\SiVI_Maps-20210201T084648Z-001\SiVI_Maps' + '\\' + i + '\\SiVI\\Spat3\\map_gau_err.fits' > > > > disp_gau = r'C:\Users\didri\Documents\Spring2021\PHYS481 Individual Research\H2_Maps-20210201T082125Z-001\H2_Maps' + '\\' + i + '\\H2\\Spat3\\disp_gau.fits' > > > > image_data_dg = fits.open(disp_gau) > > > > image_data_mg = fits.open(map_gau) > > > > image_data_err = fits.open(map_gau_err) > > > > dshape = image_data_mg[0].data.shape > > > > dshape = np.subtract(dshape, (1, 1)) > > > > y, x = dshape > > > > data_mg = image_data_mg[0].data[0:x, 0:y].astype('float') > > > > data_err = image_data_err[0].data[0:x, 0:y].astype('float') > > > > data_dg = image_data_dg[0].data[0:x, 0:y].astype('float') > > > > data_mg[data_mg == 0] = 'nan' > > > > data_err[data_err == 0] = 'nan' > > > > data_dg[data_dg == 0] = 'nan' > > > > ratio = np.divide(data_mg[0:x, 0:y], data_err[0:x, 0:y]) > > > > low_snr = (ratio < 2) > > > > bad_pixel = (ratio == np.nan) > > > > mask = ~(low_snr & bad_pixel) > > > > counter1 = 0 > > > > for i in ratio: > > > > counter2 = 0 > > > > for j in i: > > > > if j < 2: > > > > data_mg[counter1][counter2] = 'nan' > > > > data_dg[counter1][counter2] = 'nan' > > > > elif j == 'nan': > > > > data_mg[counter1][counter2] = 'nan' > > > > data_dg[counter1][counter2] = 'nan' > > > > counter1 = counter1 + 1 > > > > plt.scatter(data_mg, data_dg) > > > > plt.xlim(0, .2) > > > > plt.ylim(0, 500) > > > > #plt.savefig('plot' + str(hello)) > > > > hello = hello + 1 > > > > plt.show() > > > > if hello == 1: > > > > break > > > > plt.clf() > > > > > > > > > > > > data_mg = np.ndarray.flatten(data_mg) > > > > data_mg = data_mg[np.logical_not(np.isnan(data_mg))] > > > > data_dg = np.ndarray.flatten(data_dg) > > > > data_dg = data_dg[np.logical_not(np.isnan(data_dg))] > > > > > > > > b = np.where(np.array(data_dg > 100)) > > > > > > > > median = np.median(data_mg[b]) > > > > print('Flux median at dispersion > 100 km/s is ' + str(median)) > > > > a = np.where(data_dg <= 100) > > > > median1 = np.median(data_mg[a]) > > > > print('Flux median at dispersion <= 100 km/s is ' + str(median1)) > > > > > > > > > > > > Best regards, > > > > > > > > Didrik Langmoen Nilsen > > > > University of Alaska Anchorage Ski Team > > > > BBA Global Logistics & Supply Chain Managment > > > > > > > > C | +1 (907) 301 5507 > > > > E | dlnilsen at alaska.edu > > > > > > > > > > > > _______________________________________________ > > AstroPy mailing list > > AstroPy at python.org > > https://mail.python.org/mailman/listinfo/astropy > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy From stuart at cadair.com Mon Apr 19 05:02:19 2021 From: stuart at cadair.com (Stuart Mumford) Date: Mon, 19 Apr 2021 10:02:19 +0100 Subject: [AstroPy] Governance/Election Working Group Message-ID: <066AAB33-DE68-4A1C-9514-1A7950ECACD5@getmailspring.com> Hello all, The Astropy Governance/Election Working Group had it?s first meeting last week and is tasked with following the procedures outlined in APE 0 and getting the new Astropy project governance to a steady state as described in the APE. The tasks we aim to accomplish are: Identify, according to the rules in APE 0, the initial group of voting members. Comfirm will all the initial members that they wish to become a voting member. Open nominations for and then hold an election for new voting members. Hold the first election for the Coordination Committee under the rules in APE 0. Having reviewed the timelines set out in APE 0, and taking into account the availability of the volunteer working group members, we are aiming to have: identified and confirmed the initial voting members by the end of May, held the first elections for new voting members by the mid July, and have elected the new CoCo by the start of September. It should be stressed, that this is the timeline we are aiming for and it may shift. The notes of the working group are public and can be seen here: https://docs.google.com/document/d/1kCUlHs7xdlP4cT7wkvJ1V28P6pyFgkPWJ1CCfiIKfJM/edit?usp=sharing Thanks, Stuart Mumford on behalf of the Governance/Election Working Group -------------- next part -------------- An HTML attachment was scrubbed... URL: From rbaer25 at gmail.com Mon Apr 19 09:40:06 2021 From: rbaer25 at gmail.com (Rudolf Baer) Date: Mon, 19 Apr 2021 15:40:06 +0200 Subject: [AstroPy] Blackbody plus power law fitting Message-ID: I am using the following code to fit a continuum from astropy.modeling import models from astropy.modeling import models, fitting from astropy.modeling.models import BlackBody from astropy import units as u x=x y=y model_1 = models.PowerLaw1D([1, 1, 1]) model_2 = models.BlackBody(1800*u.K,5) model_1_2=model_1+model_2 print(model_1_2) def _parameter_units_for_data_units(self, inputs_unit, outputs_unit): return {'amplitude_0': inputs_unit['x'], 'x_0': inputs_unit['x'], 'alpha': inputs_unit['x'], 'temperature': outputs_unit['y'], 'scale_1': inputs_unit['x'] } # Fit the data using combined model g_init = model_1_2(1) fit_g = fitting.LevMarLSQFitter() g = fit_g(g_init, x, y) # Plot the data with the best-fit model plt.figure(figsize=(8,5)) plt.plot(x, y, 'ko') plt.plot(x, t(x), 'b-', lw=2, label='Combined model') plt.xlabel('Wavelength AA') plt.ylabel('Flux') plt.legend(loc=2) x and y are the input data (x: lambda, y: flux) given without units. By definition the blackbody temperature is in Kelvin. This leads to a Unit conversion error in the combined model. Do I have a basic mistake in the code or what is the solution. Any help would be much appreciated. With kind regards Rudolf Baer -------------- next part -------------- An HTML attachment was scrubbed... URL: From derek at astro.physik.uni-goettingen.de Mon Apr 19 11:08:28 2021 From: derek at astro.physik.uni-goettingen.de (Derek Homeier) Date: Mon, 19 Apr 2021 17:08:28 +0200 Subject: [AstroPy] Blackbody plus power law fitting In-Reply-To: References: Message-ID: On 19 Apr 2021, at 3:40 pm, Rudolf Baer wrote: > > model_1 = models.PowerLaw1D([1, 1, 1]) This seems to be a typo? This would define a PowerLaw1D with a list (or array-like) as amplitude and should already raise a ValueError unless your input `x` happened to have shape (3, ) as well. To define a model with amplitude=1, x_0=1, alpha=1, use PowerLaw1D(1, 1, 1) (or just the defaults? ;-) > model_2 = models.BlackBody(1800*u.K,5) > model_1_2=model_1+model_2 > print(model_1_2) > > x and y are the input data (x: lambda, y: flux) given without units. By definition the blackbody temperature is in Kelvin. This leads to a Unit conversion error in the combined model. Do I have a basic mistake in the code or what is the solution. Any help would be much appreciated. > The error arises from the fact that a BlackBody() model always returns flux density as a Quantity (by default in `u/Unit('erg / (cm2 Hz s sr)?)`), thus you need to define the PowerLaw1D with `amplitude` also as a Quantity in compatible units (e.g. the above, or 'Jy / sr', or 'W / (m2 * micron * sr)' if you set the BlackBody `scale` parameter to a F_lambda unit as well or enable `spectral_density` equivalencies). HTH Derek From rbaer25 at gmail.com Mon Apr 19 12:24:44 2021 From: rbaer25 at gmail.com (Rudolf Baer) Date: Mon, 19 Apr 2021 18:24:44 +0200 Subject: [AstroPy] Blackbody plus power law fitting In-Reply-To: References: Message-ID: Hi Derek that was very fast. I will try it tomorrow. Many thanks !! Rudolf On Mon, Apr 19, 2021 at 5:14 PM Derek Homeier < derek at astro.physik.uni-goettingen.de> wrote: > On 19 Apr 2021, at 3:40 pm, Rudolf Baer wrote: > > > > model_1 = models.PowerLaw1D([1, 1, 1]) > > This seems to be a typo? This would define a PowerLaw1D with a list (or > array-like) as amplitude > and should already raise a ValueError unless your input `x` happened to > have shape (3, ) as well. > To define a model with amplitude=1, x_0=1, alpha=1, use PowerLaw1D(1, 1, > 1) (or just the defaults? ;-) > > > model_2 = models.BlackBody(1800*u.K,5) > > model_1_2=model_1+model_2 > > print(model_1_2) > > > > x and y are the input data (x: lambda, y: flux) given without units. By > definition the blackbody temperature is in Kelvin. This leads to a Unit > conversion error in the combined model. Do I have a basic mistake in the > code or what is the solution. Any help would be much appreciated. > > > The error arises from the fact that a BlackBody() model always returns > flux density as a Quantity > (by default in `u/Unit('erg / (cm2 Hz s sr)?)`), thus you need to define > the PowerLaw1D with `amplitude` > also as a Quantity in compatible units (e.g. the above, or 'Jy / sr', or > 'W / (m2 * micron * sr)' if you set > the BlackBody `scale` parameter to a F_lambda unit as well or enable > `spectral_density` equivalencies). > > HTH > Derek > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mirosaide at gmail.com Fri Apr 23 05:44:54 2021 From: mirosaide at gmail.com (Miro Saide) Date: Fri, 23 Apr 2021 11:44:54 +0200 Subject: [AstroPy] How to plot a time format with hours only? Message-ID: Hello all, I am using the following code to plot the rise and set of a particular star from a selected location on earth: import numpy as np import matplotlib.pyplot as plt from astropy.visualization import astropy_mpl_style, quantity_support plt.style.use(astropy_mpl_style) quantity_support() import astropy.units as u from astropy.time import Time from astropy.coordinates import SkyCoord, EarthLocation, AltAz from astroplan import download_IERS_A download_IERS_A from astroplan import Observer, FixedTarget #Latitude and LOngitude of some cities cities = [[-25.9553,32.5892],[-25.7069,28.2294],[-15.4166,28.2833],[-22.95764,18.49041],[-13.254308,34.301525]] cities = np.array(cities) time = Time("2000-11-12 11:00:00",format='iso') #Star target target = SkyCoord.from_name("Barnard's star") #Calculation of the rise and set time Location = Observer(latitude=cities[:,0]*u.deg, longitude=cities[:,1]*u.deg) star_rise_time = Location.target_rise_time(time, target, which='next') star_set_time = Location.target_set_time(time, target, which='next') #Get the time in iso format rise_1 = star_rise_time.iso set_1 = star_set_time.iso #Random values Random_valeus = [1600,2118,3000,2750,3500] #Plot the time against random values plt.plot(rise_1,Random_valeus, marker ='o',label = 'rise') plt.plot(set_1,Random_valeus, marker ='o',label = 'set') plt.xlabel('Time [Hours]') plt.ylabel('Random_valeus') plt.show() When I run this the time axis in the plot gets messy the values overlap and can't clearly see what is what. I wonder if there's is a way to plot this with hours only, neglecting the year, month, day, minutes, and seconds? Thanks in advance. *Ramiro Caisse Saide* *MPhil Research Student* Department of Physics University of Mauritius Contact Number: +258 845672884 Email: ramiro.saide at umail.uom.mu -------------- next part -------------- An HTML attachment was scrubbed... URL: From ejensen1 at swarthmore.edu Fri Apr 23 09:03:57 2021 From: ejensen1 at swarthmore.edu (Eric Jensen) Date: Fri, 23 Apr 2021 09:03:57 -0400 Subject: [AstroPy] How to plot a time format with hours only? In-Reply-To: References: Message-ID: <0571452B-CBF4-4A3F-8A89-D46272C5B7B3@swarthmore.edu> Hi Ramiro, I think you should be able to get just the hour of the rise or set time by using star_rise_time.ymdhms.hour If you want other components as well, you can use .year, .minute, etc. with that ymdhms format. Hope this helps - Eric > On Apr 23, 2021, at 5:44 AM, Miro Saide wrote: > > Hello all, > > I am using the following code to plot the rise and set of a particular star from a selected location on earth: > > import numpy as np > import matplotlib.pyplot as plt > from astropy.visualization import astropy_mpl_style, quantity_support > plt.style.use(astropy_mpl_style) > quantity_support() > import astropy.units as u > from astropy.time import Time > from astropy.coordinates import SkyCoord, EarthLocation, AltAz > from astroplan import download_IERS_A > download_IERS_A > from astroplan import Observer, FixedTarget > > #Latitude and LOngitude of some cities > cities = [[-25.9553,32.5892],[-25.7069,28.2294],[-15.4166,28.2833],[-22.95764,18.49041],[-13.254308,34.301525]] > cities = np.array(cities) > > time = Time("2000-11-12 11:00:00",format='iso') > > #Star target > target = SkyCoord.from_name("Barnard's star") > > > #Calculation of the rise and set time > Location = Observer(latitude=cities[:,0]*u.deg, longitude=cities[:,1]*u.deg) > star_rise_time = Location.target_rise_time(time, target, which='next') > star_set_time = Location.target_set_time(time, target, which='next') > > #Get the time in iso format > rise_1 = star_rise_time.iso > set_1 = star_set_time.iso > > > #Random values > Random_valeus = [1600,2118,3000,2750,3500] > > > #Plot the time against random values > > plt.plot(rise_1,Random_valeus, marker ='o',label = 'rise') > plt.plot(set_1,Random_valeus, marker ='o',label = 'set') > plt.xlabel('Time [Hours]') > plt.ylabel('Random_valeus') > plt.show() > > When I run this the time axis in the plot gets messy the values overlap and can't clearly see what is what. > > I wonder if there's is a way to plot this with hours only, neglecting the year, month, day, minutes, and seconds? > > Thanks in advance. > > Ramiro Caisse Saide > MPhil Research Student > Department of Physics > University of Mauritius > Contact Number: +258 845672884 > Email: ramiro.saide at umail.uom.mu -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4388 bytes Desc: not available URL: From pebarrett at gmail.com Fri Apr 23 09:38:21 2021 From: pebarrett at gmail.com (Paul Barrett) Date: Fri, 23 Apr 2021 09:38:21 -0400 Subject: [AstroPy] How to plot a time format with hours only? In-Reply-To: References: Message-ID: Check out the 'xticks' method, i.e., plt.xticks([x_values], [x_labels]) https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.xticks.html On Fri, Apr 23, 2021 at 5:45 AM Miro Saide wrote: > Hello all, > > I am using the following code to plot the rise and set of a particular > star from a selected location on earth: > > import numpy as np > import matplotlib.pyplot as plt > from astropy.visualization import astropy_mpl_style, quantity_support > plt.style.use(astropy_mpl_style) > quantity_support() > import astropy.units as u > from astropy.time import Time > from astropy.coordinates import SkyCoord, EarthLocation, AltAz > from astroplan import download_IERS_A > download_IERS_A > from astroplan import Observer, FixedTarget > > #Latitude and LOngitude of some cities > cities = > [[-25.9553,32.5892],[-25.7069,28.2294],[-15.4166,28.2833],[-22.95764,18.49041],[-13.254308,34.301525]] > cities = np.array(cities) > > time = Time("2000-11-12 11:00:00",format='iso') > > #Star target > target = SkyCoord.from_name("Barnard's star") > > > #Calculation of the rise and set time > Location = Observer(latitude=cities[:,0]*u.deg, > longitude=cities[:,1]*u.deg) > star_rise_time = Location.target_rise_time(time, target, which='next') > star_set_time = Location.target_set_time(time, target, which='next') > > #Get the time in iso format > rise_1 = star_rise_time.iso > set_1 = star_set_time.iso > > > #Random values > Random_valeus = [1600,2118,3000,2750,3500] > > > #Plot the time against random values > > plt.plot(rise_1,Random_valeus, marker ='o',label = 'rise') > plt.plot(set_1,Random_valeus, marker ='o',label = 'set') > plt.xlabel('Time [Hours]') > plt.ylabel('Random_valeus') > plt.show() > > When I run this the time axis in the plot gets messy the values overlap > and can't clearly see what is what. > > I wonder if there's is a way to plot this with hours only, neglecting the > year, month, day, minutes, and seconds? > > Thanks in advance. > > *Ramiro Caisse Saide* > *MPhil Research Student* > Department of Physics > University of Mauritius > Contact Number: +258 845672884 > Email: ramiro.saide at umail.uom.mu > > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mirosaide at gmail.com Tue Apr 27 06:20:56 2021 From: mirosaide at gmail.com (Miro Saide) Date: Tue, 27 Apr 2021 12:20:56 +0200 Subject: [AstroPy] How to plot a time format with hours only? In-Reply-To: References: Message-ID: Hi Eric, Thank you very much for that, it worked. Thank you Paul as well for your input. *Ramiro Caisse Saide* *MPhil Research Student* Department of Physics University of Mauritius Contact Number: +258 845672884 Email: ramiro.saide at umail.uom.mu Paul Barrett escreveu no dia sexta, 23/04/2021 ?(s) 15:39: > Check out the 'xticks' method, i.e., plt.xticks([x_values], [x_labels]) > > https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.xticks.html > > > On Fri, Apr 23, 2021 at 5:45 AM Miro Saide wrote: > >> Hello all, >> >> I am using the following code to plot the rise and set of a particular >> star from a selected location on earth: >> >> import numpy as np >> import matplotlib.pyplot as plt >> from astropy.visualization import astropy_mpl_style, quantity_support >> plt.style.use(astropy_mpl_style) >> quantity_support() >> import astropy.units as u >> from astropy.time import Time >> from astropy.coordinates import SkyCoord, EarthLocation, AltAz >> from astroplan import download_IERS_A >> download_IERS_A >> from astroplan import Observer, FixedTarget >> >> #Latitude and LOngitude of some cities >> cities = >> [[-25.9553,32.5892],[-25.7069,28.2294],[-15.4166,28.2833],[-22.95764,18.49041],[-13.254308,34.301525]] >> cities = np.array(cities) >> >> time = Time("2000-11-12 11:00:00",format='iso') >> >> #Star target >> target = SkyCoord.from_name("Barnard's star") >> >> >> #Calculation of the rise and set time >> Location = Observer(latitude=cities[:,0]*u.deg, >> longitude=cities[:,1]*u.deg) >> star_rise_time = Location.target_rise_time(time, target, which='next') >> star_set_time = Location.target_set_time(time, target, which='next') >> >> #Get the time in iso format >> rise_1 = star_rise_time.iso >> set_1 = star_set_time.iso >> >> >> #Random values >> Random_valeus = [1600,2118,3000,2750,3500] >> >> >> #Plot the time against random values >> >> plt.plot(rise_1,Random_valeus, marker ='o',label = 'rise') >> plt.plot(set_1,Random_valeus, marker ='o',label = 'set') >> plt.xlabel('Time [Hours]') >> plt.ylabel('Random_valeus') >> plt.show() >> >> When I run this the time axis in the plot gets messy the values overlap >> and can't clearly see what is what. >> >> I wonder if there's is a way to plot this with hours only, neglecting the >> year, month, day, minutes, and seconds? >> >> Thanks in advance. >> >> *Ramiro Caisse Saide* >> *MPhil Research Student* >> Department of Physics >> University of Mauritius >> Contact Number: +258 845672884 >> Email: ramiro.saide at umail.uom.mu >> >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at python.org >> https://mail.python.org/mailman/listinfo/astropy >> > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: