Skip to content

Commit

Permalink
fixing inconsistent source_id case
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmejia committed Nov 11, 2024
1 parent 5001300 commit 3740739
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions python/lvmdrp/core/fluxcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@


def get_mean_sens_curves(sens_dir):
return {'b':pd.read_csv(f'{sens_dir}/mean-sens-b.csv', names=['wavelength', 'sens']),
'r':pd.read_csv(f'{sens_dir}/mean-sens-r.csv', names=['wavelength', 'sens']),
return {'b':pd.read_csv(f'{sens_dir}/mean-sens-b.csv', names=['wavelength', 'sens']),
'r':pd.read_csv(f'{sens_dir}/mean-sens-r.csv', names=['wavelength', 'sens']),
'z':pd.read_csv(f'{sens_dir}/mean-sens-z.csv', names=['wavelength', 'sens'])}

def retrieve_header_stars(rss):
Expand Down Expand Up @@ -130,8 +130,13 @@ def get_XP_spectra(expnum, ra_tile, dec_tile, lim_mag=14.0, n_spec=15, GAIA_CACH
#
# get XP spectra and cache the calibrated spectra
#

cols = r.colnames
new_cols = [col.lower() for col in cols]
r.rename_columns(cols, new_cols)

sampling=np.arange(336., 1021., 2.)
ids = [line['SOURCE_ID'] for line in r]
ids = [line['source_id'] for line in r]
if GAIA_CACHE_DIR is None or path.exists(GAIA_CACHE_DIR + f'/{expnum}_XP_spec.pickle') is False:
calibrated_spectra, _ = gaiaxpy.calibrate(ids, truncation=False, save_file=False)
if GAIA_CACHE_DIR is not None:
Expand All @@ -140,7 +145,7 @@ def get_XP_spectra(expnum, ra_tile, dec_tile, lim_mag=14.0, n_spec=15, GAIA_CACH
else:
#print('reading '+GAIA_CACHE_DIR + f'/{expnum}_XP_spec.csv')
calibrated_spectra = pd.read_pickle(GAIA_CACHE_DIR + f'/{expnum}_XP_spec.pickle')

# calibrated_spectra
if(plot):
gaiaxpy.plot_spectra(calibrated_spectra, sampling=sampling, multi=True, show_plot=True, output_path=None, legend=False)
Expand Down Expand Up @@ -253,7 +258,7 @@ def LVM_phot_filter(channel, w):
return np.exp(-0.5 * ((w - 8500) / 250) ** 2)
else:
raise Exception(f"Unknown filter '{channel}'")


def spec_to_mAB(lam, spec, lamf, filt):
"""
Expand Down Expand Up @@ -296,9 +301,9 @@ def spec_to_LVM_mAB(channel, w, f):

def sky_flux_in_filter(cam, skyfibs, obswave, percentile=75):
'''
Given an lvmFrame, calculate the median flux in the LVM photometric system of the
lowest 'percentile' of sky fibers.
Given an lvmFrame, calculate the median flux in the LVM photometric system of the
lowest 'percentile' of sky fibers.
Used for sky subtraction of the photometry of stars for sci IFU self calibration.
'''
nfiber = skyfibs.shape[0]
Expand Down
4 changes: 2 additions & 2 deletions python/lvmdrp/functions/fluxCalMethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def science_sensitivity(rss, res_sci, ext, GAIA_CACHE_DIR, NSCI_MAX=15, r_spaxel

dmin = d[fib] * 3600 # convert to arcsec

log.info(f"science fiberid '{scifibs['fiberid'][fib][0]}', star '{data['SOURCE_ID']}', secz '{secz:.2f}'")
log.info(f"science fiberid '{scifibs['fiberid'][fib][0]}', star '{data['source_id']}', secz '{secz:.2f}'")

# correction for Evelyn's effect
radius_fac = np.interp(dmin, np.array([0,4,6,8,10,12,14,16]), 10**(-0.4*np.array([0.0,0.0,0.05,0.12,0.15,0.2,0.2,0.2])))
Expand Down Expand Up @@ -411,7 +411,7 @@ def science_sensitivity(rss, res_sci, ext, GAIA_CACHE_DIR, NSCI_MAX=15, r_spaxel
cam = channel.upper()
rss.setHdrValue(f"SCI{i+1}{cam}AB", mAB_std, f"Gaia AB mag in {channel}-band")
rss.setHdrValue(f"SCI{i+1}{cam}IN", mAB_obs, f"Obs AB mag in {channel}-band")
rss.setHdrValue(f"SCI{i+1}ID", data['SOURCE_ID'], f"Field star {i+1} Gaia source ID")
rss.setHdrValue(f"SCI{i+1}ID", data['source_id'], f"Field star {i+1} Gaia source ID")
rss.setHdrValue(f"SCI{i+1}FIB", scifibs['fiberid'][fib][0], f"Field star {i+1} fiber id")
rss.setHdrValue(f"SCI{i+1}RA", data['ra'], f"Field star {i+1} RA")
rss.setHdrValue(f"SCI{i+1}DE", data['dec'], f"Field star {i+1} DEC")
Expand Down

0 comments on commit 3740739

Please sign in to comment.