Skip to content

Commit 82de75c

Browse files
committed
fix indentations in many files
1 parent 38b9092 commit 82de75c

22 files changed

+476
-477
lines changed

__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from .kepio import *
2+
from .kepmsg import *
3+
from .kepfit import *
14
from .kepbls import kepbls
25
from .kepclip import kepclip
36
from .kepconvert import kepconvert

kepbls.py

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def kepbls(infile,outfile,datacol,errcol,minper,maxper,mindur,maxdur,nsearch,
126126
dPeriod = (maxper - minper) / nsearch
127127
trialPeriods = np.arange(minper,maxper+dPeriod,dPeriod,dtype='float32')
128128
complete = 0
129-
print ' '
129+
print(' ')
130130
for trialPeriod in trialPeriods:
131131
fracComplete = float(complete) / float(len(trialPeriods) - 1) * 100.0
132132
txt = '\r'
@@ -206,7 +206,7 @@ def kepbls(infile,outfile,datacol,errcol,minper,maxper,mindur,maxdur,nsearch,
206206
srMax /= bestSr
207207
transitDuration *= trialPeriods / 24.0
208208
BJD0 = np.array(transitPhase * trialPeriods / nbins,dtype='float64') + intime[0] - 2454833.0
209-
print '\n'
209+
print('\n')
210210

211211
# clean up x-axis unit
212212

@@ -235,21 +235,6 @@ def kepbls(infile,outfile,datacol,errcol,minper,maxper,mindur,maxdur,nsearch,
235235

236236
# plot light curve
237237

238-
if status == 0 and plot:
239-
plotLatex = True
240-
try:
241-
params = {'backend': 'png',
242-
'axes.linewidth': 2.5,
243-
'axes.labelsize': labelsize,
244-
'axes.font': 'sans-serif',
245-
'axes.fontweight' : 'bold',
246-
'text.fontsize': 12,
247-
'legend.fontsize': 12,
248-
'xtick.labelsize': ticksize,
249-
'ytick.labelsize': ticksize}
250-
rcParams.update(params)
251-
except:
252-
plotLatex = False
253238
if status == 0 and plot:
254239
plt.figure(figsize=[xsize,ysize])
255240
plt.clf()
@@ -333,10 +318,10 @@ def kepbls(infile,outfile,datacol,errcol,minper,maxper,mindur,maxdur,nsearch,
333318
# print best trial period results
334319

335320
if status == 0:
336-
print ' Best trial period = %.5f days' % trialPeriods[bestTrial]
337-
print ' Time of mid-transit = BJD %.5f' % (BJD0[bestTrial] + 2454833.0)
338-
print ' Transit duration = %.5f hours' % transitDuration[bestTrial]
339-
print ' Maximum signal residue = %.4g \n' % (srMax[bestTrial] * bestSr)
321+
print(' Best trial period = %.5f days' % trialPeriods[bestTrial])
322+
print(' Time of mid-transit = BJD %.5f' % (BJD0[bestTrial] + 2454833.0))
323+
print(' Transit duration = %.5f hours' % transitDuration[bestTrial])
324+
print(' Maximum signal residue = %.4g \n' % (srMax[bestTrial] * bestSr))
340325

341326
# end time
342327

@@ -356,18 +341,25 @@ def kepbls(infile,outfile,datacol,errcol,minper,maxper,mindur,maxdur,nsearch,
356341
parser.add_argument('outfile', help='Name of FITS file to output', type=str)
357342
parser.add_argument('--datacol', default='DETSAP_FLUX',
358343
help='Name of data column to plot', type=str)
359-
parser.add_argument('--errcol', default='DETSAP_FLUX_ERR', help='Name of data error column to plot', type=str)
344+
parser.add_argument('--errcol', default='DETSAP_FLUX_ERR',
345+
help='Name of data error column to plot', type=str)
360346
parser.add_argument('--minper', default=1.0, help='Minimum search period [days]', type=float)
361347
parser.add_argument('--maxper', default=30.0, help='Maximum search period [days]', type=float)
362348
parser.add_argument('--mindur', default=0.5, help='Minimum transit duration [hours]', type=float)
363349
parser.add_argument('--maxdur', default=12.0, help='Maximum transit duration [hours]', type=float)
364-
parser.add_argument('--nsearch', default=1000, help='Number of test periods between minper and maxper', type=int)
365-
parser.add_argument('--nbins', default=1000, help='Number of bins in the folded time series at any test period', type=int)
350+
parser.add_argument('--nsearch', default=1000,
351+
help='Number of test periods between minper and maxper',
352+
type=int)
353+
parser.add_argument('--nbins', default=1000,
354+
help='Number of bins in the folded time series at any test period',
355+
type=int)
366356
parser.add_argument('--plot', action='store_true', help='Plot result?')
367357
parser.add_argument('--clobber', action='store_true', help='Overwrite output file?')
368358
parser.add_argument('--verbose', action='store_true', help='Write to a log file?')
369-
parser.add_argument('--logfile', '-l', help='Name of ascii log file', default='kepcotrend.log', dest='logfile', type=str)
370-
parser.add_argument('--status', '-e', help='Exit status (0=good)', default=0, dest='status', type=int)
359+
parser.add_argument('--logfile', '-l', help='Name of ascii log file',
360+
default='kepbls.log', dest='logfile', type=str)
361+
parser.add_argument('--status', '-e', help='Exit status (0=good)',
362+
default=0, dest='status', type=int)
371363
args = parser.parse_args()
372364
cmdLine=True
373365
kepbls(args.infile,args.outfile,args.datacol,args.errcol,args.minper,args.maxper,args.mindur,

kepclip.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def kepclip(infile, outfile, ranges, plot, plotcol, clobber, verbose, logfile,
5252

5353
if clobber: status = kepio.clobber(outfile,logfile,verbose)
5454
if kepio.fileexists(outfile):
55-
message = 'ERROR -- KEPCLIP: ' + outfile + ' exists. Use --clobber'
56-
status = kepmsg.err(logfile,message,verbose)
55+
message = 'ERROR -- KEPCLIP: ' + outfile + ' exists. Use --clobber'
56+
status = kepmsg.err(logfile,message,verbose)
5757

5858
# time ranges for region
5959

@@ -128,8 +128,8 @@ def kepclip(infile, outfile, ranges, plot, plotcol, clobber, verbose, logfile,
128128
# clean up x-axis unit
129129

130130
if status == 0:
131-
barytime0 = float(int(tstart / 100) * 100.0)
132-
barytime = work1 - barytime0
131+
barytime0 = float(int(tstart / 100) * 100.0)
132+
barytime = work1 - barytime0
133133
xlab = 'BJD $-$ %d' % barytime0
134134

135135
# clean up y-axis units
@@ -139,17 +139,17 @@ def kepclip(infile, outfile, ranges, plot, plotcol, clobber, verbose, logfile,
139139
nrm = len(str(int(work2.max())))-1
140140
except:
141141
nrm = 0
142-
flux = work2 / 10**nrm
143-
ylab = '10$^%d$ e$^-$ s$^{-1}$' % nrm
142+
flux = work2 / 10**nrm
143+
ylab = '10$^%d$ e$^-$ s$^{-1}$' % nrm
144144

145145
# data limits
146146

147-
xmin = barytime.min()
148-
xmax = barytime.max()
149-
ymin = flux.min()
150-
ymax = flux.max()
151-
xr = xmax - xmin
152-
yr = ymax - ymin
147+
xmin = barytime.min()
148+
xmax = barytime.max()
149+
ymin = flux.min()
150+
ymax = flux.max()
151+
xr = xmax - xmin
152+
yr = ymax - ymin
153153

154154
# clear window, plot box
155155

@@ -170,8 +170,8 @@ def kepclip(infile, outfile, ranges, plot, plotcol, clobber, verbose, logfile,
170170

171171
# plot line data
172172

173-
ltime = [barytime[0]]; ldata = [flux[0]]
174-
for i in range(1,len(flux)):
173+
ltime = [barytime[0]]; ldata = [flux[0]]
174+
for i in range(1,len(flux)):
175175
if (barytime[i-1] > barytime[i] - 0.025):
176176
ltime.append(barytime[i])
177177
ldata.append(flux[i])
@@ -180,9 +180,9 @@ def kepclip(infile, outfile, ranges, plot, plotcol, clobber, verbose, logfile,
180180
ldata = np.array(ldata, dtype=np.float)
181181
plt.plot(ltime,ldata,color=lcolor,linestyle='-',linewidth=lwidth)
182182
ltime = []; ldata = []
183-
ltime = np.array(ltime, dtype=np.float)
184-
ldata = np.array(ldata, dtype=np.float)
185-
plt.plot(ltime,ldata,color=lcolor,linestyle='-',linewidth=lwidth)
183+
ltime = np.array(ltime, dtype=np.float)
184+
ldata = np.array(ldata, dtype=np.float)
185+
plt.plot(ltime,ldata,color=lcolor,linestyle='-',linewidth=lwidth)
186186

187187
# plot fill data
188188

@@ -192,13 +192,13 @@ def kepclip(infile, outfile, ranges, plot, plotcol, clobber, verbose, logfile,
192192
flux = np.append(flux,[0.0])
193193
plt.fill(barytime,flux,fc=fcolor,linewidth=0.0,alpha=falpha)
194194
plt.xlim(xmin-xr*0.01,xmax+xr*0.01)
195-
if ymin-yr*0.01 <= 0.0:
195+
if ymin-yr*0.01 <= 0.0:
196196
plt.ylim(1.0e-10,ymax+yr*0.01)
197-
else:
197+
else:
198198
plt.ylim(ymin-yr*0.01,ymax+yr*0.01)
199-
plt.xlabel(xlab, {'color' : 'k'})
200-
plt.ylabel(ylab, {'color' : 'k'})
201-
plt.grid()
199+
plt.xlabel(xlab, {'color' : 'k'})
200+
plt.ylabel(ylab, {'color' : 'k'})
201+
plt.grid()
202202

203203
# render plot
204204

@@ -214,9 +214,9 @@ def kepclip(infile, outfile, ranges, plot, plotcol, clobber, verbose, logfile,
214214
# end time
215215

216216
if (status == 0):
217-
message = 'KEPCLIP completed at'
217+
message = 'KEPCLIP completed at'
218218
else:
219-
message = '\nKEPCLIP aborted at'
219+
message = '\nKEPCLIP aborted at'
220220
kepmsg.clock(message,logfile,verbose)
221221

222222
# main

kepconvert.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ def kepconvert(infile,outfile,conversion,columns,baddata,clobber,verbose,logfile
7373

7474
# check columns exist in FITS file
7575
if not baddata and status == 0 and conversion == 'fits2asc':
76-
try:
77-
qualcol = table.field('SAP_QUALITY') == 0
78-
except:
79-
message = 'No SAP_QUALITY column in data, are you using an old FITS file?'
80-
status = kepmsg.err(logfile,message,verbose)
76+
try:
77+
qualcol = table.field('SAP_QUALITY') == 0
78+
except:
79+
message = 'No SAP_QUALITY column in data, are you using an old FITS file?'
80+
status = kepmsg.err(logfile,message,verbose)
8181

8282
if status == 0 and conversion == 'fits2asc':
8383
work = []
@@ -304,10 +304,10 @@ def kepconvert(infile,outfile,conversion,columns,baddata,clobber,verbose,logfile
304304

305305
## end time
306306

307-
if (status == 0):
308-
message = 'KEPCONVERT completed at'
307+
if status == 0:
308+
message = 'KEPCONVERT completed at'
309309
else:
310-
message = '\nKEPCONVERT aborted at'
310+
message = '\nKEPCONVERT aborted at'
311311
kepmsg.clock(message,logfile,verbose)
312312

313313
## main

kepcotrend.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Changelog:
77
1.0 released
88
1.0.1 caught not having a new version of numpy with the in1d function and changed the simplex algorithm so that it fits the first two BV then fits
9-
the rest of them, now much more stable (Sep 5 2011)
9+
the rest of them, now much more stable (Sep 5 2011)
1010
2.0 code will now work on short cadence data by interpolating the basis vectors down to short cadence, several interpolation methods are available
1111
3.0 made it possible to run from the command line if there are arguements given to the call to kepcotrend
1212
"""
@@ -482,12 +482,12 @@ def split_on_nans(bad_data,cad):
482482
blocks = []
483483
time_of_nans = cad[bad_data == False]
484484
if bad_data[0] == True:
485-
blocks.append(cad[0])
485+
blocks.append(cad[0])
486486
for i in range(1,len(time_of_nans)):
487-
if time_of_nans[i] - time_of_nans[i-1] > 1:
488-
blocks.append(time_of_nans[i])
489-
if bad_data[-1] == True:
490-
blocks.append(cad[-1])
487+
if time_of_nans[i] - time_of_nans[i-1] > 1:
488+
blocks.append(time_of_nans[i])
489+
if bad_data[-1] == True:
490+
blocks.append(cad[-1])
491491
return blocks
492492

493493
def kepcotrendsc(infile,outfile,bvfile,listbv,fitmethod,fitpower,iterate,
@@ -557,7 +557,7 @@ def kepcotrendsc(infile,outfile,bvfile,listbv,fitmethod,fitpower,iterate,
557557
call += 'infile='+infile+' '
558558
call += 'outfile='+outfile+' '
559559
call += 'bvfile='+bvfile+' '
560-
# call += 'numpcomp= '+str(numpcomp)+' '
560+
# call += 'numpcomp= '+str(numpcomp)+' '
561561
call += 'listbv= '+str(listbv)+' '
562562
call += 'fitmethod=' +str(fitmethod)+ ' '
563563
call += 'fitpower=' + str(fitpower)+ ' '
@@ -607,23 +607,23 @@ def kepcotrendsc(infile,outfile,bvfile,listbv,fitmethod,fitpower,iterate,
607607
message = 'ERROR -- KEPCOTREND: ' + bvfile + ' does not exist.'
608608
status = kepmsg.err(logfile,message,verbose)
609609

610-
#lsq_sq - nonlinear least squares fitting and simplex_abs have been
611-
#removed from the options in PyRAF but they are still in the code!
610+
#lsq_sq - nonlinear least squares fitting and simplex_abs have been
611+
#removed from the options in PyRAF but they are still in the code!
612612
if status == 0:
613-
if fitmethod not in ['llsq','matrix','lst_sq','simplex_abs','simplex']:
614-
message = 'Fit method must either: llsq, matrix, lst_sq or simplex'
615-
status = kepmsg.err(logfile,message,verbose)
613+
if fitmethod not in ['llsq','matrix','lst_sq','simplex_abs','simplex']:
614+
message = 'Fit method must either: llsq, matrix, lst_sq or simplex'
615+
status = kepmsg.err(logfile,message,verbose)
616616

617617
if status == 0:
618-
if not is_numlike(fitpower) and fitpower is not None:
619-
message = 'Fit power must be an real number or None'
620-
status = kepmsg.err(logfile,message,verbose)
618+
if not is_numlike(fitpower) and fitpower is not None:
619+
message = 'Fit power must be an real number or None'
620+
status = kepmsg.err(logfile,message,verbose)
621621

622622

623623

624624
if status == 0:
625-
if fitpower is None:
626-
fitpower = 1.
625+
if fitpower is None:
626+
fitpower = 1.
627627

628628
# input data
629629
if status == 0:
@@ -797,9 +797,9 @@ def kepcotrendsc(infile,outfile,bvfile,listbv,fitmethod,fitpower,iterate,
797797
lc_cad_masked,
798798
short,scinterp)
799799

800-
if iterate and sigma is None:
801-
message = 'If fitting iteratively you must specify a clipping range'
802-
status = kepmsg.err(logfile,message,verbose)
800+
if iterate and sigma is None:
801+
message = 'If fitting iteratively you must specify a clipping range'
802+
status = kepmsg.err(logfile,message,verbose)
803803

804804
if status == 0:
805805
#uses Pvals = yhat * U_transpose
@@ -834,14 +834,14 @@ def kepcotrendsc(infile,outfile,bvfile,listbv,fitmethod,fitpower,iterate,
834834
bvsum_nans = putInNans(bad_data, bvsum)
835835
flux_after_nans = putInNans(bad_data, flux_after)
836836

837-
if plot and status == 0:
837+
if plot and status == 0:
838838
newmedflux = np.median(flux_after + 1)
839839
bvsum_un_norm = newmedflux*(1-bvsum)
840840
do_plot(lc_date, lc_flux, flux_after, bvsum_un_norm, lc_cad,
841841
bad_data, lc_cad_o, version, cmdLine)
842842

843843
if status == 0:
844-
make_outfile(instr,outfile,flux_after_nans,bvsum_nans,version)
844+
make_outfile(instr,outfile,flux_after_nans,bvsum_nans,version)
845845

846846
# close input file
847847
if status == 0:

0 commit comments

Comments
 (0)