Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Avet Harutyunyan
gofio
Commits
be3f1d35
Commit
be3f1d35
authored
Dec 09, 2017
by
Monica Rainer
Browse files
Fix bug in shiftY and change settings s1d
parent
c6755255
Changes
6
Hide whitespace changes
Inline
Side-by-side
gofio/drslib/config.py
View file @
be3f1d35
...
...
@@ -263,7 +263,7 @@ CONFIG['XCCD'] = 2048
CONFIG
[
'YCCD'
]
=
2048
CONFIG
[
'N_ORD'
]
=
50
# number of echelle orders
CONFIG
[
'W_ORD'
]
=
41
# width of straighten order in pixel
CONFIG
[
'SHIFT_Y'
]
=
20
# bottom position of flat signal on the lowest order and the left side of the detector
CONFIG
[
'SHIFT_Y'
]
=
20
#
expected
bottom position of flat signal on the lowest order and the left side of the detector
. DO NOT CHANGE.
#
# Quality checks
...
...
gofio/drslib/flatframes.py
View file @
be3f1d35
...
...
@@ -215,21 +215,32 @@ class GBFlats():
nor
=
flat
.
replace
(
'.fits'
,
'_nor.fits'
)
#extracted = flat.replace('.fits','_ext.fits')
shift
=
db
.
extract_dbfile
(
self
.
dbconn
,
'shiftY'
)
if
not
shift
:
cal_flat
=
db
.
extract_dbfile
(
self
.
dbconn
,
'flat'
)
mflat
=
ccdproc
.
CCDData
.
read
(
cal_flat
,
unit
=
u
.
adu
)
shift
=
varie
.
shiftY
(
mflat
.
data
)
db
.
insert_dbfile
(
self
.
dbconn
,
'shiftY'
,
shift
)
args
=
[
CONFIG
[
'STRAIGHT'
],
flat
,
straight
]
args
.
extend
(
CONFIG
[
'STRAIGHT_OPT'
])
# search for shift defined in the straighten options in config.py
dy
=
True
for
opt
in
CONFIG
[
'STRAIGHT_OPT'
]:
try
:
dy
=
opt
.
rindex
(
'DY='
)
ypos
=
int
(
opt
[
dy
-
2
:])
shift
=
CONFIG
[
'SHIFT_Y'
]
+
ypos
dy
=
False
except
:
pass
shiftY
=
''
.
join
((
'DY='
,
str
(
shift
-
CONFIG
[
'SHIFT_Y'
])))
#print shiftY
if
dy
:
shift
=
db
.
extract_dbfile
(
self
.
dbconn
,
'shiftY'
)
if
not
shift
:
cal_flat
=
db
.
extract_dbfile
(
self
.
dbconn
,
'flat'
)
mflat
=
ccdproc
.
CCDData
.
read
(
cal_flat
,
unit
=
u
.
adu
)
shift
=
varie
.
shiftY
(
mflat
.
data
)
db
.
insert_dbfile
(
self
.
dbconn
,
'shiftY'
,
shift
)
shiftY
=
[
''
.
join
((
'DY='
,
str
(
shift
-
CONFIG
[
'SHIFT_Y'
])))]
#print shiftY
args
.
extend
(
shiftY
)
#args = [CONFIG['STRAIGHT'],flat,straight,CONFIG['STRAIGHT_OPT']]
args
=
[
CONFIG
[
'STRAIGHT'
],
flat
,
straight
]
args
.
extend
(
CONFIG
[
'STRAIGHT_OPT'
])
args
.
extend
(
shiftY
)
#print args
subprocess
.
call
(
args
)
red_straight
=
os
.
path
.
join
(
CONFIG
[
'RED_CALIB'
],
os
.
path
.
basename
(
straight
))
...
...
gofio/drslib/nodding.py
View file @
be3f1d35
...
...
@@ -178,28 +178,36 @@ class GBNodding():
straight
=
fitsfile
.
replace
(
'.fits'
,
'_str.fits'
)
shift
=
db
.
extract_dbfile
(
self
.
dbconn
,
'shiftY'
)
if
not
shift
:
args
=
[
CONFIG
[
'STRAIGHT'
],
fitsfile
,
straight
]
args
.
extend
(
CONFIG
[
'STRAIGHT_OPT'
])
# search for shift defined in the straighten options in config.py
dy
=
True
for
opt
in
CONFIG
[
'STRAIGHT_OPT'
]:
try
:
cal_flat
=
db
.
extract_dbfile
(
self
.
dbconn
,
'flat
'
)
mflat
=
ccdproc
.
CCDData
.
read
(
cal_flat
,
unit
=
u
.
adu
)
shift
=
varie
.
shiftY
(
mflat
.
data
)
d
b
.
insert_dbfile
(
self
.
dbconn
,
'shiftY'
,
shift
)
dy
=
opt
.
rindex
(
'DY=
'
)
ypos
=
int
(
opt
[
dy
-
2
:]
)
shift
=
CONFIG
[
'SHIFT_Y'
]
+
ypos
d
y
=
False
except
:
try
:
pass
if
dy
:
shift
=
db
.
extract_dbfile
(
self
.
dbconn
,
'shiftY'
)
if
not
shift
:
cal_flat
=
db
.
extract_dbfile
(
self
.
dbconn
,
'flat'
)
if
cal_flat
:
mflat
=
ccdproc
.
CCDData
.
read
(
cal_flat
,
unit
=
u
.
adu
)
shift
=
varie
.
shiftY
(
mflat
.
data
)
db
.
insert_dbfile
(
self
.
dbconn
,
'shiftY'
,
shift
)
else
:
db
.
copy_dbfile
(
self
.
dbconn
,
'shiftY'
)
shift
=
db
.
extract_dbfile
(
self
.
dbconn
,
'shiftY'
)
if
not
shift
:
shift
=
CONFIG
[
'SHIFT_Y'
]
except
:
shift
=
CONFIG
[
'SHIFT_Y'
]
shiftY
=
''
.
join
((
'DY='
,
str
(
shift
-
CONFIG
[
'SHIFT_Y'
])))
#print shiftY
args
=
[
CONFIG
[
'STRAIGHT'
],
fitsfile
,
straight
]
args
.
extend
(
CONFIG
[
'STRAIGHT_OPT'
])
args
.
extend
(
shiftY
)
shiftY
=
[
''
.
join
((
'DY='
,
str
(
shift
-
CONFIG
[
'SHIFT_Y'
])))
]
#print shiftY
args
.
extend
(
shiftY
)
subprocess
.
call
(
args
)
...
...
gofio/drslib/stare.py
View file @
be3f1d35
...
...
@@ -326,28 +326,36 @@ class GBStare():
straight
=
fitsfile
.
replace
(
'.fits'
,
'_str.fits'
)
shift
=
db
.
extract_dbfile
(
self
.
dbconn
,
'shiftY'
)
if
not
shift
:
args
=
[
CONFIG
[
'STRAIGHT'
],
fitsfile
,
straight
]
args
.
extend
(
CONFIG
[
'STRAIGHT_OPT'
])
# search for shift defined in the straighten options in config.py
dy
=
True
for
opt
in
CONFIG
[
'STRAIGHT_OPT'
]:
try
:
cal_flat
=
db
.
extract_dbfile
(
self
.
dbconn
,
'flat
'
)
mflat
=
ccdproc
.
CCDData
.
read
(
cal_flat
,
unit
=
u
.
adu
)
shift
=
varie
.
shiftY
(
mflat
.
data
)
d
b
.
insert_dbfile
(
self
.
dbconn
,
'shiftY'
,
shift
)
dy
=
opt
.
rindex
(
'DY=
'
)
ypos
=
int
(
opt
[
dy
-
2
:]
)
shift
=
CONFIG
[
'SHIFT_Y'
]
+
ypos
d
y
=
False
except
:
try
:
pass
if
dy
:
shift
=
db
.
extract_dbfile
(
self
.
dbconn
,
'shiftY'
)
if
not
shift
:
cal_flat
=
db
.
extract_dbfile
(
self
.
dbconn
,
'flat'
)
if
cal_flat
:
mflat
=
ccdproc
.
CCDData
.
read
(
cal_flat
,
unit
=
u
.
adu
)
shift
=
varie
.
shiftY
(
mflat
.
data
)
db
.
insert_dbfile
(
self
.
dbconn
,
'shiftY'
,
shift
)
else
:
db
.
copy_dbfile
(
self
.
dbconn
,
'shiftY'
)
shift
=
db
.
extract_dbfile
(
self
.
dbconn
,
'shiftY'
)
if
not
shift
:
shift
=
CONFIG
[
'SHIFT_Y'
]
except
:
shift
=
CONFIG
[
'SHIFT_Y'
]
shiftY
=
''
.
join
((
'DY='
,
str
(
shift
-
CONFIG
[
'SHIFT_Y'
])))
#print shiftY
args
=
[
CONFIG
[
'STRAIGHT'
],
fitsfile
,
straight
]
args
.
extend
(
CONFIG
[
'STRAIGHT_OPT'
])
args
.
extend
(
shiftY
)
shiftY
=
[
''
.
join
((
'DY='
,
str
(
shift
-
CONFIG
[
'SHIFT_Y'
])))]
#print shiftY
args
.
extend
(
shiftY
)
subprocess
.
call
(
args
)
str_file
=
os
.
path
.
join
(
CONFIG
[
'RED_STR'
],
os
.
path
.
basename
(
straight
))
...
...
gofio/drslib/varie.py
View file @
be3f1d35
...
...
@@ -93,25 +93,25 @@ def stdcombine(x,axis):
#-------------- Define straighten option vertical shift -------------------
def
shiftY
(
fdata
):
# search for shift defined in the straighten options in config.py
try
:
for
opt
in
CONFIG
[
'STRAIGHT_OPT'
]:
try
:
dy
=
opt
.
rindex
(
'DY='
)
ypos
=
int
(
opt
[
dy
-
1
:])
shift
=
CONFIG
[
'SHIFT_Y'
]
+
ypos
return
shift
#for opt in CONFIG['STRAIGHT_OPT']:
# try:
# dy = opt.rindex('DY=')
# ypos = int(opt[dy-2:])
# shift = CONFIG['SHIFT_Y'] + ypos
# return shift
# except:
# pass
# if the shift is not defined, compute it
except
:
column
=
fdata
[
0
:
140
,
0
]
# the bottom 140 pixel of the first column on the left of the detector
background
=
np
.
sort
(
column
)[
20
]
# value of the 20th pixel after arranging them in ascending order
#print column
for
i
in
xrange
(
len
(
column
)):
if
column
[
i
]
>
3
*
background
:
if
np
.
median
(
column
[
i
+
1
:
i
+
6
])
>
3
*
background
:
shift
=
i
return
shift
# if the shift computation fails, use the default definition
return
CONFIG
[
'SHIFT_Y'
]
column
=
fdata
[
0
:
140
,
0
]
# the bottom 140 pixel of the first column on the left of the detector
background
=
np
.
sort
(
column
)[
20
]
# value of the 20th pixel after arranging them in ascending order
#print column
for
i
in
xrange
(
len
(
column
)):
if
column
[
i
]
>
3
*
background
:
if
np
.
median
(
column
[
i
+
1
:
i
+
6
])
>
3
*
background
:
shift
=
i
return
shift
# if the shift computation fails, use the default definition
return
CONFIG
[
'SHIFT_Y'
]
#--------------------- Build the extraction mask -------------------
...
...
@@ -335,6 +335,7 @@ def optExtract(data,gain,ron,slit_pos,ordine):
OptFlux
[
OptFlux
==-
np
.
inf
]
=
0
OptFlux
=
np
.
nan_to_num
(
OptFlux
)
OptFlux
[
OptFlux
<
0
]
=
0
#t5 = time.time()
#print 'First optimal extraction order %s: %s ms' % (str(ordine+32),str((t5-t4)*1000))
...
...
@@ -372,6 +373,8 @@ def optExtract(data,gain,ron,slit_pos,ordine):
OptFlux
[
OptFlux
==-
np
.
inf
]
=
0
OptFlux
=
np
.
nan_to_num
(
OptFlux
)
OptFlux
[
OptFlux
<
0
]
=
0
# update the model and its variance
model
=
OptFlux
*
profile
#model[rworst,cworst] = 0
...
...
@@ -1170,13 +1173,14 @@ def create_s1d(spectrum, header):
wave_old
[
o
]
=
wave_old
[
o
]
*
(
1
+
(
berv
/
c
))
try
:
#shift = int((wave_old[o][0] - end[o+1])/wstep) -1
shift
=
max
(
int
(
round
((
wave_old
[
o
][
0
]
-
end
[
o
+
1
])
/
wstep
,
0
)),
1
)
#start[o] = max(end[o+1] + (shift*wstep), end[o+1]+wstep)
#shift = int(round((wave_old[o][0] - end[o+1])/wstep,0))
start
[
o
]
=
round
(
end
[
o
+
1
]
+
(
shift
*
wstep
),
3
)
except
:
#shift = 1
start
[
o
]
=
round
(
wave_old
[
o
][
0
],
3
)
#nstep = int(round(((wave_old[o][-1]-start[o])/wstep),0))+1
nstep
=
int
(
round
(((
wave_old
[
o
][
-
1
]
-
start
[
o
])
/
wstep
),
0
))
end
[
o
]
=
round
(
start
[
o
]
+
(
nstep
*
wstep
),
3
)
...
...
@@ -1190,16 +1194,28 @@ def create_s1d(spectrum, header):
select_wave
=
wave_new
[
o
][
wave_old
[
o
][
0
]
<=
wave_new
[
o
]
<=
wave_old
[
o
][
-
1
]]
flux_new
=
spl
(
select_wave
)
start
[
o
]
=
select_wave
[
0
]
#shift = int((start[o]-end[o+1])/wstep)+1
end
[
o
]
=
select_wave
[
-
1
]
flux_new
[
abs
(
flux_new
)
<
1e-04
]
=
0
#print len(flux_new)
if
s1d
.
any
():
if
s1d
.
any
():
gap
=
start
[
o
]
-
(
end
[
o
+
1
]
+
wstep
)
ngap
=
max
(
int
(
round
(
gap
/
wstep
,
0
)),
0
)
s1d
=
np
.
append
(
s1d
,
np
.
zeros
(
ngap
))
#print shift
#if shift < 1:
# new = flux_new[0:-shift]
# old = s1d[shift:]
# if np.mean(new) > np.mean(old):
# s1d[shift:] = new
# shift = -shift+1
#else:
# shift = 0
#s1d = np.append(s1d,flux_new[shift:])
s1d
=
np
.
append
(
s1d
,
flux_new
)
#t2 = time.time()
...
...
gofio/drslib/wlframes.py
View file @
be3f1d35
...
...
@@ -164,28 +164,36 @@ class GBWls():
straight
=
lamp
.
replace
(
'.fits'
,
'_str.fits'
)
extracted
=
lamp
.
replace
(
'.fits'
,
'_ext.fits'
)
shift
=
db
.
extract_dbfile
(
self
.
dbconn
,
'shiftY'
)
if
not
shift
:
args
=
[
CONFIG
[
'STRAIGHT'
],
lamp
,
straight
]
args
.
extend
(
CONFIG
[
'STRAIGHT_OPT'
])
# search for shift defined in the straighten options in config.py
dy
=
True
for
opt
in
CONFIG
[
'STRAIGHT_OPT'
]:
try
:
cal_flat
=
db
.
extract_dbfile
(
self
.
dbconn
,
'flat
'
)
mflat
=
ccdproc
.
CCDData
.
read
(
cal_flat
,
unit
=
u
.
adu
)
shift
=
varie
.
shiftY
(
mflat
.
data
)
d
b
.
insert_dbfile
(
self
.
dbconn
,
'shiftY'
,
shift
)
dy
=
opt
.
rindex
(
'DY=
'
)
ypos
=
int
(
opt
[
dy
-
2
:]
)
shift
=
CONFIG
[
'SHIFT_Y'
]
+
ypos
d
y
=
False
except
:
try
:
pass
if
dy
:
shift
=
db
.
extract_dbfile
(
self
.
dbconn
,
'shiftY'
)
if
not
shift
:
cal_flat
=
db
.
extract_dbfile
(
self
.
dbconn
,
'flat'
)
if
cal_flat
:
mflat
=
ccdproc
.
CCDData
.
read
(
cal_flat
,
unit
=
u
.
adu
)
shift
=
varie
.
shiftY
(
mflat
.
data
)
db
.
insert_dbfile
(
self
.
dbconn
,
'shiftY'
,
shift
)
else
:
db
.
copy_dbfile
(
self
.
dbconn
,
'shiftY'
)
shift
=
db
.
extract_dbfile
(
self
.
dbconn
,
'shiftY'
)
if
not
shift
:
shift
=
CONFIG
[
'SHIFT_Y'
]
except
:
shift
=
CONFIG
[
'SHIFT_Y'
]
shiftY
=
''
.
join
((
'DY='
,
str
(
shift
-
CONFIG
[
'SHIFT_Y'
])))
#print shiftY
args
=
[
CONFIG
[
'STRAIGHT'
],
lamp
,
straight
]
args
.
extend
(
CONFIG
[
'STRAIGHT_OPT'
])
args
.
extend
(
shiftY
)
shiftY
=
[
''
.
join
((
'DY='
,
str
(
shift
-
CONFIG
[
'SHIFT_Y'
])))
]
#print shiftY
args
.
extend
(
shiftY
)
subprocess
.
call
(
args
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment