From b2c38ddf5cc15128dd5e129ebb2fdff636f23f64 Mon Sep 17 00:00:00 2001 From: Martin Raspaud Date: Fri, 30 Aug 2024 10:19:15 +0200 Subject: [PATCH] Add numpy 2 compatibility ruff checks --- pygac/gac_io.py | 338 ++++++++++++++++++------------------- pygac/tests/test_reader.py | 9 +- pygac/tests/test_tsm.py | 4 +- pyproject.toml | 2 +- 4 files changed, 177 insertions(+), 176 deletions(-) diff --git a/pygac/gac_io.py b/pygac/gac_io.py index 69110bc..0d0afd0 100644 --- a/pygac/gac_io.py +++ b/pygac/gac_io.py @@ -250,18 +250,18 @@ def avhrrGAC_io(satellite_name, xutcs, startdate, enddate, starttime, endtime, g6 = fout.require_group("/image6") g7 = fout.require_group("/where") - g1.attrs["channel"] = np.string_("1") - g1.attrs["description"] = np.string_("AVHRR ch1") - g2.attrs["channel"] = np.string_("2") - g2.attrs["description"] = np.string_("AVHRR ch2") - g3.attrs["channel"] = np.string_("3b") - g3.attrs["description"] = np.string_("AVHRR ch3b") - g4.attrs["channel"] = np.string_("4") - g4.attrs["description"] = np.string_("AVHRR ch4") - g5.attrs["channel"] = np.string_("5") - g5.attrs["description"] = np.string_("AVHRR ch5") - g6.attrs["channel"] = np.string_("3a") - g6.attrs["description"] = np.string_("AVHRR ch3a") + g1.attrs["channel"] = np.bytes_("1") + g1.attrs["description"] = np.bytes_("AVHRR ch1") + g2.attrs["channel"] = np.bytes_("2") + g2.attrs["description"] = np.bytes_("AVHRR ch2") + g3.attrs["channel"] = np.bytes_("3b") + g3.attrs["description"] = np.bytes_("AVHRR ch3b") + g4.attrs["channel"] = np.bytes_("4") + g4.attrs["description"] = np.bytes_("AVHRR ch4") + g5.attrs["channel"] = np.bytes_("5") + g5.attrs["description"] = np.bytes_("AVHRR ch5") + g6.attrs["channel"] = np.bytes_("3a") + g6.attrs["description"] = np.bytes_("AVHRR ch3a") g7.attrs["num_of_pixels"] = np.int32(arrSZA.shape[1]) g7.attrs["num_of_lines"] = np.int32(arrSZA.shape[0]) g7.attrs["xscale"] = np.float32(0.0) @@ -280,111 +280,111 @@ def avhrrGAC_io(satellite_name, xutcs, startdate, enddate, starttime, endtime, g8 = fout.create_group("/where/lon/what") g9 = fout.create_group("/what") - g1.attrs["product"] = np.string_("SATCH") - g1.attrs["quantity"] = np.string_("REFL") - g1.attrs["dataset_name"] = np.string_("Channel 1 reflectance") - g1.attrs["units"] = np.string_("%") + g1.attrs["product"] = np.bytes_("SATCH") + g1.attrs["quantity"] = np.bytes_("REFL") + g1.attrs["dataset_name"] = np.bytes_("Channel 1 reflectance") + g1.attrs["units"] = np.bytes_("%") g1.attrs["gain"] = np.float32(0.01) g1.attrs["offset"] = np.float32(0.0) g1.attrs["missingdata"] = np.int32(MISSING_DATA) g1.attrs["nodata"] = np.int32(MISSING_DATA) - g1.attrs["starttime"] = np.string_(starttime[0:6]) - g1.attrs["endtime"] = np.string_(endtime[0:6]) - g1.attrs["startdate"] = np.string_(startdate) - g1.attrs["enddate"] = np.string_(enddate) - - g2.attrs["product"] = np.string_("SATCH") - g2.attrs["quantity"] = np.string_("REFL") - g2.attrs["dataset_name"] = np.string_("Channel 2 reflectance") - g2.attrs["units"] = np.string_("%") + g1.attrs["starttime"] = np.bytes_(starttime[0:6]) + g1.attrs["endtime"] = np.bytes_(endtime[0:6]) + g1.attrs["startdate"] = np.bytes_(startdate) + g1.attrs["enddate"] = np.bytes_(enddate) + + g2.attrs["product"] = np.bytes_("SATCH") + g2.attrs["quantity"] = np.bytes_("REFL") + g2.attrs["dataset_name"] = np.bytes_("Channel 2 reflectance") + g2.attrs["units"] = np.bytes_("%") g2.attrs["gain"] = np.float32(0.01) g2.attrs["offset"] = np.float32(0.0) g2.attrs["missingdata"] = np.int32(MISSING_DATA) g2.attrs["nodata"] = np.int32(MISSING_DATA) - g2.attrs["starttime"] = np.string_(starttime[0:6]) - g2.attrs["endtime"] = np.string_(endtime[0:6]) - g2.attrs["startdate"] = np.string_(startdate) - g2.attrs["enddate"] = np.string_(enddate) - - g6.attrs["product"] = np.string_("SATCH") - g6.attrs["quantity"] = np.string_("REFL") - g6.attrs["dataset_name"] = np.string_("Channel 3a reflectance") - g6.attrs["units"] = np.string_("%") + g2.attrs["starttime"] = np.bytes_(starttime[0:6]) + g2.attrs["endtime"] = np.bytes_(endtime[0:6]) + g2.attrs["startdate"] = np.bytes_(startdate) + g2.attrs["enddate"] = np.bytes_(enddate) + + g6.attrs["product"] = np.bytes_("SATCH") + g6.attrs["quantity"] = np.bytes_("REFL") + g6.attrs["dataset_name"] = np.bytes_("Channel 3a reflectance") + g6.attrs["units"] = np.bytes_("%") g6.attrs["gain"] = np.float32(0.01) g6.attrs["offset"] = np.float32(0.0) g6.attrs["missingdata"] = np.int32(MISSING_DATA) g6.attrs["nodata"] = np.int32(MISSING_DATA) - g6.attrs["starttime"] = np.string_(starttime[0:6]) - g6.attrs["endtime"] = np.string_(endtime[0:6]) - g6.attrs["startdate"] = np.string_(startdate) - g6.attrs["enddate"] = np.string_(enddate) - - g3.attrs["product"] = np.string_("SATCH") - g3.attrs["quantity"] = np.string_("TB") - g3.attrs["dataset_name"] = np.string_("Channel 3b brightness temperature") - g3.attrs["units"] = np.string_("K") + g6.attrs["starttime"] = np.bytes_(starttime[0:6]) + g6.attrs["endtime"] = np.bytes_(endtime[0:6]) + g6.attrs["startdate"] = np.bytes_(startdate) + g6.attrs["enddate"] = np.bytes_(enddate) + + g3.attrs["product"] = np.bytes_("SATCH") + g3.attrs["quantity"] = np.bytes_("TB") + g3.attrs["dataset_name"] = np.bytes_("Channel 3b brightness temperature") + g3.attrs["units"] = np.bytes_("K") g3.attrs["gain"] = np.float32(0.01) g3.attrs["offset"] = np.float32(273.15) g3.attrs["missingdata"] = np.int32(MISSING_DATA) g3.attrs["nodata"] = np.int32(MISSING_DATA) - g3.attrs["starttime"] = np.string_(starttime[0:6]) - g3.attrs["endtime"] = np.string_(endtime[0:6]) - g3.attrs["startdate"] = np.string_(startdate) - g3.attrs["enddate"] = np.string_(enddate) - - g4.attrs["product"] = np.string_("SATCH") - g4.attrs["quantity"] = np.string_("TB") - g4.attrs["dataset_name"] = np.string_("Channel 4 brightness temperature") - g4.attrs["units"] = np.string_("K") + g3.attrs["starttime"] = np.bytes_(starttime[0:6]) + g3.attrs["endtime"] = np.bytes_(endtime[0:6]) + g3.attrs["startdate"] = np.bytes_(startdate) + g3.attrs["enddate"] = np.bytes_(enddate) + + g4.attrs["product"] = np.bytes_("SATCH") + g4.attrs["quantity"] = np.bytes_("TB") + g4.attrs["dataset_name"] = np.bytes_("Channel 4 brightness temperature") + g4.attrs["units"] = np.bytes_("K") g4.attrs["gain"] = np.float32(0.01) g4.attrs["offset"] = np.float32(273.15) g4.attrs["missingdata"] = np.int32(MISSING_DATA) g4.attrs["nodata"] = np.int32(MISSING_DATA) - g4.attrs["starttime"] = np.string_(starttime[0:6]) - g4.attrs["endtime"] = np.string_(endtime[0:6]) - g4.attrs["startdate"] = np.string_(startdate) - g4.attrs["enddate"] = np.string_(enddate) - - g5.attrs["product"] = np.string_("SATCH") - g5.attrs["quantity"] = np.string_("TB") - g5.attrs["dataset_name"] = np.string_("Channel 5 brightness temperature") - g5.attrs["units"] = np.string_("K") + g4.attrs["starttime"] = np.bytes_(starttime[0:6]) + g4.attrs["endtime"] = np.bytes_(endtime[0:6]) + g4.attrs["startdate"] = np.bytes_(startdate) + g4.attrs["enddate"] = np.bytes_(enddate) + + g5.attrs["product"] = np.bytes_("SATCH") + g5.attrs["quantity"] = np.bytes_("TB") + g5.attrs["dataset_name"] = np.bytes_("Channel 5 brightness temperature") + g5.attrs["units"] = np.bytes_("K") g5.attrs["gain"] = np.float32(0.01) g5.attrs["offset"] = np.float32(273.15) g5.attrs["missingdata"] = np.int32(MISSING_DATA) g5.attrs["nodata"] = np.int32(MISSING_DATA) - g5.attrs["starttime"] = np.string_(starttime[0:6]) - g5.attrs["endtime"] = np.string_(endtime[0:6]) - g5.attrs["startdate"] = np.string_(startdate) - g5.attrs["enddate"] = np.string_(enddate) + g5.attrs["starttime"] = np.bytes_(starttime[0:6]) + g5.attrs["endtime"] = np.bytes_(endtime[0:6]) + g5.attrs["startdate"] = np.bytes_(startdate) + g5.attrs["enddate"] = np.bytes_(enddate) - g7.attrs["dataset_name"] = np.string_("Latitude") - g7.attrs["units"] = np.string_("Deg") + g7.attrs["dataset_name"] = np.bytes_("Latitude") + g7.attrs["units"] = np.bytes_("Deg") g7.attrs["gain"] = np.float32(0.0010) g7.attrs["offset"] = np.float32(0.0) g7.attrs["missingdata"] = np.int32(MISSING_DATA_LATLON) g7.attrs["nodata"] = np.int32(MISSING_DATA_LATLON) - g7.attrs["starttime"] = np.string_(starttime[0:6]) - g7.attrs["endtime"] = np.string_(endtime[0:6]) - g7.attrs["startdate"] = np.string_(startdate) - g7.attrs["enddate"] = np.string_(enddate) + g7.attrs["starttime"] = np.bytes_(starttime[0:6]) + g7.attrs["endtime"] = np.bytes_(endtime[0:6]) + g7.attrs["startdate"] = np.bytes_(startdate) + g7.attrs["enddate"] = np.bytes_(enddate) - g8.attrs["dataset_name"] = np.string_("Longitude") - g8.attrs["units"] = np.string_("Deg") + g8.attrs["dataset_name"] = np.bytes_("Longitude") + g8.attrs["units"] = np.bytes_("Deg") g8.attrs["gain"] = np.float32(0.0010) g8.attrs["offset"] = np.float32(0.0) g8.attrs["missingdata"] = np.int32(MISSING_DATA_LATLON) g8.attrs["nodata"] = np.int32(MISSING_DATA_LATLON) - g8.attrs["starttime"] = np.string_(starttime[0:6]) - g8.attrs["endtime"] = np.string_(endtime[0:6]) - g8.attrs["startdate"] = np.string_(startdate) - g8.attrs["enddate"] = np.string_(enddate) + g8.attrs["starttime"] = np.bytes_(starttime[0:6]) + g8.attrs["endtime"] = np.bytes_(endtime[0:6]) + g8.attrs["startdate"] = np.bytes_(startdate) + g8.attrs["enddate"] = np.bytes_(enddate) - g9.attrs["object"] = np.string_("SATP") + g9.attrs["object"] = np.bytes_("SATP") g9.attrs["sets"] = np.int32(len(channellist)) - g9.attrs["version"] = np.string_("H5rad ?.?") - g9.attrs["date"] = np.string_(startdate) - g9.attrs["time"] = np.string_(starttime[0:6]) + g9.attrs["version"] = np.bytes_("H5rad ?.?") + g9.attrs["date"] = np.bytes_(startdate) + g9.attrs["time"] = np.bytes_(starttime[0:6]) # Attributes in the 'how' groups g1 = fout.create_group("/image1/how") @@ -396,12 +396,12 @@ def avhrrGAC_io(satellite_name, xutcs, startdate, enddate, starttime, endtime, g10 = fout.require_group("/how") # SHq: Is the sun_earth_distance correction applied? - g1.attrs["sun_earth_distance_correction_applied"] = np.string_("TRUE") + g1.attrs["sun_earth_distance_correction_applied"] = np.bytes_("TRUE") g1.attrs["sun_earth_distance_correction_factor"] = corr - g2.attrs["sun_earth_distance_correction_applied"] = np.string_("TRUE") + g2.attrs["sun_earth_distance_correction_applied"] = np.bytes_("TRUE") g2.attrs["sun_earth_distance_correction_factor"] = corr # No attributes on 'how' for image3,4,5 - g6.attrs["sun_earth_distance_correction_applied"] = np.string_("TRUE") + g6.attrs["sun_earth_distance_correction_applied"] = np.bytes_("TRUE") g6.attrs["sun_earth_distance_correction_factor"] = corr # We do not know much about how; mostly use no-data @@ -410,12 +410,12 @@ def avhrrGAC_io(satellite_name, xutcs, startdate, enddate, starttime, endtime, g10.attrs["pitch_error"] = 0.0 g10.attrs["startepochs"] = starttime_sec1970 g10.attrs["endepochs"] = endtime_sec1970 - g10.attrs["platform"] = np.string_(satellite_name) - g10.attrs["instrument"] = np.string_("avhrr") + g10.attrs["platform"] = np.bytes_(satellite_name) + g10.attrs["instrument"] = np.bytes_("avhrr") g10.attrs["orbit_number"] = np.int32(99999) - g10.attrs["gac_file"] = np.string_(gac_file) - g10.attrs["software"] = np.string_("pyGAC") - g10.attrs["version"] = np.string_("1.0") + g10.attrs["gac_file"] = np.bytes_(gac_file) + g10.attrs["software"] = np.bytes_("pyGAC") + g10.attrs["version"] = np.bytes_("1.0") fout.close() @@ -450,12 +450,12 @@ def avhrrGAC_io(satellite_name, xutcs, startdate, enddate, starttime, endtime, g5 = fout.require_group("/image5") g6 = fout.require_group("/where") - g1.attrs["description"] = np.string_("Solar zenith angle") - g2.attrs["description"] = np.string_("Satellite zenith angle") - g3.attrs["description"] = np.string_( + g1.attrs["description"] = np.bytes_("Solar zenith angle") + g2.attrs["description"] = np.bytes_("Satellite zenith angle") + g3.attrs["description"] = np.bytes_( "Relative satellite-sun azimuth angle") - g4.attrs["description"] = np.string_("Solar azimuth angle") - g5.attrs["description"] = np.string_("Satellite azimuth angle") + g4.attrs["description"] = np.bytes_("Solar azimuth angle") + g5.attrs["description"] = np.bytes_("Satellite azimuth angle") g6.attrs["num_of_pixels"] = np.int32(arrSZA.shape[1]) g6.attrs["num_of_lines"] = np.int32(arrSZA.shape[0]) g6.attrs["xscale"] = np.float32(0.0) @@ -474,99 +474,99 @@ def avhrrGAC_io(satellite_name, xutcs, startdate, enddate, starttime, endtime, g8 = fout.create_group("/what") g9 = fout.create_group("/how") - g1.attrs["product"] = np.string_("SUNZ") - g1.attrs["quantity"] = np.string_("DEG") - g1.attrs["dataset_name"] = np.string_("Solar zenith angle") - g1.attrs["units"] = np.string_("Deg") + g1.attrs["product"] = np.bytes_("SUNZ") + g1.attrs["quantity"] = np.bytes_("DEG") + g1.attrs["dataset_name"] = np.bytes_("Solar zenith angle") + g1.attrs["units"] = np.bytes_("Deg") g1.attrs["gain"] = np.float32(0.01) g1.attrs["offset"] = np.float32(0.0) g1.attrs["missingdata"] = np.int32(MISSING_DATA) g1.attrs["nodata"] = np.int32(MISSING_DATA) - g1.attrs["starttime"] = np.string_(starttime[0:6]) - g1.attrs["endtime"] = np.string_(endtime[0:6]) - g1.attrs["startdate"] = np.string_(startdate) - g1.attrs["enddate"] = np.string_(enddate) - - g2.attrs["product"] = np.string_("SATZ") - g2.attrs["quantity"] = np.string_("DEG") - g2.attrs["dataset_name"] = np.string_("Satellite zenith angle") - g2.attrs["units"] = np.string_("Deg") + g1.attrs["starttime"] = np.bytes_(starttime[0:6]) + g1.attrs["endtime"] = np.bytes_(endtime[0:6]) + g1.attrs["startdate"] = np.bytes_(startdate) + g1.attrs["enddate"] = np.bytes_(enddate) + + g2.attrs["product"] = np.bytes_("SATZ") + g2.attrs["quantity"] = np.bytes_("DEG") + g2.attrs["dataset_name"] = np.bytes_("Satellite zenith angle") + g2.attrs["units"] = np.bytes_("Deg") g2.attrs["gain"] = np.float32(0.01) g2.attrs["offset"] = np.float32(0.0) g2.attrs["missingdata"] = np.int32(MISSING_DATA) g2.attrs["nodata"] = np.int32(MISSING_DATA) - g2.attrs["starttime"] = np.string_(starttime[0:6]) - g2.attrs["endtime"] = np.string_(endtime[0:6]) - g2.attrs["startdate"] = np.string_(startdate) - g2.attrs["enddate"] = np.string_(enddate) - - g3.attrs["product"] = np.string_("SSAZD") - g3.attrs["quantity"] = np.string_("DEG") - g3.attrs["dataset_name"] = np.string_( + g2.attrs["starttime"] = np.bytes_(starttime[0:6]) + g2.attrs["endtime"] = np.bytes_(endtime[0:6]) + g2.attrs["startdate"] = np.bytes_(startdate) + g2.attrs["enddate"] = np.bytes_(enddate) + + g3.attrs["product"] = np.bytes_("SSAZD") + g3.attrs["quantity"] = np.bytes_("DEG") + g3.attrs["dataset_name"] = np.bytes_( "Relative satellite-sun azimuth angle") - g3.attrs["units"] = np.string_("Deg") + g3.attrs["units"] = np.bytes_("Deg") g3.attrs["gain"] = np.float32(0.01) g3.attrs["offset"] = np.float32(0.0) g3.attrs["missingdata"] = np.int32(MISSING_DATA) g3.attrs["nodata"] = np.int32(MISSING_DATA) - g3.attrs["starttime"] = np.string_(starttime[0:6]) - g3.attrs["endtime"] = np.string_(endtime[0:6]) - g3.attrs["startdate"] = np.string_(startdate) - g3.attrs["enddate"] = np.string_(enddate) - - g4.attrs["product"] = np.string_("SUNA") - g4.attrs["quantity"] = np.string_("DEG") - g4.attrs["dataset_name"] = np.string_("Solar azimuth angle") - g4.attrs["units"] = np.string_("Deg") + g3.attrs["starttime"] = np.bytes_(starttime[0:6]) + g3.attrs["endtime"] = np.bytes_(endtime[0:6]) + g3.attrs["startdate"] = np.bytes_(startdate) + g3.attrs["enddate"] = np.bytes_(enddate) + + g4.attrs["product"] = np.bytes_("SUNA") + g4.attrs["quantity"] = np.bytes_("DEG") + g4.attrs["dataset_name"] = np.bytes_("Solar azimuth angle") + g4.attrs["units"] = np.bytes_("Deg") g4.attrs["gain"] = np.float32(0.01) g4.attrs["offset"] = np.float32(0.0) g4.attrs["missingdata"] = np.int32(MISSING_DATA) g4.attrs["nodata"] = np.int32(MISSING_DATA) - g4.attrs["starttime"] = np.string_(starttime[0:6]) - g4.attrs["endtime"] = np.string_(endtime[0:6]) - g4.attrs["startdate"] = np.string_(startdate) - g4.attrs["enddate"] = np.string_(enddate) - - g5.attrs["product"] = np.string_("SATA") - g5.attrs["quantity"] = np.string_("DEG") - g5.attrs["dataset_name"] = np.string_("Satellite azimuth angle") - g5.attrs["units"] = np.string_("Deg") + g4.attrs["starttime"] = np.bytes_(starttime[0:6]) + g4.attrs["endtime"] = np.bytes_(endtime[0:6]) + g4.attrs["startdate"] = np.bytes_(startdate) + g4.attrs["enddate"] = np.bytes_(enddate) + + g5.attrs["product"] = np.bytes_("SATA") + g5.attrs["quantity"] = np.bytes_("DEG") + g5.attrs["dataset_name"] = np.bytes_("Satellite azimuth angle") + g5.attrs["units"] = np.bytes_("Deg") g5.attrs["gain"] = np.float32(0.01) g5.attrs["offset"] = np.float32(0.0) g5.attrs["missingdata"] = np.int32(MISSING_DATA) g5.attrs["nodata"] = np.int32(MISSING_DATA) - g5.attrs["starttime"] = np.string_(starttime[0:6]) - g5.attrs["endtime"] = np.string_(endtime[0:6]) - g5.attrs["startdate"] = np.string_(startdate) - g5.attrs["enddate"] = np.string_(enddate) + g5.attrs["starttime"] = np.bytes_(starttime[0:6]) + g5.attrs["endtime"] = np.bytes_(endtime[0:6]) + g5.attrs["startdate"] = np.bytes_(startdate) + g5.attrs["enddate"] = np.bytes_(enddate) - g6.attrs["dataset_name"] = np.string_("Latitude") - g6.attrs["units"] = np.string_("Deg") + g6.attrs["dataset_name"] = np.bytes_("Latitude") + g6.attrs["units"] = np.bytes_("Deg") g6.attrs["gain"] = np.float32(0.0010) g6.attrs["offset"] = np.float32(0.0) g6.attrs["missingdata"] = np.int32(MISSING_DATA_LATLON) g6.attrs["nodata"] = np.int32(MISSING_DATA_LATLON) - g6.attrs["starttime"] = np.string_(starttime[0:6]) - g6.attrs["endtime"] = np.string_(endtime[0:6]) - g6.attrs["startdate"] = np.string_(startdate) - g6.attrs["enddate"] = np.string_(enddate) + g6.attrs["starttime"] = np.bytes_(starttime[0:6]) + g6.attrs["endtime"] = np.bytes_(endtime[0:6]) + g6.attrs["startdate"] = np.bytes_(startdate) + g6.attrs["enddate"] = np.bytes_(enddate) - g7.attrs["dataset_name"] = np.string_("Longitude") - g7.attrs["units"] = np.string_("Deg") + g7.attrs["dataset_name"] = np.bytes_("Longitude") + g7.attrs["units"] = np.bytes_("Deg") g7.attrs["gain"] = np.float32(0.0010) g7.attrs["offset"] = np.float32(0.0) g7.attrs["missingdata"] = np.int32(MISSING_DATA_LATLON) g7.attrs["nodata"] = np.int32(MISSING_DATA_LATLON) - g7.attrs["starttime"] = np.string_(starttime[0:6]) - g7.attrs["endtime"] = np.string_(endtime[0:6]) - g7.attrs["startdate"] = np.string_(startdate) - g7.attrs["enddate"] = np.string_(enddate) + g7.attrs["starttime"] = np.bytes_(starttime[0:6]) + g7.attrs["endtime"] = np.bytes_(endtime[0:6]) + g7.attrs["startdate"] = np.bytes_(startdate) + g7.attrs["enddate"] = np.bytes_(enddate) - g8.attrs["object"] = np.string_("SATP") + g8.attrs["object"] = np.bytes_("SATP") g8.attrs["sets"] = np.int32(5) - g8.attrs["version"] = np.string_("H5rad ?.?") - g8.attrs["date"] = np.string_(startdate) - g8.attrs["time"] = np.string_(starttime[0:6]) + g8.attrs["version"] = np.bytes_("H5rad ?.?") + g8.attrs["date"] = np.bytes_(startdate) + g8.attrs["time"] = np.bytes_(starttime[0:6]) # We do not know much about how; mostly use no-data g9.attrs["yaw_error"] = 0.0 @@ -574,12 +574,12 @@ def avhrrGAC_io(satellite_name, xutcs, startdate, enddate, starttime, endtime, g9.attrs["pitch_error"] = 0.0 g9.attrs["startepochs"] = starttime_sec1970 g9.attrs["endepochs"] = endtime_sec1970 - g9.attrs["platform"] = np.string_(satellite_name) - g9.attrs["instrument"] = np.string_("avhrr") + g9.attrs["platform"] = np.bytes_(satellite_name) + g9.attrs["instrument"] = np.bytes_("avhrr") g9.attrs["orbit_number"] = np.int32(99999) - g9.attrs["gac_file"] = np.string_(gac_file) - g9.attrs["software"] = np.string_("pyGAC") - g9.attrs["version"] = np.string_("1.0") + g9.attrs["gac_file"] = np.bytes_(gac_file) + g9.attrs["software"] = np.bytes_("pyGAC") + g9.attrs["version"] = np.bytes_("1.0") fout.close() @@ -598,19 +598,19 @@ def avhrrGAC_io(satellite_name, xutcs, startdate, enddate, starttime, endtime, dset1 = g1.create_dataset("data", dtype="int16", data=qual_flags) del dset1 - g1.attrs["product"] = np.string_("QFLAG") - g1.attrs["quantity"] = np.string_("INT") - g1.attrs["dataset_name"] = np.string_("Scanline quality flags") - g1.attrs["units"] = np.string_("None") + g1.attrs["product"] = np.bytes_("QFLAG") + g1.attrs["quantity"] = np.bytes_("INT") + g1.attrs["dataset_name"] = np.bytes_("Scanline quality flags") + g1.attrs["units"] = np.bytes_("None") g1.attrs["gain"] = np.int32(1) g1.attrs["offset"] = np.int32(0) g1.attrs["missingdata"] = np.int32(MISSING_DATA) g1.attrs["nodata"] = np.int32(MISSING_DATA) - g1.attrs["starttime"] = np.string_(starttime[0:6]) - g1.attrs["endtime"] = np.string_(endtime[0:6]) - g1.attrs["startdate"] = np.string_(startdate) - g1.attrs["enddate"] = np.string_(enddate) - g1.attrs["gac_file"] = np.string_(gac_file) + g1.attrs["starttime"] = np.bytes_(starttime[0:6]) + g1.attrs["endtime"] = np.bytes_(endtime[0:6]) + g1.attrs["startdate"] = np.bytes_(startdate) + g1.attrs["enddate"] = np.bytes_(enddate) + g1.attrs["gac_file"] = np.bytes_(gac_file) g1.attrs["total_number_of_data_records"] = total_number_of_scan_lines g1.attrs["last_scan_line_number"] = last_scan_line_number @@ -622,6 +622,6 @@ def avhrrGAC_io(satellite_name, xutcs, startdate, enddate, starttime, endtime, data=xutcs.astype("int64")) dset3.attrs["units"] = "Milliseconds since 1970-01-01 00:00:00 UTC" dset3.attrs["calendar"] = "standard" - g2.attrs["midnight_scanline"] = np.string_(midnight_scanline) + g2.attrs["midnight_scanline"] = np.bytes_(midnight_scanline) fout.close() diff --git a/pygac/tests/test_reader.py b/pygac/tests/test_reader.py index 0942552..68dbf11 100644 --- a/pygac/tests/test_reader.py +++ b/pygac/tests/test_reader.py @@ -358,13 +358,14 @@ def test_interpolate(self, _get_lonlat, _adjust_clock_drift, """Test interpolate method in get_lonlat.""" self.lons = None self.lats = None - lr_lons = 90 * np.random.rand(17, 51) - lr_lats = 90 * np.random.rand(17, 51) + rng = np.random.default_rng() + lr_lons = 90 * rng.random((17, 51)) + lr_lats = 90 * rng.random((17, 51)) _get_lonlat.return_value = lr_lons, lr_lats self.interpolate_coors = True self.interpolator.reset_mock() - self.interpolator.return_value = (90 * np.random.rand(17, 409), - 90 * np.random.rand(17, 409)) + self.interpolator.return_value = (90 * rng.random((17, 409)), + 90 * rng.random((17, 409))) lons, lats = self.reader.get_lonlat() self.assertEqual(lons.shape[1], 409) self.interpolator.assert_called_once_with(lr_lons, lr_lats) diff --git a/pygac/tests/test_tsm.py b/pygac/tests/test_tsm.py index 45d3fe8..25814d5 100644 --- a/pygac/tests/test_tsm.py +++ b/pygac/tests/test_tsm.py @@ -52,9 +52,9 @@ def test_get_tsm_idx(self): # Add rectangle with noise to channel 1 and 4 noise_cols, noise_rows = np.meshgrid(np.arange(200, 300), np.arange(1000, 2000)) + rng = np.random.default_rng() for ch in [ch1, ch4]: - ch[noise_rows, noise_cols] += 1000 + 1000*np.random.rand( - noise_rows.shape[0], noise_rows.shape[1]) + ch[noise_rows, noise_cols] += 1000 + 1000*rng.random(size=noise_rows.shape) # We expect the filter to also detect the edges of the noisy # rectangle: At the edges there is a transition from zero to diff --git a/pyproject.toml b/pyproject.toml index 28cbf74..8cab2a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,4 +67,4 @@ version-file = "pygac/version.py" line-length = 120 [tool.ruff.lint] -select = ["E", "W", "F", "I", "Q"] +select = ["E", "W", "F", "I", "Q", "NPY"]