Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
bcvel_baryc = ( lbary_ltopo - 1.0 ) * 2.99792458E5
print "\t\tBarycentric velocity:", bcvel_baryc
res = jplephem.pulse_delay(ra/15.0, dec, int(mjd), mjd%1, 1, 0.0)
mbjd = mjd + res['delay'][0] / (3600.0 * 24.0)
# Moon Phase Calculations
gobs = ephem.Observer()
gobs.name = 'VLT'
gobs.lat = rad(latitude) # lat/long in decimal degrees
gobs.long = rad(longitude)
gobs.date = h[0].header['DATE-OBS'].replace('T',' ')
mephem = ephem.Moon()
mephem.compute(gobs)
Mcoo = jplephem.object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Mp = jplephem.barycentric_object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Sp = jplephem.barycentric_object_track("Sun", int(mjd), float(mjd%1), 1, 0.0)
res = jplephem.object_doppler("Moon", int(mjd), mjd%1, 1, 0.0)
lunation,moon_state,moonsep,moonvel = GLOBALutils.get_lunar_props(ephem,gobs,Mcoo,Mp,Sp,res,ra,dec)
refvel = bcvel_baryc + moonvel
print '\t\tRadial Velocity of sacttered moonlight:',refvel
sci_fits = dirout + fsim.split('/')[-1][:-4]+'spec.pkl'
sci_fits_simple = dirout + fsim.split('/')[-1][:-4]+'spec.simple.pkl'
P_fits = dirout + 'P_' + fsim.split('/')[-1][:-4]+'spec.fits'
if ( os.access(sci_fits,os.F_OK) == False ) or ( os.access(sci_fits_simple,os.F_OK) == False ) or \
( force_sci_extract ):
print "\t\tNo previous extraction or extraction forced for science file", fsim, "extracting..."
#"""
print "\t\t\tweights for chip1..."
Mho = '0'+Mho
mins = (HHOUR - int(Mho))*60.
Mmi = str(int(mins))
if len(Mmi)<2:
Mmi = '0'+Mmi
segs = (mins - int(Mmi))*60.
if segs<10:
Mse = '0'+str(segs)[:5]
else:
Mse = str(segs)[:6]
gobs.date = str(DDATE[:4]) + '-' + str(DDATE[4:6]) + '-' + str(DDATE[6:]) + ' ' + Mho + ':' + Mmi +':' +Mse
mephem = ephem.Moon()
mephem.compute(gobs)
Mcoo = jplephem.object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Mp = jplephem.barycentric_object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Sp = jplephem.barycentric_object_track("Sun", int(mjd), float(mjd%1), 1, 0.0)
res = jplephem.object_doppler("Moon", int(mjd), mjd%1, 1, 0.0)
lunation,moon_state,moonsep,moonvel = GLOBALutils.get_lunar_props(ephem,gobs,Mcoo,Mp,Sp,res,ra,dec)
refvel = bcvel_baryc + moonvel
print '\t\tRadial Velocity of sacttered moonlight:',refvel
sorted_indices = np.argsort( np.abs( np.array(ThAr_ref_dates) - mjd ) )
sorted_indices_FP = np.argsort( np.abs( np.array(ThFP_ref_dates) - mjd ) )
print '\t\tExtraction:'
# optimally and simply extract spectra
sci_fits_ob = dirout + fsim.split('/')[-1][:-8]+'spec.ob.fits.S'
sci_fits_co = dirout + fsim.split('/')[-1][:-8]+'spec.co.fits.S'
sci_fits_ob_simple = dirout + fsim.split('/')[-1][:-8]+'spec.simple.ob.fits.S'
sci_fits_co_simple = dirout + fsim.split('/')[-1][:-8]+'spec.simple.co.fits.S'
bcvel_baryc = ( lbary_ltopo - 1.0 ) * 2.99792458E5
print "\t\tBarycentric velocity:", bcvel_baryc
res = jplephem.pulse_delay(ra/15.0, dec, int(mjd), mjd%1, 1, 0.0)
mbjd = mjd + res['delay'][0] / (3600.0 * 24.0)
# Moon Phase Calculations
gobs = ephem.Observer()
gobs.name = 'Keck'
gobs.lat = rad(latitude) # lat/long in decimal degrees
gobs.long = rad(longitude)
gobs.date = h[0].header['DATE-OBS'] + ' ' + h[0].header['UTC'].replace(':','-')
mephem = ephem.Moon()
mephem.compute(gobs)
Mcoo = jplephem.object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Mp = jplephem.barycentric_object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Sp = jplephem.barycentric_object_track("Sun", int(mjd), float(mjd%1), 1, 0.0)
res = jplephem.object_doppler("Moon", int(mjd), mjd%1, 1, 0.0)
lunation,moon_state,moonsep,moonvel = GLOBALutils.get_lunar_props(ephem,gobs,Mcoo,Mp,Sp,res,ra,dec)
refvel = bcvel_baryc + moonvel
print '\t\tRadial Velocity of sacttered moonlight:',refvel
sci_fits = dirout + fsim.split('/')[-1][:-4]+'spec_'+str(int(chip))+'.fits'
sci_fits_simple = dirout + fsim.split('/')[-1][:-4]+'spec.simple_'+str(int(chip))+'.fits'
P_fits = dirout + 'P_' + fsim.split('/')[-1][:-4]+'spec_'+str(int(chip))+'.fits'
if ( os.access(sci_fits,os.F_OK) == False ) or ( os.access(sci_fits_simple,os.F_OK) == False ) or \
( force_sci_extract ):
print "\t\tNo previous extraction or extraction forced for science file", fsim, "extracting..."
print "\t\tBarycentric velocity:", bcvel_baryc
res = jplephem.pulse_delay(ra/15.0, dec, int(mjd), mjd%1, 1, 0.0)
mbjd = mjd + res['delay'][0] / (3600.0 * 24.0)
# Moon Phase Calculations
gobs = ephem.Observer()
gobs.name = 'Eso2.2'
gobs.lat = rad(latitude) # lat/long in decimal degrees
gobs.long = rad(longitude)
gobs.date = h[0].header['DATE-OBS'][:10] + ' ' + h[0].header['DATE-OBS'][11:]
mephem = ephem.Moon()
mephem.compute(gobs)
Mcoo = jplephem.object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Mp = jplephem.barycentric_object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Sp = jplephem.barycentric_object_track("Sun", int(mjd), float(mjd%1), 1, 0.0)
res = jplephem.object_doppler("Moon", int(mjd), mjd%1, 1, 0.0)
lunation,moon_state,moonsep,moonvel = GLOBALutils.get_lunar_props(ephem,gobs,Mcoo,Mp,Sp,res,ra,dec)
refvel = bcvel_baryc + moonvel
print '\t\tRadial Velocity of sacttered moonlight:',refvel
ThAr_Ne_ref_m = ThAr_Ne_ref
ThAr_Ne_ref_dates_m = ThAr_Ne_ref_dates
sorted_indices = np.argsort( np.abs( np.array(ThAr_Ne_ref_dates_m) - mjd ) )
sci_fits_ob = dirout + fsim.split('/')[-1][:-4]+'spec.ob.fits.S'
sci_fits_co = dirout + fsim.split('/')[-1][:-4]+'spec.co.fits.S'
sci_fits_ob_simple = dirout + fsim.split('/')[-1][:-4]+'spec.simple.ob.fits.S'
sci_fits_co_simple = dirout + fsim.split('/')[-1][:-4]+'spec.simple.co.fits.S'
res = jplephem.pulse_delay(ra/15.0, dec, int(mjd), mjd%1, 1, 0.0)
mbjd = mjd + res['delay'][0] / (3600.0 * 24.0)
gobs = ephem.Observer()
gobs.name = h[0].header['TELESCOP']
gobs.lat = rad(latitude) # lat/long in decimal degrees
gobs.long = rad(longitude)
timeT = h[0].header['UTC-OBS'].split(':')
if len(timeT[0]) == 1:
gobs.date = h[0].header['DATE-OBS'][:10] + ' 0' + h[0].header['UTC-OBS']
else:
gobs.date = h[0].header['DATE-OBS'][:10] + ' ' + h[0].header['UTC-OBS']
mephem = ephem.Moon()
mephem.compute(gobs)
Mcoo = jplephem.object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Mp = jplephem.barycentric_object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Sp = jplephem.barycentric_object_track("Sun", int(mjd), float(mjd%1), 1, 0.0)
res = jplephem.object_doppler("Moon", int(mjd), mjd%1, 1, 0.0)
lunation,moon_state,moonsep,moonvel = GLOBALutils.get_lunar_props(ephem,gobs,Mcoo,Mp,Sp,res,ra,dec)
refvel = bcvel_baryc + moonvel
print '\t\tRadial Velocity of sacttered moonlight:',refvel
#moon_alts.update({fsim:mephem.alt})
#moon_ills.update({fsim:lunation})
print '\t\tExtraction:'
if mode == 'so':
sci_fits = dirout + fsim.split('/')[-1][:-4]+'spec.fits.S'
sci_fits_simple = dirout + fsim.split('/')[-1][:-4]+'spec.simple.fits.S'
if ( os.access(sci_fits,os.F_OK) == False ) or ( os.access(sci_fits_simple,os.F_OK) == False ) or \
mbjd = mjd + res['delay'][0] / (3600.0 * 24.0)
# Moon Phase Calculations
gobs = ephem.Observer()
gobs.name='Clay_Mag_2'
gobs.lat=rad(latitude) # lat/long in decimal degrees
gobs.long=rad(longitude)
DDATE = h[0].header['UT-DATE']
HHOUR = h[0].header['UT-TIME']
Mho = HHOUR[:2]
Mmi = HHOUR[3:5]
Mse = HHOUR[6:]
gobs.date = str(DDATE[:4]) + '-' + str(DDATE[5:6]) + '-' + str(DDATE[7:]) + ' ' + Mho + ':' + Mmi +':' +Mse
mephem = ephem.Moon()
mephem.compute(gobs)
Mcoo = jplephem.object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Mp = jplephem.barycentric_object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Sp = jplephem.barycentric_object_track("Sun", int(mjd), float(mjd%1), 1, 0.0)
res = jplephem.object_doppler("Moon", int(mjd), mjd%1, 1, 0.0)
lunation,moon_state,moonsep,moonvel = GLOBALutils.get_lunar_props(ephem,gobs,Mcoo,Mp,Sp,res,ra,dec)
refvel = bcvel_baryc + moonvel
print '\t\tRadial Velocity of sacttered moonlight:',refvel
sorted_indices = np.argsort( np.abs( np.array(thar_dates) - mjd ) )
# optimally and simply extract spectra
sci_fits = dirout + 'PFS_' + h[0].header['UT-DATE'] + '_' + h[0].header['UT-TIME'] +'.'+ obname +'.spec.fits'
sci_fits_simple = dirout + 'PFS_' + h[0].header['UT-DATE'] + '_' + h[0].header['UT-TIME'] +'.'+ obname +'.spec.simple.fits'
P_fits = dirout + 'P_' + h[0].header['UT-DATE'] + '_' + h[0].header['UT-TIME'] +'.'+ obname +'.fits'
# Open file, trim, overscan subtract and MasterBias subtract
# Moon Phase Calculations
gobs = ephem.Observer()
gobs.name='Clay_Mag_2'
gobs.lat=rad(latitude) # lat/long in decimal degrees
gobs.long=rad(longitude)
DDATE = h[ih].header['UT-DATE']
HHOUR = mikeutils.get_hour(float(h[ih].header['UT-TIME']))
Mho = HHOUR[:2]
Mmi = HHOUR[3:5]
Mse = HHOUR[6:]
gobs.date = str(DDATE[:4]) + '-' + str(DDATE[5:6]) + '-' + str(DDATE[7:]) + ' ' + Mho + ':' + Mmi +':' +Mse
mephem = ephem.Moon()
mephem.compute(gobs)
Mcoo = jplephem.object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Mp = jplephem.barycentric_object_track("Moon", int(mjd), float(mjd%1), 1, 0.0)
Sp = jplephem.barycentric_object_track("Sun", int(mjd), float(mjd%1), 1, 0.0)
res = jplephem.object_doppler("Moon", int(mjd), mjd%1, 1, 0.0)
lunation,moon_state,moonsep,moonvel = GLOBALutils.get_lunar_props(ephem,gobs,Mcoo,Mp,Sp,res,ra,dec)
refvel = bcvel_baryc + moonvel
print '\t\tRadial Velocity of sacttered moonlight:',refvel
sorted_indices = np.argsort( np.abs( np.array(thar_dates) - mjd ) )
# optimally and simply extract spectra
sci_fits = dirout + 'MIKE_' + h[ih].header['UT-DATE'] + '_' + HHOUR +'.'+ obname +'.spec.fits'
sci_fits_simple = dirout + 'MIKE_' + h[ih].header['UT-DATE'] + '_' + HHOUR +'.'+ obname +'.spec.simple.fits'
P_fits = dirout + 'P_' + h[ih].header['UT-DATE'] + '_' + HHOUR +'.'+ obname +'.fits'
# Open file, trim, overscan subtract and MasterBias subtract
data = h[ih].data
lbary_ltopo = 1.0 + res['frac'][0]
bcvel_baryc = ( lbary_ltopo - 1.0 ) * 2.99792458E5 #This in the barycentric velocity
res = jplephem.pulse_delay(RA/15.0, DEC, int(scmjd), scmjd%1, 1, 0.0)
scmbjd = scmjd + res['delay'][0] / (3600.0 * 24.0) #This is the modified barycentric julian day of the observation
# set observatory info to retrive info about the moon
gobs = ephem.Observer()
gobs.name = 'DUPONT'
gobs.lat = rad(latitude)
gobs.long = rad(longitude)
#gobs.date = hd['UT-DATE'] + ' ' + hd['UT-TIME'].replace(':','_')
gobs.date = hd['UT-DATE'].replace('-','/') + ' ' + hd['UT-TIME']
mephem = ephem.Moon()
mephem.compute(gobs)
Mcoo = jplephem.object_track("Moon", int(scmjd), float(scmjd%1), 1, 0.0)
Mp = jplephem.barycentric_object_track("Moon", int(scmjd), float(scmjd%1), 1, 0.0)
Sp = jplephem.barycentric_object_track("Sun", int(scmjd), float(scmjd%1), 1, 0.0)
res = jplephem.object_doppler("Moon", int(scmjd), scmjd%1, 1, 0.0)
lunation,moon_state,moonsep2,moonvel = GLOBALutils.get_lunar_props(ephem,gobs,Mcoo,Mp,Sp,res,RA,DEC)
refvel = bcvel_baryc + moonvel #This is the velocity of the spectrum of the moon with the applied barycentric correction in the direction of the target.
print '\t\t\tBarycentric velocity:',refvel
# Set the ThAr lamps for applying the wavelength solution
if scmjd < thtimes[0]:
"\t\t\tProblem with ThAr and science times"
index1 = 0
index2 = 0
elif scmjd > thtimes[-1]:
"\t\t\tProblem with ThAr and science times"
index1 = -1