MGCS-pytools 0.1.3__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.3 → mgcs_pytools-0.2.0}/PKG-INFO +1 -1
  2. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/pyproject.toml +1 -1
  3. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/MGCS_pytools.egg-info/PKG-INFO +1 -1
  4. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/statistical_membership/cvt_grid.py +12 -0
  5. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/statistical_membership/dr_correction.py +0 -9
  6. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/statistical_membership/membership.py +33 -15
  7. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/LICENSE +0 -0
  8. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/README.md +0 -0
  9. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/setup.cfg +0 -0
  10. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/MGCS_pytools.egg-info/SOURCES.txt +0 -0
  11. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/MGCS_pytools.egg-info/dependency_links.txt +0 -0
  12. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/MGCS_pytools.egg-info/requires.txt +0 -0
  13. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/MGCS_pytools.egg-info/top_level.txt +0 -0
  14. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/__init__.py +0 -0
  15. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/__init__.py +0 -0
  16. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/bivariate_normal.py +0 -0
  17. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/legacy/multivariate_2d_posterior.py +0 -0
  18. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/mcmc.py +0 -0
  19. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/set_posterior.py +0 -0
  20. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/mcmc/utils.py +0 -0
  21. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/statistical_membership/__init__.py +0 -0
  22. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/statistical_membership/region_tools.py +0 -0
  23. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/utils/__init__.py +0 -0
  24. {mgcs_pytools-0.1.3 → mgcs_pytools-0.2.0}/src/mgcs_pytools/utils/plotting.py +0 -0
  25. {mgcs_pytools-0.1.3 → 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.3
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.3"
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.3
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,16 +221,18 @@ 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],
228
+ parallel_fov: float,
226
229
  member_threshold: float = 0.8,
227
230
  minstars: int = 200,
228
231
  racol: str = "RA",
229
232
  deccol: str = "DEC",
230
- process_iter: int = 3,
233
+ # process_iter: int = 3,
231
234
  min_star_per_cell: int = 3,
232
235
  membership_iter: int = 1000,
233
- fov_ratio: float = 1.0,
234
236
  roi: list[float] | None = None,
235
237
  plot_dred: bool = False,
236
238
  plot_voronoi: bool = False,
@@ -244,13 +246,28 @@ def do_statistical_membership(
244
246
  DataFrame containing the cluster stars.
245
247
  df_field_input: DataFrame
246
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).
247
255
  field_mag_col: list of str
248
256
  List containing the names of the columns with the magnitudes
249
- to use for the CMD (color, mag).
257
+ to use for the field CMD (color, mag).
250
258
  dr_params: dict of str
251
- Dictionary containing the names of the columns with the magnitudes
252
- to use for the differential reddening correction.
253
- 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
269
+ parallel_fov: float
270
+ Size of the parallel FoV in deg square.
254
271
  member_threshold: float, optional
255
272
  Membership threshold to consider a star as a member of the cluster.
256
273
  Default is 0.8.
@@ -260,8 +277,6 @@ def do_statistical_membership(
260
277
  Name of the column containing the RA of the stars. Default is "RA".
261
278
  deccol: str, optional
262
279
  Name of the column containing the DEC of the stars. Default is "DEC".
263
- process_iter: int, optional
264
- Number of iterations to perform. Default is 3.
265
280
  min_star_per_cell: int, optional
266
281
  Minimum number of stars per Voronoi cell. Default is 3.
267
282
  membership_iter: int, optional
@@ -314,7 +329,7 @@ def do_statistical_membership(
314
329
  + (df_cluster[deccol].max() - df_cluster[deccol].min()) / 2
315
330
  )
316
331
 
317
- fov_ratio = [subfov.area / instrument_fov.area for subfov in subfovs]
332
+ fov_ratio = [subfov.area / parallel_fov for subfov in subfovs]
318
333
 
319
334
  field_pts = [
320
335
  Point(row[field_mag_col[0]] - row[field_mag_col[1]], row[field_mag_col[0]])
@@ -322,14 +337,17 @@ def do_statistical_membership(
322
337
  ]
323
338
 
324
339
  # initialize the cluster columns for membership and differential reddening
325
- dr_band1_corr = dr_params["band1"] + "_drcorr"
326
- dr_band2_corr = dr_params["band2"] + "_drcorr"
327
- df_cluster[dr_band1_corr] = df_cluster[dr_params["band1"]]
328
- 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]]
329
344
 
330
345
  dr_params["band1"] = dr_band1_corr
331
346
  dr_params["band2"] = dr_band2_corr
332
347
 
348
+ dr_params["xcol"] = racol
349
+ dr_params["ycol"] = deccol
350
+
333
351
  df_cluster["delta_ebv"] = 0.0
334
352
  df_cluster["membership"] = 1.0
335
353
 
@@ -395,8 +413,8 @@ def do_statistical_membership(
395
413
  print("number of stars with null ebv: ", np.sum(EBV == 0.0) / EBV.shape[0])
396
414
  photometric_error = np.median(
397
415
  (
398
- df_cluster[dr_params["band1_error"]] ** 2
399
- + 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
400
418
  )
401
419
  ** 0.5
402
420
  )
File without changes
File without changes
File without changes
File without changes