diff --git a/spaceKLIP/analysistools.py b/spaceKLIP/analysistools.py index 1e773a38..8cdefe73 100644 --- a/spaceKLIP/analysistools.py +++ b/spaceKLIP/analysistools.py @@ -136,9 +136,13 @@ def raw_contrast(self, # Copy the starfile that will be used into this directory starfile_ext = os.path.splitext(starfile)[1] - new_starfile_path = output_dir+'/user_starfile'+starfile_ext + new_starfile_path = output_dir+'/'+starfile.split('/')[-1] new_header = '#'+starfile.split('/')[-1] + ' /// {}'.format(spectral_type)+'\n' - write_starfile(starfile, new_starfile_path, new_header) + contrast_curve_info_path = output_dir+'/contrast_curve_info.txt' + with open(contrast_curve_info_path, 'w') as ccinfo: + ccinfo.write(new_header) + log.info('Copying starfile {} to {}'.format(starfile, new_starfile_path)) + write_starfile(starfile, new_starfile_path) # Loop through concatenations. for i, key in enumerate(self.database.red.keys()): @@ -538,12 +542,13 @@ def calibrate_contrast(self, resolution_fwhm = 1.025*resolution # Get stellar magnitudes and filter zero points, but use the same file as rawcon - starfile = os.path.join(rawcon_dir, 'user_starfile.txt') - with open(starfile) as sf: - spectral_type = sf.readline().strip('\n').split(' /// ')[-1] - mstar, fzero = get_stellar_magnitudes(starfile, - spectral_type, - self.database.red[key]['INSTRUME'][j], + ccinfo = os.path.join(rawcon_dir, 'contrast_curve_info.txt') + with open(ccinfo) as cci: + starfile, spectral_type = cci.readline().strip('\n').split(' /// ') + starfile = os.path.join(rawcon_dir, starfile.replace('#','')) + mstar, fzero = get_stellar_magnitudes(starfile, + spectral_type, + self.database.red[key]['INSTRUME'][j], output_dir=output_dir) # vegamag, Jy filt = self.database.red[key]['FILTER'][j] fstar = fzero[filt] / 10.**(mstar[filt] / 2.5) / 1e6 * np.max(offsetpsf) # MJy