Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python 3 compatibility, remove some unused modules #1308

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion devel/brighter-fatter/bf_plots_07aug18.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import sys
import os
import math
import numpy
import logging
import time
import galsim
Expand Down
1 change: 0 additions & 1 deletion devel/brighter-fatter/bf_plots_20Oct17.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import sys
import os
import math
import numpy
import logging
import time
import galsim
Expand Down
42 changes: 21 additions & 21 deletions devel/lsst/csl_flats/Flat_Correlations_18Apr18.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Copyright (c) 2012-2023 by the GalSim developers team on GitHub
# https://github.com/GalSim-developers
#
# This file is part of GalSim: The modular galaxy image simulation toolkit.
# https://github.com/GalSim-developers/GalSim
#
# GalSim is free software: redistribution and use in source and binary forms,
# with or without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions, and the disclaimer given in the accompanying LICENSE
# file.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions, and the disclaimer given in the documentation
# and/or other materials provided with the distribution.
# Copyright (c) 2012-2023 by the GalSim developers team on GitHub
# https://github.com/GalSim-developers
#
# This file is part of GalSim: The modular galaxy image simulation toolkit.
# https://github.com/GalSim-developers/GalSim
#
# GalSim is free software: redistribution and use in source and binary forms,
# with or without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions, and the disclaimer given in the accompanying LICENSE
# file.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions, and the disclaimer given in the documentation
# and/or other materials provided with the distribution.
#


Expand All @@ -23,7 +23,7 @@

import pyfits as pf
from pylab import *
import os, sys, glob, time
import sys, glob, time
import numpy as np


Expand All @@ -37,12 +37,12 @@
edges[:,0:xmin] = True
edges[:,xmax:-1] = True
edge_mask = np.ma.make_mask(edges)
print edges.sum()
print (edges.sum())
mydir = "/Users/cslage/Research/LSST/code/galsim-developers-18apr18/GalSim/devel/lsst/flats/"
series = int(sys.argv[1])
even_patterns = sort(glob.glob(mydir+'flat_%d_*.fits*'%series))[0::2]
odd_patterns = sort(glob.glob(mydir+'flat_%d_*.fits*'%series))[1::2]
print "There are %d even patterns and %d oddpatterns"%(len(even_patterns), len(odd_patterns))
print ("There are %d even patterns and %d oddpatterns"%(len(even_patterns), len(odd_patterns)))
sys.stdout.flush()
numfiles = len(even_patterns)

Expand Down Expand Up @@ -101,7 +101,7 @@
sum121=(sub1*sub2).sum()
corr = (sum121 - sum11*sum21/npixused1)/npixused1

print "For file %d, NumDataPoints = %d, ii = %d, jj = %d,Cij = %.2f"%(n, npixused1, l, k, corr)
print ("For file %d, NumDataPoints = %d, ii = %d, jj = %d,Cij = %.2f"%(n, npixused1, l, k, corr))
file = open(filename,'a')
if k==0 and l==0:
line = '%d %d %d %f %f\n'%(l,k,n,corr,avemed)
Expand All @@ -111,6 +111,6 @@
file.close()
time_finish = time.time()
elapsed = time_finish - time_start
print "Elapsed time for file %d = %.2f"%(n,elapsed)
print ("Elapsed time for file %d = %.2f"%(n,elapsed))
sys.stdout.flush()

Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

import matplotlib
matplotlib.use("PDF")
import pyfits as pf
from pylab import *
import sys, glob, time
from scipy import stats
covsteps = 6

Expand Down Expand Up @@ -67,7 +65,7 @@
fluxes[i] += float(items[4])
numfluxvalues += 1
except Exception as e:
print "Exception of type %s and args = \n"%type(e).__name__, e.args
print ("Exception of type %s and args = \n"%type(e).__name__, e.args)
break
fluxes[i] /= float(numfluxvalues) # calculate the average flux in ADU

Expand Down Expand Up @@ -104,7 +102,7 @@
reduced_cov[ii,jj] = 1.0 + slope * flux_value
else:
reduced_cov[ii,jj] = slope * flux_value
print "ii = %d, jj = %d, slope = %g, reduced_cov = %.4f"%(ii,jj,slope, reduced_cov[ii,jj])
print ("ii = %d, jj = %d, slope = %g, reduced_cov = %.4f"%(ii,jj,slope, reduced_cov[ii,jj]))
if ii < 3 and jj < 3:
plotnum = 3 * ii + jj + 1
subplot(3,3,plotnum)
Expand Down
2 changes: 0 additions & 2 deletions devel/lsst/treering_flat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

from __future__ import print_function

import sys
import time
import numpy as np
import galsim

# Put the salient numbers up here so they are easy to adjust.
Expand Down
2 changes: 0 additions & 2 deletions devel/lsst/treering_flat_csl_18apr18.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

from __future__ import print_function

import sys
import time
import numpy as np
import galsim

