astrochun / Metallicity_Stack_Commons

Set of common codes used in metallicity studies that use stacking techniques
MIT License
0 stars 1 forks source link

Distinguishing metadata column names when generating flux ratio tables #73

Closed astrochun closed 3 years ago

astrochun commented 3 years ago

As brought to my attention by @Reagen, ratios.flux_ratios adopts the same naming convention for flux ratios, logR23, logO32, two_beta, and three_beta. When implementing this between individual and composite measurements, the names are not distinguished. While this is fine for interoperability, it is ultimately problem when tables are collated for individual galaxies. The composite cases are defined as bin_ratios0 list.

This is seen in feature/dust_implement.

It will be implemented as part of that branch

Reagen commented 3 years ago

Original Error Message:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/Programming/python/Zcalbase_gal/analysis/deep2_r23_o32/general.py in run_grid_r23_o32_analysis(dataset, y_correction, n_split, adaptive, dustatten, mask)
    291         attenuation.EBV_table_update(fitspath, use_revised=False)
    292         r_temp_calcul.run_function(fitspath, dataset, verification_table_revised, dustatt=True)
--> 293         error_prop.fluxes_derived_prop(fitspath, raw=False, binned_data=True, apply_dust=True, revised=True)
    294 
    295     if not dustatten:

~/Programming/Metallicity_Stack_Commons/Metallicity_Stack_Commons/analysis/error_prop.py in fluxes_derived_prop(path, raw, binned_data, apply_dust, revised)
    177         for name0 in flux_ratios_dict.keys():
    178             err_prop, peak_prop = compute_onesig_pdf(flux_ratios_dict[name0],
--> 179                                                      prop_tab0[name0],
    180                                                      usepeak=True)
    181 

~/anaconda/lib/python3.7/site-packages/astropy/table/table.py in __getitem__(self, item)
   1600     def __getitem__(self, item):
   1601         if isinstance(item, str):
-> 1602             return self.columns[item]
   1603         elif isinstance(item, (int, np.integer)):
   1604             return self.Row(self, item)

~/anaconda/lib/python3.7/site-packages/astropy/table/table.py in __getitem__(self, item)
    237         """
    238         if isinstance(item, str):
--> 239             return OrderedDict.__getitem__(self, item)
    240         elif isinstance(item, (int, np.integer)):
    241             return self.values()[item]

KeyError: 'R'
astrochun commented 3 years ago

This appears to be implemented in hotfix/1.1.5 #70

astrochun commented 3 years ago

@Reagen and @cmccormick1: Note that I fixed this issue by merging hotfix/1.1.5 (a previous fix) into feature/dust_implement #76. The merge sorted out two different ways to fix the individual/composite column names. It involved not having another keyword in ratios.flux_ratios. Rather, the same boolean flag (binned_data) is used throughput.

When feature/dust_implement is merged, the new convention will be standard.