GAIA-HR 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,149 @@
1
+ import matplotlib.pyplot as plt
2
+ import pandas as pd
3
+ import numpy as np
4
+ from matplotlib.colors import LogNorm
5
+
6
+ #Applies matplotlib's built in dark theme
7
+ plt.style.use(["dark_background"])
8
+
9
+ def plot_hr(df, property_name = "bp_rp", cmap="coolwarm", log_plot=False):
10
+ """
11
+ The plot_hr function plots the HR diagram , using the data stored in dataframe. The stars are plotted with bp-rp on x axis and absolute magnitude on y axis.
12
+ Additonal properties(tempreature , surface gravity , radial velocity, metallicity,proper motion, mass , radius) of the stars can be compared using colormap.The
13
+ function supports both linear and logarithmic scaling
14
+
15
+ Args:
16
+ df(pandas.DataFrame):
17
+ A pandas dataset containing stellar data.
18
+ The data set must contain bp-rp, absolute magnitude
19
+ property_name(str, optional):
20
+ Default: "bp-rp"
21
+ Specifies which property of the stellar data will be used for the color map
22
+ cmap(str,optional):
23
+ Default: "coolwarm"
24
+ Specifies the matplotlib colormap used for the stars
25
+ log_plot(boolean,optional):
26
+ Default: False
27
+ To determine whether colorscale to be logarithmic or linear
28
+ True : logarithmic color scale
29
+ False : linear color scale
30
+ Return:
31
+ matplotlib.figure.Figure
32
+ The matplotlib figure object showing the H-R diagram using plt.show()
33
+ """
34
+
35
+ # Creates a new figure and axes object
36
+ fig, ax = plt.subplots(figsize=(12, 10))
37
+
38
+ #If log_plot is true the scatter plot uses logarithimic normalization
39
+ if log_plot:
40
+ scatter = ax.scatter(
41
+ df["bp_rp"],
42
+ df["mag"],
43
+ c=df[property_name],
44
+ cmap=cmap,
45
+ s=2,
46
+ norm = LogNorm(vmax=np.nanpercentile(df[property_name], 99)))
47
+
48
+ else:
49
+ scatter = ax.scatter(
50
+ df["bp_rp"],
51
+ df["mag"],
52
+ c=df[property_name],
53
+ cmap=cmap,
54
+ s=2,
55
+ vmax=np.nanpercentile(df[property_name], 99)) # Gives maximum color to top outliers
56
+
57
+ # In H-R diagram lower magnitude represents brighter stars , hence y axis is reverted
58
+ ax.invert_yaxis()
59
+
60
+ # Sets X-axis label to BP-RP
61
+ ax.set_xlabel("BP - RP", fontsize=15)
62
+ # Sets Y-axis label to Absolute magnitude
63
+ ax.set_ylabel("Absolute Magnitude", fontsize=15)
64
+
65
+ # Creates the title for the property currently being displayed by the colormap
66
+ ax.set_title(
67
+ f"HR Diagram Colored by {property_name}",
68
+ fontsize=15
69
+ )
70
+
71
+ # Creates a color bar associated witht the scatter plot
72
+ cbar = plt.colorbar(scatter)
73
+ # Labels the color bar according to the property
74
+ cbar.set_label(property_name, fontsize=12)
75
+
76
+ # Renders the entire H-R diagram on the screen
77
+ plt.show()
78
+
79
+
80
+
81
+ def plot_radec(df, property_name = "bp_rp", cmap="coolwarm", log_plot=False):
82
+ """
83
+ The plot_radec function plots a 2D plot of region , using the data stored in dataframe. The stars are plotted with right ascension on x axis and declination on y axis.
84
+ Additonal properties(tempreature , surface gravity , radial velocity, metallicity,proper motion, mass , radius) of the stars can be compared using colormap.The
85
+ function supports both linear and logarithmic scaling
86
+
87
+ Args:
88
+ df(pandas.DataFrame):
89
+ A pandas dataset containing stellar data.
90
+ The data set must contain bp-rp, absolute magnitude
91
+ property_name(str, optional):
92
+ Default: "bp-rp"
93
+ Specifies which property of the stellar data will be used for the color map
94
+ cmap(str,optional):
95
+ Default: "coolwarm"
96
+ Specifies the matplotlib colormap used for the stars
97
+ log_plot(boolean,optional):
98
+ Default: False
99
+ To determine whether colorscale to be logarithmic or linear
100
+ True :logarithmic color scale
101
+ False : linear color scale
102
+ Return:
103
+ matplotlib.figure.Figure
104
+ The matplotlib figure object showing the H-R diagram using plt.show()
105
+ """
106
+
107
+ # Creates a new figure and axes object
108
+ fig, ax = plt.subplots(figsize=(12, 10))
109
+
110
+ #If log_plot is true the scatter plot uses logarithimic normalization
111
+ if log_plot:
112
+ scatter = ax.scatter(
113
+ df["ra"],
114
+ df["dec"],
115
+ c=df[property_name],
116
+ cmap=cmap,
117
+ s=2,
118
+ norm = LogNorm(vmax=np.nanpercentile(df[property_name], 99)))
119
+
120
+ else:
121
+ scatter = ax.scatter(
122
+ df["ra"],
123
+ df["dec"],
124
+ c=df[property_name],
125
+ cmap=cmap,
126
+ s=2,
127
+ vmax=np.nanpercentile(df[property_name], 99)) # Gives maximum color to top outliers
128
+
129
+ # In H-R diagram lower magnitude represents brighter stars , hence y axis is reverted
130
+ ax.invert_yaxis()
131
+
132
+ # Sets X-axis label to BP-RP
133
+ ax.set_xlabel("Right Ascension (deg)", fontsize=15)
134
+ # Sets Y-axis label to Absolute magnitude
135
+ ax.set_ylabel("Declination (deg)", fontsize=15)
136
+
137
+ # Creates the title for the property currently being displayed by the colormap
138
+ ax.set_title(
139
+ f"HR Diagram Colored by {property_name}",
140
+ fontsize=15
141
+ )
142
+
143
+ # Creates a color bar associated witht the scatter plot
144
+ cbar = plt.colorbar(scatter)
145
+ # Labels the color bar according to the property
146
+ cbar.set_label(property_name, fontsize=12)
147
+
148
+ # Renders the entire H-R diagram on the screen
149
+ plt.show()
@@ -0,0 +1,409 @@
1
+ # Importing necessary packages
2
+ from astroquery.utils.tap.core import TapPlus
3
+ import pandas as pd
4
+ import numpy as np
5
+ from astroquery.gaia import Gaia
6
+ import pyvo
7
+ import os, sys
8
+
9
+
10
+
11
+ class HiddenPrints:
12
+ """Print Enabler/Disabler
13
+
14
+ Context Manager to prevent print statement from executing within the statement setup. (Source: https://stackoverflow.com/questions/8391411)
15
+ """
16
+
17
+ def __enter__(self):
18
+ """Enter function
19
+
20
+ Disables the print statement from executing when placed within the HiddenPrints statement.
21
+ """
22
+
23
+ self._original_stdout = sys.stdout
24
+ sys.stdout = open(os.devnull, 'w')
25
+
26
+ def __exit__(self, exc_type, exc_value, exc_traceback):
27
+ """Exit function
28
+
29
+ Enables the print statement during runs when outside the HiddenPrints statement.
30
+
31
+ Args:
32
+ exc_type: indicates class of exception.
33
+ exc_value: indicates type of exception . like divide_by_zero error, floating_point_error, which are types of arithmetic exception.
34
+ exc_traceback: traceback is a report which has all of the information needed to solve the exception.
35
+ """
36
+ sys.stdout.close()
37
+ sys.stdout = self._original_stdout
38
+
39
+ class ALL_SERVER:
40
+ """GAIA Server Status Checker
41
+
42
+ Checks if the GAIA servers are connecting to the system using a simple ADQL query and returns the connection status.
43
+ """
44
+ def check_gaia_server(self):
45
+ """ESA GAIA server checker
46
+
47
+ Function to verify the ESA GAIA server responsiveness.
48
+ """
49
+ try:
50
+ job = Gaia.launch_job("SELECT TOP 1 * FROM gaiadr3.gaia_source")
51
+ results = job.get_results()
52
+
53
+ print("GAIA Server is up and responding properly!")
54
+ print(f"Successfully retrieved {len(results)} row(s).")
55
+
56
+ return 1
57
+
58
+ except Exception as e:
59
+ print("GAIA Server is not responding")
60
+ print(f"Error details: {e}")
61
+
62
+ def check_vizier_server(self):
63
+ """TAPVizieR server checker
64
+
65
+ Function to verify the TAPVizier GAIA server responsiveness.
66
+ """
67
+ url = "http://tapvizier.u-strasbg.fr/TAPVizieR/tap"
68
+ print(f"Pinging {url}...")
69
+
70
+ try:
71
+ # Initialize connection
72
+ vizier_tap = TapPlus(url=url)
73
+
74
+ # Run the lightest possible query (just 1 row)
75
+ job = vizier_tap.launch_job("SELECT TOP 1 * FROM \"I/355/gaiadr3\"")
76
+ results = job.get_results()
77
+
78
+ print("VIZIER Server is UP and responding properly!")
79
+ print(f"Successfully retrieved {len(results)} row(s).")
80
+
81
+ return 1
82
+
83
+ except Exception as e:
84
+ print("VIZIER Server appears to be DOWN or unreachable.")
85
+ print(f"Error details: {e}")
86
+
87
+ def check_ari_server(self):
88
+ """ARI server checker
89
+
90
+ Function to verify the ARI GAIA server responsiveness.
91
+ """
92
+ url = "https://gaia.ari.uni-heidelberg.de/tap"
93
+ print(f"Pinging {url}...")
94
+
95
+ try:
96
+ # Initialize connection
97
+ ari_tap = TapPlus(url=url)
98
+
99
+ # Run the lightest possible query (just 1 row)
100
+ job = ari_tap.launch_job("SELECT TOP 1 * FROM gaiadr3.gaia_source_lite")
101
+ results = job.get_results()
102
+
103
+ print("ARI (Heidelberg) Server is UP and responding properly!")
104
+ print(f"Successfully retrieved {len(results)} row(s).")
105
+
106
+ return 1
107
+
108
+ except Exception as e:
109
+ print("ARI Server appears to be DOWN or unreachable.")
110
+ print(f"Error details: {e}")
111
+
112
+ def check_aip_server(self):
113
+ """AIP server checker
114
+
115
+ Function to verify the AIP GAIA server responsiveness.
116
+ """
117
+ url = "https://gaia.aip.de/tap"
118
+ print(f"Pinging {url}...")
119
+
120
+ try:
121
+ # Initialize connection using pyvo
122
+ service = pyvo.dal.TAPService(url)
123
+
124
+ # Run the lightest possible query (just 1 row)
125
+ # Force the format parameter directly on execution to bypass strict header negotiation
126
+ # (asked by AIP server while using TapPlus)
127
+ job = service.search("SELECT TOP 1 * FROM gaiadr3.gaia_source_lite", response_format='votable')
128
+
129
+ print("AIP (Potsdam) Server is UP and responding properly!")
130
+ print(f"Successfully retrieved {len(job)} row(s).")
131
+
132
+ return 1
133
+
134
+ except Exception as e:
135
+ print("AIP Server appears to be DOWN or unreachable.")
136
+ print(f"Error details: {e}")
137
+
138
+ def check_all_server(self):
139
+ """ Check the responsiveness of all GAIA servers
140
+
141
+ Verifies whether all the servers are responding and provides exceptions if it fails.
142
+ """
143
+ self.check_gaia_server()
144
+ print("\n")
145
+ self.check_vizier_server()
146
+ print("\n")
147
+ self.check_ari_server()
148
+ print("\n")
149
+ self.check_aip_server()
150
+
151
+
152
+ # Dictionaries to map columns from different servers to rename with a common name.
153
+
154
+ column_mapping = {'source_id':'sid',
155
+ 'ra':'ra',
156
+ 'dec':'dec',
157
+ 'parallax':'parallax',
158
+ 'phot_g_mean_mag':'g_mean_mag',
159
+ 'bp_rp':'bp_rp',
160
+ 'teff_gspphot':'teff',
161
+ 'logg_gspphot':'logg',
162
+ 'mh_gspphot': 'mh',
163
+ 'pm':'pm',
164
+ 'radial_velocity':'rv',
165
+ 'lum_flame':'lum_flame',
166
+ 'radius_flame':'radius_flame',
167
+ 'mass_flame':'mass_flame',}
168
+
169
+ column_mapping_Vizier = {'Source':'sid',
170
+ 'RA_ICRS':'ra',
171
+ 'DE_ICRS':'dec',
172
+ 'Plx':'parallax',
173
+ 'Gmag':'g_mean_mag',
174
+ 'BP-RP':'bp_rp',
175
+ 'Teff':'teff',
176
+ 'logg':'logg',
177
+ '[Fe/H]': 'mh',
178
+ 'PM':'pm',
179
+ 'RV':'rv',
180
+ 'Lum-Flame':'lum_flame',
181
+ 'Rad-Flame':'radius_flame',
182
+ 'Mass-Flame':'mass_flame',}
183
+
184
+ def fetch_gaia_data(ra, dec, radius, d_max = None, d_min = None, max_source = 10000, server = None, save_file = False, filename="gaia_data.csv"):
185
+ """Fetches a sample of star data from the Gaia DR3 dataset.
186
+
187
+ Executes ADQL query to retrive sources with parallax_over_error > 20 from user specified region.
188
+ Joins standard astrometric data with evaluated astrophysical parameters for available sources.
189
+ Function utilises a fallback mechanism, attempting to connect to multiple servers until successful
190
+ connections and query are made.
191
+
192
+ Args:
193
+ ra (float): Right Ascension of region you want to query (in degrees)
194
+ dec (float): Declination of region you want to query (in degrees)
195
+ radius (float): Radius of region you want to query (in degrees)
196
+ d_max (float, optional):
197
+ Default: None
198
+ Maximum distance to sources (in lightyears)
199
+ d_min (float, optional):
200
+ Default: None
201
+ Minimum diatance to sources (in lightyears)
202
+ max_sources (int, optional):
203
+ Default: 10000
204
+ Maximum number of sources to be queried
205
+ server (str, optional):
206
+ Default: None, Autoselects server
207
+ Name of server for querying. Available options : "gaia", "ari", "aip", "vizier"
208
+ save_file (bool, optional):
209
+ Default: False
210
+ Boolean to save fetched data as csv file
211
+ filename (str, optional):
212
+ Default: "gaia_data.csv"
213
+ Filename of saved csv file
214
+
215
+
216
+ Returns:
217
+ pandas.DataFrame: gaia star data
218
+ """
219
+
220
+ # Check to verify the entered RA, DEC, radius falls within their defined range.
221
+ if (ra < 0) or (ra > 360):
222
+ raise ValueError("The specified value of RA do not exist in the celestial system bar the server issue.")
223
+ elif (dec < -90) or (dec > 90):
224
+ raise ValueError("The specified value of DEC do not exist in the celestial system bar the server issue.")
225
+ elif (radius < 0) or (radius > 180):
226
+ raise ValueError("The specified value of radius is not Queryable or the ADQL query is not accepting the assigned value.")
227
+ else:
228
+ pass
229
+
230
+ if (max_source < 0):
231
+ print("Invalid max_source input. Defaulting to 10000")
232
+ max_source = 10000
233
+ elif (max_source > 1000000):
234
+ raise ValueError("Bruh! What is wrong with you? Do you want to crash you pc?")
235
+
236
+
237
+ conditions = ["AND gs.parallax_over_error > 20"]
238
+
239
+ if d_max is not None:
240
+ min_parallax = 3261.56 / d_max
241
+ conditions.append(f"\n AND gs.parallax >= {min_parallax}")
242
+ if d_min is not None:
243
+ max_parallax = 3261.56 / d_min
244
+ conditions.append(f"\n AND gs.parallax <= {max_parallax}")
245
+
246
+
247
+ # Query construction from user input
248
+ query = f"""
249
+ SELECT TOP {max_source}
250
+ gs.source_id,
251
+ gs.ra,
252
+ gs.dec,
253
+ gs.parallax,
254
+ gs.phot_g_mean_mag,
255
+ gs.bp_rp,
256
+ gs.teff_gspphot,
257
+ gs.logg_gspphot,
258
+ gs.mh_gspphot,
259
+ gs.pm,
260
+ gs.radial_velocity,
261
+ ap.lum_flame,
262
+ ap.radius_flame,
263
+ ap.mass_flame
264
+ FROM gaiadr3.gaia_source AS gs
265
+ JOIN gaiadr3.astrophysical_parameters AS ap
266
+ ON gs.source_id = ap.source_id
267
+ WHERE 1 = CONTAINS(
268
+ POINT('ICRS', gs.ra, gs.dec),
269
+ CIRCLE('ICRS', {ra}, {dec}, {radius})
270
+ )
271
+ """
272
+
273
+
274
+
275
+ for condition in conditions:
276
+ query += condition
277
+
278
+
279
+ # Server 1 : esa.gaia
280
+ if server is None or server == "gaia":
281
+ if ALL_SERVER().check_gaia_server() == 1 :
282
+
283
+ print("Connecting to main Gaia server")
284
+
285
+ job = Gaia.launch_job_async(query)
286
+ stars = job.get_results()
287
+ df = stars.to_pandas()
288
+
289
+ # Rename column names to have a common format
290
+ df = df.rename(columns=column_mapping, errors = 'raise')
291
+ df["mag"] = df["g_mean_mag"] + 5 + 5 * np.log10(df["parallax"] / 1000)
292
+
293
+ if save_file:
294
+ df.to_csv(filename, index=False)
295
+
296
+ return df
297
+
298
+ else:
299
+ raise ConnectionError("Gaia server is not responding. Kindly try again later or check another server!!")
300
+
301
+
302
+ # Server 2 : gaia.ari
303
+ if server is None or server == "ari":
304
+ if ALL_SERVER().check_ari_server() == 1:
305
+ url = "https://gaia.ari.uni-heidelberg.de/tap"
306
+ ari_tap = TapPlus(url=url)
307
+
308
+ print("Connecting to Heidelberg server")
309
+
310
+ job = ari_tap.launch_job_async(query)
311
+ stars = job.get_results()
312
+ df = stars.to_pandas()
313
+
314
+ # Rename column names to have a common format
315
+ df = df.rename(columns=column_mapping, errors = 'raise')
316
+ df["mag"] = df["g_mean_mag"] + 5 + 5 * np.log10(df["parallax"] / 1000)
317
+
318
+ if save_file:
319
+ df.to_csv(filename, index=False)
320
+
321
+ return df
322
+
323
+ else:
324
+ raise ConnectionError("ARI Heidelberg server is not responding. Kindly try again later or check another server!!")
325
+
326
+
327
+ # Server 3 : gaia.aip
328
+ if server is None or server == "aip":
329
+ if ALL_SERVER().check_aip_server() == 1:
330
+
331
+ url = "https://gaia.aip.de/tap"
332
+ service = pyvo.dal.TAPService(url)
333
+
334
+ print("Connecting to Potsdam server")
335
+
336
+ job = service.search(query, response_format='votable')
337
+ astropy_table = job.to_table()
338
+ df = df = astropy_table.to_pandas()
339
+
340
+ # Rename column names to have a common format
341
+ df = df.rename(columns=column_mapping, errors = 'raise')
342
+ df["mag"] = df["g_mean_mag"] + 5 + 5 * np.log10(df["parallax"] / 1000)
343
+
344
+ if save_file:
345
+ df.to_csv(filename, index=False)
346
+
347
+ return df
348
+
349
+ else:
350
+ raise ConnectionError("Potsdam AIP server is not responding. Kindly try again later or check another server!!")
351
+
352
+
353
+ # Server 4 : vizier
354
+ if server is None or server == "vizier":
355
+ if ALL_SERVER().check_vizier_server() == 1:
356
+
357
+ query = f"""
358
+ SELECT TOP {max_source}
359
+ gs.Source,
360
+ gs.RA_ICRS,
361
+ gs.DE_ICRS,
362
+ gs.Plx,
363
+ gs.Gmag,
364
+ gs."BP-RP",
365
+ gs.Teff,
366
+ gs.logg,
367
+ gs."[Fe/H]",
368
+ gs.PM,
369
+ gs.RV,
370
+ ap."Lum-Flame",
371
+ ap."Rad-Flame",
372
+ ap."Mass-Flame"
373
+ FROM "I/355/gaiadr3" AS gs
374
+ JOIN "I/355/paramp" AS ap
375
+ ON gs.Source = ap.Source
376
+ WHERE 1 = CONTAINS(
377
+ POINT('ICRS', gs.RA_ICRS, gs.DE_ICRS),
378
+ CIRCLE('ICRS', {ra}, {dec}, {radius})
379
+ )
380
+ AND RPlx > 20
381
+ """
382
+
383
+ url = "http://tapvizier.u-strasbg.fr/TAPVizieR/tap"
384
+ print(f"Connecting to {url}...")
385
+
386
+ vizier_tap = TapPlus(url=url)
387
+
388
+ print("Executing query...")
389
+ job = vizier_tap.launch_job(query)
390
+ results = job.get_results()
391
+
392
+ df = results.to_pandas()
393
+
394
+ # Rename column names to have a common format
395
+ df = df.rename(columns=column_mapping_Vizier, errors = 'raise')
396
+ df["mag"] = df["g_mean_mag"] + 5 + 5 * np.log10(df["parallax"] / 1000)
397
+
398
+ if save_file:
399
+ df.to_csv(filename, index=False)
400
+
401
+ return df
402
+
403
+ else:
404
+ raise ConnectionError("TAPVizier server is not responding. Kindly try again later or check another server!!")
405
+
406
+
407
+ # Edge case: No server response
408
+ else:
409
+ raise ConnectionError("No servers are responding. Kindly try again later!!")
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: GAIA_HR
3
+ Version: 1.1.0
4
+ Summary: Python package to plot Hertzsprung-Russel diagrams from gdr3 data
5
+ Author-email: Midhun Goutham Murali <midhungm8101@gmail.com>, Nirmal US <nirmalus24@gmail.com>, Anansh Jain <ananshjain10@gmail.com>
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: numpy
9
+ Requires-Dist: matplotlib
10
+ Requires-Dist: astroquery
11
+ Requires-Dist: pyvo
12
+ Requires-Dist: pandas
13
+ Dynamic: license-file
14
+
15
+ # GAIA_HR
16
+
17
+ Library that plots HR diagram from GAIA dataset
18
+
19
+ [![A rectangular badge, half black half purple containing the text made at Code Astro](https://img.shields.io/badge/Made%20at-Code/Astro-blueviolet.svg)](https://semaphorep.github.io/codeastro/)
20
+ ## Motivation
21
+
22
+ This package queries data and plots Hertzsprung-Russell diagram for a user specified region of the sky (ra, dec, radius) from Gaia data release 3 [1]. It also compares a user specified parameter of different stars in the region using a colormap.
23
+
24
+ ## Installation
25
+
26
+ The package is installable on Python 3.x. To install the package, simply write
27
+
28
+ `pip install Gaia_HR`
29
+
30
+ Otherwise, clone this repo, and follow the below specified commands
31
+
32
+ `cd Gaia_HR`
33
+
34
+ `pip install -e .`
35
+
36
+ A list of dependencies is available in requirements.txt
37
+
38
+ ## Additional Information
39
+
40
+ Gaia HR diagrams is valid when the the relative precision on parallax is lower than 20%. This uncertainity has been included by using the parameter "parallax_over_error > 20" during the query [2].
41
+
42
+ This work has made use of data from the European Space Agency (ESA) mission Gaia (https://www.cosmos.esa.int/gaia), processed by the Gaia Data Processing and Analysis Consortium (DPAC, https://www.cosmos.esa.int/web/gaia/dpac/consortium). Funding for the DPAC has been provided by national institutions, in particular the institutions participating in the Gaia Multilateral Agreement [1, 3].
43
+
44
+ This research has made use of the VizieR catalogue access tool, CDS, Strasbourg, France [4]. The original description of the VizieR service was published in 2000, A&AS 143, 23.
45
+
46
+ ## References:
47
+
48
+ 1. Gaia Data Release 3 - Summary of the content and survey properties. Gaia Collaboration, A. Vallenari, et al. A&A 674 A1 (2023). DOI: [10.1051/0004-6361/202243940](https://doi.org/10.1051/0004-6361/202243940)
49
+
50
+ 2. Gaia Data Release 2 - Observational Hertzsprung-Russell diagrams. Gaia Collaboration, C. Babusiaux, et al. A&A 616 A10 (2018). DOI: [10.1051/0004-6361/201832843](https://doi.org/10.1051/0004-6361/201832843)
51
+
52
+ 3. The Gaia mission. Gaia Collaboration, T. Prusti, et al. A&A 595 A1 (2016). DOI: [10.1051/0004-6361/201629272](https://doi.org/10.1051/0004-6361/201629272)
53
+
54
+ 4. The VizieR database of astronomical catalogues. F. Ochsenbein, P. Bauer, J. Marcout. Astron. Astrophys. Suppl. Ser. 143 (1) 23-32 (2000). [DOI: 10.1051/aas:2000169](https://doi.org/10.1051/aas:2000169)
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ GAIA_HR/__init__.py
5
+ GAIA_HR/plot.py
6
+ GAIA_HR/query.py
7
+ GAIA_HR.egg-info/PKG-INFO
8
+ GAIA_HR.egg-info/SOURCES.txt
9
+ GAIA_HR.egg-info/dependency_links.txt
10
+ GAIA_HR.egg-info/requires.txt
11
+ GAIA_HR.egg-info/top_level.txt
12
+ test/test_GAIA_HR.py
@@ -0,0 +1,5 @@
1
+ numpy
2
+ matplotlib
3
+ astroquery
4
+ pyvo
5
+ pandas
@@ -0,0 +1 @@
1
+ GAIA_HR
gaia_hr-1.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NirmalUS, AnanshJ, Midhu4
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
gaia_hr-1.1.0/PKG-INFO ADDED
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: GAIA_HR
3
+ Version: 1.1.0
4
+ Summary: Python package to plot Hertzsprung-Russel diagrams from gdr3 data
5
+ Author-email: Midhun Goutham Murali <midhungm8101@gmail.com>, Nirmal US <nirmalus24@gmail.com>, Anansh Jain <ananshjain10@gmail.com>
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: numpy
9
+ Requires-Dist: matplotlib
10
+ Requires-Dist: astroquery
11
+ Requires-Dist: pyvo
12
+ Requires-Dist: pandas
13
+ Dynamic: license-file
14
+
15
+ # GAIA_HR
16
+
17
+ Library that plots HR diagram from GAIA dataset
18
+
19
+ [![A rectangular badge, half black half purple containing the text made at Code Astro](https://img.shields.io/badge/Made%20at-Code/Astro-blueviolet.svg)](https://semaphorep.github.io/codeastro/)
20
+ ## Motivation
21
+
22
+ This package queries data and plots Hertzsprung-Russell diagram for a user specified region of the sky (ra, dec, radius) from Gaia data release 3 [1]. It also compares a user specified parameter of different stars in the region using a colormap.
23
+
24
+ ## Installation
25
+
26
+ The package is installable on Python 3.x. To install the package, simply write
27
+
28
+ `pip install Gaia_HR`
29
+
30
+ Otherwise, clone this repo, and follow the below specified commands
31
+
32
+ `cd Gaia_HR`
33
+
34
+ `pip install -e .`
35
+
36
+ A list of dependencies is available in requirements.txt
37
+
38
+ ## Additional Information
39
+
40
+ Gaia HR diagrams is valid when the the relative precision on parallax is lower than 20%. This uncertainity has been included by using the parameter "parallax_over_error > 20" during the query [2].
41
+
42
+ This work has made use of data from the European Space Agency (ESA) mission Gaia (https://www.cosmos.esa.int/gaia), processed by the Gaia Data Processing and Analysis Consortium (DPAC, https://www.cosmos.esa.int/web/gaia/dpac/consortium). Funding for the DPAC has been provided by national institutions, in particular the institutions participating in the Gaia Multilateral Agreement [1, 3].
43
+
44
+ This research has made use of the VizieR catalogue access tool, CDS, Strasbourg, France [4]. The original description of the VizieR service was published in 2000, A&AS 143, 23.
45
+
46
+ ## References:
47
+
48
+ 1. Gaia Data Release 3 - Summary of the content and survey properties. Gaia Collaboration, A. Vallenari, et al. A&A 674 A1 (2023). DOI: [10.1051/0004-6361/202243940](https://doi.org/10.1051/0004-6361/202243940)
49
+
50
+ 2. Gaia Data Release 2 - Observational Hertzsprung-Russell diagrams. Gaia Collaboration, C. Babusiaux, et al. A&A 616 A10 (2018). DOI: [10.1051/0004-6361/201832843](https://doi.org/10.1051/0004-6361/201832843)
51
+
52
+ 3. The Gaia mission. Gaia Collaboration, T. Prusti, et al. A&A 595 A1 (2016). DOI: [10.1051/0004-6361/201629272](https://doi.org/10.1051/0004-6361/201629272)
53
+
54
+ 4. The VizieR database of astronomical catalogues. F. Ochsenbein, P. Bauer, J. Marcout. Astron. Astrophys. Suppl. Ser. 143 (1) 23-32 (2000). [DOI: 10.1051/aas:2000169](https://doi.org/10.1051/aas:2000169)
@@ -0,0 +1,40 @@
1
+ # GAIA_HR
2
+
3
+ Library that plots HR diagram from GAIA dataset
4
+
5
+ [![A rectangular badge, half black half purple containing the text made at Code Astro](https://img.shields.io/badge/Made%20at-Code/Astro-blueviolet.svg)](https://semaphorep.github.io/codeastro/)
6
+ ## Motivation
7
+
8
+ This package queries data and plots Hertzsprung-Russell diagram for a user specified region of the sky (ra, dec, radius) from Gaia data release 3 [1]. It also compares a user specified parameter of different stars in the region using a colormap.
9
+
10
+ ## Installation
11
+
12
+ The package is installable on Python 3.x. To install the package, simply write
13
+
14
+ `pip install Gaia_HR`
15
+
16
+ Otherwise, clone this repo, and follow the below specified commands
17
+
18
+ `cd Gaia_HR`
19
+
20
+ `pip install -e .`
21
+
22
+ A list of dependencies is available in requirements.txt
23
+
24
+ ## Additional Information
25
+
26
+ Gaia HR diagrams is valid when the the relative precision on parallax is lower than 20%. This uncertainity has been included by using the parameter "parallax_over_error > 20" during the query [2].
27
+
28
+ This work has made use of data from the European Space Agency (ESA) mission Gaia (https://www.cosmos.esa.int/gaia), processed by the Gaia Data Processing and Analysis Consortium (DPAC, https://www.cosmos.esa.int/web/gaia/dpac/consortium). Funding for the DPAC has been provided by national institutions, in particular the institutions participating in the Gaia Multilateral Agreement [1, 3].
29
+
30
+ This research has made use of the VizieR catalogue access tool, CDS, Strasbourg, France [4]. The original description of the VizieR service was published in 2000, A&AS 143, 23.
31
+
32
+ ## References:
33
+
34
+ 1. Gaia Data Release 3 - Summary of the content and survey properties. Gaia Collaboration, A. Vallenari, et al. A&A 674 A1 (2023). DOI: [10.1051/0004-6361/202243940](https://doi.org/10.1051/0004-6361/202243940)
35
+
36
+ 2. Gaia Data Release 2 - Observational Hertzsprung-Russell diagrams. Gaia Collaboration, C. Babusiaux, et al. A&A 616 A10 (2018). DOI: [10.1051/0004-6361/201832843](https://doi.org/10.1051/0004-6361/201832843)
37
+
38
+ 3. The Gaia mission. Gaia Collaboration, T. Prusti, et al. A&A 595 A1 (2016). DOI: [10.1051/0004-6361/201629272](https://doi.org/10.1051/0004-6361/201629272)
39
+
40
+ 4. The VizieR database of astronomical catalogues. F. Ochsenbein, P. Bauer, J. Marcout. Astron. Astrophys. Suppl. Ser. 143 (1) 23-32 (2000). [DOI: 10.1051/aas:2000169](https://doi.org/10.1051/aas:2000169)
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "GAIA_HR"
7
+ version = "1.1.0"
8
+ description = "Python package to plot Hertzsprung-Russel diagrams from gdr3 data"
9
+ readme = "README.md"
10
+
11
+ dependencies = [
12
+ "numpy",
13
+ "matplotlib",
14
+ "astroquery",
15
+ "pyvo",
16
+ "pandas"
17
+ ]
18
+ authors = [
19
+ {name = "Midhun Goutham Murali", email = "midhungm8101@gmail.com"},
20
+ {name = "Nirmal US", email = "nirmalus24@gmail.com"},
21
+ {name = "Anansh Jain", email = "ananshjain10@gmail.com"},
22
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,48 @@
1
+ import pytest
2
+ import pandas as pd
3
+ from GAIA_HR import query
4
+ from GAIA_HR import plot
5
+ from unittest.mock import patch
6
+
7
+
8
+ def test_fetch_gaia_data():
9
+ """
10
+ Unit test to evaluate correctness of fetch_gaia_data() function
11
+ """
12
+ # Pleiades
13
+ df = query.fetch_gaia_data(56.75, 24.12, 2, d_min=300, d_max=600, max_source=20000, server="aip")
14
+
15
+ assert df.shape[0] == 1419
16
+ assert df.shape[1] == 15
17
+
18
+
19
+ def test_plot_hr():
20
+ """
21
+ Unit test to evaluate correctness of plot_hr() function
22
+ """
23
+ df = pd.read_csv("Sample_data.csv")
24
+ with patch("matplotlib.pyplot.show"):
25
+ plot.plot_hr(df, property_name="radius_flame", cmap="plasma", log_plot=True)
26
+
27
+
28
+ def test_plot_radec():
29
+ """
30
+ Unit test to evaluate correctness of plot_radec() function
31
+ """
32
+ df = pd.read_csv("Sample_data.csv")
33
+ with patch("matplotlib.pyplot.show"):
34
+ plot.plot_radec(df, property_name="radius_flame", cmap="plasma", log_plot=True)
35
+
36
+ def end_to_end_test():
37
+ """
38
+ End-to-end test to evaluate correctness of GAIA_HR module
39
+ """
40
+ df = query.fetch_gaia_data(56.75, 24.12, 2, d_min=300, d_max=600, max_source=20000, server="aip")
41
+
42
+ with patch("matplotlib.pyplot.show"):
43
+ plot.plot_hr(df, property_name="radius_flame", cmap="plasma", log_plot=True)
44
+ with patch("matplotlib.pyplot.show"):
45
+ plot.plot_radec(df, property_name="radius_flame", cmap="plasma", log_plot=True)
46
+
47
+ assert df.shape[0] == 1419
48
+ assert df.shape[1] == 15