MGCS-pytools 0.2.0__tar.gz → 0.2.1__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.
Files changed (28) hide show
  1. mgcs_pytools-0.2.1/PKG-INFO +47 -0
  2. mgcs_pytools-0.2.1/README.md +23 -0
  3. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/pyproject.toml +1 -1
  4. mgcs_pytools-0.2.1/src/MGCS_pytools.egg-info/PKG-INFO +47 -0
  5. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/MGCS_pytools.egg-info/SOURCES.txt +1 -2
  6. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/statistical_membership/dr_correction.py +30 -0
  7. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/statistical_membership/membership.py +14 -5
  8. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/utils/plotting.py +15 -12
  9. mgcs_pytools-0.2.0/PKG-INFO +0 -25
  10. mgcs_pytools-0.2.0/README.md +0 -1
  11. mgcs_pytools-0.2.0/src/MGCS_pytools.egg-info/PKG-INFO +0 -25
  12. mgcs_pytools-0.2.0/test/test.py +0 -68
  13. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/LICENSE +0 -0
  14. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/setup.cfg +0 -0
  15. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/MGCS_pytools.egg-info/dependency_links.txt +0 -0
  16. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/MGCS_pytools.egg-info/requires.txt +0 -0
  17. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/MGCS_pytools.egg-info/top_level.txt +0 -0
  18. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/__init__.py +0 -0
  19. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/mcmc/__init__.py +0 -0
  20. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/mcmc/bivariate_normal.py +0 -0
  21. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/mcmc/legacy/multivariate_2d_posterior.py +0 -0
  22. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/mcmc/mcmc.py +0 -0
  23. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/mcmc/set_posterior.py +0 -0
  24. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/mcmc/utils.py +0 -0
  25. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/statistical_membership/__init__.py +0 -0
  26. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/statistical_membership/cvt_grid.py +0 -0
  27. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/statistical_membership/region_tools.py +0 -0
  28. {mgcs_pytools-0.2.0 → mgcs_pytools-0.2.1}/src/mgcs_pytools/utils/__init__.py +0 -0
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: MGCS_pytools
3
+ Version: 0.2.1
4
+ Summary: A collection of Python tools for data analysis and visualization made for the MGCS HST Treasury program.
5
+ Author-email: Luca Rosignoli <luca.rosignoli@inaf.it>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/LR-inaf/MGCS_pytools
8
+ Project-URL: Bug Tracker, https://github.com/LR-inaf/MGCS_pytools/issues
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: numpy
12
+ Requires-Dist: pandas
13
+ Requires-Dist: shapely
14
+ Requires-Dist: scipy
15
+ Requires-Dist: matplotlib
16
+ Requires-Dist: astropy
17
+ Requires-Dist: emcee
18
+ Requires-Dist: corner
19
+ Requires-Dist: tqdm
20
+ Requires-Dist: seaborn
21
+ Requires-Dist: h5py
22
+ Requires-Dist: scikit-learn
23
+ Dynamic: license-file
24
+
25
+ # Python tools used for the Missing Globular Cluster Survey [D. Massari et al. 2024](https://doi.org/10.1051/0004-6361/202554007)
26
+
27
+ ## Installation
28
+ You can install this module from PyPi repository using `pip install mgcs-pytools`
29
+
30
+ ## Brief description
31
+ This package provides three modules:
32
+ 1. `mcmc`: this module provide a inference-based Guassian Mixture Model (GMM). this module has been designed to study the distribution of the Proper Motions but it can be used for any 2D distribution.
33
+ 2. `statistical_membership`: you can use this module to perform a statistical decontamination of your CMD. This approach implements an adaptive CMD grid based on the Voronoi tassellation, and it combines the statistical decontamination with the differential reddening correction. the output is your photometric catalog with the membership probability for each star, the corrected magnitude and the delta_ebv to construct the reddening map
34
+ 3. `utils`: this package contain usefull plotting routin for both outcomes of the `mcmc` and `statistical_memberhsip` modules.
35
+
36
+ Further details on the code and it performance on real data will be published in an upcoming paper(s).
37
+
38
+ You can find a boilerplate in the main folder.
39
+
40
+ ## Contributing
41
+ __!!Contributions are super welcome!!__
42
+ If you wanna develop this project just clone this repo, make your branch with your branch and start developing.
43
+
44
+ ## Issue reporting
45
+ Also reporting bugs is important. If you find some bugs please open a ticket in the issue tab and I will more than happy to try to fix it.
46
+
47
+ For any information please reach me at _luca.rosignoli@inaf.it_
@@ -0,0 +1,23 @@
1
+ # Python tools used for the Missing Globular Cluster Survey [D. Massari et al. 2024](https://doi.org/10.1051/0004-6361/202554007)
2
+
3
+ ## Installation
4
+ You can install this module from PyPi repository using `pip install mgcs-pytools`
5
+
6
+ ## Brief description
7
+ This package provides three modules:
8
+ 1. `mcmc`: this module provide a inference-based Guassian Mixture Model (GMM). this module has been designed to study the distribution of the Proper Motions but it can be used for any 2D distribution.
9
+ 2. `statistical_membership`: you can use this module to perform a statistical decontamination of your CMD. This approach implements an adaptive CMD grid based on the Voronoi tassellation, and it combines the statistical decontamination with the differential reddening correction. the output is your photometric catalog with the membership probability for each star, the corrected magnitude and the delta_ebv to construct the reddening map
10
+ 3. `utils`: this package contain usefull plotting routin for both outcomes of the `mcmc` and `statistical_memberhsip` modules.
11
+
12
+ Further details on the code and it performance on real data will be published in an upcoming paper(s).
13
+
14
+ You can find a boilerplate in the main folder.
15
+
16
+ ## Contributing
17
+ __!!Contributions are super welcome!!__
18
+ If you wanna develop this project just clone this repo, make your branch with your branch and start developing.
19
+
20
+ ## Issue reporting
21
+ Also reporting bugs is important. If you find some bugs please open a ticket in the issue tab and I will more than happy to try to fix it.
22
+
23
+ For any information please reach me at _luca.rosignoli@inaf.it_
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "MGCS_pytools"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "A collection of Python tools for data analysis and visualization made for the MGCS HST Treasury program."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: MGCS_pytools
3
+ Version: 0.2.1
4
+ Summary: A collection of Python tools for data analysis and visualization made for the MGCS HST Treasury program.
5
+ Author-email: Luca Rosignoli <luca.rosignoli@inaf.it>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/LR-inaf/MGCS_pytools
8
+ Project-URL: Bug Tracker, https://github.com/LR-inaf/MGCS_pytools/issues
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: numpy
12
+ Requires-Dist: pandas
13
+ Requires-Dist: shapely
14
+ Requires-Dist: scipy
15
+ Requires-Dist: matplotlib
16
+ Requires-Dist: astropy
17
+ Requires-Dist: emcee
18
+ Requires-Dist: corner
19
+ Requires-Dist: tqdm
20
+ Requires-Dist: seaborn
21
+ Requires-Dist: h5py
22
+ Requires-Dist: scikit-learn
23
+ Dynamic: license-file
24
+
25
+ # Python tools used for the Missing Globular Cluster Survey [D. Massari et al. 2024](https://doi.org/10.1051/0004-6361/202554007)
26
+
27
+ ## Installation
28
+ You can install this module from PyPi repository using `pip install mgcs-pytools`
29
+
30
+ ## Brief description
31
+ This package provides three modules:
32
+ 1. `mcmc`: this module provide a inference-based Guassian Mixture Model (GMM). this module has been designed to study the distribution of the Proper Motions but it can be used for any 2D distribution.
33
+ 2. `statistical_membership`: you can use this module to perform a statistical decontamination of your CMD. This approach implements an adaptive CMD grid based on the Voronoi tassellation, and it combines the statistical decontamination with the differential reddening correction. the output is your photometric catalog with the membership probability for each star, the corrected magnitude and the delta_ebv to construct the reddening map
34
+ 3. `utils`: this package contain usefull plotting routin for both outcomes of the `mcmc` and `statistical_memberhsip` modules.
35
+
36
+ Further details on the code and it performance on real data will be published in an upcoming paper(s).
37
+
38
+ You can find a boilerplate in the main folder.
39
+
40
+ ## Contributing
41
+ __!!Contributions are super welcome!!__
42
+ If you wanna develop this project just clone this repo, make your branch with your branch and start developing.
43
+
44
+ ## Issue reporting
45
+ Also reporting bugs is important. If you find some bugs please open a ticket in the issue tab and I will more than happy to try to fix it.
46
+
47
+ For any information please reach me at _luca.rosignoli@inaf.it_
@@ -19,5 +19,4 @@ src/mgcs_pytools/statistical_membership/dr_correction.py
19
19
  src/mgcs_pytools/statistical_membership/membership.py
