From 74422c15edbe571b4a3211e4974a7efc2350eba9 Mon Sep 17 00:00:00 2001 From: Sean-Morrison Date: Thu, 27 Jan 2022 09:41:59 -0700 Subject: [PATCH] FPS updates --- bin/run_PyXCSAO.py | 2 + pro/rm/rm_spcoadd_v5.pro | 66 +++++++++++++++++++---- pro/rm/rm_spflux_v5.pro | 4 +- pro/rm/spreduce1d_empca.pro | 4 +- pro/spec1d/conflist.pro | 78 ++++++++++++++------------- pro/spec1d/fieldmerge.pro | 87 +++++++++++++++++++++---------- pro/spec1d/reformat_spec.pro | 7 +-- pro/spec1d/sdss_spec_image.pro | 45 +++++++++++----- pro/spec2d/prerun_readplugmap.pro | 46 +++++++++++++++- pro/spec2d/readplugmap.pro | 10 ++-- pro/spec2d/spplan1d.pro | 28 +++++++--- pro/spec2d/uubatchpbs.pro | 22 ++++++-- 12 files changed, 285 insertions(+), 114 deletions(-) diff --git a/bin/run_PyXCSAO.py b/bin/run_PyXCSAO.py index a46a5b167..c8a43d6a0 100755 --- a/bin/run_PyXCSAO.py +++ b/bin/run_PyXCSAO.py @@ -64,6 +64,8 @@ def get_fiber(flux, PlugMap, hdr, i): meta['mjd']=hdr['MJD'] meta['TARGET_INDEX']=PlugMap['TARGET_INDEX'][i] + if 'FIBERID_LIST' in PlugMap.colnames: + meta['FIBERID_LIST']=PlugMap['FIBERID_LIST'][i] #meta['fiber']=PlugMap['FIBERID'][i] #meta['snr']=PlugMap['SN_MEDIAN_ALL'][i] meta['snr']=np.nan diff --git a/pro/rm/rm_spcoadd_v5.pro b/pro/rm/rm_spcoadd_v5.pro index c73c7b031..a95504ed9 100644 --- a/pro/rm/rm_spcoadd_v5.pro +++ b/pro/rm/rm_spcoadd_v5.pro @@ -256,6 +256,13 @@ pro rm_spcoadd_v5, spframes, outputname, $ cameras = strtrim(sxpar(hdr, 'CAMERAS'),2) expstr = string(sxpar(hdr, 'EXPOSURE'), format='(i8.8)') + thisdesign = sxpar(hdr,'DESIGNID') + thisconfig = sxpar(hdr,'CONFID') + if (NOT keyword_set(designlist)) then designlist = thisdesign $ + else designlist = [designlist, thisdesign] + if (NOT keyword_set(configlist)) then configlist = thisconfig $ + else configlist = [configlist, thisconfig] + ;---------- ; Solve for wavelength and lambda-dispersion at each pixel in the image @@ -580,6 +587,8 @@ pro rm_spcoadd_v5, spframes, outputname, $ finalplugmap_rm = replicate(plugmap[0], nfiber, nexp_tmp) finalra_rm = fltarr(nfiber, nexp_tmp) finaldec_rm = fltarr(nfiber, nexp_tmp) +; final_FIBERID = strarr(nfiber) + fiberid_rm = lonarr(nfiber,nexp_tmp) mjds_rm = lonarr(nfiber, nexp_tmp) config_rm = lonarr(nfiber, nexp_tmp) tai_rm = fltarr(nfiber, nexp_tmp) @@ -646,7 +655,11 @@ pro rm_spcoadd_v5, spframes, outputname, $ dectemp=plugmap[indx].dec finaldec_rm[ifiber,iexp]=dectemp[0] mjds_rm[ifiber,iexp]=rm_plugmap[iexp].mjd - tai_rm[ifiber,iexp]=rm_plugmap[iexp].tai+rm_plugmap[iexp].exptime/2.0 + ;print, plugmap[indx[0]].fiberid, indx + ;print, fiberid_rm[ifiber, iexp], ifiber, iexp + fiberid_rm[ifiber, iexp] = plugmap[indx[0]].fiberid + ;print, fiberid_rm[ifiber, iexp] + tai_rm[ifiber,iexp]=rm_plugmap[iexp].tai+double(rm_plugmap[iexp].exptime/2.0) ; use expuse number instad of configuration number for legacy config_rm[ifiber,iexp]=rm_plugmap[iexp].configuration endif else begin @@ -756,6 +769,8 @@ pro rm_spcoadd_v5, spframes, outputname, $ moon_target = strarr(ntarget) moon_phasef = strarr(ntarget) tai_target = strarr(ntarget) + fiber_target = strarr(ntarget) + fiber_target_s=replicate(create_struct('FIBERID_LIST',' '),ntarget) indx_target_s=replicate(create_struct('target_index',0),ntarget) nexp_target_s=replicate(create_struct('nexp',0),ntarget) mjdf_target_s=replicate(create_struct('MJD_FINAL',0.D),ntarget) @@ -776,7 +791,8 @@ pro rm_spcoadd_v5, spframes, outputname, $ plugmap[indx[0]].mag, format = '(a, i5.4, a, a, f6.2, 5f6.2)' finalplugmap[itarget] = plugmap[indx[0]] mjds[itarget]=mjds_rm[indx[0]] - ;mjd_final[itarget] + ;mjd_finaldd[itarget] + ; final_FIBERID[itarget]=strtrim(strcompress(string(plugmap[indx].FIBERID,format='(999a)')),2) final_ra[itarget]=plugmap[indx[0]].ra final_dec[itarget]=plugmap[indx[0]].dec ; ;Check this part, this will no longer the case for the BHM @@ -827,6 +843,8 @@ pro rm_spcoadd_v5, spframes, outputname, $ ;print, indx_tar[nt[0]+1:nt[1]-1]/nfiber mod nexp_tmp indx_target_s.target_index=indx_target nexp_target_s.nexp=nexp_target + ; fiber_target_s.FIBERID_LIST=final_FIBERID + ;finalplugmap=struct_addtags(finalplugmap,fiber_target_s) finalplugmap=struct_addtags(finalplugmap,indx_target_s) finalplugmap=struct_addtags(finalplugmap,nexp_target_s) ;---------- @@ -951,7 +969,8 @@ pro rm_spcoadd_v5, spframes, outputname, $ if (indx[0] NE -1) then begin moon_target[itarget]=moon_target_rm[indx[0]] moon_phasef[itarget]=moon_phasef_rm[indx[0]] - tai_target[itarget]=strtrim(strcompress(string(tai_rm[indx[0]],format='(999a)')),2) + fiber_target[itarget]=strtrim(strcompress(string(fiberid_rm[indx[0]],format='(999a)')),2) + tai_target[itarget]=strtrim(strcompress(string(string(tai_rm[indx[0]],format='(i15)'),format='(999a)')),2) snr2G_target[itarget]=snr2listG[indx[0]];strtrim(strcompress(string(snr2listG[0],format='(999a)')),2) snr2R_target[itarget]=snr2listR[indx[0]];strtrim(strcompress(string(snr2listR[0],format='(999a)')),2) snr2I_target[itarget]=snr2listI[indx[0]];strtrim(strcompress(string(snr2listI[0],format='(999a)')),2) @@ -960,7 +979,8 @@ pro rm_spcoadd_v5, spframes, outputname, $ ;print,iexp,indx[iexp],n_elements(indx),n_elements(moon_target_rm) moon_target[itarget]=moon_target[itarget]+' '+moon_target_rm[indx[iexp]] moon_phasef[itarget]=moon_phasef[itarget]+' '+moon_phasef_rm[indx[iexp]] - tai_target[itarget]=tai_target[itarget]+' '+strtrim(strcompress(string(tai_rm[indx[iexp]],format='(999a)')),2) + fiber_target[itarget]=fiber_target[itarget]+' '+strtrim(strcompress(string(fiberid_rm[indx[iexp]],format='(999a)')),2) + tai_target[itarget]=tai_target[itarget]+' '+strtrim(strcompress(string(string(tai_rm[indx[iexp]],format='(i15)'),format='(999a)')),2) snr2G_target[itarget]=snr2G_target[itarget]+' '+snr2listG[indx[iexp]];strtrim(strcompress(string(snr2listG[iexp],format='(999a)')),2) snr2R_target[itarget]=snr2R_target[itarget]+' '+snr2listR[indx[iexp]];strtrim(strcompress(string(snr2listR[iexp],format='(999a)')),2) snr2I_target[itarget]=snr2I_target[itarget]+' '+snr2listI[indx[iexp]];strtrim(strcompress(string(snr2listI[iexp],format='(999a)')),2) @@ -1029,6 +1049,8 @@ pro rm_spcoadd_v5, spframes, outputname, $ finalplugmap=struct_addtags(finalplugmap,moon_target_s) moon_phasef_s.moon_phase=moon_phasef finalplugmap=struct_addtags(finalplugmap,moon_phasef_s) + fiber_target_s.fiberid_list=fiber_target + finalplugmap=struct_addtags(finalplugmap,fiber_target_s) tai_target_s.tai_list=tai_target finalplugmap=struct_addtags(finalplugmap,tai_target_s) snr2G_target_s.fieldsnr2g_list=snr2G_target @@ -1145,6 +1167,8 @@ pro rm_spcoadd_v5, spframes, outputname, $ for i=2, ncoeff-1 do sxdelpar, bighdr, 'COEFF'+strtrim(string(i),2) sxdelpar, bighdr, ['SPA', 'IPA', 'IPARATE'] + sxdelpar, bighdr, 'CONFID' + sxdelpar, bighdr, 'DESIGNID' sxdelpar, bighdr, 'EXPOSURE' sxdelpar, bighdr, 'REQTIME' sxdelpar, bighdr, 'QUALITY' @@ -1171,7 +1195,7 @@ pro rm_spcoadd_v5, spframes, outputname, $ ;---------- ; Average together some of the fields from the individual headers. fieldid - cardname = [ 'AZ', 'ALT', 'TAI', 'WTIME', 'AIRTEMP', 'DEWPOINT', $ + cardname = [ 'AZ', 'ALT', 'AIRMASS', 'TAI', 'WTIME', 'AIRTEMP', 'DEWPOINT', $ 'DEWDEP', 'DUSTA', 'DUSTB', 'DUSTC', 'DUSTD', 'GUSTS', 'HUMIDITY', $ 'HUMIDOUT', 'PRESSURE', 'WINDD', 'WINDS', 'TEMP01', 'TEMP02', $ 'TEMP03', 'TEMP04', 'HELIO_RV', 'SEEING20', 'SEEING50', 'SEEING80', $ @@ -1221,8 +1245,19 @@ pro rm_spcoadd_v5, spframes, outputname, $ ; Get the list of MJD's used for these reductions, then convert to a string mjdlist = mjdlist[uniq(mjdlist, sort(mjdlist))] - mjdlist = strtrim(strcompress(string(mjdlist,format='(99a)')),2) - sxaddpar, bighdr, 'MJDLIST', mjdlist, after='MJD' + mjdlist = strtrim(strcompress(string(mjdlist,format='(999a)')),2) + sxaddpar, bighdr, 'MJDLIST', mjdlist, ' MJDs coadded for epoch', after='MJD' + + ; Get the list of Designs used for these reductions, then convert to a string + designlist = designlist[uniq(designlist, sort(designlist))] + designlist = strtrim(strcompress(string(designlist,format='(999a)')),2) + sxaddpar, bighdr, 'DESIGNS',designlist, ' DesignIDs coadded', after='MJDLIST' + + ; Get the list of configurations used for these reductions, then convert to a string + configlist = configlist[uniq(configlist, sort(configlist))] + configlist = strtrim(strcompress(string(configlist,format='(999a)')),2) + sxaddpar, bighdr, 'CONFIGS', configlist, ' FPS ConfigIDs coadded', after='DESIGNS' + if keyword_set(tai_flag) then begin indtai=uniq(tailist, sort(tailist)) tailist = tailist[indtai] @@ -1233,10 +1268,10 @@ pro rm_spcoadd_v5, spframes, outputname, $ snr2listG = strtrim(strcompress(string(snr2listG,format='(999a)')),2) snr2listR = strtrim(strcompress(string(snr2listR,format='(999a)')),2) snr2listI = strtrim(strcompress(string(snr2listI,format='(999a)')),2) - sxaddpar, bighdr, 'TAILIST', tailist, after='MJDLIST' - sxaddpar, bighdr, 'SN2GLIST', snr2listG, after='TAILIST' - sxaddpar, bighdr, 'SN2RLIST', snr2listR, after='SN2GLIST' - sxaddpar, bighdr, 'SN2ILIST', snr2listI, after='SN2RLIST' + sxaddpar, bighdr, 'TAILIST', tailist,' TAIs of individual exposures in Coadd', after='CONFIGS' + sxaddpar, bighdr, 'SN2GLIST', snr2listG,' SN2 in g of individual exposures in Coadd', after='TAILIST' + sxaddpar, bighdr, 'SN2RLIST', snr2listR,' SN2 in r of individual exposures in Coadd', after='SN2GLIST' + sxaddpar, bighdr, 'SN2ILIST', snr2listI,' SN2 in i of individual exposures in Coadd', after='SN2RLIST' endif ;---------- ; Add new header cards @@ -1314,6 +1349,15 @@ pro rm_spcoadd_v5, spframes, outputname, $ bighdr_rm=bighdr sxaddpar, bighdr_rm, 'NAXIS3', nexp_tmp, '' + ;---------- + ; Clean plugmap + tags_to_delete= ['POSITIONERID','HOLEID', 'XWOK', 'YWOK', 'ZWOK', $ + 'XFOCAL', 'YFOCAL', 'ZFOCAL', 'ALPHA', 'BETA', 'FIBERID'] + foreach tag, tags_to_delete do begin + if tag_exist(finalplugmap,tag) then $ + finalplugmap = struct_trimtags(finalplugmap,except_tags=[tag]) + endforeach + ;---------- ; Add keywords for IRAF-compatability diff --git a/pro/rm/rm_spflux_v5.pro b/pro/rm/rm_spflux_v5.pro index 09eacb9b3..e280152a8 100644 --- a/pro/rm/rm_spflux_v5.pro +++ b/pro/rm/rm_spflux_v5.pro @@ -801,8 +801,8 @@ pro rm_spflux_v5, objname, adderr=adderr, combinedir=combinedir, $ if strmatch(programname, '*MWM*', /fold_case) eq 1 then MWMPlate=1 if strmatch(programname, '*OFFSET*', /fold_case) eq 1 then MWMPlate=1 endif else begin - racen = sxpar(objhdr, 'RACEN') - deccen = sxpar(objhdr, 'DECCEN') + racen = sxpar(hdr, 'RACEN') + deccen = sxpar(hdr, 'DECCEN') euler, racen, deccen, ll, bb, 1 if abs(bb) lt 15. then MWMPlate=1 endelse diff --git a/pro/rm/spreduce1d_empca.pro b/pro/rm/spreduce1d_empca.pro index 388fc626f..0761ae7e5 100644 --- a/pro/rm/spreduce1d_empca.pro +++ b/pro/rm/spreduce1d_empca.pro @@ -549,6 +549,7 @@ flambda2fnu = 0 ; Free memory tile: long(sxpar(hdr, 'TILEID')), $ mjd: long(sxpar(hdr, 'MJD')), $ fiberid: 0L , $ + fiberid_List: '', $ run2d: strtrim(sxpar(hdr, 'RUN2D'),2), $ run1d: run1d, $ ;objid: lindgen(5), $ @@ -560,6 +561,7 @@ flambda2fnu = 0 ; Free memory for iobj=0, nobj-1 do begin res_all[*,iobj].fiberid = fiberid[iobj] + res_all[*,iobj].fiberid_list = plugmap[iobj].fiberid_list ;res_all[*,iobj].objid = plugmap[iobj].objid res_all[*,iobj].objtype = plugmap[iobj].objtype res_all[*,iobj].plug_ra = plugmap[iobj].ra @@ -900,7 +902,7 @@ endif ;---------- ; Add the cas-styled specobjid to output - zans = struct_addtags(zans, replicate({specobjid:0LL},n_elements(zans))) + zans = struct_addtags(zans, replicate({specobjid:0ULL},n_elements(zans))) words= STREGEX(STRTRIM(zans.run2d,2),'^v([0-9]+)_([0-9]+)_([0-9]+)', /SUB, /EXTRACT) ; did it parse as vXX_YY_ZZ? if words[0] ne '' then begin diff --git a/pro/spec1d/conflist.pro b/pro/spec1d/conflist.pro index 4a269a410..aba716d00 100644 --- a/pro/spec1d/conflist.pro +++ b/pro/spec1d/conflist.pro @@ -612,8 +612,10 @@ pro conflist, plist=plist, create=create, $ endif else begin plist = create_struct( $ 'field' , 0L, $ - 'tileid' , 0L, $ - 'designid' , 0L, $ +; 'tileid' , 0L, $ +; 'designid' , 0L, $ + 'DESIGNS' , '', $ + 'CONFIGS' , '', $ 'mjd' , 0L, $ 'run2d' , '', $ 'run1d' , '', $ @@ -629,14 +631,14 @@ pro conflist, plist=plist, create=create, $ 'mapname' , ' ', $ 'survey' , ' ', $ 'programname' , ' ', $ - 'chunk' , ' ', $ - 'chunkhtml' , ' ', $ + ;'chunk' , ' ', $ + ;'chunkhtml' , ' ', $ 'plotsn' , ' ', $ 'data' , ' ', $ 'plots' , ' ', $ 'fieldquality' , ' ', $ 'fieldsn2' , 0.0, $ - 'deredsn2' , 0.0, $ + ;'deredsn2' , 0.0, $ 'qsurvey' , 0L, $ 'mjdlist' , ' ', $ 'tailist' , ' ', $ @@ -655,9 +657,9 @@ pro conflist, plist=plist, create=create, $ ;'sn2_g2' , 0.0, $ ;'sn2_r2' , 0.0, $ ;'sn2_i2' , 0.0, $ - 'dered_sn2_g1' , 0.0, $ - 'dered_sn2_r1' , 0.0, $ - 'dered_sn2_i1' , 0.0, $ + ;'dered_sn2_g1' , 0.0, $ + ;'dered_sn2_r1' , 0.0, $ + ;'dered_sn2_i1' , 0.0, $ ;'dered_sn2_g2' , 0.0, $ ;'dered_sn2_r2' , 0.0, $ ;'dered_sn2_i2' , 0.0, $ @@ -729,7 +731,7 @@ pro conflist, plist=plist, create=create, $ 'moon_frac' , 0.0 ) endelse endelse - + if (not keyword_set(legacy)) and (not keyword_set(plates)) then rawsn2 = 1 if keyword_set(rawsn2) then begin if keyword_set(legacy) then sn2tag = 'platesn2' else sn2tag = 'fieldsn2' dereddened_sn2 = 0 @@ -809,7 +811,7 @@ pro conflist, plist=plist, create=create, $ ['moon_frac' , 'f5.1'], $ ['survey' , 'a'], $ ['programname' , 'a'], $ - ['chunkhtml' , 'a'], $ +; ['chunkhtml' , 'a'], $ ['designid' , 'i'], $ ['public' , 'a'] ] ;; For platequality @@ -841,7 +843,7 @@ pro conflist, plist=plist, create=create, $ endif else begin ;; For platelist trimtags1 = [ $ - ['field' , 'i6'], $ + ['field' , 'i7'], $ ['mjd' , 'i5'], $ ['plots' , 'a'], $ ['racen' , 'f6.2'], $ @@ -860,13 +862,14 @@ pro conflist, plist=plist, create=create, $ ['moon_frac' , 'f5.1'], $ ['survey' , 'a'], $ ['programname' , 'a'], $ - ['chunkhtml' , 'a'], $ + ;['chunkhtml' , 'a'], $ ;['tileid' , 'i'], $ - ['designid' , 'i'], $ + ;['designid' , 'i'], $ + ['designs' , 'a'], $ ['public' , 'a'] ] ;; For platequality trimtags2 = [ $ - ['field' , 'i6'], $ + ['field' , 'i7'], $ ['mjd' , 'i5'], $ ['plots' , 'a'], $ ['run2d' , 'a'], $ @@ -905,9 +908,6 @@ pro conflist, plist=plist, create=create, $ root_dir=getenv('SDSSCORE_DIR'), subdirectory='opfiles') publicdata = yanny_readone(publicfile, 'SPCONFLIST') endelse - ;print,publicfile - ;print,getenv('SDSSCORE') - ;print,publicdata ;if (NOT keyword_set(publicdata)) then $ ; message, 'Missing spConfList.par file' @@ -935,9 +935,7 @@ pro conflist, plist=plist, create=create, $ then begin combparfile[ifile] = fullfile[ifile] ;hdrp=0 - ;print,fullfile[ifile] yanny_read, fullfile[ifile], hdr=hdrp,/anonymous - ;print,plate_to_string(yanny_par(hdrp,'plateid')) if keyword_set(legacy) or keyword_set(plates) then begin ;plt_strt= platefile[ifile] = $ @@ -1075,6 +1073,8 @@ pro conflist, plist=plist, create=create, $ ; plist[ifile].mjd = sxpar(hdr1, 'MJD') plist[ifile].mjdlist = sxpar(hdr1, 'MJDLIST') plist[ifile].tailist = sxpar(hdr1, 'TAILIST') + plist[ifile].designs = sxpar(hdr1, 'DESIGNS') + plist[ifile].configs = sxpar(hdr1, 'CONFIGS') ; thisrun2d = sxpar(hdr1, 'RUN2D', count=ct) ; plist[ifile].run2d = (ct GT 0) ? thisrun2d : '' ; plist[ifile].tileid = sxpar(hdr1, 'TILEID') ; Get from platePlans @@ -1097,9 +1097,9 @@ pro conflist, plist=plist, create=create, $ plist[ifile].sn2_r1 = sxpar(hdr1, 'SPEC1_R') plist[ifile].sn2_i1 = sxpar(hdr1, 'SPEC1_I') ; If these keywords don't exist, these will just get 0 - plist[ifile].dered_sn2_g1 = sxpar(hdr1, 'SN2EXT1G') - plist[ifile].dered_sn2_r1 = sxpar(hdr1, 'SN2EXT1R') - plist[ifile].dered_sn2_i1 = sxpar(hdr1, 'SN2EXT1I') + if tag_exist(plist, 'dered_sn2_g1') then plist[ifile].dered_sn2_g1 = sxpar(hdr1, 'SN2EXT1G') + if tag_exist(plist, 'dered_sn2_r1') then plist[ifile].dered_sn2_r1 = sxpar(hdr1, 'SN2EXT1R') + if tag_exist(plist, 'dered_sn2_i1') then plist[ifile].dered_sn2_i1 = sxpar(hdr1, 'SN2EXT1I') if keyword_set(legacy) then begin plist[ifile].nexp_b2 = sxpar(hdr1, 'NEXP_B2') plist[ifile].nexp_r2 = sxpar(hdr1, 'NEXP_R2') @@ -1212,11 +1212,11 @@ pro conflist, plist=plist, create=create, $ ;---------- ; Determine the chunk name and the version of target used if keyword_set(plates) or keyword_set(legacy) then begin - plist[ifile].field = long( strmid(fi, p1+1, p2-p1-1) ) - cinfo = chunkinfo(plist[ifile].field,plates=plates,legacy=legacy) - endif else begin plist[ifile].field = long( strmid(fi, p1+1, p2-p1-1) ) cinfo = chunkinfo(plist[ifile].field,plates=plates,legacy=legacy) + endif else begin + plist[ifile].field = long( strmid(fi, p1+1, p2-p1-1) ) + ;cinfo = chunkinfo(plist[ifile].field,plates=plates,legacy=legacy) endelse if keyword_set(cinfo) then begin plist[ifile].survey = cinfo.survey @@ -1232,13 +1232,14 @@ pro conflist, plist=plist, create=create, $ if keyword_set(plates) or keyword_set(legacy) then begin splog, 'Empty or missing platePlans.par file' endif else begin - splog, 'Empty or missing configPlans.par file' + ;splog, 'Empty or missing configPlans.par file' fibermap='fibermap-'+strtrim(yanny_par(hdrp,'fieldid'),2)+'.fits' fibermap=djs_filepath(fibermap, root_dir=topdir + '/' + run2d, subdir=field_to_string(yanny_par(hdrp,'fieldid'))) if FILE_TEST(fibermap) then begin plughead=headfits(fibermap,EXTEN=1) plist[ifile].racen = sxpar(plughead,'RACEN') plist[ifile].deccen = sxpar(plughead,'DECCEN') +; plist[ifile].DESIGNID = sxpar(plughead,'DESIGN_ID') ;if strtrim(sxpar(plughead,'OBS'),2) EQ 'APO' endif else splog, 'Empty or missing fibermap: '+fibermap endelse @@ -1346,14 +1347,14 @@ pro conflist, plist=plist, create=create, $ qualstring = ['bad', 'marginal', 'good'] for ifile=0L, nfile-1L do begin if (strtrim(plist[ifile].statuscombine,2) EQ 'Done') then begin - if keyword_set(plates) or keyword_set(legacy) then begin + if keyword_set(legacy) then begin strplt=strtrim(string(plist[ifile].field),2) strmjd=strtrim(string(plist[ifile].mjd),2) endif else begin - strplt=strtrim(string(plist[ifile].field),2) + strplt=field_to_string(plist[ifile].field) ; strtrim(string(plist[ifile].field),2) strmjd=strtrim(string(plist[ifile].mjd),2) endelse - plist[ifile].plotsn='SNPLOT' + plist[ifile].plotsn='SNPLOT' if keyword_set(legacy) then begin nexp_min = min( $ [plist[ifile].nexp_b1, plist[ifile].nexp_r1, $ @@ -1376,7 +1377,7 @@ pro conflist, plist=plist, create=create, $ [plist[ifile].nexp_b1, plist[ifile].nexp_r1], max=nexp_max) plist[ifile].fieldsn2 = min( $ [plist[ifile].sn2_g1, plist[ifile].sn2_i1]) - plist[ifile].deredsn2 = min( $ + if tag_exist(plist, 'deredsn2') then plist[ifile].deredsn2 = min( $ [plist[ifile].dered_sn2_g1, plist[ifile].dered_sn2_i1]) if keyword_set(rawsn2) then begin min_sn2_b = plist[ifile].sn2_g1 @@ -1427,9 +1428,11 @@ pro conflist, plist=plist, create=create, $ ; Also insist that PROGNAME='main'. ; First get the unique list of TILE - isort = sort(plist.tileid) - isort = isort[ uniq(plist[isort].tileid) ] - tilelist = plist[isort].tileid + + if tag_exist(plist, 'tileid') then begin + isort = sort(plist.tileid) + isort = isort[ uniq(plist[isort].tileid) ] + tilelist = plist[isort].tileid if keyword_set(legacy) then begin for itile=0L, n_elements(tilelist)-1L do begin @@ -1475,6 +1478,7 @@ pro conflist, plist=plist, create=create, $ endfor endelse endelse + endif ;--------------------------------------------------------------------------- ; Read the Spectro-1D files @@ -1501,14 +1505,14 @@ pro conflist, plist=plist, create=create, $ if (size(hdr2, /tname) EQ 'STRING') then begin - if keyword_set(plates) or keyword_set(legacy) then begin + if keyword_set(legacy) then begin strplt=strtrim(string(plist[ifile].field),2) strmjd=strtrim(string(plist[ifile].mjd),2) endif else begin - strplt=strtrim(string(plist[ifile].field),2) + strplt=field_to_string(plist[ifile].field); strtrim(string(plist[ifile].field),2) strmjd=strtrim(string(plist[ifile].mjd),2) endelse - plist[ifile].data='DATA' + plist[ifile].data='DATA' plist[ifile].plots='PLOTS' zans = mrdfits((*zbestfile[i])[j], 1, /silent) plug = mrdfits(platefile[i], 5, /silent) @@ -1629,7 +1633,7 @@ pro conflist, plist=plist, create=create, $ ;---------- ; Find the state of the 1D reductions -- spZbest file is missing - print, run1d, ' ', (*zlogfile[i])[j] + ; print, run1d, ' ', (*zlogfile[i])[j] ;print,(file_search((*zlogfile[i])[j])) if (file_search((*zlogfile[i])[j])) then begin ;;; spawn, 'tail -1 '+(*zlogfile[i])[j], lastline diff --git a/pro/spec1d/fieldmerge.pro b/pro/spec1d/fieldmerge.pro index 5b76e406f..eb93824ac 100644 --- a/pro/spec1d/fieldmerge.pro +++ b/pro/spec1d/fieldmerge.pro @@ -230,15 +230,16 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ pstuff = create_struct( $ 'programname' , ' ', $ - 'chunk' , ' ', $ +; 'chunk' , ' ', $ 'survey' , ' ', $ ; 'platequality', ' ', $ 'fieldquality', ' ', $ ; 'platesn2' , 0.0, $ 'fieldsn2' , 0.0, $ - 'deredsn2' , 0.0, $ - 'primtarget' , 0L, $ - 'sectarget' , 0L, $ +; 'deredsn2' , 0.0, $ +; 'primtarget' , 0L, $ +; 'sectarget' , 0L, $ + 'fiberid_list' , ' ', $ 'lambda_eff' , 0.0, $ 'bluefiber' , 0L, $ 'zoffset' , 0.0, $ @@ -254,10 +255,10 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ ; 'eboss_target2', 0LL, $ ; 'eboss_target_id', 0LL, $ ; 'thing_id_targeting', 0LL, $ - 'specprimary' , 0B, $ - 'specboss' , 0B, $ - 'boss_specobj_id' , 0L, $ - 'nspecobs' , 0, $ +; 'specprimary' , 0B, $ +; 'specboss' , 0B, $ +; 'boss_specobj_id' , 0L, $ +; 'nspecobs' , 0, $ ;;- SB Oct 2012: remove QSO VAC inputs for DR10 ;; 'z_person' , 0.0, $ ;; 'class_person', 0L, $ @@ -272,10 +273,14 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ 'firstcarton', ' ', $ ; 'sdssv_boss_target0', ulong64(0), $ ; 'catalogid' , ulong64(0), $ - 'mag' , fltarr(5), $ + 'FIBER2MAG', fltarr(5), $ + 'PSFMAG', fltarr(5), $ +; 'mag' , fltarr(5), $ ; 'plate', 0, $ 'field', 0, $ - 'designid', 0, $ + 'designs', '', $ + 'configs', '', $ +; 'designid', 0, $ 'nexp', 0, $ 'exptime', 0, $ 'airmass', 0.0, $ @@ -301,6 +306,11 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ 'gaia_pmra', 0.0, $ 'gaia_pmdec', 0.0,$ 'SPEC_FILE', ' ') + + if keyword_set(legacy) then $ + pstuff = struct_addtags(pstuff, {chunk:'',DEREDSN2:'',primtarget:0L,sectarget:0L,$ + specprimary:0B,specboss:0B,boss_specobj_id:0L,$ + nspecobs:0}) if keyword_set(XCSAO) then $ pstuff = struct_addtags(pstuff, {XCSAO_rv: !values.f_nan, XCSAO_erv: !values.f_nan,$ @@ -325,7 +335,7 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ zans=zans, objhdr=objhdr, $ ;; zmanual=zmanual, plugmap=plugmap, legacy=legacy, plates=plates, /silent, unsigned=(ifile EQ 0) - zans = struct_selecttags(zans, except_tags='OBJID') + zans = struct_selecttags(zans, except_tags=['OBJID','TILE']) if not keyword_set(legacy) then begin zans = struct_selecttags(zans, except_tags='SPEC2_G') zans = struct_selecttags(zans, except_tags='SPEC2_R') @@ -416,7 +426,7 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ pstuff = struct_addtags(pstuff, $ struct_selecttags(plugmap[0], select_tags=htags)) ;pstuff = create_struct(pstuff, plutt[0]) - outdat1 = create_struct(pstuff, struct_selecttags(zans[0], except_tags=['field'])) + outdat1 = create_struct(pstuff, struct_selecttags(zans[0], except_tags=['field','fiberid_list'])) struct_assign, {junk:0}, outdat1 ; Zero-out all elements if keyword_set(xcsao) then begin outdat1.xcsao_rv=!values.f_nan @@ -442,15 +452,18 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ outdat[indx] = tmpdat ; Fill in the first columns of this output structure - outdat[indx].programname = plist[ifile].programname - outdat[indx].chunk = plist[ifile].chunk + if keyword_set(legacy) then begin + outdat[indx].programname = plist[ifile].programname + endif else outdat[indx].programname=plugmap.program + if (tag_exist(outdat,'CHUNK')) then $ + outdat[indx].chunk = plist[ifile].chunk if (tag_exist(plist,'PLATEQUALITY')) then $ outdat[indx].fieldquality = plist[ifile].platequality $ - else outdat[indx].fieldquality = plist[ifile].fieldquality + else outdat[indx].fieldquality = plist[ifile].fieldquality if (tag_exist(plist,'PLATESN2')) then $ outdat[indx].fieldsn2 = plist[ifile].platesn2 $ else outdat[indx].fieldsn2 = plist[ifile].fieldsn2 - if has_deredsn2 then $ + if (has_deredsn2 AND tag_exist(outdat,'deredsn2')) then $ outdat[indx].deredsn2 = plist[ifile].deredsn2 if (tag_exist(plist,'EXPTIME')) then $ outdat[indx].exptime = plist[ifile].exptime @@ -458,8 +471,15 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ outdat[indx].airmass = plist[ifile].airmass if (tag_exist(plist,'DESIGNID')) then $ outdat[indx].designid = plist[ifile].designid + if (tag_exist(plist,'DESIGNS')) then $ + outdat[indx].designs = plist[ifile].designs + if (tag_exist(plist,'CONFIGS')) then $ + outdat[indx].configs = plist[ifile].configs if (tag_exist(plist,'SURVEY')) then $ outdat[indx].survey = plist[ifile].survey + if (not keyword_set(legacy)) and (not keyword_set(plates)) then $ + if (tag_exist(plugmap,'survey') AND tag_exist(outdat,'survey')) then $ + outdat[indx].survey = plugmap.survey if (tag_exist(plist,'MJDLIST')) then $ outdat[indx].mjd_list = plist[ifile].mjdlist if (tag_exist(plist,'TAILIST')) then $ @@ -476,9 +496,9 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ ; Get PRIMTARGET+SECTARGET with those values from ; the plug-map structure in spfield file. ; HJIM decoment the next three lines for the final version - if (tag_exist(plugmap,'primtarget')) then $ + if (tag_exist(plugmap,'primtarget') AND tag_exist(outdat,'primtarget')) then $ outdat[indx].primtarget = plugmap.primtarget - if (tag_exist(plugmap,'sectarget')) then $ + if (tag_exist(plugmap,'sectarget') AND tag_exist(outdat,'sectarget')) then $ outdat[indx].sectarget = plugmap.sectarget if (tag_exist(plugmap,'lambda_eff')) then $ outdat[indx].lambda_eff = plugmap.lambda_eff @@ -528,8 +548,14 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ outdat[indx].firstcarton = plugmap.firstcarton if (tag_exist(plugmap,'CATALOGID')) then $ outdat[indx].catalogid = plugmap.catalogid - if (tag_exist(plugmap,'MAG')) then $ - outdat[indx].mag = plugmap.mag + if (tag_exist(plugmap,'FIBER2MAG')) then begin + outdat[indx].FIBER2MAG = plugmap.FIBER2mag + endif else if (tag_exist(plugmap,'MAG')) then $ + outdat[indx].mag = plugmap.mag + if (tag_exist(plugmap,'PSFMAG')) then $ + outdat[indx].PSFmag = plugmap.PSFmag +; if (tag_exist(plugmap,'MAG')) then $ +; outdat[indx].mag = plugmap.mag if (tag_exist(plugmap,'NEXP')) then $ outdat[indx].nexp = plugmap.nexp if (tag_exist(zans,'PLATE')) then begin @@ -701,27 +727,27 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ multgroup=multgroup, firstgroup=firstgroup, nextgroup=nextgroup) ; Set the unique object IDs - outdat.boss_specobj_id = ingroup + 1L + if tag_exist(outdat, 'boss_specobj_id') then outdat.boss_specobj_id = ingroup + 1L for j=0L, n_elements(firstgroup)-1L do begin if (firstgroup[j] NE -1) then begin if (multgroup[j] EQ 1) then begin - outdat[firstgroup[j]].specprimary = 1 - outdat[firstgroup[j]].nspecobs = 1 + if tag_exist(outdat, 'specprimary') then outdat[firstgroup[j]].specprimary = 1 + if tag_exist(outdat, 'nspecobs') then outdat[firstgroup[j]].nspecobs = 1 endif else begin indx = lonarr(multgroup[j]) indx[0] = firstgroup[j] for k=0L, multgroup[j]-2L do indx[k+1] = nextgroup[indx[k]] foo = max(score[indx], ibest) - outdat[indx[ibest]].specprimary = 1 - outdat[indx].nspecobs = multgroup[j] + if tag_exist(outdat, 'specprimary') then outdat[indx[ibest]].specprimary = 1 + if tag_exist(outdat, 'nspecobs') then outdat[indx].nspecobs = multgroup[j] endelse endif endfor ; ASB: Copy specprimary into specboss ; (Thinking is that specprimary can be superseded downstream.) - outdat.specboss = outdat.specprimary + if tag_exist(outdat, 'specboss') then outdat.specboss = outdat.specprimary splog, 'Time to assign primaries = ', systime(1)-t2, ' sec' @@ -815,10 +841,10 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ 'plug_ra' , 0.0d, $ 'plug_dec' , 0.0d, $ 'specprimary', 0L, $ - 'chunk' , '', $ +; 'chunk' , '', $ ; 'platesn2' , 0.0, $ 'fieldsn2' , 0.0, $ - 'deredsn2' , 0.0, $ +; 'deredsn2' , 0.0, $ 'objtype' , '', $ ; 'boss_target1', 0LL, $ ; 'ancillary_target1', 0LL, $ @@ -835,6 +861,11 @@ pro fieldmerge1, field=field, mjd=mjd, except_tags1=except_tags1, $ ;; 'class_person', 0L, $ ;; 'z_conf_person', 0L ) + if keyword_set(legacy) then $ + adat1 = struct_addtags(adat1, {chunk:'',DEREDSN2:'',$ + specprimary:0B,specboss:0B,boss_specobj_id:0L,$ + nspecobs:0}) + tag_alias = [['SPECPRIMARY','PRIMARY'], $ ['FIBERID','FIBER']];, $ ; ['BOSS_TARGET1','BOSS1'], $ diff --git a/pro/spec1d/reformat_spec.pro b/pro/spec1d/reformat_spec.pro index 3350463b5..7c8959325 100644 --- a/pro/spec1d/reformat_spec.pro +++ b/pro/spec1d/reformat_spec.pro @@ -345,7 +345,7 @@ CPU, TPOOL_NTHREADS = 1 endif splog,'Writing the final output files' - print, zallfile + ;print, zallfile plugmap = mrdfits(platefile,5,/silent) zall = mrdfits(zallfile,1,/silent) zbest = mrdfits(zbestfile,1,/silent) @@ -451,7 +451,8 @@ CPU, TPOOL_NTHREADS = 1 ; single_file=single_basefile+plug_target.targetid+'.fits' single_file=single_basefile+strtrim(plug_target.catalogid,2)+'.fits' endelse - ;print,single_file + print,single_file + print,plug_target.catalogid junk = mrdfits(single_file,0,hdr0,/silent) coadd = mrdfits(single_file,1,/silent) values_t=replicate(create_struct('model',0.0),n_elements(coadd.flux)) @@ -464,7 +465,7 @@ CPU, TPOOL_NTHREADS = 1 if keyword_set(legacy) then begin struct_delete_field,zbest_target,'field' endif - fin_plug=struct_addtags(plug_target,struct_selecttags(zbest_target, except_tags='field')) + fin_plug=struct_addtags(plug_target,struct_selecttags(zbest_target, except_tags=['field','fiberid_list'])) if keyword_set(XCSAO) then fin_plug=struct_addtags(fin_plug,XCSAO_targ) nexp=plug_target.nexp if keyword_set(plates) or keyword_set(legacy) then begin diff --git a/pro/spec1d/sdss_spec_image.pro b/pro/spec1d/sdss_spec_image.pro index a94e6c5a5..c502a076b 100644 --- a/pro/spec1d/sdss_spec_image.pro +++ b/pro/spec1d/sdss_spec_image.pro @@ -53,8 +53,9 @@ pro sdss_spec_image, outbase, plate, fiber, mjd=mjd, run2d=run2d, $ common com_sdss_spec_image, plans if(n_tags(plans) eq 0) then $ - plans= yanny_readone(getenv('PLATELIST_DIR')+'/platePlans.par') - + ;if keyword_set(legacy) or keyword_set(plates) then begin + plans= yanny_readone(getenv('PLATELIST_DIR')+'/platePlans.par') + ; endif else sscale=1.5 if(NOT keyword_set(xsize)) then xsize= 10.5*sscale if(NOT keyword_set(ysize)) then ysize= 7.5*sscale @@ -80,7 +81,6 @@ readspec, plate, fiber, mjd=mjd, zans=zans, flux=flux, wave=wave, $ silent=silent, legacy=legacy, plates=plates ipl= where(plate eq plans.plateid, npl) - igd= where(invvar gt 0, ngd) if(ngd gt 0) then begin ist= min(igd) @@ -149,6 +149,7 @@ if(npl gt 0) then begin title0= 'Survey: !8'+strtrim(plans[ipl].survey,2)+ $ '!6 Program: !8'+strtrim(plans[ipl].programname,2) targets='' + targ_title='Target' if(plans[ipl].survey eq 'sdss') then $ targets= strtrim(strjoin(sdss_flagname('TARGET', plug.primtarget),' '),2) if(plans[ipl].survey eq 'segue1') then $ @@ -156,18 +157,35 @@ if(npl gt 0) then begin if(plans[ipl].survey eq 'boss') then $ targets= strtrim(strjoin(sdss_flagname('BOSS_TARGET1', plug.boss_target1),' '),2)+ $ ' '+strtrim(strjoin(sdss_flagname('ANCILLARY_TARGET1', plug.ancillary_target1),' '),2) - if(plans[ipl].survey eq 'bhm-mwm') then $ + if(plans[ipl].survey eq 'bhm-mwm') then begin + targ_title='Firstcarton' targets= plug.firstcarton - if(plans[ipl].survey eq 'bhm') then $ + endif + if(plans[ipl].survey eq 'bhm') then begin + targ_title='Firstcarton' targets= plug.firstcarton - if(plans[ipl].survey eq 'mwm') then $ + endif + if(plans[ipl].survey eq 'mwm') then begin + targ_title='Firstcarton' targets= plug.firstcarton - if(plans[ipl].survey eq 'mwm-bhm') then $ + endif + if(plans[ipl].survey eq 'mwm-bhm') then begin + targ_title='Firstcarton' targets= plug.firstcarton - if (strtrim(targets,2) eq 'NA') then $ + endif + if (strtrim(targets,2) eq 'NA') then begin + targ_title='Firstcarton' targets=strtrim(plug.objtype,2) - title0= title0+' !6Target: !8'+targets+'!6' -endif + endif + title0= title0+' !6'+targ_title+': !8'+targets+'!6' +endif else begin + prog=strtrim(plug.program,2) + if strlen(prog) eq 0 then prog='NA' + fcart=strtrim(plug.firstcarton,2) + if strlen(fcart) eq 0 then fcart='NA' + title0= 'Program: !8'+prog+'!6,'+$ + ' Firstcarton: !8'+fcart+'!6' +endelse if keyword_set(plates) or keyword_set(legacy) then begin lab_temp='Plate=' @@ -180,10 +198,13 @@ title1= 'RA='+strtrim(string(f='(f40.5)', zans.plug_ra),2)+', '+ $ lab_temp+strtrim(string(zans.field),2)+', '+ $ 'Fiber='+strtrim(string(zans.fiberid),2)+', '+ $ 'MJD='+strtrim(string(zans.mjd),2) -if (not keyword_set(legacy)) then begin +if (keyword_set(plates)) then begin title1=title1+', '+'CatID='+strtrim(string(plug.catalogid),2) +endif else if (not keyword_set(legacy)) then begin + title0=title0+', '+'CatID='+strtrim(string(plug.catalogid),2) endif + if(zans.z lt 1000./299792.) then $ zstr= '!8cz='+strtrim(string(long(zans.z*299792.)),2)+'+/-'+ $ strtrim(string(long(zans.z_err*299792.)),2)+'!6 km/s' $ @@ -193,7 +214,7 @@ else $ title2= zstr+', Class='+strtrim(zans.class)+' '+strtrim(zans.subclass) mag_vec=plug.mag m_i=mag_vec[3] -title2=title2+', mag!8_i='+strtrim(string(f='(f40.2)',m_i),2)+'!6' +title2=title2+', mag!8_{i,fib2}='+strtrim(string(f='(f40.2)',m_i),2)+'!6' warnings= strtrim(strjoin(sdss_flagname('ZWARNING', zans.zwarning),' '),2) ;;; print, zans.zwarning if(keyword_set(warnings) gt 0) then $ diff --git a/pro/spec2d/prerun_readplugmap.pro b/pro/spec2d/prerun_readplugmap.pro index 45bb9dc34..c2489f770 100644 --- a/pro/spec2d/prerun_readplugmap.pro +++ b/pro/spec2d/prerun_readplugmap.pro @@ -165,8 +165,10 @@ function psf2Fiber_mag, fibermap fibermap = struct_addtags(fibermap, replicate(create_struct('CatDB_mag', fltarr(5)), n_elements(fibermap))) fibermap = struct_addtags(fibermap, replicate(create_struct('Fiber2mag', fltarr(5)), n_elements(fibermap))) + fibermap = struct_addtags(fibermap, replicate(create_struct('PSFmag', fltarr(5)), n_elements(fibermap))) fibermap.CatDB_mag = fibermap.mag fibermap.Fiber2mag = fibermap.mag + fibermap.PSFmag = fibermap.mag mags=fibermap[where(strmatch(fibermap.OPTICAL_PROV, "*psf*"))].mag pratio = [2.085, 2.085, 2.116, 2.134, 2.135] for ifilt=0, 4 do mags[ifilt,*]=mags[ifilt,*]+2.5*alog10(pratio[ifilt]) @@ -174,12 +176,48 @@ function psf2Fiber_mag, fibermap fibermap[where(strmatch(fibermap.OPTICAL_PROV, "*psf*"))].mag=mags fibermap[where(strmatch(fibermap.OPTICAL_PROV, "*psf*"))].Fiber2mag=mags + mags=fibermap[where(not strmatch(fibermap.OPTICAL_PROV, "*psf*"))].mag + for ifilt=0, 4 do mags[ifilt,*]=mags[ifilt,*]-2.5*alog10(pratio[ifilt]) + mags[where(mags lt -99)]=-999 + fibermap[where(not strmatch(fibermap.OPTICAL_PROV, "*psf*"))].PSFmag=mags + fibermap[where(strmatch(fibermap.OPTICAL_PROV, "*undefined*"))].Fiber2mag=make_array(5,/float, value=-999) fibermap[where(strmatch(fibermap.OPTICAL_PROV, "*other*"))].Fiber2mag=make_array(5,/float, value=-999) fibermap[where(strmatch(fibermap.OPTICAL_PROV, ""))].Fiber2mag=make_array(5,/float, value=-999) + + fibermap[where(strmatch(fibermap.OPTICAL_PROV, "*undefined*"))].PSFmag=make_array(5,/float, value=-999) + fibermap[where(strmatch(fibermap.OPTICAL_PROV, "*other*"))].PSFmag=make_array(5,/float, value=-999) + fibermap[where(strmatch(fibermap.OPTICAL_PROV, ""))].PSFmag=make_array(5,/float, value=-999) + return, fibermap end +;------------------------------------------------------------------------------i + +function get_survey, plugmap + + plugmap = struct_addtags(plugmap, $ + replicate(create_struct('SURVEY', ''), n_elements(plugmap))) + + MWM_fibers = where(strmatch(plugmap.program, '*MWM*', /FOLD_CASE) EQ 1, ctMWM) + if ctMWM gt 0 then plugmap[MWM_fibers].survey = 'MWM' + + BHM_fibers = where(strmatch(plugmap.program, '*BHM*', /FOLD_CASE) EQ 1, ctBHM) + if ctBHM gt 0 then plugmap[BHM_fibers].survey = 'BHM' + + COM_fibers = where(strmatch(plugmap.program, '*commissioning*', /FOLD_CASE) EQ 1, ctCOM) + if ctCOM gt 0 then plugmap[COM_fibers].survey = 'COMMISSIONING' + + OPS_fibers = where(strmatch(plugmap.program, '*ops*', /FOLD_CASE) EQ 1, ctCOM) + if ctCOM gt 0 then plugmap[OPS_fibers].survey = 'COMMISSIONING' + + OPEN_fibers = where(strmatch(plugmap.program, '*open_fiber*', /FOLD_CASE) EQ 1, ctOPEN) + if ctOPEN gt 0 then plugmap[OPEN_fibers].survey = 'open_fiber' + + return, plugmap +end + + ;------------------------------------------------------------------------------ function calibrobj, plugfile, fibermap, fieldid, rafield, decfield, programname=programname,$ @@ -485,7 +523,8 @@ function NoAssignRobomap, robomap sign[where(robomap.DEC lt 0)] = '-' radec, robomap.RA, robomap.DEC, ihr, imin, xsec, ideg, imn, xsc - + ideg = abs(ideg) + imn = abs(imn) xsc = abs(xsc) xsc_str=string(xsc,format='(f04.1)') ; xsc_str[where(xsc lt 10)]='0'+string(xsc_str[where(xsc lt 10)],format='(f3.1)') @@ -591,7 +630,7 @@ function readFPSobsSummary, plugfile, robomap, stnames, mjd, hdr=hdr, $ if (keyword_set(apotags)) then begin addtags = { configuration_id : long((yanny_par(hdr, 'configuration_id'))[0]), $ - targeting_vers : long((yanny_par(hdr, 'robostrategy_run'))[0]), $ + targeting_vers : (yanny_par(hdr, 'robostrategy_run'))[0], $ observation_id : long((yanny_par(hdr, 'observation_id'))[0]), $ fieldid : long((yanny_par(hdr, 'field_id'))[0]), $ MJD : long((yanny_par(hdr, 'MJD'))[0]), $ @@ -627,6 +666,9 @@ function readFPSobsSummary, plugfile, robomap, stnames, mjd, hdr=hdr, $ robomap[where(strtrim(robomap.objtype,2) EQ 'sky_boss')].objtype = 'SKY' robomap[where(strtrim(robomap.program,2) EQ 'ops_std')].objtype = 'SPECTROPHOTO_STD' robomap.fibermask=fibermask + + robomap = get_survey(robomap) + return, robomap end diff --git a/pro/spec2d/readplugmap.pro b/pro/spec2d/readplugmap.pro index 892d20e51..29c077df7 100644 --- a/pro/spec2d/readplugmap.pro +++ b/pro/spec2d/readplugmap.pro @@ -143,16 +143,16 @@ function readplugmap, plugfile, spectrographid, plugdir=plugdir, savdir=savdir, fibermask = [-100] foreach pf, plugfile do begin fits_fibermap = FILE_TEST(mapfits_name) - + create=0 if (not fits_fibermap) then begin splog, 'No fits fiber map exists: '+mapfits_name create=1 endif else begin fits_info, mapfits_name, EXTNAME=fibermaps_names, /SILENT - map_ext = where(fibermaps_names EQ pf) - if map_ext ne -1 then begin + map_ext = where(fibermaps_names EQ file_basename(pf), ct) + if ct NE 0 then begin splog, 'Reading fits fiber map extension for '+pf+' from '+mapfits_name - fibermap = mrdfits(mapfits_name, pf, hdr1,/silent) + fibermap = mrdfits(mapfits_name, file_basename(pf), hdr1,/silent) plugmap = [plugmap, fibermap] hdr = [hdr, fits_to_yanny_hdr(hdr1),'cut'] fibermask = [fibermask, fibermap.fibermask, -100] @@ -215,7 +215,7 @@ function readplugmap, plugfile, spectrographid, plugdir=plugdir, savdir=savdir, endif endif endif else begin - euler, ra_field, dec_field, ll_field, bb_field, 1 + euler, ra_field[0], dec_field[0], ll_field, bb_field, 1 if abs(bb_field) lt 15 then gaiaext = 1 endelse endif diff --git a/pro/spec2d/spplan1d.pro b/pro/spec2d/spplan1d.pro index 79f7701d9..7fbe021b5 100644 --- a/pro/spec2d/spplan1d.pro +++ b/pro/spec2d/spplan1d.pro @@ -383,6 +383,7 @@ pro spplan1d, topdir=topdir1, run2d=run2d1, $ indx = where((allexp.flavor EQ 'science' OR allexp.flavor EQ 'smear')) if (indx[0] NE -1) then begin spexp = allexp[indx] + planlist = planlist[indx] endif else begin spexp = 0 endelse @@ -402,9 +403,11 @@ pro spplan1d, topdir=topdir1, run2d=run2d1, $ RM_fields=[] fld=spexp[0].fieldid junk = where(RM_fields eq fld ,ct) - epc=1000;this number force to coadd during all the pluggin mapname + ;epc=10000;this number force to coadd during all the pluggin mapname + epc=1 ; only coadd single night if ct gt 0 then epc=3 spexp_org=spexp + planlist_org=planlist stop_loop=0 while stop_loop eq 0 do begin indx_ep = where(spexp.mjd lt min(spexp.mjd)+epc) @@ -416,7 +419,8 @@ RM_fields=[] ;spexp=spexp[qmjd] ;---------- ; Determine the 2D plan files that are relevant - planlist1 = planlist[indx] + ; planlist1 = planlist[indx] + planlist1 = planlist[indx_ep] ;planlist1 = planlist1[qmjd] ;print, planlist1u ;---------- @@ -426,11 +430,14 @@ RM_fields=[] runspexp=[] planlist1f=[] foreach runmjd, mjd do begin - nind=where(spexp.mjd EQ mjd) - runspexp=[runspexp,spexp[nind]] - planlist1f=[planlist1f,planlist1[nind]] + nind=where(spexp.mjd EQ mjd,ct) + if ct ne 0 then begin + runspexp=[runspexp,spexp[nind]] + planlist1f=[planlist1f,planlist1[nind]] + endif endforeach - planlist1=planlist1f[0] + if n_elements(planlist1f) eq 0 then goto, NoMatch + planlist1=planlist1f[0] endif if (keyword_set(mjstart) AND keyword_set(mjend) AND qmjd) then begin nind=where((spexp.mjd LE mjend) and (spexp.mjd GE mjstart)) @@ -464,7 +471,7 @@ RM_fields=[] mjdstr = string(thismjd, format='(i05.5)') outdir = concat_dir(topdir, fielddir) planfile = 'spPlancomb-' + fieldstr + '-' + mjdstr + '.par' - print, planfile + ;print, planfile ;---------- ; Create keyword pairs for plan file hdr = '' @@ -489,6 +496,7 @@ RM_fields=[] ;---------- ; Write output file spawn, 'mkdir -p ' + outdir + ; struct_print, spexp fullplanfile = djs_filepath(planfile, root_dir=outdir) qexist = keyword_set(findfile(fullplanfile)) if (qexist) then begin @@ -501,13 +509,17 @@ RM_fields=[] splog, 'Writing plan file ', fullplanfile yanny_write, fullplanfile, ptr_new(spexp), hdr=hdr, stnames='SPEXP' endif + NoMatch: if max(spexp_org.mjd) eq max(spexp.mjd) then begin stop_loop=1 endif else begin stop_loop=0 endelse indx_ep = where(spexp_org.mjd gt max(spexp.mjd)) - if (indx_ep[0] NE -1) then spexp = spexp_org[indx_ep] + if (indx_ep[0] NE -1) then begin + spexp = spexp_org[indx_ep] + planlist=planlist_org[indx_ep] + endif endwhile endif diff --git a/pro/spec2d/uubatchpbs.pro b/pro/spec2d/uubatchpbs.pro index ff7c2e306..53fb1c172 100644 --- a/pro/spec2d/uubatchpbs.pro +++ b/pro/spec2d/uubatchpbs.pro @@ -414,7 +414,6 @@ pro uubatchpbs, platenums1, topdir=topdir1, run2d=run2d1, run1d=run1d1, $ endif endfor endfor - nplate = n_elements(planlist) if (nplate EQ 0) then begin splog, 'No plan files found' @@ -547,8 +546,15 @@ pro uubatchpbs, platenums1, topdir=topdir1, run2d=run2d1, run1d=run1d1, $ platefile = 'spField-'+platemjd+'.fits' ; Track the beginning and ending MJD going into this plate - mjd_beg[iplate] = min(strmid(planfile2d,14,5)) - mjd_end[iplate] = max(strmid(planfile2d,14,5)) + + plan2dfile = file_basename(planfile2d,'.par') + if n_elements(planfile2d) gt 1 then begin + mjd_beg[iplate]=min(((strsplit(plan2dfile,'-',/extract)).ToArray())[*,2]) + mjd_end[iplate]=max(((strsplit(plan2dfile,'-',/extract)).ToArray())[*,2]) + endif else begin + mjd_beg[iplate] = min(((strsplit(plan2dfile,'-',/extract)))[2]) + mjd_end[iplate] = max(((strsplit(plan2dfile,'-',/extract)))[2]) + endelse ; Split the combine plan file name into a directory and file name planfilecomb = fileandpath(planlist[iplate], path=pathcomb) @@ -678,11 +684,17 @@ pro uubatchpbs, platenums1, topdir=topdir1, run2d=run2d1, run1d=run1d1, $ endif else begin spreduce2d_keys = spreduce2d_keys +' /plates,' rm_combine_keys = rm_combine_keys +' /plates,' - if keyword_set(MWM_fluxer) then $ + if keyword_set(MWM_fluxer) then begin spreduce2d_keys = spreduce2d_keys +' /MWM_fluxer,' rm_combine_keys = rm_combine_keys +' /MWM_fluxer,' + endif endelse - endif + endif else begin + if keyword_set(MWM_fluxer) then begin + spreduce2d_keys = spreduce2d_keys +' /MWM_fluxer,' + rm_combine_keys = rm_combine_keys +' /MWM_fluxer,' + endif + endelse for i=0, n_elements(planfile2d)-1 do begin pmjd=STRJOIN((STRSPLIT((STRSPLIT(planfile2d[i],'.',/EXTRACT))[0],'-',/extract))[1:*],'-')