DavidT3 / XGA

X-ray: Generate and Analyse is a module designed to make the analysis of XMM observations simple and efficient. It provides an interface with SAS for the creation of XMM data products, as well as a way to easily perform fits (scalable for multiple observations) and retrieve information about an object, all within a Python package.
BSD 3-Clause "New" or "Revised" License
29 stars 3 forks source link

Declaration of XLSSC-57 is failing now that I have manually edited regions for the first mass paper #827

Closed DavidT3 closed 2 years ago

DavidT3 commented 2 years ago

Specifically:

IndexError Traceback (most recent call last) /tmp/ipykernel_33494/2047891876.py in 8 # Declaring the actual ClusterSample instance for the XXL sample 9 # This is the only sample whose original analysis used the WMAP9 cosmology ---> 10 xxl_srcs = ClusterSample(ra, dec, z, n, r500=r500, cosmology=xxl_cosmo, load_fits=False, use_peak=False, 11 clean_obs=True, clean_obs_reg='r500', clean_obs_threshold=0.7, back_inn_rad_factor=3.33, 12 back_out_rad_factor=5)

/mnt/pact/dt237/code/PycharmProjects/XGA/xga/samples/extended.py in init(self, ra, dec, redshift, name, r200, r500, r2500, richness, richness_err, wl_mass, wl_mass_err, custom_region_radius, use_peak, peak_lo_en, peak_hi_en, back_inn_rad_factor, back_out_rad_factor, cosmology, load_fits, clean_obs, clean_obs_reg, clean_obs_threshold, no_prog_bar, psf_corr, peak_find_method) 139 # bunch to make GalaxyCluster declaration quicker 140 try: --> 141 self._sources[n] = GalaxyCluster(r, d, z, n, r2, r5, r25, lam, lam_err, wlm, wlm_err, cr, 142 use_peak, peak_lo_en, peak_hi_en, back_inn_rad_factor, 143 back_out_rad_factor, cosmology, True, load_fits, clean_obs,

/mnt/pact/dt237/code/PycharmProjects/XGA/xga/sources/extended.py in init(self, ra, dec, redshift, name, r200, r500, r2500, richness, richness_err, wl_mass, wl_mass_err, custom_region_radius, use_peak, peak_lo_en, peak_hi_en, back_inn_rad_factor, back_out_rad_factor, cosmology, load_products, load_fits, clean_obs, clean_obs_reg, clean_obs_threshold, regen_merged, peak_find_method) 111 raise UnitConversionError("R2500 radius must be in either angular or distance units.") 112 --> 113 super().init(ra, dec, redshift, name, custom_region_radius, use_peak, peak_lo_en, peak_hi_en, 114 back_inn_rad_factor, back_out_rad_factor, cosmology, load_products, load_fits, 115 peak_find_method)

/mnt/pact/dt237/code/PycharmProjects/XGA/xga/sources/general.py in init(self, ra, dec, redshift, name, custom_region_radius, use_peak, peak_lo_en, peak_hi_en, back_inn_rad_factor, back_out_rad_factor, cosmology, load_products, load_fits, peak_find_method) 97 98 # This uses the added context of the type of source to find (or not find) matches in region files ---> 99 self._regions, self._alt_match_regions, self._other_regions = self._source_type_match("ext") 100 101 # Making a combined list of interloper regions

/mnt/pact/dt237/code/PycharmProjects/XGA/xga/sources/extended.py in _source_type_match(self, source_type) 191 return Quantity(np.sqrt(abs(ra - self._ra_dec[0]) 2 + abs(dec - self._ra_dec[1]) 2), 'deg') 192 --> 193 results_dict, alt_match_dict, anti_results_dict = super()._source_type_match('ext') 194 195 # The 0.66 and 2.25 factors are intended to shift the r200 and r2500 values to approximately r500, and were

/mnt/pact/dt237/code/PycharmProjects/XGA/xga/sources/base.py in _source_type_match(self, source_type) 1327 # print(self._initial_regions[obs][self._initial_region_matches[obs]]) 1328 print(obs) -> 1329 if len(self._initial_regions[obs][self._initial_region_matches[obs]]) == 0: 1330 results_dict[obs] = None 1331 else:

IndexError: boolean index did not match indexed array along dimension 0; dimension is 2 but corresponding boolean dimension is 1

This is specifically happening for ObsID 0553912001, which as it turns out has no region file in XCS.

I also gave this source a new custom region, which I suspect must be what's causing the issue here. I'm going to temporarily remove the custom source region and see if that allows declaration.

DavidT3 commented 2 years ago

I was correct, that is whats causing the problem. Now I just need to track down the actual source - presumably when the custom regions are added to the existing ObsID regions.

DavidT3 commented 2 years ago

So I think it's because the custom region is being appended to an array which just contains None (that is what XGA does when no regions exist), which of course throws things off.

DavidT3 commented 2 years ago

This may have highlighted another issue where the initial matching function hates region lists with only one entry:

TypeError Traceback (most recent call last) /tmp/ipykernel_40237/2047891876.py in 8 # Declaring the actual ClusterSample instance for the XXL sample 9 # This is the only sample whose original analysis used the WMAP9 cosmology ---> 10 xxl_srcs = ClusterSample(ra, dec, z, n, r500=r500, cosmology=xxl_cosmo, load_fits=False, use_peak=False, 11 clean_obs=True, clean_obs_reg='r500', clean_obs_threshold=0.7, back_inn_rad_factor=3.33, 12 back_out_rad_factor=5)

/mnt/pact/dt237/code/PycharmProjects/XGA/xga/samples/extended.py in init(self, ra, dec, redshift, name, r200, r500, r2500, richness, richness_err, wl_mass, wl_mass_err, custom_region_radius, use_peak, peak_lo_en, peak_hi_en, back_inn_rad_factor, back_out_rad_factor, cosmology, load_fits, clean_obs, clean_obs_reg, clean_obs_threshold, no_prog_bar, psf_corr, peak_find_method) 73 74 # Using the super defines BaseSources and stores them in the self._sources dictionary ---> 75 super().init(ra, dec, redshift, name, cosmology, load_products=True, load_fits=False, 76 no_prog_bar=no_prog_bar) 77

/mnt/pact/dt237/code/PycharmProjects/XGA/xga/samples/base.py in init(self, ra, dec, redshift, name, cosmology, load_products, load_fits, no_prog_bar) 74 75 try: ---> 76 temp = BaseSource(r, d, z, n, cosmology, load_products, load_fits) 77 n = temp.name 78 self._sources[n] = temp

/mnt/pact/dt237/code/PycharmProjects/XGA/xga/sources/base.py in init(self, ra, dec, redshift, name, cosmology, load_products, load_fits) 143 self._lum_dist = None 144 self._ang_diam_dist = None --> 145 self._initial_regions, self._initial_region_matches = self._load_regions(region_dict) 146 147 # This is a queue for products to be generated for this source, will be a numpy array in practise.

/mnt/pact/dt237/code/PycharmProjects/XGA/xga/sources/base.py in _load_regions(self, reg_paths) 1183 # to do this contains match... 1184 within = np.array([reg.contains(SkyCoord(*self._ra_dec, unit='deg'), w) -> 1185 for reg in reg_dict[obs_id][diff_sort[0:5]]]) 1186 1187 # Make sure to re-order the region list to match the sorted within array

TypeError: only integer scalar arrays can be converted to a scalar index

DavidT3 commented 2 years ago

This appears to be resolved now