imcopy fibre_flat_high.fits[0] fibre_flat_img_high.imh
imcopy fibre_calib_high.fits[0] fibre_calib_img_high.imh

imred
crutil
cosmicrays obj_none_30_15_high.fits[0] obj_none_cr_high.fits thresho=500 fluxrat=4 npasses=5 window=7
cosmicrays obj_QSOz14_H19_30_15_high.fits[0] obj_QSOz14_H19_cr_high.fits thresho=500 fluxrat=4 npasses=5 window=7
cosmicrays obj_Em_15_16_30_15_high.fits[0] obj_Em_15_16_cr_high.fits thresho=500 fluxrat=4 npasses=5 window=7
cosmicrays obj_Em_16_16_30_15_high.fits[0] obj_Em_16_16_cr_high.fits thresho=500 fluxrat=4 npasses=5 window=7
cosmicrays obj_flat_AB20_30_15_high.fits[0] obj_flat_AB20_cr_high.fits thresho=500 fluxrat=4 npasses=5 window=7
cosmicrays obj_flat_AB21_30_15_high.fits[0] obj_flat_AB21_cr_high.fits thresho=500 fluxrat=4 npasses=5 window=7

imarith obj_QSOz14_H19_cr_high.fits - obj_none_cr_high.fits obj_QSOz14_H19_ss_high.imh
imarith obj_Em_15_16_cr_high.fits - obj_none_cr_high.fits obj_Em_15_16_ss_high.imh
imarith obj_Em_16_16_cr_high.fits - obj_none_cr_high.fits obj_Em_16_16_ss_high.imh
imarith obj_flat_AB20_cr_high.fits - obj_none_cr_high.fits obj_flat_AB20_ss_high.imh
imarith obj_flat_AB21_cr_high.fits - obj_none_cr_high.fits obj_flat_AB21_ss_high.imh

imdel *_cr_high.fits

hydra
unlearn hydra

params.nsum = 100
params.coordli = "arcXe.txt"
params.t_funct = "cheby"
params.t_order = 4
params.weights = "none"
params.i_funct = "cheby"
params.sort = "MJD"
params.group = "MJD"
reid.search = 100.0
reid.cradius = 150.0

awk '{print NR,1}' obj_QSOz14_H19.list > list200

dohydra obj_QSOz14_H19_ss_high.imh apref=fibre_flat_img_high.imh flat=fibre_flat_img_high.imh \
arcs1=fibre_calib_img_high.imh readnoi=RON gain=GAIN datamax=INDEF fibers=200 width=6 \
minsep=8 maxsep=12 apidtab=list200 objbeam=0,1 skybeam=0 \
scatter- fitflat+ clean- dispcor+ savearc+ skysubt- skyedit- savesky- \
splot+ redo+ update+ batch- listonl-

dohydra obj_Em_15_16_ss_high.imh apref=fibre_flat_img_high.imh flat=fibre_flat_img_high.imh \
arcs1=fibre_calib_img_high.imh readnoi=RON gain=GAIN datamax=INDEF fibers=200 width=6 \
minsep=8 maxsep=12 apidtab=list200 objbeam=0,1 skybeam=0 \
scatter- fitflat+ clean- dispcor+ savearc+ skysubt- skyedit- savesky- \
splot+ redo+ update+ batch- listonl-

dohydra obj_Em_16_16_ss_high.imh apref=fibre_flat_img_high.imh flat=fibre_flat_img_high.imh \
arcs1=fibre_calib_img_high.imh readnoi=RON gain=GAIN datamax=INDEF fibers=200 width=6 \
minsep=8 maxsep=12 apidtab=list200 objbeam=0,1 skybeam=0 \
scatter- fitflat+ clean- dispcor+ savearc+ skysubt- skyedit- savesky- \
splot+ redo+ update+ batch- listonl-

dohydra obj_flat_AB20_ss_high.imh apref=fibre_flat_img_high.imh flat=fibre_flat_img_high.imh \
arcs1=fibre_calib_img_high.imh readnoi=RON gain=GAIN datamax=INDEF fibers=200 width=6 \
minsep=8 maxsep=12 apidtab=list200 objbeam=0,1 skybeam=0 \
scatter- fitflat+ clean- dispcor+ savearc+ skysubt- skyedit- savesky- \
splot+ redo+ update+ batch- listonl-

dohydra obj_flat_AB21_ss_high.imh apref=fibre_flat_img_high.imh flat=fibre_flat_img_high.imh \
arcs1=fibre_calib_img_high.imh readnoi=RON gain=GAIN datamax=INDEF fibers=200 width=6 \
minsep=8 maxsep=12 apidtab=list200 objbeam=0,1 skybeam=0 \
scatter- fitflat+ clean- dispcor+ savearc+ skysubt- skyedit- savesky- \
splot+ redo+ update+ batch- listonl-

low_rej = 0.5 niterate=3 order=5

imarith obj_QSOz14_H19_ss.ms_high.imh / obj_QSOz14_H19_ss.ms_high.imh[*,50] obj_QSOz14_H19_nr_high.fits
imarith obj_Em_15_16_ss.ms_high.imh / obj_Em_15_16_ss.ms_high.imh[*,50] obj_Em_15_16_nr_high.fits
imarith obj_Em_16_16_ss.ms_high.imh / obj_Em_16_16_ss.ms_high.imh[*,50] obj_Em_16_16_nr_high.fits
imarith obj_flat_AB20_ss.ms_high.imh / obj_flat_AB20_ss.ms_high.imh[*,50] obj_flat_AB20_nr_high.fits
imarith obj_flat_AB21_ss.ms_high.imh / obj_flat_AB21_ss.ms_high.imh[*,50] obj_flat_AB21_nr_high.fits

oned
rspectext ../template/obj_F0V_J15 obj_F0V_J15_high.fits dtype=linear crval1=8000.0 cdelt1=1.0
dispcor obj_F0V_J15_high.fits obj_F0V_J15_cor_high.fits w1 =9984.014 w2=18194.830 dw=3.9955 nw=2056 flux-

imarith obj_QSOz14_H19_nr_high.fits * obj_F0V_J15_cor3_high.fits obj_QSOz14_H19_cal_high.fits
imarith obj_Em_15_16_nr_high.fits * obj_F0V_J15_cor_high.fits obj_Em_15_16_cal_high.fits
imarith obj_Em_16_16_nr_high.fits * obj_F0V_J15_cor_high.fits obj_Em_16_16_cal_high.fits
imarith obj_flat_AB20_nr_high.fits * obj_F0V_J15_cor_high.fits obj_flat_AB20_cal_high.fits
imarith obj_flat_AB21_nr_high.fits * obj_F0V_J15_cor_high.fits obj_flat_AB21_cal_high.fits

/* Simulate 5 hours exposure : 30min * 10 */

blkavg obj_Em_16_16_cal_high.fits[*,2:11] obj_Em_16_16_10h_high.fits 1 10 option=average

/* Fit emission line width and strength */

fitprofs obj_Em_15_16_cal_high.fits region="15800 16200" \
lines="!1,50,100,150,200" logfile=obj_flat_Em_15_16_log \
positio="Em_16" profile="gaussian" gfwhm=20.0 fitback=yes fitposi=all fitgfwh=all

awk '{if($1!="#") print $1,$2,$3,$6}' obj_Em_15_16_log
