Repository: LSSTDESC/gcr-catalogs

Issue:
Add object catalog configs for Run 2.2i
As title. We should add the config files for Run 2.2i DR3 (and DR2?) object catalogs. 

Discussion:

Patch:
diff --git a/GCRCatalogs/buzzard.py b/GCRCatalogs/buzzard.py
index 0be270b..3b4b5e8 100644
--- a/GCRCatalogs/buzzard.py
+++ b/GCRCatalogs/buzzard.py
@@ -175,7 +175,7 @@ class BuzzardGalaxyCatalog(BaseGenericCatalog):
                 'velocity_z': 'truth/VZ',
             }
 
-            if (self.version.split('_')[0] == '1.9.2') | (self.version.split('_')[0] == '2.0.0'):
+            if self.version.split('_')[0] == '1.9.2':
 
                 for i, b in enumerate(['Z_vista', 'Y_vista', 'J_vista', 'H_vista', 'Ks_vista', 'u_lsst', 
                                        'g_lsst', 'r_lsst', 'i_lsst', 'z_lsst', 'y_lsst', 'Y_wfirst',
diff --git a/GCRCatalogs/catalog_configs/buzzard.yaml b/GCRCatalogs/catalog_configs/buzzard.yaml
index 7c8b029..a46ce0a 100644
--- a/GCRCatalogs/catalog_configs/buzzard.yaml
+++ b/GCRCatalogs/catalog_configs/buzzard.yaml
@@ -1,2 +1,2 @@
-alias: buzzard_v2.0.0_3
+alias: buzzard_v1.9.2_3
 include_in_default_catalog_list: true
diff --git a/GCRCatalogs/catalog_configs/buzzard_v2.0.0_3.yaml b/GCRCatalogs/catalog_configs/buzzard_v2.0.0_3.yaml
deleted file mode 100644
index e85e12e..0000000
--- a/GCRCatalogs/catalog_configs/buzzard_v2.0.0_3.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-subclass_name: buzzard.BuzzardGalaxyCatalog
-
-catalog_root_dir: /global/projecta/projectdirs/lsst/groups/CS/Buzzard/Buzzard-3/v2.0.0/
-catalog_path_template:
-    truth: truth/Chinchilla-3_lensed_rs_shift_rs_scat_cam.{}.fits
-    auxmag : auxmags/Chinchilla-3-v1.9.7-auxmag.{}.fits
-
-cosmology:
-    H0: 70.0
-    Om0: 0.286
-    Ob0: 0.047
-    sigma8: 0.82
-    n_s: 0.96
-
-halo_mass_def: vir
-lightcone: true
-sky_area : 10313.24
-version: '2.0.0_3'
-
-creators: ['Joe DeRose', 'Risa Wechsler', 'Eli Rykoff', 'Matt Becker']
-description: |
-    Buzzard galaxy catalog v2.0.0 (realization 3).
-    This is a 10,000-square-degree catalog created with the ADDGALS algorithm.
-    It has galaxies down to r~26.5 magnitudes fainter than projected DES Y5 magnitude limits.
-    Read more at https://confluence.slac.stanford.edu/x/4o2bDQ
diff --git a/GCRCatalogs/catalog_configs/dc2_metacal_run2.2i_dr3.yaml b/GCRCatalogs/catalog_configs/dc2_metacal_run2.2i_dr3.yaml
new file mode 100644
index 0000000..bb91f15
--- /dev/null
+++ b/GCRCatalogs/catalog_configs/dc2_metacal_run2.2i_dr3.yaml
@@ -0,0 +1,7 @@
+subclass_name: dc2_metacal.DC2MetacalCatalog
+base_dir: /global/cfs/cdirs/lsst/production/DC2_ImSim/Run2.2i/dpdd/Run2.2i-dr3/metacal_table_summary
+filename_pattern: 'metacal_tract_\d+\.parquet$'
+bands: 'griz'
+apply_metacal_test3_fix: true
+description: DC2 Run 2.2i DR3 Metacal Table
+creators: ['DESC DC2 Team']
diff --git a/GCRCatalogs/catalog_configs/dc2_object_run2.2i_dr3.yaml b/GCRCatalogs/catalog_configs/dc2_object_run2.2i_dr3.yaml
new file mode 100644
index 0000000..f072757
--- /dev/null
+++ b/GCRCatalogs/catalog_configs/dc2_object_run2.2i_dr3.yaml
@@ -0,0 +1,7 @@
+subclass_name: dc2_object.DC2ObjectParquetCatalog
+base_dir: /global/cfs/cdirs/lsst/production/DC2_ImSim/Run2.2i/dpdd/Run2.2i-dr3/object_table_summary
+filename_pattern: 'object_tract_\d+\.parquet$'
+description: DC2 Run 2.2i DR3 Object Table
+creators: ['DESC DC2 Team']
+pixel_scale: 0.2
+include_in_default_catalog_list: true
diff --git a/GCRCatalogs/catalog_configs/dc2_object_run2.2i_dr3_tract3830.yaml b/GCRCatalogs/catalog_configs/dc2_object_run2.2i_dr3_tract3830.yaml
new file mode 100644
index 0000000..60bd5bf
--- /dev/null
+++ b/GCRCatalogs/catalog_configs/dc2_object_run2.2i_dr3_tract3830.yaml
@@ -0,0 +1,3 @@
+based_on: dc2_object_run2.2i_dr3
+tract: 3830
+include_in_default_catalog_list: true
diff --git a/GCRCatalogs/catalog_configs/dc2_object_run2.2i_dr3_with_metacal.yaml b/GCRCatalogs/catalog_configs/dc2_object_run2.2i_dr3_with_metacal.yaml
new file mode 100644
index 0000000..b1542f9
--- /dev/null
+++ b/GCRCatalogs/catalog_configs/dc2_object_run2.2i_dr3_with_metacal.yaml
@@ -0,0 +1,12 @@
+subclass_name: composite.CompositeReader
+description: DC2 Run 2.2i DR3 Object Catalog with metacal
+catalogs:
+  - catalog_name: dc2_object_run2.2i_dr3
+    # excluding some tracts due to missing patches in metacal catalog (as of March 11, 2020)
+    filename_pattern: 'object_tract_(?!3079|4034|4232|4636|5066|5073)\d+\.parquet$'
+    matching_method: MATCHING_FORMAT
+  - catalog_name: dc2_metacal_run2.2i_dr3
+    # excluding some tracts due to missing patches in metacal catalog (as of March 11, 2020)
+    filename_pattern: 'metacal_tract_(?!3079|4034|4232|4636|5066|5073)\d+\.parquet$'
+    matching_method: MATCHING_FORMAT
+include_in_default_catalog_list: true
diff --git a/GCRCatalogs/dc2_metacal.py b/GCRCatalogs/dc2_metacal.py
index bdd9fb1..a075475 100644
--- a/GCRCatalogs/dc2_metacal.py
+++ b/GCRCatalogs/dc2_metacal.py
@@ -62,13 +62,16 @@ class DC2MetacalCatalog(DC2DMTractCatalog):
         """
 
         modifiers = {
-            'objectId': 'id',
             'mcal_psf_g1': 'mcal_psf_g1_mean',
             'mcal_psf_g2': 'mcal_psf_g2_mean',
             'mcal_T_psf' : 'mcal_psf_T_mean',
             'mcal_flags' : 'mcal_flags'
         }
 
+        # newer metacal catalogs no longer have the id column
+        if 'id' in self._columns:
+            modifiers['objectId'] = 'id'
+
         # Additional metacal values and their variants
         for variant in ['', '_1p', '_1m', '_2p', '_2m']:
             # Shape
diff --git a/GCRCatalogs/dc2_object.py b/GCRCatalogs/dc2_object.py
index 67bb2db..561d798 100644
--- a/GCRCatalogs/dc2_object.py
+++ b/GCRCatalogs/dc2_object.py
@@ -758,8 +758,9 @@ class DC2ObjectParquetCatalog(DC2DMTractCatalog):
             modifiers[f'magerr_{band}_cModel'] = (convert_flux_err_to_mag_err,
                                                   f'{band}_modelfit_CModel_{FLUX}',
                                                   f'{band}_modelfit_CModel_{FLUX}{ERR}')
-
-            modifiers['snr_{}_cModel'.format(band)] = '{}_modelfit_SNR'.format(band)
+            modifiers[f'snr_{band}_cModel'] = (np.divide,
+                                               f'{band}_modelfit_CModel_{FLUX}',
+                                               f'{band}_modelfit_CModel_{FLUX}{ERR}')
 
             # Per-band shape information
             modifiers[f'I_flag_{band}'] = f'{band}_base_SdssShape_flag'
diff --git a/README.md b/README.md
index 1d3287f..282e844 100644
--- a/README.md
+++ b/README.md
@@ -65,7 +65,10 @@ Confluence page (*DESC member only*).
 
 
 -  **DC2 "Object Catalogs"** \
-   *by LSST DESC, compiled by Michael Wood-Vasey*
+   *by LSST DESC, compiled by the DC2 Team*
+   - `dc2_object_run2.2i_dr3`: static object catalog for Run 2.2i dr3
+   - `dc2_object_run2.2i_dr3_tract3830`: static object catalog for Run 2.2i dr3 (one tract only, for testing purpose / faster access)
+   - `dc2_object_run2.2i_dr3_with_metacal`: static object catalog for Run 2.2i dr3 + metacal
    - `dc2_object_run2.1i_dr4`: static object catalog for Run 2.1i dr4
    - `dc2_object_run2.1i_dr4_tract3830`: static object catalog for Run 2.1i dr4 (one tract only, for testing purpose / faster access)
    - `dc2_object_run2.1i_dr1b`: static object catalog for Run 2.1i dr1b


Test patch:
diff --git a/GCRCatalogs/catalog_configs/buzzard_test.yaml b/GCRCatalogs/catalog_configs/buzzard_test.yaml
index 44ce39c..51f1110 100644
--- a/GCRCatalogs/catalog_configs/buzzard_test.yaml
+++ b/GCRCatalogs/catalog_configs/buzzard_test.yaml
@@ -1,1 +1,1 @@
-alias: buzzard_v2.0.0_test
+alias: buzzard_v1.9.2_test
diff --git a/GCRCatalogs/catalog_configs/buzzard_v2.0.0_test.yaml b/GCRCatalogs/catalog_configs/buzzard_v2.0.0_test.yaml
deleted file mode 100644
index ff48187..0000000
--- a/GCRCatalogs/catalog_configs/buzzard_v2.0.0_test.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-subclass_name: buzzard.BuzzardGalaxyCatalog
-
-catalog_root_dir: /global/projecta/projectdirs/lsst/groups/CS/Buzzard/Buzzard-3/v2.0.0/
-catalog_path_template:
-    truth: truth/Chinchilla-3_lensed_rs_shift_rs_scat_cam.{}.fits
-    auxmag : auxmags/Chinchilla-3-v1.9.7-auxmag.{}.fits
-
-cosmology:
-    H0: 70.0
-    Om0: 0.286
-    Ob0: 0.047
-    sigma8: 0.82
-    n_s: 0.96
-
-healpix_pixels: [ 42 ]
-halo_mass_def: vir
-lightcone: true
-sky_area : 10313.24
-version: '2.0.0_3'
-
-creators: ['Joe DeRose', 'Risa Wechsler', 'Eli Rykoff', 'Matt Becker']
-description: |
-    Buzzard galaxy catalog v2.0.0 (realization 3).
-    This is a 10,000-square-degree catalog created with the ADDGALS algorithm.
-    It has galaxies down to r~26.5 magnitudes fainter than projected DES Y5 magnitude limits.
-    Read more at https://confluence.slac.stanford.edu/x/4o2bDQ