MGCS-pytools 0.1.4__tar.gz → 0.2.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.
Files changed (25) hide show
  1. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/PKG-INFO +1 -1
  2. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/pyproject.toml +1 -1
  3. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/MGCS_pytools.egg-info/PKG-INFO +1 -1
  4. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/statistical_membership/cvt_grid.py +12 -0
  5. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/statistical_membership/dr_correction.py +0 -9
  6. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/statistical_membership/membership.py +29 -14
  7. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/LICENSE +0 -0
  8. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/README.md +0 -0
  9. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/setup.cfg +0 -0
  10. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/MGCS_pytools.egg-info/SOURCES.txt +0 -0
  11. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/MGCS_pytools.egg-info/dependency_links.txt +0 -0
  12. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/MGCS_pytools.egg-info/requires.txt +0 -0
  13. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/MGCS_pytools.egg-info/top_level.txt +0 -0
  14. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/__init__.py +0 -0
  15. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/__init__.py +0 -0
  16. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/bivariate_normal.py +0 -0
  17. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/legacy/multivariate_2d_posterior.py +0 -0
  18. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/mcmc.py +0 -0
  19. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/set_posterior.py +0 -0
  20. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/utils.py +0 -0
  21. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/statistical_membership/__init__.py +0 -0
  22. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/statistical_membership/region_tools.py +0 -0
  23. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/utils/__init__.py +0 -0
  24. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/src/mgcs_pytools/utils/plotting.py +0 -0
  25. {mgcs_pytools-0.1.4 → mgcs_pytools-0.2.0}/test/test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MGCS_pytools
3
- Version: 0.1.4
3
+ Version: 0.2.0
4
4
  Summary: A collection of Python tools for data analysis and visualization made for the MGCS HST Treasury program.
5
5
  Author-email: Luca Rosignoli <luca.rosignoli@inaf.it>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "MGCS_pytools"
7
- version = "0.1.4"
7
+ version = "0.2.0"
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"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MGCS_pytools
3
- Version: 0.1.4
3
+ Version: 0.2.0
4
4
  Summary: A collection of Python tools for data analysis and visualization made for the MGCS HST Treasury program.
5
5
  Author-email: Luca Rosignoli <luca.rosignoli@inaf.it>
6
6
  License-Expression: MIT
@@ -195,6 +195,18 @@ def _aggregate_regions(regions: NDArray) -> NDArray:
195
195
  np.where(np.isin(new_touched_regions, old_touched_regions)),
196
196
  )
197
197
 
198
+ # discard too large cells, most likely to be a field one
199
+ mask = np.where(
200
+ [
201
+ regions[idx].area > 10.0 * reg.area for idx in new_touched_regions
202
+ ] # to understand if it is better 5 or 10
203
+ )
204
+ new_touched_regions = (
205
+ np.delete(new_touched_regions, mask[0])
206
+ if len(mask[0]) > 0
207
+ else new_touched_regions
208
+ )
209
+
198
210
  old_touched_regions = np.append(old_touched_regions, new_touched_regions)
199
211
  old_touched_regions = np.append(old_touched_regions, i)
200
212
 
@@ -100,15 +100,6 @@ class createROI:
100
100
  self.cid_KEYBOARD = self.ax.figure.canvas.mpl_connect("key_press_event", self)
101
101
 
102
102
 