20
20
  src/mgcs_pytools/statistical_membership/region_tools.py
21
21
  src/mgcs_pytools/utils/__init__.py
22
- src/mgcs_pytools/utils/plotting.py
23
- test/test.py
22
+ src/mgcs_pytools/utils/plotting.py
@@ -31,6 +31,20 @@ class createROI:
31
31
 
32
32
  # make plot
33
33
  self.ax.scatter(self.points[:, 0], self.points[:, 1], marker=".", s=0.5, lw=0.1)
34
+ self.ax.set(
35
+ xlabel="abscissa",
36
+ ylabel="ordinate",
37
+ title="CMD in the abscissa-ordinate plane",
38
+ )
39
+ self.ax.text(
40
+ 0.05,
41
+ 0.95,
42
+ "Left click: add vertex\nSpacebar: close polygon\nC: cancel polygon\nQ: quit",
43
+ transform=self.ax.transAxes,
44
+ fontsize=8,
45
+ verticalalignment="top",
46
+ bbox=dict(boxstyle="round", facecolor="wheat", alpha=0.5),
47
+ )
34
48
  self.fig.canvas.draw()
35
49
  plt.show()
36
50
 
@@ -84,6 +98,22 @@ class createROI:
84
98
  lw=0.5,
85
99
  zorder=3,
