From 756fb3fcd9a0cb2cac7e8a518a86ca0500ab7088 Mon Sep 17 00:00:00 2001 From: wbalmer Date: Mon, 8 Jan 2024 16:30:56 -0500 Subject: [PATCH 1/2] initial hotfix to ensure .vot starfilescan be used w/calibrate_contrast --- spaceKLIP/analysistools.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spaceKLIP/analysistools.py b/spaceKLIP/analysistools.py index 1e773a38..b89d0917 100644 --- a/spaceKLIP/analysistools.py +++ b/spaceKLIP/analysistools.py @@ -137,8 +137,10 @@ 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_header = '#'+starfile.split('/')[-1] + ' /// {}'.format(spectral_type)+'\n' - write_starfile(starfile, new_starfile_path, new_header) + self.new_starfile_path = new_starfile_path + self.contrast_spectral_type = spectral_type + 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 +540,10 @@ 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], + starfile = self.new_starfile_path + mstar, fzero = get_stellar_magnitudes(starfile, + self.contrast_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 From f7e8b9c3139d61c08765fd1ece41b2dc6ebb8710 Mon Sep 17 00:00:00 2001 From: wbalmer Date: Mon, 8 Jan 2024 17:39:22 -0500 Subject: [PATCH 2/2] save contrast curve info txt as opposed to header - still copy starfile --- spaceKLIP/analysistools.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/spaceKLIP/analysistools.py b/spaceKLIP/analysistools.py index b89d0917..8cdefe73 100644 --- a/spaceKLIP/analysistools.py +++ b/spaceKLIP/analysistools.py @@ -136,9 +136,11 @@ 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 - self.new_starfile_path = new_starfile_path - self.contrast_spectral_type = spectral_type + new_starfile_path = output_dir+'/'+starfile.split('/')[-1] + new_header = '#'+starfile.split('/')[-1] + ' /// {}'.format(spectral_type)+'\n' + 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) @@ -540,9 +542,12 @@ def calibrate_contrast(self, resolution_fwhm = 1.025*resolution # Get stellar magnitudes and filter zero points, but use the same file as rawcon - starfile = self.new_starfile_path + 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, - self.contrast_spectral_type, + spectral_type, self.database.red[key]['INSTRUME'][j], output_dir=output_dir) # vegamag, Jy filt = self.database.red[key]['FILTER'][j]