103
- # params needed:
104
- # rband1[float], exctiction law in band1
105
- # rband2[float], exctiction law in band2
106
- # RA[str], RA colname
107
- # DEC[str], DEC colname
108
- # TO_mag[float], Turn off mag
109
- # TO_color[float], Turn off color
110
- # nref[int], number of neighbors stars used as reference
111
- # columns[dict[str]] columns name of the dataframe [X, Y, V, I, membership]
112
103
  def compute_differential_reddening(
113
104
  df: pd.DataFrame,
114
105
  params: dict,
@@ -221,6 +221,8 @@ def get_membership(
221
221
  def do_statistical_membership(
222
222
  df_cluster_input: DataFrame,
223
223
  df_field_input: DataFrame,
224
+ target_mag_col: list[str],
225
+ target_mag_col_error: list[str],
224
226
  field_mag_col: list[str],
225
227
  dr_params: dict[str, str],
226
228
  parallel_fov: float,
@@ -228,10 +230,9 @@ def do_statistical_membership(
228
230
  minstars: int = 200,
229
231
  racol: str = "RA",
230
232
  deccol: str = "DEC",
231
- process_iter: int = 3,
233
+ # process_iter: int = 3,
232
234
  min_star_per_cell: int = 3,
233
235
  membership_iter: int = 1000,
234
- # fov_ratio: float = 1.0,
235
236
  roi: list[float] | None = None,
236
237
  plot_dred: bool = False,
237
238
  plot_voronoi: bool = False,
@@ -245,13 +246,26 @@ def do_statistical_membership(
245
246
  DataFrame containing the cluster stars.
246
247
  df_field_input: DataFrame
247
248
  DataFrame containing the field stars.
249
+ target_mag_col: list of str
250
+ List containing the names of the columns with the magnitudes
251
+ to use for the target CMD (color, mag).
252
+ target_mag_col_error: list of str
253
+ List containing the names of the columns with the magnitude errors
254
+ to use for the target CMD (color, mag).
248
255
  field_mag_col: list of str
249
256
  List containing the names of the columns with the magnitudes
250
- to use for the CMD (color, mag).
257
+ to use for the field CMD (color, mag).
251
258
  dr_params: dict of str
252
- Dictionary containing the names of the columns with the magnitudes
253
- to use for the differential reddening correction.
254
- Example: {"band1": "F606W", "band2": "F814W"}
259
+ Dictionary containing inputs parameters for the differential reddening
260
+ correction. It must contain the following keys:
261
+ - 'rband1': the exction value in band1,
262
+ - 'rband2': the exction value in band2,
263
+ - 'TO_mag': the magnitude of the Turn-off,
264
+ - 'TO_color': the color of the Turn-off,
265
+ - 'nref': the number of reference stars,
266
+ - 'xcol': the name of the column containing the x coordinates,
267
+ - 'ycol': the name of the column containing the y coordinates,
268
+ - 'ord_step': the bin size in the 'ordinate' to calculate the ridge line
255
269
  parallel_fov: float
256
270
  Size of the parallel FoV in deg square.
257
271
  member_threshold: float, optional
@@ -263,8 +277,6 @@ def do_statistical_membership(
263
277
  Name of the column containing the RA of the stars. Default is "RA".
264
278
  deccol: str, optional
265
279
  Name of the column containing the DEC of the stars. Default is "DEC".
266
- process_iter: int, optional
267
- Number of iterations to perform. Default is 3.
268
280
  min_star_per_cell: int, optional
269
281
  Minimum number of stars per Voronoi cell. Default is 3.
270
282
  membership_iter: int, optional
@@ -325,14 +337,17 @@ def do_statistical_membership(
325
337
  ]
326
338
 
327
339
  # initialize the cluster columns for membership and differential reddening
328
- dr_band1_corr = dr_params["band1"] + "_drcorr"
329
- dr_band2_corr = dr_params["band2"] + "_drcorr"
330
- df_cluster[dr_band1_corr] = df_cluster[dr_params["band1"]]
331
- df_cluster[dr_band2_corr] = df_cluster[dr_params["band2"]]
340
+ dr_band1_corr = target_mag_col[0] + "_drcorr"
341
+ dr_band2_corr = target_mag_col[1] + "_drcorr"
342
+ df_cluster[dr_band1_corr] = df_cluster[target_mag_col[0]]
343
+ df_cluster[dr_band2_corr] = df_cluster[target_mag_col[1]]
332
344
 
333
345
  dr_params["band1"] = dr_band1_corr
334
346
  dr_params["band2"] = dr_band2_corr
335
347
 
348
+ dr_params["xcol"] = racol
349
+ dr_params["ycol"] = deccol
350
+
336
351
  df_cluster["delta_ebv"] = 0.0
337
352
  df_cluster["membership"] = 1.0
338
353
 
@@ -398,8 +413,8 @@ def do_statistical_membership(
398
413
  print("number of stars with null ebv: ", np.sum(EBV == 0.0) / EBV.shape[0])
399
414
  photometric_error = np.median(
400
415
  (
401
- df_cluster[dr_params["band1_error"]] ** 2
402
- + df_cluster[dr_params["band2_error"]] ** 2
416
+ df_cluster[target_mag_col_error[0]] ** 2
417
+ + df_cluster[target_mag_col_error[1]] ** 2
403
418
  )
404
419
  ** 0.5
405
420
  )
File without changes
File without changes
File without changes
File without changes