86
100
  )
101
+
102
+ self.ax.set(
103
+ xlabel="abscissa",
104
+ ylabel="ordinate",
105
+ title="CMD in the abscissa-ordinate plane",
106
+ )
107
+ self.ax.text(
108
+ 0.05,
109
+ 0.95,
110
+ "Left click: add vertex\nSpacebar: close polygon\nC: cancel polygon\nQ: quit",
111
+ transform=self.ax.transAxes,
112
+ fontsize=8,
113
+ verticalalignment="top",
114
+ bbox=dict(boxstyle="round", facecolor="wheat", alpha=0.5),
115
+ )
116
+
87
117
  self.fig.canvas.draw()
88
118
  self.fig.canvas.flush_events()
89
119
 
@@ -352,18 +352,19 @@ def do_statistical_membership(
352
352
  df_cluster["membership"] = 1.0
353
353
 
354
354
  it = 0
355
+ it_stop = None
355
356
  # for it in range(process_iter):
356
357
  while True:
357
358
  print(f"ITERATION {it+1}")
358
359
 
359
360
  # reddening differential correction
360
- print("compute differential reddening..")
361
- print(df_cluster["membership"].describe())
361
+ print("Compute differential reddening..")
362
+ # print(df_cluster["membership"].describe())
362
363
  if it == 0:
363
364
  print("First iteration, correction threshold skipped")
364
365
  calc_corr_threhsold = False
365
366
  else:
366
- print(f"do calcuation of the Correction threshold")
367
+ print(f"Do calculation of the correction threshold")
367
368
  calc_corr_threhsold = True
368
369
 
369
370
  b1_corr, b2_corr, EBV, poli = compute_differential_reddening(
@@ -410,7 +411,10 @@ def do_statistical_membership(
410
411
  # _, ax = plt.subplots()
411
412
  # ax.hist(EBV, bins=30, color="gray", edgecolor="black", density=True)
412
413
  # plt.show()
413
- print("number of stars with null ebv: ", np.sum(EBV == 0.0) / EBV.shape[0])
414
+ print(
415
+ f"Number of stars with null ebv: {np.sum(EBV == 0.0) / EBV.shape[0] * 100:.2f}%"
416
+ f" ({np.sum(EBV == 0.0)} over {EBV.shape[0]})"
417
+ )
414
418
  photometric_error = np.median(
415
419
  (
416
420
  df_cluster[target_mag_col_error[0]] ** 2
@@ -501,9 +505,14 @@ def do_statistical_membership(
501
505
  membership[:, 1]
502
506
  )
503
507
 
508
+ if it == it_stop:
509
+ break
510
+
504
511
  if abs(np.median(EBV)) < abs(photometric_error) and it > 0:
505
512
  print("Differential reddening converged, stopping iterations.")
506
- break
513
+ print("Next iteration will be the last one.")
514
+ it_stop = it + 1
515
+
507
516
  it += 1
508
517
 
509
518
  return df_cluster
@@ -3,6 +3,7 @@ import matplotlib.pyplot as plt
3
3
  import matplotlib.cm as cm
4
4
  from matplotlib.ticker import MultipleLocator
5
5
  from mpl_toolkits.axes_grid1.inset_locator import inset_axes
6
+ from matplotlib.gridspec import GridSpec
6
7
 
7
8
  from scipy.spatial import voronoi_plot_2d, Voronoi
8
9
  from scipy.stats import norm
@@ -678,25 +679,24 @@ def plot_vpd_and_mdist_component(
678
679
  vpd_xlabel=None,
679
680
  vpd_ylabel=None,
680
681
  figsize_inches=8,
681
- wspace=0.05,
682
- hspace=0.05,
683
682
  figsize_wadjust=0.0,
684
683
  figsize_hadjust=-0.6,
685
684
  xlim=None,
686
685
  ylim=None,
687
686
  membership_cmap="coolwarm",
687
+ component_colors=None,
688
688
  hist_scale="log",
689
689
  ):
690
690
 
691
- layout = [("histx", "."), ("vpd", "histy")]
692
- fig, axs_dict = plt.subplot_mosaic(
693
- layout,
694
- figsize=(figsize_inches + figsize_wadjust, figsize_inches + figsize_hadjust),
695
- width_ratios=[1, 0.3],
696
- height_ratios=[0.3, 1],
697
- gridspec_kw={"wspace": wspace, "hspace": hspace},
698
- layout="compressed",
691
+ fig = plt.figure(
692
+ figsize=(figsize_inches + figsize_wadjust, figsize_inches + figsize_hadjust)
699
693
  )
694
+ gs = GridSpec(4, 4, wspace=0, hspace=0)
695
+
696
+ ax_scatter = fig.add_subplot(gs[1:4, 0:3])
697
+ ax_hist_x = fig.add_subplot(gs[0, 0:3]) # sharex=ax_scatter)
698
+ ax_hist_y = fig.add_subplot(gs[1:4, 3]) # sharey=ax_scatter)
699
+ axs_dict = {"vpd": ax_scatter, "histx": ax_hist_x, "histy": ax_hist_y}
700
700
 
701
701
  capsize = 1.5
702
702
  ms = 15
@@ -766,8 +766,11 @@ def plot_vpd_and_mdist_component(
766
766
  if ylim is not None:
767
767
  axs_dict["vpd"].set(ylim=ylim)
768
768
 
769
- cmap = mpl.colormaps["Set1"]
770
- component_colors = [cmap(i) for i in range(ncomp)]
769
+ if component_colors is None:
770
+ cmap = mpl.colormaps["Set1"]
771
+ component_colors = [cmap(i) for i in range(ncomp)]
772
+ else:
773
+ assert len(component_colors) == ncomp, "Component colors length mismatch."
771
774
 
772
775
  # Mdist
773
776
  mdist_x_sum = None
@@ -1,25 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: MGCS_pytools
3
- Version: 0.2.0
4
- Summary: A collection of Python tools for data analysis and visualization made for the MGCS HST Treasury program.
5
- Author-email: Luca Rosignoli <luca.rosignoli@inaf.it>
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://github.com/LR-inaf/MGCS_pytools
8
- Project-URL: Bug Tracker, https://github.com/LR-inaf/MGCS_pytools/issues
9
- Description-Content-Type: text/markdown
10
- License-File: LICENSE
11
- Requires-Dist: numpy
12
- Requires-Dist: pandas
13
- Requires-Dist: shapely
14
- Requires-Dist: scipy
15
- Requires-Dist: matplotlib
16
- Requires-Dist: astropy
17
- Requires-Dist: emcee
18
- Requires-Dist: corner
19
- Requires-Dist: tqdm
20
- Requires-Dist: seaborn
21
- Requires-Dist: h5py
22
- Requires-Dist: scikit-learn
23
- Dynamic: license-file
24
-
25
- # Python tools used for the Missing Globular Cluster Survey
@@ -1 +0,0 @@
1
- # Python tools used for the Missing Globular Cluster Survey
@@ -1,25 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: MGCS_pytools
3
- Version: 0.2.0
4
- Summary: A collection of Python tools for data analysis and visualization made for the MGCS HST Treasury program.
5
- Author-email: Luca Rosignoli <luca.rosignoli@inaf.it>
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://github.com/LR-inaf/MGCS_pytools
8
- Project-URL: Bug Tracker, https://github.com/LR-inaf/MGCS_pytools/issues
9
- Description-Content-Type: text/markdown
10
- License-File: LICENSE
11
- Requires-Dist: numpy
12
- Requires-Dist: pandas
13
- Requires-Dist: shapely
14
- Requires-Dist: scipy
15
- Requires-Dist: matplotlib
16
- Requires-Dist: astropy
17
- Requires-Dist: emcee
18
- Requires-Dist: corner
19
- Requires-Dist: tqdm
20
- Requires-Dist: seaborn
21
- Requires-Dist: h5py
22
- Requires-Dist: scikit-learn
23
- Dynamic: license-file
24
-
25
- # Python tools used for the Missing Globular Cluster Survey
@@ -1,68 +0,0 @@
1
- import os
2
- import pandas as pd
3
- import numpy as np
4
-
5
- import statistical_membership.membership as stat_mem
6
-
7
-
8
- def main():
9
- CATALOG_PATH = os.path.join(
10
- os.getcwd(), "NGC6749.CAT.v1"
11
- ) # Replace with the actual path to your catalog
12
- OUTPUT_PATH = os.getcwd() # Replace with the actual path to your output directory
13
-
14
- # v1cat = "/home/linux-machine/NGC6749/NGC6749.CAT.v1"
15
-
16
- df_cat_v1 = pd.read_csv(os.path.join(CATALOG_PATH, "NGC6749.CAT.v1"), sep="\s+")
17
- df_cat_v1 = df_cat_v1[df_cat_v1["oktot(54)"] == 1]
18
- df_cat_v1["membership"] = 0.0
19
-
20
- cluster_mag = ["m6061c(6)", "m8141c(7)"]
21
- cluster_mag_corr = [col + "_rdcorr" for col in cluster_mag]
22
- field_mag = ["m6062c(8)", "m8142c(9)"]
23
-
24
- df_field = df_cat_v1[df_cat_v1[field_mag[0]] != 0.0]
25
- df_cluster = df_cat_v1[df_cat_v1[cluster_mag[0]] != 0.0]
26
-
27
- fov_wfc3 = 163.0**2 # arcsec squared
28
- fov_acs = 202.0**2 # arcsec squared
29
-
30
- # reload(stat_mem)
31
-
32
- # setting up the parameters for the reddening correction
33
- dr_params = {
34
- "rband1": 0.903,
35
- "rband2": 0.597,
36
- "TO_mag": 22,
37
- "TO_color": 1.75,
38
- "nref": 20,
39
- "xcol": "x(3)",
40
- "ycol": "y(4)",
41
- "band1": cluster_mag[0],
42
- "band2": cluster_mag[1],
43
- "ord_step": 0.2,
44
- }
45
-
46
- # ord_max = -0.4 # 0.40
47
- # ord_min = -2.0 # -0.05
48
- # roi = np.array([[1.0, ord_max], [2.1, ord_max], [0.3, ord_min], [-0.2, ord_min]])
49
- # roi = np.array([[-0.8, ord_max], [0, ord_max], [-4, ord_min], [-5, ord_min]])
50
- # compute ememberhsip and reddening correction
51
- df_cluster_corr = stat_mem.do_statistical_membership(
52
- df_cluster,
53
- df_field,
54
- field_mag,
55
- dr_params,
56
- racol="ra(1)",
57
- deccol="dec(2)",
58
- fov_ratio=fov_acs / fov_wfc3,
59
- minstars=1000,
60
- memebership_iter=100,
61
- member_threshold=0.9,
62
- plot_dred=True,
63
- plot_voronoi=True,
64
- )
65
-
66
-
67
- if __name__ == "__main__":
68
- main()
File without changes
File without changes