Skip to content

Commit

Permalink
python: remove indentation inconsistencies
Browse files Browse the repository at this point in the history
Python 3 refused to import rts2 module because of this

Signed-off-by: Eduardo Alonso <eduardo.alonso@quasarsr.com>
  • Loading branch information
XePeleato committed Mar 1, 2023
1 parent 4370ad0 commit a987692
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions python/rts2/brights.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def get_brightest(s_objects, fn, verbose = 0, useDS9 = False, exclusion = None,
return None, None, None, None
# remove all "stars" below threshold
if pix_treshold is not None:
s_new = []
s_new = []
for o in s_objects:
if o['tnpix'] >= pix_treshold:
s_new.append(o)
s_new.append(o)
if len(s_new) == 0:
return None, None, None, None

Expand Down
2 changes: 1 addition & 1 deletion python/rts2/dms.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def parse(strin):
elif x >= '0' and x <= '9':
if fraction >= 1:
subres = fraction*subres + int(x)
fraction*=10
fraction*=10
else:
subres = subres + int(x)*fraction
fraction/=10
Expand Down
2 changes: 1 addition & 1 deletion python/rts2/fits2model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def model_line(fitsname, of, center=None):

try:
imgid = h['IMGID']
except KeyError, ke:
except KeyError:
imgid = ln

if w.wcs.radesys == '':
Expand Down
6 changes: 3 additions & 3 deletions python/rts2/flats.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,14 @@ def acquireImage(self):
self.setValue('exposure', self.exptime)
self.setValue('SHUTTER', 'LIGHT')
img = self.exposure(self.beforeReadout)
self.log("I", "IMG name is {}".format(img))
#to_dataserver(img)
self.log("I", "IMG name is {}".format(img))
#to_dataserver(img)
# Calculate average of image (can be just the central
# 100x100pix if you want to speed up)
time.sleep(1)
self.sendCommand("info")
avrg = self.getValueFloat('average')
self.log("I", "avrg = {}".format(avrg))
self.log("I", "avrg = {}".format(avrg))
ratio = (avrg - self.biasLevel) / self.optimalFlat
ret = None
expMulti = 1
Expand Down
10 changes: 5 additions & 5 deletions python/rts2/focusing.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ def doFit(self,fit):

if fit == LINEAR:
b = (self.linear_fit_fwhm - self.fwhm_poly[0]) / self.fwhm_poly[1]
elif fit == H3:
b = self.fwhm_poly[2]
elif fit == H3:
b = self.fwhm_poly[2]
self.log('I', 'found minimum FWHM: {0}'.format(abs(self.fwhm_poly[0])))
self.log('I', 'found slope at infinity: {0}'.format(abs(self.fwhm_poly[1])))
elif fit == H2:
b = self.fwhm_poly[1]
elif fit == H2:
b = self.fwhm_poly[1]
self.log('I', 'found minimum FWHM: {0}'.format(abs(self.fwhm_poly[0])))
else:
b = optimize.fmin(fitfunc_r,self.fwhm_MinimumX,args=(self.fwhm_poly), disp=0)[0]
Expand Down Expand Up @@ -259,7 +259,7 @@ def takeImages(self):
self.current_focus = None

for self.num in range(1,self.attempts+1):
self.log('I','starting {0}s exposure on offset {1}'.format(self.exptime,self.off))
self.log('I','starting {0}s exposure on offset {1}'.format(self.exptime,self.off))
img = self.exposure(self.beforeReadout,'%b/focusing/%N/%o/%f')
tries[self.current_focus] = img

Expand Down
2 changes: 1 addition & 1 deletion python/rts2/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def load_xml(self, fn, queues=None):

def from_xml(self, node, queues=None):
for qu in node.getElementsByTagName('queue'):
qname = qu.getAttribute('name')
qname = qu.getAttribute('name')
if queues is not None and not(qname in queues):
continue
q = queue.Queue(self.jsonProxy, qname)
Expand Down
16 changes: 8 additions & 8 deletions python/rts2/sextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_field(self,fieldname):
return self.fields.index(fieldname)

def runSExtractor(self,filename):
pf,pfn = tempfile.mkstemp()
pf,pfn = tempfile.mkstemp()
ofd,output = tempfile.mkstemp()
pfi = os.fdopen(pf,'w')
for f in self.fields:
Expand All @@ -78,15 +78,15 @@ def runSExtractor(self,filename):
self.objects = []
of = os.fdopen(ofd,'r')
while (True):
x=of.readline()
x=of.readline()
if self.verbose:
print(x, end=' ')
if x == '':
break
if x[0] == '#':
continue
self.objects.append(list(map(float,x.split())))

# unlink tmp files
pfi.close()
of.close()
Expand All @@ -95,8 +95,8 @@ def runSExtractor(self,filename):
os.unlink(output)

def sortObjects(self,col):
"""Sort objects by given collumn."""
self.objects.sort(cmp=lambda x,y: cmp(x[col],y[col]))
"""Sort objects by given collumn."""
self.objects.sort(cmp=lambda x,y: cmp(x[col],y[col]))

def reverseObjects(self,col):
"""Reverse sort objects by given collumn."""
Expand All @@ -115,7 +115,7 @@ def filter_galaxies(self,limit=0.2):
except ValueError as ve:
print('result does not contain CLASS_STAR')
traceback.print_exc()

def get_FWHM_stars(self,starsn=None,filterGalaxies=True,segments=None):
"""Returns candidate stars for FWHM calculations. """
if len(self.objects) == 0:
Expand Down Expand Up @@ -165,8 +165,8 @@ def calculate_FWHM(self,starsn=None,filterGalaxies=True,segments=None):
i_fwhm = self.get_field('FWHM_IMAGE')
import numpy
fwhms = [x[i_fwhm] for x in obj]
return numpy.median(fwhms), numpy.std(fwhms), len(fwhms)
# return numpy.average(obj), len(obj)
return numpy.median(fwhms), numpy.std(fwhms), len(fwhms)
# return numpy.average(obj), len(obj)
except ValueError as ve:
traceback.print_exc()
raise Exception('cannot find FWHM_IMAGE value')

0 comments on commit a987692

Please sign in to comment.