66#Imports
77#-----------------------------------------------------------------------------------------
88from __future__ import division #Must be first line of code in the file
9+ from __future__ import print_function
910from astropy .io import fits
1011from argparse import ArgumentParser
1112from argparse import ArgumentDefaultsHelpFormatter
@@ -107,7 +108,7 @@ def announcement(strings):
107108 return result
108109
109110def announce (strings ):
110- print announcement (strings )
111+ print ( announcement (strings ) )
111112
112113def update_progress (progress , message = 'Progress:' , final_message = 'Finished:' ):
113114 # Create progress meter that looks like:
@@ -167,7 +168,7 @@ def update_progress(progress, message='Progress:', final_message='Finished:'):
167168 sys .stdout .flush ()
168169 start_time = None
169170 stop_time = None
170- print ''
171+ print ( '' )
171172
172173#-----------------------------------------------------------------------------------------
173174# Naming Conventions and Converisons
@@ -215,8 +216,8 @@ def xyt_name_factory(filepath, wlen, smr, frac, original):
215216
216217 # Failure: No match and no available output slots
217218 xyt_filename = string .replace (fnmatch_string , '?' , '0' )
218- print 'In xyt_filename(): No existing ouput matches the input parameters and no namespace is available'
219- print 'Overwrite ' + xyt_filename + '?..'
219+ print ( 'In xyt_filename(): No existing ouput matches the input parameters and no namespace is available' )
220+ print ( 'Overwrite ' + xyt_filename + '?..' )
220221 choice = raw_input (' [y]/n/' + '0' * (DIGITS - 1 )+ 'x' )
221222 if len (choice ) == 0 or choice == 'y' :
222223 return os .path .normpath (os .path .join (dirname , xyt_filename ))
@@ -355,7 +356,7 @@ def getXYT(xyt_filename, match_only=False):
355356 xyt = np .memmap (tempfile .TemporaryFile (), dtype = DTYPE , mode = 'w+' , shape = (datay , datax , ntheta ))
356357 xyt .fill (0.0 )
357358 else :
358- print 'Warning: Reconstructing very large array in memory! Set BUFFER to True!'
359+ print ( 'Warning: Reconstructing very large array in memory! Set BUFFER to True!' )
359360 xyt = np .zeros ((datay , datax , ntheta ))
360361 coords = zip (Hj , Hi )
361362 for c in range (len (coords )):
@@ -411,7 +412,7 @@ def bad_pixels(data):
411412 '''
412413 except :
413414 # IMPLEMENTATION3: Give up?
414- print 'Unable to properly mask data in bad_pixels()...'
415+ print ( 'Unable to properly mask data in bad_pixels()...' )
415416 return data .astype (np .bool )
416417
417418def all_within_diameter_are_good (data , diameter ):
@@ -480,10 +481,10 @@ def getData(filepath, make_mask=False, smr=SMR, wlen=WLEN):
480481 except :
481482 # Failure Reading Data
482483 if make_mask :
483- print 'Failure in getData(' + filepath + ')... Returning None, None, None'
484+ print ( 'Failure in getData(' + filepath + ')... Returning None, None, None' )
484485 return None , None , None
485486 else :
486- print 'Failure in getData(' + filepath + ')... Returning None'
487+ print ( 'Failure in getData(' + filepath + ')... Returning None' )
487488 return None
488489
489490 if not make_mask :
@@ -666,15 +667,15 @@ def buffershape(ntheta, filesize=FILECAP):
666667 ntheta = int (ntheta )
667668 filesize = int (filesize )
668669 if not 0 < filesize <= FILECAP :
669- print 'Chosen buffer size exceeds existing limit. Reset to' , str (FILECAP ), 'Bytes'
670+ print ( 'Chosen buffer size exceeds existing limit. Reset to' , str (FILECAP ), 'Bytes' )
670671 filesize = FILECAP
671672
672673 bits_per_element_in_bits = np .dtype (DTYPE ).itemsize
673674 bits_per_file_in_bits = filesize * 8
674675 elements_per_file_in_elements = int (bits_per_file_in_bits // bits_per_element_in_bits )
675676 length_in_elements = int (elements_per_file_in_elements // ntheta )
676677 if length_in_elements <= 0 :
677- print 'In buffershape, ntheta has forced your buffer size to become larger than' , filesize , 'Bytes'
678+ print ( 'In buffershape, ntheta has forced your buffer size to become larger than' , filesize , 'Bytes' )
678679 length_in_elements = 1
679680
680681 return (length_in_elements , ntheta )
@@ -859,7 +860,7 @@ def rmtree_failue(function, path, excinfo):
859860 os .remove (obj )
860861 os .removedirs (temp_dir )
861862 except :
862- print 'Failed to delete temporary files:' , path
863+ print ( 'Failed to delete temporary files:' , path )
863864
864865 shutil .rmtree (temp_dir , ignore_errors = False , onerror = rmtree_failue )
865866 return True
@@ -899,7 +900,7 @@ def rht(filepath, force=False, original=ORIGINAL, wlen=WLEN, frac=FRAC, smr=SMR)
899900
900901 if not is_valid_file (filepath ):
901902 # Check to see if a file should have the rht applied to it.
902- print 'Invalid filepath encountered in rht(' + filepath + ')...'
903+ print ( 'Invalid filepath encountered in rht(' + filepath + ')...' )
903904 return False
904905
905906 try :
@@ -911,17 +912,16 @@ def rht(filepath, force=False, original=ORIGINAL, wlen=WLEN, frac=FRAC, smr=SMR)
911912 # This can overridden by setting the 'force' flag.
912913 return True
913914
914- print '1/4:: Retrieving Data from:' , filepath
915+ print ( '1/4:: Retrieving Data from:' , filepath )
915916 data , smr_mask , wlen_mask = getData (filepath , make_mask = True , smr = smr , wlen = wlen )
916917 datay , datax = data .shape
917918
918- print '2/4::' , 'Size:' , str (datax )+ 'x' + str (datay )+ ',' , 'Wlen:' , str (wlen )+ ',' , 'Smr:' , str (smr )+ ',' , 'Frac:' , str (frac )+ ',' , 'Standard (half-polar) RHT:' , str (original )
919-
919+ print ('2/4::' , 'Size:' , str (datax )+ 'x' + str (datay )+ ',' , 'Wlen:' , str (wlen )+ ',' , 'Smr:' , str (smr )+ ',' , 'Frac:' , str (frac )+ ',' , 'Standard (half-polar) RHT:' , str (original ))
920920 message = '3/4:: Running RHT...'
921921
922922 success = window_step (data = data , wlen = wlen , frac = frac , smr = smr , original = original , smr_mask = smr_mask , wlen_mask = wlen_mask , xyt_filename = xyt_filename , message = message ) #TODO__________________
923923
924- print '4/4:: Successfully Saved Data As' , xyt_filename
924+ print ( '4/4:: Successfully Saved Data As' , xyt_filename )
925925 return success
926926
927927 except :
@@ -950,7 +950,7 @@ def interpret(filepath, force=False, wlen=WLEN, frac=FRAC, smr=SMR, original=ORI
950950 '''
951951
952952
953- print 'viewer() is currently in disrepair! Exiting to avoid unpleasant results!'
953+ print ( 'viewer() is currently in disrepair! Exiting to avoid unpleasant results!' )
954954 return False
955955
956956 # Make sure relevant files are present.
@@ -1004,7 +1004,7 @@ def cleanup():
10041004 plt .close ()
10051005
10061006 #---------------------------------------------------------------------- PLOT 1
1007- print 'Plotting Whole Figure...'
1007+ print ( 'Plotting Whole Figure...' )
10081008 fig , axes = plt .subplots (nrows = 2 , ncols = 2 )
10091009
10101010 #### Log-scale plot of original image data
@@ -1034,7 +1034,7 @@ def cleanup():
10341034 cleanup ()
10351035
10361036 #---------------------------------------------------------------------- PLOT 2
1037- print 'Backprojecting...'
1037+ print ( 'Backprojecting...' )
10381038
10391039 #### Log-scale plot of original image data
10401040 plt .subplot (121 )
@@ -1065,7 +1065,7 @@ def cleanup():
10651065 '''
10661066 #---------------------------------------------------------------------- PLOT 4
10671067 #Polar plot of theta power
1068- print 'Linearity'
1068+ print ( 'Linearity' )
10691069
10701070 if original :
10711071 modified_spectrum = np .true_divide (np .append (spectrum , spectrum ), 2.0 )
@@ -1123,12 +1123,12 @@ def main(source=None, display=False, force=False, drht=False, wlen=WLEN, frac=FR
11231123 pathlist .append (obj_path )
11241124 else :
11251125 # Input is neither a file nor a directory.
1126- print 'Invalid source encountered in main(); must be file or directory.'
1126+ print ( 'Invalid source encountered in main(); must be file or directory.' )
11271127 return False
11281128
11291129 pathlist = filter (is_valid_file , pathlist )
11301130 if len (pathlist ) == 0 :
1131- print 'Invalid source encountered in main(); no valid images found.'
1131+ print ( 'Invalid source encountered in main(); no valid images found.' )
11321132 return False
11331133
11341134 # Run RHT over all valid inputs.
0 commit comments