diff --git a/CHANGES.rst b/CHANGES.rst index 9b3810bd..87416cde 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,4 +1,3 @@ -Changes included in this version --------------------------------- - -Edit this template to detail updates to the codebase +v0.19.1 +------- +- Patch for new numpy version release (1.25.0). This version deprecated np.int and np.float. This release removes mention of these old methods. \ No newline at end of file diff --git a/README.md b/README.md index c8ceb413..24a166af 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ The following describes the typical work flow for contributing to the pysiaf pro 11. Delete your local copy of your branch. ### Installation -This package is supported in python 3.7, 3.8 and 3.9 +This package is supported in python 3.8 and 3.9 `pip install pysiaf` diff --git a/generate/generate_fgs.py b/generate/generate_fgs.py index b62a962d..35413399 100644 --- a/generate/generate_fgs.py +++ b/generate/generate_fgs.py @@ -129,7 +129,7 @@ polynomial_coefficients = iando.read.read_siaf_distortion_coefficients(instrument, AperName) number_of_coefficients = len(polynomial_coefficients) - polynomial_degree = np.int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) + polynomial_degree = int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) # set polynomial coefficients siaf_indices = ['{:02d}'.format(d) for d in polynomial_coefficients['siaf_index'].tolist()] diff --git a/generate/generate_nircam.py b/generate/generate_nircam.py index ed4c84d3..80c2913b 100644 --- a/generate/generate_nircam.py +++ b/generate/generate_nircam.py @@ -108,7 +108,7 @@ polynomial_coefficients = iando.read.read_siaf_distortion_coefficients(instrument, AperName) number_of_coefficients = len(polynomial_coefficients) - polynomial_degree = np.int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) + polynomial_degree = int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) aperture.Sci2IdlDeg = polynomial_degree # set polynomial coefficients @@ -163,8 +163,8 @@ if (sca_name == 'NRCA5') and (('MASK335R' in aperture.AperName) or ('MASK430R' in aperture.AperName)): # see https://jira.stsci.edu/browse/JWSTSIAF-77 sca_name += '335R430R' - v2_offset = np.float(wedge_offsets['v2_offset'][wedge_offsets['name'] == sca_name]) - v3_offset = np.float(wedge_offsets['v3_offset'][wedge_offsets['name'] == sca_name]) + v2_offset = float(wedge_offsets['v2_offset'][wedge_offsets['name'] == sca_name]) + v3_offset = float(wedge_offsets['v3_offset'][wedge_offsets['name'] == sca_name]) aperture.V2Ref += v2_offset aperture.V3Ref += v3_offset elif dependency_type == 'dhspil_wedge': diff --git a/generate/generate_niriss.py b/generate/generate_niriss.py index 8ab06ee3..4dcc4562 100644 --- a/generate/generate_niriss.py +++ b/generate/generate_niriss.py @@ -101,7 +101,7 @@ polynomial_coefficients = iando.read.read_siaf_distortion_coefficients(instrument, AperName) number_of_coefficients = len(polynomial_coefficients) - polynomial_degree = np.int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) + polynomial_degree = int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) # set polynomial coefficients siaf_indices = ['{:02d}'.format(d) for d in polynomial_coefficients['siaf_index'].tolist()] diff --git a/generate/generate_nirspec.py b/generate/generate_nirspec.py index 45f29bea..86c6f9d1 100644 --- a/generate/generate_nirspec.py +++ b/generate/generate_nirspec.py @@ -297,7 +297,7 @@ def read_pcf_gtp(file_name): # transform to numpy array when possible for key in data.keys(): try: - data[key] = np.array(data[key][0].split()).astype(np.float) + data[key] = np.array(data[key][0].split()).astype(float) except: pass @@ -802,7 +802,7 @@ def rows(pcfName, new_pcf_format=False): # 'F140X_GWA_OTE', 'F110W_GWA_OTE', 'CLEAR_GWA_OTE'] elif AperName in pcf_file_mapping.keys(): number_of_coefficients = len(pcf_data[AperName]['A']) - polynomial_degree = np.int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) + polynomial_degree = int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) aperture.Sci2IdlDeg = polynomial_degree k = 0 # polynomial coefficients for transformation that goes directly from the GWA pupil plane to the sky @@ -816,10 +816,10 @@ def rows(pcfName, new_pcf_format=False): # coefficients to apply the reflection in the MIRROR taking into account the correction # to the GWA position as derived from the sensor readings and their calibration relation - aperture.XSciScale = np.float(disperser_mirror_tiltx['CoeffsTemperature00'][0]) - aperture.YSciScale = np.float(disperser_mirror_tilty['CoeffsTemperature00'][0]) - aperture.XSciRef = np.float(disperser_mirror_tiltx['Zeroreadings'][0]) - aperture.YSciRef = np.float(disperser_mirror_tilty['Zeroreadings'][0]) + aperture.XSciScale = float(disperser_mirror_tiltx['CoeffsTemperature00'][0]) + aperture.YSciScale = float(disperser_mirror_tilty['CoeffsTemperature00'][0]) + aperture.XSciRef = float(disperser_mirror_tiltx['Zeroreadings'][0]) + aperture.YSciRef = float(disperser_mirror_tilty['Zeroreadings'][0]) aperture.DDCName = 'None' # TRANSFORM apertures for the conversion between the OTE image plane and the MSA plane @@ -838,7 +838,7 @@ def rows(pcfName, new_pcf_format=False): fore_pcf_data = read_pcf_gtp(fore_pcf) # deal with different formats of the .pcf files - fore_year = np.int(fore_pcf_data['DATE'][0][0:4]) + fore_year = int(fore_pcf_data['DATE'][0][0:4]) if fore_year > 2016: new_pcf_format = True else: diff --git a/generate/generate_reference_files.py b/generate/generate_reference_files.py index d90df7b4..ed48b23b 100644 --- a/generate/generate_reference_files.py +++ b/generate/generate_reference_files.py @@ -669,7 +669,7 @@ def generate_siaf_pre_flight_reference_files_nircam(): #generate distortion reference file number_of_coefficients = len(A) - polynomial_degree = np.int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) + polynomial_degree = int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) siaf_index = [] exponent_x = [] exponent_y = [] @@ -1143,7 +1143,7 @@ def generate_siaf_pre_flight_reference_files_niriss(distortion_file_name, verbos number_of_coefficients = len(AR) - polynomial_degree = np.int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) + polynomial_degree = int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) # if oss is False: if 1: @@ -1294,7 +1294,7 @@ def generate_siaf_pre_flight_reference_files_fgs(verbose=False, mode='siaf'): -2.81501600E-15, -1.73025000E-15, 2.57732600E-15, 1.75268080E-15, 2.95238320E-15]) number_of_coefficients = len(A) - polynomial_degree = np.int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) + polynomial_degree = int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) # generate distortion coefficient files siaf_index = [] diff --git a/pysiaf/aperture.py b/pysiaf/aperture.py index 776a4281..2a63e64e 100644 --- a/pysiaf/aperture.py +++ b/pysiaf/aperture.py @@ -288,7 +288,7 @@ def set_distortion_coefficients_from_file(self, file_name): polynomial_coefficients = read.read_siaf_distortion_coefficients(file_name=file_name) number_of_coefficients = len(polynomial_coefficients) - polynomial_degree = np.int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) + polynomial_degree = int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) self.Sci2IdlDeg = polynomial_degree # set polynomial coefficients @@ -910,7 +910,7 @@ def distortion_transform(self, from_system, to_system, include_offset=True): # Get the coefficients for "science" to "ideal" transformation (and back) # degree of distortion polynomial - degree = np.int(getattr(self, 'Sci2IdlDeg')) + degree = int(getattr(self, 'Sci2IdlDeg')) number_of_coefficients = polynomial.number_of_coefficients(degree) all_keys = self.__dict__.keys() @@ -1513,8 +1513,8 @@ def dms_corner(self): This corresponds to the OSS corner position (x: ColCorner, y: RowCorner). The notation for OSS is 1-based, i.e. the lower left corner of a FULL subarray is (1,1) """ - col_corner = np.ceil(np.min(self.corners('det')[0])).astype(np.int_) - row_corner = np.ceil(np.min(self.corners('det')[1])).astype(np.int_) + col_corner = np.ceil(np.min(self.corners('det')[0])).astype(int) + row_corner = np.ceil(np.min(self.corners('det')[1])).astype(int) return col_corner, row_corner diff --git a/pysiaf/iando/read.py b/pysiaf/iando/read.py index 61c09e25..d8b51eda 100644 --- a/pysiaf/iando/read.py +++ b/pysiaf/iando/read.py @@ -126,11 +126,11 @@ def read_hst_siaf(file=None, version=None): a = aperture.HstAperture() # Process the first 'CAJ' record. a.ap_name = text[0:10].strip() # Aperture Identifier. - a.v2_cent = np.float(text[10:25]) # SICS V2 Center. (same as a_v2_ref) - a.v3_cent = np.float(text[25:40]) # SICS V3 Center. (same as a_v3_ref) + a.v2_cent = float(text[10:25]) # SICS V2 Center. (same as a_v2_ref) + a.v3_cent = float(text[25:40]) # SICS V3 Center. (same as a_v3_ref) a.a_shape = text[40:44] # Aperture Shape. try: - a.maj = np.float(text[44:59]) # Major Axis Dimension. + a.maj = float(text[44:59]) # Major Axis Dimension. except ValueError: # when field is empty a.maj = None a.Mac_Flag = text[59] # !SI Macro Aperture Flag. @@ -144,24 +144,24 @@ def read_hst_siaf(file=None, version=None): elif (text.rstrip()[-3::] == 'CAJ') & (CAJ_index == 1): # Process the second 'CAJ' record. try: - a.min = np.float(text[0:15]) # !Minor Axis Dimension. + a.min = float(text[0:15]) # !Minor Axis Dimension. except ValueError: # when field is empty a.min = None - a.plate_scale = np.float(text[15:30]) # !Arcsecond per Pixel plate scale. - a.a_area = np.float(text[30:45]) # !Area of SI Aperture. - a.theta = np.float(text[45:60]) # !Aperture Rotation Angle. + a.plate_scale = float(text[15:30]) # !Arcsecond per Pixel plate scale. + a.a_area = float(text[30:45]) # !Area of SI Aperture. + a.theta = float(text[45:60]) # !Aperture Rotation Angle. a.SIAS_Flag = text[60] # !SIAS coordinate system flag. (If set then AK rec.) rec_type = text[70:73] # !Record type. CAJ_index = 2 elif (text.rstrip()[-3::] == 'CAJ') & (CAJ_index == 2): # Process the third 'CAJ' record. - a.im_par = np.int(text[0:2]) # Image Parity. - a.ideg = np.int(text[2]) # !Polynomial Degree. - a.xa0 = np.float(text[3:18]) # !SIAS X Center. -> like JWST SCIENCE frame - a.ya0 = np.float(text[18:33]) # !SIAS Y Center. - a.xs0 = np.float(text[33:48]) # !SICS X Center. -> like JWST IDEAL frame - a.ys0 = np.float(text[48:63]) # !SICS Y Center. + a.im_par = int(text[0:2]) # Image Parity. + a.ideg = int(text[2]) # !Polynomial Degree. + a.xa0 = float(text[3:18]) # !SIAS X Center. -> like JWST SCIENCE frame + a.ya0 = float(text[18:33]) # !SIAS Y Center. + a.xs0 = float(text[33:48]) # !SICS X Center. -> like JWST IDEAL frame + a.ys0 = float(text[48:63]) # !SICS Y Center. rec_type = text[70:73] # !Record type. CAJ_index = 0 @@ -174,34 +174,34 @@ def read_hst_siaf(file=None, version=None): rec_type = text[70:73] # !Record type. elif text.rstrip()[-3::] == 'CAQ': - a.v1x = np.float(text[0:15]) # !SICS Vertex 1_X -> like JWST IDEAL frame - a.v1y = np.float(text[15:30]) # !SICS Vertex 1_Y - a.v2x = np.float(text[30:45]) # !SICS Vertex 2_X - a.v2y = np.float(text[45:60]) # !SICS Vertex 2_Y + a.v1x = float(text[0:15]) # !SICS Vertex 1_X -> like JWST IDEAL frame + a.v1y = float(text[15:30]) # !SICS Vertex 1_Y + a.v2x = float(text[30:45]) # !SICS Vertex 2_X + a.v2y = float(text[45:60]) # !SICS Vertex 2_Y rec_type = text[70:73] # !Record type. elif text.rstrip()[-2::] == 'AQ': - a.v3x = np.float(text[0:15]) # !SICS Vertex 3_X - a.v3y = np.float(text[15:30]) # !SICS Vertex 3_Y - a.v4x = np.float(text[30:45]) # !SICS Vertex 4_X - a.v4y = np.float(text[45:60]) # !SICS Vertex 4_Y + a.v3x = float(text[0:15]) # !SICS Vertex 3_X + a.v3y = float(text[15:30]) # !SICS Vertex 3_Y + a.v4x = float(text[30:45]) # !SICS Vertex 4_X + a.v4y = float(text[45:60]) # !SICS Vertex 4_Y rec_type = text[70:73] # !Record type. elif text.rstrip()[-2::] == 'AP': # FGS pickles - a.pi_angle = np.float(text[0:15]) # !Inner Radius Orientation Angle. - a.pi_ext = np.float(text[15:30]) # !Angular Extent of the Inner Radius. - a.po_angle = np.float(text[30:45]) # !Outer Radius Orientation Angle. - a.po_ext = np.float(text[45:60]) # !Angular Extent of the Outer Radius. + a.pi_angle = float(text[0:15]) # !Inner Radius Orientation Angle. + a.pi_ext = float(text[15:30]) # !Angular Extent of the Inner Radius. + a.po_angle = float(text[30:45]) # !Outer Radius Orientation Angle. + a.po_ext = float(text[45:60]) # !Angular Extent of the Outer Radius. rec_type = text[70:73] # !Record type. elif text.rstrip()[-2::] == 'AM': - a.a_v2_ref = np.float(text[0:15]) # !V2 Coordinate of Aperture Reference Point. + a.a_v2_ref = float(text[0:15]) # !V2 Coordinate of Aperture Reference Point. # (same as v2_cent) - a.a_v3_ref = np.float(text[15:30]) # !V3 Coordinate of Aperture Reference Point. + a.a_v3_ref = float(text[15:30]) # !V3 Coordinate of Aperture Reference Point. # (same as v3_cent) - a.a_x_incr = np.float(text[30:45]) # !First Coordinate Axis increment. - a.a_y_incr = np.float(text[45:60]) # !Second Coordinate Axis increment. + a.a_x_incr = float(text[30:45]) # !First Coordinate Axis increment. + a.a_y_incr = float(text[45:60]) # !Second Coordinate Axis increment. elif text.rstrip()[-2::] == 'AN': if (a.a_shape == 'PICK') and ('FGS' in a.ap_name): @@ -229,7 +229,7 @@ def read_hst_siaf(file=None, version=None): elif (text.rstrip()[-3::] == 'CAK') & (CAK_index == 0): # Process the first 'CAK' record. - n_polynomial_coefficients = np.int(((a.ideg + 1) * (a.ideg + 2)) / 2) + n_polynomial_coefficients = int(((a.ideg + 1) * (a.ideg + 2)) / 2) # the order is # SIAS to SICS X Transformation. # SIAS to SICS Y Transformation. @@ -238,19 +238,19 @@ def read_hst_siaf(file=None, version=None): polynomial_coefficients = np.ones((n_polynomial_coefficients, 4)) * -99 for jj in np.arange(4): - polynomial_coefficients[CAK_index, jj] = np.float(text[15 * jj:15 * (jj + 1)]) + polynomial_coefficients[CAK_index, jj] = float(text[15 * jj:15 * (jj + 1)]) CAK_index += 1 elif (text.rstrip()[-3::] == 'CAK') & (CAK_index != 0): # Process the remaining 'CAK' records for jj in np.arange(4): - polynomial_coefficients[CAK_index, jj] = np.float(text[15 * jj:15 * (jj + 1)]) + polynomial_coefficients[CAK_index, jj] = float(text[15 * jj:15 * (jj + 1)]) CAK_index += 1 elif text.rstrip()[-2::] == 'AK': # Process the last polynomial coefficient record. for jj in np.arange(4): - polynomial_coefficients[CAK_index, jj] = np.float(text[15 * jj:15 * (jj + 1)]) + polynomial_coefficients[CAK_index, jj] = float(text[15 * jj:15 * (jj + 1)]) a.polynomial_coefficients = polynomial_coefficients CAK_index = 0 @@ -415,7 +415,7 @@ def read_jwst_siaf(instrument=None, filename=None, basepath=None): except (TypeError, ValueError) as e: # print('{}: {}: {}'.format(e, node.tag, node.text)) if node.tag == 'DetSciYAngle': - value = np.int(float((node.text))) + value = int(float((node.text))) else: raise TypeError elif node.tag in aperture.STRING_ATTRIBUTES: diff --git a/pysiaf/tests/test_nirspec.py b/pysiaf/tests/test_nirspec.py index 3a5d0acb..fd1b4b0e 100644 --- a/pysiaf/tests/test_nirspec.py +++ b/pysiaf/tests/test_nirspec.py @@ -72,7 +72,7 @@ def test_against_test_data(siaf=None): tilt = None else: test_header = fits.getheader(test_data_file) - tilt = (np.float(test_header['GWA_XTIL']), np.float(test_header['GWA_YTIL'])) + tilt = (float(test_header['GWA_XTIL']), float(test_header['GWA_YTIL'])) if sca_name == 'SCA491': AperName = 'NRS1_FULL_OSS' diff --git a/pysiaf/utils/polynomial.py b/pysiaf/utils/polynomial.py index 38871030..d6f44141 100644 --- a/pysiaf/utils/polynomial.py +++ b/pysiaf/utils/polynomial.py @@ -375,7 +375,7 @@ def jacob(a, b, x, y): def number_of_coefficients(poly_degree): """Return number of coefficients corresponding to polynomial degree.""" if type(poly_degree) == int: - n_coefficients = np.int((poly_degree + 1) * (poly_degree + 2) / 2) + n_coefficients = int((poly_degree + 1) * (poly_degree + 2) / 2) return n_coefficients else: raise TypeError('Argument has to be of type int') @@ -486,7 +486,7 @@ def polynomial_degree(number_of_coefficients): if not poly_degree.is_integer(): raise ValueError('Number of coefficients does not match a valid polynomial degree.') else: - return np.int(poly_degree) + return int(poly_degree) def prepend_rotation_to_polynomial(a, theta, verbose=False): diff --git a/pysiaf/utils/tools.py b/pysiaf/utils/tools.py index 33cf070a..454a5754 100644 --- a/pysiaf/utils/tools.py +++ b/pysiaf/utils/tools.py @@ -67,7 +67,7 @@ def compute_roundtrip_error(A, B, C, D, offset_x=0., offset_y=0., verbose=False, """ number_of_coefficients = len(A) - polynomial_degree = np.int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) + polynomial_degree = int((np.sqrt(8 * number_of_coefficients + 1) - 3) / 2) order = polynomial_degree # regular grid of points (in science pixel coordinates) in the full frame science frame @@ -440,7 +440,7 @@ def set_reference_point_and_distortion(instrument, aperture, parent_aperture): """ polynomial_degree = parent_aperture.Sci2IdlDeg - number_of_coefficients = np.int((polynomial_degree + 1) * (polynomial_degree + 2) / 2) + number_of_coefficients = int((polynomial_degree + 1) * (polynomial_degree + 2) / 2) k = 0 sci2idlx_coefficients = np.zeros(number_of_coefficients)