hpparvi / MuSCAT2_transit_pipeline

MuSCAT2 transit analysis pipeline
GNU General Public License v3.0
5 stars 0 forks source link

error when r-band is missing #27

Closed jpdeleon closed 3 years ago

jpdeleon commented 3 years ago

TFOPAnalysis throws the error shown below when it is initialized without r in the passband argument, and also when no r-band dataset is available in the photometry folder, as in the case of TOI 1605 taken on Sep. 2.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-0efaa7fc2cab> in <module>
      4 CIDS=[1,2,3,4] #comparison id(s); can be guesses for now
      5 
----> 6 ta = TFOPAnalysis(target=OBJ, 
      7                   date=DATE,
      8                   tid=TID,

~/github/MuSCAT2_transit_pipeline/muscat2ta/tfopanalysis.py in __init__(self, target, date, tid, cids, dataroot, nlegendre, npop, mjd_start, mjd_end, excluded_mjd_ranges, aperture_lims, passbands, use_opencl, with_transit, with_contamination, radius_ratio, excluded_stars, toi, klims, clear_field_only, check_saturation, contamination_model, contamination_reference_passband)
     86                  contamination_reference_passband: str = "r'"):
     87 
---> 88         super().__init__(target, date, tid, cids, dataroot=dataroot,
     89                  nlegendre=nlegendre,  npop=npop,  mjd_start=mjd_start, mjd_end=mjd_end,
     90                  excluded_mjd_ranges=excluded_mjd_ranges,

~/github/MuSCAT2_transit_pipeline/muscat2ta/transitanalysis.py in __init__(self, target, date, tid, cids, dataroot, exptime_min, nlegendre, npop, mjd_start, mjd_end, excluded_mjd_ranges, aperture_lims, passbands, use_opencl, with_transit, with_contamination, radius_ratio, klims, catalog_name, init_lpf, check_saturation, contamination_model, contamination_reference_passband, target_coordinates)
    149 
    150         if self.init_lpf:
--> 151             self.lpf = M2LPF(target, self.phs, tid, cids, pbs, aperture_lims=aperture_lims, use_opencl=use_opencl,
    152                              with_transit=with_transit, with_contamination=with_contamination,
    153                              n_legendre=nlegendre, radius_ratio=radius_ratio, klims=klims,

~/github/MuSCAT2_transit_pipeline/muscat2ta/m2lpf.py in __init__(self, target, photometry, tid, cids, filters, aperture_lims, use_opencl, n_legendre, use_toi_info, with_transit, with_contamination, radius_ratio, noise_model, klims, contamination_model, contamination_reference_passband)
    301             tm = QuadraticModel(interpolate=False, klims=klims, nk=1024, nz=1024)
    302 
--> 303         BaseLPF.__init__(self, target, filters, times, fluxes, wns, arange(len(photometry)), covariates,
    304                          arange(len(fluxes)), tm = tm, tref=floor(times[0].min()))
    305         self._start_flares = len(self.ps)

~/miniconda3/envs/py3/lib/python3.8/site-packages/pytransit/lpf/lpf.py in __init__(self, name, passbands, times, fluxes, errors, pbids, covariates, wnids, tm, nsamples, exptimes, init_data, result_dir, tref, lnlikelihood)
    208             # Inititalise the instrument
    209             # --------------------------
--> 210             self._init_instrument()
    211 
    212         self._init_lnlikelihood()

~/github/MuSCAT2_transit_pipeline/muscat2ta/m2lpf.py in _init_instrument(self)
    425         filters = {'g': sdss_g, 'r': sdss_r, 'i':sdss_i, 'z_s':sdss_z}
    426         self.instrument = Instrument('MuSCAT2', [filters[pb] for pb in self.passbands])
--> 427         self.cm = SMContamination(self.instrument, self.contamination_reference_passband)
    428 
    429     def add_flare(self, loc, amp=(0, 0.2)):

~/miniconda3/envs/py3/lib/python3.8/site-packages/pytransit/contamination/contamination.py in __init__(self, instrument, ref_pb)
    299               name of the reference passband
    300           """
--> 301         super().__init__(instrument, ref_pb)
    302 
    303         self._spectra: DataFrame = DataFrame(pd.read_hdf(resource_filename(__name__, join("data", "spectra.h5")), 'Z0'))

~/miniconda3/envs/py3/lib/python3.8/site-packages/pytransit/contamination/contamination.py in __init__(self, instrument, ref_pb)
     85         """
     86         self.instrument = instrument
---> 87         self._ri = self.instrument.pb_names.index(ref_pb)
     88         self._rpb = ref_pb
     89 

ValueError: "r'" is not in list
jpdeleon commented 3 years ago

This issue has been resolved thanks to Felipe's suggestion to change the default parameter to another available passband, e.g. contamination_reference_passband="i'"