# Put the salient numbers up here so they are easy to adjust.
Expand Down
1 change: 0 additions & 1 deletion devel/lsst/treering_skybg2.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from __future__ import print_function

import sys
import time
import numpy as np
import galsim
Expand Down
1 change: 0 additions & 1 deletion devel/modules/atmValidate/firstKick.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"""


import warnings
import os
import numpy as np
import galsim
Expand Down
1 change: 0 additions & 1 deletion devel/modules/atmValidate/firstKick_screen_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import matplotlib
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg

from astropy.utils.console import ProgressBar
Expand Down
2 changes: 0 additions & 2 deletions devel/modules/atmValidate/screen_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

import matplotlib
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg

from astropy.utils.console import ProgressBar

Expand Down
1 change: 0 additions & 1 deletion devel/modules/atmValidate/screen_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import matplotlib
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg

from astropy.utils.console import ProgressBar
Expand Down
1 change: 0 additions & 1 deletion devel/modules/atmValidate/secondKick.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

import matplotlib
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg

from astropy.utils.console import ProgressBar
Expand Down
1 change: 0 additions & 1 deletion devel/modules/atmValidate/vonKarman.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

import matplotlib
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg

from astropy.utils.console import ProgressBar
Expand Down
1 change: 0 additions & 1 deletion devel/modules/corrfuncs/test_cf_interpolant.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
used to describe correlation functions. See the discussion at
https://github.com/GalSim-developers/GalSim/pull/452#discussion-diff-5701561
"""
import numpy as np
import matplotlib.pyplot as plt
import galsim

Expand Down
12 changes: 6 additions & 6 deletions devel/modules/lensing_engine_interpolants.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def check_dir(dir):
"""
try:
os.makedirs(dir)
print "Created directory %s for outputs"%dir
print ("Created directory %s for outputs"%dir)
except OSError:
if os.path.isdir(dir):
# It was already a directory.
Expand Down Expand Up @@ -156,7 +156,7 @@ def generate_ps_cutoff_plots(ell, ps, theory_ps,
# Write to file.
outfile = ps_plot_prefix + interpolant + '_grid_cutoff_' + type + '.png'
plt.savefig(outfile)
print "Wrote power spectrum (grid cutoff) plot to file %r"%outfile
print ("Wrote power spectrum (grid cutoff) plot to file %r"%outfile)


def generate_ps_plots(ell, ps, interpolated_ps, interpolant, ps_plot_prefix,
Expand Down Expand Up @@ -257,7 +257,7 @@ def generate_ps_plots(ell, ps, interpolated_ps, interpolant, ps_plot_prefix,
# Write to file.
outfile = ps_plot_prefix + interpolant + '_' + type + '.png'
plt.savefig(outfile)
print "Wrote power spectrum plots to file %r"%outfile
print ("Wrote power spectrum plots to file %r"%outfile)

def generate_cf_cutoff_plots(th, cf, nocutoff_th, nocutoff_cf, interpolant, cf_plot_prefix,
type='p'):
Expand Down Expand Up @@ -303,7 +303,7 @@ def generate_cf_cutoff_plots(th, cf, nocutoff_th, nocutoff_cf, interpolant, cf_p
# Write to file.
outfile = cf_plot_prefix + interpolant + '_grid_cutoff_' + type + '.png'
plt.savefig(outfile)
print "Wrote correlation function (grid cutoff) plots to file %r"%outfile
print ("Wrote correlation function (grid cutoff) plots to file %r"%outfile)

def generate_cf_plots(th, cf, interpolated_cf, interpolant, cf_plot_prefix,
dth, type='p', theory_raw=None, theory_binned=None, theory_rand=None):
Expand Down Expand Up @@ -380,7 +380,7 @@ def generate_cf_plots(th, cf, interpolated_cf, interpolant, cf_plot_prefix,
# Write to file.
outfile = cf_plot_prefix + interpolant + '_' + type + '.png'
plt.savefig(outfile)
print "Wrote correlation function plots to file %r"%outfile
print ("Wrote correlation function plots to file %r"%outfile)

def write_ps_output(ell, ps, interpolated_ps, interpolant, ps_plot_prefix, type='EE'):
"""Routine to write final power spectra to file.
Expand All @@ -405,7 +405,7 @@ def write_ps_output(ell, ps, interpolated_ps, interpolant, ps_plot_prefix, type=
# Make ascii output.
outfile = ps_plot_prefix + interpolant + '_' + type + '.dat'
np.savetxt(outfile, np.column_stack((ell, ps, interpolated_ps)), fmt='%12.4e')
print "Wrote ascii output to file %r"%outfile
print ("Wrote ascii output to file %r"%outfile)

# Set up a FITS table for output file.
ell_col = pyfits.Column(name='ell', format='1D', array=ell)
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# and/or other materials provided with the distribution.
#
import sys,os,glob,re
import platform
import ctypes
import ctypes.util
import types
Expand Down
Loading