Commit d10eb6a8 authored by Zhang Xin's avatar Zhang Xin
Browse files

pep8 formatting

parent 4c36363e
Pipeline #7113 failed with stage
in 0 seconds
...@@ -173,9 +173,11 @@ class SpecDisperser(object): ...@@ -173,9 +173,11 @@ class SpecDisperser(object):
lam_index = argsort(lam_beam) lam_index = argsort(lam_beam)
conf_sens = self.grating_conf.sens[beam] conf_sens = self.grating_conf.sens[beam]
lam_intep = np.linspace(self.band_start, self.band_end, int((self.band_end - self.band_start) / 0.1)) lam_intep = np.linspace(self.band_start, self.band_end, int(
(self.band_end - self.band_start) / 0.1))
thri = interpolate.interp1d(conf_sens["WAVELENGTH"], conf_sens["SENSITIVITY"]) thri = interpolate.interp1d(
conf_sens["WAVELENGTH"], conf_sens["SENSITIVITY"])
spci = interpolate.interp1d(self.spec["WAVELENGTH"], self.spec["FLUX"]) spci = interpolate.interp1d(self.spec["WAVELENGTH"], self.spec["FLUX"])
beam_thr = thri(lam_intep) beam_thr = thri(lam_intep)
...@@ -201,7 +203,8 @@ class SpecDisperser(object): ...@@ -201,7 +203,8 @@ class SpecDisperser(object):
sensitivity_beam = ysens sensitivity_beam = ysens
len_spec_x = len(dx) len_spec_x = len(dx)
len_spec_y = int(abs(ceil(ytrace_beam[-1]) - floor(ytrace_beam[0])) + 1) len_spec_y = int(
abs(ceil(ytrace_beam[-1]) - floor(ytrace_beam[0])) + 1)
beam_sh = (self.img_sh[0] + len_spec_y, self.img_sh[1] + len_spec_x) beam_sh = (self.img_sh[0] + len_spec_y, self.img_sh[1] + len_spec_x)
modelf = zeros(product(beam_sh), dtype=float) modelf = zeros(product(beam_sh), dtype=float)
...@@ -246,7 +249,8 @@ class SpecDisperser(object): ...@@ -246,7 +249,8 @@ class SpecDisperser(object):
else: else:
beam_flat = zeros([len(modelf), len(self.flat_cube)]) beam_flat = zeros([len(modelf), len(self.flat_cube)])
sub_flat_cube = zeros([len(self.flat_cube), beam_sh[0], beam_sh[1]]) sub_flat_cube = zeros(
[len(self.flat_cube), beam_sh[0], beam_sh[1]])
sub_flat_cube[0] = sub_flat_cube[0] + 1.0 sub_flat_cube[0] = sub_flat_cube[0] + 1.0
overlap_flag = 1 overlap_flag = 1
...@@ -276,9 +280,9 @@ class SpecDisperser(object): ...@@ -276,9 +280,9 @@ class SpecDisperser(object):
if overlap_flag == 1: if overlap_flag == 1:
sub_flat_cube[ sub_flat_cube[
:, :,
beam_y_s - originOut_y : beam_y_e - originOut_y + 1, beam_y_s - originOut_y: beam_y_e - originOut_y + 1,
beam_x_s - originOut_x : beam_x_e - originOut_x + 1, beam_x_s - originOut_x: beam_x_e - originOut_x + 1,
] = self.flat_cube[:, beam_y_s : beam_y_e + 1, beam_x_s : beam_x_e + 1] ] = self.flat_cube[:, beam_y_s: beam_y_e + 1, beam_x_s: beam_x_e + 1]
for i in arange(0, len(self.flat_cube), 1): for i in arange(0, len(self.flat_cube), 1):
beam_flat[:, i] = sub_flat_cube[i].flatten() beam_flat[:, i] = sub_flat_cube[i].flatten()
...@@ -330,9 +334,11 @@ class SpecDisperser(object): ...@@ -330,9 +334,11 @@ class SpecDisperser(object):
def writerSensitivityFile(self, conffile="", beam="", w=None, sens=None): def writerSensitivityFile(self, conffile="", beam="", w=None, sens=None):
orders = {"A": "1st", "B": "0st", "C": "2st", "D": "-1st", "E": "-2st"} orders = {"A": "1st", "B": "0st", "C": "2st", "D": "-1st", "E": "-2st"}
sens_file_name = conffile[0:-5] + "_sensitivity_" + orders[beam] + ".fits" sens_file_name = conffile[0:-5] + \
"_sensitivity_" + orders[beam] + ".fits"
if not os.path.exists(sens_file_name) == True: if not os.path.exists(sens_file_name) == True:
senstivity_out = Table(array([w, sens]).T, names=("WAVELENGTH", "SENSITIVITY")) senstivity_out = Table(
array([w, sens]).T, names=("WAVELENGTH", "SENSITIVITY"))
senstivity_out.write(sens_file_name, format="fits") senstivity_out.write(sens_file_name, format="fits")
...@@ -431,9 +437,11 @@ class aXeConf: ...@@ -431,9 +437,11 @@ class aXeConf:
self.dxlam[beam] = np.arange( self.dxlam[beam] = np.arange(
self.conf["BEAM{0}".format(beam)].min(), self.conf["BEAM{0}".format(beam)].max(), dtype=int self.conf["BEAM{0}".format(beam)].min(), self.conf["BEAM{0}".format(beam)].max(), dtype=int
) )
self.nx[beam] = int(self.dxlam[beam].max() - self.dxlam[beam].min()) + 1 self.nx[beam] = int(self.dxlam[beam].max() -
self.dxlam[beam].min()) + 1
self.sens[beam] = Table.read( self.sens[beam] = Table.read(
"{0}/{1}".format(os.path.dirname(self.conf_file), self.conf["SENSITIVITY_{0}".format(beam)]) "{0}/{1}".format(os.path.dirname(self.conf_file),
self.conf["SENSITIVITY_{0}".format(beam)])
) )
# self.sens[beam].wave = np.cast[np.double](self.sens[beam]['WAVELENGTH']) # self.sens[beam].wave = np.cast[np.double](self.sens[beam]['WAVELENGTH'])
# self.sens[beam].sens = np.cast[np.double](self.sens[beam]['SENSITIVITY']) # self.sens[beam].sens = np.cast[np.double](self.sens[beam]['SENSITIVITY'])
...@@ -548,7 +556,8 @@ class aXeConf: ...@@ -548,7 +556,8 @@ class aXeConf:
dpfull = xfull * 0.0 dpfull = xfull * 0.0
lt0 = xfull < 0 lt0 = xfull < 0
if lt0.sum() > 1: if lt0.sum() > 1:
dpfull[lt0] = np.cumsum(np.sqrt(1 + dyfull[lt0][::-1] ** 2))[::-1] dpfull[lt0] = np.cumsum(
np.sqrt(1 + dyfull[lt0][::-1] ** 2))[::-1]
dpfull[lt0] *= -1 dpfull[lt0] *= -1
# #
...@@ -592,8 +601,10 @@ class aXeConf: ...@@ -592,8 +601,10 @@ class aXeConf:
NORDER = self.orders[beam] + 1 NORDER = self.orders[beam] + 1
xi, yi = x - self.xoff, y - self.yoff xi, yi = x - self.xoff, y - self.yoff
xoff_beam = self.field_dependent(xi, yi, self.conf["XOFF_{0}".format(beam)]) xoff_beam = self.field_dependent(
yoff_beam = self.field_dependent(xi, yi, self.conf["YOFF_{0}".format(beam)]) xi, yi, self.conf["XOFF_{0}".format(beam)])
yoff_beam = self.field_dependent(
xi, yi, self.conf["YOFF_{0}".format(beam)])
# y offset of trace (DYDX) # y offset of trace (DYDX)
dydx = np.zeros(NORDER) # 0 #+1.e-80 dydx = np.zeros(NORDER) # 0 #+1.e-80
...@@ -690,19 +701,24 @@ class aXeConf: ...@@ -690,19 +701,24 @@ class aXeConf:
s = 200 # marker size s = 200 # marker size
fig = plt.figure(figsize=[10, 3]) fig = plt.figure(figsize=[10, 3])
plt.scatter(0, 0, marker="s", s=s, color="black", edgecolor="0.8", label="Direct") plt.scatter(0, 0, marker="s", s=s, color="black",
edgecolor="0.8", label="Direct")
for beam in beams: for beam in beams:
if "XOFF_{0}".format(beam) not in self.conf.keys(): if "XOFF_{0}".format(beam) not in self.conf.keys():
continue continue
xoff = self.field_dependent(x0, x1, self.conf["XOFF_{0}".format(beam)]) xoff = self.field_dependent(
x0, x1, self.conf["XOFF_{0}".format(beam)])
dy, lam = self.get_beam_trace(x0, x1, dx=dx, beam=beam) dy, lam = self.get_beam_trace(x0, x1, dx=dx, beam=beam)
xlim = self.conf["BEAM{0}".format(beam)] xlim = self.conf["BEAM{0}".format(beam)]
ok = (dx >= xlim[0]) & (dx <= xlim[1]) ok = (dx >= xlim[0]) & (dx <= xlim[1])
plt.scatter(dx[ok] + xoff, dy[ok], c=lam[ok] / 1.0e4, marker="s", s=s, alpha=0.5, edgecolor="None") plt.scatter(dx[ok] + xoff, dy[ok], c=lam[ok] / 1.0e4,
plt.text(np.median(dx[ok]), np.median(dy[ok]) + 1, beam, ha="center", va="center", fontsize=14) marker="s", s=s, alpha=0.5, edgecolor="None")
print("Beam {0}, lambda=({1:.1f} - {2:.1f})".format(beam, lam[ok].min(), lam[ok].max())) plt.text(np.median(dx[ok]), np.median(
dy[ok]) + 1, beam, ha="center", va="center", fontsize=14)
print("Beam {0}, lambda=({1:.1f} - {2:.1f})".format(beam,
lam[ok].min(), lam[ok].max()))
plt.grid() plt.grid()
plt.xlabel(r"$\Delta x$") plt.xlabel(r"$\Delta x$")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment