diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2fcca72 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/dem-L-SAR/run_log/ diff --git a/Ortho-L-SAR/OrthoMain.py b/Ortho-L-SAR/OrthoMain.py index e991dd9..ec88429 100644 --- a/Ortho-L-SAR/OrthoMain.py +++ b/Ortho-L-SAR/OrthoMain.py @@ -12,6 +12,7 @@ import logging from tool.algorithm.block.blockprocess import BlockProcess from tool.algorithm.image.ImageHandle import ImageHandler +from tool.algorithm.xml.AnalysisXml import DictXml from tool.algorithm.xml.CreateMetaDict import CreateMetaDict, CreateProductXml from tool.algorithm.algtools.PreProcess import PreProcess as pp import tarfile @@ -523,11 +524,17 @@ class OrthoMain: pass - def cut_dem(self, dem_merged_path, meta_file_path): - left_up_lon = 0 - left_up_lat = 0 - + _, scopes = DictXml(meta_file_path).get_extend() + intersect_polygon = pp().intersect_polygon(scopes) + if intersect_polygon is None: + raise Exception('cal intersect box fail!') + shp_path = os.path.join(self.__workspace_Temporary_path, 'IntersectPolygon.shp') + if pp().write_polygon_shp(shp_path, intersect_polygon, 4326) is False: + raise Exception('create intersect shp fail!') + dem_process = os.path.join(self.__workspace_Temporary_path, 'dem_cut.tif') + pp().cut_img(dem_process, dem_merged_path, shp_path) + return dem_process def process_sim_ori(self, ori_sim, sim_ori): diff --git a/backScattering-L-SAR/BackScattering-L-SAR.xml b/backScattering-L-SAR/BackScattering-L-SAR.xml index ad8e829..fdf5e53 100644 --- a/backScattering-L-SAR/BackScattering-L-SAR.xml +++ b/backScattering-L-SAR/BackScattering-L-SAR.xml @@ -42,7 +42,7 @@ File tar.gz Cal - E:\MicroWorkspace\LT1B\LT230919\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966.tar.gz + F:\MicroWorkspace\LT1B\LT230919\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966.tar.gz True False File @@ -57,7 +57,7 @@ File tif Cal - E:\MicroWorkspace\LT1B\LT230919\DEM30m.tif + F:\MicroWorkspace\LT1B\LT230919\DEM30m.tif True True File @@ -74,7 +74,7 @@ File tar.gz Cal - D:\micro\LWork\BackScattering\Output\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-cal.tar.gz + D:\micro\LWork\BackScattering\Output\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-CAL.tar.gz DEFAULT DEFAULT DEFAULT diff --git a/backScattering-L-SAR/BackScatteringMain.py b/backScattering-L-SAR/BackScatteringMain.py index bb4adef..ba4bdff 100644 --- a/backScattering-L-SAR/BackScatteringMain.py +++ b/backScattering-L-SAR/BackScatteringMain.py @@ -11,6 +11,7 @@ import logging from tool.algorithm.algtools.logHandler import LogHandler from tool.algorithm.xml.AlgXmlHandle import ManageAlgXML, CheckSource +from tool.algorithm.xml.AnalysisXml import DictXml from tool.algorithm.xml.CreateMetaDict import CreateMetaDict, CreateProductXml from tool.algorithm.image.ImageHandle import ImageHandler from tool.algorithm.algtools.PreProcess import PreProcess as pp @@ -24,7 +25,6 @@ import shutil import tarfile import sys - if cf.get('debug') == 'True': DEBUG = True else: @@ -249,6 +249,18 @@ class ScatteringMain: if os.path.exists(path): self.del_floder(path) + def cut_dem(self, dem_merged_path, meta_file_path): + _, scopes = DictXml(meta_file_path).get_extend() + intersect_polygon = pp().intersect_polygon(scopes) + if intersect_polygon is None: + raise Exception('cal intersect box fail!') + shp_path = os.path.join(self.__workspace_preprocessing_path, 'IntersectPolygon.shp') + if pp().write_polygon_shp(shp_path, intersect_polygon, 4326) is False: + raise Exception('create intersect shp fail!') + dem_process = os.path.join(self.__workspace_preprocessing_path, 'dem_cut.tif') + pp().cut_img(dem_process, dem_merged_path, shp_path) + return dem_process + def process_sim_ori(self, ori_sim, sim_ori): scopes = () @@ -303,6 +315,7 @@ class ScatteringMain: out_dem_path = self.__workspace_preprocessing_path dem_merged_path=DEMProcess.dem_merged(in_dem_path, meta_file_path, out_dem_path) # 生成TestDEM\mergedDEM_VRT.tif + dem_path = self.cut_dem(dem_merged_path, meta_file_path) in_slc_path=None for slc_path in in_tif_paths: if slc_path.find(".tiff")>0 and (slc_path.find("_HH_")>0 or slc_path.find("_VV_")>0): @@ -310,7 +323,7 @@ class ScatteringMain: break # 获取校正模型后 - Orthorectification.preCaldem_sar_rc(dem_merged_path,in_slc_path,self.__workspace_preprocessing_path,self.__workspace_processing_path.replace("\\","\\\\")) # 初步筛选坐标范围 + Orthorectification.preCaldem_sar_rc(dem_path,in_slc_path,self.__workspace_preprocessing_path,self.__workspace_processing_path.replace("\\","\\\\")) # 初步筛选坐标范围 logger.info('progress bar: 40%') # clip_dem_reample_path=os.path.join(self.__workspace_preprocessing_path, "SAR_dem.tiff") # infooption=gdal.InfoOptions("-json") @@ -465,7 +478,7 @@ if __name__ == '__main__': start = datetime.datetime.now() try: if len(sys.argv)<2: - xml_path = 'BackScattering.xml' + xml_path = 'BackScattering-L-SAR.xml' else: xml_path = sys.argv[1] ScatteringMain = ScatteringMain(xml_path) diff --git a/backScattering-L-SAR/run_log/BackScattering2023-11-21-18-32-28.log b/backScattering-L-SAR/run_log/BackScattering2023-11-21-18-32-28.log deleted file mode 100644 index 7327b7c..0000000 --- a/backScattering-L-SAR/run_log/BackScattering2023-11-21-18-32-28.log +++ /dev/null @@ -1,19 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-L-SAR\backScattering -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:mylog:progress bar: 30% -ERROR:mylog:run-time error! -Traceback (most recent call last): - File "D:/estar-proj/microproduct-L-SAR/backScattering/BackScatteringMain.py", line 471, in - if not ScatteringMain.process_handle(start): - File "D:/estar-proj/microproduct-L-SAR/backScattering/BackScatteringMain.py", line 292, in process_handle - Orthorectification.IndirectOrthorectification(self.__in_processing_paras["SLC"], self.__workspace_processing_path) # 改动1 - File "D:\estar-proj\microproduct-L-SAR\backScattering\BackScatteringAlg.py", line 1520, in IndirectOrthorectification - self.header_info = self.ParseHearderFile(os.path.join(FilePath_str, header_name)) - File "D:\estar-proj\microproduct-L-SAR\backScattering\BackScatteringAlg.py", line 1094, in ParseHearderFile - GPSPoints = FindInfomationFromJson(HeaderFile_dom_json, GPSNode_Path) - File "D:\estar-proj\microproduct-L-SAR\backScattering\BackScatteringAlg.py", line 131, in FindInfomationFromJson - result_node = result_node[nodename] -KeyError: 'product' -INFO:mylog:running use time: 0:00:17.072831 diff --git a/backScattering-L-SAR/run_log/BackScattering2023-11-21-18-42-11.log b/backScattering-L-SAR/run_log/BackScattering2023-11-21-18-42-11.log deleted file mode 100644 index 1fda6d5..0000000 --- a/backScattering-L-SAR/run_log/BackScattering2023-11-21-18-42-11.log +++ /dev/null @@ -1,30 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-L-SAR\backScattering -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:mylog:progress bar: 30% -INFO:mylog:progress bar: 40% -WARNING:mylog:LTMetaData.get_QualifyValue() error! -ERROR:mylog:run-time error! -Traceback (most recent call last): - File "D:\estar-proj\microproduct-L-SAR\tool\algorithm\algtools\MetaDataHandler.py", line 85, in get_QualifyValue - QualifyValue = OrthoMetaData.get_QualifyValue(meta_file_path, polarization) - File "D:\estar-proj\microproduct-L-SAR\tool\algorithm\algtools\MetaDataHandler.py", line 47, in get_QualifyValue - QualifyValue = float(root.find('processing').find('processingParameter').find('quantifyValue').find(polarization).text) -AttributeError: 'NoneType' object has no attribute 'find' - -During handling of the above exception, another exception occurred: - -Traceback (most recent call last): - File "D:/estar-proj/microproduct-L-SAR/backScattering/BackScatteringMain.py", line 471, in - if not ScatteringMain.process_handle(start): - File "D:/estar-proj/microproduct-L-SAR/backScattering/BackScatteringMain.py", line 371, in process_handle - alg.sar_backscattering_coef(in_tif_path, meta_file_path, out_tif_path) - File "D:\estar-proj\microproduct-L-SAR\backScattering\BackScatteringAlg.py", line 93, in sar_backscattering_coef - QualifyValue = MetaDataHandler.get_QualifyValue(meta_file_path, polarization) - File "D:\estar-proj\microproduct-L-SAR\tool\algorithm\algtools\MetaDataHandler.py", line 88, in get_QualifyValue - QualifyValue = GF3L1AMetaData.get_QualifyValue(meta_file_path, polarization) - File "D:\estar-proj\microproduct-L-SAR\tool\algorithm\algtools\MetaDataHandler.py", line 27, in get_QualifyValue - QualifyValue = float(root.find('imageinfo').find('QualifyValue').find(polarization).text) -AttributeError: 'NoneType' object has no attribute 'find' -INFO:mylog:running use time: 0:00:26.594524 diff --git a/backScattering-L-SAR/run_log/BackScattering2023-11-21-18-44-18.log b/backScattering-L-SAR/run_log/BackScattering2023-11-21-18-44-18.log deleted file mode 100644 index 23b3d46..0000000 --- a/backScattering-L-SAR/run_log/BackScattering2023-11-21-18-44-18.log +++ /dev/null @@ -1,30 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-L-SAR\backScattering -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:mylog:progress bar: 30% -INFO:mylog:progress bar: 40% -WARNING:mylog:LTMetaData.get_QualifyValue() error! -ERROR:mylog:run-time error! -Traceback (most recent call last): - File "D:\estar-proj\microproduct-L-SAR\tool\algorithm\algtools\MetaDataHandler.py", line 85, in get_QualifyValue - QualifyValue = OrthoMetaData.get_QualifyValue(meta_file_path, polarization) - File "D:\estar-proj\microproduct-L-SAR\tool\algorithm\algtools\MetaDataHandler.py", line 47, in get_QualifyValue - QualifyValue = float(root.find('processing').find('processingParameter').find('quantifyValue').find(polarization).text) -AttributeError: 'NoneType' object has no attribute 'find' - -During handling of the above exception, another exception occurred: - -Traceback (most recent call last): - File "D:/estar-proj/microproduct-L-SAR/backScattering/BackScatteringMain.py", line 471, in - if not ScatteringMain.process_handle(start): - File "D:/estar-proj/microproduct-L-SAR/backScattering/BackScatteringMain.py", line 371, in process_handle - alg.sar_backscattering_coef(in_tif_path, meta_file_path, out_tif_path) - File "D:\estar-proj\microproduct-L-SAR\backScattering\BackScatteringAlg.py", line 93, in sar_backscattering_coef - QualifyValue = MetaDataHandler.get_QualifyValue(meta_file_path, polarization) - File "D:\estar-proj\microproduct-L-SAR\tool\algorithm\algtools\MetaDataHandler.py", line 88, in get_QualifyValue - QualifyValue = GF3L1AMetaData.get_QualifyValue(meta_file_path, polarization) - File "D:\estar-proj\microproduct-L-SAR\tool\algorithm\algtools\MetaDataHandler.py", line 27, in get_QualifyValue - QualifyValue = float(root.find('imageinfo').find('QualifyValue').find(polarization).text) -AttributeError: 'NoneType' object has no attribute 'find' -INFO:mylog:running use time: 0:08:05.774058 diff --git a/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-00-41.log b/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-00-41.log deleted file mode 100644 index 36a1087..0000000 --- a/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-00-41.log +++ /dev/null @@ -1,5 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-L-SAR\backScattering -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:mylog:progress bar: 30% diff --git a/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-03-11.log b/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-03-11.log deleted file mode 100644 index 1336962..0000000 --- a/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-03-11.log +++ /dev/null @@ -1,17 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-L-SAR\backScattering -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:mylog:progress bar: 30% -INFO:mylog:progress bar: 40% -INFO:mylog:progress bar: 90% -ERROR:mylog:run-time error! -Traceback (most recent call last): - File "D:/estar-proj/microproduct-L-SAR/backScattering/BackScatteringMain.py", line 471, in - if not ScatteringMain.process_handle(start): - File "D:/estar-proj/microproduct-L-SAR/backScattering/BackScatteringMain.py", line 437, in process_handle - para_dict = CreateMetaDict(image_path, self.__in_processing_paras['META'], self.__workspace_processing_path, - File "D:\estar-proj\microproduct-L-SAR\tool\algorithm\xml\CreateMetaDict.py", line 58, in calu_nature - imageinfo_widthspace = self.ImageHandler.get_geotransform(self.out_path1)[1] # 投影后的分辨率 -TypeError: 'NoneType' object is not subscriptable -INFO:mylog:running use time: 0:10:04.334320 diff --git a/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-27-00.log b/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-27-00.log deleted file mode 100644 index 1e18da4..0000000 --- a/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-27-00.log +++ /dev/null @@ -1,7 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-L-SAR\backScattering -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:mylog:progress bar: 30% -INFO:mylog:progress bar: 40% -INFO:mylog:progress bar: 90% diff --git a/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-40-46.log b/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-40-46.log deleted file mode 100644 index 1e18da4..0000000 --- a/backScattering-L-SAR/run_log/BackScattering2023-11-21-19-40-46.log +++ /dev/null @@ -1,7 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-L-SAR\backScattering -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:mylog:progress bar: 30% -INFO:mylog:progress bar: 40% -INFO:mylog:progress bar: 90% diff --git a/backScattering-L-SAR/run_log/BackScattering2023-11-22-11-12-38.log b/backScattering-L-SAR/run_log/BackScattering2023-11-22-11-12-38.log deleted file mode 100644 index 67404de..0000000 --- a/backScattering-L-SAR/run_log/BackScattering2023-11-22-11-12-38.log +++ /dev/null @@ -1,11 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-L-SAR\backScattering -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:mylog:progress bar: 30% -INFO:mylog:progress bar: 40% -INFO:mylog:progress bar: 90% -INFO:mylog:process_handle finished! -INFO:mylog:progress bar: 100% -INFO:mylog:successful production of backscattering products! -INFO:mylog:running use time: 0:12:32.600524 diff --git a/backScattering-L-SAR/run_log/BackScattering2023-11-22-16-29-13.log b/backScattering-L-SAR/run_log/BackScattering2023-11-22-16-29-13.log deleted file mode 100644 index 74fd804..0000000 --- a/backScattering-L-SAR/run_log/BackScattering2023-11-22-16-29-13.log +++ /dev/null @@ -1,11 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-L-SAR\backScattering -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:mylog:progress bar: 30% -INFO:mylog:progress bar: 40% -INFO:mylog:progress bar: 90% -INFO:mylog:process_handle finished! -INFO:mylog:progress bar: 100% -INFO:mylog:successful production of backscattering products! -INFO:mylog:running use time: 0:12:19.438164 diff --git a/landcover-L-SAR/LandCover-L-SAR.xml b/landcover-L-SAR/LandCover-L-SAR.xml index d918d69..27c590e 100644 --- a/landcover-L-SAR/LandCover-L-SAR.xml +++ b/landcover-L-SAR/LandCover-L-SAR.xml @@ -38,7 +38,7 @@ File tar.gz Man - E:\MicroWorkspace\LT1B\LT230919\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-ortho.tar.gz + F:\MicroWorkspace\LT1B\LT230919\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-ortho.tar.gz True False File @@ -53,7 +53,7 @@ File csv Man - E:\MicroWorkspace\LT1B\LT230919\LT1B_landaCoverSample.csv + F:\MicroWorkspace\LT1B\LT230919\LT1B_landaCoverSample.csv True True UploadInput diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-12-37-08.log b/landcover-L-SAR/run_log/LandCover2024-01-12-12-37-08.log deleted file mode 100644 index e52ddfc..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-12-37-08.log +++ /dev/null @@ -1,21 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-l-sar\landcover-L-SAR -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:root:scope0:[[130.58930555555554, 47.875416666666666], [131.11458333333331, 47.875416666666666], [130.58930555555554, 47.428472222222226], [131.11458333333331, 47.428472222222226]] -INFO:root:scope1:[[130.58930555555554, 47.875416666666666], [131.11458333333331, 47.875416666666666], [130.58930555555554, 47.428472222222226], [131.11458333333331, 47.428472222222226]] -INFO:root:scope roi :[(130.58930555555554, 47.428472222222226), (130.58930555555554, 47.875416666666666), (131.11458333333331, 47.875416666666666), (131.11458333333331, 47.428472222222226)] -INFO:mylog:cut sim_ori success! -INFO:mylog:preprocess_handle success! -INFO:mylog:1,water,num:2598827 -INFO:mylog:max number =10000, random select10000 point as train data! -INFO:mylog:2,build,num:260469 -INFO:mylog:max number =10000, random select10000 point as train data! -INFO:mylog:3,dryland,num:12290 -INFO:mylog:max number =10000, random select10000 point as train data! -INFO:mylog:4,road,num:803810 -INFO:mylog:max number =10000, random select10000 point as train data! -INFO:mylog:read csv data success! -INFO:mylog:progress bar: 20% -INFO:mylog:refine_lee filter success! -INFO:mylog:progress bar: 30% diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-00-19.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-00-19.log deleted file mode 100644 index 9e9fca9..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-00-19.log +++ /dev/null @@ -1,44 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-l-sar\landcover-L-SAR -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:root:scope0:[[130.58930555555554, 47.875416666666666], [131.11458333333331, 47.875416666666666], [130.58930555555554, 47.428472222222226], [131.11458333333331, 47.428472222222226]] -INFO:root:scope1:[[130.58930555555554, 47.875416666666666], [131.11458333333331, 47.875416666666666], [130.58930555555554, 47.428472222222226], [131.11458333333331, 47.428472222222226]] -INFO:root:scope roi :[(130.58930555555554, 47.428472222222226), (130.58930555555554, 47.875416666666666), (131.11458333333331, 47.875416666666666), (131.11458333333331, 47.428472222222226)] -INFO:mylog:cut sim_ori success! -INFO:mylog:preprocess_handle success! -INFO:mylog:1,water,num:2598827 -INFO:mylog:max number =10000, random select10000 point as train data! -INFO:mylog:2,build,num:260469 -INFO:mylog:max number =10000, random select10000 point as train data! -INFO:mylog:3,dryland,num:12290 -INFO:mylog:max number =10000, random select10000 point as train data! -INFO:mylog:4,road,num:803810 -INFO:mylog:max number =10000, random select10000 point as train data! -INFO:mylog:read csv data success! -INFO:mylog:progress bar: 20% -INFO:mylog:refine_lee filter success! -INFO:mylog:progress bar: 30% -INFO:root:feature_tif_paths:{'Freeman_Dbl': 'D:\\micro\\LWork\\LandCover\\Temporary\\processing\\feature_tif\\Freeman_Dbl.tif', 'Freeman_Odd': 'D:\\micro\\LWork\\LandCover\\Temporary\\processing\\feature_tif\\Freeman_Odd.tif', 'Freeman_Vol': 'D:\\micro\\LWork\\LandCover\\Temporary\\processing\\feature_tif\\Freeman_Vol.tif'} -INFO:mylog:decompose feature success! -INFO:mylog:progress bar: 50% -INFO:mylog:feature_list:['0: Freeman_Dbl_geo.tif', '1: Freeman_Odd_geo.tif', '2: Freeman_Vol_geo.tif'] -INFO:mylog:gene_train_set success! -INFO:mylog:importances:[0.0872527 0.40417686 0.50857044],threshold=0.07 -INFO:mylog:optimal_feature:[2, 1, 0] -INFO:mylog:correlation_map: - [[0. 1. 1.] - [0. 0. 1.] - [0. 0. 0.]] -INFO:mylog:validity_list_corr:[2] -INFO:mylog:[2] -INFO:mylog:train_feature:['2: Freeman_Vol_geo.tif'] -INFO:mylog:RF trainning -INFO:mylog:RF train successful -INFO:mylog:progress bar: 60% -INFO:mylog:test_feature:dict_keys(['Freeman_Vol_geo']) -INFO:mylog:blocking tifs success! -INFO:mylog:create features matrix success! -INFO:mylog:testing -INFO:mylog:test success! -INFO:mylog:progress bar: 95% diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-17.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-17.log deleted file mode 100644 index 2f72cbd..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-17.log +++ /dev/null @@ -1,30 +0,0 @@ -INFO:mylog:total:195,block:0 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_0_1024.tif -INFO:mylog:total:195,block:1 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_10240_11264.tif -INFO:mylog:total:195,block:9 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_4096_5120.tif -INFO:mylog:total:195,block:10 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_5120_6144.tif -INFO:mylog:total:195,block:19 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_12288_13312.tif -INFO:mylog:total:195,block:20 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_13312_14336.tif -INFO:mylog:total:195,block:29 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_9216_10240.tif -INFO:mylog:total:195,block:30 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_0_1024.tif -INFO:mylog:total:195,block:40 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_5120_6144.tif -INFO:mylog:total:195,block:41 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_6144_7168.tif -INFO:mylog:total:195,block:52 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_2048_3072.tif -INFO:mylog:total:195,block:53 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_3072_4096.tif -INFO:mylog:total:195,block:64 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_12288_13312.tif -INFO:mylog:total:195,block:65 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_13312_14336.tif -INFO:mylog:total:195,block:77 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_1024_2048.tif -INFO:mylog:total:195,block:78 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_11264_12288.tif -INFO:mylog:total:195,block:92 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_1024_2048.tif -INFO:mylog:total:195,block:93 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_11264_12288.tif -INFO:mylog:total:195,block:107 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_1024_2048.tif -INFO:mylog:total:195,block:108 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_11264_12288.tif -INFO:mylog:total:195,block:122 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_1024_2048.tif -INFO:mylog:total:195,block:123 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_11264_12288.tif -INFO:mylog:total:195,block:137 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_1024_2048.tif -INFO:mylog:total:195,block:138 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_11264_12288.tif -INFO:mylog:total:195,block:152 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_1024_2048.tif -INFO:mylog:total:195,block:153 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_11264_12288.tif -INFO:mylog:total:195,block:167 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_1024_2048.tif -INFO:mylog:total:195,block:168 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_11264_12288.tif -INFO:mylog:total:195,block:182 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_1024_2048.tif -INFO:mylog:total:195,block:183 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_11264_12288.tif diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-18.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-18.log deleted file mode 100644 index dbe6805..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-18.log +++ /dev/null @@ -1,15 +0,0 @@ -INFO:mylog:total:195,block:2 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_1024_2048.tif -INFO:mylog:total:195,block:11 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_6144_7168.tif -INFO:mylog:total:195,block:21 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_13931_14955.tif -INFO:mylog:total:195,block:31 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_10240_11264.tif -INFO:mylog:total:195,block:42 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_7168_8192.tif -INFO:mylog:total:195,block:54 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_4096_5120.tif -INFO:mylog:total:195,block:67 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_2048_3072.tif -INFO:mylog:total:195,block:80 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_13312_14336.tif -INFO:mylog:total:195,block:95 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_13312_14336.tif -INFO:mylog:total:195,block:110 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_13312_14336.tif -INFO:mylog:total:195,block:125 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_13312_14336.tif -INFO:mylog:total:195,block:140 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_13312_14336.tif -INFO:mylog:total:195,block:155 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_13312_14336.tif -INFO:mylog:total:195,block:170 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_13312_14336.tif -INFO:mylog:total:195,block:185 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_13312_14336.tif diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-19.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-19.log deleted file mode 100644 index a62309d..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-19.log +++ /dev/null @@ -1,30 +0,0 @@ -INFO:mylog:total:195,block:3 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_11264_12288.tif -INFO:mylog:total:195,block:4 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_12288_13312.tif -INFO:mylog:total:195,block:12 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_7168_8192.tif -INFO:mylog:total:195,block:13 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_8192_9216.tif -INFO:mylog:total:195,block:22 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_2048_3072.tif -INFO:mylog:total:195,block:23 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_3072_4096.tif -INFO:mylog:total:195,block:32 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_1024_2048.tif -INFO:mylog:total:195,block:33 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_11264_12288.tif -INFO:mylog:total:195,block:43 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_8192_9216.tif -INFO:mylog:total:195,block:44 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_9216_10240.tif -INFO:mylog:total:195,block:55 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_5120_6144.tif -INFO:mylog:total:195,block:56 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_6144_7168.tif -INFO:mylog:total:195,block:68 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_3072_4096.tif -INFO:mylog:total:195,block:69 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_4096_5120.tif -INFO:mylog:total:195,block:82 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_2048_3072.tif -INFO:mylog:total:195,block:83 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_3072_4096.tif -INFO:mylog:total:195,block:97 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_2048_3072.tif -INFO:mylog:total:195,block:98 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_3072_4096.tif -INFO:mylog:total:195,block:112 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_2048_3072.tif -INFO:mylog:total:195,block:113 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_3072_4096.tif -INFO:mylog:total:195,block:127 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_2048_3072.tif -INFO:mylog:total:195,block:128 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_3072_4096.tif -INFO:mylog:total:195,block:142 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_2048_3072.tif -INFO:mylog:total:195,block:143 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_3072_4096.tif -INFO:mylog:total:195,block:157 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_2048_3072.tif -INFO:mylog:total:195,block:158 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_3072_4096.tif -INFO:mylog:total:195,block:172 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_2048_3072.tif -INFO:mylog:total:195,block:173 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_3072_4096.tif -INFO:mylog:total:195,block:187 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_2048_3072.tif -INFO:mylog:total:195,block:188 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_3072_4096.tif diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-21.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-21.log deleted file mode 100644 index 8bfa6a2..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-21.log +++ /dev/null @@ -1,30 +0,0 @@ -INFO:mylog:total:195,block:5 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_13312_14336.tif -INFO:mylog:total:195,block:6 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_13931_14955.tif -INFO:mylog:total:195,block:14 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_9216_10240.tif -INFO:mylog:total:195,block:15 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_0_1024.tif -INFO:mylog:total:195,block:24 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_4096_5120.tif -INFO:mylog:total:195,block:25 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_5120_6144.tif -INFO:mylog:total:195,block:35 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_13312_14336.tif -INFO:mylog:total:195,block:36 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_13931_14955.tif -INFO:mylog:total:195,block:46 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_10240_11264.tif -INFO:mylog:total:195,block:47 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_1024_2048.tif -INFO:mylog:total:195,block:58 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_8192_9216.tif -INFO:mylog:total:195,block:59 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_9216_10240.tif -INFO:mylog:total:195,block:71 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_6144_7168.tif -INFO:mylog:total:195,block:72 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_7168_8192.tif -INFO:mylog:total:195,block:85 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_5120_6144.tif -INFO:mylog:total:195,block:86 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_6144_7168.tif -INFO:mylog:total:195,block:100 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_5120_6144.tif -INFO:mylog:total:195,block:101 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_6144_7168.tif -INFO:mylog:total:195,block:115 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_5120_6144.tif -INFO:mylog:total:195,block:116 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_6144_7168.tif -INFO:mylog:total:195,block:130 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_5120_6144.tif -INFO:mylog:total:195,block:131 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_6144_7168.tif -INFO:mylog:total:195,block:145 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_5120_6144.tif -INFO:mylog:total:195,block:146 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_6144_7168.tif -INFO:mylog:total:195,block:160 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_5120_6144.tif -INFO:mylog:total:195,block:161 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_6144_7168.tif -INFO:mylog:total:195,block:175 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_5120_6144.tif -INFO:mylog:total:195,block:176 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_6144_7168.tif -INFO:mylog:total:195,block:190 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_5120_6144.tif -INFO:mylog:total:195,block:191 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_6144_7168.tif diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-22.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-22.log deleted file mode 100644 index 9236693..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-22.log +++ /dev/null @@ -1,15 +0,0 @@ -INFO:mylog:total:195,block:7 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_2048_3072.tif -INFO:mylog:total:195,block:16 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_10240_11264.tif -INFO:mylog:total:195,block:26 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_6144_7168.tif -INFO:mylog:total:195,block:37 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_2048_3072.tif -INFO:mylog:total:195,block:49 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_12288_13312.tif -INFO:mylog:total:195,block:61 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_10240_11264.tif -INFO:mylog:total:195,block:74 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_9216_10240.tif -INFO:mylog:total:195,block:88 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_8192_9216.tif -INFO:mylog:total:195,block:103 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_8192_9216.tif -INFO:mylog:total:195,block:118 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_8192_9216.tif -INFO:mylog:total:195,block:133 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_8192_9216.tif -INFO:mylog:total:195,block:148 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_8192_9216.tif -INFO:mylog:total:195,block:163 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_8192_9216.tif -INFO:mylog:total:195,block:178 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_8192_9216.tif -INFO:mylog:total:195,block:193 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_8192_9216.tif diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-23.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-23.log deleted file mode 100644 index 765725c..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-23.log +++ /dev/null @@ -1,14 +0,0 @@ -INFO:mylog:total:195,block:8 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_0_1024_3072_4096.tif -INFO:mylog:total:195,block:18 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_11264_12288.tif -INFO:mylog:total:195,block:28 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_8192_9216.tif -INFO:mylog:total:195,block:39 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_4096_5120.tif -INFO:mylog:total:195,block:51 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_13931_14955.tif -INFO:mylog:total:195,block:63 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_11264_12288.tif -INFO:mylog:total:195,block:76 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_10240_11264.tif -INFO:mylog:total:195,block:91 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_10240_11264.tif -INFO:mylog:total:195,block:106 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_10240_11264.tif -INFO:mylog:total:195,block:121 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_10240_11264.tif -INFO:mylog:total:195,block:136 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_10240_11264.tif -INFO:mylog:total:195,block:151 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_10240_11264.tif -INFO:mylog:total:195,block:166 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_10240_11264.tif -INFO:mylog:total:195,block:181 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_10240_11264.tif diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-25.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-25.log deleted file mode 100644 index eaf286a..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-25.log +++ /dev/null @@ -1,14 +0,0 @@ -INFO:mylog:total:195,block:17 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_1024_2048.tif -INFO:mylog:total:195,block:27 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_10240_11264_7168_8192.tif -INFO:mylog:total:195,block:38 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_3072_4096.tif -INFO:mylog:total:195,block:50 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_13312_14336.tif -INFO:mylog:total:195,block:62 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_1024_2048.tif -INFO:mylog:total:195,block:75 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_0_1024.tif -INFO:mylog:total:195,block:89 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_9216_10240.tif -INFO:mylog:total:195,block:104 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_9216_10240.tif -INFO:mylog:total:195,block:119 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_9216_10240.tif -INFO:mylog:total:195,block:134 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_9216_10240.tif -INFO:mylog:total:195,block:149 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_9216_10240.tif -INFO:mylog:total:195,block:164 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_9216_10240.tif -INFO:mylog:total:195,block:179 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_9216_10240.tif -INFO:mylog:total:195,block:194 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_9216_10240.tif diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-26.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-26.log deleted file mode 100644 index 35b4f61..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-26.log +++ /dev/null @@ -1,23 +0,0 @@ -INFO:mylog:total:195,block:34 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_1024_2048_12288_13312.tif -INFO:mylog:total:195,block:45 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_0_1024.tif -INFO:mylog:total:195,block:48 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_11264_12288.tif -INFO:mylog:total:195,block:57 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11264_12288_7168_8192.tif -INFO:mylog:total:195,block:60 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_0_1024.tif -INFO:mylog:total:195,block:70 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_5120_6144.tif -INFO:mylog:total:195,block:73 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_8192_9216.tif -INFO:mylog:total:195,block:84 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_4096_5120.tif -INFO:mylog:total:195,block:87 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_7168_8192.tif -INFO:mylog:total:195,block:99 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_4096_5120.tif -INFO:mylog:total:195,block:102 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_7168_8192.tif -INFO:mylog:total:195,block:114 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_4096_5120.tif -INFO:mylog:total:195,block:117 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_7168_8192.tif -INFO:mylog:total:195,block:129 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_4096_5120.tif -INFO:mylog:total:195,block:132 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_7168_8192.tif -INFO:mylog:total:195,block:144 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_4096_5120.tif -INFO:mylog:total:195,block:147 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_7168_8192.tif -INFO:mylog:total:195,block:159 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_4096_5120.tif -INFO:mylog:total:195,block:162 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_7168_8192.tif -INFO:mylog:total:195,block:174 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_4096_5120.tif -INFO:mylog:total:195,block:177 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_7168_8192.tif -INFO:mylog:total:195,block:189 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_4096_5120.tif -INFO:mylog:total:195,block:192 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_7168_8192.tif diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-27.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-27.log deleted file mode 100644 index b7eb1e1..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-27.log +++ /dev/null @@ -1,9 +0,0 @@ -INFO:mylog:total:195,block:66 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_11701_12725_13931_14955.tif -INFO:mylog:total:195,block:79 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_12288_13312.tif -INFO:mylog:total:195,block:94 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_12288_13312.tif -INFO:mylog:total:195,block:109 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_12288_13312.tif -INFO:mylog:total:195,block:124 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_12288_13312.tif -INFO:mylog:total:195,block:139 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_12288_13312.tif -INFO:mylog:total:195,block:154 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_12288_13312.tif -INFO:mylog:total:195,block:169 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_12288_13312.tif -INFO:mylog:total:195,block:184 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_12288_13312.tif diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-28.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-28.log deleted file mode 100644 index 7f44211..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-28.log +++ /dev/null @@ -1,8 +0,0 @@ -INFO:mylog:total:195,block:81 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_2048_3072_13931_14955.tif -INFO:mylog:total:195,block:96 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_13931_14955.tif -INFO:mylog:total:195,block:111 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_13931_14955.tif -INFO:mylog:total:195,block:126 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_13931_14955.tif -INFO:mylog:total:195,block:141 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_13931_14955.tif -INFO:mylog:total:195,block:156 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_13931_14955.tif -INFO:mylog:total:195,block:171 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_13931_14955.tif -INFO:mylog:total:195,block:186 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_13931_14955.tif diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-29.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-29.log deleted file mode 100644 index e144039..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-15-29.log +++ /dev/null @@ -1,7 +0,0 @@ -INFO:mylog:total:195,block:90 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_3072_4096_0_1024.tif -INFO:mylog:total:195,block:105 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_4096_5120_0_1024.tif -INFO:mylog:total:195,block:120 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_5120_6144_0_1024.tif -INFO:mylog:total:195,block:135 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_6144_7168_0_1024.tif -INFO:mylog:total:195,block:150 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_7168_8192_0_1024.tif -INFO:mylog:total:195,block:165 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_8192_9216_0_1024.tif -INFO:mylog:total:195,block:180 testing data !path:D:\micro\LWork\LandCover\Temporary\processing\LandCover\LandCover_9216_10240_0_1024.tif diff --git a/landcover-L-SAR/run_log/LandCover2024-01-12-13-18-30.log b/landcover-L-SAR/run_log/LandCover2024-01-12-13-18-30.log deleted file mode 100644 index 8dda3b0..0000000 --- a/landcover-L-SAR/run_log/LandCover2024-01-12-13-18-30.log +++ /dev/null @@ -1,3 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-l-sar\landcover-L-SAR -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! diff --git a/landcover-L-SAR/tool/LAI/LAIProcess.cp38-win_amd64.pyd b/landcover-L-SAR/tool/LAI/LAIProcess.cp38-win_amd64.pyd deleted file mode 100644 index bc5375e..0000000 Binary files a/landcover-L-SAR/tool/LAI/LAIProcess.cp38-win_amd64.pyd and /dev/null differ diff --git a/landcover-L-SAR/tool/LAI/LAIProcess.pyx b/landcover-L-SAR/tool/LAI/LAIProcess.pyx deleted file mode 100644 index a445ffd..0000000 --- a/landcover-L-SAR/tool/LAI/LAIProcess.pyx +++ /dev/null @@ -1,166 +0,0 @@ -# -# 模型计算的库 -# -import cython -cimport cython # 必须导入 -import numpy as np -cimport numpy as np -from libc.math cimport pi -from scipy.optimize import leastsq -import random -import logging -logger = logging.getLogger("mylog") - - -def WMCModel(param_arr,sample_lai,sample_soil,sample_inc,sample_sigma): - """ WMC模型 增加 归一化植被指数 - - Args: - param_arr (np.ndarray): 参数数组 - sample_lai (double): 叶面积指数 - sample_soil (double): 土壤含水量 - sample_inc (double): 入射角(弧度值) - sample_sigma (double): 后向散射系数(线性值) - - Returns: - double: 方程值 - """ - # 映射参数,方便修改模型 - A,B,C,D,M,N=param_arr # 在这里修改模型 - V_lai=sample_lai - #V_lai=E*sample_lai+F - exp_gamma=np.exp(-2*B*((V_lai*D+C))*(1/np.cos(sample_inc))) - sigma_soil=M*sample_soil+N - sigma_veg=A*((V_lai))*np.cos(sample_inc) - f_veg=1 - result=sigma_veg*(1-exp_gamma)+sigma_soil*exp_gamma-sample_sigma - return result - - - - -def train_WMCmodel(lai_water_inc_sigma_list,params_X0,train_err_image_path,draw_flag=True): - """ 训练模型参数 - - Args: - lai_waiter_inc_sigma_list (list): 训练模型使用的样本呢 - """ - def f(X): - eqs=[] - for lai_water_inc_sigma_item in lai_water_inc_sigma_list: - sample_lai=lai_water_inc_sigma_item[4] - sample_sigma=lai_water_inc_sigma_item[5] # 5: csv_sigma, 8:tiff_sigma - sample_soil=lai_water_inc_sigma_item[6] - sample_inc=lai_water_inc_sigma_item[7] - FVC=lai_water_inc_sigma_item[8] - eqs.append(WMCModel(X,sample_lai,sample_soil,sample_inc,sample_sigma)) - return eqs - - X0 = params_X0 # 初始值 - # logger.info(str(X0)) - h = leastsq(f, X0) - # logger.info(h[0],h[1]) - err_f=f(h[0]) - x_arr=[lai_waiter_inc_sigma_item[4] for lai_waiter_inc_sigma_item in lai_water_inc_sigma_list] - # 根据误差大小进行排序 - # logger.info("训练集:\n根据误差输出点序\n数量:{}\n点序\t误差值\t 样点信息".format(str(np.array(err_f).shape))) - # for i in np.argsort(np.array(err_f)): - # logger.info('{}\t{}\t{}'.format(i,err_f[i],str(lai_water_inc_sigma_list[i]))) - # logger.info("\n误差点序输出结束\n") - - if draw_flag: - # logger.info(err_f) - # logger.info(np.where(np.abs(err_f)<10)) - from matplotlib import pyplot as plt - plt.scatter(x_arr,err_f) - plt.title("equation-err") - plt.savefig(train_err_image_path,dpi=600) - plt.show() - - return h[0] - -def test_WMCModel(lai_waiter_inc_sigma_list,param_arr,lai_X0,test_err_image_path,draw_flag=True): - """ 测试模型训练结果 - - Args: - lai_waiter_inc_sigma_list (list): 测试使用的样本集 - A (_type_): 参数A - B (_type_): 参数B - C (_type_): 参数C - D (_type_): 参数D - M (_type_): 参数M - N (_type_): 参数N - lai_X0 (_type_): 初始值 - - Returns: - list: 误差列表 [sample_lai,err,predict] - """ - err=[] - err_f=[] - x_arr=[] - err_lai=[] - for lai_waiter_inc_sigma_item in lai_waiter_inc_sigma_list: - sample_time,sample_code,sample_lon,sample_lat,sample_lai,csv_sigma,sample_soil,sample_inc,sample_sigma=lai_waiter_inc_sigma_item - def f(X): - lai=X[0] - eqs=[WMCModel(param_arr,lai,sample_soil,sample_inc,csv_sigma)] - return eqs - X0=lai_X0 - h = leastsq(f, X0) - temp_err=h[0]-sample_lai - err_lai.append(temp_err[0]) # lai预测的插值 - err.append([sample_lai,temp_err[0],h[0][0],sample_code]) - err_f.append(f(h[0])[0]) # 方程差 - x_arr.append(sample_lai) - - # 根据误差大小进行排序 - # logger.info("测试集:\n根据误差输出点序\n数量:{}\n点序\t误差值\t 方程差\t样点信息".format(str(np.array(err_lai).shape))) - # for i in np.argsort(np.array(err_lai)): - # logger.info('{}\t{}\t{}\t{}'.format(i,err_lai[i],err_f[i],str(lai_waiter_inc_sigma_list[i]))) - # logger.info("\n误差点序输出结束\n") - - if draw_flag: - from matplotlib import pyplot as plt - plt.scatter(x_arr,err_lai) - plt.title("equation-err") - plt.savefig(test_err_image_path,dpi=600) - plt.show() - return err - -def processs_WMCModel(param_arr,lai_X0,sigma,inc_angle,soil_water): - - if(sigma<0 ): - return np.nan - def f(X): - lai=X[0] - eqs=[WMCModel(param_arr,lai,soil_water,inc_angle,sigma )] - return eqs - h = leastsq(f, [lai_X0]) - - return h[0][0] - -# Cython 的扩展地址 -cpdef np.ndarray[double,ndim=2] process_tiff(np.ndarray[double,ndim=2] sigma_tiff, - np.ndarray[double,ndim=2] inc_tiff, - np.ndarray[double,ndim=2] soil_water_tiff, - np.ndarray[double,ndim=1] param_arr, - double lai_X0): - - cdef np.ndarray[double,ndim=2] result=sigma_tiff - cdef int param_arr_length=param_arr.shape[0] - cdef int height=sigma_tiff.shape[0] - cdef int width=sigma_tiff.shape[1] - cdef int i=0 - cdef int j=0 - cdef double temp=0 - - while i=0 else np.nan - result[i,j]=temp - j=j+1 - i=i+1 - return result - \ No newline at end of file diff --git a/landcover-L-SAR/tool/LAI/build/LAIProcess.c b/landcover-L-SAR/tool/LAI/build/LAIProcess.c deleted file mode 100644 index eb1f143..0000000 --- a/landcover-L-SAR/tool/LAI/build/LAIProcess.c +++ /dev/null @@ -1,11637 +0,0 @@ -/* Generated by Cython 0.29.24 */ - -/* BEGIN: Cython Metadata -{ - "distutils": { - "depends": [], - "name": "LAIProcess", - "sources": [ - "./LAIProcess.pyx" - ] - }, - "module_name": "LAIProcess" -} -END: Cython Metadata */ - -#ifndef PY_SSIZE_T_CLEAN -#define PY_SSIZE_T_CLEAN -#endif /* PY_SSIZE_T_CLEAN */ -#include "Python.h" -#ifndef Py_PYTHON_H - #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) - #error Cython requires Python 2.6+ or Python 3.3+. -#else -#define CYTHON_ABI "0_29_24" -#define CYTHON_HEX_VERSION 0x001D18F0 -#define CYTHON_FUTURE_DIVISION 0 -#include -#ifndef offsetof - #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !defined(WIN32) && !defined(MS_WINDOWS) - #ifndef __stdcall - #define __stdcall - #endif - #ifndef __cdecl - #define __cdecl - #endif - #ifndef __fastcall - #define __fastcall - #endif -#endif -#ifndef DL_IMPORT - #define DL_IMPORT(t) t -#endif -#ifndef DL_EXPORT - #define DL_EXPORT(t) t -#endif -#define __PYX_COMMA , -#ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x02070000 - #define HAVE_LONG_LONG - #endif -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION - #define CYTHON_COMPILING_IN_PYPY 1 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #undef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #if PY_VERSION_HEX < 0x03050000 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #undef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #undef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 1 - #undef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 0 - #undef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 0 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 - #undef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS 0 - #undef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK 0 -#elif defined(PYSTON_VERSION) - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 1 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 - #undef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS 0 - #undef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK 0 -#else - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 1 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) - #define CYTHON_USE_PYTYPE_LOOKUP 1 - #endif - #if PY_MAJOR_VERSION < 3 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #elif !defined(CYTHON_USE_PYLONG_INTERNALS) - #define CYTHON_USE_PYLONG_INTERNALS 1 - #endif - #ifndef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 1 - #endif - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #if PY_VERSION_HEX < 0x030300F0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #elif !defined(CYTHON_USE_UNICODE_WRITER) - #define CYTHON_USE_UNICODE_WRITER 1 - #endif - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #ifndef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 1 - #endif - #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 1 - #endif - #ifndef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) - #endif - #ifndef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) - #endif - #ifndef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) - #endif - #ifndef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) - #endif -#endif -#if !defined(CYTHON_FAST_PYCCALL) -#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) -#endif -#if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #undef SHIFT - #undef BASE - #undef MASK - #ifdef SIZEOF_VOID_P - enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; - #endif -#endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif -#ifndef __has_cpp_attribute - #define __has_cpp_attribute(x) 0 -#endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif -#endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) -#ifdef _MSC_VER - #ifndef _MSC_STDINT_H_ - #if _MSC_VER < 1300 - typedef unsigned char uint8_t; - typedef unsigned int uint32_t; - #else - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - #endif - #endif -#else - #include -#endif -#ifndef CYTHON_FALLTHROUGH - #if defined(__cplusplus) && __cplusplus >= 201103L - #if __has_cpp_attribute(fallthrough) - #define CYTHON_FALLTHROUGH [[fallthrough]] - #elif __has_cpp_attribute(clang::fallthrough) - #define CYTHON_FALLTHROUGH [[clang::fallthrough]] - #elif __has_cpp_attribute(gnu::fallthrough) - #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] - #endif - #endif - #ifndef CYTHON_FALLTHROUGH - #if __has_attribute(fallthrough) - #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) - #else - #define CYTHON_FALLTHROUGH - #endif - #endif - #if defined(__clang__ ) && defined(__apple_build_version__) - #if __apple_build_version__ < 7000000 - #undef CYTHON_FALLTHROUGH - #define CYTHON_FALLTHROUGH - #endif - #endif -#endif - -#ifndef CYTHON_INLINE - #if defined(__clang__) - #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) - #elif defined(__GNUC__) - #define CYTHON_INLINE __inline__ - #elif defined(_MSC_VER) - #define CYTHON_INLINE __inline - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_INLINE inline - #else - #define CYTHON_INLINE - #endif -#endif - -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) - #define Py_OptimizeFlag 0 -#endif -#define __PYX_BUILD_PY_SSIZE_T "n" -#define CYTHON_FORMAT_SSIZE_T "z" -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" -#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2 - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#else - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#endif - #define __Pyx_DefaultClassType PyType_Type -#endif -#ifndef Py_TPFLAGS_CHECKTYPES - #define Py_TPFLAGS_CHECKTYPES 0 -#endif -#ifndef Py_TPFLAGS_HAVE_INDEX - #define Py_TPFLAGS_HAVE_INDEX 0 -#endif -#ifndef Py_TPFLAGS_HAVE_NEWBUFFER - #define Py_TPFLAGS_HAVE_NEWBUFFER 0 -#endif -#ifndef Py_TPFLAGS_HAVE_FINALIZE - #define Py_TPFLAGS_HAVE_FINALIZE 0 -#endif -#ifndef METH_STACKLESS - #define METH_STACKLESS 0 -#endif -#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) - #ifndef METH_FASTCALL - #define METH_FASTCALL 0x80 - #endif - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); - typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, - Py_ssize_t nargs, PyObject *kwnames); -#else - #define __Pyx_PyCFunctionFast _PyCFunctionFast - #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords -#endif -#if CYTHON_FAST_PYCCALL -#define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) -#else -#define __Pyx_PyFastCFunction_Check(func) 0 -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) - #define PyObject_Malloc(s) PyMem_Malloc(s) - #define PyObject_Free(p) PyMem_Free(p) - #define PyObject_Realloc(p) PyMem_Realloc(p) -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 - #define PyMem_RawMalloc(n) PyMem_Malloc(n) - #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) - #define PyMem_RawFree(p) PyMem_Free(p) -#endif -#if CYTHON_COMPILING_IN_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) -#else - #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) -#endif -#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#elif PY_VERSION_HEX >= 0x03060000 - #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() -#elif PY_VERSION_HEX >= 0x03000000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#else - #define __Pyx_PyThreadState_Current _PyThreadState_Current -#endif -#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) -#include "pythread.h" -#define Py_tss_NEEDS_INIT 0 -typedef int Py_tss_t; -static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { - *key = PyThread_create_key(); - return 0; -} -static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { - Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); - *key = Py_tss_NEEDS_INIT; - return key; -} -static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { - PyObject_Free(key); -} -static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { - return *key != Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { - PyThread_delete_key(*key); - *key = Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { - return PyThread_set_key_value(*key, value); -} -static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { - return PyThread_get_key_value(*key); -} -#endif -#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) -#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) -#else -#define __Pyx_PyDict_NewPresized(n) PyDict_New() -#endif -#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS -#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) -#else -#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #if defined(PyUnicode_IS_READY) - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #else - #define __Pyx_PyUnicode_READY(op) (0) - #endif - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) - #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) - #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) - #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) - #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE) - #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) - #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) - #endif - #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) - #endif -#else - #define CYTHON_PEP393_ENABLED 0 - #define PyUnicode_1BYTE_KIND 1 - #define PyUnicode_2BYTE_KIND 2 - #define PyUnicode_4BYTE_KIND 4 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) -#endif -#if CYTHON_COMPILING_IN_PYPY - #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) -#else - #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ - PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) - #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) - #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) - #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) -#endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) - #define PyObject_ASCII(o) PyObject_Repr(o) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#ifndef PyObject_Unicode - #define PyObject_Unicode PyObject_Str -#endif -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#if PY_VERSION_HEX >= 0x030900A4 - #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) - #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) -#else - #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) - #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) -#endif -#if CYTHON_ASSUME_SAFE_MACROS - #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) -#else - #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) -#endif -#if CYTHON_USE_ASYNC_SLOTS - #if PY_VERSION_HEX >= 0x030500B1 - #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods - #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) - #else - #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef __Pyx_PyAsyncMethodsStruct - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; -#endif - -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES -#endif -#include -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) -#define __Pyx_truncl trunc -#else -#define __Pyx_truncl truncl -#endif - -#define __PYX_MARK_ERR_POS(f_index, lineno) \ - { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } -#define __PYX_ERR(f_index, lineno, Ln_error) \ - { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#define __PYX_HAVE__LAIProcess -#define __PYX_HAVE_API__LAIProcess -/* Early includes */ -#include -#include -#include "numpy/arrayobject.h" -#include "numpy/ndarrayobject.h" -#include "numpy/ndarraytypes.h" -#include "numpy/arrayscalars.h" -#include "numpy/ufuncobject.h" - - /* NumPy API declarations from "numpy/__init__.pxd" */ - -#include -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) -#define __PYX_DEFAULT_STRING_ENCODING "" -#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString -#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#define __Pyx_uchar_cast(c) ((unsigned char)c) -#define __Pyx_long_cast(x) ((long)x) -#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ - (sizeof(type) < sizeof(Py_ssize_t)) ||\ - (sizeof(type) > sizeof(Py_ssize_t) &&\ - likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX) &&\ - (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ - v == (type)PY_SSIZE_T_MIN))) ||\ - (sizeof(type) == sizeof(Py_ssize_t) &&\ - (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX))) ) -static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { - return (size_t) i < (size_t) limit; -} -#if defined (__cplusplus) && __cplusplus >= 201103L - #include - #define __Pyx_sst_abs(value) std::abs(value) -#elif SIZEOF_INT >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) abs(value) -#elif SIZEOF_LONG >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) labs(value) -#elif defined (_MSC_VER) - #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) -#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define __Pyx_sst_abs(value) llabs(value) -#elif defined (__GNUC__) - #define __Pyx_sst_abs(value) __builtin_llabs(value) -#else - #define __Pyx_sst_abs(value) ((value<0) ? -value : value) -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) -#define __Pyx_PyBytes_FromString PyBytes_FromString -#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) -#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) -#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) -#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) -#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); -#define __Pyx_PySequence_Tuple(obj)\ - (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -#if CYTHON_ASSUME_SAFE_MACROS -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) -#else -#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) -#endif -#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#endif - - -/* Test for GCC > 2.95 */ -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) -#else /* !__GNUC__ or GCC < 2.95 */ - #define likely(x) (x) - #define unlikely(x) (x) -#endif /* __GNUC__ */ -static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } - -static PyObject *__pyx_m = NULL; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime = NULL; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static PyObject *__pyx_empty_unicode; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - -/* Header.proto */ -#if !defined(CYTHON_CCOMPLEX) - #if defined(__cplusplus) - #define CYTHON_CCOMPLEX 1 - #elif defined(_Complex_I) - #define CYTHON_CCOMPLEX 1 - #else - #define CYTHON_CCOMPLEX 0 - #endif -#endif -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #include - #else - #include - #endif -#endif -#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) - #undef _Complex_I - #define _Complex_I 1.0fj -#endif - - -static const char *__pyx_f[] = { - "LAIProcess.pyx", - "__init__.pxd", - "type.pxd", -}; -/* BufferFormatStructs.proto */ -#define IS_UNSIGNED(type) (((type) -1) > 0) -struct __Pyx_StructField_; -#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) -typedef struct { - const char* name; - struct __Pyx_StructField_* fields; - size_t size; - size_t arraysize[8]; - int ndim; - char typegroup; - char is_unsigned; - int flags; -} __Pyx_TypeInfo; -typedef struct __Pyx_StructField_ { - __Pyx_TypeInfo* type; - const char* name; - size_t offset; -} __Pyx_StructField; -typedef struct { - __Pyx_StructField* field; - size_t parent_offset; -} __Pyx_BufFmt_StackElem; -typedef struct { - __Pyx_StructField root; - __Pyx_BufFmt_StackElem* head; - size_t fmt_offset; - size_t new_count, enc_count; - size_t struct_alignment; - int is_complex; - char enc_type; - char new_packmode; - char enc_packmode; - char is_valid_array; -} __Pyx_BufFmt_Context; - - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":690 - * # in Cython to enable them only on the right systems. - * - * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - */ -typedef npy_int8 __pyx_t_5numpy_int8_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":691 - * - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t - */ -typedef npy_int16 __pyx_t_5numpy_int16_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":692 - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< - * ctypedef npy_int64 int64_t - * #ctypedef npy_int96 int96_t - */ -typedef npy_int32 __pyx_t_5numpy_int32_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":693 - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< - * #ctypedef npy_int96 int96_t - * #ctypedef npy_int128 int128_t - */ -typedef npy_int64 __pyx_t_5numpy_int64_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":697 - * #ctypedef npy_int128 int128_t - * - * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - */ -typedef npy_uint8 __pyx_t_5numpy_uint8_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":698 - * - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t - */ -typedef npy_uint16 __pyx_t_5numpy_uint16_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":699 - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< - * ctypedef npy_uint64 uint64_t - * #ctypedef npy_uint96 uint96_t - */ -typedef npy_uint32 __pyx_t_5numpy_uint32_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":700 - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< - * #ctypedef npy_uint96 uint96_t - * #ctypedef npy_uint128 uint128_t - */ -typedef npy_uint64 __pyx_t_5numpy_uint64_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":704 - * #ctypedef npy_uint128 uint128_t - * - * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< - * ctypedef npy_float64 float64_t - * #ctypedef npy_float80 float80_t - */ -typedef npy_float32 __pyx_t_5numpy_float32_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":705 - * - * ctypedef npy_float32 float32_t - * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< - * #ctypedef npy_float80 float80_t - * #ctypedef npy_float128 float128_t - */ -typedef npy_float64 __pyx_t_5numpy_float64_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":714 - * # The int types are mapped a bit surprising -- - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t - */ -typedef npy_long __pyx_t_5numpy_int_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":715 - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong longlong_t - * - */ -typedef npy_longlong __pyx_t_5numpy_long_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":716 - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_ulong uint_t - */ -typedef npy_longlong __pyx_t_5numpy_longlong_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":718 - * ctypedef npy_longlong longlong_t - * - * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t - */ -typedef npy_ulong __pyx_t_5numpy_uint_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":719 - * - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulonglong_t - * - */ -typedef npy_ulonglong __pyx_t_5numpy_ulong_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":720 - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_intp intp_t - */ -typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":722 - * ctypedef npy_ulonglong ulonglong_t - * - * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< - * ctypedef npy_uintp uintp_t - * - */ -typedef npy_intp __pyx_t_5numpy_intp_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":723 - * - * ctypedef npy_intp intp_t - * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< - * - * ctypedef npy_double float_t - */ -typedef npy_uintp __pyx_t_5numpy_uintp_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":725 - * ctypedef npy_uintp uintp_t - * - * ctypedef npy_double float_t # <<<<<<<<<<<<<< - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t - */ -typedef npy_double __pyx_t_5numpy_float_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":726 - * - * ctypedef npy_double float_t - * ctypedef npy_double double_t # <<<<<<<<<<<<<< - * ctypedef npy_longdouble longdouble_t - * - */ -typedef npy_double __pyx_t_5numpy_double_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":727 - * ctypedef npy_double float_t - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cfloat cfloat_t - */ -typedef npy_longdouble __pyx_t_5numpy_longdouble_t; -/* Declarations.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< float > __pyx_t_float_complex; - #else - typedef float _Complex __pyx_t_float_complex; - #endif -#else - typedef struct { float real, imag; } __pyx_t_float_complex; -#endif -static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); - -/* Declarations.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< double > __pyx_t_double_complex; - #else - typedef double _Complex __pyx_t_double_complex; - #endif -#else - typedef struct { double real, imag; } __pyx_t_double_complex; -#endif -static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); - - -/*--- Type declarations ---*/ -struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel; -struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel; -struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":729 - * ctypedef npy_longdouble longdouble_t - * - * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t - */ -typedef npy_cfloat __pyx_t_5numpy_cfloat_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":730 - * - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< - * ctypedef npy_clongdouble clongdouble_t - * - */ -typedef npy_cdouble __pyx_t_5numpy_cdouble_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":731 - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cdouble complex_t - */ -typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":733 - * ctypedef npy_clongdouble clongdouble_t - * - * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew1(a): - */ -typedef npy_cdouble __pyx_t_5numpy_complex_t; - -/* "LAIProcess.pyx":42 - * - * - * def train_WMCmodel(lai_water_inc_sigma_list,params_X0,train_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ -struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel { - PyObject_HEAD - PyObject *__pyx_v_lai_water_inc_sigma_list; -}; - - -/* "LAIProcess.pyx":82 - * return h[0] - * - * def test_WMCModel(lai_waiter_inc_sigma_list,param_arr,lai_X0,test_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ -struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel { - PyObject_HEAD - PyObject *__pyx_v_csv_sigma; - PyObject *__pyx_v_param_arr; - PyObject *__pyx_v_sample_inc; - PyObject *__pyx_v_sample_soil; -}; - - -/* "LAIProcess.pyx":130 - * return err - * - * def processs_WMCModel(param_arr,lai_X0,sigma,inc_angle,soil_water): # <<<<<<<<<<<<<< - * - * if(sigma<0 ): - */ -struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel { - PyObject_HEAD - PyObject *__pyx_v_inc_angle; - PyObject *__pyx_v_param_arr; - PyObject *__pyx_v_sigma; - PyObject *__pyx_v_soil_water; -}; - - -/* --- Runtime support code (head) --- */ -/* Refnanny.proto */ -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, const char*); - void (*FinishContext)(void**); - } __Pyx_RefNannyAPIStruct; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); - #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; -#ifdef WITH_THREAD - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - if (acquire_gil) {\ - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - PyGILState_Release(__pyx_gilstate_save);\ - } else {\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #define __Pyx_RefNannyFinishContext()\ - __Pyx_RefNanny->FinishContext(&__pyx_refnanny) - #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #define __Pyx_RefNannyFinishContext() - #define __Pyx_INCREF(r) Py_INCREF(r) - #define __Pyx_DECREF(r) Py_DECREF(r) - #define __Pyx_GOTREF(r) - #define __Pyx_GIVEREF(r) - #define __Pyx_XINCREF(r) Py_XINCREF(r) - #define __Pyx_XDECREF(r) Py_XDECREF(r) - #define __Pyx_XGOTREF(r) - #define __Pyx_XGIVEREF(r) -#endif -#define __Pyx_XDECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_XDECREF(tmp);\ - } while (0) -#define __Pyx_DECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_DECREF(tmp);\ - } while (0) -#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) -#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) - -/* RaiseArgTupleInvalid.proto */ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* RaiseTooManyValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); - -/* RaiseNeedMoreValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); - -/* IterFinish.proto */ -static CYTHON_INLINE int __Pyx_IterFinish(void); - -/* UnpackItemEndCheck.proto */ -static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); - -/* PyObjectGetAttrStr.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -/* GetBuiltinName.proto */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name); - -/* PyDictVersioning.proto */ -#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS -#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) -#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) -#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ - (version_var) = __PYX_GET_DICT_VERSION(dict);\ - (cache_var) = (value); -#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ - static PY_UINT64_T __pyx_dict_version = 0;\ - static PyObject *__pyx_dict_cached_value = NULL;\ - if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ - (VAR) = __pyx_dict_cached_value;\ - } else {\ - (VAR) = __pyx_dict_cached_value = (LOOKUP);\ - __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ - }\ -} -static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); -static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); -static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); -#else -#define __PYX_GET_DICT_VERSION(dict) (0) -#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) -#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); -#endif - -/* GetModuleGlobalName.proto */ -#if CYTHON_USE_DICT_VERSIONS -#define __Pyx_GetModuleGlobalName(var, name) {\ - static PY_UINT64_T __pyx_dict_version = 0;\ - static PyObject *__pyx_dict_cached_value = NULL;\ - (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ - (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ - __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ -} -#define __Pyx_GetModuleGlobalNameUncached(var, name) {\ - PY_UINT64_T __pyx_dict_version;\ - PyObject *__pyx_dict_cached_value;\ - (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ -} -static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); -#else -#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) -#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) -static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); -#endif - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#define __Pyx_BUILD_ASSERT_EXPR(cond)\ - (sizeof(char [1 - 2*!(cond)]) - 1) -#ifndef Py_MEMBER_SIZE -#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) -#endif - static size_t __pyx_pyframe_localsplus_offset = 0; - #include "frameobject.h" - #define __Pxy_PyFrame_Initialize_Offsets()\ - ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ - (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) - #define __Pyx_PyFrame_GetLocalsplus(frame)\ - (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) -#endif - -/* PyObjectCall.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); -#else -#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) -#endif - -/* PyObjectCall2Args.proto */ -static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); - -/* PyObjectCallMethO.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); -#endif - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* PyIntBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_SubtractCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); -#else -#define __Pyx_PyInt_SubtractCObj(op1, op2, intval, inplace, zerodivision_check)\ - (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2)) -#endif - -/* None.proto */ -static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname); - -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ - __Pyx_GetItemInt_Generic(o, to_py_func(i)))) -#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, - int is_list, int wraparound, int boundscheck); - -/* ListAppend.proto */ -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { - PyListObject* L = (PyListObject*) list; - Py_ssize_t len = Py_SIZE(list); - if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { - Py_INCREF(x); - PyList_SET_ITEM(list, len, x); - __Pyx_SET_SIZE(list, len + 1); - return 0; - } - return PyList_Append(list, x); -} -#else -#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) -#endif - -/* FetchCommonType.proto */ -static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); - -/* CythonFunctionShared.proto */ -#define __Pyx_CyFunction_USED 1 -#define __Pyx_CYFUNCTION_STATICMETHOD 0x01 -#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 -#define __Pyx_CYFUNCTION_CCLASS 0x04 -#define __Pyx_CyFunction_GetClosure(f)\ - (((__pyx_CyFunctionObject *) (f))->func_closure) -#define __Pyx_CyFunction_GetClassObj(f)\ - (((__pyx_CyFunctionObject *) (f))->func_classobj) -#define __Pyx_CyFunction_Defaults(type, f)\ - ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) -#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ - ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) -typedef struct { - PyCFunctionObject func; -#if PY_VERSION_HEX < 0x030500A0 - PyObject *func_weakreflist; -#endif - PyObject *func_dict; - PyObject *func_name; - PyObject *func_qualname; - PyObject *func_doc; - PyObject *func_globals; - PyObject *func_code; - PyObject *func_closure; - PyObject *func_classobj; - void *defaults; - int defaults_pyobjects; - size_t defaults_size; // used by FusedFunction for copying defaults - int flags; - PyObject *defaults_tuple; - PyObject *defaults_kwdict; - PyObject *(*defaults_getter)(PyObject *); - PyObject *func_annotations; -} __pyx_CyFunctionObject; -static PyTypeObject *__pyx_CyFunctionType = 0; -#define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType)) -static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, - int flags, PyObject* qualname, - PyObject *self, - PyObject *module, PyObject *globals, - PyObject* code); -static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, - size_t size, - int pyobjects); -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, - PyObject *tuple); -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, - PyObject *dict); -static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, - PyObject *dict); -static int __pyx_CyFunction_init(void); - -/* CythonFunction.proto */ -static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, - int flags, PyObject* qualname, - PyObject *closure, - PyObject *module, PyObject *globals, - PyObject* code); - -/* ListCompAppend.proto */ -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { - PyListObject* L = (PyListObject*) list; - Py_ssize_t len = Py_SIZE(list); - if (likely(L->allocated > len)) { - Py_INCREF(x); - PyList_SET_ITEM(list, len, x); - __Pyx_SET_SIZE(list, len + 1); - return 0; - } - return PyList_Append(list, x); -} -#else -#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) -#endif - -/* Import.proto */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); - -/* ImportFrom.proto */ -static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); - -/* PyObjectCallNoArg.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); -#else -#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) -#endif - -/* IsLittleEndian.proto */ -static CYTHON_INLINE int __Pyx_Is_Little_Endian(void); - -/* BufferFormatCheck.proto */ -static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); -static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type); - -/* BufferGetAndValidate.proto */ -#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\ - ((obj == Py_None || obj == NULL) ?\ - (__Pyx_ZeroBuffer(buf), 0) :\ - __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)) -static int __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj, - __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); -static void __Pyx_ZeroBuffer(Py_buffer* buf); -static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); -static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - -/* BufferIndexError.proto */ -static void __Pyx_RaiseBufferIndexError(int axis); - -#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) -/* PyThreadStateGet.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; -#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type -#else -#define __Pyx_PyThreadState_declare -#define __Pyx_PyThreadState_assign -#define __Pyx_PyErr_Occurred() PyErr_Occurred() -#endif - -/* PyErrFetchRestore.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) -#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) -#else -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#endif -#else -#define __Pyx_PyErr_Clear() PyErr_Clear() -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) -#endif - -/* ArgTypeTest.proto */ -#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ - ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ - __Pyx__ArgTypeTest(obj, type, name, exact)) -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); - -/* GetTopmostException.proto */ -#if CYTHON_USE_EXC_INFO_STACK -static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); -#endif - -/* SaveResetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -#else -#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) -#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) -#endif - -/* PyErrExceptionMatches.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) -static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); -#else -#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) -#endif - -/* GetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); -#endif - -/* RaiseException.proto */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); - -/* IncludeStringH.proto */ -#include - -/* PyObject_GenericGetAttrNoDict.proto */ -#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 -static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); -#else -#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr -#endif - -/* TypeImport.proto */ -#ifndef __PYX_HAVE_RT_ImportType_proto -#define __PYX_HAVE_RT_ImportType_proto -enum __Pyx_ImportType_CheckSize { - __Pyx_ImportType_CheckSize_Error = 0, - __Pyx_ImportType_CheckSize_Warn = 1, - __Pyx_ImportType_CheckSize_Ignore = 2 -}; -static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size); -#endif - -/* CLineInTraceback.proto */ -#ifdef CYTHON_CLINE_IN_TRACEBACK -#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) -#else -static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); -#endif - -/* CodeObjectCache.proto */ -typedef struct { - PyCodeObject* code_object; - int code_line; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -/* AddTraceback.proto */ -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); - -/* BufferStructDeclare.proto */ -typedef struct { - Py_ssize_t shape, strides, suboffsets; -} __Pyx_Buf_DimInfo; -typedef struct { - size_t refcount; - Py_buffer pybuffer; -} __Pyx_Buffer; -typedef struct { - __Pyx_Buffer *rcbuffer; - char *data; - __Pyx_Buf_DimInfo diminfo[8]; -} __Pyx_LocalBuf_ND; - -#if PY_MAJOR_VERSION < 3 - static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); - static void __Pyx_ReleaseBuffer(Py_buffer *view); -#else - #define __Pyx_GetBuffer PyObject_GetBuffer - #define __Pyx_ReleaseBuffer PyBuffer_Release -#endif - - -/* GCCDiagnostics.proto */ -#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) -#define __Pyx_HAS_GCC_DIAGNOSTIC -#endif - -/* RealImag.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #define __Pyx_CREAL(z) ((z).real()) - #define __Pyx_CIMAG(z) ((z).imag()) - #else - #define __Pyx_CREAL(z) (__real__(z)) - #define __Pyx_CIMAG(z) (__imag__(z)) - #endif -#else - #define __Pyx_CREAL(z) ((z).real) - #define __Pyx_CIMAG(z) ((z).imag) -#endif -#if defined(__cplusplus) && CYTHON_CCOMPLEX\ - && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) - #define __Pyx_SET_CREAL(z,x) ((z).real(x)) - #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) -#else - #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) - #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) -#endif - -/* Arithmetic.proto */ -#if CYTHON_CCOMPLEX - #define __Pyx_c_eq_float(a, b) ((a)==(b)) - #define __Pyx_c_sum_float(a, b) ((a)+(b)) - #define __Pyx_c_diff_float(a, b) ((a)-(b)) - #define __Pyx_c_prod_float(a, b) ((a)*(b)) - #define __Pyx_c_quot_float(a, b) ((a)/(b)) - #define __Pyx_c_neg_float(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zero_float(z) ((z)==(float)0) - #define __Pyx_c_conj_float(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_abs_float(z) (::std::abs(z)) - #define __Pyx_c_pow_float(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zero_float(z) ((z)==0) - #define __Pyx_c_conj_float(z) (conjf(z)) - #if 1 - #define __Pyx_c_abs_float(z) (cabsf(z)) - #define __Pyx_c_pow_float(a, b) (cpowf(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex); - static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex); - #if 1 - static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex); - #endif -#endif - -/* Arithmetic.proto */ -#if CYTHON_CCOMPLEX - #define __Pyx_c_eq_double(a, b) ((a)==(b)) - #define __Pyx_c_sum_double(a, b) ((a)+(b)) - #define __Pyx_c_diff_double(a, b) ((a)-(b)) - #define __Pyx_c_prod_double(a, b) ((a)*(b)) - #define __Pyx_c_quot_double(a, b) ((a)/(b)) - #define __Pyx_c_neg_double(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zero_double(z) ((z)==(double)0) - #define __Pyx_c_conj_double(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_abs_double(z) (::std::abs(z)) - #define __Pyx_c_pow_double(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zero_double(z) ((z)==0) - #define __Pyx_c_conj_double(z) (conj(z)) - #if 1 - #define __Pyx_c_abs_double(z) (cabs(z)) - #define __Pyx_c_pow_double(a, b) (cpow(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex); - static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex); - #if 1 - static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex); - #endif -#endif - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -/* FastTypeChecks.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); -#else -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) -#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) -#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) -#endif -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) - -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* InitStrings.proto */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); - - -/* Module declarations from 'cython' */ - -/* Module declarations from 'cpython.buffer' */ - -/* Module declarations from 'libc.string' */ - -/* Module declarations from 'libc.stdio' */ - -/* Module declarations from '__builtin__' */ - -/* Module declarations from 'cpython.type' */ -static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; - -/* Module declarations from 'cpython' */ - -/* Module declarations from 'cpython.object' */ - -/* Module declarations from 'cpython.ref' */ - -/* Module declarations from 'cpython.mem' */ - -/* Module declarations from 'numpy' */ - -/* Module declarations from 'numpy' */ -static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; -static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; -static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; -static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; -static PyTypeObject *__pyx_ptype_5numpy_generic = 0; -static PyTypeObject *__pyx_ptype_5numpy_number = 0; -static PyTypeObject *__pyx_ptype_5numpy_integer = 0; -static PyTypeObject *__pyx_ptype_5numpy_signedinteger = 0; -static PyTypeObject *__pyx_ptype_5numpy_unsignedinteger = 0; -static PyTypeObject *__pyx_ptype_5numpy_inexact = 0; -static PyTypeObject *__pyx_ptype_5numpy_floating = 0; -static PyTypeObject *__pyx_ptype_5numpy_complexfloating = 0; -static PyTypeObject *__pyx_ptype_5numpy_flexible = 0; -static PyTypeObject *__pyx_ptype_5numpy_character = 0; -static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; - -/* Module declarations from 'libc.math' */ - -/* Module declarations from 'LAIProcess' */ -static PyTypeObject *__pyx_ptype_10LAIProcess___pyx_scope_struct__train_WMCmodel = 0; -static PyTypeObject *__pyx_ptype_10LAIProcess___pyx_scope_struct_1_test_WMCModel = 0; -static PyTypeObject *__pyx_ptype_10LAIProcess___pyx_scope_struct_2_processs_WMCModel = 0; -static PyArrayObject *__pyx_f_10LAIProcess_process_tiff(PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, double, int __pyx_skip_dispatch); /*proto*/ -static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 }; -#define __Pyx_MODULE_NAME "LAIProcess" -extern int __pyx_module_is_main_LAIProcess; -int __pyx_module_is_main_LAIProcess = 0; - -/* Implementation of 'LAIProcess' */ -static PyObject *__pyx_builtin_ImportError; -static const char __pyx_k_A[] = "A"; -static const char __pyx_k_B[] = "B"; -static const char __pyx_k_C[] = "C"; -static const char __pyx_k_D[] = "D"; -static const char __pyx_k_M[] = "M"; -static const char __pyx_k_N[] = "N"; -static const char __pyx_k_X[] = "X"; -static const char __pyx_k_f[] = "f"; -static const char __pyx_k_h[] = "h"; -static const char __pyx_k_X0[] = "X0"; -static const char __pyx_k_np[] = "np"; -static const char __pyx_k_FVC[] = "FVC"; -static const char __pyx_k_cos[] = "cos"; -static const char __pyx_k_dpi[] = "dpi"; -static const char __pyx_k_eqs[] = "eqs"; -static const char __pyx_k_err[] = "err"; -static const char __pyx_k_exp[] = "exp"; -static const char __pyx_k_lai[] = "lai"; -static const char __pyx_k_nan[] = "nan"; -static const char __pyx_k_plt[] = "plt"; -static const char __pyx_k_main[] = "__main__"; -static const char __pyx_k_name[] = "__name__"; -static const char __pyx_k_show[] = "show"; -static const char __pyx_k_test[] = "__test__"; -static const char __pyx_k_V_lai[] = "V_lai"; -static const char __pyx_k_err_f[] = "err_f"; -static const char __pyx_k_f_veg[] = "f_veg"; -static const char __pyx_k_mylog[] = "mylog"; -static const char __pyx_k_numpy[] = "numpy"; -static const char __pyx_k_sigma[] = "sigma"; -static const char __pyx_k_title[] = "title"; -static const char __pyx_k_x_arr[] = "x_arr"; -static const char __pyx_k_import[] = "__import__"; -static const char __pyx_k_lai_X0[] = "lai_X0"; -static const char __pyx_k_logger[] = "logger"; -static const char __pyx_k_pyplot[] = "pyplot"; -static const char __pyx_k_random[] = "random"; -static const char __pyx_k_result[] = "result"; -static const char __pyx_k_err_lai[] = "err_lai"; -static const char __pyx_k_leastsq[] = "leastsq"; -static const char __pyx_k_logging[] = "logging"; -static const char __pyx_k_savefig[] = "savefig"; -static const char __pyx_k_scatter[] = "scatter"; -static const char __pyx_k_WMCModel[] = "WMCModel"; -static const char __pyx_k_inc_tiff[] = "inc_tiff"; -static const char __pyx_k_temp_err[] = "temp_err"; -static const char __pyx_k_csv_sigma[] = "csv_sigma"; -static const char __pyx_k_draw_flag[] = "draw_flag"; -static const char __pyx_k_exp_gamma[] = "exp_gamma"; -static const char __pyx_k_getLogger[] = "getLogger"; -static const char __pyx_k_inc_angle[] = "inc_angle"; -static const char __pyx_k_param_arr[] = "param_arr"; -static const char __pyx_k_params_X0[] = "params_X0"; -static const char __pyx_k_sigma_veg[] = "sigma_veg"; -static const char __pyx_k_LAIProcess[] = "LAIProcess"; -static const char __pyx_k_matplotlib[] = "matplotlib"; -static const char __pyx_k_sample_inc[] = "sample_inc"; -static const char __pyx_k_sample_lai[] = "sample_lai"; -static const char __pyx_k_sample_lat[] = "sample_lat"; -static const char __pyx_k_sample_lon[] = "sample_lon"; -static const char __pyx_k_sigma_soil[] = "sigma_soil"; -static const char __pyx_k_sigma_tiff[] = "sigma_tiff"; -static const char __pyx_k_soil_water[] = "soil_water"; -static const char __pyx_k_ImportError[] = "ImportError"; -static const char __pyx_k_sample_code[] = "sample_code"; -static const char __pyx_k_sample_soil[] = "sample_soil"; -static const char __pyx_k_sample_time[] = "sample_time"; -static const char __pyx_k_equation_err[] = "equation-err"; -static const char __pyx_k_sample_sigma[] = "sample_sigma"; -static const char __pyx_k_test_WMCModel[] = "test_WMCModel"; -static const char __pyx_k_LAIProcess_pyx[] = "LAIProcess.pyx"; -static const char __pyx_k_scipy_optimize[] = "scipy.optimize"; -static const char __pyx_k_train_WMCmodel[] = "train_WMCmodel"; -static const char __pyx_k_soil_water_tiff[] = "soil_water_tiff"; -static const char __pyx_k_processs_WMCModel[] = "processs_WMCModel"; -static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; -static const char __pyx_k_test_err_image_path[] = "test_err_image_path"; -static const char __pyx_k_train_err_image_path[] = "train_err_image_path"; -static const char __pyx_k_test_WMCModel_locals_f[] = "test_WMCModel..f"; -static const char __pyx_k_train_WMCmodel_locals_f[] = "train_WMCmodel..f"; -static const char __pyx_k_lai_water_inc_sigma_item[] = "lai_water_inc_sigma_item"; -static const char __pyx_k_lai_water_inc_sigma_list[] = "lai_water_inc_sigma_list"; -static const char __pyx_k_lai_waiter_inc_sigma_item[] = "lai_waiter_inc_sigma_item"; -static const char __pyx_k_lai_waiter_inc_sigma_list[] = "lai_waiter_inc_sigma_list"; -static const char __pyx_k_processs_WMCModel_locals_f[] = "processs_WMCModel..f"; -static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import"; -static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import"; -static PyObject *__pyx_n_s_A; -static PyObject *__pyx_n_s_B; -static PyObject *__pyx_n_s_C; -static PyObject *__pyx_n_s_D; -static PyObject *__pyx_n_s_FVC; -static PyObject *__pyx_n_s_ImportError; -static PyObject *__pyx_n_s_LAIProcess; -static PyObject *__pyx_kp_s_LAIProcess_pyx; -static PyObject *__pyx_n_s_M; -static PyObject *__pyx_n_s_N; -static PyObject *__pyx_n_s_V_lai; -static PyObject *__pyx_n_s_WMCModel; -static PyObject *__pyx_n_s_X; -static PyObject *__pyx_n_s_X0; -static PyObject *__pyx_n_s_cline_in_traceback; -static PyObject *__pyx_n_s_cos; -static PyObject *__pyx_n_s_csv_sigma; -static PyObject *__pyx_n_s_dpi; -static PyObject *__pyx_n_s_draw_flag; -static PyObject *__pyx_n_s_eqs; -static PyObject *__pyx_kp_s_equation_err; -static PyObject *__pyx_n_s_err; -static PyObject *__pyx_n_s_err_f; -static PyObject *__pyx_n_s_err_lai; -static PyObject *__pyx_n_s_exp; -static PyObject *__pyx_n_s_exp_gamma; -static PyObject *__pyx_n_s_f; -static PyObject *__pyx_n_s_f_veg; -static PyObject *__pyx_n_s_getLogger; -static PyObject *__pyx_n_s_h; -static PyObject *__pyx_n_s_import; -static PyObject *__pyx_n_s_inc_angle; -static PyObject *__pyx_n_s_inc_tiff; -static PyObject *__pyx_n_s_lai; -static PyObject *__pyx_n_s_lai_X0; -static PyObject *__pyx_n_s_lai_waiter_inc_sigma_item; -static PyObject *__pyx_n_s_lai_waiter_inc_sigma_list; -static PyObject *__pyx_n_s_lai_water_inc_sigma_item; -static PyObject *__pyx_n_s_lai_water_inc_sigma_list; -static PyObject *__pyx_n_s_leastsq; -static PyObject *__pyx_n_s_logger; -static PyObject *__pyx_n_s_logging; -static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_matplotlib; -static PyObject *__pyx_n_s_mylog; -static PyObject *__pyx_n_s_name; -static PyObject *__pyx_n_s_nan; -static PyObject *__pyx_n_s_np; -static PyObject *__pyx_n_s_numpy; -static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to; -static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor; -static PyObject *__pyx_n_s_param_arr; -static PyObject *__pyx_n_s_params_X0; -static PyObject *__pyx_n_s_plt; -static PyObject *__pyx_n_s_processs_WMCModel; -static PyObject *__pyx_n_s_processs_WMCModel_locals_f; -static PyObject *__pyx_n_s_pyplot; -static PyObject *__pyx_n_s_random; -static PyObject *__pyx_n_s_result; -static PyObject *__pyx_n_s_sample_code; -static PyObject *__pyx_n_s_sample_inc; -static PyObject *__pyx_n_s_sample_lai; -static PyObject *__pyx_n_s_sample_lat; -static PyObject *__pyx_n_s_sample_lon; -static PyObject *__pyx_n_s_sample_sigma; -static PyObject *__pyx_n_s_sample_soil; -static PyObject *__pyx_n_s_sample_time; -static PyObject *__pyx_n_s_savefig; -static PyObject *__pyx_n_s_scatter; -static PyObject *__pyx_n_s_scipy_optimize; -static PyObject *__pyx_n_s_show; -static PyObject *__pyx_n_s_sigma; -static PyObject *__pyx_n_s_sigma_soil; -static PyObject *__pyx_n_s_sigma_tiff; -static PyObject *__pyx_n_s_sigma_veg; -static PyObject *__pyx_n_s_soil_water; -static PyObject *__pyx_n_s_soil_water_tiff; -static PyObject *__pyx_n_s_temp_err; -static PyObject *__pyx_n_s_test; -static PyObject *__pyx_n_s_test_WMCModel; -static PyObject *__pyx_n_s_test_WMCModel_locals_f; -static PyObject *__pyx_n_s_test_err_image_path; -static PyObject *__pyx_n_s_title; -static PyObject *__pyx_n_s_train_WMCmodel; -static PyObject *__pyx_n_s_train_WMCmodel_locals_f; -static PyObject *__pyx_n_s_train_err_image_path; -static PyObject *__pyx_n_s_x_arr; -static PyObject *__pyx_pf_10LAIProcess_WMCModel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_param_arr, PyObject *__pyx_v_sample_lai, PyObject *__pyx_v_sample_soil, PyObject *__pyx_v_sample_inc, PyObject *__pyx_v_sample_sigma); /* proto */ -static PyObject *__pyx_pf_10LAIProcess_14train_WMCmodel_f(PyObject *__pyx_self, PyObject *__pyx_v_X); /* proto */ -static PyObject *__pyx_pf_10LAIProcess_2train_WMCmodel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_lai_water_inc_sigma_list, PyObject *__pyx_v_params_X0, PyObject *__pyx_v_train_err_image_path, PyObject *__pyx_v_draw_flag); /* proto */ -static PyObject *__pyx_pf_10LAIProcess_13test_WMCModel_f(PyObject *__pyx_self, PyObject *__pyx_v_X); /* proto */ -static PyObject *__pyx_pf_10LAIProcess_4test_WMCModel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_lai_waiter_inc_sigma_list, PyObject *__pyx_v_param_arr, PyObject *__pyx_v_lai_X0, PyObject *__pyx_v_test_err_image_path, PyObject *__pyx_v_draw_flag); /* proto */ -static PyObject *__pyx_pf_10LAIProcess_17processs_WMCModel_f(PyObject *__pyx_self, PyObject *__pyx_v_X); /* proto */ -static PyObject *__pyx_pf_10LAIProcess_6processs_WMCModel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_param_arr, PyObject *__pyx_v_lai_X0, PyObject *__pyx_v_sigma, PyObject *__pyx_v_inc_angle, PyObject *__pyx_v_soil_water); /* proto */ -static PyObject *__pyx_pf_10LAIProcess_8process_tiff(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_sigma_tiff, PyArrayObject *__pyx_v_inc_tiff, PyArrayObject *__pyx_v_soil_water_tiff, PyArrayObject *__pyx_v_param_arr, double __pyx_v_lai_X0); /* proto */ -static PyObject *__pyx_tp_new_10LAIProcess___pyx_scope_struct__train_WMCmodel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_10LAIProcess___pyx_scope_struct_1_test_WMCModel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_10LAIProcess___pyx_scope_struct_2_processs_WMCModel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_int_0; -static PyObject *__pyx_int_1; -static PyObject *__pyx_int_600; -static PyObject *__pyx_int_neg_2; -static PyObject *__pyx_tuple_; -static PyObject *__pyx_tuple__3; -static PyObject *__pyx_tuple__5; -static PyObject *__pyx_tuple__7; -static PyObject *__pyx_tuple__8; -static PyObject *__pyx_tuple__9; -static PyObject *__pyx_tuple__10; -static PyObject *__pyx_tuple__12; -static PyObject *__pyx_tuple__14; -static PyObject *__pyx_tuple__16; -static PyObject *__pyx_codeobj__2; -static PyObject *__pyx_codeobj__4; -static PyObject *__pyx_codeobj__6; -static PyObject *__pyx_codeobj__11; -static PyObject *__pyx_codeobj__13; -static PyObject *__pyx_codeobj__15; -static PyObject *__pyx_codeobj__17; -/* Late includes */ - -/* "LAIProcess.pyx":15 - * - * - * def WMCModel(param_arr,sample_lai,sample_soil,sample_inc,sample_sigma): # <<<<<<<<<<<<<< - * """ WMC - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10LAIProcess_1WMCModel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_10LAIProcess_WMCModel[] = " WMC\346\250\241\345\236\213 \345\242\236\345\212\240 \345\275\222\344\270\200\345\214\226\346\244\215\350\242\253\346\214\207\346\225\260\n\n Args:\n param_arr (np.ndarray): \345\217\202\346\225\260\346\225\260\347\273\204\n sample_lai (double): \345\217\266\351\235\242\347\247\257\346\214\207\346\225\260\n sample_soil (double): \345\234\237\345\243\244\345\220\253\346\260\264\351\207\217\n sample_inc (double): \345\205\245\345\260\204\350\247\222\357\274\210\345\274\247\345\272\246\345\200\274\357\274\211\n sample_sigma (double): \345\220\216\345\220\221\346\225\243\345\260\204\347\263\273\346\225\260\357\274\210\347\272\277\346\200\247\345\200\274\357\274\211\n\n Returns:\n double: \346\226\271\347\250\213\345\200\274\n "; -static PyMethodDef __pyx_mdef_10LAIProcess_1WMCModel = {"WMCModel", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10LAIProcess_1WMCModel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10LAIProcess_WMCModel}; -static PyObject *__pyx_pw_10LAIProcess_1WMCModel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_param_arr = 0; - PyObject *__pyx_v_sample_lai = 0; - PyObject *__pyx_v_sample_soil = 0; - PyObject *__pyx_v_sample_inc = 0; - PyObject *__pyx_v_sample_sigma = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("WMCModel (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_param_arr,&__pyx_n_s_sample_lai,&__pyx_n_s_sample_soil,&__pyx_n_s_sample_inc,&__pyx_n_s_sample_sigma,0}; - PyObject* values[5] = {0,0,0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_param_arr)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sample_lai)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("WMCModel", 1, 5, 5, 1); __PYX_ERR(0, 15, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sample_soil)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("WMCModel", 1, 5, 5, 2); __PYX_ERR(0, 15, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 3: - if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sample_inc)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("WMCModel", 1, 5, 5, 3); __PYX_ERR(0, 15, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 4: - if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sample_sigma)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("WMCModel", 1, 5, 5, 4); __PYX_ERR(0, 15, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "WMCModel") < 0)) __PYX_ERR(0, 15, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - } - __pyx_v_param_arr = values[0]; - __pyx_v_sample_lai = values[1]; - __pyx_v_sample_soil = values[2]; - __pyx_v_sample_inc = values[3]; - __pyx_v_sample_sigma = values[4]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("WMCModel", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 15, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("LAIProcess.WMCModel", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10LAIProcess_WMCModel(__pyx_self, __pyx_v_param_arr, __pyx_v_sample_lai, __pyx_v_sample_soil, __pyx_v_sample_inc, __pyx_v_sample_sigma); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10LAIProcess_WMCModel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_param_arr, PyObject *__pyx_v_sample_lai, PyObject *__pyx_v_sample_soil, PyObject *__pyx_v_sample_inc, PyObject *__pyx_v_sample_sigma) { - PyObject *__pyx_v_A = NULL; - PyObject *__pyx_v_B = NULL; - PyObject *__pyx_v_C = NULL; - PyObject *__pyx_v_D = NULL; - PyObject *__pyx_v_M = NULL; - PyObject *__pyx_v_N = NULL; - PyObject *__pyx_v_V_lai = NULL; - PyObject *__pyx_v_exp_gamma = NULL; - PyObject *__pyx_v_sigma_soil = NULL; - PyObject *__pyx_v_sigma_veg = NULL; - CYTHON_UNUSED long __pyx_v_f_veg; - PyObject *__pyx_v_result = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *(*__pyx_t_8)(PyObject *); - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("WMCModel", 0); - - /* "LAIProcess.pyx":29 - * """ - * # - * A,B,C,D,M,N=param_arr # # <<<<<<<<<<<<<< - * V_lai=sample_lai - * #V_lai=E*sample_lai+F - */ - if ((likely(PyTuple_CheckExact(__pyx_v_param_arr))) || (PyList_CheckExact(__pyx_v_param_arr))) { - PyObject* sequence = __pyx_v_param_arr; - Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); - if (unlikely(size != 6)) { - if (size > 6) __Pyx_RaiseTooManyValuesError(6); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 29, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); - __pyx_t_5 = PyTuple_GET_ITEM(sequence, 4); - __pyx_t_6 = PyTuple_GET_ITEM(sequence, 5); - } else { - __pyx_t_1 = PyList_GET_ITEM(sequence, 0); - __pyx_t_2 = PyList_GET_ITEM(sequence, 1); - __pyx_t_3 = PyList_GET_ITEM(sequence, 2); - __pyx_t_4 = PyList_GET_ITEM(sequence, 3); - __pyx_t_5 = PyList_GET_ITEM(sequence, 4); - __pyx_t_6 = PyList_GET_ITEM(sequence, 5); - } - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - #else - { - Py_ssize_t i; - PyObject** temps[6] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5,&__pyx_t_6}; - for (i=0; i < 6; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 29, __pyx_L1_error) - __Pyx_GOTREF(item); - *(temps[i]) = item; - } - } - #endif - } else { - Py_ssize_t index = -1; - PyObject** temps[6] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5,&__pyx_t_6}; - __pyx_t_7 = PyObject_GetIter(__pyx_v_param_arr); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 29, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; - for (index=0; index < 6; index++) { - PyObject* item = __pyx_t_8(__pyx_t_7); if (unlikely(!item)) goto __pyx_L3_unpacking_failed; - __Pyx_GOTREF(item); - *(temps[index]) = item; - } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 6) < 0) __PYX_ERR(0, 29, __pyx_L1_error) - __pyx_t_8 = NULL; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - goto __pyx_L4_unpacking_done; - __pyx_L3_unpacking_failed:; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_8 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 29, __pyx_L1_error) - __pyx_L4_unpacking_done:; - } - __pyx_v_A = __pyx_t_1; - __pyx_t_1 = 0; - __pyx_v_B = __pyx_t_2; - __pyx_t_2 = 0; - __pyx_v_C = __pyx_t_3; - __pyx_t_3 = 0; - __pyx_v_D = __pyx_t_4; - __pyx_t_4 = 0; - __pyx_v_M = __pyx_t_5; - __pyx_t_5 = 0; - __pyx_v_N = __pyx_t_6; - __pyx_t_6 = 0; - - /* "LAIProcess.pyx":30 - * # - * A,B,C,D,M,N=param_arr # - * V_lai=sample_lai # <<<<<<<<<<<<<< - * #V_lai=E*sample_lai+F - * exp_gamma=np.exp(-2*B*((V_lai*D+C))*(1/np.cos(sample_inc))) - */ - __Pyx_INCREF(__pyx_v_sample_lai); - __pyx_v_V_lai = __pyx_v_sample_lai; - - /* "LAIProcess.pyx":32 - * V_lai=sample_lai - * #V_lai=E*sample_lai+F - * exp_gamma=np.exp(-2*B*((V_lai*D+C))*(1/np.cos(sample_inc))) # <<<<<<<<<<<<<< - * sigma_soil=M*sample_soil+N - * sigma_veg=A*((V_lai))*np.cos(sample_inc) - */ - __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_exp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Multiply(__pyx_int_neg_2, __pyx_v_B); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyNumber_Multiply(__pyx_v_V_lai, __pyx_v_D); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyNumber_Add(__pyx_t_3, __pyx_v_C); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Multiply(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_cos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v_sample_inc) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_sample_inc); - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_int_1, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - __pyx_t_6 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_exp_gamma = __pyx_t_6; - __pyx_t_6 = 0; - - /* "LAIProcess.pyx":33 - * #V_lai=E*sample_lai+F - * exp_gamma=np.exp(-2*B*((V_lai*D+C))*(1/np.cos(sample_inc))) - * sigma_soil=M*sample_soil+N # <<<<<<<<<<<<<< - * sigma_veg=A*((V_lai))*np.cos(sample_inc) - * f_veg=1 - */ - __pyx_t_6 = PyNumber_Multiply(__pyx_v_M, __pyx_v_sample_soil); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyNumber_Add(__pyx_t_6, __pyx_v_N); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_v_sigma_soil = __pyx_t_4; - __pyx_t_4 = 0; - - /* "LAIProcess.pyx":34 - * exp_gamma=np.exp(-2*B*((V_lai*D+C))*(1/np.cos(sample_inc))) - * sigma_soil=M*sample_soil+N - * sigma_veg=A*((V_lai))*np.cos(sample_inc) # <<<<<<<<<<<<<< - * f_veg=1 - * result=sigma_veg*(1-exp_gamma)+sigma_soil*exp_gamma-sample_sigma - */ - __pyx_t_4 = PyNumber_Multiply(__pyx_v_A, __pyx_v_V_lai); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_cos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_6 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_v_sample_inc) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_sample_inc); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Multiply(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_v_sigma_veg = __pyx_t_1; - __pyx_t_1 = 0; - - /* "LAIProcess.pyx":35 - * sigma_soil=M*sample_soil+N - * sigma_veg=A*((V_lai))*np.cos(sample_inc) - * f_veg=1 # <<<<<<<<<<<<<< - * result=sigma_veg*(1-exp_gamma)+sigma_soil*exp_gamma-sample_sigma - * return result - */ - __pyx_v_f_veg = 1; - - /* "LAIProcess.pyx":36 - * sigma_veg=A*((V_lai))*np.cos(sample_inc) - * f_veg=1 - * result=sigma_veg*(1-exp_gamma)+sigma_soil*exp_gamma-sample_sigma # <<<<<<<<<<<<<< - * return result - * - */ - __pyx_t_1 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_v_exp_gamma, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyNumber_Multiply(__pyx_v_sigma_veg, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 36, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Multiply(__pyx_v_sigma_soil, __pyx_v_exp_gamma); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyNumber_Add(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Subtract(__pyx_t_4, __pyx_v_sample_sigma); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_result = __pyx_t_1; - __pyx_t_1 = 0; - - /* "LAIProcess.pyx":37 - * f_veg=1 - * result=sigma_veg*(1-exp_gamma)+sigma_soil*exp_gamma-sample_sigma - * return result # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_result); - __pyx_r = __pyx_v_result; - goto __pyx_L0; - - /* "LAIProcess.pyx":15 - * - * - * def WMCModel(param_arr,sample_lai,sample_soil,sample_inc,sample_sigma): # <<<<<<<<<<<<<< - * """ WMC - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_AddTraceback("LAIProcess.WMCModel", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_A); - __Pyx_XDECREF(__pyx_v_B); - __Pyx_XDECREF(__pyx_v_C); - __Pyx_XDECREF(__pyx_v_D); - __Pyx_XDECREF(__pyx_v_M); - __Pyx_XDECREF(__pyx_v_N); - __Pyx_XDECREF(__pyx_v_V_lai); - __Pyx_XDECREF(__pyx_v_exp_gamma); - __Pyx_XDECREF(__pyx_v_sigma_soil); - __Pyx_XDECREF(__pyx_v_sigma_veg); - __Pyx_XDECREF(__pyx_v_result); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "LAIProcess.pyx":42 - * - * - * def train_WMCmodel(lai_water_inc_sigma_list,params_X0,train_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10LAIProcess_3train_WMCmodel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_10LAIProcess_2train_WMCmodel[] = " \350\256\255\347\273\203\346\250\241\345\236\213\345\217\202\346\225\260\n\n Args:\n lai_waiter_inc_sigma_list (list): \350\256\255\347\273\203\346\250\241\345\236\213\344\275\277\347\224\250\347\232\204\346\240\267\346\234\254\345\221\242\n "; -static PyMethodDef __pyx_mdef_10LAIProcess_3train_WMCmodel = {"train_WMCmodel", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10LAIProcess_3train_WMCmodel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10LAIProcess_2train_WMCmodel}; -static PyObject *__pyx_pw_10LAIProcess_3train_WMCmodel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_lai_water_inc_sigma_list = 0; - PyObject *__pyx_v_params_X0 = 0; - PyObject *__pyx_v_train_err_image_path = 0; - PyObject *__pyx_v_draw_flag = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("train_WMCmodel (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lai_water_inc_sigma_list,&__pyx_n_s_params_X0,&__pyx_n_s_train_err_image_path,&__pyx_n_s_draw_flag,0}; - PyObject* values[4] = {0,0,0,0}; - values[3] = ((PyObject *)Py_True); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lai_water_inc_sigma_list)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_params_X0)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("train_WMCmodel", 0, 3, 4, 1); __PYX_ERR(0, 42, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_train_err_image_path)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("train_WMCmodel", 0, 3, 4, 2); __PYX_ERR(0, 42, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 3: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_draw_flag); - if (value) { values[3] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "train_WMCmodel") < 0)) __PYX_ERR(0, 42, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_lai_water_inc_sigma_list = values[0]; - __pyx_v_params_X0 = values[1]; - __pyx_v_train_err_image_path = values[2]; - __pyx_v_draw_flag = values[3]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("train_WMCmodel", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 42, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("LAIProcess.train_WMCmodel", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10LAIProcess_2train_WMCmodel(__pyx_self, __pyx_v_lai_water_inc_sigma_list, __pyx_v_params_X0, __pyx_v_train_err_image_path, __pyx_v_draw_flag); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "LAIProcess.pyx":48 - * lai_waiter_inc_sigma_list (list): - * """ - * def f(X): # <<<<<<<<<<<<<< - * eqs=[] - * for lai_water_inc_sigma_item in lai_water_inc_sigma_list: - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10LAIProcess_14train_WMCmodel_1f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_10LAIProcess_14train_WMCmodel_1f = {"f", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10LAIProcess_14train_WMCmodel_1f, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_10LAIProcess_14train_WMCmodel_1f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_X = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("f (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_X,0}; - PyObject* values[1] = {0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_X)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f") < 0)) __PYX_ERR(0, 48, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - } - __pyx_v_X = values[0]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("f", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 48, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("LAIProcess.train_WMCmodel.f", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10LAIProcess_14train_WMCmodel_f(__pyx_self, __pyx_v_X); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10LAIProcess_14train_WMCmodel_f(PyObject *__pyx_self, PyObject *__pyx_v_X) { - struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *__pyx_cur_scope; - struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *__pyx_outer_scope; - PyObject *__pyx_v_eqs = NULL; - PyObject *__pyx_v_lai_water_inc_sigma_item = NULL; - PyObject *__pyx_v_sample_lai = NULL; - PyObject *__pyx_v_sample_sigma = NULL; - PyObject *__pyx_v_sample_soil = NULL; - PyObject *__pyx_v_sample_inc = NULL; - CYTHON_UNUSED PyObject *__pyx_v_FVC = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *(*__pyx_t_3)(PyObject *); - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("f", 0); - __pyx_outer_scope = (struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *) __Pyx_CyFunction_GetClosure(__pyx_self); - __pyx_cur_scope = __pyx_outer_scope; - - /* "LAIProcess.pyx":49 - * """ - * def f(X): - * eqs=[] # <<<<<<<<<<<<<< - * for lai_water_inc_sigma_item in lai_water_inc_sigma_list: - * sample_lai=lai_water_inc_sigma_item[4] - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_eqs = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "LAIProcess.pyx":50 - * def f(X): - * eqs=[] - * for lai_water_inc_sigma_item in lai_water_inc_sigma_list: # <<<<<<<<<<<<<< - * sample_lai=lai_water_inc_sigma_item[4] - * sample_sigma=lai_water_inc_sigma_item[5] # 5: csv_sigma, 8:tiff_sigma - */ - if (unlikely(!__pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list)) { __Pyx_RaiseClosureNameError("lai_water_inc_sigma_list"); __PYX_ERR(0, 50, __pyx_L1_error) } - if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list)) { - __pyx_t_1 = __pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - __pyx_t_3 = NULL; - } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_3)) { - if (likely(PyList_CheckExact(__pyx_t_1))) { - if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 50, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } else { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 50, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } - } else { - __pyx_t_4 = __pyx_t_3(__pyx_t_1); - if (unlikely(!__pyx_t_4)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 50, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF_SET(__pyx_v_lai_water_inc_sigma_item, __pyx_t_4); - __pyx_t_4 = 0; - - /* "LAIProcess.pyx":51 - * eqs=[] - * for lai_water_inc_sigma_item in lai_water_inc_sigma_list: - * sample_lai=lai_water_inc_sigma_item[4] # <<<<<<<<<<<<<< - * sample_sigma=lai_water_inc_sigma_item[5] # 5: csv_sigma, 8:tiff_sigma - * sample_soil=lai_water_inc_sigma_item[6] - */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_lai_water_inc_sigma_item, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 51, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF_SET(__pyx_v_sample_lai, __pyx_t_4); - __pyx_t_4 = 0; - - /* "LAIProcess.pyx":52 - * for lai_water_inc_sigma_item in lai_water_inc_sigma_list: - * sample_lai=lai_water_inc_sigma_item[4] - * sample_sigma=lai_water_inc_sigma_item[5] # 5: csv_sigma, 8:tiff_sigma # <<<<<<<<<<<<<< - * sample_soil=lai_water_inc_sigma_item[6] - * sample_inc=lai_water_inc_sigma_item[7] - */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_lai_water_inc_sigma_item, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF_SET(__pyx_v_sample_sigma, __pyx_t_4); - __pyx_t_4 = 0; - - /* "LAIProcess.pyx":53 - * sample_lai=lai_water_inc_sigma_item[4] - * sample_sigma=lai_water_inc_sigma_item[5] # 5: csv_sigma, 8:tiff_sigma - * sample_soil=lai_water_inc_sigma_item[6] # <<<<<<<<<<<<<< - * sample_inc=lai_water_inc_sigma_item[7] - * FVC=lai_water_inc_sigma_item[8] - */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_lai_water_inc_sigma_item, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 53, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF_SET(__pyx_v_sample_soil, __pyx_t_4); - __pyx_t_4 = 0; - - /* "LAIProcess.pyx":54 - * sample_sigma=lai_water_inc_sigma_item[5] # 5: csv_sigma, 8:tiff_sigma - * sample_soil=lai_water_inc_sigma_item[6] - * sample_inc=lai_water_inc_sigma_item[7] # <<<<<<<<<<<<<< - * FVC=lai_water_inc_sigma_item[8] - * eqs.append(WMCModel(X,sample_lai,sample_soil,sample_inc,sample_sigma)) - */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_lai_water_inc_sigma_item, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 54, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF_SET(__pyx_v_sample_inc, __pyx_t_4); - __pyx_t_4 = 0; - - /* "LAIProcess.pyx":55 - * sample_soil=lai_water_inc_sigma_item[6] - * sample_inc=lai_water_inc_sigma_item[7] - * FVC=lai_water_inc_sigma_item[8] # <<<<<<<<<<<<<< - * eqs.append(WMCModel(X,sample_lai,sample_soil,sample_inc,sample_sigma)) - * return eqs - */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_lai_water_inc_sigma_item, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF_SET(__pyx_v_FVC, __pyx_t_4); - __pyx_t_4 = 0; - - /* "LAIProcess.pyx":56 - * sample_inc=lai_water_inc_sigma_item[7] - * FVC=lai_water_inc_sigma_item[8] - * eqs.append(WMCModel(X,sample_lai,sample_soil,sample_inc,sample_sigma)) # <<<<<<<<<<<<<< - * return eqs - * - */ - __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_WMCModel); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[6] = {__pyx_t_6, __pyx_v_X, __pyx_v_sample_lai, __pyx_v_sample_soil, __pyx_v_sample_inc, __pyx_v_sample_sigma}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_4); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[6] = {__pyx_t_6, __pyx_v_X, __pyx_v_sample_lai, __pyx_v_sample_soil, __pyx_v_sample_inc, __pyx_v_sample_sigma}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_4); - } else - #endif - { - __pyx_t_8 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_v_X); - __Pyx_GIVEREF(__pyx_v_X); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_X); - __Pyx_INCREF(__pyx_v_sample_lai); - __Pyx_GIVEREF(__pyx_v_sample_lai); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_sample_lai); - __Pyx_INCREF(__pyx_v_sample_soil); - __Pyx_GIVEREF(__pyx_v_sample_soil); - PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_v_sample_soil); - __Pyx_INCREF(__pyx_v_sample_inc); - __Pyx_GIVEREF(__pyx_v_sample_inc); - PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_7, __pyx_v_sample_inc); - __Pyx_INCREF(__pyx_v_sample_sigma); - __Pyx_GIVEREF(__pyx_v_sample_sigma); - PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_7, __pyx_v_sample_sigma); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_eqs, __pyx_t_4); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "LAIProcess.pyx":50 - * def f(X): - * eqs=[] - * for lai_water_inc_sigma_item in lai_water_inc_sigma_list: # <<<<<<<<<<<<<< - * sample_lai=lai_water_inc_sigma_item[4] - * sample_sigma=lai_water_inc_sigma_item[5] # 5: csv_sigma, 8:tiff_sigma - */ - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "LAIProcess.pyx":57 - * FVC=lai_water_inc_sigma_item[8] - * eqs.append(WMCModel(X,sample_lai,sample_soil,sample_inc,sample_sigma)) - * return eqs # <<<<<<<<<<<<<< - * - * X0 = params_X0 # - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_eqs); - __pyx_r = __pyx_v_eqs; - goto __pyx_L0; - - /* "LAIProcess.pyx":48 - * lai_waiter_inc_sigma_list (list): - * """ - * def f(X): # <<<<<<<<<<<<<< - * eqs=[] - * for lai_water_inc_sigma_item in lai_water_inc_sigma_list: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("LAIProcess.train_WMCmodel.f", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_eqs); - __Pyx_XDECREF(__pyx_v_lai_water_inc_sigma_item); - __Pyx_XDECREF(__pyx_v_sample_lai); - __Pyx_XDECREF(__pyx_v_sample_sigma); - __Pyx_XDECREF(__pyx_v_sample_soil); - __Pyx_XDECREF(__pyx_v_sample_inc); - __Pyx_XDECREF(__pyx_v_FVC); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "LAIProcess.pyx":42 - * - * - * def train_WMCmodel(lai_water_inc_sigma_list,params_X0,train_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ - -static PyObject *__pyx_pf_10LAIProcess_2train_WMCmodel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_lai_water_inc_sigma_list, PyObject *__pyx_v_params_X0, PyObject *__pyx_v_train_err_image_path, PyObject *__pyx_v_draw_flag) { - struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *__pyx_cur_scope; - PyObject *__pyx_v_f = 0; - PyObject *__pyx_v_X0 = NULL; - PyObject *__pyx_v_h = NULL; - PyObject *__pyx_v_err_f = NULL; - PyObject *__pyx_v_x_arr = NULL; - PyObject *__pyx_v_plt = NULL; - PyObject *__pyx_v_lai_waiter_inc_sigma_item = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - Py_ssize_t __pyx_t_6; - PyObject *(*__pyx_t_7)(PyObject *); - int __pyx_t_8; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("train_WMCmodel", 0); - __pyx_cur_scope = (struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *)__pyx_tp_new_10LAIProcess___pyx_scope_struct__train_WMCmodel(__pyx_ptype_10LAIProcess___pyx_scope_struct__train_WMCmodel, __pyx_empty_tuple, NULL); - if (unlikely(!__pyx_cur_scope)) { - __pyx_cur_scope = ((struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *)Py_None); - __Pyx_INCREF(Py_None); - __PYX_ERR(0, 42, __pyx_L1_error) - } else { - __Pyx_GOTREF(__pyx_cur_scope); - } - __pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list = __pyx_v_lai_water_inc_sigma_list; - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list); - - /* "LAIProcess.pyx":48 - * lai_waiter_inc_sigma_list (list): - * """ - * def f(X): # <<<<<<<<<<<<<< - * eqs=[] - * for lai_water_inc_sigma_item in lai_water_inc_sigma_list: - */ - __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_10LAIProcess_14train_WMCmodel_1f, 0, __pyx_n_s_train_WMCmodel_locals_f, ((PyObject*)__pyx_cur_scope), __pyx_n_s_LAIProcess, __pyx_d, ((PyObject *)__pyx_codeobj__2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_f = __pyx_t_1; - __pyx_t_1 = 0; - - /* "LAIProcess.pyx":59 - * return eqs - * - * X0 = params_X0 # # <<<<<<<<<<<<<< - * # logger.info(str(X0)) - * h = leastsq(f, X0) - */ - __Pyx_INCREF(__pyx_v_params_X0); - __pyx_v_X0 = __pyx_v_params_X0; - - /* "LAIProcess.pyx":61 - * X0 = params_X0 # - * # logger.info(str(X0)) - * h = leastsq(f, X0) # <<<<<<<<<<<<<< - * # logger.info(h[0],h[1]) - * err_f=f(h[0]) - */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_leastsq); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - __pyx_t_4 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_4 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_f, __pyx_v_X0}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_f, __pyx_v_X0}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; - } - __Pyx_INCREF(__pyx_v_f); - __Pyx_GIVEREF(__pyx_v_f); - PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_f); - __Pyx_INCREF(__pyx_v_X0); - __Pyx_GIVEREF(__pyx_v_X0); - PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_X0); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_h = __pyx_t_1; - __pyx_t_1 = 0; - - /* "LAIProcess.pyx":63 - * h = leastsq(f, X0) - * # logger.info(h[0],h[1]) - * err_f=f(h[0]) # <<<<<<<<<<<<<< - * x_arr=[lai_waiter_inc_sigma_item[4] for lai_waiter_inc_sigma_item in lai_water_inc_sigma_list] - * # - */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_h, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __pyx_pf_10LAIProcess_14train_WMCmodel_f(__pyx_v_f, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_err_f = __pyx_t_2; - __pyx_t_2 = 0; - - /* "LAIProcess.pyx":64 - * # logger.info(h[0],h[1]) - * err_f=f(h[0]) - * x_arr=[lai_waiter_inc_sigma_item[4] for lai_waiter_inc_sigma_item in lai_water_inc_sigma_list] # <<<<<<<<<<<<<< - * # - * # logger.info("\n\n{}\n\t\t ".format(str(np.array(err_f).shape))) - */ - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list)) { - __pyx_t_1 = __pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; - __pyx_t_7 = NULL; - } else { - __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_lai_water_inc_sigma_list); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 64, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_7)) { - if (likely(PyList_CheckExact(__pyx_t_1))) { - if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 64, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } else { - if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 64, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } - } else { - __pyx_t_5 = __pyx_t_7(__pyx_t_1); - if (unlikely(!__pyx_t_5)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 64, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_5); - } - __Pyx_XDECREF_SET(__pyx_v_lai_waiter_inc_sigma_item, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_lai_waiter_inc_sigma_item, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_x_arr = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - - /* "LAIProcess.pyx":71 - * # logger.info("\n\n") - * - * if draw_flag: # <<<<<<<<<<<<<< - * # logger.info(err_f) - * # logger.info(np.where(np.abs(err_f)<10)) - */ - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_draw_flag); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 71, __pyx_L1_error) - if (__pyx_t_8) { - - /* "LAIProcess.pyx":74 - * # logger.info(err_f) - * # logger.info(np.where(np.abs(err_f)<10)) - * from matplotlib import pyplot as plt # <<<<<<<<<<<<<< - * plt.scatter(x_arr,err_f) - * plt.title("equation-err") - */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_pyplot); - __Pyx_GIVEREF(__pyx_n_s_pyplot); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_pyplot); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_matplotlib, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_pyplot); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_t_2); - __pyx_v_plt = __pyx_t_2; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "LAIProcess.pyx":75 - * # logger.info(np.where(np.abs(err_f)<10)) - * from matplotlib import pyplot as plt - * plt.scatter(x_arr,err_f) # <<<<<<<<<<<<<< - * plt.title("equation-err") - * plt.savefig(train_err_image_path,dpi=600) - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_scatter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = NULL; - __pyx_t_4 = 0; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_4 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x_arr, __pyx_v_err_f}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_x_arr, __pyx_v_err_f}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_3 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_v_x_arr); - __Pyx_GIVEREF(__pyx_v_x_arr); - PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_4, __pyx_v_x_arr); - __Pyx_INCREF(__pyx_v_err_f); - __Pyx_GIVEREF(__pyx_v_err_f); - PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_4, __pyx_v_err_f); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "LAIProcess.pyx":76 - * from matplotlib import pyplot as plt - * plt.scatter(x_arr,err_f) - * plt.title("equation-err") # <<<<<<<<<<<<<< - * plt.savefig(train_err_image_path,dpi=600) - * plt.show() - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_title); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_s_equation_err) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s_equation_err); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "LAIProcess.pyx":77 - * plt.scatter(x_arr,err_f) - * plt.title("equation-err") - * plt.savefig(train_err_image_path,dpi=600) # <<<<<<<<<<<<<< - * plt.show() - * - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_savefig); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_train_err_image_path); - __Pyx_GIVEREF(__pyx_v_train_err_image_path); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_train_err_image_path); - __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dpi, __pyx_int_600) < 0) __PYX_ERR(0, 77, __pyx_L1_error) - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 77, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - - /* "LAIProcess.pyx":78 - * plt.title("equation-err") - * plt.savefig(train_err_image_path,dpi=600) - * plt.show() # <<<<<<<<<<<<<< - * - * return h[0] - */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_show); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 78, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - - /* "LAIProcess.pyx":71 - * # logger.info("\n\n") - * - * if draw_flag: # <<<<<<<<<<<<<< - * # logger.info(err_f) - * # logger.info(np.where(np.abs(err_f)<10)) - */ - } - - /* "LAIProcess.pyx":80 - * plt.show() - * - * return h[0] # <<<<<<<<<<<<<< - * - * def test_WMCModel(lai_waiter_inc_sigma_list,param_arr,lai_X0,test_err_image_path,draw_flag=True): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_h, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 80, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; - - /* "LAIProcess.pyx":42 - * - * - * def train_WMCmodel(lai_water_inc_sigma_list,params_X0,train_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("LAIProcess.train_WMCmodel", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_f); - __Pyx_XDECREF(__pyx_v_X0); - __Pyx_XDECREF(__pyx_v_h); - __Pyx_XDECREF(__pyx_v_err_f); - __Pyx_XDECREF(__pyx_v_x_arr); - __Pyx_XDECREF(__pyx_v_plt); - __Pyx_XDECREF(__pyx_v_lai_waiter_inc_sigma_item); - __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "LAIProcess.pyx":82 - * return h[0] - * - * def test_WMCModel(lai_waiter_inc_sigma_list,param_arr,lai_X0,test_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10LAIProcess_5test_WMCModel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_10LAIProcess_4test_WMCModel[] = " \346\265\213\350\257\225\346\250\241\345\236\213\350\256\255\347\273\203\347\273\223\346\236\234\n\n Args:\n lai_waiter_inc_sigma_list (list): \346\265\213\350\257\225\344\275\277\347\224\250\347\232\204\346\240\267\346\234\254\351\233\206\n A (_type_): \345\217\202\346\225\260A\n B (_type_): \345\217\202\346\225\260B\n C (_type_): \345\217\202\346\225\260C\n D (_type_): \345\217\202\346\225\260D\n M (_type_): \345\217\202\346\225\260M\n N (_type_): \345\217\202\346\225\260N\n lai_X0 (_type_): \345\210\235\345\247\213\345\200\274\n\n Returns:\n list: \350\257\257\345\267\256\345\210\227\350\241\250 [sample_lai,err,predict]\n "; -static PyMethodDef __pyx_mdef_10LAIProcess_5test_WMCModel = {"test_WMCModel", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10LAIProcess_5test_WMCModel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10LAIProcess_4test_WMCModel}; -static PyObject *__pyx_pw_10LAIProcess_5test_WMCModel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_lai_waiter_inc_sigma_list = 0; - PyObject *__pyx_v_param_arr = 0; - PyObject *__pyx_v_lai_X0 = 0; - PyObject *__pyx_v_test_err_image_path = 0; - PyObject *__pyx_v_draw_flag = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("test_WMCModel (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lai_waiter_inc_sigma_list,&__pyx_n_s_param_arr,&__pyx_n_s_lai_X0,&__pyx_n_s_test_err_image_path,&__pyx_n_s_draw_flag,0}; - PyObject* values[5] = {0,0,0,0,0}; - values[4] = ((PyObject *)Py_True); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lai_waiter_inc_sigma_list)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_param_arr)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("test_WMCModel", 0, 4, 5, 1); __PYX_ERR(0, 82, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lai_X0)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("test_WMCModel", 0, 4, 5, 2); __PYX_ERR(0, 82, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 3: - if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_test_err_image_path)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("test_WMCModel", 0, 4, 5, 3); __PYX_ERR(0, 82, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 4: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_draw_flag); - if (value) { values[4] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "test_WMCModel") < 0)) __PYX_ERR(0, 82, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_lai_waiter_inc_sigma_list = values[0]; - __pyx_v_param_arr = values[1]; - __pyx_v_lai_X0 = values[2]; - __pyx_v_test_err_image_path = values[3]; - __pyx_v_draw_flag = values[4]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("test_WMCModel", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 82, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("LAIProcess.test_WMCModel", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10LAIProcess_4test_WMCModel(__pyx_self, __pyx_v_lai_waiter_inc_sigma_list, __pyx_v_param_arr, __pyx_v_lai_X0, __pyx_v_test_err_image_path, __pyx_v_draw_flag); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "LAIProcess.pyx":104 - * for lai_waiter_inc_sigma_item in lai_waiter_inc_sigma_list: - * sample_time,sample_code,sample_lon,sample_lat,sample_lai,csv_sigma,sample_soil,sample_inc,sample_sigma=lai_waiter_inc_sigma_item - * def f(X): # <<<<<<<<<<<<<< - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,sample_soil,sample_inc,csv_sigma)] - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10LAIProcess_13test_WMCModel_1f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_10LAIProcess_13test_WMCModel_1f = {"f", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10LAIProcess_13test_WMCModel_1f, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_10LAIProcess_13test_WMCModel_1f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_X = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("f (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_X,0}; - PyObject* values[1] = {0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_X)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f") < 0)) __PYX_ERR(0, 104, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - } - __pyx_v_X = values[0]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("f", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 104, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("LAIProcess.test_WMCModel.f", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10LAIProcess_13test_WMCModel_f(__pyx_self, __pyx_v_X); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10LAIProcess_13test_WMCModel_f(PyObject *__pyx_self, PyObject *__pyx_v_X) { - struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *__pyx_cur_scope; - struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *__pyx_outer_scope; - PyObject *__pyx_v_lai = NULL; - PyObject *__pyx_v_eqs = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("f", 0); - __pyx_outer_scope = (struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *) __Pyx_CyFunction_GetClosure(__pyx_self); - __pyx_cur_scope = __pyx_outer_scope; - - /* "LAIProcess.pyx":105 - * sample_time,sample_code,sample_lon,sample_lat,sample_lai,csv_sigma,sample_soil,sample_inc,sample_sigma=lai_waiter_inc_sigma_item - * def f(X): - * lai=X[0] # <<<<<<<<<<<<<< - * eqs=[WMCModel(param_arr,lai,sample_soil,sample_inc,csv_sigma)] - * return eqs - */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_X, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_lai = __pyx_t_1; - __pyx_t_1 = 0; - - /* "LAIProcess.pyx":106 - * def f(X): - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,sample_soil,sample_inc,csv_sigma)] # <<<<<<<<<<<<<< - * return eqs - * X0=lai_X0 - */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_WMCModel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(!__pyx_cur_scope->__pyx_v_param_arr)) { __Pyx_RaiseClosureNameError("param_arr"); __PYX_ERR(0, 106, __pyx_L1_error) } - if (unlikely(!__pyx_cur_scope->__pyx_v_sample_soil)) { __Pyx_RaiseClosureNameError("sample_soil"); __PYX_ERR(0, 106, __pyx_L1_error) } - if (unlikely(!__pyx_cur_scope->__pyx_v_sample_inc)) { __Pyx_RaiseClosureNameError("sample_inc"); __PYX_ERR(0, 106, __pyx_L1_error) } - if (unlikely(!__pyx_cur_scope->__pyx_v_csv_sigma)) { __Pyx_RaiseClosureNameError("csv_sigma"); __PYX_ERR(0, 106, __pyx_L1_error) } - __pyx_t_3 = NULL; - __pyx_t_4 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_4 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_param_arr, __pyx_v_lai, __pyx_cur_scope->__pyx_v_sample_soil, __pyx_cur_scope->__pyx_v_sample_inc, __pyx_cur_scope->__pyx_v_csv_sigma}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 5+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_param_arr, __pyx_v_lai, __pyx_cur_scope->__pyx_v_sample_soil, __pyx_cur_scope->__pyx_v_sample_inc, __pyx_cur_scope->__pyx_v_csv_sigma}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 5+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_5 = PyTuple_New(5+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; - } - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_param_arr); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_param_arr); - PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_cur_scope->__pyx_v_param_arr); - __Pyx_INCREF(__pyx_v_lai); - __Pyx_GIVEREF(__pyx_v_lai); - PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_lai); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sample_soil); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sample_soil); - PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_cur_scope->__pyx_v_sample_soil); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sample_inc); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sample_inc); - PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_cur_scope->__pyx_v_sample_inc); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_csv_sigma); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_csv_sigma); - PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_cur_scope->__pyx_v_csv_sigma); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_v_eqs = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - - /* "LAIProcess.pyx":107 - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,sample_soil,sample_inc,csv_sigma)] - * return eqs # <<<<<<<<<<<<<< - * X0=lai_X0 - * h = leastsq(f, X0) - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_eqs); - __pyx_r = __pyx_v_eqs; - goto __pyx_L0; - - /* "LAIProcess.pyx":104 - * for lai_waiter_inc_sigma_item in lai_waiter_inc_sigma_list: - * sample_time,sample_code,sample_lon,sample_lat,sample_lai,csv_sigma,sample_soil,sample_inc,sample_sigma=lai_waiter_inc_sigma_item - * def f(X): # <<<<<<<<<<<<<< - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,sample_soil,sample_inc,csv_sigma)] - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("LAIProcess.test_WMCModel.f", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_lai); - __Pyx_XDECREF(__pyx_v_eqs); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "LAIProcess.pyx":82 - * return h[0] - * - * def test_WMCModel(lai_waiter_inc_sigma_list,param_arr,lai_X0,test_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ - -static PyObject *__pyx_pf_10LAIProcess_4test_WMCModel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_lai_waiter_inc_sigma_list, PyObject *__pyx_v_param_arr, PyObject *__pyx_v_lai_X0, PyObject *__pyx_v_test_err_image_path, PyObject *__pyx_v_draw_flag) { - struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *__pyx_cur_scope; - PyObject *__pyx_v_err = NULL; - PyObject *__pyx_v_err_f = NULL; - PyObject *__pyx_v_x_arr = NULL; - PyObject *__pyx_v_err_lai = NULL; - PyObject *__pyx_v_lai_waiter_inc_sigma_item = NULL; - CYTHON_UNUSED PyObject *__pyx_v_sample_time = NULL; - PyObject *__pyx_v_sample_code = NULL; - CYTHON_UNUSED PyObject *__pyx_v_sample_lon = NULL; - CYTHON_UNUSED PyObject *__pyx_v_sample_lat = NULL; - PyObject *__pyx_v_sample_lai = NULL; - CYTHON_UNUSED PyObject *__pyx_v_sample_sigma = NULL; - PyObject *__pyx_v_f = 0; - PyObject *__pyx_v_X0 = NULL; - PyObject *__pyx_v_h = NULL; - PyObject *__pyx_v_temp_err = NULL; - PyObject *__pyx_v_plt = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *(*__pyx_t_3)(PyObject *); - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - PyObject *(*__pyx_t_14)(PyObject *); - int __pyx_t_15; - int __pyx_t_16; - int __pyx_t_17; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("test_WMCModel", 0); - __pyx_cur_scope = (struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *)__pyx_tp_new_10LAIProcess___pyx_scope_struct_1_test_WMCModel(__pyx_ptype_10LAIProcess___pyx_scope_struct_1_test_WMCModel, __pyx_empty_tuple, NULL); - if (unlikely(!__pyx_cur_scope)) { - __pyx_cur_scope = ((struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *)Py_None); - __Pyx_INCREF(Py_None); - __PYX_ERR(0, 82, __pyx_L1_error) - } else { - __Pyx_GOTREF(__pyx_cur_scope); - } - __pyx_cur_scope->__pyx_v_param_arr = __pyx_v_param_arr; - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_param_arr); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_param_arr); - - /* "LAIProcess.pyx":98 - * list: [sample_lai,err,predict] - * """ - * err=[] # <<<<<<<<<<<<<< - * err_f=[] - * x_arr=[] - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_err = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "LAIProcess.pyx":99 - * """ - * err=[] - * err_f=[] # <<<<<<<<<<<<<< - * x_arr=[] - * err_lai=[] - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_err_f = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "LAIProcess.pyx":100 - * err=[] - * err_f=[] - * x_arr=[] # <<<<<<<<<<<<<< - * err_lai=[] - * for lai_waiter_inc_sigma_item in lai_waiter_inc_sigma_list: - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_x_arr = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "LAIProcess.pyx":101 - * err_f=[] - * x_arr=[] - * err_lai=[] # <<<<<<<<<<<<<< - * for lai_waiter_inc_sigma_item in lai_waiter_inc_sigma_list: - * sample_time,sample_code,sample_lon,sample_lat,sample_lai,csv_sigma,sample_soil,sample_inc,sample_sigma=lai_waiter_inc_sigma_item - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_err_lai = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "LAIProcess.pyx":102 - * x_arr=[] - * err_lai=[] - * for lai_waiter_inc_sigma_item in lai_waiter_inc_sigma_list: # <<<<<<<<<<<<<< - * sample_time,sample_code,sample_lon,sample_lat,sample_lai,csv_sigma,sample_soil,sample_inc,sample_sigma=lai_waiter_inc_sigma_item - * def f(X): - */ - if (likely(PyList_CheckExact(__pyx_v_lai_waiter_inc_sigma_list)) || PyTuple_CheckExact(__pyx_v_lai_waiter_inc_sigma_list)) { - __pyx_t_1 = __pyx_v_lai_waiter_inc_sigma_list; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - __pyx_t_3 = NULL; - } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_lai_waiter_inc_sigma_list); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 102, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_3)) { - if (likely(PyList_CheckExact(__pyx_t_1))) { - if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 102, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } else { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 102, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } - } else { - __pyx_t_4 = __pyx_t_3(__pyx_t_1); - if (unlikely(!__pyx_t_4)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 102, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF_SET(__pyx_v_lai_waiter_inc_sigma_item, __pyx_t_4); - __pyx_t_4 = 0; - - /* "LAIProcess.pyx":103 - * err_lai=[] - * for lai_waiter_inc_sigma_item in lai_waiter_inc_sigma_list: - * sample_time,sample_code,sample_lon,sample_lat,sample_lai,csv_sigma,sample_soil,sample_inc,sample_sigma=lai_waiter_inc_sigma_item # <<<<<<<<<<<<<< - * def f(X): - * lai=X[0] - */ - if ((likely(PyTuple_CheckExact(__pyx_v_lai_waiter_inc_sigma_item))) || (PyList_CheckExact(__pyx_v_lai_waiter_inc_sigma_item))) { - PyObject* sequence = __pyx_v_lai_waiter_inc_sigma_item; - Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); - if (unlikely(size != 9)) { - if (size > 9) __Pyx_RaiseTooManyValuesError(9); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 103, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); - __pyx_t_7 = PyTuple_GET_ITEM(sequence, 3); - __pyx_t_8 = PyTuple_GET_ITEM(sequence, 4); - __pyx_t_9 = PyTuple_GET_ITEM(sequence, 5); - __pyx_t_10 = PyTuple_GET_ITEM(sequence, 6); - __pyx_t_11 = PyTuple_GET_ITEM(sequence, 7); - __pyx_t_12 = PyTuple_GET_ITEM(sequence, 8); - } else { - __pyx_t_4 = PyList_GET_ITEM(sequence, 0); - __pyx_t_5 = PyList_GET_ITEM(sequence, 1); - __pyx_t_6 = PyList_GET_ITEM(sequence, 2); - __pyx_t_7 = PyList_GET_ITEM(sequence, 3); - __pyx_t_8 = PyList_GET_ITEM(sequence, 4); - __pyx_t_9 = PyList_GET_ITEM(sequence, 5); - __pyx_t_10 = PyList_GET_ITEM(sequence, 6); - __pyx_t_11 = PyList_GET_ITEM(sequence, 7); - __pyx_t_12 = PyList_GET_ITEM(sequence, 8); - } - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(__pyx_t_12); - #else - { - Py_ssize_t i; - PyObject** temps[9] = {&__pyx_t_4,&__pyx_t_5,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11,&__pyx_t_12}; - for (i=0; i < 9; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 103, __pyx_L1_error) - __Pyx_GOTREF(item); - *(temps[i]) = item; - } - } - #endif - } else { - Py_ssize_t index = -1; - PyObject** temps[9] = {&__pyx_t_4,&__pyx_t_5,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11,&__pyx_t_12}; - __pyx_t_13 = PyObject_GetIter(__pyx_v_lai_waiter_inc_sigma_item); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 103, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext; - for (index=0; index < 9; index++) { - PyObject* item = __pyx_t_14(__pyx_t_13); if (unlikely(!item)) goto __pyx_L5_unpacking_failed; - __Pyx_GOTREF(item); - *(temps[index]) = item; - } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 9) < 0) __PYX_ERR(0, 103, __pyx_L1_error) - __pyx_t_14 = NULL; - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - goto __pyx_L6_unpacking_done; - __pyx_L5_unpacking_failed:; - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __pyx_t_14 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 103, __pyx_L1_error) - __pyx_L6_unpacking_done:; - } - __Pyx_XDECREF_SET(__pyx_v_sample_time, __pyx_t_4); - __pyx_t_4 = 0; - __Pyx_XDECREF_SET(__pyx_v_sample_code, __pyx_t_5); - __pyx_t_5 = 0; - __Pyx_XDECREF_SET(__pyx_v_sample_lon, __pyx_t_6); - __pyx_t_6 = 0; - __Pyx_XDECREF_SET(__pyx_v_sample_lat, __pyx_t_7); - __pyx_t_7 = 0; - __Pyx_XDECREF_SET(__pyx_v_sample_lai, __pyx_t_8); - __pyx_t_8 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_csv_sigma); - __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_csv_sigma, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - __pyx_t_9 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sample_soil); - __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_sample_soil, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_t_10 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sample_inc); - __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_sample_inc, __pyx_t_11); - __Pyx_GIVEREF(__pyx_t_11); - __pyx_t_11 = 0; - __Pyx_XDECREF_SET(__pyx_v_sample_sigma, __pyx_t_12); - __pyx_t_12 = 0; - - /* "LAIProcess.pyx":104 - * for lai_waiter_inc_sigma_item in lai_waiter_inc_sigma_list: - * sample_time,sample_code,sample_lon,sample_lat,sample_lai,csv_sigma,sample_soil,sample_inc,sample_sigma=lai_waiter_inc_sigma_item - * def f(X): # <<<<<<<<<<<<<< - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,sample_soil,sample_inc,csv_sigma)] - */ - __pyx_t_12 = __Pyx_CyFunction_New(&__pyx_mdef_10LAIProcess_13test_WMCModel_1f, 0, __pyx_n_s_test_WMCModel_locals_f, ((PyObject*)__pyx_cur_scope), __pyx_n_s_LAIProcess, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_XDECREF_SET(__pyx_v_f, __pyx_t_12); - __pyx_t_12 = 0; - - /* "LAIProcess.pyx":108 - * eqs=[WMCModel(param_arr,lai,sample_soil,sample_inc,csv_sigma)] - * return eqs - * X0=lai_X0 # <<<<<<<<<<<<<< - * h = leastsq(f, X0) - * temp_err=h[0]-sample_lai - */ - __Pyx_INCREF(__pyx_v_lai_X0); - __Pyx_XDECREF_SET(__pyx_v_X0, __pyx_v_lai_X0); - - /* "LAIProcess.pyx":109 - * return eqs - * X0=lai_X0 - * h = leastsq(f, X0) # <<<<<<<<<<<<<< - * temp_err=h[0]-sample_lai - * err_lai.append(temp_err[0]) # lai - */ - __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_leastsq); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_10 = NULL; - __pyx_t_15 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); - if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_11, function); - __pyx_t_15 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_f, __pyx_v_X0}; - __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_12); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_f, __pyx_v_X0}; - __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_12); - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_10) { - __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL; - } - __Pyx_INCREF(__pyx_v_f); - __Pyx_GIVEREF(__pyx_v_f); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_15, __pyx_v_f); - __Pyx_INCREF(__pyx_v_X0); - __Pyx_GIVEREF(__pyx_v_X0); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_15, __pyx_v_X0); - __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_XDECREF_SET(__pyx_v_h, __pyx_t_12); - __pyx_t_12 = 0; - - /* "LAIProcess.pyx":110 - * X0=lai_X0 - * h = leastsq(f, X0) - * temp_err=h[0]-sample_lai # <<<<<<<<<<<<<< - * err_lai.append(temp_err[0]) # lai - * err.append([sample_lai,temp_err[0],h[0][0],sample_code]) - */ - __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_h, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 110, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_11 = PyNumber_Subtract(__pyx_t_12, __pyx_v_sample_lai); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 110, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_XDECREF_SET(__pyx_v_temp_err, __pyx_t_11); - __pyx_t_11 = 0; - - /* "LAIProcess.pyx":111 - * h = leastsq(f, X0) - * temp_err=h[0]-sample_lai - * err_lai.append(temp_err[0]) # lai # <<<<<<<<<<<<<< - * err.append([sample_lai,temp_err[0],h[0][0],sample_code]) - * err_f.append(f(h[0])[0]) # - */ - __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_temp_err, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_err_lai, __pyx_t_11); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - - /* "LAIProcess.pyx":112 - * temp_err=h[0]-sample_lai - * err_lai.append(temp_err[0]) # lai - * err.append([sample_lai,temp_err[0],h[0][0],sample_code]) # <<<<<<<<<<<<<< - * err_f.append(f(h[0])[0]) # - * x_arr.append(sample_lai) - */ - __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_temp_err, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_h, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_12, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_12 = PyList_New(4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_INCREF(__pyx_v_sample_lai); - __Pyx_GIVEREF(__pyx_v_sample_lai); - PyList_SET_ITEM(__pyx_t_12, 0, __pyx_v_sample_lai); - __Pyx_GIVEREF(__pyx_t_11); - PyList_SET_ITEM(__pyx_t_12, 1, __pyx_t_11); - __Pyx_GIVEREF(__pyx_t_9); - PyList_SET_ITEM(__pyx_t_12, 2, __pyx_t_9); - __Pyx_INCREF(__pyx_v_sample_code); - __Pyx_GIVEREF(__pyx_v_sample_code); - PyList_SET_ITEM(__pyx_t_12, 3, __pyx_v_sample_code); - __pyx_t_11 = 0; - __pyx_t_9 = 0; - __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_err, __pyx_t_12); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - - /* "LAIProcess.pyx":113 - * err_lai.append(temp_err[0]) # lai - * err.append([sample_lai,temp_err[0],h[0][0],sample_code]) - * err_f.append(f(h[0])[0]) # # <<<<<<<<<<<<<< - * x_arr.append(sample_lai) - * - */ - __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_h, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_9 = __pyx_pf_10LAIProcess_13test_WMCModel_f(__pyx_v_f, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_9, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_err_f, __pyx_t_12); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 113, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - - /* "LAIProcess.pyx":114 - * err.append([sample_lai,temp_err[0],h[0][0],sample_code]) - * err_f.append(f(h[0])[0]) # - * x_arr.append(sample_lai) # <<<<<<<<<<<<<< - * - * # - */ - __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_x_arr, __pyx_v_sample_lai); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 114, __pyx_L1_error) - - /* "LAIProcess.pyx":102 - * x_arr=[] - * err_lai=[] - * for lai_waiter_inc_sigma_item in lai_waiter_inc_sigma_list: # <<<<<<<<<<<<<< - * sample_time,sample_code,sample_lon,sample_lat,sample_lai,csv_sigma,sample_soil,sample_inc,sample_sigma=lai_waiter_inc_sigma_item - * def f(X): - */ - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "LAIProcess.pyx":122 - * # logger.info("\n\n") - * - * if draw_flag: # <<<<<<<<<<<<<< - * from matplotlib import pyplot as plt - * plt.scatter(x_arr,err_lai) - */ - __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_v_draw_flag); if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 122, __pyx_L1_error) - if (__pyx_t_17) { - - /* "LAIProcess.pyx":123 - * - * if draw_flag: - * from matplotlib import pyplot as plt # <<<<<<<<<<<<<< - * plt.scatter(x_arr,err_lai) - * plt.title("equation-err") - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_pyplot); - __Pyx_GIVEREF(__pyx_n_s_pyplot); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_pyplot); - __pyx_t_12 = __Pyx_Import(__pyx_n_s_matplotlib, __pyx_t_1, -1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 123, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_12, __pyx_n_s_pyplot); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_t_1); - __pyx_v_plt = __pyx_t_1; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - - /* "LAIProcess.pyx":124 - * if draw_flag: - * from matplotlib import pyplot as plt - * plt.scatter(x_arr,err_lai) # <<<<<<<<<<<<<< - * plt.title("equation-err") - * plt.savefig(test_err_image_path,dpi=600) - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_scatter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = NULL; - __pyx_t_15 = 0; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - __pyx_t_15 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_x_arr, __pyx_v_err_lai}; - __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 124, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_12); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_x_arr, __pyx_v_err_lai}; - __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 124, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_12); - } else - #endif - { - __pyx_t_11 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 124, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - if (__pyx_t_9) { - __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; - } - __Pyx_INCREF(__pyx_v_x_arr); - __Pyx_GIVEREF(__pyx_v_x_arr); - PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_15, __pyx_v_x_arr); - __Pyx_INCREF(__pyx_v_err_lai); - __Pyx_GIVEREF(__pyx_v_err_lai); - PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_15, __pyx_v_err_lai); - __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 124, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - - /* "LAIProcess.pyx":125 - * from matplotlib import pyplot as plt - * plt.scatter(x_arr,err_lai) - * plt.title("equation-err") # <<<<<<<<<<<<<< - * plt.savefig(test_err_image_path,dpi=600) - * plt.show() - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_title); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_12 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_11, __pyx_kp_s_equation_err) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_kp_s_equation_err); - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 125, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - - /* "LAIProcess.pyx":126 - * plt.scatter(x_arr,err_lai) - * plt.title("equation-err") - * plt.savefig(test_err_image_path,dpi=600) # <<<<<<<<<<<<<< - * plt.show() - * return err - */ - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_savefig); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_v_test_err_image_path); - __Pyx_GIVEREF(__pyx_v_test_err_image_path); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_test_err_image_path); - __pyx_t_11 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dpi, __pyx_int_600) < 0) __PYX_ERR(0, 126, __pyx_L1_error) - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_1, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "LAIProcess.pyx":127 - * plt.title("equation-err") - * plt.savefig(test_err_image_path,dpi=600) - * plt.show() # <<<<<<<<<<<<<< - * return err - * - */ - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_show); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 127, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); - if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_11, function); - } - } - __pyx_t_9 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_11); - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 127, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "LAIProcess.pyx":122 - * # logger.info("\n\n") - * - * if draw_flag: # <<<<<<<<<<<<<< - * from matplotlib import pyplot as plt - * plt.scatter(x_arr,err_lai) - */ - } - - /* "LAIProcess.pyx":128 - * plt.savefig(test_err_image_path,dpi=600) - * plt.show() - * return err # <<<<<<<<<<<<<< - * - * def processs_WMCModel(param_arr,lai_X0,sigma,inc_angle,soil_water): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_err); - __pyx_r = __pyx_v_err; - goto __pyx_L0; - - /* "LAIProcess.pyx":82 - * return h[0] - * - * def test_WMCModel(lai_waiter_inc_sigma_list,param_arr,lai_X0,test_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_XDECREF(__pyx_t_12); - __Pyx_XDECREF(__pyx_t_13); - __Pyx_AddTraceback("LAIProcess.test_WMCModel", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_err); - __Pyx_XDECREF(__pyx_v_err_f); - __Pyx_XDECREF(__pyx_v_x_arr); - __Pyx_XDECREF(__pyx_v_err_lai); - __Pyx_XDECREF(__pyx_v_lai_waiter_inc_sigma_item); - __Pyx_XDECREF(__pyx_v_sample_time); - __Pyx_XDECREF(__pyx_v_sample_code); - __Pyx_XDECREF(__pyx_v_sample_lon); - __Pyx_XDECREF(__pyx_v_sample_lat); - __Pyx_XDECREF(__pyx_v_sample_lai); - __Pyx_XDECREF(__pyx_v_sample_sigma); - __Pyx_XDECREF(__pyx_v_f); - __Pyx_XDECREF(__pyx_v_X0); - __Pyx_XDECREF(__pyx_v_h); - __Pyx_XDECREF(__pyx_v_temp_err); - __Pyx_XDECREF(__pyx_v_plt); - __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "LAIProcess.pyx":130 - * return err - * - * def processs_WMCModel(param_arr,lai_X0,sigma,inc_angle,soil_water): # <<<<<<<<<<<<<< - * - * if(sigma<0 ): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10LAIProcess_7processs_WMCModel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_10LAIProcess_7processs_WMCModel = {"processs_WMCModel", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10LAIProcess_7processs_WMCModel, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_10LAIProcess_7processs_WMCModel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_param_arr = 0; - PyObject *__pyx_v_lai_X0 = 0; - PyObject *__pyx_v_sigma = 0; - PyObject *__pyx_v_inc_angle = 0; - PyObject *__pyx_v_soil_water = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("processs_WMCModel (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_param_arr,&__pyx_n_s_lai_X0,&__pyx_n_s_sigma,&__pyx_n_s_inc_angle,&__pyx_n_s_soil_water,0}; - PyObject* values[5] = {0,0,0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_param_arr)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lai_X0)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("processs_WMCModel", 1, 5, 5, 1); __PYX_ERR(0, 130, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("processs_WMCModel", 1, 5, 5, 2); __PYX_ERR(0, 130, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 3: - if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inc_angle)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("processs_WMCModel", 1, 5, 5, 3); __PYX_ERR(0, 130, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 4: - if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_soil_water)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("processs_WMCModel", 1, 5, 5, 4); __PYX_ERR(0, 130, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "processs_WMCModel") < 0)) __PYX_ERR(0, 130, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - } - __pyx_v_param_arr = values[0]; - __pyx_v_lai_X0 = values[1]; - __pyx_v_sigma = values[2]; - __pyx_v_inc_angle = values[3]; - __pyx_v_soil_water = values[4]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("processs_WMCModel", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 130, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("LAIProcess.processs_WMCModel", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10LAIProcess_6processs_WMCModel(__pyx_self, __pyx_v_param_arr, __pyx_v_lai_X0, __pyx_v_sigma, __pyx_v_inc_angle, __pyx_v_soil_water); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "LAIProcess.pyx":134 - * if(sigma<0 ): - * return np.nan - * def f(X): # <<<<<<<<<<<<<< - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,soil_water,inc_angle,sigma )] - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10LAIProcess_17processs_WMCModel_1f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_10LAIProcess_17processs_WMCModel_1f = {"f", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10LAIProcess_17processs_WMCModel_1f, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_10LAIProcess_17processs_WMCModel_1f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_X = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("f (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_X,0}; - PyObject* values[1] = {0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_X)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f") < 0)) __PYX_ERR(0, 134, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - } - __pyx_v_X = values[0]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("f", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 134, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("LAIProcess.processs_WMCModel.f", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10LAIProcess_17processs_WMCModel_f(__pyx_self, __pyx_v_X); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10LAIProcess_17processs_WMCModel_f(PyObject *__pyx_self, PyObject *__pyx_v_X) { - struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *__pyx_cur_scope; - struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *__pyx_outer_scope; - PyObject *__pyx_v_lai = NULL; - PyObject *__pyx_v_eqs = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("f", 0); - __pyx_outer_scope = (struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *) __Pyx_CyFunction_GetClosure(__pyx_self); - __pyx_cur_scope = __pyx_outer_scope; - - /* "LAIProcess.pyx":135 - * return np.nan - * def f(X): - * lai=X[0] # <<<<<<<<<<<<<< - * eqs=[WMCModel(param_arr,lai,soil_water,inc_angle,sigma )] - * return eqs - */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_X, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_lai = __pyx_t_1; - __pyx_t_1 = 0; - - /* "LAIProcess.pyx":136 - * def f(X): - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,soil_water,inc_angle,sigma )] # <<<<<<<<<<<<<< - * return eqs - * h = leastsq(f, [lai_X0]) - */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_WMCModel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(!__pyx_cur_scope->__pyx_v_param_arr)) { __Pyx_RaiseClosureNameError("param_arr"); __PYX_ERR(0, 136, __pyx_L1_error) } - if (unlikely(!__pyx_cur_scope->__pyx_v_soil_water)) { __Pyx_RaiseClosureNameError("soil_water"); __PYX_ERR(0, 136, __pyx_L1_error) } - if (unlikely(!__pyx_cur_scope->__pyx_v_inc_angle)) { __Pyx_RaiseClosureNameError("inc_angle"); __PYX_ERR(0, 136, __pyx_L1_error) } - if (unlikely(!__pyx_cur_scope->__pyx_v_sigma)) { __Pyx_RaiseClosureNameError("sigma"); __PYX_ERR(0, 136, __pyx_L1_error) } - __pyx_t_3 = NULL; - __pyx_t_4 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_4 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_param_arr, __pyx_v_lai, __pyx_cur_scope->__pyx_v_soil_water, __pyx_cur_scope->__pyx_v_inc_angle, __pyx_cur_scope->__pyx_v_sigma}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 5+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_param_arr, __pyx_v_lai, __pyx_cur_scope->__pyx_v_soil_water, __pyx_cur_scope->__pyx_v_inc_angle, __pyx_cur_scope->__pyx_v_sigma}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 5+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_5 = PyTuple_New(5+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; - } - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_param_arr); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_param_arr); - PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_cur_scope->__pyx_v_param_arr); - __Pyx_INCREF(__pyx_v_lai); - __Pyx_GIVEREF(__pyx_v_lai); - PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_lai); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_soil_water); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_soil_water); - PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_cur_scope->__pyx_v_soil_water); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_inc_angle); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_inc_angle); - PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_cur_scope->__pyx_v_inc_angle); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sigma); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sigma); - PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_cur_scope->__pyx_v_sigma); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_v_eqs = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - - /* "LAIProcess.pyx":137 - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,soil_water,inc_angle,sigma )] - * return eqs # <<<<<<<<<<<<<< - * h = leastsq(f, [lai_X0]) - * - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_eqs); - __pyx_r = __pyx_v_eqs; - goto __pyx_L0; - - /* "LAIProcess.pyx":134 - * if(sigma<0 ): - * return np.nan - * def f(X): # <<<<<<<<<<<<<< - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,soil_water,inc_angle,sigma )] - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("LAIProcess.processs_WMCModel.f", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_lai); - __Pyx_XDECREF(__pyx_v_eqs); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "LAIProcess.pyx":130 - * return err - * - * def processs_WMCModel(param_arr,lai_X0,sigma,inc_angle,soil_water): # <<<<<<<<<<<<<< - * - * if(sigma<0 ): - */ - -static PyObject *__pyx_pf_10LAIProcess_6processs_WMCModel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_param_arr, PyObject *__pyx_v_lai_X0, PyObject *__pyx_v_sigma, PyObject *__pyx_v_inc_angle, PyObject *__pyx_v_soil_water) { - struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *__pyx_cur_scope; - PyObject *__pyx_v_f = 0; - PyObject *__pyx_v_h = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; - PyObject *__pyx_t_7 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("processs_WMCModel", 0); - __pyx_cur_scope = (struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *)__pyx_tp_new_10LAIProcess___pyx_scope_struct_2_processs_WMCModel(__pyx_ptype_10LAIProcess___pyx_scope_struct_2_processs_WMCModel, __pyx_empty_tuple, NULL); - if (unlikely(!__pyx_cur_scope)) { - __pyx_cur_scope = ((struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *)Py_None); - __Pyx_INCREF(Py_None); - __PYX_ERR(0, 130, __pyx_L1_error) - } else { - __Pyx_GOTREF(__pyx_cur_scope); - } - __pyx_cur_scope->__pyx_v_param_arr = __pyx_v_param_arr; - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_param_arr); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_param_arr); - __pyx_cur_scope->__pyx_v_sigma = __pyx_v_sigma; - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sigma); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sigma); - __pyx_cur_scope->__pyx_v_inc_angle = __pyx_v_inc_angle; - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_inc_angle); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_inc_angle); - __pyx_cur_scope->__pyx_v_soil_water = __pyx_v_soil_water; - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_soil_water); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_soil_water); - - /* "LAIProcess.pyx":132 - * def processs_WMCModel(param_arr,lai_X0,sigma,inc_angle,soil_water): - * - * if(sigma<0 ): # <<<<<<<<<<<<<< - * return np.nan - * def f(X): - */ - __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_sigma, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_2) { - - /* "LAIProcess.pyx":133 - * - * if(sigma<0 ): - * return np.nan # <<<<<<<<<<<<<< - * def f(X): - * lai=X[0] - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "LAIProcess.pyx":132 - * def processs_WMCModel(param_arr,lai_X0,sigma,inc_angle,soil_water): - * - * if(sigma<0 ): # <<<<<<<<<<<<<< - * return np.nan - * def f(X): - */ - } - - /* "LAIProcess.pyx":134 - * if(sigma<0 ): - * return np.nan - * def f(X): # <<<<<<<<<<<<<< - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,soil_water,inc_angle,sigma )] - */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_10LAIProcess_17processs_WMCModel_1f, 0, __pyx_n_s_processs_WMCModel_locals_f, ((PyObject*)__pyx_cur_scope), __pyx_n_s_LAIProcess, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_v_f = __pyx_t_3; - __pyx_t_3 = 0; - - /* "LAIProcess.pyx":138 - * eqs=[WMCModel(param_arr,lai,soil_water,inc_angle,sigma )] - * return eqs - * h = leastsq(f, [lai_X0]) # <<<<<<<<<<<<<< - * - * return h[0][0] - */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_leastsq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(__pyx_v_lai_X0); - __Pyx_GIVEREF(__pyx_v_lai_X0); - PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_lai_X0); - __pyx_t_5 = NULL; - __pyx_t_6 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - __pyx_t_6 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_f, __pyx_t_4}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_f, __pyx_t_4}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_v_f); - __Pyx_GIVEREF(__pyx_v_f); - PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_f); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_h = __pyx_t_3; - __pyx_t_3 = 0; - - /* "LAIProcess.pyx":140 - * h = leastsq(f, [lai_X0]) - * - * return h[0][0] # <<<<<<<<<<<<<< - * - * # Cython - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_h, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "LAIProcess.pyx":130 - * return err - * - * def processs_WMCModel(param_arr,lai_X0,sigma,inc_angle,soil_water): # <<<<<<<<<<<<<< - * - * if(sigma<0 ): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_AddTraceback("LAIProcess.processs_WMCModel", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_f); - __Pyx_XDECREF(__pyx_v_h); - __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "LAIProcess.pyx":143 - * - * # Cython - * cpdef np.ndarray[double,ndim=2] process_tiff(np.ndarray[double,ndim=2] sigma_tiff, # <<<<<<<<<<<<<< - * np.ndarray[double,ndim=2] inc_tiff, - * np.ndarray[double,ndim=2] soil_water_tiff, - */ - -static PyObject *__pyx_pw_10LAIProcess_9process_tiff(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyArrayObject *__pyx_f_10LAIProcess_process_tiff(PyArrayObject *__pyx_v_sigma_tiff, PyArrayObject *__pyx_v_inc_tiff, PyArrayObject *__pyx_v_soil_water_tiff, PyArrayObject *__pyx_v_param_arr, double __pyx_v_lai_X0, CYTHON_UNUSED int __pyx_skip_dispatch) { - PyArrayObject *__pyx_v_result = 0; - CYTHON_UNUSED int __pyx_v_param_arr_length; - int __pyx_v_height; - int __pyx_v_width; - int __pyx_v_i; - int __pyx_v_j; - double __pyx_v_temp; - __Pyx_LocalBuf_ND __pyx_pybuffernd_inc_tiff; - __Pyx_Buffer __pyx_pybuffer_inc_tiff; - __Pyx_LocalBuf_ND __pyx_pybuffernd_param_arr; - __Pyx_Buffer __pyx_pybuffer_param_arr; - __Pyx_LocalBuf_ND __pyx_pybuffernd_result; - __Pyx_Buffer __pyx_pybuffer_result; - __Pyx_LocalBuf_ND __pyx_pybuffernd_sigma_tiff; - __Pyx_Buffer __pyx_pybuffer_sigma_tiff; - __Pyx_LocalBuf_ND __pyx_pybuffernd_soil_water_tiff; - __Pyx_Buffer __pyx_pybuffer_soil_water_tiff; - PyArrayObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - Py_ssize_t __pyx_t_5; - Py_ssize_t __pyx_t_6; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - double __pyx_t_13; - int __pyx_t_14; - double __pyx_t_15; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("process_tiff", 0); - __pyx_pybuffer_result.pybuffer.buf = NULL; - __pyx_pybuffer_result.refcount = 0; - __pyx_pybuffernd_result.data = NULL; - __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result; - __pyx_pybuffer_sigma_tiff.pybuffer.buf = NULL; - __pyx_pybuffer_sigma_tiff.refcount = 0; - __pyx_pybuffernd_sigma_tiff.data = NULL; - __pyx_pybuffernd_sigma_tiff.rcbuffer = &__pyx_pybuffer_sigma_tiff; - __pyx_pybuffer_inc_tiff.pybuffer.buf = NULL; - __pyx_pybuffer_inc_tiff.refcount = 0; - __pyx_pybuffernd_inc_tiff.data = NULL; - __pyx_pybuffernd_inc_tiff.rcbuffer = &__pyx_pybuffer_inc_tiff; - __pyx_pybuffer_soil_water_tiff.pybuffer.buf = NULL; - __pyx_pybuffer_soil_water_tiff.refcount = 0; - __pyx_pybuffernd_soil_water_tiff.data = NULL; - __pyx_pybuffernd_soil_water_tiff.rcbuffer = &__pyx_pybuffer_soil_water_tiff; - __pyx_pybuffer_param_arr.pybuffer.buf = NULL; - __pyx_pybuffer_param_arr.refcount = 0; - __pyx_pybuffernd_param_arr.data = NULL; - __pyx_pybuffernd_param_arr.rcbuffer = &__pyx_pybuffer_param_arr; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer, (PyObject*)__pyx_v_sigma_tiff, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 143, __pyx_L1_error) - } - __pyx_pybuffernd_sigma_tiff.diminfo[0].strides = __pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sigma_tiff.diminfo[0].shape = __pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_sigma_tiff.diminfo[1].strides = __pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_sigma_tiff.diminfo[1].shape = __pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer, (PyObject*)__pyx_v_inc_tiff, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 143, __pyx_L1_error) - } - __pyx_pybuffernd_inc_tiff.diminfo[0].strides = __pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_inc_tiff.diminfo[0].shape = __pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_inc_tiff.diminfo[1].strides = __pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_inc_tiff.diminfo[1].shape = __pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer, (PyObject*)__pyx_v_soil_water_tiff, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 143, __pyx_L1_error) - } - __pyx_pybuffernd_soil_water_tiff.diminfo[0].strides = __pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_soil_water_tiff.diminfo[0].shape = __pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_soil_water_tiff.diminfo[1].strides = __pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_soil_water_tiff.diminfo[1].shape = __pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_param_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_param_arr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 143, __pyx_L1_error) - } - __pyx_pybuffernd_param_arr.diminfo[0].strides = __pyx_pybuffernd_param_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_param_arr.diminfo[0].shape = __pyx_pybuffernd_param_arr.rcbuffer->pybuffer.shape[0]; - - /* "LAIProcess.pyx":149 - * double lai_X0): - * - * cdef np.ndarray[double,ndim=2] result=sigma_tiff # <<<<<<<<<<<<<< - * cdef int param_arr_length=param_arr.shape[0] - * cdef int height=sigma_tiff.shape[0] - */ - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_sigma_tiff), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { - __pyx_v_result = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_result.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 149, __pyx_L1_error) - } else {__pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_result.diminfo[1].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_result.diminfo[1].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[1]; - } - } - __Pyx_INCREF(((PyObject *)__pyx_v_sigma_tiff)); - __pyx_v_result = ((PyArrayObject *)__pyx_v_sigma_tiff); - - /* "LAIProcess.pyx":150 - * - * cdef np.ndarray[double,ndim=2] result=sigma_tiff - * cdef int param_arr_length=param_arr.shape[0] # <<<<<<<<<<<<<< - * cdef int height=sigma_tiff.shape[0] - * cdef int width=sigma_tiff.shape[1] - */ - __pyx_v_param_arr_length = (__pyx_v_param_arr->dimensions[0]); - - /* "LAIProcess.pyx":151 - * cdef np.ndarray[double,ndim=2] result=sigma_tiff - * cdef int param_arr_length=param_arr.shape[0] - * cdef int height=sigma_tiff.shape[0] # <<<<<<<<<<<<<< - * cdef int width=sigma_tiff.shape[1] - * cdef int i=0 - */ - __pyx_v_height = (__pyx_v_sigma_tiff->dimensions[0]); - - /* "LAIProcess.pyx":152 - * cdef int param_arr_length=param_arr.shape[0] - * cdef int height=sigma_tiff.shape[0] - * cdef int width=sigma_tiff.shape[1] # <<<<<<<<<<<<<< - * cdef int i=0 - * cdef int j=0 - */ - __pyx_v_width = (__pyx_v_sigma_tiff->dimensions[1]); - - /* "LAIProcess.pyx":153 - * cdef int height=sigma_tiff.shape[0] - * cdef int width=sigma_tiff.shape[1] - * cdef int i=0 # <<<<<<<<<<<<<< - * cdef int j=0 - * cdef double temp=0 - */ - __pyx_v_i = 0; - - /* "LAIProcess.pyx":154 - * cdef int width=sigma_tiff.shape[1] - * cdef int i=0 - * cdef int j=0 # <<<<<<<<<<<<<< - * cdef double temp=0 - * - */ - __pyx_v_j = 0; - - /* "LAIProcess.pyx":155 - * cdef int i=0 - * cdef int j=0 - * cdef double temp=0 # <<<<<<<<<<<<<< - * - * while i=0 else np.nan - */ - while (1) { - __pyx_t_1 = ((__pyx_v_j < __pyx_v_width) != 0); - if (!__pyx_t_1) break; - - /* "LAIProcess.pyx":160 - * j=0 - * while j=0 else np.nan - * result[i,j]=temp - */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_processs_WMCModel); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_lai_X0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __pyx_v_i; - __pyx_t_6 = __pyx_v_j; - __pyx_t_7 = -1; - if (__pyx_t_5 < 0) { - __pyx_t_5 += __pyx_pybuffernd_sigma_tiff.diminfo[0].shape; - if (unlikely(__pyx_t_5 < 0)) __pyx_t_7 = 0; - } else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_sigma_tiff.diminfo[0].shape)) __pyx_t_7 = 0; - if (__pyx_t_6 < 0) { - __pyx_t_6 += __pyx_pybuffernd_sigma_tiff.diminfo[1].shape; - if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 1; - } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_sigma_tiff.diminfo[1].shape)) __pyx_t_7 = 1; - if (unlikely(__pyx_t_7 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 160, __pyx_L1_error) - } - __pyx_t_8 = PyFloat_FromDouble((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_sigma_tiff.diminfo[0].strides, __pyx_t_6, __pyx_pybuffernd_sigma_tiff.diminfo[1].strides))); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = __pyx_v_i; - __pyx_t_5 = __pyx_v_j; - __pyx_t_7 = -1; - if (__pyx_t_6 < 0) { - __pyx_t_6 += __pyx_pybuffernd_inc_tiff.diminfo[0].shape; - if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 0; - } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_inc_tiff.diminfo[0].shape)) __pyx_t_7 = 0; - if (__pyx_t_5 < 0) { - __pyx_t_5 += __pyx_pybuffernd_inc_tiff.diminfo[1].shape; - if (unlikely(__pyx_t_5 < 0)) __pyx_t_7 = 1; - } else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_inc_tiff.diminfo[1].shape)) __pyx_t_7 = 1; - if (unlikely(__pyx_t_7 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 160, __pyx_L1_error) - } - __pyx_t_9 = PyFloat_FromDouble((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_inc_tiff.diminfo[0].strides, __pyx_t_5, __pyx_pybuffernd_inc_tiff.diminfo[1].strides))); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = __pyx_v_i; - __pyx_t_6 = __pyx_v_j; - __pyx_t_7 = -1; - if (__pyx_t_5 < 0) { - __pyx_t_5 += __pyx_pybuffernd_soil_water_tiff.diminfo[0].shape; - if (unlikely(__pyx_t_5 < 0)) __pyx_t_7 = 0; - } else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_soil_water_tiff.diminfo[0].shape)) __pyx_t_7 = 0; - if (__pyx_t_6 < 0) { - __pyx_t_6 += __pyx_pybuffernd_soil_water_tiff.diminfo[1].shape; - if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 1; - } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_soil_water_tiff.diminfo[1].shape)) __pyx_t_7 = 1; - if (unlikely(__pyx_t_7 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 160, __pyx_L1_error) - } - __pyx_t_10 = PyFloat_FromDouble((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_soil_water_tiff.diminfo[0].strides, __pyx_t_6, __pyx_pybuffernd_soil_water_tiff.diminfo[1].strides))); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[6] = {__pyx_t_11, ((PyObject *)__pyx_v_param_arr), __pyx_t_4, __pyx_t_8, __pyx_t_9, __pyx_t_10}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[6] = {__pyx_t_11, ((PyObject *)__pyx_v_param_arr), __pyx_t_4, __pyx_t_8, __pyx_t_9, __pyx_t_10}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - #endif - { - __pyx_t_12 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - if (__pyx_t_11) { - __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL; - } - __Pyx_INCREF(((PyObject *)__pyx_v_param_arr)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_param_arr)); - PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_7, ((PyObject *)__pyx_v_param_arr)); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_7, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_7, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_7, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_7, __pyx_t_10); - __pyx_t_4 = 0; - __pyx_t_8 = 0; - __pyx_t_9 = 0; - __pyx_t_10 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_temp = __pyx_t_13; - - /* "LAIProcess.pyx":161 - * while j=0 else np.nan # <<<<<<<<<<<<<< - * result[i,j]=temp - * j=j+1 - */ - __pyx_t_14 = ((__pyx_v_temp < 10.0) != 0); - if (__pyx_t_14) { - } else { - __pyx_t_1 = __pyx_t_14; - goto __pyx_L7_bool_binop_done; - } - __pyx_t_14 = ((__pyx_v_temp >= 0.0) != 0); - __pyx_t_1 = __pyx_t_14; - __pyx_L7_bool_binop_done:; - if (__pyx_t_1) { - __pyx_t_13 = __pyx_v_temp; - } else { - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_15 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_15 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_13 = __pyx_t_15; - } - __pyx_v_temp = __pyx_t_13; - - /* "LAIProcess.pyx":162 - * temp = processs_WMCModel(param_arr,lai_X0,sigma_tiff[i,j],inc_tiff[i,j],soil_water_tiff[i,j]) - * temp=temp if temp<10 and temp>=0 else np.nan - * result[i,j]=temp # <<<<<<<<<<<<<< - * j=j+1 - * i=i+1 - */ - __pyx_t_6 = __pyx_v_i; - __pyx_t_5 = __pyx_v_j; - __pyx_t_7 = -1; - if (__pyx_t_6 < 0) { - __pyx_t_6 += __pyx_pybuffernd_result.diminfo[0].shape; - if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 0; - } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_7 = 0; - if (__pyx_t_5 < 0) { - __pyx_t_5 += __pyx_pybuffernd_result.diminfo[1].shape; - if (unlikely(__pyx_t_5 < 0)) __pyx_t_7 = 1; - } else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_result.diminfo[1].shape)) __pyx_t_7 = 1; - if (unlikely(__pyx_t_7 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 162, __pyx_L1_error) - } - *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_result.diminfo[0].strides, __pyx_t_5, __pyx_pybuffernd_result.diminfo[1].strides) = __pyx_v_temp; - - /* "LAIProcess.pyx":163 - * temp=temp if temp<10 and temp>=0 else np.nan - * result[i,j]=temp - * j=j+1 # <<<<<<<<<<<<<< - * i=i+1 - * return result - */ - __pyx_v_j = (__pyx_v_j + 1); - } - - /* "LAIProcess.pyx":164 - * result[i,j]=temp - * j=j+1 - * i=i+1 # <<<<<<<<<<<<<< - * return result - * - */ - __pyx_v_i = (__pyx_v_i + 1); - } - - /* "LAIProcess.pyx":165 - * j=j+1 - * i=i+1 - * return result # <<<<<<<<<<<<<< - * - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyArrayObject *)__pyx_v_result); - goto __pyx_L0; - - /* "LAIProcess.pyx":143 - * - * # Cython - * cpdef np.ndarray[double,ndim=2] process_tiff(np.ndarray[double,ndim=2] sigma_tiff, # <<<<<<<<<<<<<< - * np.ndarray[double,ndim=2] inc_tiff, - * np.ndarray[double,ndim=2] soil_water_tiff, - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_XDECREF(__pyx_t_12); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_param_arr.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("LAIProcess.process_tiff", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_param_arr.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_10LAIProcess_9process_tiff(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_10LAIProcess_9process_tiff(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_sigma_tiff = 0; - PyArrayObject *__pyx_v_inc_tiff = 0; - PyArrayObject *__pyx_v_soil_water_tiff = 0; - PyArrayObject *__pyx_v_param_arr = 0; - double __pyx_v_lai_X0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("process_tiff (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sigma_tiff,&__pyx_n_s_inc_tiff,&__pyx_n_s_soil_water_tiff,&__pyx_n_s_param_arr,&__pyx_n_s_lai_X0,0}; - PyObject* values[5] = {0,0,0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma_tiff)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inc_tiff)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("process_tiff", 1, 5, 5, 1); __PYX_ERR(0, 143, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_soil_water_tiff)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("process_tiff", 1, 5, 5, 2); __PYX_ERR(0, 143, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 3: - if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_param_arr)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("process_tiff", 1, 5, 5, 3); __PYX_ERR(0, 143, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 4: - if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lai_X0)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("process_tiff", 1, 5, 5, 4); __PYX_ERR(0, 143, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "process_tiff") < 0)) __PYX_ERR(0, 143, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - } - __pyx_v_sigma_tiff = ((PyArrayObject *)values[0]); - __pyx_v_inc_tiff = ((PyArrayObject *)values[1]); - __pyx_v_soil_water_tiff = ((PyArrayObject *)values[2]); - __pyx_v_param_arr = ((PyArrayObject *)values[3]); - __pyx_v_lai_X0 = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_lai_X0 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 147, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("process_tiff", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 143, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("LAIProcess.process_tiff", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sigma_tiff), __pyx_ptype_5numpy_ndarray, 1, "sigma_tiff", 0))) __PYX_ERR(0, 143, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_inc_tiff), __pyx_ptype_5numpy_ndarray, 1, "inc_tiff", 0))) __PYX_ERR(0, 144, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_soil_water_tiff), __pyx_ptype_5numpy_ndarray, 1, "soil_water_tiff", 0))) __PYX_ERR(0, 145, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_param_arr), __pyx_ptype_5numpy_ndarray, 1, "param_arr", 0))) __PYX_ERR(0, 146, __pyx_L1_error) - __pyx_r = __pyx_pf_10LAIProcess_8process_tiff(__pyx_self, __pyx_v_sigma_tiff, __pyx_v_inc_tiff, __pyx_v_soil_water_tiff, __pyx_v_param_arr, __pyx_v_lai_X0); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10LAIProcess_8process_tiff(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_sigma_tiff, PyArrayObject *__pyx_v_inc_tiff, PyArrayObject *__pyx_v_soil_water_tiff, PyArrayObject *__pyx_v_param_arr, double __pyx_v_lai_X0) { - __Pyx_LocalBuf_ND __pyx_pybuffernd_inc_tiff; - __Pyx_Buffer __pyx_pybuffer_inc_tiff; - __Pyx_LocalBuf_ND __pyx_pybuffernd_param_arr; - __Pyx_Buffer __pyx_pybuffer_param_arr; - __Pyx_LocalBuf_ND __pyx_pybuffernd_sigma_tiff; - __Pyx_Buffer __pyx_pybuffer_sigma_tiff; - __Pyx_LocalBuf_ND __pyx_pybuffernd_soil_water_tiff; - __Pyx_Buffer __pyx_pybuffer_soil_water_tiff; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("process_tiff", 0); - __pyx_pybuffer_sigma_tiff.pybuffer.buf = NULL; - __pyx_pybuffer_sigma_tiff.refcount = 0; - __pyx_pybuffernd_sigma_tiff.data = NULL; - __pyx_pybuffernd_sigma_tiff.rcbuffer = &__pyx_pybuffer_sigma_tiff; - __pyx_pybuffer_inc_tiff.pybuffer.buf = NULL; - __pyx_pybuffer_inc_tiff.refcount = 0; - __pyx_pybuffernd_inc_tiff.data = NULL; - __pyx_pybuffernd_inc_tiff.rcbuffer = &__pyx_pybuffer_inc_tiff; - __pyx_pybuffer_soil_water_tiff.pybuffer.buf = NULL; - __pyx_pybuffer_soil_water_tiff.refcount = 0; - __pyx_pybuffernd_soil_water_tiff.data = NULL; - __pyx_pybuffernd_soil_water_tiff.rcbuffer = &__pyx_pybuffer_soil_water_tiff; - __pyx_pybuffer_param_arr.pybuffer.buf = NULL; - __pyx_pybuffer_param_arr.refcount = 0; - __pyx_pybuffernd_param_arr.data = NULL; - __pyx_pybuffernd_param_arr.rcbuffer = &__pyx_pybuffer_param_arr; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer, (PyObject*)__pyx_v_sigma_tiff, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 143, __pyx_L1_error) - } - __pyx_pybuffernd_sigma_tiff.diminfo[0].strides = __pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sigma_tiff.diminfo[0].shape = __pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_sigma_tiff.diminfo[1].strides = __pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_sigma_tiff.diminfo[1].shape = __pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer, (PyObject*)__pyx_v_inc_tiff, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 143, __pyx_L1_error) - } - __pyx_pybuffernd_inc_tiff.diminfo[0].strides = __pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_inc_tiff.diminfo[0].shape = __pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_inc_tiff.diminfo[1].strides = __pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_inc_tiff.diminfo[1].shape = __pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer, (PyObject*)__pyx_v_soil_water_tiff, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 143, __pyx_L1_error) - } - __pyx_pybuffernd_soil_water_tiff.diminfo[0].strides = __pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_soil_water_tiff.diminfo[0].shape = __pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_soil_water_tiff.diminfo[1].strides = __pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_soil_water_tiff.diminfo[1].shape = __pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_param_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_param_arr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 143, __pyx_L1_error) - } - __pyx_pybuffernd_param_arr.diminfo[0].strides = __pyx_pybuffernd_param_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_param_arr.diminfo[0].shape = __pyx_pybuffernd_param_arr.rcbuffer->pybuffer.shape[0]; - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)__pyx_f_10LAIProcess_process_tiff(__pyx_v_sigma_tiff, __pyx_v_inc_tiff, __pyx_v_soil_water_tiff, __pyx_v_param_arr, __pyx_v_lai_X0, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_param_arr.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("LAIProcess.process_tiff", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inc_tiff.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_param_arr.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma_tiff.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_soil_water_tiff.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":735 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":736 - * - * cdef inline object PyArray_MultiIterNew1(a): - * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew2(a, b): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 736, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":735 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":738 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":739 - * - * cdef inline object PyArray_MultiIterNew2(a, b): - * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 739, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":738 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":741 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":742 - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 742, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":741 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":744 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":745 - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 745, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":744 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":747 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":748 - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 748, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":747 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":750 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":751 - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< - * return d.subarray.shape - * else: - */ - __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); - if (__pyx_t_1) { - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":752 - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape # <<<<<<<<<<<<<< - * else: - * return () - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape)); - __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":751 - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< - * return d.subarray.shape - * else: - */ - } - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":754 - * return d.subarray.shape - * else: - * return () # <<<<<<<<<<<<<< - * - * - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_empty_tuple); - __pyx_r = __pyx_empty_tuple; - goto __pyx_L0; - } - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":750 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":931 - * int _import_umath() except -1 - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) - */ - -static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_array_base", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":932 - * - * cdef inline void set_array_base(ndarray arr, object base): - * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< - * PyArray_SetBaseObject(arr, base) - * - */ - Py_INCREF(__pyx_v_base); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":933 - * cdef inline void set_array_base(ndarray arr, object base): - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< - * - * cdef inline object get_array_base(ndarray arr): - */ - (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":931 - * int _import_umath() except -1 - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":935 - * PyArray_SetBaseObject(arr, base) - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * base = PyArray_BASE(arr) - * if base is NULL: - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { - PyObject *__pyx_v_base; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("get_array_base", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":936 - * - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< - * if base is NULL: - * return None - */ - __pyx_v_base = PyArray_BASE(__pyx_v_arr); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":937 - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) - * if base is NULL: # <<<<<<<<<<<<<< - * return None - * return base - */ - __pyx_t_1 = ((__pyx_v_base == NULL) != 0); - if (__pyx_t_1) { - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":938 - * base = PyArray_BASE(arr) - * if base is NULL: - * return None # <<<<<<<<<<<<<< - * return base - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":937 - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) - * if base is NULL: # <<<<<<<<<<<<<< - * return None - * return base - */ - } - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":939 - * if base is NULL: - * return None - * return base # <<<<<<<<<<<<<< - * - * # Versions of the import_* functions which are more suitable for - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_base)); - __pyx_r = ((PyObject *)__pyx_v_base); - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":935 - * PyArray_SetBaseObject(arr, base) - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * base = PyArray_BASE(arr) - * if base is NULL: - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":943 - * # Versions of the import_* functions which are more suitable for - * # Cython code. - * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< - * try: - * __pyx_import_array() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_array", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":945 - * cdef inline int import_array() except -1: - * try: - * __pyx_import_array() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") - */ - __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 945, __pyx_L3_error) - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":946 - * try: - * __pyx_import_array() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.multiarray failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 946, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":947 - * __pyx_import_array() - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_umath() except -1: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 947, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 947, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":943 - * # Versions of the import_* functions which are more suitable for - * # Cython code. - * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< - * try: - * __pyx_import_array() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":949 - * raise ImportError("numpy.core.multiarray failed to import") - * - * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_umath", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":951 - * cdef inline int import_umath() except -1: - * try: - * _import_umath() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.umath failed to import") - */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 951, __pyx_L3_error) - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":952 - * try: - * _import_umath() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.umath failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 952, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":953 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_ufunc() except -1: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 953, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 953, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":949 - * raise ImportError("numpy.core.multiarray failed to import") - * - * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":955 - * raise ImportError("numpy.core.umath failed to import") - * - * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_ufunc", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":957 - * cdef inline int import_ufunc() except -1: - * try: - * _import_umath() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.umath failed to import") - */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 957, __pyx_L3_error) - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":958 - * try: - * _import_umath() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.umath failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 958, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":959 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef extern from *: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 959, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 959, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":955 - * raise ImportError("numpy.core.umath failed to import") - * - * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":969 - * - * - * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.timedelta64)` - */ - -static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_obj) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_timedelta64_object", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":981 - * bool - * """ - * return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type) # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyTimedeltaArrType_Type)); - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":969 - * - * - * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.timedelta64)` - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":984 - * - * - * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.datetime64)` - */ - -static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_obj) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_datetime64_object", 0); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":996 - * bool - * """ - * return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type) # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyDatetimeArrType_Type)); - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":984 - * - * - * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.datetime64)` - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":999 - * - * - * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy datetime64 object - */ - -static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject *__pyx_v_obj) { - npy_datetime __pyx_r; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1006 - * also needed. That can be found using `get_datetime64_unit`. - * """ - * return (obj).obval # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = ((PyDatetimeScalarObject *)__pyx_v_obj)->obval; - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":999 - * - * - * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy datetime64 object - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1009 - * - * - * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy timedelta64 object - */ - -static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject *__pyx_v_obj) { - npy_timedelta __pyx_r; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1013 - * returns the int64 value underlying scalar numpy timedelta64 object - * """ - * return (obj).obval # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = ((PyTimedeltaScalarObject *)__pyx_v_obj)->obval; - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1009 - * - * - * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy timedelta64 object - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - -static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObject *__pyx_v_obj) { - NPY_DATETIMEUNIT __pyx_r; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1020 - * returns the unit part of the dtype for a numpy datetime64 object. - * """ - * return (obj).obmeta.base # <<<<<<<<<<<<<< - */ - __pyx_r = ((NPY_DATETIMEUNIT)((PyDatetimeScalarObject *)__pyx_v_obj)->obmeta.base); - goto __pyx_L0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -static struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *__pyx_freelist_10LAIProcess___pyx_scope_struct__train_WMCmodel[8]; -static int __pyx_freecount_10LAIProcess___pyx_scope_struct__train_WMCmodel = 0; - -static PyObject *__pyx_tp_new_10LAIProcess___pyx_scope_struct__train_WMCmodel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - PyObject *o; - if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_10LAIProcess___pyx_scope_struct__train_WMCmodel > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel)))) { - o = (PyObject*)__pyx_freelist_10LAIProcess___pyx_scope_struct__train_WMCmodel[--__pyx_freecount_10LAIProcess___pyx_scope_struct__train_WMCmodel]; - memset(o, 0, sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel)); - (void) PyObject_INIT(o, t); - PyObject_GC_Track(o); - } else { - o = (*t->tp_alloc)(t, 0); - if (unlikely(!o)) return 0; - } - return o; -} - -static void __pyx_tp_dealloc_10LAIProcess___pyx_scope_struct__train_WMCmodel(PyObject *o) { - struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *p = (struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *)o; - PyObject_GC_UnTrack(o); - Py_CLEAR(p->__pyx_v_lai_water_inc_sigma_list); - if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_10LAIProcess___pyx_scope_struct__train_WMCmodel < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel)))) { - __pyx_freelist_10LAIProcess___pyx_scope_struct__train_WMCmodel[__pyx_freecount_10LAIProcess___pyx_scope_struct__train_WMCmodel++] = ((struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *)o); - } else { - (*Py_TYPE(o)->tp_free)(o); - } -} - -static int __pyx_tp_traverse_10LAIProcess___pyx_scope_struct__train_WMCmodel(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *p = (struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *)o; - if (p->__pyx_v_lai_water_inc_sigma_list) { - e = (*v)(p->__pyx_v_lai_water_inc_sigma_list, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_10LAIProcess___pyx_scope_struct__train_WMCmodel(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *p = (struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel *)o; - tmp = ((PyObject*)p->__pyx_v_lai_water_inc_sigma_list); - p->__pyx_v_lai_water_inc_sigma_list = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyTypeObject __pyx_type_10LAIProcess___pyx_scope_struct__train_WMCmodel = { - PyVarObject_HEAD_INIT(0, 0) - "LAIProcess.__pyx_scope_struct__train_WMCmodel", /*tp_name*/ - sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct__train_WMCmodel), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_10LAIProcess___pyx_scope_struct__train_WMCmodel, /*tp_dealloc*/ - #if PY_VERSION_HEX < 0x030800b4 - 0, /*tp_print*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 - 0, /*tp_vectorcall_offset*/ - #endif - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_10LAIProcess___pyx_scope_struct__train_WMCmodel, /*tp_traverse*/ - __pyx_tp_clear_10LAIProcess___pyx_scope_struct__train_WMCmodel, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - 0, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_10LAIProcess___pyx_scope_struct__train_WMCmodel, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif - #if PY_VERSION_HEX >= 0x030800b1 - 0, /*tp_vectorcall*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 - 0, /*tp_print*/ - #endif -}; - -static struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *__pyx_freelist_10LAIProcess___pyx_scope_struct_1_test_WMCModel[8]; -static int __pyx_freecount_10LAIProcess___pyx_scope_struct_1_test_WMCModel = 0; - -static PyObject *__pyx_tp_new_10LAIProcess___pyx_scope_struct_1_test_WMCModel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - PyObject *o; - if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_10LAIProcess___pyx_scope_struct_1_test_WMCModel > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel)))) { - o = (PyObject*)__pyx_freelist_10LAIProcess___pyx_scope_struct_1_test_WMCModel[--__pyx_freecount_10LAIProcess___pyx_scope_struct_1_test_WMCModel]; - memset(o, 0, sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel)); - (void) PyObject_INIT(o, t); - PyObject_GC_Track(o); - } else { - o = (*t->tp_alloc)(t, 0); - if (unlikely(!o)) return 0; - } - return o; -} - -static void __pyx_tp_dealloc_10LAIProcess___pyx_scope_struct_1_test_WMCModel(PyObject *o) { - struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *p = (struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *)o; - PyObject_GC_UnTrack(o); - Py_CLEAR(p->__pyx_v_csv_sigma); - Py_CLEAR(p->__pyx_v_param_arr); - Py_CLEAR(p->__pyx_v_sample_inc); - Py_CLEAR(p->__pyx_v_sample_soil); - if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_10LAIProcess___pyx_scope_struct_1_test_WMCModel < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel)))) { - __pyx_freelist_10LAIProcess___pyx_scope_struct_1_test_WMCModel[__pyx_freecount_10LAIProcess___pyx_scope_struct_1_test_WMCModel++] = ((struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *)o); - } else { - (*Py_TYPE(o)->tp_free)(o); - } -} - -static int __pyx_tp_traverse_10LAIProcess___pyx_scope_struct_1_test_WMCModel(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *p = (struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *)o; - if (p->__pyx_v_csv_sigma) { - e = (*v)(p->__pyx_v_csv_sigma, a); if (e) return e; - } - if (p->__pyx_v_param_arr) { - e = (*v)(p->__pyx_v_param_arr, a); if (e) return e; - } - if (p->__pyx_v_sample_inc) { - e = (*v)(p->__pyx_v_sample_inc, a); if (e) return e; - } - if (p->__pyx_v_sample_soil) { - e = (*v)(p->__pyx_v_sample_soil, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_10LAIProcess___pyx_scope_struct_1_test_WMCModel(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *p = (struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel *)o; - tmp = ((PyObject*)p->__pyx_v_csv_sigma); - p->__pyx_v_csv_sigma = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_param_arr); - p->__pyx_v_param_arr = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_sample_inc); - p->__pyx_v_sample_inc = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_sample_soil); - p->__pyx_v_sample_soil = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyTypeObject __pyx_type_10LAIProcess___pyx_scope_struct_1_test_WMCModel = { - PyVarObject_HEAD_INIT(0, 0) - "LAIProcess.__pyx_scope_struct_1_test_WMCModel", /*tp_name*/ - sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct_1_test_WMCModel), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_10LAIProcess___pyx_scope_struct_1_test_WMCModel, /*tp_dealloc*/ - #if PY_VERSION_HEX < 0x030800b4 - 0, /*tp_print*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 - 0, /*tp_vectorcall_offset*/ - #endif - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_10LAIProcess___pyx_scope_struct_1_test_WMCModel, /*tp_traverse*/ - __pyx_tp_clear_10LAIProcess___pyx_scope_struct_1_test_WMCModel, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - 0, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_10LAIProcess___pyx_scope_struct_1_test_WMCModel, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif - #if PY_VERSION_HEX >= 0x030800b1 - 0, /*tp_vectorcall*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 - 0, /*tp_print*/ - #endif -}; - -static struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *__pyx_freelist_10LAIProcess___pyx_scope_struct_2_processs_WMCModel[8]; -static int __pyx_freecount_10LAIProcess___pyx_scope_struct_2_processs_WMCModel = 0; - -static PyObject *__pyx_tp_new_10LAIProcess___pyx_scope_struct_2_processs_WMCModel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - PyObject *o; - if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_10LAIProcess___pyx_scope_struct_2_processs_WMCModel > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel)))) { - o = (PyObject*)__pyx_freelist_10LAIProcess___pyx_scope_struct_2_processs_WMCModel[--__pyx_freecount_10LAIProcess___pyx_scope_struct_2_processs_WMCModel]; - memset(o, 0, sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel)); - (void) PyObject_INIT(o, t); - PyObject_GC_Track(o); - } else { - o = (*t->tp_alloc)(t, 0); - if (unlikely(!o)) return 0; - } - return o; -} - -static void __pyx_tp_dealloc_10LAIProcess___pyx_scope_struct_2_processs_WMCModel(PyObject *o) { - struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *p = (struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *)o; - PyObject_GC_UnTrack(o); - Py_CLEAR(p->__pyx_v_inc_angle); - Py_CLEAR(p->__pyx_v_param_arr); - Py_CLEAR(p->__pyx_v_sigma); - Py_CLEAR(p->__pyx_v_soil_water); - if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_10LAIProcess___pyx_scope_struct_2_processs_WMCModel < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel)))) { - __pyx_freelist_10LAIProcess___pyx_scope_struct_2_processs_WMCModel[__pyx_freecount_10LAIProcess___pyx_scope_struct_2_processs_WMCModel++] = ((struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *)o); - } else { - (*Py_TYPE(o)->tp_free)(o); - } -} - -static int __pyx_tp_traverse_10LAIProcess___pyx_scope_struct_2_processs_WMCModel(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *p = (struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *)o; - if (p->__pyx_v_inc_angle) { - e = (*v)(p->__pyx_v_inc_angle, a); if (e) return e; - } - if (p->__pyx_v_param_arr) { - e = (*v)(p->__pyx_v_param_arr, a); if (e) return e; - } - if (p->__pyx_v_sigma) { - e = (*v)(p->__pyx_v_sigma, a); if (e) return e; - } - if (p->__pyx_v_soil_water) { - e = (*v)(p->__pyx_v_soil_water, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_10LAIProcess___pyx_scope_struct_2_processs_WMCModel(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *p = (struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel *)o; - tmp = ((PyObject*)p->__pyx_v_inc_angle); - p->__pyx_v_inc_angle = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_param_arr); - p->__pyx_v_param_arr = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_sigma); - p->__pyx_v_sigma = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_soil_water); - p->__pyx_v_soil_water = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyTypeObject __pyx_type_10LAIProcess___pyx_scope_struct_2_processs_WMCModel = { - PyVarObject_HEAD_INIT(0, 0) - "LAIProcess.__pyx_scope_struct_2_processs_WMCModel", /*tp_name*/ - sizeof(struct __pyx_obj_10LAIProcess___pyx_scope_struct_2_processs_WMCModel), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_10LAIProcess___pyx_scope_struct_2_processs_WMCModel, /*tp_dealloc*/ - #if PY_VERSION_HEX < 0x030800b4 - 0, /*tp_print*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 - 0, /*tp_vectorcall_offset*/ - #endif - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_10LAIProcess___pyx_scope_struct_2_processs_WMCModel, /*tp_traverse*/ - __pyx_tp_clear_10LAIProcess___pyx_scope_struct_2_processs_WMCModel, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - 0, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_10LAIProcess___pyx_scope_struct_2_processs_WMCModel, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif - #if PY_VERSION_HEX >= 0x030800b1 - 0, /*tp_vectorcall*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 - 0, /*tp_print*/ - #endif -}; - -static PyMethodDef __pyx_methods[] = { - {"process_tiff", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_10LAIProcess_9process_tiff, METH_VARARGS|METH_KEYWORDS, 0}, - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -#if CYTHON_PEP489_MULTI_PHASE_INIT -static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ -static int __pyx_pymod_exec_LAIProcess(PyObject* module); /*proto*/ -static PyModuleDef_Slot __pyx_moduledef_slots[] = { - {Py_mod_create, (void*)__pyx_pymod_create}, - {Py_mod_exec, (void*)__pyx_pymod_exec_LAIProcess}, - {0, NULL} -}; -#endif - -static struct PyModuleDef __pyx_moduledef = { - PyModuleDef_HEAD_INIT, - "LAIProcess", - 0, /* m_doc */ - #if CYTHON_PEP489_MULTI_PHASE_INIT - 0, /* m_size */ - #else - -1, /* m_size */ - #endif - __pyx_methods /* m_methods */, - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_moduledef_slots, /* m_slots */ - #else - NULL, /* m_reload */ - #endif - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif -#ifndef CYTHON_SMALL_CODE -#if defined(__clang__) - #define CYTHON_SMALL_CODE -#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) - #define CYTHON_SMALL_CODE __attribute__((cold)) -#else - #define CYTHON_SMALL_CODE -#endif -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1}, - {&__pyx_n_s_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 0, 1, 1}, - {&__pyx_n_s_C, __pyx_k_C, sizeof(__pyx_k_C), 0, 0, 1, 1}, - {&__pyx_n_s_D, __pyx_k_D, sizeof(__pyx_k_D), 0, 0, 1, 1}, - {&__pyx_n_s_FVC, __pyx_k_FVC, sizeof(__pyx_k_FVC), 0, 0, 1, 1}, - {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, - {&__pyx_n_s_LAIProcess, __pyx_k_LAIProcess, sizeof(__pyx_k_LAIProcess), 0, 0, 1, 1}, - {&__pyx_kp_s_LAIProcess_pyx, __pyx_k_LAIProcess_pyx, sizeof(__pyx_k_LAIProcess_pyx), 0, 0, 1, 0}, - {&__pyx_n_s_M, __pyx_k_M, sizeof(__pyx_k_M), 0, 0, 1, 1}, - {&__pyx_n_s_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 0, 1, 1}, - {&__pyx_n_s_V_lai, __pyx_k_V_lai, sizeof(__pyx_k_V_lai), 0, 0, 1, 1}, - {&__pyx_n_s_WMCModel, __pyx_k_WMCModel, sizeof(__pyx_k_WMCModel), 0, 0, 1, 1}, - {&__pyx_n_s_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 0, 1, 1}, - {&__pyx_n_s_X0, __pyx_k_X0, sizeof(__pyx_k_X0), 0, 0, 1, 1}, - {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, - {&__pyx_n_s_cos, __pyx_k_cos, sizeof(__pyx_k_cos), 0, 0, 1, 1}, - {&__pyx_n_s_csv_sigma, __pyx_k_csv_sigma, sizeof(__pyx_k_csv_sigma), 0, 0, 1, 1}, - {&__pyx_n_s_dpi, __pyx_k_dpi, sizeof(__pyx_k_dpi), 0, 0, 1, 1}, - {&__pyx_n_s_draw_flag, __pyx_k_draw_flag, sizeof(__pyx_k_draw_flag), 0, 0, 1, 1}, - {&__pyx_n_s_eqs, __pyx_k_eqs, sizeof(__pyx_k_eqs), 0, 0, 1, 1}, - {&__pyx_kp_s_equation_err, __pyx_k_equation_err, sizeof(__pyx_k_equation_err), 0, 0, 1, 0}, - {&__pyx_n_s_err, __pyx_k_err, sizeof(__pyx_k_err), 0, 0, 1, 1}, - {&__pyx_n_s_err_f, __pyx_k_err_f, sizeof(__pyx_k_err_f), 0, 0, 1, 1}, - {&__pyx_n_s_err_lai, __pyx_k_err_lai, sizeof(__pyx_k_err_lai), 0, 0, 1, 1}, - {&__pyx_n_s_exp, __pyx_k_exp, sizeof(__pyx_k_exp), 0, 0, 1, 1}, - {&__pyx_n_s_exp_gamma, __pyx_k_exp_gamma, sizeof(__pyx_k_exp_gamma), 0, 0, 1, 1}, - {&__pyx_n_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 1}, - {&__pyx_n_s_f_veg, __pyx_k_f_veg, sizeof(__pyx_k_f_veg), 0, 0, 1, 1}, - {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1}, - {&__pyx_n_s_h, __pyx_k_h, sizeof(__pyx_k_h), 0, 0, 1, 1}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_n_s_inc_angle, __pyx_k_inc_angle, sizeof(__pyx_k_inc_angle), 0, 0, 1, 1}, - {&__pyx_n_s_inc_tiff, __pyx_k_inc_tiff, sizeof(__pyx_k_inc_tiff), 0, 0, 1, 1}, - {&__pyx_n_s_lai, __pyx_k_lai, sizeof(__pyx_k_lai), 0, 0, 1, 1}, - {&__pyx_n_s_lai_X0, __pyx_k_lai_X0, sizeof(__pyx_k_lai_X0), 0, 0, 1, 1}, - {&__pyx_n_s_lai_waiter_inc_sigma_item, __pyx_k_lai_waiter_inc_sigma_item, sizeof(__pyx_k_lai_waiter_inc_sigma_item), 0, 0, 1, 1}, - {&__pyx_n_s_lai_waiter_inc_sigma_list, __pyx_k_lai_waiter_inc_sigma_list, sizeof(__pyx_k_lai_waiter_inc_sigma_list), 0, 0, 1, 1}, - {&__pyx_n_s_lai_water_inc_sigma_item, __pyx_k_lai_water_inc_sigma_item, sizeof(__pyx_k_lai_water_inc_sigma_item), 0, 0, 1, 1}, - {&__pyx_n_s_lai_water_inc_sigma_list, __pyx_k_lai_water_inc_sigma_list, sizeof(__pyx_k_lai_water_inc_sigma_list), 0, 0, 1, 1}, - {&__pyx_n_s_leastsq, __pyx_k_leastsq, sizeof(__pyx_k_leastsq), 0, 0, 1, 1}, - {&__pyx_n_s_logger, __pyx_k_logger, sizeof(__pyx_k_logger), 0, 0, 1, 1}, - {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_matplotlib, __pyx_k_matplotlib, sizeof(__pyx_k_matplotlib), 0, 0, 1, 1}, - {&__pyx_n_s_mylog, __pyx_k_mylog, sizeof(__pyx_k_mylog), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_n_s_nan, __pyx_k_nan, sizeof(__pyx_k_nan), 0, 0, 1, 1}, - {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, - {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, - {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0}, - {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0}, - {&__pyx_n_s_param_arr, __pyx_k_param_arr, sizeof(__pyx_k_param_arr), 0, 0, 1, 1}, - {&__pyx_n_s_params_X0, __pyx_k_params_X0, sizeof(__pyx_k_params_X0), 0, 0, 1, 1}, - {&__pyx_n_s_plt, __pyx_k_plt, sizeof(__pyx_k_plt), 0, 0, 1, 1}, - {&__pyx_n_s_processs_WMCModel, __pyx_k_processs_WMCModel, sizeof(__pyx_k_processs_WMCModel), 0, 0, 1, 1}, - {&__pyx_n_s_processs_WMCModel_locals_f, __pyx_k_processs_WMCModel_locals_f, sizeof(__pyx_k_processs_WMCModel_locals_f), 0, 0, 1, 1}, - {&__pyx_n_s_pyplot, __pyx_k_pyplot, sizeof(__pyx_k_pyplot), 0, 0, 1, 1}, - {&__pyx_n_s_random, __pyx_k_random, sizeof(__pyx_k_random), 0, 0, 1, 1}, - {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1}, - {&__pyx_n_s_sample_code, __pyx_k_sample_code, sizeof(__pyx_k_sample_code), 0, 0, 1, 1}, - {&__pyx_n_s_sample_inc, __pyx_k_sample_inc, sizeof(__pyx_k_sample_inc), 0, 0, 1, 1}, - {&__pyx_n_s_sample_lai, __pyx_k_sample_lai, sizeof(__pyx_k_sample_lai), 0, 0, 1, 1}, - {&__pyx_n_s_sample_lat, __pyx_k_sample_lat, sizeof(__pyx_k_sample_lat), 0, 0, 1, 1}, - {&__pyx_n_s_sample_lon, __pyx_k_sample_lon, sizeof(__pyx_k_sample_lon), 0, 0, 1, 1}, - {&__pyx_n_s_sample_sigma, __pyx_k_sample_sigma, sizeof(__pyx_k_sample_sigma), 0, 0, 1, 1}, - {&__pyx_n_s_sample_soil, __pyx_k_sample_soil, sizeof(__pyx_k_sample_soil), 0, 0, 1, 1}, - {&__pyx_n_s_sample_time, __pyx_k_sample_time, sizeof(__pyx_k_sample_time), 0, 0, 1, 1}, - {&__pyx_n_s_savefig, __pyx_k_savefig, sizeof(__pyx_k_savefig), 0, 0, 1, 1}, - {&__pyx_n_s_scatter, __pyx_k_scatter, sizeof(__pyx_k_scatter), 0, 0, 1, 1}, - {&__pyx_n_s_scipy_optimize, __pyx_k_scipy_optimize, sizeof(__pyx_k_scipy_optimize), 0, 0, 1, 1}, - {&__pyx_n_s_show, __pyx_k_show, sizeof(__pyx_k_show), 0, 0, 1, 1}, - {&__pyx_n_s_sigma, __pyx_k_sigma, sizeof(__pyx_k_sigma), 0, 0, 1, 1}, - {&__pyx_n_s_sigma_soil, __pyx_k_sigma_soil, sizeof(__pyx_k_sigma_soil), 0, 0, 1, 1}, - {&__pyx_n_s_sigma_tiff, __pyx_k_sigma_tiff, sizeof(__pyx_k_sigma_tiff), 0, 0, 1, 1}, - {&__pyx_n_s_sigma_veg, __pyx_k_sigma_veg, sizeof(__pyx_k_sigma_veg), 0, 0, 1, 1}, - {&__pyx_n_s_soil_water, __pyx_k_soil_water, sizeof(__pyx_k_soil_water), 0, 0, 1, 1}, - {&__pyx_n_s_soil_water_tiff, __pyx_k_soil_water_tiff, sizeof(__pyx_k_soil_water_tiff), 0, 0, 1, 1}, - {&__pyx_n_s_temp_err, __pyx_k_temp_err, sizeof(__pyx_k_temp_err), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_test_WMCModel, __pyx_k_test_WMCModel, sizeof(__pyx_k_test_WMCModel), 0, 0, 1, 1}, - {&__pyx_n_s_test_WMCModel_locals_f, __pyx_k_test_WMCModel_locals_f, sizeof(__pyx_k_test_WMCModel_locals_f), 0, 0, 1, 1}, - {&__pyx_n_s_test_err_image_path, __pyx_k_test_err_image_path, sizeof(__pyx_k_test_err_image_path), 0, 0, 1, 1}, - {&__pyx_n_s_title, __pyx_k_title, sizeof(__pyx_k_title), 0, 0, 1, 1}, - {&__pyx_n_s_train_WMCmodel, __pyx_k_train_WMCmodel, sizeof(__pyx_k_train_WMCmodel), 0, 0, 1, 1}, - {&__pyx_n_s_train_WMCmodel_locals_f, __pyx_k_train_WMCmodel_locals_f, sizeof(__pyx_k_train_WMCmodel_locals_f), 0, 0, 1, 1}, - {&__pyx_n_s_train_err_image_path, __pyx_k_train_err_image_path, sizeof(__pyx_k_train_err_image_path), 0, 0, 1, 1}, - {&__pyx_n_s_x_arr, __pyx_k_x_arr, sizeof(__pyx_k_x_arr), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 947, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "LAIProcess.pyx":48 - * lai_waiter_inc_sigma_list (list): - * """ - * def f(X): # <<<<<<<<<<<<<< - * eqs=[] - * for lai_water_inc_sigma_item in lai_water_inc_sigma_list: - */ - __pyx_tuple_ = PyTuple_Pack(8, __pyx_n_s_X, __pyx_n_s_eqs, __pyx_n_s_lai_water_inc_sigma_item, __pyx_n_s_sample_lai, __pyx_n_s_sample_sigma, __pyx_n_s_sample_soil, __pyx_n_s_sample_inc, __pyx_n_s_FVC); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); - __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_LAIProcess_pyx, __pyx_n_s_f, 48, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 48, __pyx_L1_error) - - /* "LAIProcess.pyx":104 - * for lai_waiter_inc_sigma_item in lai_waiter_inc_sigma_list: - * sample_time,sample_code,sample_lon,sample_lat,sample_lai,csv_sigma,sample_soil,sample_inc,sample_sigma=lai_waiter_inc_sigma_item - * def f(X): # <<<<<<<<<<<<<< - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,sample_soil,sample_inc,csv_sigma)] - */ - __pyx_tuple__3 = PyTuple_Pack(3, __pyx_n_s_X, __pyx_n_s_lai, __pyx_n_s_eqs); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); - __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_LAIProcess_pyx, __pyx_n_s_f, 104, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 104, __pyx_L1_error) - - /* "LAIProcess.pyx":134 - * if(sigma<0 ): - * return np.nan - * def f(X): # <<<<<<<<<<<<<< - * lai=X[0] - * eqs=[WMCModel(param_arr,lai,soil_water,inc_angle,sigma )] - */ - __pyx_tuple__5 = PyTuple_Pack(3, __pyx_n_s_X, __pyx_n_s_lai, __pyx_n_s_eqs); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); - __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_LAIProcess_pyx, __pyx_n_s_f, 134, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 134, __pyx_L1_error) - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":947 - * __pyx_import_array() - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_umath() except -1: - */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 947, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":953 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_ufunc() except -1: - */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 953, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - - /* "LAIProcess.pyx":12 - * import random - * import logging - * logger = logging.getLogger("mylog") # <<<<<<<<<<<<<< - * - * - */ - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_mylog); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__9); - __Pyx_GIVEREF(__pyx_tuple__9); - - /* "LAIProcess.pyx":15 - * - * - * def WMCModel(param_arr,sample_lai,sample_soil,sample_inc,sample_sigma): # <<<<<<<<<<<<<< - * """ WMC - * - */ - __pyx_tuple__10 = PyTuple_Pack(17, __pyx_n_s_param_arr, __pyx_n_s_sample_lai, __pyx_n_s_sample_soil, __pyx_n_s_sample_inc, __pyx_n_s_sample_sigma, __pyx_n_s_A, __pyx_n_s_B, __pyx_n_s_C, __pyx_n_s_D, __pyx_n_s_M, __pyx_n_s_N, __pyx_n_s_V_lai, __pyx_n_s_exp_gamma, __pyx_n_s_sigma_soil, __pyx_n_s_sigma_veg, __pyx_n_s_f_veg, __pyx_n_s_result); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 15, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); - __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(5, 0, 17, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_LAIProcess_pyx, __pyx_n_s_WMCModel, 15, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 15, __pyx_L1_error) - - /* "LAIProcess.pyx":42 - * - * - * def train_WMCmodel(lai_water_inc_sigma_list,params_X0,train_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ - __pyx_tuple__12 = PyTuple_Pack(12, __pyx_n_s_lai_water_inc_sigma_list, __pyx_n_s_params_X0, __pyx_n_s_train_err_image_path, __pyx_n_s_draw_flag, __pyx_n_s_f, __pyx_n_s_f, __pyx_n_s_X0, __pyx_n_s_h, __pyx_n_s_err_f, __pyx_n_s_x_arr, __pyx_n_s_plt, __pyx_n_s_lai_waiter_inc_sigma_item); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 42, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__12); - __Pyx_GIVEREF(__pyx_tuple__12); - __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_LAIProcess_pyx, __pyx_n_s_train_WMCmodel, 42, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 42, __pyx_L1_error) - - /* "LAIProcess.pyx":82 - * return h[0] - * - * def test_WMCModel(lai_waiter_inc_sigma_list,param_arr,lai_X0,test_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ - __pyx_tuple__14 = PyTuple_Pack(25, __pyx_n_s_lai_waiter_inc_sigma_list, __pyx_n_s_param_arr, __pyx_n_s_lai_X0, __pyx_n_s_test_err_image_path, __pyx_n_s_draw_flag, __pyx_n_s_err, __pyx_n_s_err_f, __pyx_n_s_x_arr, __pyx_n_s_err_lai, __pyx_n_s_lai_waiter_inc_sigma_item, __pyx_n_s_sample_time, __pyx_n_s_sample_code, __pyx_n_s_sample_lon, __pyx_n_s_sample_lat, __pyx_n_s_sample_lai, __pyx_n_s_csv_sigma, __pyx_n_s_sample_soil, __pyx_n_s_sample_inc, __pyx_n_s_sample_sigma, __pyx_n_s_f, __pyx_n_s_f, __pyx_n_s_X0, __pyx_n_s_h, __pyx_n_s_temp_err, __pyx_n_s_plt); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__14); - __Pyx_GIVEREF(__pyx_tuple__14); - __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(5, 0, 25, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_LAIProcess_pyx, __pyx_n_s_test_WMCModel, 82, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 82, __pyx_L1_error) - - /* "LAIProcess.pyx":130 - * return err - * - * def processs_WMCModel(param_arr,lai_X0,sigma,inc_angle,soil_water): # <<<<<<<<<<<<<< - * - * if(sigma<0 ): - */ - __pyx_tuple__16 = PyTuple_Pack(8, __pyx_n_s_param_arr, __pyx_n_s_lai_X0, __pyx_n_s_sigma, __pyx_n_s_inc_angle, __pyx_n_s_soil_water, __pyx_n_s_f, __pyx_n_s_f, __pyx_n_s_h); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__16); - __Pyx_GIVEREF(__pyx_tuple__16); - __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(5, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_LAIProcess_pyx, __pyx_n_s_processs_WMCModel, 130, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_600 = PyInt_FromLong(600); if (unlikely(!__pyx_int_600)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_neg_2 = PyInt_FromLong(-2); if (unlikely(!__pyx_int_neg_2)) __PYX_ERR(0, 1, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ - -static int __Pyx_modinit_global_init_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); - /*--- Global init code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_variable_export_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); - /*--- Variable export code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_function_export_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); - /*--- Function export code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_type_init_code(void) { - __Pyx_RefNannyDeclarations - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); - /*--- Type init code ---*/ - if (PyType_Ready(&__pyx_type_10LAIProcess___pyx_scope_struct__train_WMCmodel) < 0) __PYX_ERR(0, 42, __pyx_L1_error) - #if PY_VERSION_HEX < 0x030800B1 - __pyx_type_10LAIProcess___pyx_scope_struct__train_WMCmodel.tp_print = 0; - #endif - if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_10LAIProcess___pyx_scope_struct__train_WMCmodel.tp_dictoffset && __pyx_type_10LAIProcess___pyx_scope_struct__train_WMCmodel.tp_getattro == PyObject_GenericGetAttr)) { - __pyx_type_10LAIProcess___pyx_scope_struct__train_WMCmodel.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; - } - __pyx_ptype_10LAIProcess___pyx_scope_struct__train_WMCmodel = &__pyx_type_10LAIProcess___pyx_scope_struct__train_WMCmodel; - if (PyType_Ready(&__pyx_type_10LAIProcess___pyx_scope_struct_1_test_WMCModel) < 0) __PYX_ERR(0, 82, __pyx_L1_error) - #if PY_VERSION_HEX < 0x030800B1 - __pyx_type_10LAIProcess___pyx_scope_struct_1_test_WMCModel.tp_print = 0; - #endif - if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_10LAIProcess___pyx_scope_struct_1_test_WMCModel.tp_dictoffset && __pyx_type_10LAIProcess___pyx_scope_struct_1_test_WMCModel.tp_getattro == PyObject_GenericGetAttr)) { - __pyx_type_10LAIProcess___pyx_scope_struct_1_test_WMCModel.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; - } - __pyx_ptype_10LAIProcess___pyx_scope_struct_1_test_WMCModel = &__pyx_type_10LAIProcess___pyx_scope_struct_1_test_WMCModel; - if (PyType_Ready(&__pyx_type_10LAIProcess___pyx_scope_struct_2_processs_WMCModel) < 0) __PYX_ERR(0, 130, __pyx_L1_error) - #if PY_VERSION_HEX < 0x030800B1 - __pyx_type_10LAIProcess___pyx_scope_struct_2_processs_WMCModel.tp_print = 0; - #endif - if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_10LAIProcess___pyx_scope_struct_2_processs_WMCModel.tp_dictoffset && __pyx_type_10LAIProcess___pyx_scope_struct_2_processs_WMCModel.tp_getattro == PyObject_GenericGetAttr)) { - __pyx_type_10LAIProcess___pyx_scope_struct_2_processs_WMCModel.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; - } - __pyx_ptype_10LAIProcess___pyx_scope_struct_2_processs_WMCModel = &__pyx_type_10LAIProcess___pyx_scope_struct_2_processs_WMCModel; - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_modinit_type_import_code(void) { - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); - /*--- Type import code ---*/ - __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", - #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 - sizeof(PyTypeObject), - #else - sizeof(PyHeapTypeObject), - #endif - __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 200, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 200, __pyx_L1_error) - __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 223, __pyx_L1_error) - __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 227, __pyx_L1_error) - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 239, __pyx_L1_error) - __pyx_ptype_5numpy_generic = __Pyx_ImportType(__pyx_t_1, "numpy", "generic", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_generic) __PYX_ERR(1, 771, __pyx_L1_error) - __pyx_ptype_5numpy_number = __Pyx_ImportType(__pyx_t_1, "numpy", "number", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_number) __PYX_ERR(1, 773, __pyx_L1_error) - __pyx_ptype_5numpy_integer = __Pyx_ImportType(__pyx_t_1, "numpy", "integer", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_integer) __PYX_ERR(1, 775, __pyx_L1_error) - __pyx_ptype_5numpy_signedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "signedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_signedinteger) __PYX_ERR(1, 777, __pyx_L1_error) - __pyx_ptype_5numpy_unsignedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "unsignedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_unsignedinteger) __PYX_ERR(1, 779, __pyx_L1_error) - __pyx_ptype_5numpy_inexact = __Pyx_ImportType(__pyx_t_1, "numpy", "inexact", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_inexact) __PYX_ERR(1, 781, __pyx_L1_error) - __pyx_ptype_5numpy_floating = __Pyx_ImportType(__pyx_t_1, "numpy", "floating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_floating) __PYX_ERR(1, 783, __pyx_L1_error) - __pyx_ptype_5numpy_complexfloating = __Pyx_ImportType(__pyx_t_1, "numpy", "complexfloating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_complexfloating) __PYX_ERR(1, 785, __pyx_L1_error) - __pyx_ptype_5numpy_flexible = __Pyx_ImportType(__pyx_t_1, "numpy", "flexible", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_flexible) __PYX_ERR(1, 787, __pyx_L1_error) - __pyx_ptype_5numpy_character = __Pyx_ImportType(__pyx_t_1, "numpy", "character", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_character) __PYX_ERR(1, 789, __pyx_L1_error) - __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 827, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_modinit_variable_import_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); - /*--- Variable import code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_function_import_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); - /*--- Function import code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - - -#ifndef CYTHON_NO_PYINIT_EXPORT -#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC -#elif PY_MAJOR_VERSION < 3 -#ifdef __cplusplus -#define __Pyx_PyMODINIT_FUNC extern "C" void -#else -#define __Pyx_PyMODINIT_FUNC void -#endif -#else -#ifdef __cplusplus -#define __Pyx_PyMODINIT_FUNC extern "C" PyObject * -#else -#define __Pyx_PyMODINIT_FUNC PyObject * -#endif -#endif - - -#if PY_MAJOR_VERSION < 3 -__Pyx_PyMODINIT_FUNC initLAIProcess(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC initLAIProcess(void) -#else -__Pyx_PyMODINIT_FUNC PyInit_LAIProcess(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC PyInit_LAIProcess(void) -#if CYTHON_PEP489_MULTI_PHASE_INIT -{ - return PyModuleDef_Init(&__pyx_moduledef); -} -static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { - #if PY_VERSION_HEX >= 0x030700A1 - static PY_INT64_T main_interpreter_id = -1; - PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); - if (main_interpreter_id == -1) { - main_interpreter_id = current_id; - return (unlikely(current_id == -1)) ? -1 : 0; - } else if (unlikely(main_interpreter_id != current_id)) - #else - static PyInterpreterState *main_interpreter = NULL; - PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; - if (!main_interpreter) { - main_interpreter = current_interpreter; - } else if (unlikely(main_interpreter != current_interpreter)) - #endif - { - PyErr_SetString( - PyExc_ImportError, - "Interpreter change detected - this module can only be loaded into one interpreter per process."); - return -1; - } - return 0; -} -static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { - PyObject *value = PyObject_GetAttrString(spec, from_name); - int result = 0; - if (likely(value)) { - if (allow_none || value != Py_None) { - result = PyDict_SetItemString(moddict, to_name, value); - } - Py_DECREF(value); - } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - } else { - result = -1; - } - return result; -} -static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { - PyObject *module = NULL, *moddict, *modname; - if (__Pyx_check_single_interpreter()) - return NULL; - if (__pyx_m) - return __Pyx_NewRef(__pyx_m); - modname = PyObject_GetAttrString(spec, "name"); - if (unlikely(!modname)) goto bad; - module = PyModule_NewObject(modname); - Py_DECREF(modname); - if (unlikely(!module)) goto bad; - moddict = PyModule_GetDict(module); - if (unlikely(!moddict)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; - return module; -bad: - Py_XDECREF(module); - return NULL; -} - - -static CYTHON_SMALL_CODE int __pyx_pymod_exec_LAIProcess(PyObject *__pyx_pyinit_module) -#endif -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannyDeclarations - #if CYTHON_PEP489_MULTI_PHASE_INIT - if (__pyx_m) { - if (__pyx_m == __pyx_pyinit_module) return 0; - PyErr_SetString(PyExc_RuntimeError, "Module 'LAIProcess' has already been imported. Re-initialisation is not supported."); - return -1; - } - #elif PY_MAJOR_VERSION >= 3 - if (__pyx_m) return __Pyx_NewRef(__pyx_m); - #endif - #if CYTHON_REFNANNY -__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); -if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); -} -#endif - __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_LAIProcess(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pxy_PyFrame_Initialize_Offsets - __Pxy_PyFrame_Initialize_Offsets(); - #endif - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_AsyncGen_USED - if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - PyEval_InitThreads(); - #endif - /*--- Module creation code ---*/ - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_m = __pyx_pyinit_module; - Py_INCREF(__pyx_m); - #else - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("LAIProcess", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_b); - __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_cython_runtime); - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main_LAIProcess) { - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "LAIProcess")) { - if (unlikely(PyDict_SetItemString(modules, "LAIProcess", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global type/function init code ---*/ - (void)__Pyx_modinit_global_init_code(); - (void)__Pyx_modinit_variable_export_code(); - (void)__Pyx_modinit_function_export_code(); - if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - (void)__Pyx_modinit_variable_import_code(); - (void)__Pyx_modinit_function_import_code(); - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - - /* "LAIProcess.pyx":6 - * import cython - * cimport cython # - * import numpy as np # <<<<<<<<<<<<<< - * cimport numpy as np - * from libc.math cimport pi - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "LAIProcess.pyx":9 - * cimport numpy as np - * from libc.math cimport pi - * from scipy.optimize import leastsq # <<<<<<<<<<<<<< - * import random - * import logging - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_leastsq); - __Pyx_GIVEREF(__pyx_n_s_leastsq); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_leastsq); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_scipy_optimize, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_leastsq); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_leastsq, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "LAIProcess.pyx":10 - * from libc.math cimport pi - * from scipy.optimize import leastsq - * import random # <<<<<<<<<<<<<< - * import logging - * logger = logging.getLogger("mylog") - */ - __pyx_t_2 = __Pyx_Import(__pyx_n_s_random, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_random, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "LAIProcess.pyx":11 - * from scipy.optimize import leastsq - * import random - * import logging # <<<<<<<<<<<<<< - * logger = logging.getLogger("mylog") - * - */ - __pyx_t_2 = __Pyx_Import(__pyx_n_s_logging, 0, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "LAIProcess.pyx":12 - * import random - * import logging - * logger = logging.getLogger("mylog") # <<<<<<<<<<<<<< - * - * - */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (PyDict_SetItem(__pyx_d, __pyx_n_s_logger, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "LAIProcess.pyx":15 - * - * - * def WMCModel(param_arr,sample_lai,sample_soil,sample_inc,sample_sigma): # <<<<<<<<<<<<<< - * """ WMC - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10LAIProcess_1WMCModel, NULL, __pyx_n_s_LAIProcess); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_WMCModel, __pyx_t_2) < 0) __PYX_ERR(0, 15, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "LAIProcess.pyx":42 - * - * - * def train_WMCmodel(lai_water_inc_sigma_list,params_X0,train_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10LAIProcess_3train_WMCmodel, NULL, __pyx_n_s_LAIProcess); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_train_WMCmodel, __pyx_t_2) < 0) __PYX_ERR(0, 42, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "LAIProcess.pyx":82 - * return h[0] - * - * def test_WMCModel(lai_waiter_inc_sigma_list,param_arr,lai_X0,test_err_image_path,draw_flag=True): # <<<<<<<<<<<<<< - * """ - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10LAIProcess_5test_WMCModel, NULL, __pyx_n_s_LAIProcess); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test_WMCModel, __pyx_t_2) < 0) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "LAIProcess.pyx":130 - * return err - * - * def processs_WMCModel(param_arr,lai_X0,sigma,inc_angle,soil_water): # <<<<<<<<<<<<<< - * - * if(sigma<0 ): - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10LAIProcess_7processs_WMCModel, NULL, __pyx_n_s_LAIProcess); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_processs_WMCModel, __pyx_t_2) < 0) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "LAIProcess.pyx":1 - * # # <<<<<<<<<<<<<< - * # - * # - */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init LAIProcess", __pyx_clineno, __pyx_lineno, __pyx_filename); - } - Py_CLEAR(__pyx_m); - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init LAIProcess"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if CYTHON_PEP489_MULTI_PHASE_INIT - return (__pyx_m != NULL) ? 0 : -1; - #elif PY_MAJOR_VERSION >= 3 - return __pyx_m; - #else - return; - #endif -} - -/* --- Runtime support code --- */ -/* Refnanny */ -#if CYTHON_REFNANNY -static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule(modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, "RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif - -/* RaiseArgTupleInvalid */ -static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} - -/* RaiseDoubleKeywords */ -static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -/* ParseKeywords */ -static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* RaiseTooManyValuesToUnpack */ -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { - PyErr_Format(PyExc_ValueError, - "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); -} - -/* RaiseNeedMoreValuesToUnpack */ -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { - PyErr_Format(PyExc_ValueError, - "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", - index, (index == 1) ? "" : "s"); -} - -/* IterFinish */ -static CYTHON_INLINE int __Pyx_IterFinish(void) { -#if CYTHON_FAST_THREAD_STATE - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject* exc_type = tstate->curexc_type; - if (unlikely(exc_type)) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { - PyObject *exc_value, *exc_tb; - exc_value = tstate->curexc_value; - exc_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; - Py_DECREF(exc_type); - Py_XDECREF(exc_value); - Py_XDECREF(exc_tb); - return 0; - } else { - return -1; - } - } - return 0; -#else - if (unlikely(PyErr_Occurred())) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { - PyErr_Clear(); - return 0; - } else { - return -1; - } - } - return 0; -#endif -} - -/* UnpackItemEndCheck */ -static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { - if (unlikely(retval)) { - Py_DECREF(retval); - __Pyx_RaiseTooManyValuesError(expected); - return -1; - } else { - return __Pyx_IterFinish(); - } - return 0; -} - -/* PyObjectGetAttrStr */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#endif - -/* GetBuiltinName */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -/* PyDictVersioning */ -#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; -} -static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { - PyObject **dictptr = NULL; - Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; - if (offset) { -#if CYTHON_COMPILING_IN_CPYTHON - dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); -#else - dictptr = _PyObject_GetDictPtr(obj); -#endif - } - return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; -} -static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) - return 0; - return obj_dict_version == __Pyx_get_object_dict_version(obj); -} -#endif - -/* GetModuleGlobalName */ -#if CYTHON_USE_DICT_VERSIONS -static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) -#else -static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) -#endif -{ - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 - result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } else if (unlikely(PyErr_Occurred())) { - return NULL; - } -#else - result = PyDict_GetItem(__pyx_d, name); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } -#endif -#else - result = PyObject_GetItem(__pyx_d, name); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } - PyErr_Clear(); -#endif - return __Pyx_GetBuiltinName(name); -} - -/* PyCFunctionFastCall */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); - } else { - return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); - } -} -#endif - -/* PyFunctionFastCall */ -#if CYTHON_FAST_PYCALL -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = __Pyx_PyFrame_GetLocalsplus(f); - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif -#endif - -/* PyObjectCall */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = Py_TYPE(func)->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = (*call)(func, arg, kw); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCall2Args */ -static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { - PyObject *args, *result = NULL; - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyFunction_FastCall(function, args, 2); - } - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyCFunction_FastCall(function, args, 2); - } - #endif - args = PyTuple_New(2); - if (unlikely(!args)) goto done; - Py_INCREF(arg1); - PyTuple_SET_ITEM(args, 0, arg1); - Py_INCREF(arg2); - PyTuple_SET_ITEM(args, 1, arg2); - Py_INCREF(function); - result = __Pyx_PyObject_Call(function, args, NULL); - Py_DECREF(args); - Py_DECREF(function); -done: - return result; -} - -/* PyObjectCallMethO */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { - PyObject *self, *result; - PyCFunction cfunc; - cfunc = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = cfunc(self, arg); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallOneArg */ -#if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif - if (likely(PyCFunction_Check(func))) { - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (__Pyx_PyFastCFunction_Check(func)) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - -/* PyIntBinop */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_SubtractCObj(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { - (void)inplace; - (void)zerodivision_check; - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op2))) { - const long a = intval; - long x; - long b = PyInt_AS_LONG(op2); - x = (long)((unsigned long)a - b); - if (likely((x^a) >= 0 || (x^~b) >= 0)) - return PyInt_FromLong(x); - return PyLong_Type.tp_as_number->nb_subtract(op1, op2); - } - #endif - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op2))) { - const long a = intval; - long b, x; -#ifdef HAVE_LONG_LONG - const PY_LONG_LONG lla = intval; - PY_LONG_LONG llb, llx; -#endif - const digit* digits = ((PyLongObject*)op2)->ob_digit; - const Py_ssize_t size = Py_SIZE(op2); - if (likely(__Pyx_sst_abs(size) <= 1)) { - b = likely(size) ? digits[0] : 0; - if (size == -1) b = -b; - } else { - switch (size) { - case -2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - b = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - llb = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case -3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - b = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - llb = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - llb = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case -4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - b = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - llb = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - llb = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2); - } - } - x = a - b; - return PyLong_FromLong(x); -#ifdef HAVE_LONG_LONG - long_long: - llx = lla - llb; - return PyLong_FromLongLong(llx); -#endif - - - } - #endif - if (PyFloat_CheckExact(op2)) { - const long a = intval; - double b = PyFloat_AS_DOUBLE(op2); - double result; - PyFPE_START_PROTECT("subtract", return NULL) - result = ((double)a) - (double)b; - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); - } - return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2); -} -#endif - -/* None */ -static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) { - PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname); -} - -/* GetItemInt */ -static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!j) return NULL; - r = PyObject_GetItem(o, j); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyList_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyTuple_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* FetchCommonType */ -static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { - PyObject* fake_module; - PyTypeObject* cached_type = NULL; - fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); - if (!fake_module) return NULL; - Py_INCREF(fake_module); - cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); - if (cached_type) { - if (!PyType_Check((PyObject*)cached_type)) { - PyErr_Format(PyExc_TypeError, - "Shared Cython type %.200s is not a type object", - type->tp_name); - goto bad; - } - if (cached_type->tp_basicsize != type->tp_basicsize) { - PyErr_Format(PyExc_TypeError, - "Shared Cython type %.200s has the wrong size, try recompiling", - type->tp_name); - goto bad; - } - } else { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; - PyErr_Clear(); - if (PyType_Ready(type) < 0) goto bad; - if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) - goto bad; - Py_INCREF(type); - cached_type = type; - } -done: - Py_DECREF(fake_module); - return cached_type; -bad: - Py_XDECREF(cached_type); - cached_type = NULL; - goto done; -} - -/* CythonFunctionShared */ -#include -static PyObject * -__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) -{ - if (unlikely(op->func_doc == NULL)) { - if (op->func.m_ml->ml_doc) { -#if PY_MAJOR_VERSION >= 3 - op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); -#else - op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); -#endif - if (unlikely(op->func_doc == NULL)) - return NULL; - } else { - Py_INCREF(Py_None); - return Py_None; - } - } - Py_INCREF(op->func_doc); - return op->func_doc; -} -static int -__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) -{ - PyObject *tmp = op->func_doc; - if (value == NULL) { - value = Py_None; - } - Py_INCREF(value); - op->func_doc = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) -{ - if (unlikely(op->func_name == NULL)) { -#if PY_MAJOR_VERSION >= 3 - op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); -#else - op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); -#endif - if (unlikely(op->func_name == NULL)) - return NULL; - } - Py_INCREF(op->func_name); - return op->func_name; -} -static int -__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) -{ - PyObject *tmp; -#if PY_MAJOR_VERSION >= 3 - if (unlikely(value == NULL || !PyUnicode_Check(value))) -#else - if (unlikely(value == NULL || !PyString_Check(value))) -#endif - { - PyErr_SetString(PyExc_TypeError, - "__name__ must be set to a string object"); - return -1; - } - tmp = op->func_name; - Py_INCREF(value); - op->func_name = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) -{ - Py_INCREF(op->func_qualname); - return op->func_qualname; -} -static int -__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) -{ - PyObject *tmp; -#if PY_MAJOR_VERSION >= 3 - if (unlikely(value == NULL || !PyUnicode_Check(value))) -#else - if (unlikely(value == NULL || !PyString_Check(value))) -#endif - { - PyErr_SetString(PyExc_TypeError, - "__qualname__ must be set to a string object"); - return -1; - } - tmp = op->func_qualname; - Py_INCREF(value); - op->func_qualname = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) -{ - PyObject *self; - self = m->func_closure; - if (self == NULL) - self = Py_None; - Py_INCREF(self); - return self; -} -static PyObject * -__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) -{ - if (unlikely(op->func_dict == NULL)) { - op->func_dict = PyDict_New(); - if (unlikely(op->func_dict == NULL)) - return NULL; - } - Py_INCREF(op->func_dict); - return op->func_dict; -} -static int -__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) -{ - PyObject *tmp; - if (unlikely(value == NULL)) { - PyErr_SetString(PyExc_TypeError, - "function's dictionary may not be deleted"); - return -1; - } - if (unlikely(!PyDict_Check(value))) { - PyErr_SetString(PyExc_TypeError, - "setting function's dictionary to a non-dict"); - return -1; - } - tmp = op->func_dict; - Py_INCREF(value); - op->func_dict = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) -{ - Py_INCREF(op->func_globals); - return op->func_globals; -} -static PyObject * -__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) -{ - Py_INCREF(Py_None); - return Py_None; -} -static PyObject * -__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) -{ - PyObject* result = (op->func_code) ? op->func_code : Py_None; - Py_INCREF(result); - return result; -} -static int -__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { - int result = 0; - PyObject *res = op->defaults_getter((PyObject *) op); - if (unlikely(!res)) - return -1; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - op->defaults_tuple = PyTuple_GET_ITEM(res, 0); - Py_INCREF(op->defaults_tuple); - op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); - Py_INCREF(op->defaults_kwdict); - #else - op->defaults_tuple = PySequence_ITEM(res, 0); - if (unlikely(!op->defaults_tuple)) result = -1; - else { - op->defaults_kwdict = PySequence_ITEM(res, 1); - if (unlikely(!op->defaults_kwdict)) result = -1; - } - #endif - Py_DECREF(res); - return result; -} -static int -__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { - PyObject* tmp; - if (!value) { - value = Py_None; - } else if (value != Py_None && !PyTuple_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "__defaults__ must be set to a tuple object"); - return -1; - } - Py_INCREF(value); - tmp = op->defaults_tuple; - op->defaults_tuple = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { - PyObject* result = op->defaults_tuple; - if (unlikely(!result)) { - if (op->defaults_getter) { - if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; - result = op->defaults_tuple; - } else { - result = Py_None; - } - } - Py_INCREF(result); - return result; -} -static int -__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { - PyObject* tmp; - if (!value) { - value = Py_None; - } else if (value != Py_None && !PyDict_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "__kwdefaults__ must be set to a dict object"); - return -1; - } - Py_INCREF(value); - tmp = op->defaults_kwdict; - op->defaults_kwdict = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { - PyObject* result = op->defaults_kwdict; - if (unlikely(!result)) { - if (op->defaults_getter) { - if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; - result = op->defaults_kwdict; - } else { - result = Py_None; - } - } - Py_INCREF(result); - return result; -} -static int -__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { - PyObject* tmp; - if (!value || value == Py_None) { - value = NULL; - } else if (!PyDict_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "__annotations__ must be set to a dict object"); - return -1; - } - Py_XINCREF(value); - tmp = op->func_annotations; - op->func_annotations = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { - PyObject* result = op->func_annotations; - if (unlikely(!result)) { - result = PyDict_New(); - if (unlikely(!result)) return NULL; - op->func_annotations = result; - } - Py_INCREF(result); - return result; -} -static PyGetSetDef __pyx_CyFunction_getsets[] = { - {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, - {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, - {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, - {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, - {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, - {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, - {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, - {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, - {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, - {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, - {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, - {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, - {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, - {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, - {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, - {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, - {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, - {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, - {0, 0, 0, 0, 0} -}; -static PyMemberDef __pyx_CyFunction_members[] = { - {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0}, - {0, 0, 0, 0, 0} -}; -static PyObject * -__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) -{ -#if PY_MAJOR_VERSION >= 3 - Py_INCREF(m->func_qualname); - return m->func_qualname; -#else - return PyString_FromString(m->func.m_ml->ml_name); -#endif -} -static PyMethodDef __pyx_CyFunction_methods[] = { - {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, - {0, 0, 0, 0} -}; -#if PY_VERSION_HEX < 0x030500A0 -#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) -#else -#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) -#endif -static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, - PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { - if (unlikely(op == NULL)) - return NULL; - op->flags = flags; - __Pyx_CyFunction_weakreflist(op) = NULL; - op->func.m_ml = ml; - op->func.m_self = (PyObject *) op; - Py_XINCREF(closure); - op->func_closure = closure; - Py_XINCREF(module); - op->func.m_module = module; - op->func_dict = NULL; - op->func_name = NULL; - Py_INCREF(qualname); - op->func_qualname = qualname; - op->func_doc = NULL; - op->func_classobj = NULL; - op->func_globals = globals; - Py_INCREF(op->func_globals); - Py_XINCREF(code); - op->func_code = code; - op->defaults_pyobjects = 0; - op->defaults_size = 0; - op->defaults = NULL; - op->defaults_tuple = NULL; - op->defaults_kwdict = NULL; - op->defaults_getter = NULL; - op->func_annotations = NULL; - return (PyObject *) op; -} -static int -__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) -{ - Py_CLEAR(m->func_closure); - Py_CLEAR(m->func.m_module); - Py_CLEAR(m->func_dict); - Py_CLEAR(m->func_name); - Py_CLEAR(m->func_qualname); - Py_CLEAR(m->func_doc); - Py_CLEAR(m->func_globals); - Py_CLEAR(m->func_code); - Py_CLEAR(m->func_classobj); - Py_CLEAR(m->defaults_tuple); - Py_CLEAR(m->defaults_kwdict); - Py_CLEAR(m->func_annotations); - if (m->defaults) { - PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); - int i; - for (i = 0; i < m->defaults_pyobjects; i++) - Py_XDECREF(pydefaults[i]); - PyObject_Free(m->defaults); - m->defaults = NULL; - } - return 0; -} -static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) -{ - if (__Pyx_CyFunction_weakreflist(m) != NULL) - PyObject_ClearWeakRefs((PyObject *) m); - __Pyx_CyFunction_clear(m); - PyObject_GC_Del(m); -} -static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) -{ - PyObject_GC_UnTrack(m); - __Pyx__CyFunction_dealloc(m); -} -static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) -{ - Py_VISIT(m->func_closure); - Py_VISIT(m->func.m_module); - Py_VISIT(m->func_dict); - Py_VISIT(m->func_name); - Py_VISIT(m->func_qualname); - Py_VISIT(m->func_doc); - Py_VISIT(m->func_globals); - Py_VISIT(m->func_code); - Py_VISIT(m->func_classobj); - Py_VISIT(m->defaults_tuple); - Py_VISIT(m->defaults_kwdict); - if (m->defaults) { - PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); - int i; - for (i = 0; i < m->defaults_pyobjects; i++) - Py_VISIT(pydefaults[i]); - } - return 0; -} -static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) -{ -#if PY_MAJOR_VERSION < 3 - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { - Py_INCREF(func); - return func; - } - if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { - if (type == NULL) - type = (PyObject *)(Py_TYPE(obj)); - return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); - } - if (obj == Py_None) - obj = NULL; -#endif - return __Pyx_PyMethod_New(func, obj, type); -} -static PyObject* -__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) -{ -#if PY_MAJOR_VERSION >= 3 - return PyUnicode_FromFormat("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - PyString_AsString(op->func_qualname), (void *)op); -#endif -} -static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { - PyCFunctionObject* f = (PyCFunctionObject*)func; - PyCFunction meth = f->m_ml->ml_meth; - Py_ssize_t size; - switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { - case METH_VARARGS: - if (likely(kw == NULL || PyDict_Size(kw) == 0)) - return (*meth)(self, arg); - break; - case METH_VARARGS | METH_KEYWORDS: - return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw); - case METH_NOARGS: - if (likely(kw == NULL || PyDict_Size(kw) == 0)) { - size = PyTuple_GET_SIZE(arg); - if (likely(size == 0)) - return (*meth)(self, NULL); - PyErr_Format(PyExc_TypeError, - "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", - f->m_ml->ml_name, size); - return NULL; - } - break; - case METH_O: - if (likely(kw == NULL || PyDict_Size(kw) == 0)) { - size = PyTuple_GET_SIZE(arg); - if (likely(size == 1)) { - PyObject *result, *arg0; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - arg0 = PyTuple_GET_ITEM(arg, 0); - #else - arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; - #endif - result = (*meth)(self, arg0); - #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) - Py_DECREF(arg0); - #endif - return result; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", - f->m_ml->ml_name, size); - return NULL; - } - break; - default: - PyErr_SetString(PyExc_SystemError, "Bad call flags in " - "__Pyx_CyFunction_Call. METH_OLDARGS is no " - "longer supported!"); - return NULL; - } - PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", - f->m_ml->ml_name); - return NULL; -} -static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { - return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); -} -static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { - PyObject *result; - __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; - if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { - Py_ssize_t argc; - PyObject *new_args; - PyObject *self; - argc = PyTuple_GET_SIZE(args); - new_args = PyTuple_GetSlice(args, 1, argc); - if (unlikely(!new_args)) - return NULL; - self = PyTuple_GetItem(args, 0); - if (unlikely(!self)) { - Py_DECREF(new_args); - return NULL; - } - result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); - Py_DECREF(new_args); - } else { - result = __Pyx_CyFunction_Call(func, args, kw); - } - return result; -} -static PyTypeObject __pyx_CyFunctionType_type = { - PyVarObject_HEAD_INIT(0, 0) - "cython_function_or_method", - sizeof(__pyx_CyFunctionObject), - 0, - (destructor) __Pyx_CyFunction_dealloc, - 0, - 0, - 0, -#if PY_MAJOR_VERSION < 3 - 0, -#else - 0, -#endif - (reprfunc) __Pyx_CyFunction_repr, - 0, - 0, - 0, - 0, - __Pyx_CyFunction_CallAsMethod, - 0, - 0, - 0, - 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, - 0, - (traverseproc) __Pyx_CyFunction_traverse, - (inquiry) __Pyx_CyFunction_clear, - 0, -#if PY_VERSION_HEX < 0x030500A0 - offsetof(__pyx_CyFunctionObject, func_weakreflist), -#else - offsetof(PyCFunctionObject, m_weakreflist), -#endif - 0, - 0, - __pyx_CyFunction_methods, - __pyx_CyFunction_members, - __pyx_CyFunction_getsets, - 0, - 0, - __Pyx_CyFunction_descr_get, - 0, - offsetof(__pyx_CyFunctionObject, func_dict), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, -#if PY_VERSION_HEX >= 0x030400a1 - 0, -#endif -#if PY_VERSION_HEX >= 0x030800b1 - 0, -#endif -#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 - 0, -#endif -}; -static int __pyx_CyFunction_init(void) { - __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); - if (unlikely(__pyx_CyFunctionType == NULL)) { - return -1; - } - return 0; -} -static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->defaults = PyObject_Malloc(size); - if (unlikely(!m->defaults)) - return PyErr_NoMemory(); - memset(m->defaults, 0, size); - m->defaults_pyobjects = pyobjects; - m->defaults_size = size; - return m->defaults; -} -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->defaults_tuple = tuple; - Py_INCREF(tuple); -} -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->defaults_kwdict = dict; - Py_INCREF(dict); -} -static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->func_annotations = dict; - Py_INCREF(dict); -} - -/* CythonFunction */ -static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, - PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { - PyObject *op = __Pyx_CyFunction_Init( - PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType), - ml, flags, qualname, closure, module, globals, code - ); - if (likely(op)) { - PyObject_GC_Track(op); - } - return op; -} - -/* Import */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_MAJOR_VERSION < 3 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; - } - #endif - if (!module) { - #if PY_MAJOR_VERSION < 3 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } -bad: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_list); - Py_XDECREF(empty_dict); - return module; -} - -/* ImportFrom */ -static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { - PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); - if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Format(PyExc_ImportError, - #if PY_MAJOR_VERSION < 3 - "cannot import name %.230s", PyString_AS_STRING(name)); - #else - "cannot import name %S", name); - #endif - } - return value; -} - -/* PyObjectCallNoArg */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, NULL, 0); - } -#endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) -#else - if (likely(PyCFunction_Check(func))) -#endif - { - if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { - return __Pyx_PyObject_CallMethO(func, NULL); - } - } - return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); -} -#endif - -/* IsLittleEndian */ -static CYTHON_INLINE int __Pyx_Is_Little_Endian(void) -{ - union { - uint32_t u32; - uint8_t u8[4]; - } S; - S.u32 = 0x01020304; - return S.u8[0] == 4; -} - -/* BufferFormatCheck */ -static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type) { - stack[0].field = &ctx->root; - stack[0].parent_offset = 0; - ctx->root.type = type; - ctx->root.name = "buffer dtype"; - ctx->root.offset = 0; - ctx->head = stack; - ctx->head->field = &ctx->root; - ctx->fmt_offset = 0; - ctx->head->parent_offset = 0; - ctx->new_packmode = '@'; - ctx->enc_packmode = '@'; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->is_complex = 0; - ctx->is_valid_array = 0; - ctx->struct_alignment = 0; - while (type->typegroup == 'S') { - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = 0; - type = type->fields->type; - } -} -static int __Pyx_BufFmt_ParseNumber(const char** ts) { - int count; - const char* t = *ts; - if (*t < '0' || *t > '9') { - return -1; - } else { - count = *t++ - '0'; - while (*t >= '0' && *t <= '9') { - count *= 10; - count += *t++ - '0'; - } - } - *ts = t; - return count; -} -static int __Pyx_BufFmt_ExpectNumber(const char **ts) { - int number = __Pyx_BufFmt_ParseNumber(ts); - if (number == -1) - PyErr_Format(PyExc_ValueError,\ - "Does not understand character buffer dtype format string ('%c')", **ts); - return number; -} -static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { - PyErr_Format(PyExc_ValueError, - "Unexpected format string character: '%c'", ch); -} -static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { - switch (ch) { - case '?': return "'bool'"; - case 'c': return "'char'"; - case 'b': return "'signed char'"; - case 'B': return "'unsigned char'"; - case 'h': return "'short'"; - case 'H': return "'unsigned short'"; - case 'i': return "'int'"; - case 'I': return "'unsigned int'"; - case 'l': return "'long'"; - case 'L': return "'unsigned long'"; - case 'q': return "'long long'"; - case 'Q': return "'unsigned long long'"; - case 'f': return (is_complex ? "'complex float'" : "'float'"); - case 'd': return (is_complex ? "'complex double'" : "'double'"); - case 'g': return (is_complex ? "'complex long double'" : "'long double'"); - case 'T': return "a struct"; - case 'O': return "Python object"; - case 'P': return "a pointer"; - case 's': case 'p': return "a string"; - case 0: return "end"; - default: return "unparseable format string"; - } -} -static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return 2; - case 'i': case 'I': case 'l': case 'L': return 4; - case 'q': case 'Q': return 8; - case 'f': return (is_complex ? 8 : 4); - case 'd': return (is_complex ? 16 : 8); - case 'g': { - PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); - return 0; - } - case 'O': case 'P': return sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(short); - case 'i': case 'I': return sizeof(int); - case 'l': case 'L': return sizeof(long); - #ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(PY_LONG_LONG); - #endif - case 'f': return sizeof(float) * (is_complex ? 2 : 1); - case 'd': return sizeof(double) * (is_complex ? 2 : 1); - case 'g': return sizeof(long double) * (is_complex ? 2 : 1); - case 'O': case 'P': return sizeof(void*); - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } - } -} -typedef struct { char c; short x; } __Pyx_st_short; -typedef struct { char c; int x; } __Pyx_st_int; -typedef struct { char c; long x; } __Pyx_st_long; -typedef struct { char c; float x; } __Pyx_st_float; -typedef struct { char c; double x; } __Pyx_st_double; -typedef struct { char c; long double x; } __Pyx_st_longdouble; -typedef struct { char c; void *x; } __Pyx_st_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_st_float) - sizeof(float); - case 'd': return sizeof(__Pyx_st_double) - sizeof(double); - case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -/* These are for computing the padding at the end of the struct to align - on the first member of the struct. This will probably the same as above, - but we don't have any guarantees. - */ -typedef struct { short x; char c; } __Pyx_pad_short; -typedef struct { int x; char c; } __Pyx_pad_int; -typedef struct { long x; char c; } __Pyx_pad_long; -typedef struct { float x; char c; } __Pyx_pad_float; -typedef struct { double x; char c; } __Pyx_pad_double; -typedef struct { long double x; char c; } __Pyx_pad_longdouble; -typedef struct { void *x; char c; } __Pyx_pad_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); - case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); - case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { - switch (ch) { - case 'c': - return 'H'; - case 'b': case 'h': case 'i': - case 'l': case 'q': case 's': case 'p': - return 'I'; - case '?': case 'B': case 'H': case 'I': case 'L': case 'Q': - return 'U'; - case 'f': case 'd': case 'g': - return (is_complex ? 'C' : 'R'); - case 'O': - return 'O'; - case 'P': - return 'P'; - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } - } -} -static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { - if (ctx->head == NULL || ctx->head->field == &ctx->root) { - const char* expected; - const char* quote; - if (ctx->head == NULL) { - expected = "end"; - quote = ""; - } else { - expected = ctx->head->field->type->name; - quote = "'"; - } - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected %s%s%s but got %s", - quote, expected, quote, - __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); - } else { - __Pyx_StructField* field = ctx->head->field; - __Pyx_StructField* parent = (ctx->head - 1)->field; - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", - field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), - parent->type->name, field->name); - } -} -static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { - char group; - size_t size, offset, arraysize = 1; - if (ctx->enc_type == 0) return 0; - if (ctx->head->field->type->arraysize[0]) { - int i, ndim = 0; - if (ctx->enc_type == 's' || ctx->enc_type == 'p') { - ctx->is_valid_array = ctx->head->field->type->ndim == 1; - ndim = 1; - if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { - PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %zu", - ctx->head->field->type->arraysize[0], ctx->enc_count); - return -1; - } - } - if (!ctx->is_valid_array) { - PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", - ctx->head->field->type->ndim, ndim); - return -1; - } - for (i = 0; i < ctx->head->field->type->ndim; i++) { - arraysize *= ctx->head->field->type->arraysize[i]; - } - ctx->is_valid_array = 0; - ctx->enc_count = 1; - } - group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); - do { - __Pyx_StructField* field = ctx->head->field; - __Pyx_TypeInfo* type = field->type; - if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { - size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); - } else { - size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); - } - if (ctx->enc_packmode == '@') { - size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); - size_t align_mod_offset; - if (align_at == 0) return -1; - align_mod_offset = ctx->fmt_offset % align_at; - if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; - if (ctx->struct_alignment == 0) - ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, - ctx->is_complex); - } - if (type->size != size || type->typegroup != group) { - if (type->typegroup == 'C' && type->fields != NULL) { - size_t parent_offset = ctx->head->parent_offset + field->offset; - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = parent_offset; - continue; - } - if ((type->typegroup == 'H' || group == 'H') && type->size == size) { - } else { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; - } - } - offset = ctx->head->parent_offset + field->offset; - if (ctx->fmt_offset != offset) { - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", - (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); - return -1; - } - ctx->fmt_offset += size; - if (arraysize) - ctx->fmt_offset += (arraysize - 1) * size; - --ctx->enc_count; - while (1) { - if (field == &ctx->root) { - ctx->head = NULL; - if (ctx->enc_count != 0) { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; - } - break; - } - ctx->head->field = ++field; - if (field->type == NULL) { - --ctx->head; - field = ctx->head->field; - continue; - } else if (field->type->typegroup == 'S') { - size_t parent_offset = ctx->head->parent_offset + field->offset; - if (field->type->fields->type == NULL) continue; - field = field->type->fields; - ++ctx->head; - ctx->head->field = field; - ctx->head->parent_offset = parent_offset; - break; - } else { - break; - } - } - } while (ctx->enc_count); - ctx->enc_type = 0; - ctx->is_complex = 0; - return 0; -} -static PyObject * -__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) -{ - const char *ts = *tsp; - int i = 0, number, ndim; - ++ts; - if (ctx->new_count != 1) { - PyErr_SetString(PyExc_ValueError, - "Cannot handle repeated arrays in format string"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ndim = ctx->head->field->type->ndim; - while (*ts && *ts != ')') { - switch (*ts) { - case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; - default: break; - } - number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) - return PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %d", - ctx->head->field->type->arraysize[i], number); - if (*ts != ',' && *ts != ')') - return PyErr_Format(PyExc_ValueError, - "Expected a comma in format string, got '%c'", *ts); - if (*ts == ',') ts++; - i++; - } - if (i != ndim) - return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", - ctx->head->field->type->ndim, i); - if (!*ts) { - PyErr_SetString(PyExc_ValueError, - "Unexpected end of format string, expected ')'"); - return NULL; - } - ctx->is_valid_array = 1; - ctx->new_count = 1; - *tsp = ++ts; - return Py_None; -} -static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { - int got_Z = 0; - while (1) { - switch(*ts) { - case 0: - if (ctx->enc_type != 0 && ctx->head == NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - if (ctx->head != NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - return ts; - case ' ': - case '\r': - case '\n': - ++ts; - break; - case '<': - if (!__Pyx_Is_Little_Endian()) { - PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '>': - case '!': - if (__Pyx_Is_Little_Endian()) { - PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '=': - case '@': - case '^': - ctx->new_packmode = *ts++; - break; - case 'T': - { - const char* ts_after_sub; - size_t i, struct_count = ctx->new_count; - size_t struct_alignment = ctx->struct_alignment; - ctx->new_count = 1; - ++ts; - if (*ts != '{') { - PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - ctx->enc_count = 0; - ctx->struct_alignment = 0; - ++ts; - ts_after_sub = ts; - for (i = 0; i != struct_count; ++i) { - ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); - if (!ts_after_sub) return NULL; - } - ts = ts_after_sub; - if (struct_alignment) ctx->struct_alignment = struct_alignment; - } - break; - case '}': - { - size_t alignment = ctx->struct_alignment; - ++ts; - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - if (alignment && ctx->fmt_offset % alignment) { - ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); - } - } - return ts; - case 'x': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->fmt_offset += ctx->new_count; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->enc_packmode = ctx->new_packmode; - ++ts; - break; - case 'Z': - got_Z = 1; - ++ts; - if (*ts != 'f' && *ts != 'd' && *ts != 'g') { - __Pyx_BufFmt_RaiseUnexpectedChar('Z'); - return NULL; - } - CYTHON_FALLTHROUGH; - case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': - case 'l': case 'L': case 'q': case 'Q': - case 'f': case 'd': case 'g': - case 'O': case 'p': - if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) && - (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) { - ctx->enc_count += ctx->new_count; - ctx->new_count = 1; - got_Z = 0; - ++ts; - break; - } - CYTHON_FALLTHROUGH; - case 's': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_count = ctx->new_count; - ctx->enc_packmode = ctx->new_packmode; - ctx->enc_type = *ts; - ctx->is_complex = got_Z; - ++ts; - ctx->new_count = 1; - got_Z = 0; - break; - case ':': - ++ts; - while(*ts != ':') ++ts; - ++ts; - break; - case '(': - if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; - break; - default: - { - int number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - ctx->new_count = (size_t)number; - } - } - } -} - -/* BufferGetAndValidate */ - static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { - if (unlikely(info->buf == NULL)) return; - if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; - __Pyx_ReleaseBuffer(info); -} -static void __Pyx_ZeroBuffer(Py_buffer* buf) { - buf->buf = NULL; - buf->obj = NULL; - buf->strides = __Pyx_zeros; - buf->shape = __Pyx_zeros; - buf->suboffsets = __Pyx_minusones; -} -static int __Pyx__GetBufferAndValidate( - Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, - int nd, int cast, __Pyx_BufFmt_StackElem* stack) -{ - buf->buf = NULL; - if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) { - __Pyx_ZeroBuffer(buf); - return -1; - } - if (unlikely(buf->ndim != nd)) { - PyErr_Format(PyExc_ValueError, - "Buffer has wrong number of dimensions (expected %d, got %d)", - nd, buf->ndim); - goto fail; - } - if (!cast) { - __Pyx_BufFmt_Context ctx; - __Pyx_BufFmt_Init(&ctx, stack, dtype); - if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; - } - if (unlikely((size_t)buf->itemsize != dtype->size)) { - PyErr_Format(PyExc_ValueError, - "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", - buf->itemsize, (buf->itemsize > 1) ? "s" : "", - dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); - goto fail; - } - if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; - return 0; -fail:; - __Pyx_SafeReleaseBuffer(buf); - return -1; -} - -/* BufferIndexError */ - static void __Pyx_RaiseBufferIndexError(int axis) { - PyErr_Format(PyExc_IndexError, - "Out of bounds on buffer access (axis %d)", axis); -} - -/* PyErrFetchRestore */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -} -#endif - -/* ArgTypeTest */ - static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) -{ - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - else if (exact) { - #if PY_MAJOR_VERSION == 2 - if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif - } - else { - if (likely(__Pyx_TypeCheck(obj, type))) return 1; - } - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); - return 0; -} - -/* GetTopmostException */ - #if CYTHON_USE_EXC_INFO_STACK -static _PyErr_StackItem * -__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) -{ - _PyErr_StackItem *exc_info = tstate->exc_info; - while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && - exc_info->previous_item != NULL) - { - exc_info = exc_info->previous_item; - } - return exc_info; -} -#endif - -/* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - #if CYTHON_USE_EXC_INFO_STACK - _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); - *type = exc_info->exc_type; - *value = exc_info->exc_value; - *tb = exc_info->exc_traceback; - #else - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - #endif - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -} -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - #if CYTHON_USE_EXC_INFO_STACK - _PyErr_StackItem *exc_info = tstate->exc_info; - tmp_type = exc_info->exc_type; - tmp_value = exc_info->exc_value; - tmp_tb = exc_info->exc_traceback; - exc_info->exc_type = type; - exc_info->exc_value = value; - exc_info->exc_traceback = tb; - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -#endif - -/* PyErrExceptionMatches */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; icurexc_type; - if (exc_type == err) return 1; - if (unlikely(!exc_type)) return 0; - if (unlikely(PyTuple_Check(err))) - return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); - return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); -} -#endif - -/* GetException */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) -#endif -{ - PyObject *local_type, *local_value, *local_tb; -#if CYTHON_FAST_THREAD_STATE - PyObject *tmp_type, *tmp_value, *tmp_tb; - local_type = tstate->curexc_type; - local_value = tstate->curexc_value; - local_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -#else - PyErr_Fetch(&local_type, &local_value, &local_tb); -#endif - PyErr_NormalizeException(&local_type, &local_value, &local_tb); -#if CYTHON_FAST_THREAD_STATE - if (unlikely(tstate->curexc_type)) -#else - if (unlikely(PyErr_Occurred())) -#endif - goto bad; - #if PY_MAJOR_VERSION >= 3 - if (local_tb) { - if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) - goto bad; - } - #endif - Py_XINCREF(local_tb); - Py_XINCREF(local_type); - Py_XINCREF(local_value); - *type = local_type; - *value = local_value; - *tb = local_tb; -#if CYTHON_FAST_THREAD_STATE - #if CYTHON_USE_EXC_INFO_STACK - { - _PyErr_StackItem *exc_info = tstate->exc_info; - tmp_type = exc_info->exc_type; - tmp_value = exc_info->exc_value; - tmp_tb = exc_info->exc_traceback; - exc_info->exc_type = local_type; - exc_info->exc_value = local_value; - exc_info->exc_traceback = local_tb; - } - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = local_type; - tstate->exc_value = local_value; - tstate->exc_traceback = local_tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(local_type, local_value, local_tb); -#endif - return 0; -bad: - *type = 0; - *value = 0; - *tb = 0; - Py_XDECREF(local_type); - Py_XDECREF(local_value); - Py_XDECREF(local_tb); - return -1; -} - -/* RaiseException */ - #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - __Pyx_PyThreadState_declare - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - } - if (PyType_Check(type)) { -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; - } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - value = type; - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - } - __Pyx_PyThreadState_assign - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { - PyObject* owned_instance = NULL; - if (tb == Py_None) { - tb = 0; - } else if (tb && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto bad; - } - if (value == Py_None) - value = 0; - if (PyExceptionInstance_Check(type)) { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto bad; - } - value = type; - type = (PyObject*) Py_TYPE(value); - } else if (PyExceptionClass_Check(type)) { - PyObject *instance_class = NULL; - if (value && PyExceptionInstance_Check(value)) { - instance_class = (PyObject*) Py_TYPE(value); - if (instance_class != type) { - int is_subclass = PyObject_IsSubclass(instance_class, type); - if (!is_subclass) { - instance_class = NULL; - } else if (unlikely(is_subclass == -1)) { - goto bad; - } else { - type = instance_class; - } - } - } - if (!instance_class) { - PyObject *args; - if (!value) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } else - args = PyTuple_Pack(1, value); - if (!args) - goto bad; - owned_instance = PyObject_Call(type, args, NULL); - Py_DECREF(args); - if (!owned_instance) - goto bad; - value = owned_instance; - if (!PyExceptionInstance_Check(value)) { - PyErr_Format(PyExc_TypeError, - "calling %R should have returned an instance of " - "BaseException, not %R", - type, Py_TYPE(value)); - goto bad; - } - } - } else { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto bad; - } - if (cause) { - PyObject *fixed_cause; - if (cause == Py_None) { - fixed_cause = NULL; - } else if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); - if (fixed_cause == NULL) - goto bad; - } else if (PyExceptionInstance_Check(cause)) { - fixed_cause = cause; - Py_INCREF(fixed_cause); - } else { - PyErr_SetString(PyExc_TypeError, - "exception causes must derive from " - "BaseException"); - goto bad; - } - PyException_SetCause(value, fixed_cause); - } - PyErr_SetObject(type, value); - if (tb) { -#if CYTHON_COMPILING_IN_PYPY - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); - Py_INCREF(tb); - PyErr_Restore(tmp_type, tmp_value, tb); - Py_XDECREF(tmp_tb); -#else - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject* tmp_tb = tstate->curexc_traceback; - if (tb != tmp_tb) { - Py_INCREF(tb); - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_tb); - } -#endif - } -bad: - Py_XDECREF(owned_instance); - return; -} -#endif - -/* PyObject_GenericGetAttrNoDict */ - #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 -static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { - PyErr_Format(PyExc_AttributeError, -#if PY_MAJOR_VERSION >= 3 - "'%.50s' object has no attribute '%U'", - tp->tp_name, attr_name); -#else - "'%.50s' object has no attribute '%.400s'", - tp->tp_name, PyString_AS_STRING(attr_name)); -#endif - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { - PyObject *descr; - PyTypeObject *tp = Py_TYPE(obj); - if (unlikely(!PyString_Check(attr_name))) { - return PyObject_GenericGetAttr(obj, attr_name); - } - assert(!tp->tp_dictoffset); - descr = _PyType_Lookup(tp, attr_name); - if (unlikely(!descr)) { - return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); - } - Py_INCREF(descr); - #if PY_MAJOR_VERSION < 3 - if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) - #endif - { - descrgetfunc f = Py_TYPE(descr)->tp_descr_get; - if (unlikely(f)) { - PyObject *res = f(descr, obj, (PyObject *)tp); - Py_DECREF(descr); - return res; - } - } - return descr; -} -#endif - -/* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType -#define __PYX_HAVE_RT_ImportType -static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, - size_t size, enum __Pyx_ImportType_CheckSize check_size) -{ - PyObject *result = 0; - char warning[200]; - Py_ssize_t basicsize; -#ifdef Py_LIMITED_API - PyObject *py_basicsize; -#endif - result = PyObject_GetAttrString(module, class_name); - if (!result) - goto bad; - if (!PyType_Check(result)) { - PyErr_Format(PyExc_TypeError, - "%.200s.%.200s is not a type object", - module_name, class_name); - goto bad; - } -#ifndef Py_LIMITED_API - basicsize = ((PyTypeObject *)result)->tp_basicsize; -#else - py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); - if (!py_basicsize) - goto bad; - basicsize = PyLong_AsSsize_t(py_basicsize); - Py_DECREF(py_basicsize); - py_basicsize = 0; - if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) - goto bad; -#endif - if ((size_t)basicsize < size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - goto bad; - } - if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - goto bad; - } - else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) { - PyOS_snprintf(warning, sizeof(warning), - "%s.%s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; - } - return (PyTypeObject *)result; -bad: - Py_XDECREF(result); - return NULL; -} -#endif - -/* CLineInTraceback */ - #ifndef CYTHON_CLINE_IN_TRACEBACK -static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) { - PyObject *use_cline; - PyObject *ptype, *pvalue, *ptraceback; -#if CYTHON_COMPILING_IN_CPYTHON - PyObject **cython_runtime_dict; -#endif - if (unlikely(!__pyx_cython_runtime)) { - return c_line; - } - __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); -#if CYTHON_COMPILING_IN_CPYTHON - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (likely(cython_runtime_dict)) { - __PYX_PY_DICT_LOOKUP_IF_MODIFIED( - use_cline, *cython_runtime_dict, - __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) - } else -#endif - { - PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); - if (use_cline_obj) { - use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; - Py_DECREF(use_cline_obj); - } else { - PyErr_Clear(); - use_cline = NULL; - } - } - if (!use_cline) { - c_line = 0; - PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); - } - else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { - c_line = 0; - } - __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); - return c_line; -} -#endif - -/* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { - int start = 0, mid = 0, end = count - 1; - if (end >= 0 && code_line > entries[end].code_line) { - return count; - } - while (start < end) { - mid = start + (end - start) / 2; - if (code_line < entries[mid].code_line) { - end = mid; - } else if (code_line > entries[mid].code_line) { - start = mid + 1; - } else { - return mid; - } - } - if (code_line <= entries[mid].code_line) { - return mid; - } else { - return mid + 1; - } -} -static PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_code_cache.count = 1; - entries[0].code_line = code_line; - entries[0].code_object = code_object; - Py_INCREF(code_object); - } - return; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -/* AddTraceback */ - #include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, - 0, - 0, - 0, - 0, - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - return NULL; -} -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyFrameObject *py_frame = 0; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - if (c_line) { - c_line = __Pyx_CLineForTraceback(tstate, c_line); - } - py_code = __pyx_find_code_object(c_line ? -c_line : py_line); - if (!py_code) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); - } - py_frame = PyFrame_New( - tstate, /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __pyx_d, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - __Pyx_PyFrame_SetLineNumber(py_frame, py_line); - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} - -#if PY_MAJOR_VERSION < 3 -static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { - if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); - PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); - return -1; -} -static void __Pyx_ReleaseBuffer(Py_buffer *view) { - PyObject *obj = view->obj; - if (!obj) return; - if (PyObject_CheckBuffer(obj)) { - PyBuffer_Release(view); - return; - } - if ((0)) {} - view->obj = NULL; - Py_DECREF(obj); -} -#endif - - - /* Declarations */ - #if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return ::std::complex< float >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return x + y*(__pyx_t_float_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - __pyx_t_float_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -/* Arithmetic */ - #if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - #if 1 - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - if (b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); - } else if (fabsf(b.real) >= fabsf(b.imag)) { - if (b.real == 0 && b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag); - } else { - float r = b.imag / b.real; - float s = (float)(1.0) / (b.real + b.imag * r); - return __pyx_t_float_complex_from_parts( - (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); - } - } else { - float r = b.real / b.imag; - float s = (float)(1.0) / (b.imag + b.real * r); - return __pyx_t_float_complex_from_parts( - (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); - } - } - #else - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - if (b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); - } else { - float denom = b.real * b.real + b.imag * b.imag; - return __pyx_t_float_complex_from_parts( - (a.real * b.real + a.imag * b.imag) / denom, - (a.imag * b.real - a.real * b.imag) / denom); - } - } - #endif - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrtf(z.real*z.real + z.imag*z.imag); - #else - return hypotf(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - float r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - float denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - return __Pyx_c_prod_float(a, a); - case 3: - z = __Pyx_c_prod_float(a, a); - return __Pyx_c_prod_float(z, a); - case 4: - z = __Pyx_c_prod_float(a, a); - return __Pyx_c_prod_float(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } else if (b.imag == 0) { - z.real = powf(a.real, b.real); - z.imag = 0; - return z; - } else if (a.real > 0) { - r = a.real; - theta = 0; - } else { - r = -a.real; - theta = atan2f(0.0, -1.0); - } - } else { - r = __Pyx_c_abs_float(a); - theta = atan2f(a.imag, a.real); - } - lnr = logf(r); - z_r = expf(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cosf(z_theta); - z.imag = z_r * sinf(z_theta); - return z; - } - #endif -#endif - -/* Declarations */ - #if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return ::std::complex< double >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return x + y*(__pyx_t_double_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - __pyx_t_double_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -/* Arithmetic */ - #if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - #if 1 - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - if (b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); - } else if (fabs(b.real) >= fabs(b.imag)) { - if (b.real == 0 && b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag); - } else { - double r = b.imag / b.real; - double s = (double)(1.0) / (b.real + b.imag * r); - return __pyx_t_double_complex_from_parts( - (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); - } - } else { - double r = b.real / b.imag; - double s = (double)(1.0) / (b.imag + b.real * r); - return __pyx_t_double_complex_from_parts( - (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); - } - } - #else - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - if (b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); - } else { - double denom = b.real * b.real + b.imag * b.imag; - return __pyx_t_double_complex_from_parts( - (a.real * b.real + a.imag * b.imag) / denom, - (a.imag * b.real - a.real * b.imag) / denom); - } - } - #endif - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrt(z.real*z.real + z.imag*z.imag); - #else - return hypot(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - double r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - double denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - return __Pyx_c_prod_double(a, a); - case 3: - z = __Pyx_c_prod_double(a, a); - return __Pyx_c_prod_double(z, a); - case 4: - z = __Pyx_c_prod_double(a, a); - return __Pyx_c_prod_double(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } else if (b.imag == 0) { - z.real = pow(a.real, b.real); - z.imag = 0; - return z; - } else if (a.real > 0) { - r = a.real; - theta = 0; - } else { - r = -a.real; - theta = atan2(0.0, -1.0); - } - } else { - r = __Pyx_c_abs_double(a); - theta = atan2(a.imag, a.real); - } - lnr = log(r); - z_r = exp(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cos(z_theta); - z.imag = z_r * sin(z_theta); - return z; - } - #endif -#endif - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) -#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) -#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ - {\ - func_type value = func_value;\ - if (sizeof(target_type) < sizeof(func_type)) {\ - if (unlikely(value != (func_type) (target_type) value)) {\ - func_type zero = 0;\ - if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ - return (target_type) -1;\ - if (is_unsigned && unlikely(value < zero))\ - goto raise_neg_overflow;\ - else\ - goto raise_overflow;\ - }\ - }\ - return (target_type) value;\ - } - -/* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { - return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { - return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { - return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (long) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) - case -2: - if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - } -#endif - if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to long"); - return (long) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; -} - -/* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const int neg_one = (int) -1, const_zero = (int) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (int) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) - case -2: - if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - } -#endif - if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int"); - return (int) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; -} - -/* FastTypeChecks */ - #if CYTHON_COMPILING_IN_CPYTHON -static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { - while (a) { - a = a->tp_base; - if (a == b) - return 1; - } - return b == &PyBaseObject_Type; -} -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { - PyObject *mro; - if (a == b) return 1; - mro = a->tp_mro; - if (likely(mro)) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(mro); - for (i = 0; i < n; i++) { - if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) - return 1; - } - return 0; - } - return __Pyx_InBases(a, b); -} -#if PY_MAJOR_VERSION == 2 -static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { - PyObject *exception, *value, *tb; - int res; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&exception, &value, &tb); - res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - if (!res) { - res = PyObject_IsSubclass(err, exc_type2); - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - } - __Pyx_ErrRestore(exception, value, tb); - return res; -} -#else -static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { - int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; - if (!res) { - res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); - } - return res; -} -#endif -static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - assert(PyExceptionClass_Check(exc_type)); - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; ip) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - if (PyObject_Hash(*t->p) == -1) - return -1; - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { - Py_ssize_t ignore; - return __Pyx_PyObject_AsStringAndSize(o, &ignore); -} -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -#if !CYTHON_PEP393_ENABLED -static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -} -#else -static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (likely(PyUnicode_IS_ASCII(o))) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } -#else - return PyUnicode_AsUTF8AndSize(o, length); -#endif -} -#endif -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { - return __Pyx_PyUnicode_AsStringAndSize(o, length); - } else -#endif -#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif - { - char* result; - int r = PyBytes_AsStringAndSize(o, &result, length); - if (unlikely(r < 0)) { - return NULL; - } else { - return result; - } - } -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { - int is_true = x == Py_True; - if (is_true | (x == Py_False) | (x == Py_None)) return is_true; - else return PyObject_IsTrue(x); -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { - int retval; - if (unlikely(!x)) return -1; - retval = __Pyx_PyObject_IsTrue(x); - Py_DECREF(x); - return retval; -} -static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { -#if PY_MAJOR_VERSION >= 3 - if (PyLong_Check(result)) { - if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, - "__int__ returned non-int (type %.200s). " - "The ability to return an instance of a strict subclass of int " - "is deprecated, and may be removed in a future version of Python.", - Py_TYPE(result)->tp_name)) { - Py_DECREF(result); - return NULL; - } - return result; - } -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - type_name, type_name, Py_TYPE(result)->tp_name); - Py_DECREF(result); - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { -#if CYTHON_USE_TYPE_SLOTS - PyNumberMethods *m; -#endif - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x) || PyLong_Check(x))) -#else - if (likely(PyLong_Check(x))) -#endif - return __Pyx_NewRef(x); -#if CYTHON_USE_TYPE_SLOTS - m = Py_TYPE(x)->tp_as_number; - #if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = m->nb_int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = m->nb_long(x); - } - #else - if (likely(m && m->nb_int)) { - name = "int"; - res = m->nb_int(x); - } - #endif -#else - if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { - res = PyNumber_Int(x); - } -#endif - if (likely(res)) { -#if PY_MAJOR_VERSION < 3 - if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { -#else - if (unlikely(!PyLong_CheckExact(res))) { -#endif - return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); - } - } - else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "an integer is required"); - } - return res; -} -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { - Py_ssize_t ival; - PyObject *x; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) { - if (sizeof(Py_ssize_t) >= sizeof(long)) - return PyInt_AS_LONG(b); - else - return PyInt_AsSsize_t(b); - } -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)b)->ob_digit; - const Py_ssize_t size = Py_SIZE(b); - if (likely(__Pyx_sst_abs(size) <= 1)) { - ival = likely(size) ? digits[0] : 0; - if (size == -1) ival = -ival; - return ival; - } else { - switch (size) { - case 2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - } - } - #endif - return PyLong_AsSsize_t(b); - } - x = PyNumber_Index(b); - if (!x) return -1; - ival = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { - return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { - return PyInt_FromSize_t(ival); -} - - -#endif /* Py_PYTHON_H */ diff --git a/landcover-L-SAR/tool/LAI/build/temp.win-amd64-3.8/Release/build/LAIProcess.cp38-win_amd64.exp b/landcover-L-SAR/tool/LAI/build/temp.win-amd64-3.8/Release/build/LAIProcess.cp38-win_amd64.exp deleted file mode 100644 index 8d773ec..0000000 Binary files a/landcover-L-SAR/tool/LAI/build/temp.win-amd64-3.8/Release/build/LAIProcess.cp38-win_amd64.exp and /dev/null differ diff --git a/landcover-L-SAR/tool/LAI/build/temp.win-amd64-3.8/Release/build/LAIProcess.cp38-win_amd64.lib b/landcover-L-SAR/tool/LAI/build/temp.win-amd64-3.8/Release/build/LAIProcess.cp38-win_amd64.lib deleted file mode 100644 index 1938c72..0000000 Binary files a/landcover-L-SAR/tool/LAI/build/temp.win-amd64-3.8/Release/build/LAIProcess.cp38-win_amd64.lib and /dev/null differ diff --git a/landcover-L-SAR/tool/LAI/build/temp.win-amd64-3.8/Release/build/LAIProcess.obj b/landcover-L-SAR/tool/LAI/build/temp.win-amd64-3.8/Release/build/LAIProcess.obj deleted file mode 100644 index 85b20de..0000000 Binary files a/landcover-L-SAR/tool/LAI/build/temp.win-amd64-3.8/Release/build/LAIProcess.obj and /dev/null differ diff --git a/landcover-L-SAR/tool/LAI/setup.py b/landcover-L-SAR/tool/LAI/setup.py deleted file mode 100644 index 67c737a..0000000 --- a/landcover-L-SAR/tool/LAI/setup.py +++ /dev/null @@ -1,45 +0,0 @@ -from setuptools import setup -from setuptools.extension import Extension -from Cython.Distutils import build_ext -from Cython.Build import cythonize -import numpy -from pathlib import Path -import shutil - - -class MyBuildExt(build_ext): - def run(self): - build_ext.run(self) - - build_dir = Path(self.build_lib) - root_dir = Path(__file__).parent - target_dir = build_dir if not self.inplace else root_dir - - self.copy_file(Path('./LAIProcess') / '__init__.py', root_dir, target_dir) - #self.copy_file(Path('./pkg2') / '__init__.py', root_dir, target_dir) - self.copy_file(Path('.') / '__init__.py', root_dir, target_dir) - def copy_file(self, path, source_dir, destination_dir): - if not (source_dir / path).exists(): - return - shutil.copyfile(str(source_dir / path), str(destination_dir / path)) - -setup( - name="MyModule", - ext_modules=cythonize( - [ - #Extension("pkg1.*", ["root/pkg1/*.py"]), - Extension("pkg2.*", ["./LAIProcess.pyx"]), - #Extension("1.*", ["root/*.py"]) - ], - build_dir="build", - compiler_directives=dict( - always_allow_keywords=True - )), - cmdclass=dict( - build_ext=MyBuildExt - ), - packages=[], - include_dirs=[numpy.get_include()], -) - -# 指令: python setup.py build_ext --inplace diff --git a/landcover-L-SAR/tool/algorithm/algtools/CoordinateTransformation.py b/landcover-L-SAR/tool/algorithm/algtools/CoordinateTransformation.py deleted file mode 100644 index 8afe99b..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/CoordinateTransformation.py +++ /dev/null @@ -1,117 +0,0 @@ -# -*- encoding: utf-8 -*- -# code from https://blog.csdn.net/theonegis/article/details/54427906 -from osgeo import gdal -from osgeo import osr -import numpy as np - -def getSRSPair(dataset): - """ - 获得给定数据的投影参考系和地理参考系 - :param dataset: GDAL地理数据 - :return: 投影参考系和地理参考系 - """ - prosrs = osr.SpatialReference() - prosrs.ImportFromWkt(dataset.GetProjection()) - geosrs = prosrs.CloneGeogCS() - return prosrs, geosrs - - -def geo2lonlat(dataset, x, y): - """ - 将投影坐标转为经纬度坐标(具体的投影坐标系由给定数据确定) - :param dataset: GDAL地理数据 - :param x: 投影坐标x - :param y: 投影坐标y - :return: 投影坐标(x, y)对应的经纬度坐标(lon, lat) - """ - prosrs, geosrs = getSRSPair(dataset) - ct = osr.CoordinateTransformation(prosrs, geosrs) - coords = ct.TransformPoint(x, y) - return coords[:2] - - -def lonlat2geo(dataset, lon, lat): - """ - 将经纬度坐标转为投影坐标(具体的投影坐标系由给定数据确定) - :param dataset: GDAL地理数据 - :param lon: 地理坐标lon经度 - :param lat: 地理坐标lat纬度 - :return: 经纬度坐标(lon, lat)对应的投影坐标 - """ - prosrs, geosrs = getSRSPair(dataset) - ct = osr.CoordinateTransformation(geosrs, prosrs) - coords = ct.TransformPoint(lat, lon) - return coords[:2] - - -def imagexy2geo(dataset, row, col): - """ - 根据GDAL的六参数模型将影像图上坐标(行列号)转为投影坐标或地理坐标(根据具体数据的坐标系统转换) - :param dataset: GDAL地理数据 - :param row: 像素的行号 - :param col: 像素的列号 - :return: 行列号(row, col)对应的投影坐标或地理坐标(x, y) - """ - trans = dataset.GetGeoTransform() - px = trans[0] + col * trans[1] + row * trans[2] - py = trans[3] + col * trans[4] + row * trans[5] - return px, py - - -def geo2imagexy(dataset, x, y): - """ - 根据GDAL的六 参数模型将给定的投影或地理坐标转为影像图上坐标(行列号) - :param dataset: GDAL地理数据 - :param x: 投影或地理坐标x - :param y: 投影或地理坐标y - :return: 影坐标或地理坐标(x, y)对应的影像图上行列号(col, row) - """ - trans = dataset.GetGeoTransform() - a = np.array([[trans[1], trans[2]], [trans[4], trans[5]]]) - b = np.array([x - trans[0], y - trans[3]]) - return np.linalg.solve(a, b) # 使用numpy的linalg.solve进行二元一次方程的求解 - - -def test1(): - gdal.AllRegister() - tif = 'D:/DATA/testdata/GLCFCS30_E110N25.tif' - # dataset = gdal.Open(r"D:\\DATA\\雷达测试\\GaoFen3_20200528_HH_DB.tif") - dataset = gdal.Open(tif) - - print('数据投影:') - print(dataset.GetProjection()) - print('数据的大小(行,列):') - print('(%s %s)' % (dataset.RasterYSize, dataset.RasterXSize)) - - x = 793214.118 - y = 2485865.527 - lon = 113.84897082317516 - lat = 22.453998686022448 - row = 24576 - col = 22540 - - print('图上坐标 -> 投影坐标:') - coords = imagexy2geo(dataset, row, col) - print('(%s, %s)->(%s, %s)' % (row, col, coords[0], coords[1])) - print('投影坐标 -> 图上坐标:') - coords = geo2imagexy(dataset, x, y) - col = coords[0] - row = coords[1] - print('(%s, %s)->(%s, %s)' % (x, y, coords[0], coords[1])) - - print('投影坐标 -> 经纬度:') - coords = geo2lonlat(dataset, x, y) - print('(%s, %s)->(%s, %s)' % (x, y, coords[0], coords[1])) - print('经纬度 -> 投影坐标:') - coords = lonlat2geo(dataset, lon, lat) - print('(%s, %s)->(%s, %s)' % (lon, lat, coords[0], coords[1])) - - coords1 = geo2lonlat(dataset, 657974.118, 2633321.527) - print(coords1) - coords2 = geo2lonlat(dataset, 793214.118, 2485865.527) - print(coords2) - pass - -# if __name__ == '__main__': -# -# print('done') diff --git a/landcover-L-SAR/tool/algorithm/algtools/DEMJoint.py b/landcover-L-SAR/tool/algorithm/algtools/DEMJoint.py deleted file mode 100644 index d3a71cd..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/DEMJoint.py +++ /dev/null @@ -1,156 +0,0 @@ -""" -@Project :microproduct -@File :DEMJoint -@Function :主函数 -@Author :LMM -@Date :2021/10/19 14:39 -@Version :1.0.0 -""" -from osgeo import gdal, osr -import os -import numpy as np - - -class DEMProcess: - """ - DEM拼接、重采样 - """ - def __init__(self): - pass - - @staticmethod - def get_extent(fn): - ''' - 原文链接:https://blog.csdn.net/XBR_2014/article/details/85255412 - ''' - ds = gdal.Open(fn) - rows = ds.RasterYSize - cols = ds.RasterXSize - # 获取图像角点坐标 - gt = ds.GetGeoTransform() - minx = gt[0] - maxy = gt[3] - maxx = gt[0] + gt[1] * rows - miny = gt[3] + gt[5] * cols - return (minx, maxy, maxx, miny) - - @staticmethod - def img_mosaic(in_files, out_dem_path): - # 通过两两比较大小,将最终符合条件的四个角点坐标保存 - # 即为拼接图像的四个角点坐标 - minX, maxY, maxX, minY = DEMProcess.get_extent(in_files[0]) - for fn in in_files[1:]: - minx, maxy, maxx, miny = DEMProcess.get_extent(fn) - minX = min(minX, minx) - maxY = max(maxY, maxy) - maxX = max(maxX, maxx) - minY = min(minY, miny) - - # 获取输出图像的行列数 - in_ds = gdal.Open(in_files[0]) - bands_num = in_ds.RasterCount - gt = in_ds.GetGeoTransform() - rows = int((maxX - minX) / abs(gt[5])) - cols = int((maxY - minY) / gt[1]) - - # 判断栅格数据的数据类型 - datatype = gdal.GDT_UInt16 - - # 创建输出图像 - driver = gdal.GetDriverByName('GTiff') - out_dem = os.path.join(out_dem_path, 'mosaic0.tif') - out_ds = driver.Create(out_dem, cols, rows, bands_num, datatype) - out_ds.SetProjection(in_ds.GetProjection()) - - gt = list(in_ds.GetGeoTransform()) - gt[0], gt[3] = minX, maxY - out_ds.SetGeoTransform(gt) - - for fn in in_files: - in_ds = gdal.Open(fn) - x_size = in_ds.RasterXSize - y_size = in_ds.RasterYSize - trans = gdal.Transformer(in_ds, out_ds, []) - success, xyz = trans.TransformPoint(False, 0, 0) - x, y, z = map(int, xyz) - for i in range(1, bands_num + 1): - data = in_ds.GetRasterBand(i).ReadAsArray() - out_band = out_ds.GetRasterBand(i) - out_data = out_band.ReadAsArray(x, y, x_size, y_size) - data = np.maximum(data, out_data) - out_band.WriteArray(data, x, y) - - del in_ds, out_band, out_ds - - @staticmethod - def dem_clip(OutFilePath, DEMFilePath, SelectArea): - ''' - 根据选择范围裁剪DEM,并输出 - agrs: - outFilePath:裁剪DEM输出地址 - DEMFilePath:被裁减DEM地址 - SelectArea:list [(xmin,ymax),(xmax,ymin)] 框选范围 左上角,右下角 - ''' - DEM_ptr = gdal.Open(DEMFilePath) - DEM_GeoTransform = DEM_ptr.GetGeoTransform() # 读取影像的投影变换 - DEM_InvGeoTransform = gdal.InvGeoTransform(DEM_GeoTransform) - SelectAreaArrayPoints = [gdal.ApplyGeoTransform(DEM_InvGeoTransform, p[0], p[1]) for p in SelectArea] - SelectAreaArrayPoints = list(map(lambda p: (int(p[0]), int(p[1])), SelectAreaArrayPoints)) # 确定坐标 - - [(ulx, uly), (brx, bry)] = SelectAreaArrayPoints - rowCount, colCount = bry - uly, brx - ulx - - # 输出DEM的桌面坐标转换 - Out_Transfrom = list(DEM_GeoTransform) - Out_Transfrom[0] = SelectArea[0][0] - Out_Transfrom[3] = SelectArea[0][1] - - # 构建输出DEM - Bands_num = DEM_ptr.RasterCount - gtiff_driver = gdal.GetDriverByName('GTiff') - datatype = gdal.GDT_UInt16 - out_dem = gtiff_driver.Create(OutFilePath, colCount, rowCount, Bands_num, datatype) - out_dem.SetProjection(DEM_ptr.GetProjection()) - out_dem.SetGeoTransform(Out_Transfrom) - - for i in range(1, Bands_num + 1): - data_band = DEM_ptr.GetRasterBand(i) - out_band = out_dem.GetRasterBand(i) - data = data_band.ReadAsArray(ulx, uly, colCount, rowCount) - out_band.WriteArray(data) - del out_dem - - @staticmethod - def dem_resample(in_dem_path, out_dem_path): - ''' - DEM重采样函数,默认坐标系为WGS84 - agrs: - in_dem_path: 输入的DEM文件夹路径 - meta_file_path: 输入的xml元文件路径 - out_dem_path: 输出的DEM文件夹路径 - ''' - # 读取文件夹中所有的DEM - dem_file_paths=[os.path.join(in_dem_path,dem_name) for dem_name in os.listdir(in_dem_path) if dem_name.find(".tif")>=0 and dem_name.find(".tif.")==-1] - spatialreference=osr.SpatialReference() - spatialreference.SetWellKnownGeogCS("WGS84") # 设置地理坐标,单位为度 degree # 设置投影坐标,单位为度 degree - spatialproj=spatialreference.ExportToWkt() # 导出投影结果 - # 将DEM拼接成一张大图 - mergeFile =gdal.BuildVRT(os.path.join(out_dem_path,"mergeDEM.tif"), dem_file_paths) - out_DEM=os.path.join(out_dem_path,"mosaic.tif") - gdal.Warp(out_DEM, - mergeFile, - format="GTiff", - dstSRS=spatialproj, - dstNodata=-9999, - outputType=gdal.GDT_Float32) - return out_DEM - - -# if __name__ == "__main__": -# DEMProcess = DEMProcess() -# in_dem_path = r'F:\大气延迟\out_dem' -# out_dem_path = r'F:\大气延迟\out_dem' -# DEMProcess.dem_resample(in_dem_path, out_dem_path) - - - diff --git a/landcover-L-SAR/tool/algorithm/algtools/MetaDataHandler.py b/landcover-L-SAR/tool/algorithm/algtools/MetaDataHandler.py deleted file mode 100644 index 8779132..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/MetaDataHandler.py +++ /dev/null @@ -1,154 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project :microproduct -@File :ScatteringAuxData.py -@Function :后向散射 -@Author :SHJ -@Contact: -@Date :2022/6/29 -@Version :1.0.0 -修改历史: -[修改序列] [修改日期] [修改者] [修改内容] - 1 2022-6-29 石海军 1.兼容GF3元文件和正射校正元文件提取信息 -""" -import logging -from xml.etree.ElementTree import ElementTree -import math -logger = logging.getLogger("mylog") - -class GF3L1AMetaData: - def __init__(self): - pass - @staticmethod - def get_QualifyValue(meta_file_path, polarization): - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - QualifyValue = float(root.find('imageinfo').find('QualifyValue').find(polarization).text) - return QualifyValue - - - @staticmethod - def get_Kdb(meta_file_path, polarization): - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - Kdb = float(root.find('processinfo').find('CalibrationConst').find(polarization).text) if root.find('processinfo').find('CalibrationConst').find(polarization).text!="NULL" else 0 - return Kdb - -class OrthoMetaData: - def __init__(self): - pass - @staticmethod - def get_QualifyValue(meta_file_path, polarization): - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - QualifyValue = float(root.find('processing').find('processingParameter').find('quantifyValue').find(polarization).text) - return QualifyValue - - @staticmethod - def get_Kdb(meta_file_path, polarization): - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - Kdb = float(root.find('processing').find('processingParameter').find('calibrationConst').find(polarization).text) - return Kdb - - - @staticmethod - def get_RadarCenterFrequency(meta_file_path): - # 获取微波中心频率 - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - RadarCenterFrequency = float(root.find('instrument').find('radarParameters').find('centerFrequency').text) - return RadarCenterFrequency - - - @staticmethod - def get_lamda(meta_file_path): - # 获取微波波长,单位:m - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - lamda = float(root.find('sensor').find('lamda').text) - return lamda - -class MetaDataHandler: - def __init__(self): - pass - - @staticmethod - def get_QualifyValue(meta_file_path, polarization): - try: - QualifyValue = OrthoMetaData.get_QualifyValue(meta_file_path, polarization) - except Exception: - logger.warning('LTMetaData.get_QualifyValue() error!') - QualifyValue = GF3L1AMetaData.get_QualifyValue(meta_file_path, polarization) - logger.info('GF3L1AMetaData.get_QualifyValue() success!') - return QualifyValue - - @staticmethod - def get_Kdb(meta_file_path, polarization): - try: - Kdb = OrthoMetaData.get_Kdb(meta_file_path, polarization) - except Exception: - logger.warning('LTMetaData.get_Kdb() error!') - Kdb = GF3L1AMetaData.get_Kdb(meta_file_path, polarization) - logger.info('GF3L1AMetaData.get_Kdb() success!') - return Kdb - - @staticmethod - def get_RadarCenterFrequency(meta_file_path): - # 获取微波中心频率,单位GHz - RadarCenterFrequency = OrthoMetaData.get_RadarCenterFrequency(meta_file_path) - return RadarCenterFrequency - - @staticmethod - def get_lamda(meta_file_path): - # 获取微波波长,单位:m - lamda = OrthoMetaData.get_lamda(meta_file_path) - return lamda - -class Calibration: - def __init__(self): - pass - - @staticmethod - def get_Calibration_coefficient(meta_file_path, polarization): - calibration = [0, 0, 0, 0] - for i in polarization: - if i == 'HH': - quality = MetaDataHandler.get_QualifyValue(meta_file_path, i) - kdb = MetaDataHandler.get_Kdb(meta_file_path, i) - data_value = ((quality/32767)**2) * (10**((kdb/10)*-1)) - calibration[0] = math.sqrt(data_value) - if i == 'HV': - quality = MetaDataHandler.get_QualifyValue(meta_file_path, i) - kdb = MetaDataHandler.get_Kdb(meta_file_path, i) - data_value = ((quality/32767)**2) * (10**((kdb/10)*-1)) - calibration[1] = math.sqrt(data_value) - if i == 'VH': - quality = MetaDataHandler.get_QualifyValue(meta_file_path, i) - kdb = MetaDataHandler.get_Kdb(meta_file_path, i) - data_value = ((quality/32767)**2) * (10**((kdb/10)*-1)) - calibration[2] = math.sqrt(data_value) - if i == 'VV': - quality = MetaDataHandler.get_QualifyValue(meta_file_path, i) - kdb = MetaDataHandler.get_Kdb(meta_file_path, i) - data_value = ((quality/32767)**2) * (10**((kdb/10)*-1)) - calibration[3] = math.sqrt(data_value) - return calibration - - -# if __name__ == '__main__': -# A = ScatteringAuxData() -# dir = 'G:\MicroWorkspace\C-SAR\AuxSAR\GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HHHV_L10004829485_geo/' -# path = dir + 'GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HHHV_L10004829485.meta.xml' -# path1 = dir + 'OrthoProduct.meta.xml' -# t1 = A.get_QualifyValue(path, 'HH') -# t2 = A.get_Kdb(path, 'HH') -# t3 = A.get_RadarCenterFrequency(path) -# t4 = A.get_lamda(path) -# pass \ No newline at end of file diff --git a/landcover-L-SAR/tool/algorithm/algtools/PreProcess.py b/landcover-L-SAR/tool/algorithm/algtools/PreProcess.py deleted file mode 100644 index e9b9155..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/PreProcess.py +++ /dev/null @@ -1,527 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project :microproduct -@File :PreProcess.py -@Function :@Function: 坐标转换,坐标系转换,图像裁剪,重投影,重采样 -@Author :LMM -@Date :2021/8/25 14:17 -@Version :1.0.0 -""" -from shapely.geometry import Polygon # 导入 gdal库要放到这一句的后面,不然会引起错误 - -from osgeo import gdal -from osgeo import gdalconst -from osgeo import osr -from osgeo import ogr -import os -import cv2 -import numpy as np -import shutil -import scipy.spatial.transform -import scipy.spatial.transform._rotation_groups # 用于解决打包错误 -import scipy.special.cython_special # 用于解决打包错误 -import scipy.spatial.transform._rotation_groups # 解决打包的问题 -import shapefile -from shapely.errors import TopologicalError -from tool.algorithm.image.ImageHandle import ImageHandler -import logging -logger = logging.getLogger("mylog") - -os.environ['PROJ_LIB'] = os.getcwd() - - - -class PreProcess: - """ - 预处理,所有的影像配准 - """ - def __init__(self): - self._ImageHandler = ImageHandler() - pass - - def cal_scopes(self, processing_paras): - # 计算roi - scopes = () - for key, value in processing_paras.items(): - if 'ori_sim' in key: - scopes += (ImageHandler.get_scope_ori_sim(value),) - if(processing_paras['box'] != "" or processing_paras['box'] != "empty"): - scopes += self.box2scope(processing_paras['box']) - return scopes - - def cal_scopes_roi(self, processing_paras): - return self.intersect_polygon(self.cal_scopes(processing_paras)) - - def cut_geoimg(self,workspace_preprocessing_path, para_names_geo, processing_paras): - self.check_img_projection(workspace_preprocessing_path, para_names_geo, processing_paras) - # 计算roi - - scopes = self.cal_scopes(processing_paras) - # 计算图像的轮廓,并求相交区域 - intersect_shp_path = os.path.join(workspace_preprocessing_path, 'IntersectPolygon.shp') - scopes_roi = self.cal_intersect_shp(intersect_shp_path, para_names_geo, processing_paras, scopes) - # 裁剪 - # 裁剪图像:裁剪微波图像,裁剪其他图像 - cutted_img_paths = self.cut_imgs(workspace_preprocessing_path, para_names_geo, processing_paras, intersect_shp_path) - return cutted_img_paths, scopes_roi - - - - def preprocessing(self, para_names, ref_img_name, processing_paras, workspace_preprocessing_path, workspace_preprocessed_path): - # 读取每一张图像,检查图像坐标系 - - self.check_img_projection(workspace_preprocessing_path, para_names, processing_paras) - - # 计算图像的轮廓,并求相交区域 - intersect_shp_path = os.path.join(workspace_preprocessing_path, 'IntersectPolygon.shp') - self.cal_intersect_shp(intersect_shp_path, para_names, processing_paras, - self.box2scope(processing_paras['box'])) - logger.info('create intersect shp success!') - - # 裁剪图像:裁剪微波图像,裁剪其他图像 - cutted_img_paths = self.cut_imgs(workspace_preprocessing_path, para_names, processing_paras, - intersect_shp_path) - logger.info('cut images success!') - - # 重采样:重采样到跟微波图像一致的分辨率,然后保存到临时目录 - - preprocessed_paras = self.resampling_img(workspace_preprocessed_path, para_names, cutted_img_paths,cutted_img_paths[ref_img_name]) - # 清除预处理缓存文件 - logger.info('preprocess_handle success!') - return preprocessed_paras # cutted_img_paths - - def get_ref_inf(self, ref_img_path): - """获取参考影像的图像信息""" - ref_img_path = ref_img_path - cols = ImageHandler.get_img_width(ref_img_path) - rows = ImageHandler.get_img_height(ref_img_path) - proj = ImageHandler.get_projection(ref_img_path) - geo = ImageHandler.get_geotransform(ref_img_path) - return ref_img_path, cols, rows, proj, geo - - def check_img_projection(self, out_dir, para_names, processing_paras): - """ - 读取每一张图像,检查图像坐标系; - 将投影坐标系影像转换为地理坐标系影像(EPSG:4326) - :param para_names:需要检查的参数名称 - """ - if len(para_names) == 0: - return False - for name in para_names: - proj = ImageHandler.get_projection(processing_paras[name]) - keyword = proj.split("[", 2)[0] - - if keyword == "PROJCS": - # 投影坐标系 转 地理坐标系 - para_dir = os.path.split(processing_paras[name]) - out_para = os.path.join(out_dir, para_dir[1].split(".", 1)[0] + "_EPSG4326.tif") - self.trans_epsg4326(out_para, processing_paras[name]) - processing_paras[name] = out_para - elif len(keyword) == 0 or keyword.strip() == "" or keyword.isspace() is True: - raise Exception('coordinate is missing!') - - - def preprocessing_oh2004(self, para_names, processing_paras, workspace_preprocessing_path, workspace_preprocessed_path): - # 读取每一张图像,检查图像坐标系 - - self.check_img_projection(workspace_preprocessing_path, para_names, processing_paras) - - # 计算图像的轮廓,并求相交区域 - intersect_shp_path = os.path.join(workspace_preprocessing_path, 'IntersectPolygon.shp') - scopes = self.cal_intersect_shp(intersect_shp_path, para_names, processing_paras, - self.box2scope(processing_paras['box'])) - logger.info('create intersect shp success!') - - # 裁剪图像:裁剪微波图像,裁剪其他图像 - cutted_img_paths = self.cut_imgs(workspace_preprocessed_path, para_names, processing_paras, - intersect_shp_path) - logger.info('cut images success!') - - # 重采样:重采样到跟微波图像一致的分辨率,然后保存到临时目录 - - return cutted_img_paths, scopes - - @staticmethod - def lonlat2geo(lat, lon): - """ - WGS84转平面坐标 - Param: lat 为WGS_1984的纬度 - Param: lon 为WGS_1984的经度 - 输出转换后的坐标x,y - """ - - dstsrs1 = osr.SpatialReference() - dstsrs1.ImportFromEPSG(32649) - - dstsrs2 = osr.SpatialReference() - dstsrs2.ImportFromEPSG(4326) - - ct = osr.CoordinateTransformation(dstsrs2, dstsrs1) - coords = ct.TransformPoint(lat, lon) - # print("输出转换后的坐标x,y:",coords[:2]) - return coords[:2] - - @staticmethod - def trans_geogcs2projcs(out_path, in_path): - """ - :param out_path:wgs84投影坐标影像保存路径 - :param in_path:地理坐标影像输入路径 - """ - # 创建文件 - if os.path.exists(os.path.split(out_path)[0]) is False: - os.makedirs(os.path.split(out_path)[0]) - options = gdal.WarpOptions(format='GTiff', srcSRS='EPSG:4326', dstSRS='EPSG:32649') - gdal.Warp(out_path, in_path, options=options) - - @staticmethod - def trans_projcs2geogcs(out_path, in_path): - """ - :param out_path:wgs84地理坐标影像输入路径 - :param in_path:wgs84投影坐标影像保存路径 - """ - # 创建文件 - if os.path.exists(os.path.split(out_path)[0]) is False: - os.makedirs(os.path.split(out_path)[0]) - options = gdal.WarpOptions(format='GTiff', srcSRS='EPSG:32649', dstSRS='EPSG:4326') - gdal.Warp(out_path, in_path, options=options) - - @staticmethod - def trans_projcs2geogcs(out_path, in_path ,EPSG_src=32649,EPSG_dst=4326): - """ - :param out_path:wgs84地理坐标影像输入路径 - :param in_path:wgs84投影坐标影像保存路径 - :param EPSG_src:原始投影系 - :param EPSG_dst:目标坐标系 - """ - str_EPSG_src = 'EPSG:'+ str(EPSG_src) - str_EPSG_dst = 'EPSG:'+ str(EPSG_dst) - - # 创建文件 - if os.path.exists(os.path.split(out_path)[0]) is False: - os.makedirs(os.path.split(out_path)[0]) - options = gdal.WarpOptions(format='GTiff', srcSRS=str_EPSG_src, dstSRS=str_EPSG_dst) - gdal.Warp(out_path, in_path, options=options) - - @staticmethod - def trans_epsg4326(out_path, in_path): - OutTile = gdal.Warp(out_path, in_path, - dstSRS='EPSG:4326', - resampleAlg=gdalconst.GRA_Bilinear - ) - OutTile = None - return True - - @staticmethod - def box2scope(str_box): - roi_box = () - if str_box == '' or str_box == 'empty': - return roi_box - box_list = [float(num) for num in list(str_box.split(';'))] - if len(box_list) == 4: - roi_box = ([[box_list[2], box_list[1]], [box_list[3], box_list[1]], [box_list[2], box_list[0]], - [box_list[3], box_list[0]]],) - return roi_box - - def cal_intersect_shp(self, shp_path, para_names,processing_paras, add_scope =()): - """ - :param shp_path:相交区域矢量文件保存区域 - :param para_names:判断相交影像的名称 - :return: True or False - """ - scopes = () - - if len(add_scope) != 0: - scopes += add_scope - for name in para_names: - scope_tuple = (self._ImageHandler.get_scope(processing_paras[name]),) - scopes += scope_tuple - for n, scope in zip( range(len(scopes)), scopes): - logging.info("scope" + str(n) + ":%s", scope) - - intersect_polygon = self.intersect_polygon(scopes) - if intersect_polygon is None: - logger.error('image range does not overlap!') - raise Exception('create intersect shp fail!') - logging.info("scope roi :%s", intersect_polygon) - if self.write_polygon_shp(shp_path, intersect_polygon, 4326) is False: - raise Exception('create intersect shp fail!') - return intersect_polygon - - @staticmethod - def intersect_polygon(scopes_tuple): - """ - 功能说明:计算多边形相交的区域坐标;注意:多边形区域会转变成凸区域再求交 - :param scopes_tuple: 输入多个区域坐标的tuple - :return: 多边形相交的区域坐标((x0,y0),(x1,y1),..., (xn,yn)) - """ - if len(scopes_tuple) < 2: - logger.error('len(scopes_tuple) < 2') - # return # todo 修改只有单景会出现无法判断相交区域问题 - - try: - # python四边形对象,会自动计算四个点,最后四个点顺序为:左上 左下 右下 右上 左上 - tmp = tuple(scopes_tuple[0]) - poly_intersect = Polygon(tmp).convex_hull - for i in range(len(scopes_tuple)-1): - polygon_next = Polygon(tuple(scopes_tuple[i+1])).convex_hull - if poly_intersect.intersects(polygon_next): - poly_intersect = poly_intersect.intersection(polygon_next) - else: - msg = 'Image:' + str(i) + 'range does not overlap!' - logger.error(msg) - return - return list(poly_intersect.boundary.coords)[:-1] - # except shapely.geos.TopologicalError: - except TopologicalError: - logger.error('shapely.geos.TopologicalError occurred!') - return - - - @staticmethod - def write_polygon_shp(out_shp_path, point_list, EPSG =32649): - """ - 功能说明:创建闭环的矢量文件。 - :param out_shp_path :矢量文件保存路径 - :param point_list :装有闭环点的列表[[x0,y0],[x1,y1]...[xn,yn]] - :return: True or False - """ - # 为了支持中文路径,请添加下面这句代码 - gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO") - # 为了使属性表字段支持中文,请添加下面这句 - gdal.SetConfigOption("SHAPE_ENCODING", "") - # 注册所有的驱动 - ogr.RegisterAll() - - # 创建数据,这里以创建ESRI的shp文件为例 - str_driver_name = "ESRI Shapefile" - o_driver = ogr.GetDriverByName(str_driver_name) - if o_driver is None: - msg = 'driver('+str_driver_name+')is invalid value' - logger.error(msg) - return False - - # 创建数据源 - if os.path.exists(out_shp_path) and os.path.isfile(out_shp_path): # 如果已存在同名文件 - os.remove(out_shp_path) # 则删除之 - o_ds = o_driver.CreateDataSource(out_shp_path) - if o_ds is None: - msg = 'create file failed!' + out_shp_path - logger.error(msg) - return False - - # 创建图层,创建一个多边形图层 - srs = osr.SpatialReference() - #srs.ImportFromEPSG(32649) # 投影坐标系,空间参考:WGS84 - - srs.ImportFromEPSG(EPSG) # 地理坐标系EPSG - o_layer = o_ds.CreateLayer("TestPolygon", srs, ogr.wkbPolygon) - if o_layer is None: - msg = 'create coverage failed!' - logger.error(msg) - return False - - # 下面创建属性表 - # 先创建一个叫FieldID的整型属性 - o_field_id = ogr.FieldDefn("FieldID", ogr.OFTInteger) - o_layer.CreateField(o_field_id, 1) - - # 再创建一个叫FeatureName的字符型属性,字符长度为50 - o_field_name = ogr.FieldDefn("FieldName", ogr.OFTString) - o_field_name.SetWidth(100) - o_layer.CreateField(o_field_name, 1) - - o_defn = o_layer.GetLayerDefn() - - # 创建矩形要素 - o_feature_rectangle = ogr.Feature(o_defn) - o_feature_rectangle.SetField(0, 1) - o_feature_rectangle.SetField(1, "IntersectRegion") - - # 创建环对象ring - ring = ogr.Geometry(ogr.wkbLinearRing) - - for i in range(len(point_list)): - ring.AddPoint(point_list[i][0], point_list[i][1]) - ring.CloseRings() - - # 创建环对象polygon - geom_rect_polygon = ogr.Geometry(ogr.wkbPolygon) - geom_rect_polygon.AddGeometry(ring) - - o_feature_rectangle.SetGeometry(geom_rect_polygon) - o_layer.CreateFeature(o_feature_rectangle) - - o_ds.Destroy() - return True - - def cut_imgs(self, out_dir, para_names, processing_paras, shp_path): - """ - 使用矢量数据裁剪影像 - :param para_names:需要检查的参数名称 - :param shp_path:裁剪的shp文件 - """ - if len(para_names) == 0: - return {} - cutted_img_paths = {} - try: - for name in para_names: - input_path = processing_paras[name] - output_path = os.path.join(out_dir, name + '_cut.tif') - self.cut_img(output_path, input_path, shp_path) - cutted_img_paths.update({name: output_path}) - logger.info('cut %s success!', name) - except BaseException: - logger.error('cut_img failed!') - return {} - return cutted_img_paths - - @staticmethod - def cut_img(output_path, input_path, shp_path): - """ - :param output_path:剪切后的影像 - :param input_path:待剪切的影像 - :param shp_path:矢量数据 - :return: True or False - """ - r = shapefile.Reader(shp_path) - box = r.bbox - - input_dataset = gdal.Open(input_path) - - gdal.Warp(output_path, input_dataset, format='GTiff', outputBounds=box, cutlineDSName=shp_path, dstNodata=-9999) - # cutlineWhere="FIELD = ‘whatever’", - # optionally you can filter your cutline (shapefile) based on attribute values - # select the no data value you like - # ds = None - # do other stuff with ds object, it is your cropped dataset. in this case we only close the dataset. - del input_dataset - return True - - def resampling_img(self, out_dir, para_names, img_paths, refer_img_path): - """ - 以主影像为参考,对影像重采样 - :param para_names:需要检查的参数名称 - :param img_paths:待重采样影像路径 - :param refer_img_path:参考影像路径 - """ - if len(para_names) == 0 or len(img_paths) == 0: - return - prepro_imgs_path = {} - for name in para_names: - img_path = img_paths[name] - output_para = os.path.join(out_dir, name + '_preprocessed.tif') # + name + '_preprocessed.tif' - self.resampling_by_scale(img_path, output_para, refer_img_path) - prepro_imgs_path.update({name: output_para}) - logger.info('resampling %s success!', name) - return prepro_imgs_path - - @staticmethod - def resampling_by_scale(input_path, target_file, refer_img_path): - """ - 按照缩放比例对影像重采样 - :param input_path: GDAL地理数据路径 - :param target_file: 输出影像 - :param refer_img_path:参考影像 - :return: True or False - """ - ref_dataset = gdal.Open(refer_img_path) - ref_cols = ref_dataset.RasterXSize # 列数 - ref_rows = ref_dataset.RasterYSize # 行数 - - target_dataset = gdal.Open(input_path) - target_cols = target_dataset.RasterXSize # 列数 - target_rows = target_dataset.RasterYSize # 行数 - - if(ref_cols == target_cols) and (ref_rows == target_rows): - shutil.copyfile(input_path, target_file) - return True - - dataset = gdal.Open(input_path) - if dataset is None: - logger.error('resampling_by_scale:dataset is None!') - return False - - band_count = dataset.RasterCount # 波段数 - if (band_count == 0) or (target_file == ""): - logger.error("resampling_by_scale:Parameters of the abnormal!") - return False - - cols = dataset.RasterXSize # 列数 - rows = dataset.RasterYSize # 行数 - scale_x = ref_cols/cols - scale_y = ref_rows/rows - - # rows = dataset.RasterYSize # 行数 - # cols = int(cols * scale) # 计算新的行列数 - # rows = int(rows * scale) - cols = ref_cols - rows = ref_rows - - geotrans = list(dataset.GetGeoTransform()) - geotrans[1] = geotrans[1] / scale_x # 像元宽度变为原来的scale倍 - geotrans[5] = geotrans[5] / scale_y # 像元高度变为原来的scale倍 - - if os.path.exists(target_file) and os.path.isfile(target_file): # 如果已存在同名影像 - os.remove(target_file) # 则删除之 - if not os.path.exists(os.path.split(target_file)[0]): - os.makedirs(os.path.split(target_file)[0]) - - band1 = dataset.GetRasterBand(1) - data_type = band1.DataType - target = dataset.GetDriver().Create(target_file, xsize=cols, ysize=rows, bands=band_count, - eType=data_type) - target.SetProjection(dataset.GetProjection()) # 设置投影坐标 - target.SetGeoTransform(geotrans) # 设置地理变换参数 - total = band_count + 1 - for index in range(1, total): - # 读取波段数据 - data = dataset.GetRasterBand(index).ReadAsArray(buf_xsize=cols, buf_ysize=rows) - out_band = target.GetRasterBand(index) - - no_data_value = dataset.GetRasterBand(index).GetNoDataValue() # 获取没有数据的点 - if not (no_data_value is None): - out_band.SetNoDataValue(no_data_value) - - out_band.WriteArray(data) # 写入数据到新影像中 - out_band.FlushCache() - out_band.ComputeBandStats(False) # 计算统计信息 - del dataset - del target - return True - - @staticmethod - def cv_mean_filter(out_path, in_path, filter_size): - """ - :param out_path:滤波后的影像 - :param in_path:滤波前的影像 - :param filter_size:滤波尺寸 - :return: True or False - """ - proj = ImageHandler.get_projection(in_path) - geotrans = ImageHandler.get_geotransform(in_path) - array = ImageHandler.get_band_array(in_path, 1) - array = cv2.blur(array, (filter_size, filter_size)) # 均值滤波 - ImageHandler.write_img(out_path, proj, geotrans, array) - return True - - @staticmethod - def check_LocalIncidenceAngle(out_tif_path, in_tif_path): - """ - 将角度的无效值设置为nan,把角度值转为弧度值 - :param out_tif_path:处理后影像路径 - :param in_tif_path:处理前影像路径 - """ - proj, geo, angle = ImageHandler.read_img(in_tif_path) - angle = angle.astype(np.float32, order='C') - angle[angle == -9999] = np.nan - - mean = np.nanmean(angle) - if mean > np.pi: - angle = np.deg2rad(angle)# 角度转弧度 - - angle[np.where(angle >= 0.5 * np.pi)] = np.nan - angle[np.where(angle < 0)] = np.nan - - ImageHandler.write_img(out_tif_path, proj, geo, angle) - - diff --git a/landcover-L-SAR/tool/algorithm/algtools/ROIAlg.py b/landcover-L-SAR/tool/algorithm/algtools/ROIAlg.py deleted file mode 100644 index 1bf9b56..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/ROIAlg.py +++ /dev/null @@ -1,237 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:microproduct -@File:ROIAlg.py -@Function: -@Contact: -@Author:SHJ -@Date:2021/11/17 -@Version:1.0.0 -""" -import logging -from tool.algorithm.image.ImageHandle import ImageHandler -from tool.algorithm.algtools.PreProcess import PreProcess as pp -import numpy as np - - -logger = logging.getLogger("mylog") - - -class ROIAlg: - def __init__(self,): - pass - - @staticmethod - def roi_process(names, processing_path, processing_paras, preprocessed_paras): - roi_paths = [] - roi = ROIAlg() - for name in names: - if 'LocalIncidenceAngle' in name: - # 利用角度为nan生成Mask - pp.check_LocalIncidenceAngle(preprocessed_paras[name],preprocessed_paras[name]) - angle_nan_mask_path = processing_path + 'angle_nan_mask.tif' - roi.trans_tif2mask(angle_nan_mask_path, preprocessed_paras[name], np.nan) - roi_paths.append(angle_nan_mask_path) - elif ("HH" in name) or ("HV" in name) or ("VH" in name) or ("VV" in name): - # 利用影像的有效范围生成MASK - tif_mask_path = processing_path + name + "_tif_mask.tif" - roi.trans_tif2mask(tif_mask_path, preprocessed_paras[name], np.nan) - roi_paths.append(tif_mask_path) - elif name == 'Covering': - # 利用cover计算植被覆盖范围 - if processing_paras['CoveringIDs'] == 'empty': - cover_data = ImageHandler.get_data(preprocessed_paras[name]) - cover_data[np.where(np.isnan(cover_data))] = 0 - cover_id_list = list(np.unique(cover_data)) - else: - cover_id_list = list(processing_paras['CoveringIDs'].split(';')) - cover_id_list = [int(num) for num in cover_id_list] - cover_mask_path = processing_path + "cover_mask.tif" - roi.trans_cover2mask(cover_mask_path, preprocessed_paras[name], cover_id_list) - roi_paths.append(cover_mask_path) - elif name == "NDVI": - # 利用NDVI计算裸土范围该指数的输出值在 -1.0 和 1.0 之间,大部分表示植被量, - # 负值主要根据云、水和雪而生成 - # 接近零的值则主要根据岩石和裸土而生成。 - # 较低的(小于等于 0.1)NDVI 值表示岩石、沙石或雪覆盖的贫瘠区域。 - # 中等值(0.2 至 0.3)表示灌木丛和草地 - # 较高的值(0.6 至 0.8)表示温带雨林和热带雨林。 - ndvi_mask_path = processing_path + "ndvi_mask.tif" - ndvi_scope = list(processing_paras['NDVIScope'].split(';')) - threshold_of_ndvi_min = float(ndvi_scope[0]) - threshold_of_ndvi_max = float(ndvi_scope[1]) - roi.trans_tif2mask(ndvi_mask_path, preprocessed_paras[name], threshold_of_ndvi_min, threshold_of_ndvi_max) - roi_paths.append(ndvi_mask_path) - # else: - # # 其他特征影像 - # tif_mask_path = processing_path + name + "_mask.tif" - # roi.trans_tif2mask(tif_mask_path, preprocessed_paras[name], np.nan) - # roi_paths.append(tif_mask_path) - - bare_land_mask_path = processing_path + "bare_land_mask.tif" - for roi_path in roi_paths: - roi.combine_mask(bare_land_mask_path, roi_path, bare_land_mask_path) - return bare_land_mask_path - - @staticmethod - def roi_process_VP(names, processing_path, processing_paras, preprocessed_paras, file_name): - roi_paths = [] - roi = ROIAlg() - for name in names: - if 'LocalIncidenceAngle' in name: - # 利用角度为nan生成Mask - pp.check_LocalIncidenceAngle(preprocessed_paras[name], preprocessed_paras[name]) - angle_nan_mask_path = processing_path + 'angle_nan_mask.tif' - roi.trans_tif2mask(angle_nan_mask_path, preprocessed_paras[name], np.nan) - roi_paths.append(angle_nan_mask_path) - elif ("HH" in name) or ("HV" in name) or ("VH" in name) or ("VV" in name): - # 利用影像的有效范围生成MASK - tif_mask_path = processing_path + name + "_tif_mask.tif" - roi.trans_tif2mask(tif_mask_path, preprocessed_paras[name], np.nan) - roi_paths.append(tif_mask_path) - elif name == 'Covering': - # 利用cover计算植被覆盖范围 - cover_mask_path = processing_path + "cover_mask.tif" - if processing_paras['CoveringIDs'] == 'empty': - cover_data = ImageHandler.get_data(preprocessed_paras[file_name + '_' + name]) - cover_data[np.where(np.isnan(cover_data))] = 0 - cover_id_list = list(np.unique(cover_data)) - else: - cover_id_list = list(processing_paras['CoveringIDs'].split(';')) - cover_id_list = [int(num) for num in cover_id_list] - roi.trans_cover2mask(cover_mask_path, preprocessed_paras[file_name + '_' + name], cover_id_list) - roi_paths.append(cover_mask_path) - elif name == "NDVI": - # 利用NDVI计算裸土范围该指数的输出值在 -1.0 和 1.0 之间,大部分表示植被量, - # 负值主要根据云、水和雪而生成 - # 接近零的值则主要根据岩石和裸土而生成。 - # 较低的(小于等于 0.1)NDVI 值表示岩石、沙石或雪覆盖的贫瘠区域。 - # 中等值(0.2 至 0.3)表示灌木丛和草地 - # 较高的值(0.6 至 0.8)表示温带雨林和热带雨林。 - ndvi_mask_path = processing_path + "ndvi_mask.tif" - ndvi_scope = list(processing_paras['NDVIScope'].split(';')) - threshold_of_ndvi_min = float(ndvi_scope[0]) - threshold_of_ndvi_max = float(ndvi_scope[1]) - roi.trans_tif2mask(ndvi_mask_path, preprocessed_paras[name], threshold_of_ndvi_min, - threshold_of_ndvi_max) - roi_paths.append(ndvi_mask_path) - # else: - # # 其他特征影像 - # tif_mask_path = processing_path + name + "_mask.tif" - # roi.trans_tif2mask(tif_mask_path, preprocessed_paras[name], np.nan) - # roi_paths.append(tif_mask_path) - - bare_land_mask_path = processing_path + "bare_land_mask.tif" - for roi_path in roi_paths: - roi.combine_mask(bare_land_mask_path, roi_path, bare_land_mask_path) - return bare_land_mask_path - - @staticmethod - def trans_tif2mask(out_mask_path, in_tif_path, threshold_min, threshold_max = None): - """ - :param out_mask_path:mask输出路径 - :param in_tif_path:输入路径 - :param threshold_min:最小阈值 - :param threshold_max:最大阈值 - :return: True or False - """ - image_handler = ImageHandler() - proj = image_handler.get_projection(in_tif_path) - geotrans = image_handler.get_geotransform(in_tif_path) - array = image_handler.get_band_array(in_tif_path, 1) - if threshold_max == None and np.isnan(threshold_min)==True: - nan = np.isnan(array) - mask = (nan.astype(int) == 0).astype(int) - mask1 = ((array == -9999).astype(int) == 0).astype(int) - mask *= mask1 - image_handler.write_img(out_mask_path, proj, geotrans, mask) - else: - if threshold_min < threshold_max: - mask = ((array > threshold_min) & (array < threshold_max)).astype(int) - image_handler.write_img(out_mask_path, proj, geotrans, mask) - elif threshold_min > threshold_max: - mask = ((array < threshold_min) & (array > threshold_max)).astype(int) - image_handler.write_img(out_mask_path, proj, geotrans, mask) - elif threshold_max == threshold_min: - mask = ((array == threshold_min).astype(int) == 0).astype(int) - image_handler.write_img(out_mask_path, proj, geotrans, mask) - - logger.info("trans_tif2mask success, path: %s", out_mask_path) - return True - - @staticmethod - def trans_cover2mask(out_mask_path, in_tif_path, cover_id_list): - """ - :param out_mask_path:mask输出路径 - :param in_tif_path:输入路径 - :param cover_id_list 地表覆盖类型数据的id - :return: True or False - """ - image_handler = ImageHandler() - proj = image_handler.get_projection(in_tif_path) - geotrans = image_handler.get_geotransform(in_tif_path) - array = image_handler.get_band_array(in_tif_path, 1) - - mask = np.zeros(array.shape, dtype=bool) - for id in cover_id_list: - mask_tmp = (array == id) - mask = mask | mask_tmp - - mask = mask.astype(int) - image_handler.write_img(out_mask_path, proj, geotrans, mask) - - @staticmethod - def combine_mask(out_mask_path, in_main_mask_path, in_sub_mask_path): - """ - :param out_mask_path:输出路径 - :param in_main_mask_path:主mask路径,输出影像采用主mask的地理信息 - :param in_sub_mask_path:副mask路径 - """ - image_handler = ImageHandler() - proj = image_handler.get_projection(in_main_mask_path) - geotrans = image_handler.get_geotransform(in_main_mask_path) - main_array = image_handler.get_band_array(in_main_mask_path, 1) - if image_handler.get_dataset(in_sub_mask_path) != None: - sub_array = image_handler.get_band_array(in_sub_mask_path, 1) - main_array = main_array * sub_array - image_handler.write_img(out_mask_path, proj, geotrans, main_array) - logger.info("combine_mask success, path: %s", out_mask_path) - return True - - @staticmethod - def cal_roi(out_tif_path, in_tif_path, mask_path, background_value=1): - """ - :param out_tif_path:ROI的影像 - :param in_tif_path:计算ROI的影像 - :param mask_path:掩模 - :param background_value:无效区域设置的背景值 - :return: True or False - """ - image_handler = ImageHandler() - proj = image_handler.get_projection(in_tif_path) - geotrans = image_handler.get_geotransform(in_tif_path) - tif_array = image_handler.get_data(in_tif_path) # 读取所有波段的像元值存为数组 - mask_array = image_handler.get_band_array(mask_path, 1) - if len(tif_array.shape) == 3: - im_bands, im_height, im_width = tif_array.shape - else: - im_bands, (im_height, im_width) = 1, tif_array.shape - if im_bands == 1: - tif_array[np.isnan(mask_array)] = background_value - tif_array[mask_array == 0] = background_value - elif im_bands>1: - for i in range(0, im_bands): - tif_array[i, :, :][np.isnan(mask_array)] = background_value - tif_array[i, :, :][mask_array == 0] = background_value - image_handler.write_img(out_tif_path, proj, geotrans, tif_array, background_value) - logger.info("cal_roi success, path: %s", out_tif_path) - return True - -# if __name__ == '__main__': -# dir = r'G:\MicroWorkspace\C-SAR\SoilMoisture\Temporary\processing/' -# out_tif_path = dir + 'soil_moisture_roi.tif' -# in_tif_path = dir + 'soil_moisture.tif' -# mask_path = dir + 'bare_land_mask.tif' -# background_value = np.nan -# ROIAlg.cal_roi(out_tif_path, in_tif_path, mask_path, background_value) -# pass \ No newline at end of file diff --git a/landcover-L-SAR/tool/algorithm/algtools/RieveFilter.py b/landcover-L-SAR/tool/algorithm/algtools/RieveFilter.py deleted file mode 100644 index 4756a76..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/RieveFilter.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:sieve_filter.py -@Function:gdal斑点滤波功能 -@Contact: 'https://www.osgeo.cn/gdal/api/gdal_alg.html?highlight=gdalsievefilter#' - '_CPPv415GDALSieveFilter15GDALRasterBandH15GDALRasterBandH15GDALRasterBandHiiPPc16GDALProgressFuncPv' -@Author:SHJ -@Date:2021/8/30 8:42 -@Version:1.0.0 -""" -import logging -from osgeo import gdal -import numpy as np -# from onestar.soilMoisture.OneMoistureImage import ImageHandler -from tool.algorithm.image.ImageHandle import ImageHandler -logger = logging.getLogger("mylog") - - -def gdal_sieve_filter(dst_filename, src_filename, threshold=100, connectedness=4): - """ - 基于python GDAL栅格滤波 - :param dst_filename: 输出滤波后的影像 - :param src_filename: 输入需要处理的文件 - :param threshold: 滤波的值大小 - :param connectedness: 连通域, 范围:4或者8 - :return: - """ - # 4表示对角像素不被视为直接相邻用于多边形成员资格,8表示对角像素不相邻 - # connectedness = 4 - gdal.AllRegister() - # print('需要处理滤波的栅格文件:{},阈值(分辨率):{}'.format(src_filename, threshold)) - dataset = gdal.Open(src_filename, gdal.GA_Update) - if dataset is None: - logger.error('{}open tif fail!'.format(src_filename)) - return False - # 获取需要处理的源栅格波段 - src_band = dataset.GetRasterBand(1) - mask_band = src_band.GetMaskBand() - dst_band = src_band - prog_func = gdal.TermProgress_nocb - # 调用gdal滤波函数 - result = gdal.SieveFilter(src_band, mask_band, dst_band, threshold, connectedness, callback=prog_func) - if result != 0: - return False - proj = dataset.GetProjection() - geotransform = dataset.GetGeoTransform() - dst_array = dst_band.ReadAsArray(0, 0, dst_band.XSize, dst_band.YSize) - ImageHandler.write_img(dst_filename, proj, geotransform, dst_array) - del dataset - return True - -# -# if __name__ == '__main__': -# inputfile = r'D:\DATA\testdata\srcimg\GLCFCS30_E110N25.tif' -# outputfile = r'D:\DATA\testdata\srcimg\GLCFCS30_E110N25_sieve_filter.tif' -# flag = gdal_sieve_filter(outputfile, inputfile, threshold=100, connectedness=4) diff --git a/landcover-L-SAR/tool/algorithm/algtools/ScatteringAuxData.py b/landcover-L-SAR/tool/algorithm/algtools/ScatteringAuxData.py deleted file mode 100644 index 6a00c8f..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/ScatteringAuxData.py +++ /dev/null @@ -1,122 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project :microproduct -@File :ScatteringAuxData.py -@Function :后向散射 -@Author :SHJ -@Contact: -@Date :2022/6/29 -@Version :1.0.0 -修改历史: -[修改序列] [修改日期] [修改者] [修改内容] - 1 2022-6-29 石海军 1.兼容GF3元文件和正射校正元文件提取信息 -""" -import logging -from xml.etree.ElementTree import ElementTree -logger = logging.getLogger("mylog") - -class GF3L1AMetaData: - def __init__(self): - pass - @staticmethod - def get_QualifyValue(meta_file_path, polarization): - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - QualifyValue = float(root.find('imageinfo').find('QualifyValue').find(polarization).text) - return QualifyValue - - - @staticmethod - def get_Kdb(meta_file_path, polarization): - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - Kdb = float(root.find('processinfo').find('CalibrationConst').find(polarization).text) - return Kdb - -class OrthoMetaData: - def __init__(self): - pass - @staticmethod - def get_QualifyValue(meta_file_path, polarization): - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - QualifyValue = float(root.find('l1aInfo').find('imageinfo').find('QualifyValue').find(polarization).text) - return QualifyValue - - @staticmethod - def get_Kdb(meta_file_path, polarization): - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - Kdb = float(root.find('l1aInfo').find('processinfo').find('CalibrationConst').find(polarization).text) - return Kdb - - - @staticmethod - def get_RadarCenterFrequency(meta_file_path): - # 获取微波中心频率 - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - RadarCenterFrequency = float(root.find('sensor').find('RadarCenterFrequency').text) - return RadarCenterFrequency - - - @staticmethod - def get_lamda(meta_file_path): - # 获取微波波长,单位:m - tree = ElementTree() - tree.parse(meta_file_path) - root = tree.getroot() - lamda = float(root.find('sensor').find('lamda').text) - return lamda - -class ScatteringAuxData: - def __init__(self): - pass - - @staticmethod - def get_QualifyValue(meta_file_path, polarization): - try: - QualifyValue = OrthoMetaData.get_QualifyValue(meta_file_path, polarization) - except Exception: - logger.warning('OrthoMetaData.get_QualifyValue() error!') - QualifyValue = GF3L1AMetaData.get_QualifyValue(meta_file_path, polarization) - logger.info('GF3L1AMetaData.get_QualifyValue() success!') - return QualifyValue - - @staticmethod - def get_Kdb(meta_file_path, polarization): - try: - Kdb = OrthoMetaData.get_Kdb(meta_file_path, polarization) - except Exception: - logger.warning('OrthoMetaData.get_Kdb() error!') - Kdb = GF3L1AMetaData.get_Kdb(meta_file_path, polarization) - logger.info('GF3L1AMetaData.get_Kdb() success!') - return Kdb - - @staticmethod - def get_RadarCenterFrequency(meta_file_path): - # 获取微波中心频率,单位GHz - RadarCenterFrequency = OrthoMetaData.get_RadarCenterFrequency(meta_file_path) - return RadarCenterFrequency - - @staticmethod - def get_lamda(meta_file_path): - # 获取微波波长,单位:m - lamda = OrthoMetaData.get_lamda(meta_file_path) - return lamda - -# if __name__ == '__main__': -# A = ScatteringAuxData() -# dir = 'G:\MicroWorkspace\C-SAR\AuxSAR\GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HHHV_L10004829485_geo/' -# path = dir + 'GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HHHV_L10004829485.meta.xml' -# path1 = dir + 'OrthoProduct.meta.xml' -# t1 = A.get_QualifyValue(path, 'HH') -# t2 = A.get_Kdb(path, 'HH') -# t3 = A.get_RadarCenterFrequency(path) -# t4 = A.get_lamda(path) -# pass \ No newline at end of file diff --git a/landcover-L-SAR/tool/algorithm/algtools/calculateLocalIncident/calculateLocalIncident.py b/landcover-L-SAR/tool/algorithm/algtools/calculateLocalIncident/calculateLocalIncident.py deleted file mode 100644 index c2b634d..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/calculateLocalIncident/calculateLocalIncident.py +++ /dev/null @@ -1,414 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project :microproduct -@File :CalculateIncident.py -@Function :计算、局部入射角计算 -@Author :LMM -@Date :2021/8/25 14:17 -@Version :1.0.0 -""" -import os -import numpy as np -from osgeo import gdal -from osgeo import gdalconst -import gc -import math -from xml.dom import minidom # 不需要安装,默认环境里就有 - - -class CalculateIncident: - def __init__(self): - pass - - @staticmethod - def add_round(npgrid): - """ - 边缘填充一圈,然后输出填充得到的矩阵 - param:npgrid dem数组 - """ - ny, nx = npgrid.shape # ny:行数,nx:列数 - zbc = np.zeros((ny + 2, nx + 2)) - zbc[1:-1, 1:-1] = npgrid - # 四边 - zbc[0, 1:-1] = npgrid[0, :] - zbc[-1, 1:-1] = npgrid[-1, :] - zbc[1:-1, 0] = npgrid[:, 0] - zbc[1:-1, -1] = npgrid[:, -1] - # 角点 - zbc[0, 0] = npgrid[0, 0] - zbc[0, -1] = npgrid[0, -1] - zbc[-1, 0] = npgrid[-1, 0] - zbc[-1, -1] = npgrid[-1, -1] - print("输出填充后的数组的形状", zbc.shape) - return zbc - - @staticmethod - def cal_dxdy(zbc, dx): - """ - 计算dx,dy - param:zbc填充后的数组 - param:dx dem数据像元大小 - - """ - we_x = ((zbc[1:-1, :-2]) - (zbc[1:-1, 2:])) / dx / 2 # WE方向 - ns_y = ((zbc[2:, 1:-1]) - (zbc[:-2, 1:-1])) / dx / 2 # NS方向 - print("输出Sx的数组的形状", we_x.shape, "输出Sy的数组的形状", ns_y.shape) - sx = we_x[1:-1, 1:-1] - sy = ns_y[1:-1, 1:-1] - # np.savetxt("dxdy.csv",dx,delimiter=",") - print("输出Sx2的数组的形状", sx.shape, "输出Sy2的数组的形状", sy.shape) - return sx, sy - - @staticmethod - def cal_slopasp(dx, dy): - # 计算坡度\坡向 - # 坡度计算 slope - slope = (np.arctan(np.sqrt(dx * dx + dy * dy))) * 57.29578 # 转换成°,57.29578=180/math.pi - slope = slope[1:-1, 1:-1] - # 坡向计算 aspect - aspect = np.ones([dx.shape[0], dx.shape[1]]).astype(np.float32) # 生成一个全是0的数组 - - # dx = dx.astype(np.float32) - # dy = dy.astype(np.float32) - # a1=(np.where(dx==0) and np.where(dy ==0)) - # print(a1) - # aspect[a1]=-1 - # a2 = (np.where(dx == 0) and np.where(dy > 0)) - # aspect[a2] =0.0 - # a3 = (np.where(dx == 0) and np.where(dy <0)) - # aspect[a3] =180.0 - # a4 = (np.where(dx > 0) and np.where(dy ==0)) - # aspect[a4] =90.0 - # a5 = (np.where(dx < 0) and np.where(dy ==0)) - # aspect[a5] =270.0 - # a6 = (np.where(dx != 0) or np.where(dy !=0)) - # b=dy[a6] - # print(":", 1) - # aspect[a6] =float(math.atan2(dy[i, j], dx[i, j])) * 57.29578 - # a7=np.where(aspect[a6]< 0.0) - # aspect[a7] = 90.0 - aspect[a7] - # a8=np.where(aspect[a6]> 90.0) - # aspect[a8] = 450.0- aspect[a8] - # a9 =np.where(aspect[a6] >= 0 or aspect[a6] <= 90) - # aspect[a9] =90.0 - aspect[a9] - - for i in range(dx.shape[0]): - for j in range(dx.shape[1]): - x = float(dx[i, j]) - y = float(dy[i, j]) - if (x == 0.0) & (y == 0.0): - aspect[i, j] = -1 - elif x == 0.0: - if y > 0.0: - aspect[i, j] = 0.0 - else: - aspect[i, j] = 180.0 - elif y == 0.0: - if x > 0.0: - aspect[i, j] = 90.0 - else: - aspect[i, j] = 270.0 - else: - aspect[i, j] = float(math.atan2(y, x)) * 57.29578 # 范围(-Π/2,Π/2) - if aspect[i, j] < 0.0: - aspect[i, j] = 90.0 - aspect[i, j] - elif aspect[i, j] > 90.0: - aspect[i, j] = 450.0 - aspect[i, j] - else: - aspect[i, j] = 90.0 - aspect[i, j] - print("输出aspect形状:", aspect.shape) # 3599, 3599 - print("输出aspect:", aspect) - return slope, aspect - - def creat_twofile(self, dem_file_path, slope_out_path, aspect_out_path): - """ - 生成坡度图、坡向图 - param: path_file1 为输入文件tif数据的文件路径 - - """ - if os.path.isfile(dem_file_path): - print("高程数据文件存在") - else: - print("高程数据文件不存在") - - dataset_caijian = gdal.Open(dem_file_path) - x_size = dataset_caijian.RasterXSize - y_size = dataset_caijian.RasterYSize - geo = dataset_caijian.GetGeoTransform() - pro = dataset_caijian.GetProjection() - array0 = dataset_caijian.ReadAsArray(0, 0, x_size, y_size) - print("输出dem数据的数组", array0) - zbc = self.add_round(array0) - sx, sy = self.cal_dxdy(zbc, 30) - slope, aspect = self.cal_slopasp(sx, sy) - - driver = gdal.GetDriverByName("GTiff") # 创建一个数据格式 - driver.Register() - newfile = driver.Create(slope_out_path, x_size, y_size, 1, gdal.GDT_Float32) # 存放路径文件名,长,宽,波段,数据类型 - newfile.SetProjection(pro) - geo = [geo[0], geo[1], 0, geo[3], 0, -geo[1]] - newfile.SetGeoTransform(geo) - newfile.GetRasterBand(1).WriteArray(slope) - - driver2 = gdal.GetDriverByName("GTiff") # 创建一个数据格式 - driver2.Register() - newfile2 = driver2.Create(aspect_out_path, x_size, y_size, 1, gdal.GDT_Float32) # 存放路径文件名,长,宽,波段,数据类型 - geo = [geo[0], geo[1], 0, geo[3], 0, -geo[1]] - newfile2.SetGeoTransform(geo) - newfile2.GetRasterBand(1).WriteArray(aspect) - - @staticmethod - def resampling(input_file1, input_file2, ref_file, output_file, output_file2): - """ - 采用gdal.Warp()方法进行重采样,差值法为双线性插值 - :param input_file1 slope path - :param input_file2 aspect path - :param ref_file: 参考图像路径 - :param output_file: slope path - :param output_file2 aspect path - :return: - """ - gdal.AllRegister() - in_ds1 = gdal.Open(input_file1) - in_ds2 = gdal.Open(input_file2) - ref_ds = gdal.Open(ref_file, gdal.GA_ReadOnly) - - # 获取输入影像信息 - input_file_proj = in_ds1.GetProjection() - # inputefileTrans = in_ds1.GetGeoTransform() - reference_file_proj = ref_ds.GetProjection() - reference_file_trans = ref_ds.GetGeoTransform() - - nbands = in_ds1.RasterCount - bandinputfile1 = in_ds1.GetRasterBand(1) - bandinputfile2 = in_ds2.GetRasterBand(1) - x = ref_ds.RasterXSize - y = ref_ds.RasterYSize - - # 创建重采样输出文件(设置投影及六参数) - driver1 = gdal.GetDriverByName('GTiff') - output1 = driver1.Create(output_file, x, y, nbands, bandinputfile1.DataType) - output1.SetGeoTransform(reference_file_trans) - output1.SetProjection(reference_file_proj) - # options = gdal.WarpOptions(srcSRS=inputProj, dstSRS=referencefileProj, resampleAlg=gdalconst.GRA_Bilinear) - # resampleAlg = gdalconst.GRA_NearestNeighbour - gdal.ReprojectImage(in_ds1, output1, input_file_proj, reference_file_proj, gdalconst.GRA_Bilinear) - - driver2 = gdal.GetDriverByName('GTiff') - output2 = driver2.Create(output_file2, x, y, nbands, bandinputfile2.DataType) - output2.SetGeoTransform(reference_file_trans) - output2.SetProjection(reference_file_proj) - # options = gdal.WarpOptions(srcSRS=inputProj, dstSRS=referencefileProj, resampleAlg=gdalconst.GRA_Bilinear) - # resampleAlg = gdalconst.GRA_NearestNeighbour - gdal.ReprojectImage(in_ds2, output2, input_file_proj, reference_file_proj, gdalconst.GRA_Bilinear) - - @staticmethod - def getorbitparameter(xml_path): - """ - 从轨道参数文件xml中获取升降轨信息、影像四个角的经纬度坐标 - - """ - # 打开xml文档,根据路径初始化DOM - doc = minidom.parse(xml_path) - # 得到xml文档元素对象,初始化root对象 - root = doc.documentElement - - # 输出升降轨信息,DEC降轨,ASC升轨 - direction = root.getElementsByTagName("Direction")[0] - # print("输出Direction的子节点列表",Direction.firstChild.data) - pd = direction.firstChild.data - - imageinfo = root.getElementsByTagName("imageinfo")[0] - # 输出topLeft的纬度和经度 - top_left = imageinfo.getElementsByTagName("topLeft")[0] - latitude = top_left.getElementsByTagName("latitude")[0] - longitude = top_left.getElementsByTagName("longitude")[0] - # print("输出topLeft的纬度lat和经度lon:", latitude.firstChild.data,longitude.firstChild.data) - tl_lat, tl_lon = latitude.firstChild.data, longitude.firstChild.data - - # 输出topRight的纬度和经度 - top_right = imageinfo.getElementsByTagName("topRight")[0] - latitude = top_right.getElementsByTagName("latitude")[0] - longitude = top_right.getElementsByTagName("longitude")[0] - # print("输出topRight的纬度lat和经度lon:", latitude.firstChild.data,longitude.firstChild.data) - tr_lat, tr_lon = latitude.firstChild.data, longitude.firstChild.data - - # 输出 bottomLeft的纬度和经度 - bottom_left = imageinfo.getElementsByTagName("bottomLeft")[0] - latitude = bottom_left.getElementsByTagName("latitude")[0] - longitude = bottom_left.getElementsByTagName("longitude")[0] - # print("输出bottomLeft的纬度lat和经度lon:", latitude.firstChild.data,longitude.firstChild.data) - bl_lat, bl_lon = latitude.firstChild.data, longitude.firstChild.data - - # 输出 bottomRight的纬度和经度 - bottom_right = imageinfo.getElementsByTagName("bottomRight")[0] - latitude = bottom_right.getElementsByTagName("latitude")[0] - longitude = bottom_right.getElementsByTagName("longitude")[0] - # print("输出bottomRight的纬度lat和经度lon:", latitude.firstChild.data,longitude.firstChild.data) - br_lat, br_lon = latitude.firstChild.data, longitude.firstChild.data - print("pd,tl_lat,tl_lon,tr_lat,tr_lon,bl_lat,bl_lon,br_lat,br_lon", pd, tl_lat, tl_lon, tr_lat, tr_lon, bl_lat, - bl_lon, br_lat, br_lon) - return pd, tl_lat, tl_lon, tr_lat, tr_lon, bl_lat, bl_lon, br_lat, br_lon - - def get_rparademeter(self, xml_path): - """ - 计算雷达视线向方向角R - """ - pd, tl_lat, tl_lon, tr_lat, tr_lon, bl_lat, bl_lon, br_lat, br_lon = self.getorbitparameter(xml_path) - - tl_lat = float(tl_lat) # 原来的数是带有小数点的字符串,int会报错,使用float - tl_lon = float(tl_lon) - # tr_lat = float(tr_lat) - # tr_lon = float(tr_lon) - bl_lat = float(bl_lat) - bl_lon = float(bl_lon) - # br_lat = float(br_lat) - # br_lon = float(br_lon) - - if pd == "DEC": - # 降轨 - b = np.arctan((tl_lat - bl_lat) / (tl_lon - bl_lon)) * 57.29578 - r = 270 + b - return r - # tl_lat, tl_lon = lonlat2geo(tl_lat, tl_lon) - # tr_lat, tr_lon = lonlat2geo(tr_lat, tr_lon) - # bl_lat, bl_lon = lonlat2geo(bl_lat, bl_lon) - # br_lat, br_lon = lonlat2geo(br_lat, br_lon) - # B2 = np.arctan((tl_lat - bl_lat) / (tl_lon - bl_lon)) * 57.29578 - # R2 = 270 + B2 - # print(("输出R2:", R2)) - if pd == "ASC": - # 升轨 - b = np.arctan((tl_lat - bl_lat) / (tl_lon - bl_lon)) * 57.29578 - return b - - def clau(self, pathfile1, pathfile2, pathfile3, xml_path, save_localangle_path): - """ - 计算局部入射角 - param: pathfile1是slope的坡度图路径 - param: pathfile2是aspect的坡向图路径 - param: pathfile3是入射角文件的路径 - param: xml_path是轨道参数文件 - r是雷达视线向方位角 - """ - r = self.get_rparademeter(xml_path) - pd, tl_lat, tl_lon, tr_lat, tr_lon, bl_lat, bl_lon, br_lat, br_lon = self.getorbitparameter(xml_path) - print("输出升降轨:", pd) - dataset = gdal.Open(pathfile1) - x = dataset.RasterXSize - y = dataset.RasterYSize - print("输出slope的行、列:", x, y) - slope_array = dataset.ReadAsArray(0, 0, x, y) - - dataset2 = gdal.Open(pathfile2) - x2 = dataset2.RasterXSize - y2 = dataset2.RasterYSize - print("输出aspect的行、列:", x2, y2) - aspect_array = dataset2.ReadAsArray(0, 0, x2, y2) - - dataset3 = gdal.Open(pathfile3) - x3 = dataset3.RasterXSize - y3 = dataset3.RasterYSize - geo3 = dataset3.GetGeoTransform() - pro3 = dataset3.GetProjection() - print("输出入射角文件的行、列:", x3, y3) - - rushe_array = dataset3.ReadAsArray(0, 0, x3, y3) - # b0 = np.where(rushe_array > 0.00001, 0, 1) - radina_value = 0 - if pd == "DEC": - # 降轨数据 - # 雷达视线角-坡度角在90度到270度之间 - where_0 = np.where(rushe_array == 0) - - bb1 = (r-aspect_array).all() and (r-aspect_array).all() - bb2 = np.where(90 < bb1 < 270, 1, 0) - b1 = (bb1 and bb2) - # b1 = np.where(90 < ((r-aspect_array).all()) and ((r-aspect_array).all()) < 270, 1, 0) - c1 = np.cos(rushe_array*(math.pi/180)) * np.cos(slope_array*(math.pi/180)) - np.sin(slope_array*(math.pi/180)) * np.sin( - rushe_array*(math.pi/180)) * np.cos((r - aspect_array)*(math.pi/180)) - d1 = b1 * c1 - # 雷达视线角-坡度角=90度或=270度时 - b2 = np.where((r-aspect_array == 90) | (r-aspect_array == 270), 1, 0) - d2 = b2*c1 - # 雷达视线角-坡度角在90度到270度之间 - b3 = 1-b1-b2 - c3 = np.cos(rushe_array*(math.pi/180)) * np.cos(slope_array*(math.pi/180)) + np.sin( - slope_array*(math.pi/180)) * np.sin(rushe_array*(math.pi/180)) * np.cos((r - aspect_array)*(math.pi/180)) - d3 = b3 * c3 - del b1, b2, b3, c3, c1 - gc.collect() - radina_value = d1 + d2 + d3 - radina_value[where_0] = 0 - del d1, d2, d3 - gc.collect() - if pd == "ASC": - # 升轨数据 - # 坡度-雷达视线角在90度到270度之间 - where_0 = np.where(rushe_array == 0) - - bb1 = (r-aspect_array).all() and (r-aspect_array).all() - bb2 = np.where(90 < bb1 < 270, 1, 0) - b1 = (bb1 and bb2) - # b1 = np.where(90 < ((r-aspect_array).all()) and ((r-aspect_array).all()) < 270, 1, 0) - c1 = np.cos(rushe_array*(math.pi/180)) * np.cos(slope_array*(math.pi/180)) + np.sin( - slope_array*(math.pi/180)) * np.sin(rushe_array*(math.pi/180)) * np.cos((r - aspect_array)*(math.pi/180)) - d1 = b1 * c1 - # 坡度-雷达视线角=90或=270时 - b2 = np.where((aspect_array-r == 90) | (aspect_array-r == 270), 1, 0) - d2 = b2 * c1 - # 坡度-雷达视线角在0-90度或270-360度之间 - b3 = 1 - b1-b2 - c3 = np.cos(rushe_array*(math.pi/180)) * np.cos(slope_array*(math.pi/180)) - np.sin(slope_array*(math.pi/180)) *\ - np.sin(rushe_array*(math.pi/180)) * np.cos((r - aspect_array)*(math.pi/180)) - d3 = b3 * c3 - radina_value = d1 + d2 + d3 - radina_value[where_0] = 0 - del b1, b2, b3, c3, c1, d1, d2, d3 - gc.collect() - jubu_o = 57.29578 * np.arccos(radina_value) - print("输出局部入射角", jubu_o) - driver = gdal.GetDriverByName("GTiff") # 创建一个数据格式 - driver.Register() - newfile = driver.Create(save_localangle_path, x3, y3, 1, gdal.GDT_Float32) # 存放路径文件名,长,宽,波段,数据类型 - newfile.SetProjection(pro3) - newfile.SetGeoTransform(geo3) - newfile.GetRasterBand(1).WriteArray(jubu_o) - - def localangle(self, dem_path, incidence_angle_path, orbital_parameters_path): - """ - 获取输入文件的路径 - 计算坡度图、坡向图 - 计算局部入射角 - """ - para_names = ["Dem", "IncidenceAngle", "OrbitalParameters", "经验A"] - if len(para_names) == 0: - return False - # 获取三个文件的路径 - - # print("输出三个文件路径",Dem_path,IncidenceAngle_path,OrbitalParameters_path) - # 确定坡度、坡向的输出路径,输出坡度、坡向图 - slope_out_path = r"D:\MicroWorkspace\LeafAreaIndex\Temporary\UnClipslope.tif" - aspect_out_path = r"D:\MicroWorkspace\LeafAreaIndex\Temporary\UnClipaspect.tif" - print("slope_out_path的路径是", slope_out_path) - print("aspect_out_path的路径是", aspect_out_path) - self.creat_twofile(dem_path, slope_out_path, aspect_out_path) - # 根据入射角文件对坡度坡向图进行裁剪与重采样 - slope_out_path2 = r"D:\MicroWorkspace\LocaLangle\Temporary\Clipslope.tif" - aspect_out_path2 = r"D:\MicroWorkspace\LocaLangle\Temporary\Clipaspect.tif" - self.resampling(slope_out_path, aspect_out_path, incidence_angle_path, slope_out_path2, aspect_out_path2) - - # 输出局部入射角文件 - save_localangle_path = r"D:\\MicroWorkspace\\LocaLangle\\Temporary\\\localangle.tif" - self.clau(slope_out_path2, aspect_out_path2, incidence_angle_path, - orbital_parameters_path, save_localangle_path) - - -# if __name__ == '__main__': -# calu_incident = CalculateIncident() -# Dem_path = "D:\\MicroWorkspace\\LocaLangle\\Input\\dem.tif" -# IncidenceAngle_path = "D:\\MicroWorkspace\\LocaLangle\\Input\\RSJ.tif" -# OrbitalParameters_path = "D:\\MicroWorkspace\\LocaLangle\\Input\\" \ -# "GF3_KAS_FSII_020008_E113.2_N23.1_20200528_L1A_HHHV_L10004829485.meta.xml" -# calu_incident.localangle(Dem_path, IncidenceAngle_path, OrbitalParameters_path) -# print('done') diff --git a/landcover-L-SAR/tool/algorithm/algtools/filter/build/lee_Filter/lee_Filter_c.c b/landcover-L-SAR/tool/algorithm/algtools/filter/build/lee_Filter/lee_Filter_c.c deleted file mode 100644 index f14bfc5..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/filter/build/lee_Filter/lee_Filter_c.c +++ /dev/null @@ -1,7654 +0,0 @@ -/* Generated by Cython 0.29.24 */ - -/* BEGIN: Cython Metadata -{ - "distutils": { - "depends": [], - "name": "lee_Filter_c", - "sources": [ - "./lee_Filter/lee_Filter_c.pyx" - ] - }, - "module_name": "lee_Filter_c" -} -END: Cython Metadata */ - -#ifndef PY_SSIZE_T_CLEAN -#define PY_SSIZE_T_CLEAN -#endif /* PY_SSIZE_T_CLEAN */ -#include "Python.h" -#ifndef Py_PYTHON_H - #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) - #error Cython requires Python 2.6+ or Python 3.3+. -#else -#define CYTHON_ABI "0_29_24" -#define CYTHON_HEX_VERSION 0x001D18F0 -#define CYTHON_FUTURE_DIVISION 0 -#include -#ifndef offsetof - #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !defined(WIN32) && !defined(MS_WINDOWS) - #ifndef __stdcall - #define __stdcall - #endif - #ifndef __cdecl - #define __cdecl - #endif - #ifndef __fastcall - #define __fastcall - #endif -#endif -#ifndef DL_IMPORT - #define DL_IMPORT(t) t -#endif -#ifndef DL_EXPORT - #define DL_EXPORT(t) t -#endif -#define __PYX_COMMA , -#ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x02070000 - #define HAVE_LONG_LONG - #endif -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION - #define CYTHON_COMPILING_IN_PYPY 1 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #undef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #if PY_VERSION_HEX < 0x03050000 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #undef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #undef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 1 - #undef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 0 - #undef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 0 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 - #undef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS 0 - #undef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK 0 -#elif defined(PYSTON_VERSION) - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 1 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 - #undef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS 0 - #undef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK 0 -#else - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 1 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) - #define CYTHON_USE_PYTYPE_LOOKUP 1 - #endif - #if PY_MAJOR_VERSION < 3 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #elif !defined(CYTHON_USE_PYLONG_INTERNALS) - #define CYTHON_USE_PYLONG_INTERNALS 1 - #endif - #ifndef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 1 - #endif - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #if PY_VERSION_HEX < 0x030300F0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #elif !defined(CYTHON_USE_UNICODE_WRITER) - #define CYTHON_USE_UNICODE_WRITER 1 - #endif - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #ifndef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 1 - #endif - #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 1 - #endif - #ifndef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) - #endif - #ifndef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) - #endif - #ifndef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) - #endif - #ifndef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) - #endif -#endif -#if !defined(CYTHON_FAST_PYCCALL) -#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) -#endif -#if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #undef SHIFT - #undef BASE - #undef MASK - #ifdef SIZEOF_VOID_P - enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; - #endif -#endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif -#ifndef __has_cpp_attribute - #define __has_cpp_attribute(x) 0 -#endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif -#endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) -#ifdef _MSC_VER - #ifndef _MSC_STDINT_H_ - #if _MSC_VER < 1300 - typedef unsigned char uint8_t; - typedef unsigned int uint32_t; - #else - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - #endif - #endif -#else - #include -#endif -#ifndef CYTHON_FALLTHROUGH - #if defined(__cplusplus) && __cplusplus >= 201103L - #if __has_cpp_attribute(fallthrough) - #define CYTHON_FALLTHROUGH [[fallthrough]] - #elif __has_cpp_attribute(clang::fallthrough) - #define CYTHON_FALLTHROUGH [[clang::fallthrough]] - #elif __has_cpp_attribute(gnu::fallthrough) - #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] - #endif - #endif - #ifndef CYTHON_FALLTHROUGH - #if __has_attribute(fallthrough) - #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) - #else - #define CYTHON_FALLTHROUGH - #endif - #endif - #if defined(__clang__ ) && defined(__apple_build_version__) - #if __apple_build_version__ < 7000000 - #undef CYTHON_FALLTHROUGH - #define CYTHON_FALLTHROUGH - #endif - #endif -#endif - -#ifndef CYTHON_INLINE - #if defined(__clang__) - #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) - #elif defined(__GNUC__) - #define CYTHON_INLINE __inline__ - #elif defined(_MSC_VER) - #define CYTHON_INLINE __inline - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_INLINE inline - #else - #define CYTHON_INLINE - #endif -#endif - -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) - #define Py_OptimizeFlag 0 -#endif -#define __PYX_BUILD_PY_SSIZE_T "n" -#define CYTHON_FORMAT_SSIZE_T "z" -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" -#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2 - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#else - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#endif - #define __Pyx_DefaultClassType PyType_Type -#endif -#ifndef Py_TPFLAGS_CHECKTYPES - #define Py_TPFLAGS_CHECKTYPES 0 -#endif -#ifndef Py_TPFLAGS_HAVE_INDEX - #define Py_TPFLAGS_HAVE_INDEX 0 -#endif -#ifndef Py_TPFLAGS_HAVE_NEWBUFFER - #define Py_TPFLAGS_HAVE_NEWBUFFER 0 -#endif -#ifndef Py_TPFLAGS_HAVE_FINALIZE - #define Py_TPFLAGS_HAVE_FINALIZE 0 -#endif -#ifndef METH_STACKLESS - #define METH_STACKLESS 0 -#endif -#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) - #ifndef METH_FASTCALL - #define METH_FASTCALL 0x80 - #endif - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); - typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, - Py_ssize_t nargs, PyObject *kwnames); -#else - #define __Pyx_PyCFunctionFast _PyCFunctionFast - #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords -#endif -#if CYTHON_FAST_PYCCALL -#define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) -#else -#define __Pyx_PyFastCFunction_Check(func) 0 -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) - #define PyObject_Malloc(s) PyMem_Malloc(s) - #define PyObject_Free(p) PyMem_Free(p) - #define PyObject_Realloc(p) PyMem_Realloc(p) -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 - #define PyMem_RawMalloc(n) PyMem_Malloc(n) - #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) - #define PyMem_RawFree(p) PyMem_Free(p) -#endif -#if CYTHON_COMPILING_IN_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) -#else - #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) -#endif -#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#elif PY_VERSION_HEX >= 0x03060000 - #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() -#elif PY_VERSION_HEX >= 0x03000000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#else - #define __Pyx_PyThreadState_Current _PyThreadState_Current -#endif -#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) -#include "pythread.h" -#define Py_tss_NEEDS_INIT 0 -typedef int Py_tss_t; -static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { - *key = PyThread_create_key(); - return 0; -} -static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { - Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); - *key = Py_tss_NEEDS_INIT; - return key; -} -static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { - PyObject_Free(key); -} -static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { - return *key != Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { - PyThread_delete_key(*key); - *key = Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { - return PyThread_set_key_value(*key, value); -} -static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { - return PyThread_get_key_value(*key); -} -#endif -#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) -#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) -#else -#define __Pyx_PyDict_NewPresized(n) PyDict_New() -#endif -#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS -#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) -#else -#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #if defined(PyUnicode_IS_READY) - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #else - #define __Pyx_PyUnicode_READY(op) (0) - #endif - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) - #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) - #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) - #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) - #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE) - #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) - #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) - #endif - #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) - #endif -#else - #define CYTHON_PEP393_ENABLED 0 - #define PyUnicode_1BYTE_KIND 1 - #define PyUnicode_2BYTE_KIND 2 - #define PyUnicode_4BYTE_KIND 4 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) -#endif -#if CYTHON_COMPILING_IN_PYPY - #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) -#else - #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ - PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) - #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) - #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) - #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) -#endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) - #define PyObject_ASCII(o) PyObject_Repr(o) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#ifndef PyObject_Unicode - #define PyObject_Unicode PyObject_Str -#endif -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#if PY_VERSION_HEX >= 0x030900A4 - #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) - #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) -#else - #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) - #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) -#endif -#if CYTHON_ASSUME_SAFE_MACROS - #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) -#else - #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) -#endif -#if CYTHON_USE_ASYNC_SLOTS - #if PY_VERSION_HEX >= 0x030500B1 - #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods - #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) - #else - #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef __Pyx_PyAsyncMethodsStruct - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; -#endif - -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES -#endif -#include -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) -#define __Pyx_truncl trunc -#else -#define __Pyx_truncl truncl -#endif - -#define __PYX_MARK_ERR_POS(f_index, lineno) \ - { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } -#define __PYX_ERR(f_index, lineno, Ln_error) \ - { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#define __PYX_HAVE__lee_Filter_c -#define __PYX_HAVE_API__lee_Filter_c -/* Early includes */ -#include -#include -#include "numpy/arrayobject.h" -#include "numpy/ndarrayobject.h" -#include "numpy/ndarraytypes.h" -#include "numpy/arrayscalars.h" -#include "numpy/ufuncobject.h" - - /* NumPy API declarations from "numpy/__init__.pxd" */ - -#include -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) -#define __PYX_DEFAULT_STRING_ENCODING "" -#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString -#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#define __Pyx_uchar_cast(c) ((unsigned char)c) -#define __Pyx_long_cast(x) ((long)x) -#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ - (sizeof(type) < sizeof(Py_ssize_t)) ||\ - (sizeof(type) > sizeof(Py_ssize_t) &&\ - likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX) &&\ - (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ - v == (type)PY_SSIZE_T_MIN))) ||\ - (sizeof(type) == sizeof(Py_ssize_t) &&\ - (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX))) ) -static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { - return (size_t) i < (size_t) limit; -} -#if defined (__cplusplus) && __cplusplus >= 201103L - #include - #define __Pyx_sst_abs(value) std::abs(value) -#elif SIZEOF_INT >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) abs(value) -#elif SIZEOF_LONG >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) labs(value) -#elif defined (_MSC_VER) - #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) -#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define __Pyx_sst_abs(value) llabs(value) -#elif defined (__GNUC__) - #define __Pyx_sst_abs(value) __builtin_llabs(value) -#else - #define __Pyx_sst_abs(value) ((value<0) ? -value : value) -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) -#define __Pyx_PyBytes_FromString PyBytes_FromString -#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) -#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) -#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) -#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) -#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); -#define __Pyx_PySequence_Tuple(obj)\ - (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -#if CYTHON_ASSUME_SAFE_MACROS -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) -#else -#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) -#endif -#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#endif - - -/* Test for GCC > 2.95 */ -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) -#else /* !__GNUC__ or GCC < 2.95 */ - #define likely(x) (x) - #define unlikely(x) (x) -#endif /* __GNUC__ */ -static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } - -static PyObject *__pyx_m = NULL; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime = NULL; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static PyObject *__pyx_empty_unicode; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - -/* Header.proto */ -#if !defined(CYTHON_CCOMPLEX) - #if defined(__cplusplus) - #define CYTHON_CCOMPLEX 1 - #elif defined(_Complex_I) - #define CYTHON_CCOMPLEX 1 - #else - #define CYTHON_CCOMPLEX 0 - #endif -#endif -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #include - #else - #include - #endif -#endif -#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) - #undef _Complex_I - #define _Complex_I 1.0fj -#endif - - -static const char *__pyx_f[] = { - "lee_Filter\\lee_Filter_c.pyx", - "__init__.pxd", - "type.pxd", -}; -/* BufferFormatStructs.proto */ -#define IS_UNSIGNED(type) (((type) -1) > 0) -struct __Pyx_StructField_; -#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) -typedef struct { - const char* name; - struct __Pyx_StructField_* fields; - size_t size; - size_t arraysize[8]; - int ndim; - char typegroup; - char is_unsigned; - int flags; -} __Pyx_TypeInfo; -typedef struct __Pyx_StructField_ { - __Pyx_TypeInfo* type; - const char* name; - size_t offset; -} __Pyx_StructField; -typedef struct { - __Pyx_StructField* field; - size_t parent_offset; -} __Pyx_BufFmt_StackElem; -typedef struct { - __Pyx_StructField root; - __Pyx_BufFmt_StackElem* head; - size_t fmt_offset; - size_t new_count, enc_count; - size_t struct_alignment; - int is_complex; - char enc_type; - char new_packmode; - char enc_packmode; - char is_valid_array; -} __Pyx_BufFmt_Context; - - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":690 - * # in Cython to enable them only on the right systems. - * - * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - */ -typedef npy_int8 __pyx_t_5numpy_int8_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":691 - * - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t - */ -typedef npy_int16 __pyx_t_5numpy_int16_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":692 - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< - * ctypedef npy_int64 int64_t - * #ctypedef npy_int96 int96_t - */ -typedef npy_int32 __pyx_t_5numpy_int32_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":693 - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< - * #ctypedef npy_int96 int96_t - * #ctypedef npy_int128 int128_t - */ -typedef npy_int64 __pyx_t_5numpy_int64_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":697 - * #ctypedef npy_int128 int128_t - * - * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - */ -typedef npy_uint8 __pyx_t_5numpy_uint8_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":698 - * - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t - */ -typedef npy_uint16 __pyx_t_5numpy_uint16_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":699 - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< - * ctypedef npy_uint64 uint64_t - * #ctypedef npy_uint96 uint96_t - */ -typedef npy_uint32 __pyx_t_5numpy_uint32_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":700 - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< - * #ctypedef npy_uint96 uint96_t - * #ctypedef npy_uint128 uint128_t - */ -typedef npy_uint64 __pyx_t_5numpy_uint64_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":704 - * #ctypedef npy_uint128 uint128_t - * - * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< - * ctypedef npy_float64 float64_t - * #ctypedef npy_float80 float80_t - */ -typedef npy_float32 __pyx_t_5numpy_float32_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":705 - * - * ctypedef npy_float32 float32_t - * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< - * #ctypedef npy_float80 float80_t - * #ctypedef npy_float128 float128_t - */ -typedef npy_float64 __pyx_t_5numpy_float64_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":714 - * # The int types are mapped a bit surprising -- - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t - */ -typedef npy_long __pyx_t_5numpy_int_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":715 - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong longlong_t - * - */ -typedef npy_longlong __pyx_t_5numpy_long_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":716 - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_ulong uint_t - */ -typedef npy_longlong __pyx_t_5numpy_longlong_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":718 - * ctypedef npy_longlong longlong_t - * - * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t - */ -typedef npy_ulong __pyx_t_5numpy_uint_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":719 - * - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulonglong_t - * - */ -typedef npy_ulonglong __pyx_t_5numpy_ulong_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":720 - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_intp intp_t - */ -typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":722 - * ctypedef npy_ulonglong ulonglong_t - * - * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< - * ctypedef npy_uintp uintp_t - * - */ -typedef npy_intp __pyx_t_5numpy_intp_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":723 - * - * ctypedef npy_intp intp_t - * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< - * - * ctypedef npy_double float_t - */ -typedef npy_uintp __pyx_t_5numpy_uintp_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":725 - * ctypedef npy_uintp uintp_t - * - * ctypedef npy_double float_t # <<<<<<<<<<<<<< - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t - */ -typedef npy_double __pyx_t_5numpy_float_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":726 - * - * ctypedef npy_double float_t - * ctypedef npy_double double_t # <<<<<<<<<<<<<< - * ctypedef npy_longdouble longdouble_t - * - */ -typedef npy_double __pyx_t_5numpy_double_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":727 - * ctypedef npy_double float_t - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cfloat cfloat_t - */ -typedef npy_longdouble __pyx_t_5numpy_longdouble_t; -/* Declarations.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< float > __pyx_t_float_complex; - #else - typedef float _Complex __pyx_t_float_complex; - #endif -#else - typedef struct { float real, imag; } __pyx_t_float_complex; -#endif -static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); - -/* Declarations.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< double > __pyx_t_double_complex; - #else - typedef double _Complex __pyx_t_double_complex; - #endif -#else - typedef struct { double real, imag; } __pyx_t_double_complex; -#endif -static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); - - -/*--- Type declarations ---*/ - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":729 - * ctypedef npy_longdouble longdouble_t - * - * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t - */ -typedef npy_cfloat __pyx_t_5numpy_cfloat_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":730 - * - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< - * ctypedef npy_clongdouble clongdouble_t - * - */ -typedef npy_cdouble __pyx_t_5numpy_cdouble_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":731 - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cdouble complex_t - */ -typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":733 - * ctypedef npy_clongdouble clongdouble_t - * - * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew1(a): - */ -typedef npy_cdouble __pyx_t_5numpy_complex_t; - -/* --- Runtime support code (head) --- */ -/* Refnanny.proto */ -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, const char*); - void (*FinishContext)(void**); - } __Pyx_RefNannyAPIStruct; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); - #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; -#ifdef WITH_THREAD - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - if (acquire_gil) {\ - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - PyGILState_Release(__pyx_gilstate_save);\ - } else {\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #define __Pyx_RefNannyFinishContext()\ - __Pyx_RefNanny->FinishContext(&__pyx_refnanny) - #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #define __Pyx_RefNannyFinishContext() - #define __Pyx_INCREF(r) Py_INCREF(r) - #define __Pyx_DECREF(r) Py_DECREF(r) - #define __Pyx_GOTREF(r) - #define __Pyx_GIVEREF(r) - #define __Pyx_XINCREF(r) Py_XINCREF(r) - #define __Pyx_XDECREF(r) Py_XDECREF(r) - #define __Pyx_XGOTREF(r) - #define __Pyx_XGIVEREF(r) -#endif -#define __Pyx_XDECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_XDECREF(tmp);\ - } while (0) -#define __Pyx_DECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_DECREF(tmp);\ - } while (0) -#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) -#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) - -/* PyObjectGetAttrStr.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -/* GetBuiltinName.proto */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name); - -/* IsLittleEndian.proto */ -static CYTHON_INLINE int __Pyx_Is_Little_Endian(void); - -/* BufferFormatCheck.proto */ -static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); -static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type); - -/* BufferGetAndValidate.proto */ -#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\ - ((obj == Py_None || obj == NULL) ?\ - (__Pyx_ZeroBuffer(buf), 0) :\ - __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)) -static int __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj, - __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); -static void __Pyx_ZeroBuffer(Py_buffer* buf); -static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); -static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#define __Pyx_BUILD_ASSERT_EXPR(cond)\ - (sizeof(char [1 - 2*!(cond)]) - 1) -#ifndef Py_MEMBER_SIZE -#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) -#endif - static size_t __pyx_pyframe_localsplus_offset = 0; - #include "frameobject.h" - #define __Pxy_PyFrame_Initialize_Offsets()\ - ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ - (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) - #define __Pyx_PyFrame_GetLocalsplus(frame)\ - (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) -#endif - -/* PyObjectCall.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); -#else -#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) -#endif - -/* PyObjectCallMethO.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); -#endif - -/* PyObjectCallNoArg.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); -#else -#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) -#endif - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* PyThreadStateGet.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; -#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type -#else -#define __Pyx_PyThreadState_declare -#define __Pyx_PyThreadState_assign -#define __Pyx_PyErr_Occurred() PyErr_Occurred() -#endif - -/* PyErrFetchRestore.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) -#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) -#else -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#endif -#else -#define __Pyx_PyErr_Clear() PyErr_Clear() -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) -#endif - -/* WriteUnraisableException.proto */ -static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename, - int full_traceback, int nogil); - -/* None.proto */ -static CYTHON_INLINE long __Pyx_div_long(long, long); - -/* BufferIndexError.proto */ -static void __Pyx_RaiseBufferIndexError(int axis); - -#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ - __Pyx_GetItemInt_Generic(o, to_py_func(i)))) -#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, - int is_list, int wraparound, int boundscheck); - -/* ObjectGetItem.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); -#else -#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) -#endif - -/* ExtTypeTest.proto */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); - -/* BufferFallbackError.proto */ -static void __Pyx_RaiseBufferFallbackError(void); - -/* PyDictVersioning.proto */ -#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS -#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) -#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) -#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ - (version_var) = __PYX_GET_DICT_VERSION(dict);\ - (cache_var) = (value); -#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ - static PY_UINT64_T __pyx_dict_version = 0;\ - static PyObject *__pyx_dict_cached_value = NULL;\ - if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ - (VAR) = __pyx_dict_cached_value;\ - } else {\ - (VAR) = __pyx_dict_cached_value = (LOOKUP);\ - __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ - }\ -} -static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); -static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); -static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); -#else -#define __PYX_GET_DICT_VERSION(dict) (0) -#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) -#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); -#endif - -/* GetModuleGlobalName.proto */ -#if CYTHON_USE_DICT_VERSIONS -#define __Pyx_GetModuleGlobalName(var, name) {\ - static PY_UINT64_T __pyx_dict_version = 0;\ - static PyObject *__pyx_dict_cached_value = NULL;\ - (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ - (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ - __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ -} -#define __Pyx_GetModuleGlobalNameUncached(var, name) {\ - PY_UINT64_T __pyx_dict_version;\ - PyObject *__pyx_dict_cached_value;\ - (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ -} -static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); -#else -#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) -#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) -static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); -#endif - -/* PyObjectCall2Args.proto */ -static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); - -/* PyFloatBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyFloat_DivideObjC(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check); -#else -#define __Pyx_PyFloat_DivideObjC(op1, op2, floatval, inplace, zerodivision_check)\ - ((inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2))) - #endif - -/* RaiseArgTupleInvalid.proto */ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* ArgTypeTest.proto */ -#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ - ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ - __Pyx__ArgTypeTest(obj, type, name, exact)) -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); - -/* GetTopmostException.proto */ -#if CYTHON_USE_EXC_INFO_STACK -static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); -#endif - -/* SaveResetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -#else -#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) -#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) -#endif - -/* PyErrExceptionMatches.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) -static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); -#else -#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) -#endif - -/* GetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); -#endif - -/* RaiseException.proto */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); - -/* TypeImport.proto */ -#ifndef __PYX_HAVE_RT_ImportType_proto -#define __PYX_HAVE_RT_ImportType_proto -enum __Pyx_ImportType_CheckSize { - __Pyx_ImportType_CheckSize_Error = 0, - __Pyx_ImportType_CheckSize_Warn = 1, - __Pyx_ImportType_CheckSize_Ignore = 2 -}; -static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size); -#endif - -/* Import.proto */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); - -/* CLineInTraceback.proto */ -#ifdef CYTHON_CLINE_IN_TRACEBACK -#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) -#else -static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); -#endif - -/* CodeObjectCache.proto */ -typedef struct { - PyCodeObject* code_object; - int code_line; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -/* AddTraceback.proto */ -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); - -/* BufferStructDeclare.proto */ -typedef struct { - Py_ssize_t shape, strides, suboffsets; -} __Pyx_Buf_DimInfo; -typedef struct { - size_t refcount; - Py_buffer pybuffer; -} __Pyx_Buffer; -typedef struct { - __Pyx_Buffer *rcbuffer; - char *data; - __Pyx_Buf_DimInfo diminfo[8]; -} __Pyx_LocalBuf_ND; - -#if PY_MAJOR_VERSION < 3 - static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); - static void __Pyx_ReleaseBuffer(Py_buffer *view); -#else - #define __Pyx_GetBuffer PyObject_GetBuffer - #define __Pyx_ReleaseBuffer PyBuffer_Release -#endif - - -/* GCCDiagnostics.proto */ -#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) -#define __Pyx_HAS_GCC_DIAGNOSTIC -#endif - -/* RealImag.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #define __Pyx_CREAL(z) ((z).real()) - #define __Pyx_CIMAG(z) ((z).imag()) - #else - #define __Pyx_CREAL(z) (__real__(z)) - #define __Pyx_CIMAG(z) (__imag__(z)) - #endif -#else - #define __Pyx_CREAL(z) ((z).real) - #define __Pyx_CIMAG(z) ((z).imag) -#endif -#if defined(__cplusplus) && CYTHON_CCOMPLEX\ - && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) - #define __Pyx_SET_CREAL(z,x) ((z).real(x)) - #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) -#else - #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) - #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) -#endif - -/* Arithmetic.proto */ -#if CYTHON_CCOMPLEX - #define __Pyx_c_eq_float(a, b) ((a)==(b)) - #define __Pyx_c_sum_float(a, b) ((a)+(b)) - #define __Pyx_c_diff_float(a, b) ((a)-(b)) - #define __Pyx_c_prod_float(a, b) ((a)*(b)) - #define __Pyx_c_quot_float(a, b) ((a)/(b)) - #define __Pyx_c_neg_float(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zero_float(z) ((z)==(float)0) - #define __Pyx_c_conj_float(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_abs_float(z) (::std::abs(z)) - #define __Pyx_c_pow_float(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zero_float(z) ((z)==0) - #define __Pyx_c_conj_float(z) (conjf(z)) - #if 1 - #define __Pyx_c_abs_float(z) (cabsf(z)) - #define __Pyx_c_pow_float(a, b) (cpowf(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex); - static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex); - #if 1 - static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex); - #endif -#endif - -/* Arithmetic.proto */ -#if CYTHON_CCOMPLEX - #define __Pyx_c_eq_double(a, b) ((a)==(b)) - #define __Pyx_c_sum_double(a, b) ((a)+(b)) - #define __Pyx_c_diff_double(a, b) ((a)-(b)) - #define __Pyx_c_prod_double(a, b) ((a)*(b)) - #define __Pyx_c_quot_double(a, b) ((a)/(b)) - #define __Pyx_c_neg_double(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zero_double(z) ((z)==(double)0) - #define __Pyx_c_conj_double(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_abs_double(z) (::std::abs(z)) - #define __Pyx_c_pow_double(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zero_double(z) ((z)==0) - #define __Pyx_c_conj_double(z) (conj(z)) - #if 1 - #define __Pyx_c_abs_double(z) (cabs(z)) - #define __Pyx_c_pow_double(a, b) (cpow(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex); - static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex); - #if 1 - static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex); - #endif -#endif - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -/* FastTypeChecks.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); -#else -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) -#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) -#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) -#endif -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) - -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* InitStrings.proto */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); - - -/* Module declarations from 'cython' */ - -/* Module declarations from 'cpython.buffer' */ - -/* Module declarations from 'libc.string' */ - -/* Module declarations from 'libc.stdio' */ - -/* Module declarations from '__builtin__' */ - -/* Module declarations from 'cpython.type' */ -static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; - -/* Module declarations from 'cpython' */ - -/* Module declarations from 'cpython.object' */ - -/* Module declarations from 'cpython.ref' */ - -/* Module declarations from 'cpython.mem' */ - -/* Module declarations from 'numpy' */ - -/* Module declarations from 'numpy' */ -static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; -static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; -static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; -static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; -static PyTypeObject *__pyx_ptype_5numpy_generic = 0; -static PyTypeObject *__pyx_ptype_5numpy_number = 0; -static PyTypeObject *__pyx_ptype_5numpy_integer = 0; -static PyTypeObject *__pyx_ptype_5numpy_signedinteger = 0; -static PyTypeObject *__pyx_ptype_5numpy_unsignedinteger = 0; -static PyTypeObject *__pyx_ptype_5numpy_inexact = 0; -static PyTypeObject *__pyx_ptype_5numpy_floating = 0; -static PyTypeObject *__pyx_ptype_5numpy_complexfloating = 0; -static PyTypeObject *__pyx_ptype_5numpy_flexible = 0; -static PyTypeObject *__pyx_ptype_5numpy_character = 0; -static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; - -/* Module declarations from 'libc.math' */ - -/* Module declarations from 'lee_Filter_c' */ -static double __pyx_v_12lee_Filter_c_COEF_VAR_DEFAULT; -static double __pyx_v_12lee_Filter_c_CU_DEFAULT; -static int __pyx_f_12lee_Filter_c_ceil_usr(double); /*proto*/ -static double __pyx_f_12lee_Filter_c_weighting(PyArrayObject *, double); /*proto*/ -static PyArrayObject *__pyx_f_12lee_Filter_c_lee_filter_array(PyArrayObject *, PyArrayObject *, int, int __pyx_skip_dispatch); /*proto*/ -static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 }; -#define __Pyx_MODULE_NAME "lee_Filter_c" -extern int __pyx_module_is_main_lee_Filter_c; -int __pyx_module_is_main_lee_Filter_c = 0; - -/* Implementation of 'lee_Filter_c' */ -static PyObject *__pyx_builtin_round; -static PyObject *__pyx_builtin_ImportError; -static const char __pyx_k_np[] = "np"; -static const char __pyx_k_os[] = "os"; -static const char __pyx_k_img[] = "img"; -static const char __pyx_k_std[] = "std"; -static const char __pyx_k_main[] = "__main__"; -static const char __pyx_k_mean[] = "mean"; -static const char __pyx_k_name[] = "__name__"; -static const char __pyx_k_test[] = "__test__"; -static const char __pyx_k_numpy[] = "numpy"; -static const char __pyx_k_round[] = "round"; -static const char __pyx_k_import[] = "__import__"; -static const char __pyx_k_out_arry[] = "out_arry"; -static const char __pyx_k_win_size[] = "win_size"; -static const char __pyx_k_ImportError[] = "ImportError"; -static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; -static const char __pyx_k_Project___init___py_File_lee_fi[] = "\n@Project:__init__.py\n@File:lee_filter.py\n@Function:lee_filter\n@Contact: https://github.com/PyRadar/pyradar\n@Author:SHJ\n@Date:2021/8/30 8:42\n@Version:1.0.0\n"; -static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import"; -static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import"; -static PyObject *__pyx_n_s_ImportError; -static PyObject *__pyx_n_s_cline_in_traceback; -static PyObject *__pyx_n_s_img; -static PyObject *__pyx_n_s_import; -static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_mean; -static PyObject *__pyx_n_s_name; -static PyObject *__pyx_n_s_np; -static PyObject *__pyx_n_s_numpy; -static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to; -static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor; -static PyObject *__pyx_n_s_os; -static PyObject *__pyx_n_s_out_arry; -static PyObject *__pyx_n_s_round; -static PyObject *__pyx_n_s_std; -static PyObject *__pyx_n_s_test; -static PyObject *__pyx_n_s_win_size; -static PyObject *__pyx_pf_12lee_Filter_c_lee_filter_array(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_img, PyArrayObject *__pyx_v_out_arry, int __pyx_v_win_size); /* proto */ -static PyObject *__pyx_float_100000_0; -static PyObject *__pyx_int_0; -static PyObject *__pyx_tuple_; -static PyObject *__pyx_tuple__2; -/* Late includes */ - -/* "lee_Filter_c.pyx":40 - * - * - * cdef int ceil_usr(double v): # <<<<<<<<<<<<<< - * return int(math_ceil(v)) - * - */ - -static int __pyx_f_12lee_Filter_c_ceil_usr(double __pyx_v_v) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("ceil_usr", 0); - - /* "lee_Filter_c.pyx":41 - * - * cdef int ceil_usr(double v): - * return int(math_ceil(v)) # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = ((int)ceil(__pyx_v_v)); - goto __pyx_L0; - - /* "lee_Filter_c.pyx":40 - * - * - * cdef int ceil_usr(double v): # <<<<<<<<<<<<<< - * return int(math_ceil(v)) - * - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "lee_Filter_c.pyx":45 - * - * - * cdef double weighting(np.ndarray[double,ndim=2] window,double cu): # <<<<<<<<<<<<<< - * """ - * Computes the weighthing function for Lee filter using cu as the noise - */ - -static double __pyx_f_12lee_Filter_c_weighting(PyArrayObject *__pyx_v_window, double __pyx_v_cu) { - double __pyx_v_two_cu; - double __pyx_v_window_mean; - double __pyx_v_window_std; - double __pyx_v_ci; - double __pyx_v_two_ci; - double __pyx_v_w_t; - __Pyx_LocalBuf_ND __pyx_pybuffernd_window; - __Pyx_Buffer __pyx_pybuffer_window; - double __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - double __pyx_t_4; - int __pyx_t_5; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("weighting", 0); - __pyx_pybuffer_window.pybuffer.buf = NULL; - __pyx_pybuffer_window.refcount = 0; - __pyx_pybuffernd_window.data = NULL; - __pyx_pybuffernd_window.rcbuffer = &__pyx_pybuffer_window; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_window.rcbuffer->pybuffer, (PyObject*)__pyx_v_window, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 45, __pyx_L1_error) - } - __pyx_pybuffernd_window.diminfo[0].strides = __pyx_pybuffernd_window.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_window.diminfo[0].shape = __pyx_pybuffernd_window.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_window.diminfo[1].strides = __pyx_pybuffernd_window.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_window.diminfo[1].shape = __pyx_pybuffernd_window.rcbuffer->pybuffer.shape[1]; - - /* "lee_Filter_c.pyx":51 - * """ - * # cu is the noise variation coefficient - * cdef double two_cu = cu * cu # <<<<<<<<<<<<<< - * - * # ci is the variation coefficient in the window - */ - __pyx_v_two_cu = (__pyx_v_cu * __pyx_v_cu); - - /* "lee_Filter_c.pyx":54 - * - * # ci is the variation coefficient in the window - * cdef double window_mean = window.mean() # <<<<<<<<<<<<<< - * cdef double window_std = window.std() - * cdef double ci = window_std / window_mean - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_window), __pyx_n_s_mean); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 54, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 54, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_window_mean = __pyx_t_4; - - /* "lee_Filter_c.pyx":55 - * # ci is the variation coefficient in the window - * cdef double window_mean = window.mean() - * cdef double window_std = window.std() # <<<<<<<<<<<<<< - * cdef double ci = window_std / window_mean - * - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_window), __pyx_n_s_std); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_window_std = __pyx_t_4; - - /* "lee_Filter_c.pyx":56 - * cdef double window_mean = window.mean() - * cdef double window_std = window.std() - * cdef double ci = window_std / window_mean # <<<<<<<<<<<<<< - * - * cdef double two_ci = ci * ci - */ - if (unlikely(__pyx_v_window_mean == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division"); - __PYX_ERR(0, 56, __pyx_L1_error) - } - __pyx_v_ci = (__pyx_v_window_std / __pyx_v_window_mean); - - /* "lee_Filter_c.pyx":58 - * cdef double ci = window_std / window_mean - * - * cdef double two_ci = ci * ci # <<<<<<<<<<<<<< - * cdef double w_t=0; - * if not (two_ci==0): # dirty patch to avoid zero division - */ - __pyx_v_two_ci = (__pyx_v_ci * __pyx_v_ci); - - /* "lee_Filter_c.pyx":59 - * - * cdef double two_ci = ci * ci - * cdef double w_t=0; # <<<<<<<<<<<<<< - * if not (two_ci==0): # dirty patch to avoid zero division - * two_ci = COEF_VAR_DEFAULT - */ - __pyx_v_w_t = 0.0; - - /* "lee_Filter_c.pyx":60 - * cdef double two_ci = ci * ci - * cdef double w_t=0; - * if not (two_ci==0): # dirty patch to avoid zero division # <<<<<<<<<<<<<< - * two_ci = COEF_VAR_DEFAULT - * - */ - __pyx_t_5 = ((!((__pyx_v_two_ci == 0.0) != 0)) != 0); - if (__pyx_t_5) { - - /* "lee_Filter_c.pyx":61 - * cdef double w_t=0; - * if not (two_ci==0): # dirty patch to avoid zero division - * two_ci = COEF_VAR_DEFAULT # <<<<<<<<<<<<<< - * - * if cu > ci: - */ - __pyx_v_two_ci = __pyx_v_12lee_Filter_c_COEF_VAR_DEFAULT; - - /* "lee_Filter_c.pyx":60 - * cdef double two_ci = ci * ci - * cdef double w_t=0; - * if not (two_ci==0): # dirty patch to avoid zero division # <<<<<<<<<<<<<< - * two_ci = COEF_VAR_DEFAULT - * - */ - } - - /* "lee_Filter_c.pyx":63 - * two_ci = COEF_VAR_DEFAULT - * - * if cu > ci: # <<<<<<<<<<<<<< - * w_t = 0.0 - * else: - */ - __pyx_t_5 = ((__pyx_v_cu > __pyx_v_ci) != 0); - if (__pyx_t_5) { - - /* "lee_Filter_c.pyx":64 - * - * if cu > ci: - * w_t = 0.0 # <<<<<<<<<<<<<< - * else: - * w_t = 1.0 - (two_cu / two_ci) - */ - __pyx_v_w_t = 0.0; - - /* "lee_Filter_c.pyx":63 - * two_ci = COEF_VAR_DEFAULT - * - * if cu > ci: # <<<<<<<<<<<<<< - * w_t = 0.0 - * else: - */ - goto __pyx_L4; - } - - /* "lee_Filter_c.pyx":66 - * w_t = 0.0 - * else: - * w_t = 1.0 - (two_cu / two_ci) # <<<<<<<<<<<<<< - * - * return w_t - */ - /*else*/ { - if (unlikely(__pyx_v_two_ci == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division"); - __PYX_ERR(0, 66, __pyx_L1_error) - } - __pyx_v_w_t = (1.0 - (__pyx_v_two_cu / __pyx_v_two_ci)); - } - __pyx_L4:; - - /* "lee_Filter_c.pyx":68 - * w_t = 1.0 - (two_cu / two_ci) - * - * return w_t # <<<<<<<<<<<<<< - * - * cpdef np.ndarray[double,ndim=2] lee_filter_array(np.ndarray[double,ndim=2] img,np.ndarray[double,ndim=2] out_arry,int win_size): - */ - __pyx_r = __pyx_v_w_t; - goto __pyx_L0; - - /* "lee_Filter_c.pyx":45 - * - * - * cdef double weighting(np.ndarray[double,ndim=2] window,double cu): # <<<<<<<<<<<<<< - * """ - * Computes the weighthing function for Lee filter using cu as the noise - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_window.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_WriteUnraisable("lee_Filter_c.weighting", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); - __pyx_r = 0; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_window.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "lee_Filter_c.pyx":70 - * return w_t - * - * cpdef np.ndarray[double,ndim=2] lee_filter_array(np.ndarray[double,ndim=2] img,np.ndarray[double,ndim=2] out_arry,int win_size): # <<<<<<<<<<<<<< - * """ - * Apply lee to a numpy matrix containing the image, with a window of - */ - -static PyObject *__pyx_pw_12lee_Filter_c_1lee_filter_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyArrayObject *__pyx_f_12lee_Filter_c_lee_filter_array(PyArrayObject *__pyx_v_img, PyArrayObject *__pyx_v_out_arry, int __pyx_v_win_size, CYTHON_UNUSED int __pyx_skip_dispatch) { - double __pyx_v_cu; - int __pyx_v_i; - int __pyx_v_j; - int __pyx_v_xleft; - int __pyx_v_xright; - int __pyx_v_yup; - int __pyx_v_ydown; - PyArrayObject *__pyx_v_window = 0; - double __pyx_v_w_t; - double __pyx_v_window_mean; - CYTHON_UNUSED double __pyx_v_new_pix_valu; - int __pyx_v_n; - int __pyx_v_m; - int __pyx_v_win_offset; - PyObject *__pyx_v_pix_value = NULL; - PyObject *__pyx_v_new_pix_value = NULL; - __Pyx_LocalBuf_ND __pyx_pybuffernd_img; - __Pyx_Buffer __pyx_pybuffer_img; - __Pyx_LocalBuf_ND __pyx_pybuffernd_out_arry; - __Pyx_Buffer __pyx_pybuffer_out_arry; - __Pyx_LocalBuf_ND __pyx_pybuffernd_window; - __Pyx_Buffer __pyx_pybuffer_window; - PyArrayObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - Py_ssize_t __pyx_t_3; - Py_ssize_t __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - PyArrayObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - double __pyx_t_13; - int __pyx_t_14; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("lee_filter_array", 0); - __pyx_pybuffer_window.pybuffer.buf = NULL; - __pyx_pybuffer_window.refcount = 0; - __pyx_pybuffernd_window.data = NULL; - __pyx_pybuffernd_window.rcbuffer = &__pyx_pybuffer_window; - __pyx_pybuffer_img.pybuffer.buf = NULL; - __pyx_pybuffer_img.refcount = 0; - __pyx_pybuffernd_img.data = NULL; - __pyx_pybuffernd_img.rcbuffer = &__pyx_pybuffer_img; - __pyx_pybuffer_out_arry.pybuffer.buf = NULL; - __pyx_pybuffer_out_arry.refcount = 0; - __pyx_pybuffernd_out_arry.data = NULL; - __pyx_pybuffernd_out_arry.rcbuffer = &__pyx_pybuffer_out_arry; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_img.rcbuffer->pybuffer, (PyObject*)__pyx_v_img, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 70, __pyx_L1_error) - } - __pyx_pybuffernd_img.diminfo[0].strides = __pyx_pybuffernd_img.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_img.diminfo[0].shape = __pyx_pybuffernd_img.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_img.diminfo[1].strides = __pyx_pybuffernd_img.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_img.diminfo[1].shape = __pyx_pybuffernd_img.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out_arry.rcbuffer->pybuffer, (PyObject*)__pyx_v_out_arry, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 70, __pyx_L1_error) - } - __pyx_pybuffernd_out_arry.diminfo[0].strides = __pyx_pybuffernd_out_arry.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out_arry.diminfo[0].shape = __pyx_pybuffernd_out_arry.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_out_arry.diminfo[1].strides = __pyx_pybuffernd_out_arry.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_out_arry.diminfo[1].shape = __pyx_pybuffernd_out_arry.rcbuffer->pybuffer.shape[1]; - - /* "lee_Filter_c.pyx":77 - * # we process the entire img as float64 to avoid type overflow error - * #n, m = img.shape - * cdef double cu = CU_DEFAULT # <<<<<<<<<<<<<< - * cdef int i=0 - * cdef int j=0 - */ - __pyx_v_cu = __pyx_v_12lee_Filter_c_CU_DEFAULT; - - /* "lee_Filter_c.pyx":78 - * #n, m = img.shape - * cdef double cu = CU_DEFAULT - * cdef int i=0 # <<<<<<<<<<<<<< - * cdef int j=0 - * cdef int xleft=0 - */ - __pyx_v_i = 0; - - /* "lee_Filter_c.pyx":79 - * cdef double cu = CU_DEFAULT - * cdef int i=0 - * cdef int j=0 # <<<<<<<<<<<<<< - * cdef int xleft=0 - * cdef int xright=0 - */ - __pyx_v_j = 0; - - /* "lee_Filter_c.pyx":80 - * cdef int i=0 - * cdef int j=0 - * cdef int xleft=0 # <<<<<<<<<<<<<< - * cdef int xright=0 - * cdef int yup=0 - */ - __pyx_v_xleft = 0; - - /* "lee_Filter_c.pyx":81 - * cdef int j=0 - * cdef int xleft=0 - * cdef int xright=0 # <<<<<<<<<<<<<< - * cdef int yup=0 - * cdef int ydown=0 - */ - __pyx_v_xright = 0; - - /* "lee_Filter_c.pyx":82 - * cdef int xleft=0 - * cdef int xright=0 - * cdef int yup=0 # <<<<<<<<<<<<<< - * cdef int ydown=0 - * cdef np.ndarray[double,ndim=2] window; - */ - __pyx_v_yup = 0; - - /* "lee_Filter_c.pyx":83 - * cdef int xright=0 - * cdef int yup=0 - * cdef int ydown=0 # <<<<<<<<<<<<<< - * cdef np.ndarray[double,ndim=2] window; - * cdef double w_t=0; - */ - __pyx_v_ydown = 0; - - /* "lee_Filter_c.pyx":85 - * cdef int ydown=0 - * cdef np.ndarray[double,ndim=2] window; - * cdef double w_t=0; # <<<<<<<<<<<<<< - * cdef double window_mean=0; - * cdef double new_pix_valu=0; - */ - __pyx_v_w_t = 0.0; - - /* "lee_Filter_c.pyx":86 - * cdef np.ndarray[double,ndim=2] window; - * cdef double w_t=0; - * cdef double window_mean=0; # <<<<<<<<<<<<<< - * cdef double new_pix_valu=0; - * cdef int n = img.shape[0] - */ - __pyx_v_window_mean = 0.0; - - /* "lee_Filter_c.pyx":87 - * cdef double w_t=0; - * cdef double window_mean=0; - * cdef double new_pix_valu=0; # <<<<<<<<<<<<<< - * cdef int n = img.shape[0] - * cdef int m=img.shape[1] - */ - __pyx_v_new_pix_valu = 0.0; - - /* "lee_Filter_c.pyx":88 - * cdef double window_mean=0; - * cdef double new_pix_valu=0; - * cdef int n = img.shape[0] # <<<<<<<<<<<<<< - * cdef int m=img.shape[1] - * cdef int win_offset=int(win_size/2) - */ - __pyx_v_n = (__pyx_v_img->dimensions[0]); - - /* "lee_Filter_c.pyx":89 - * cdef double new_pix_valu=0; - * cdef int n = img.shape[0] - * cdef int m=img.shape[1] # <<<<<<<<<<<<<< - * cdef int win_offset=int(win_size/2) - * - */ - __pyx_v_m = (__pyx_v_img->dimensions[1]); - - /* "lee_Filter_c.pyx":90 - * cdef int n = img.shape[0] - * cdef int m=img.shape[1] - * cdef int win_offset=int(win_size/2) # <<<<<<<<<<<<<< - * - * while i= n: - */ - __pyx_t_1 = ((__pyx_v_xleft < 0) != 0); - if (__pyx_t_1) { - - /* "lee_Filter_c.pyx":96 - * xright=int(i+win_offset) - * if xleft < 0: - * xleft = 0 # <<<<<<<<<<<<<< - * if xright >= n: - * xright = n - */ - __pyx_v_xleft = 0; - - /* "lee_Filter_c.pyx":95 - * xleft=ceil_usr(i-win_offset) - * xright=int(i+win_offset) - * if xleft < 0: # <<<<<<<<<<<<<< - * xleft = 0 - * if xright >= n: - */ - } - - /* "lee_Filter_c.pyx":97 - * if xleft < 0: - * xleft = 0 - * if xright >= n: # <<<<<<<<<<<<<< - * xright = n - * j=0 - */ - __pyx_t_1 = ((__pyx_v_xright >= __pyx_v_n) != 0); - if (__pyx_t_1) { - - /* "lee_Filter_c.pyx":98 - * xleft = 0 - * if xright >= n: - * xright = n # <<<<<<<<<<<<<< - * j=0 - * while j= n: # <<<<<<<<<<<<<< - * xright = n - * j=0 - */ - } - - /* "lee_Filter_c.pyx":99 - * if xright >= n: - * xright = n - * j=0 # <<<<<<<<<<<<<< - * while j= m: - */ - __pyx_t_1 = ((__pyx_v_yup < 0) != 0); - if (__pyx_t_1) { - - /* "lee_Filter_c.pyx":105 - * ydown = int(j + win_offset) - * if yup < 0: - * yup = 0 # <<<<<<<<<<<<<< - * if ydown >= m: - * ydown = m - */ - __pyx_v_yup = 0; - - /* "lee_Filter_c.pyx":104 - * yup=0 if yup<0 else yup - * ydown = int(j + win_offset) - * if yup < 0: # <<<<<<<<<<<<<< - * yup = 0 - * if ydown >= m: - */ - } - - /* "lee_Filter_c.pyx":106 - * if yup < 0: - * yup = 0 - * if ydown >= m: # <<<<<<<<<<<<<< - * ydown = m - * - */ - __pyx_t_1 = ((__pyx_v_ydown >= __pyx_v_m) != 0); - if (__pyx_t_1) { - - /* "lee_Filter_c.pyx":107 - * yup = 0 - * if ydown >= m: - * ydown = m # <<<<<<<<<<<<<< - * - * pix_value = img[i, j] - */ - __pyx_v_ydown = __pyx_v_m; - - /* "lee_Filter_c.pyx":106 - * if yup < 0: - * yup = 0 - * if ydown >= m: # <<<<<<<<<<<<<< - * ydown = m - * - */ - } - - /* "lee_Filter_c.pyx":109 - * ydown = m - * - * pix_value = img[i, j] # <<<<<<<<<<<<<< - * - * window = img[xleft:xright+1, yup:ydown+1] - */ - __pyx_t_3 = __pyx_v_i; - __pyx_t_4 = __pyx_v_j; - __pyx_t_2 = -1; - if (__pyx_t_3 < 0) { - __pyx_t_3 += __pyx_pybuffernd_img.diminfo[0].shape; - if (unlikely(__pyx_t_3 < 0)) __pyx_t_2 = 0; - } else if (unlikely(__pyx_t_3 >= __pyx_pybuffernd_img.diminfo[0].shape)) __pyx_t_2 = 0; - if (__pyx_t_4 < 0) { - __pyx_t_4 += __pyx_pybuffernd_img.diminfo[1].shape; - if (unlikely(__pyx_t_4 < 0)) __pyx_t_2 = 1; - } else if (unlikely(__pyx_t_4 >= __pyx_pybuffernd_img.diminfo[1].shape)) __pyx_t_2 = 1; - if (unlikely(__pyx_t_2 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_2); - __PYX_ERR(0, 109, __pyx_L1_error) - } - __pyx_t_5 = PyFloat_FromDouble((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_img.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_img.diminfo[0].strides, __pyx_t_4, __pyx_pybuffernd_img.diminfo[1].strides))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_XDECREF_SET(__pyx_v_pix_value, __pyx_t_5); - __pyx_t_5 = 0; - - /* "lee_Filter_c.pyx":111 - * pix_value = img[i, j] - * - * window = img[xleft:xright+1, yup:ydown+1] # <<<<<<<<<<<<<< - * - * w_t = weighting(window, cu) - */ - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_xleft); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_xright + 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PySlice_New(__pyx_t_5, __pyx_t_6, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_yup); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyInt_From_long((__pyx_v_ydown + 1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_8 = PySlice_New(__pyx_t_6, __pyx_t_5, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_8); - __pyx_t_7 = 0; - __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_img), __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 111, __pyx_L1_error) - __pyx_t_9 = ((PyArrayObject *)__pyx_t_8); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_window.rcbuffer->pybuffer); - __pyx_t_2 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_window.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); - if (unlikely(__pyx_t_2 < 0)) { - PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_window.rcbuffer->pybuffer, (PyObject*)__pyx_v_window, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); - __Pyx_RaiseBufferFallbackError(); - } else { - PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12); - } - __pyx_t_10 = __pyx_t_11 = __pyx_t_12 = 0; - } - __pyx_pybuffernd_window.diminfo[0].strides = __pyx_pybuffernd_window.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_window.diminfo[0].shape = __pyx_pybuffernd_window.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_window.diminfo[1].strides = __pyx_pybuffernd_window.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_window.diminfo[1].shape = __pyx_pybuffernd_window.rcbuffer->pybuffer.shape[1]; - if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 111, __pyx_L1_error) - } - __pyx_t_9 = 0; - __Pyx_XDECREF_SET(__pyx_v_window, ((PyArrayObject *)__pyx_t_8)); - __pyx_t_8 = 0; - - /* "lee_Filter_c.pyx":113 - * window = img[xleft:xright+1, yup:ydown+1] - * - * w_t = weighting(window, cu) # <<<<<<<<<<<<<< - * - * window_mean = np.mean(window) - */ - __pyx_v_w_t = __pyx_f_12lee_Filter_c_weighting(((PyArrayObject *)__pyx_v_window), __pyx_v_cu); - - /* "lee_Filter_c.pyx":115 - * w_t = weighting(window, cu) - * - * window_mean = np.mean(window) # <<<<<<<<<<<<<< - * new_pix_value = (pix_value * w_t) + (window_mean * (1.0 - w_t)) - * - */ - __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_mean); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - } - } - __pyx_t_8 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_5, ((PyObject *)__pyx_v_window)) : __Pyx_PyObject_CallOneArg(__pyx_t_7, ((PyObject *)__pyx_v_window)); - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_8); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_v_window_mean = __pyx_t_13; - - /* "lee_Filter_c.pyx":116 - * - * window_mean = np.mean(window) - * new_pix_value = (pix_value * w_t) + (window_mean * (1.0 - w_t)) # <<<<<<<<<<<<<< - * - * if not new_pix_value > 0: - */ - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_w_t); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyNumber_Multiply(__pyx_v_pix_value, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyFloat_FromDouble((__pyx_v_window_mean * (1.0 - __pyx_v_w_t))); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_5 = PyNumber_Add(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_XDECREF_SET(__pyx_v_new_pix_value, __pyx_t_5); - __pyx_t_5 = 0; - - /* "lee_Filter_c.pyx":118 - * new_pix_value = (pix_value * w_t) + (window_mean * (1.0 - w_t)) - * - * if not new_pix_value > 0: # <<<<<<<<<<<<<< - * new_pix_value = 0 - * out_arry[i, j] = round(new_pix_value*100000.0)/100000.0 - */ - __pyx_t_5 = PyObject_RichCompare(__pyx_v_new_pix_value, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 118, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_14 = ((!__pyx_t_1) != 0); - if (__pyx_t_14) { - - /* "lee_Filter_c.pyx":119 - * - * if not new_pix_value > 0: - * new_pix_value = 0 # <<<<<<<<<<<<<< - * out_arry[i, j] = round(new_pix_value*100000.0)/100000.0 - * j=j+1 - */ - __Pyx_INCREF(__pyx_int_0); - __Pyx_DECREF_SET(__pyx_v_new_pix_value, __pyx_int_0); - - /* "lee_Filter_c.pyx":118 - * new_pix_value = (pix_value * w_t) + (window_mean * (1.0 - w_t)) - * - * if not new_pix_value > 0: # <<<<<<<<<<<<<< - * new_pix_value = 0 - * out_arry[i, j] = round(new_pix_value*100000.0)/100000.0 - */ - } - - /* "lee_Filter_c.pyx":120 - * if not new_pix_value > 0: - * new_pix_value = 0 - * out_arry[i, j] = round(new_pix_value*100000.0)/100000.0 # <<<<<<<<<<<<<< - * j=j+1 - * i=i+1 - */ - __pyx_t_5 = PyNumber_Multiply(__pyx_v_new_pix_value, __pyx_float_100000_0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 120, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_round, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 120, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyFloat_DivideObjC(__pyx_t_8, __pyx_float_100000_0, 100000.0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 120, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 120, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_4 = __pyx_v_i; - __pyx_t_3 = __pyx_v_j; - __pyx_t_2 = -1; - if (__pyx_t_4 < 0) { - __pyx_t_4 += __pyx_pybuffernd_out_arry.diminfo[0].shape; - if (unlikely(__pyx_t_4 < 0)) __pyx_t_2 = 0; - } else if (unlikely(__pyx_t_4 >= __pyx_pybuffernd_out_arry.diminfo[0].shape)) __pyx_t_2 = 0; - if (__pyx_t_3 < 0) { - __pyx_t_3 += __pyx_pybuffernd_out_arry.diminfo[1].shape; - if (unlikely(__pyx_t_3 < 0)) __pyx_t_2 = 1; - } else if (unlikely(__pyx_t_3 >= __pyx_pybuffernd_out_arry.diminfo[1].shape)) __pyx_t_2 = 1; - if (unlikely(__pyx_t_2 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_2); - __PYX_ERR(0, 120, __pyx_L1_error) - } - *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_out_arry.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_out_arry.diminfo[0].strides, __pyx_t_3, __pyx_pybuffernd_out_arry.diminfo[1].strides) = __pyx_t_13; - - /* "lee_Filter_c.pyx":121 - * new_pix_value = 0 - * out_arry[i, j] = round(new_pix_value*100000.0)/100000.0 - * j=j+1 # <<<<<<<<<<<<<< - * i=i+1 - * return out_arry - */ - __pyx_v_j = (__pyx_v_j + 1); - } - - /* "lee_Filter_c.pyx":122 - * out_arry[i, j] = round(new_pix_value*100000.0)/100000.0 - * j=j+1 - * i=i+1 # <<<<<<<<<<<<<< - * return out_arry - * - */ - __pyx_v_i = (__pyx_v_i + 1); - } - - /* "lee_Filter_c.pyx":123 - * j=j+1 - * i=i+1 - * return out_arry # <<<<<<<<<<<<<< - * - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_out_arry)); - __pyx_r = ((PyArrayObject *)__pyx_v_out_arry); - goto __pyx_L0; - - /* "lee_Filter_c.pyx":70 - * return w_t - * - * cpdef np.ndarray[double,ndim=2] lee_filter_array(np.ndarray[double,ndim=2] img,np.ndarray[double,ndim=2] out_arry,int win_size): # <<<<<<<<<<<<<< - * """ - * Apply lee to a numpy matrix containing the image, with a window of - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out_arry.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_window.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("lee_Filter_c.lee_filter_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out_arry.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_window.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_window); - __Pyx_XDECREF(__pyx_v_pix_value); - __Pyx_XDECREF(__pyx_v_new_pix_value); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_12lee_Filter_c_1lee_filter_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_12lee_Filter_c_lee_filter_array[] = "\n Apply lee to a numpy matrix containing the image, with a window of\n win_size x win_size.\n "; -static PyObject *__pyx_pw_12lee_Filter_c_1lee_filter_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_img = 0; - PyArrayObject *__pyx_v_out_arry = 0; - int __pyx_v_win_size; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("lee_filter_array (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_img,&__pyx_n_s_out_arry,&__pyx_n_s_win_size,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_img)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out_arry)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("lee_filter_array", 1, 3, 3, 1); __PYX_ERR(0, 70, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_win_size)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("lee_filter_array", 1, 3, 3, 2); __PYX_ERR(0, 70, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lee_filter_array") < 0)) __PYX_ERR(0, 70, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_img = ((PyArrayObject *)values[0]); - __pyx_v_out_arry = ((PyArrayObject *)values[1]); - __pyx_v_win_size = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_win_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 70, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("lee_filter_array", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 70, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("lee_Filter_c.lee_filter_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_img), __pyx_ptype_5numpy_ndarray, 1, "img", 0))) __PYX_ERR(0, 70, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_arry), __pyx_ptype_5numpy_ndarray, 1, "out_arry", 0))) __PYX_ERR(0, 70, __pyx_L1_error) - __pyx_r = __pyx_pf_12lee_Filter_c_lee_filter_array(__pyx_self, __pyx_v_img, __pyx_v_out_arry, __pyx_v_win_size); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_12lee_Filter_c_lee_filter_array(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_img, PyArrayObject *__pyx_v_out_arry, int __pyx_v_win_size) { - __Pyx_LocalBuf_ND __pyx_pybuffernd_img; - __Pyx_Buffer __pyx_pybuffer_img; - __Pyx_LocalBuf_ND __pyx_pybuffernd_out_arry; - __Pyx_Buffer __pyx_pybuffer_out_arry; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("lee_filter_array", 0); - __pyx_pybuffer_img.pybuffer.buf = NULL; - __pyx_pybuffer_img.refcount = 0; - __pyx_pybuffernd_img.data = NULL; - __pyx_pybuffernd_img.rcbuffer = &__pyx_pybuffer_img; - __pyx_pybuffer_out_arry.pybuffer.buf = NULL; - __pyx_pybuffer_out_arry.refcount = 0; - __pyx_pybuffernd_out_arry.data = NULL; - __pyx_pybuffernd_out_arry.rcbuffer = &__pyx_pybuffer_out_arry; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_img.rcbuffer->pybuffer, (PyObject*)__pyx_v_img, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 70, __pyx_L1_error) - } - __pyx_pybuffernd_img.diminfo[0].strides = __pyx_pybuffernd_img.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_img.diminfo[0].shape = __pyx_pybuffernd_img.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_img.diminfo[1].strides = __pyx_pybuffernd_img.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_img.diminfo[1].shape = __pyx_pybuffernd_img.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_out_arry.rcbuffer->pybuffer, (PyObject*)__pyx_v_out_arry, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 70, __pyx_L1_error) - } - __pyx_pybuffernd_out_arry.diminfo[0].strides = __pyx_pybuffernd_out_arry.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out_arry.diminfo[0].shape = __pyx_pybuffernd_out_arry.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_out_arry.diminfo[1].strides = __pyx_pybuffernd_out_arry.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_out_arry.diminfo[1].shape = __pyx_pybuffernd_out_arry.rcbuffer->pybuffer.shape[1]; - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)__pyx_f_12lee_Filter_c_lee_filter_array(__pyx_v_img, __pyx_v_out_arry, __pyx_v_win_size, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out_arry.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("lee_Filter_c.lee_filter_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_out_arry.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":735 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":736 - * - * cdef inline object PyArray_MultiIterNew1(a): - * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew2(a, b): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 736, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":735 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":738 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":739 - * - * cdef inline object PyArray_MultiIterNew2(a, b): - * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 739, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":738 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":741 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":742 - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 742, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":741 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":744 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":745 - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 745, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":744 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":747 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":748 - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 748, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":747 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":750 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":751 - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< - * return d.subarray.shape - * else: - */ - __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); - if (__pyx_t_1) { - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":752 - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape # <<<<<<<<<<<<<< - * else: - * return () - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape)); - __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":751 - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< - * return d.subarray.shape - * else: - */ - } - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":754 - * return d.subarray.shape - * else: - * return () # <<<<<<<<<<<<<< - * - * - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_empty_tuple); - __pyx_r = __pyx_empty_tuple; - goto __pyx_L0; - } - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":750 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":931 - * int _import_umath() except -1 - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) - */ - -static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_array_base", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":932 - * - * cdef inline void set_array_base(ndarray arr, object base): - * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< - * PyArray_SetBaseObject(arr, base) - * - */ - Py_INCREF(__pyx_v_base); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":933 - * cdef inline void set_array_base(ndarray arr, object base): - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< - * - * cdef inline object get_array_base(ndarray arr): - */ - (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":931 - * int _import_umath() except -1 - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":935 - * PyArray_SetBaseObject(arr, base) - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * base = PyArray_BASE(arr) - * if base is NULL: - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { - PyObject *__pyx_v_base; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("get_array_base", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":936 - * - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< - * if base is NULL: - * return None - */ - __pyx_v_base = PyArray_BASE(__pyx_v_arr); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":937 - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) - * if base is NULL: # <<<<<<<<<<<<<< - * return None - * return base - */ - __pyx_t_1 = ((__pyx_v_base == NULL) != 0); - if (__pyx_t_1) { - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":938 - * base = PyArray_BASE(arr) - * if base is NULL: - * return None # <<<<<<<<<<<<<< - * return base - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":937 - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) - * if base is NULL: # <<<<<<<<<<<<<< - * return None - * return base - */ - } - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":939 - * if base is NULL: - * return None - * return base # <<<<<<<<<<<<<< - * - * # Versions of the import_* functions which are more suitable for - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_base)); - __pyx_r = ((PyObject *)__pyx_v_base); - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":935 - * PyArray_SetBaseObject(arr, base) - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * base = PyArray_BASE(arr) - * if base is NULL: - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":943 - * # Versions of the import_* functions which are more suitable for - * # Cython code. - * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< - * try: - * __pyx_import_array() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_array", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":945 - * cdef inline int import_array() except -1: - * try: - * __pyx_import_array() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") - */ - __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 945, __pyx_L3_error) - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":946 - * try: - * __pyx_import_array() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.multiarray failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 946, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":947 - * __pyx_import_array() - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_umath() except -1: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 947, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 947, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":943 - * # Versions of the import_* functions which are more suitable for - * # Cython code. - * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< - * try: - * __pyx_import_array() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":949 - * raise ImportError("numpy.core.multiarray failed to import") - * - * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_umath", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":951 - * cdef inline int import_umath() except -1: - * try: - * _import_umath() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.umath failed to import") - */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 951, __pyx_L3_error) - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":952 - * try: - * _import_umath() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.umath failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 952, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":953 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_ufunc() except -1: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 953, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 953, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":949 - * raise ImportError("numpy.core.multiarray failed to import") - * - * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":955 - * raise ImportError("numpy.core.umath failed to import") - * - * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_ufunc", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":957 - * cdef inline int import_ufunc() except -1: - * try: - * _import_umath() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.umath failed to import") - */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 957, __pyx_L3_error) - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":958 - * try: - * _import_umath() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.umath failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 958, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":959 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef extern from *: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 959, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 959, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":955 - * raise ImportError("numpy.core.umath failed to import") - * - * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":969 - * - * - * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.timedelta64)` - */ - -static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_obj) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_timedelta64_object", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":981 - * bool - * """ - * return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type) # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyTimedeltaArrType_Type)); - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":969 - * - * - * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.timedelta64)` - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":984 - * - * - * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.datetime64)` - */ - -static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_obj) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_datetime64_object", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":996 - * bool - * """ - * return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type) # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyDatetimeArrType_Type)); - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":984 - * - * - * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.datetime64)` - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":999 - * - * - * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy datetime64 object - */ - -static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject *__pyx_v_obj) { - npy_datetime __pyx_r; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1006 - * also needed. That can be found using `get_datetime64_unit`. - * """ - * return (obj).obval # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = ((PyDatetimeScalarObject *)__pyx_v_obj)->obval; - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":999 - * - * - * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy datetime64 object - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1009 - * - * - * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy timedelta64 object - */ - -static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject *__pyx_v_obj) { - npy_timedelta __pyx_r; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1013 - * returns the int64 value underlying scalar numpy timedelta64 object - * """ - * return (obj).obval # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = ((PyTimedeltaScalarObject *)__pyx_v_obj)->obval; - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1009 - * - * - * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy timedelta64 object - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - -static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObject *__pyx_v_obj) { - NPY_DATETIMEUNIT __pyx_r; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1020 - * returns the unit part of the dtype for a numpy datetime64 object. - * """ - * return (obj).obmeta.base # <<<<<<<<<<<<<< - */ - __pyx_r = ((NPY_DATETIMEUNIT)((PyDatetimeScalarObject *)__pyx_v_obj)->obmeta.base); - goto __pyx_L0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -static PyMethodDef __pyx_methods[] = { - {"lee_filter_array", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_12lee_Filter_c_1lee_filter_array, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12lee_Filter_c_lee_filter_array}, - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -#if CYTHON_PEP489_MULTI_PHASE_INIT -static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ -static int __pyx_pymod_exec_lee_Filter_c(PyObject* module); /*proto*/ -static PyModuleDef_Slot __pyx_moduledef_slots[] = { - {Py_mod_create, (void*)__pyx_pymod_create}, - {Py_mod_exec, (void*)__pyx_pymod_exec_lee_Filter_c}, - {0, NULL} -}; -#endif - -static struct PyModuleDef __pyx_moduledef = { - PyModuleDef_HEAD_INIT, - "lee_Filter_c", - __pyx_k_Project___init___py_File_lee_fi, /* m_doc */ - #if CYTHON_PEP489_MULTI_PHASE_INIT - 0, /* m_size */ - #else - -1, /* m_size */ - #endif - __pyx_methods /* m_methods */, - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_moduledef_slots, /* m_slots */ - #else - NULL, /* m_reload */ - #endif - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif -#ifndef CYTHON_SMALL_CODE -#if defined(__clang__) - #define CYTHON_SMALL_CODE -#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) - #define CYTHON_SMALL_CODE __attribute__((cold)) -#else - #define CYTHON_SMALL_CODE -#endif -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, - {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, - {&__pyx_n_s_img, __pyx_k_img, sizeof(__pyx_k_img), 0, 0, 1, 1}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_mean, __pyx_k_mean, sizeof(__pyx_k_mean), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, - {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, - {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0}, - {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0}, - {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1}, - {&__pyx_n_s_out_arry, __pyx_k_out_arry, sizeof(__pyx_k_out_arry), 0, 0, 1, 1}, - {&__pyx_n_s_round, __pyx_k_round, sizeof(__pyx_k_round), 0, 0, 1, 1}, - {&__pyx_n_s_std, __pyx_k_std, sizeof(__pyx_k_std), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_win_size, __pyx_k_win_size, sizeof(__pyx_k_win_size), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_round = __Pyx_GetBuiltinName(__pyx_n_s_round); if (!__pyx_builtin_round) __PYX_ERR(0, 120, __pyx_L1_error) - __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 947, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":947 - * __pyx_import_array() - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_umath() except -1: - */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 947, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":953 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_ufunc() except -1: - */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 953, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__2); - __Pyx_GIVEREF(__pyx_tuple__2); - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - __pyx_float_100000_0 = PyFloat_FromDouble(100000.0); if (unlikely(!__pyx_float_100000_0)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ - -static int __Pyx_modinit_global_init_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); - /*--- Global init code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_variable_export_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); - /*--- Variable export code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_function_export_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); - /*--- Function export code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_type_init_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); - /*--- Type init code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_type_import_code(void) { - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); - /*--- Type import code ---*/ - __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", - #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 - sizeof(PyTypeObject), - #else - sizeof(PyHeapTypeObject), - #endif - __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 200, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 200, __pyx_L1_error) - __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 223, __pyx_L1_error) - __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 227, __pyx_L1_error) - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 239, __pyx_L1_error) - __pyx_ptype_5numpy_generic = __Pyx_ImportType(__pyx_t_1, "numpy", "generic", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_generic) __PYX_ERR(1, 771, __pyx_L1_error) - __pyx_ptype_5numpy_number = __Pyx_ImportType(__pyx_t_1, "numpy", "number", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_number) __PYX_ERR(1, 773, __pyx_L1_error) - __pyx_ptype_5numpy_integer = __Pyx_ImportType(__pyx_t_1, "numpy", "integer", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_integer) __PYX_ERR(1, 775, __pyx_L1_error) - __pyx_ptype_5numpy_signedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "signedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_signedinteger) __PYX_ERR(1, 777, __pyx_L1_error) - __pyx_ptype_5numpy_unsignedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "unsignedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_unsignedinteger) __PYX_ERR(1, 779, __pyx_L1_error) - __pyx_ptype_5numpy_inexact = __Pyx_ImportType(__pyx_t_1, "numpy", "inexact", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_inexact) __PYX_ERR(1, 781, __pyx_L1_error) - __pyx_ptype_5numpy_floating = __Pyx_ImportType(__pyx_t_1, "numpy", "floating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_floating) __PYX_ERR(1, 783, __pyx_L1_error) - __pyx_ptype_5numpy_complexfloating = __Pyx_ImportType(__pyx_t_1, "numpy", "complexfloating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_complexfloating) __PYX_ERR(1, 785, __pyx_L1_error) - __pyx_ptype_5numpy_flexible = __Pyx_ImportType(__pyx_t_1, "numpy", "flexible", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_flexible) __PYX_ERR(1, 787, __pyx_L1_error) - __pyx_ptype_5numpy_character = __Pyx_ImportType(__pyx_t_1, "numpy", "character", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_character) __PYX_ERR(1, 789, __pyx_L1_error) - __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 827, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_modinit_variable_import_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); - /*--- Variable import code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_function_import_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); - /*--- Function import code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - - -#ifndef CYTHON_NO_PYINIT_EXPORT -#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC -#elif PY_MAJOR_VERSION < 3 -#ifdef __cplusplus -#define __Pyx_PyMODINIT_FUNC extern "C" void -#else -#define __Pyx_PyMODINIT_FUNC void -#endif -#else -#ifdef __cplusplus -#define __Pyx_PyMODINIT_FUNC extern "C" PyObject * -#else -#define __Pyx_PyMODINIT_FUNC PyObject * -#endif -#endif - - -#if PY_MAJOR_VERSION < 3 -__Pyx_PyMODINIT_FUNC initlee_Filter_c(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC initlee_Filter_c(void) -#else -__Pyx_PyMODINIT_FUNC PyInit_lee_Filter_c(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC PyInit_lee_Filter_c(void) -#if CYTHON_PEP489_MULTI_PHASE_INIT -{ - return PyModuleDef_Init(&__pyx_moduledef); -} -static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { - #if PY_VERSION_HEX >= 0x030700A1 - static PY_INT64_T main_interpreter_id = -1; - PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); - if (main_interpreter_id == -1) { - main_interpreter_id = current_id; - return (unlikely(current_id == -1)) ? -1 : 0; - } else if (unlikely(main_interpreter_id != current_id)) - #else - static PyInterpreterState *main_interpreter = NULL; - PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; - if (!main_interpreter) { - main_interpreter = current_interpreter; - } else if (unlikely(main_interpreter != current_interpreter)) - #endif - { - PyErr_SetString( - PyExc_ImportError, - "Interpreter change detected - this module can only be loaded into one interpreter per process."); - return -1; - } - return 0; -} -static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { - PyObject *value = PyObject_GetAttrString(spec, from_name); - int result = 0; - if (likely(value)) { - if (allow_none || value != Py_None) { - result = PyDict_SetItemString(moddict, to_name, value); - } - Py_DECREF(value); - } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - } else { - result = -1; - } - return result; -} -static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { - PyObject *module = NULL, *moddict, *modname; - if (__Pyx_check_single_interpreter()) - return NULL; - if (__pyx_m) - return __Pyx_NewRef(__pyx_m); - modname = PyObject_GetAttrString(spec, "name"); - if (unlikely(!modname)) goto bad; - module = PyModule_NewObject(modname); - Py_DECREF(modname); - if (unlikely(!module)) goto bad; - moddict = PyModule_GetDict(module); - if (unlikely(!moddict)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; - return module; -bad: - Py_XDECREF(module); - return NULL; -} - - -static CYTHON_SMALL_CODE int __pyx_pymod_exec_lee_Filter_c(PyObject *__pyx_pyinit_module) -#endif -#endif -{ - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannyDeclarations - #if CYTHON_PEP489_MULTI_PHASE_INIT - if (__pyx_m) { - if (__pyx_m == __pyx_pyinit_module) return 0; - PyErr_SetString(PyExc_RuntimeError, "Module 'lee_Filter_c' has already been imported. Re-initialisation is not supported."); - return -1; - } - #elif PY_MAJOR_VERSION >= 3 - if (__pyx_m) return __Pyx_NewRef(__pyx_m); - #endif - #if CYTHON_REFNANNY -__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); -if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); -} -#endif - __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_lee_Filter_c(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pxy_PyFrame_Initialize_Offsets - __Pxy_PyFrame_Initialize_Offsets(); - #endif - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_AsyncGen_USED - if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - PyEval_InitThreads(); - #endif - /*--- Module creation code ---*/ - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_m = __pyx_pyinit_module; - Py_INCREF(__pyx_m); - #else - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("lee_Filter_c", __pyx_methods, __pyx_k_Project___init___py_File_lee_fi, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_b); - __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_cython_runtime); - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main_lee_Filter_c) { - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "lee_Filter_c")) { - if (unlikely(PyDict_SetItemString(modules, "lee_Filter_c", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global type/function init code ---*/ - (void)__Pyx_modinit_global_init_code(); - (void)__Pyx_modinit_variable_export_code(); - (void)__Pyx_modinit_function_export_code(); - (void)__Pyx_modinit_type_init_code(); - if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - (void)__Pyx_modinit_variable_import_code(); - (void)__Pyx_modinit_function_import_code(); - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - - /* "lee_Filter_c.pyx":12 - * """ - * - * import os # <<<<<<<<<<<<<< - * cimport cython # - * import numpy as np##cpythonnp - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "lee_Filter_c.pyx":14 - * import os - * cimport cython # - * import numpy as np##cpythonnp # <<<<<<<<<<<<<< - * cimport numpy as np # cpythonnp - * from libc.math cimport pi - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "lee_Filter_c.pyx":36 - * from libc.math cimport lround as math_round - * - * cdef double COEF_VAR_DEFAULT = 0.01 # <<<<<<<<<<<<<< - * cdef double CU_DEFAULT = 0.25 - * - */ - __pyx_v_12lee_Filter_c_COEF_VAR_DEFAULT = 0.01; - - /* "lee_Filter_c.pyx":37 - * - * cdef double COEF_VAR_DEFAULT = 0.01 - * cdef double CU_DEFAULT = 0.25 # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_12lee_Filter_c_CU_DEFAULT = 0.25; - - /* "lee_Filter_c.pyx":1 - * # -*- coding: UTF-8 -*- # <<<<<<<<<<<<<< - * """ - * @Project:__init__.py - */ - __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "../../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init lee_Filter_c", __pyx_clineno, __pyx_lineno, __pyx_filename); - } - Py_CLEAR(__pyx_m); - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init lee_Filter_c"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if CYTHON_PEP489_MULTI_PHASE_INIT - return (__pyx_m != NULL) ? 0 : -1; - #elif PY_MAJOR_VERSION >= 3 - return __pyx_m; - #else - return; - #endif -} - -/* --- Runtime support code --- */ -/* Refnanny */ -#if CYTHON_REFNANNY -static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule(modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, "RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif - -/* PyObjectGetAttrStr */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#endif - -/* GetBuiltinName */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -/* IsLittleEndian */ -static CYTHON_INLINE int __Pyx_Is_Little_Endian(void) -{ - union { - uint32_t u32; - uint8_t u8[4]; - } S; - S.u32 = 0x01020304; - return S.u8[0] == 4; -} - -/* BufferFormatCheck */ -static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type) { - stack[0].field = &ctx->root; - stack[0].parent_offset = 0; - ctx->root.type = type; - ctx->root.name = "buffer dtype"; - ctx->root.offset = 0; - ctx->head = stack; - ctx->head->field = &ctx->root; - ctx->fmt_offset = 0; - ctx->head->parent_offset = 0; - ctx->new_packmode = '@'; - ctx->enc_packmode = '@'; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->is_complex = 0; - ctx->is_valid_array = 0; - ctx->struct_alignment = 0; - while (type->typegroup == 'S') { - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = 0; - type = type->fields->type; - } -} -static int __Pyx_BufFmt_ParseNumber(const char** ts) { - int count; - const char* t = *ts; - if (*t < '0' || *t > '9') { - return -1; - } else { - count = *t++ - '0'; - while (*t >= '0' && *t <= '9') { - count *= 10; - count += *t++ - '0'; - } - } - *ts = t; - return count; -} -static int __Pyx_BufFmt_ExpectNumber(const char **ts) { - int number = __Pyx_BufFmt_ParseNumber(ts); - if (number == -1) - PyErr_Format(PyExc_ValueError,\ - "Does not understand character buffer dtype format string ('%c')", **ts); - return number; -} -static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { - PyErr_Format(PyExc_ValueError, - "Unexpected format string character: '%c'", ch); -} -static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { - switch (ch) { - case '?': return "'bool'"; - case 'c': return "'char'"; - case 'b': return "'signed char'"; - case 'B': return "'unsigned char'"; - case 'h': return "'short'"; - case 'H': return "'unsigned short'"; - case 'i': return "'int'"; - case 'I': return "'unsigned int'"; - case 'l': return "'long'"; - case 'L': return "'unsigned long'"; - case 'q': return "'long long'"; - case 'Q': return "'unsigned long long'"; - case 'f': return (is_complex ? "'complex float'" : "'float'"); - case 'd': return (is_complex ? "'complex double'" : "'double'"); - case 'g': return (is_complex ? "'complex long double'" : "'long double'"); - case 'T': return "a struct"; - case 'O': return "Python object"; - case 'P': return "a pointer"; - case 's': case 'p': return "a string"; - case 0: return "end"; - default: return "unparseable format string"; - } -} -static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return 2; - case 'i': case 'I': case 'l': case 'L': return 4; - case 'q': case 'Q': return 8; - case 'f': return (is_complex ? 8 : 4); - case 'd': return (is_complex ? 16 : 8); - case 'g': { - PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); - return 0; - } - case 'O': case 'P': return sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(short); - case 'i': case 'I': return sizeof(int); - case 'l': case 'L': return sizeof(long); - #ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(PY_LONG_LONG); - #endif - case 'f': return sizeof(float) * (is_complex ? 2 : 1); - case 'd': return sizeof(double) * (is_complex ? 2 : 1); - case 'g': return sizeof(long double) * (is_complex ? 2 : 1); - case 'O': case 'P': return sizeof(void*); - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } - } -} -typedef struct { char c; short x; } __Pyx_st_short; -typedef struct { char c; int x; } __Pyx_st_int; -typedef struct { char c; long x; } __Pyx_st_long; -typedef struct { char c; float x; } __Pyx_st_float; -typedef struct { char c; double x; } __Pyx_st_double; -typedef struct { char c; long double x; } __Pyx_st_longdouble; -typedef struct { char c; void *x; } __Pyx_st_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_st_float) - sizeof(float); - case 'd': return sizeof(__Pyx_st_double) - sizeof(double); - case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -/* These are for computing the padding at the end of the struct to align - on the first member of the struct. This will probably the same as above, - but we don't have any guarantees. - */ -typedef struct { short x; char c; } __Pyx_pad_short; -typedef struct { int x; char c; } __Pyx_pad_int; -typedef struct { long x; char c; } __Pyx_pad_long; -typedef struct { float x; char c; } __Pyx_pad_float; -typedef struct { double x; char c; } __Pyx_pad_double; -typedef struct { long double x; char c; } __Pyx_pad_longdouble; -typedef struct { void *x; char c; } __Pyx_pad_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); - case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); - case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { - switch (ch) { - case 'c': - return 'H'; - case 'b': case 'h': case 'i': - case 'l': case 'q': case 's': case 'p': - return 'I'; - case '?': case 'B': case 'H': case 'I': case 'L': case 'Q': - return 'U'; - case 'f': case 'd': case 'g': - return (is_complex ? 'C' : 'R'); - case 'O': - return 'O'; - case 'P': - return 'P'; - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } - } -} -static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { - if (ctx->head == NULL || ctx->head->field == &ctx->root) { - const char* expected; - const char* quote; - if (ctx->head == NULL) { - expected = "end"; - quote = ""; - } else { - expected = ctx->head->field->type->name; - quote = "'"; - } - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected %s%s%s but got %s", - quote, expected, quote, - __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); - } else { - __Pyx_StructField* field = ctx->head->field; - __Pyx_StructField* parent = (ctx->head - 1)->field; - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", - field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), - parent->type->name, field->name); - } -} -static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { - char group; - size_t size, offset, arraysize = 1; - if (ctx->enc_type == 0) return 0; - if (ctx->head->field->type->arraysize[0]) { - int i, ndim = 0; - if (ctx->enc_type == 's' || ctx->enc_type == 'p') { - ctx->is_valid_array = ctx->head->field->type->ndim == 1; - ndim = 1; - if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { - PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %zu", - ctx->head->field->type->arraysize[0], ctx->enc_count); - return -1; - } - } - if (!ctx->is_valid_array) { - PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", - ctx->head->field->type->ndim, ndim); - return -1; - } - for (i = 0; i < ctx->head->field->type->ndim; i++) { - arraysize *= ctx->head->field->type->arraysize[i]; - } - ctx->is_valid_array = 0; - ctx->enc_count = 1; - } - group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); - do { - __Pyx_StructField* field = ctx->head->field; - __Pyx_TypeInfo* type = field->type; - if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { - size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); - } else { - size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); - } - if (ctx->enc_packmode == '@') { - size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); - size_t align_mod_offset; - if (align_at == 0) return -1; - align_mod_offset = ctx->fmt_offset % align_at; - if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; - if (ctx->struct_alignment == 0) - ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, - ctx->is_complex); - } - if (type->size != size || type->typegroup != group) { - if (type->typegroup == 'C' && type->fields != NULL) { - size_t parent_offset = ctx->head->parent_offset + field->offset; - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = parent_offset; - continue; - } - if ((type->typegroup == 'H' || group == 'H') && type->size == size) { - } else { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; - } - } - offset = ctx->head->parent_offset + field->offset; - if (ctx->fmt_offset != offset) { - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", - (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); - return -1; - } - ctx->fmt_offset += size; - if (arraysize) - ctx->fmt_offset += (arraysize - 1) * size; - --ctx->enc_count; - while (1) { - if (field == &ctx->root) { - ctx->head = NULL; - if (ctx->enc_count != 0) { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; - } - break; - } - ctx->head->field = ++field; - if (field->type == NULL) { - --ctx->head; - field = ctx->head->field; - continue; - } else if (field->type->typegroup == 'S') { - size_t parent_offset = ctx->head->parent_offset + field->offset; - if (field->type->fields->type == NULL) continue; - field = field->type->fields; - ++ctx->head; - ctx->head->field = field; - ctx->head->parent_offset = parent_offset; - break; - } else { - break; - } - } - } while (ctx->enc_count); - ctx->enc_type = 0; - ctx->is_complex = 0; - return 0; -} -static PyObject * -__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) -{ - const char *ts = *tsp; - int i = 0, number, ndim; - ++ts; - if (ctx->new_count != 1) { - PyErr_SetString(PyExc_ValueError, - "Cannot handle repeated arrays in format string"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ndim = ctx->head->field->type->ndim; - while (*ts && *ts != ')') { - switch (*ts) { - case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; - default: break; - } - number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) - return PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %d", - ctx->head->field->type->arraysize[i], number); - if (*ts != ',' && *ts != ')') - return PyErr_Format(PyExc_ValueError, - "Expected a comma in format string, got '%c'", *ts); - if (*ts == ',') ts++; - i++; - } - if (i != ndim) - return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", - ctx->head->field->type->ndim, i); - if (!*ts) { - PyErr_SetString(PyExc_ValueError, - "Unexpected end of format string, expected ')'"); - return NULL; - } - ctx->is_valid_array = 1; - ctx->new_count = 1; - *tsp = ++ts; - return Py_None; -} -static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { - int got_Z = 0; - while (1) { - switch(*ts) { - case 0: - if (ctx->enc_type != 0 && ctx->head == NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - if (ctx->head != NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - return ts; - case ' ': - case '\r': - case '\n': - ++ts; - break; - case '<': - if (!__Pyx_Is_Little_Endian()) { - PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '>': - case '!': - if (__Pyx_Is_Little_Endian()) { - PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '=': - case '@': - case '^': - ctx->new_packmode = *ts++; - break; - case 'T': - { - const char* ts_after_sub; - size_t i, struct_count = ctx->new_count; - size_t struct_alignment = ctx->struct_alignment; - ctx->new_count = 1; - ++ts; - if (*ts != '{') { - PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - ctx->enc_count = 0; - ctx->struct_alignment = 0; - ++ts; - ts_after_sub = ts; - for (i = 0; i != struct_count; ++i) { - ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); - if (!ts_after_sub) return NULL; - } - ts = ts_after_sub; - if (struct_alignment) ctx->struct_alignment = struct_alignment; - } - break; - case '}': - { - size_t alignment = ctx->struct_alignment; - ++ts; - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - if (alignment && ctx->fmt_offset % alignment) { - ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); - } - } - return ts; - case 'x': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->fmt_offset += ctx->new_count; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->enc_packmode = ctx->new_packmode; - ++ts; - break; - case 'Z': - got_Z = 1; - ++ts; - if (*ts != 'f' && *ts != 'd' && *ts != 'g') { - __Pyx_BufFmt_RaiseUnexpectedChar('Z'); - return NULL; - } - CYTHON_FALLTHROUGH; - case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': - case 'l': case 'L': case 'q': case 'Q': - case 'f': case 'd': case 'g': - case 'O': case 'p': - if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) && - (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) { - ctx->enc_count += ctx->new_count; - ctx->new_count = 1; - got_Z = 0; - ++ts; - break; - } - CYTHON_FALLTHROUGH; - case 's': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_count = ctx->new_count; - ctx->enc_packmode = ctx->new_packmode; - ctx->enc_type = *ts; - ctx->is_complex = got_Z; - ++ts; - ctx->new_count = 1; - got_Z = 0; - break; - case ':': - ++ts; - while(*ts != ':') ++ts; - ++ts; - break; - case '(': - if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; - break; - default: - { - int number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - ctx->new_count = (size_t)number; - } - } - } -} - -/* BufferGetAndValidate */ - static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { - if (unlikely(info->buf == NULL)) return; - if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; - __Pyx_ReleaseBuffer(info); -} -static void __Pyx_ZeroBuffer(Py_buffer* buf) { - buf->buf = NULL; - buf->obj = NULL; - buf->strides = __Pyx_zeros; - buf->shape = __Pyx_zeros; - buf->suboffsets = __Pyx_minusones; -} -static int __Pyx__GetBufferAndValidate( - Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, - int nd, int cast, __Pyx_BufFmt_StackElem* stack) -{ - buf->buf = NULL; - if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) { - __Pyx_ZeroBuffer(buf); - return -1; - } - if (unlikely(buf->ndim != nd)) { - PyErr_Format(PyExc_ValueError, - "Buffer has wrong number of dimensions (expected %d, got %d)", - nd, buf->ndim); - goto fail; - } - if (!cast) { - __Pyx_BufFmt_Context ctx; - __Pyx_BufFmt_Init(&ctx, stack, dtype); - if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; - } - if (unlikely((size_t)buf->itemsize != dtype->size)) { - PyErr_Format(PyExc_ValueError, - "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", - buf->itemsize, (buf->itemsize > 1) ? "s" : "", - dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); - goto fail; - } - if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; - return 0; -fail:; - __Pyx_SafeReleaseBuffer(buf); - return -1; -} - -/* PyFunctionFastCall */ - #if CYTHON_FAST_PYCALL -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = __Pyx_PyFrame_GetLocalsplus(f); - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif -#endif - -/* PyObjectCall */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = Py_TYPE(func)->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = (*call)(func, arg, kw); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallMethO */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { - PyObject *self, *result; - PyCFunction cfunc; - cfunc = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = cfunc(self, arg); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallNoArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, NULL, 0); - } -#endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) -#else - if (likely(PyCFunction_Check(func))) -#endif - { - if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { - return __Pyx_PyObject_CallMethO(func, NULL); - } - } - return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); -} -#endif - -/* PyCFunctionFastCall */ - #if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); - } else { - return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); - } -} -#endif - -/* PyObjectCallOneArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif - if (likely(PyCFunction_Check(func))) { - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (__Pyx_PyFastCFunction_Check(func)) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - -/* PyErrFetchRestore */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -} -#endif - -/* WriteUnraisableException */ - static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, - CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, - int full_traceback, CYTHON_UNUSED int nogil) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - __Pyx_PyThreadState_declare -#ifdef WITH_THREAD - PyGILState_STATE state; - if (nogil) - state = PyGILState_Ensure(); -#ifdef _MSC_VER - else state = (PyGILState_STATE)-1; -#endif -#endif - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); - if (full_traceback) { - Py_XINCREF(old_exc); - Py_XINCREF(old_val); - Py_XINCREF(old_tb); - __Pyx_ErrRestore(old_exc, old_val, old_tb); - PyErr_PrintEx(1); - } - #if PY_MAJOR_VERSION < 3 - ctx = PyString_FromString(name); - #else - ctx = PyUnicode_FromString(name); - #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } -#ifdef WITH_THREAD - if (nogil) - PyGILState_Release(state); -#endif -} - -/* None */ - static CYTHON_INLINE long __Pyx_div_long(long a, long b) { - long q = a / b; - long r = a - q*b; - q -= ((r != 0) & ((r ^ b) < 0)); - return q; -} - -/* BufferIndexError */ - static void __Pyx_RaiseBufferIndexError(int axis) { - PyErr_Format(PyExc_IndexError, - "Out of bounds on buffer access (axis %d)", axis); -} - -/* GetItemInt */ - static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!j) return NULL; - r = PyObject_GetItem(o, j); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyList_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyTuple_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* ObjectGetItem */ - #if CYTHON_USE_TYPE_SLOTS -static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { - PyObject *runerr; - Py_ssize_t key_value; - PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; - if (unlikely(!(m && m->sq_item))) { - PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); - return NULL; - } - key_value = __Pyx_PyIndex_AsSsize_t(index); - if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { - return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); - } - if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { - PyErr_Clear(); - PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); - } - return NULL; -} -static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { - PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; - if (likely(m && m->mp_subscript)) { - return m->mp_subscript(obj, key); - } - return __Pyx_PyObject_GetIndex(obj, key); -} -#endif - -/* ExtTypeTest */ - static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (likely(__Pyx_TypeCheck(obj, type))) - return 1; - PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", - Py_TYPE(obj)->tp_name, type->tp_name); - return 0; -} - -/* BufferFallbackError */ - static void __Pyx_RaiseBufferFallbackError(void) { - PyErr_SetString(PyExc_ValueError, - "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); -} - -/* PyDictVersioning */ - #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; -} -static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { - PyObject **dictptr = NULL; - Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; - if (offset) { -#if CYTHON_COMPILING_IN_CPYTHON - dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); -#else - dictptr = _PyObject_GetDictPtr(obj); -#endif - } - return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; -} -static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) - return 0; - return obj_dict_version == __Pyx_get_object_dict_version(obj); -} -#endif - -/* GetModuleGlobalName */ - #if CYTHON_USE_DICT_VERSIONS -static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) -#else -static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) -#endif -{ - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 - result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } else if (unlikely(PyErr_Occurred())) { - return NULL; - } -#else - result = PyDict_GetItem(__pyx_d, name); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } -#endif -#else - result = PyObject_GetItem(__pyx_d, name); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } - PyErr_Clear(); -#endif - return __Pyx_GetBuiltinName(name); -} - -/* PyObjectCall2Args */ - static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { - PyObject *args, *result = NULL; - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyFunction_FastCall(function, args, 2); - } - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyCFunction_FastCall(function, args, 2); - } - #endif - args = PyTuple_New(2); - if (unlikely(!args)) goto done; - Py_INCREF(arg1); - PyTuple_SET_ITEM(args, 0, arg1); - Py_INCREF(arg2); - PyTuple_SET_ITEM(args, 1, arg2); - Py_INCREF(function); - result = __Pyx_PyObject_Call(function, args, NULL); - Py_DECREF(args); - Py_DECREF(function); -done: - return result; -} - -/* PyFloatBinop */ - #if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyFloat_DivideObjC(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) { - const double b = floatval; - double a, result; - (void)inplace; - (void)zerodivision_check; - if (likely(PyFloat_CheckExact(op1))) { - a = PyFloat_AS_DOUBLE(op1); - - } else - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op1))) { - a = (double) PyInt_AS_LONG(op1); - - } else - #endif - if (likely(PyLong_CheckExact(op1))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)op1)->ob_digit; - const Py_ssize_t size = Py_SIZE(op1); - switch (size) { - case 0: a = 0.0; break; - case -1: a = -(double) digits[0]; break; - case 1: a = (double) digits[0]; break; - case -2: - case 2: - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) { - a = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -2) - a = -a; - break; - } - } - CYTHON_FALLTHROUGH; - case -3: - case 3: - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) { - a = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -3) - a = -a; - break; - } - } - CYTHON_FALLTHROUGH; - case -4: - case 4: - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) { - a = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -4) - a = -a; - break; - } - } - CYTHON_FALLTHROUGH; - default: - #else - { - #endif - a = PyLong_AsDouble(op1); - if (unlikely(a == -1.0 && PyErr_Occurred())) return NULL; - - } - } else { - return (inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2)); - } - - PyFPE_START_PROTECT("divide", return NULL) - result = a / b; - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); -} -#endif - -/* RaiseArgTupleInvalid */ - static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} - -/* RaiseDoubleKeywords */ - static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -/* ParseKeywords */ - static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* ArgTypeTest */ - static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) -{ - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - else if (exact) { - #if PY_MAJOR_VERSION == 2 - if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif - } - else { - if (likely(__Pyx_TypeCheck(obj, type))) return 1; - } - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); - return 0; -} - -/* GetTopmostException */ - #if CYTHON_USE_EXC_INFO_STACK -static _PyErr_StackItem * -__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) -{ - _PyErr_StackItem *exc_info = tstate->exc_info; - while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && - exc_info->previous_item != NULL) - { - exc_info = exc_info->previous_item; - } - return exc_info; -} -#endif - -/* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - #if CYTHON_USE_EXC_INFO_STACK - _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); - *type = exc_info->exc_type; - *value = exc_info->exc_value; - *tb = exc_info->exc_traceback; - #else - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - #endif - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -} -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - #if CYTHON_USE_EXC_INFO_STACK - _PyErr_StackItem *exc_info = tstate->exc_info; - tmp_type = exc_info->exc_type; - tmp_value = exc_info->exc_value; - tmp_tb = exc_info->exc_traceback; - exc_info->exc_type = type; - exc_info->exc_value = value; - exc_info->exc_traceback = tb; - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -#endif - -/* PyErrExceptionMatches */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; icurexc_type; - if (exc_type == err) return 1; - if (unlikely(!exc_type)) return 0; - if (unlikely(PyTuple_Check(err))) - return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); - return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); -} -#endif - -/* GetException */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) -#endif -{ - PyObject *local_type, *local_value, *local_tb; -#if CYTHON_FAST_THREAD_STATE - PyObject *tmp_type, *tmp_value, *tmp_tb; - local_type = tstate->curexc_type; - local_value = tstate->curexc_value; - local_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -#else - PyErr_Fetch(&local_type, &local_value, &local_tb); -#endif - PyErr_NormalizeException(&local_type, &local_value, &local_tb); -#if CYTHON_FAST_THREAD_STATE - if (unlikely(tstate->curexc_type)) -#else - if (unlikely(PyErr_Occurred())) -#endif - goto bad; - #if PY_MAJOR_VERSION >= 3 - if (local_tb) { - if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) - goto bad; - } - #endif - Py_XINCREF(local_tb); - Py_XINCREF(local_type); - Py_XINCREF(local_value); - *type = local_type; - *value = local_value; - *tb = local_tb; -#if CYTHON_FAST_THREAD_STATE - #if CYTHON_USE_EXC_INFO_STACK - { - _PyErr_StackItem *exc_info = tstate->exc_info; - tmp_type = exc_info->exc_type; - tmp_value = exc_info->exc_value; - tmp_tb = exc_info->exc_traceback; - exc_info->exc_type = local_type; - exc_info->exc_value = local_value; - exc_info->exc_traceback = local_tb; - } - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = local_type; - tstate->exc_value = local_value; - tstate->exc_traceback = local_tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(local_type, local_value, local_tb); -#endif - return 0; -bad: - *type = 0; - *value = 0; - *tb = 0; - Py_XDECREF(local_type); - Py_XDECREF(local_value); - Py_XDECREF(local_tb); - return -1; -} - -/* RaiseException */ - #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - __Pyx_PyThreadState_declare - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - } - if (PyType_Check(type)) { -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; - } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - value = type; - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - } - __Pyx_PyThreadState_assign - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { - PyObject* owned_instance = NULL; - if (tb == Py_None) { - tb = 0; - } else if (tb && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto bad; - } - if (value == Py_None) - value = 0; - if (PyExceptionInstance_Check(type)) { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto bad; - } - value = type; - type = (PyObject*) Py_TYPE(value); - } else if (PyExceptionClass_Check(type)) { - PyObject *instance_class = NULL; - if (value && PyExceptionInstance_Check(value)) { - instance_class = (PyObject*) Py_TYPE(value); - if (instance_class != type) { - int is_subclass = PyObject_IsSubclass(instance_class, type); - if (!is_subclass) { - instance_class = NULL; - } else if (unlikely(is_subclass == -1)) { - goto bad; - } else { - type = instance_class; - } - } - } - if (!instance_class) { - PyObject *args; - if (!value) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } else - args = PyTuple_Pack(1, value); - if (!args) - goto bad; - owned_instance = PyObject_Call(type, args, NULL); - Py_DECREF(args); - if (!owned_instance) - goto bad; - value = owned_instance; - if (!PyExceptionInstance_Check(value)) { - PyErr_Format(PyExc_TypeError, - "calling %R should have returned an instance of " - "BaseException, not %R", - type, Py_TYPE(value)); - goto bad; - } - } - } else { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto bad; - } - if (cause) { - PyObject *fixed_cause; - if (cause == Py_None) { - fixed_cause = NULL; - } else if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); - if (fixed_cause == NULL) - goto bad; - } else if (PyExceptionInstance_Check(cause)) { - fixed_cause = cause; - Py_INCREF(fixed_cause); - } else { - PyErr_SetString(PyExc_TypeError, - "exception causes must derive from " - "BaseException"); - goto bad; - } - PyException_SetCause(value, fixed_cause); - } - PyErr_SetObject(type, value); - if (tb) { -#if CYTHON_COMPILING_IN_PYPY - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); - Py_INCREF(tb); - PyErr_Restore(tmp_type, tmp_value, tb); - Py_XDECREF(tmp_tb); -#else - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject* tmp_tb = tstate->curexc_traceback; - if (tb != tmp_tb) { - Py_INCREF(tb); - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_tb); - } -#endif - } -bad: - Py_XDECREF(owned_instance); - return; -} -#endif - -/* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType -#define __PYX_HAVE_RT_ImportType -static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, - size_t size, enum __Pyx_ImportType_CheckSize check_size) -{ - PyObject *result = 0; - char warning[200]; - Py_ssize_t basicsize; -#ifdef Py_LIMITED_API - PyObject *py_basicsize; -#endif - result = PyObject_GetAttrString(module, class_name); - if (!result) - goto bad; - if (!PyType_Check(result)) { - PyErr_Format(PyExc_TypeError, - "%.200s.%.200s is not a type object", - module_name, class_name); - goto bad; - } -#ifndef Py_LIMITED_API - basicsize = ((PyTypeObject *)result)->tp_basicsize; -#else - py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); - if (!py_basicsize) - goto bad; - basicsize = PyLong_AsSsize_t(py_basicsize); - Py_DECREF(py_basicsize); - py_basicsize = 0; - if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) - goto bad; -#endif - if ((size_t)basicsize < size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - goto bad; - } - if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - goto bad; - } - else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) { - PyOS_snprintf(warning, sizeof(warning), - "%s.%s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; - } - return (PyTypeObject *)result; -bad: - Py_XDECREF(result); - return NULL; -} -#endif - -/* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_MAJOR_VERSION < 3 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; - } - #endif - if (!module) { - #if PY_MAJOR_VERSION < 3 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } -bad: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_list); - Py_XDECREF(empty_dict); - return module; -} - -/* CLineInTraceback */ - #ifndef CYTHON_CLINE_IN_TRACEBACK -static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) { - PyObject *use_cline; - PyObject *ptype, *pvalue, *ptraceback; -#if CYTHON_COMPILING_IN_CPYTHON - PyObject **cython_runtime_dict; -#endif - if (unlikely(!__pyx_cython_runtime)) { - return c_line; - } - __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); -#if CYTHON_COMPILING_IN_CPYTHON - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (likely(cython_runtime_dict)) { - __PYX_PY_DICT_LOOKUP_IF_MODIFIED( - use_cline, *cython_runtime_dict, - __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) - } else -#endif - { - PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); - if (use_cline_obj) { - use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; - Py_DECREF(use_cline_obj); - } else { - PyErr_Clear(); - use_cline = NULL; - } - } - if (!use_cline) { - c_line = 0; - PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); - } - else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { - c_line = 0; - } - __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); - return c_line; -} -#endif - -/* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { - int start = 0, mid = 0, end = count - 1; - if (end >= 0 && code_line > entries[end].code_line) { - return count; - } - while (start < end) { - mid = start + (end - start) / 2; - if (code_line < entries[mid].code_line) { - end = mid; - } else if (code_line > entries[mid].code_line) { - start = mid + 1; - } else { - return mid; - } - } - if (code_line <= entries[mid].code_line) { - return mid; - } else { - return mid + 1; - } -} -static PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_code_cache.count = 1; - entries[0].code_line = code_line; - entries[0].code_object = code_object; - Py_INCREF(code_object); - } - return; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -/* AddTraceback */ - #include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, - 0, - 0, - 0, - 0, - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - return NULL; -} -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyFrameObject *py_frame = 0; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - if (c_line) { - c_line = __Pyx_CLineForTraceback(tstate, c_line); - } - py_code = __pyx_find_code_object(c_line ? -c_line : py_line); - if (!py_code) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); - } - py_frame = PyFrame_New( - tstate, /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __pyx_d, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - __Pyx_PyFrame_SetLineNumber(py_frame, py_line); - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} - -#if PY_MAJOR_VERSION < 3 -static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { - if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); - PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); - return -1; -} -static void __Pyx_ReleaseBuffer(Py_buffer *view) { - PyObject *obj = view->obj; - if (!obj) return; - if (PyObject_CheckBuffer(obj)) { - PyBuffer_Release(view); - return; - } - if ((0)) {} - view->obj = NULL; - Py_DECREF(obj); -} -#endif - - - /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) -#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) -#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ - {\ - func_type value = func_value;\ - if (sizeof(target_type) < sizeof(func_type)) {\ - if (unlikely(value != (func_type) (target_type) value)) {\ - func_type zero = 0;\ - if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ - return (target_type) -1;\ - if (is_unsigned && unlikely(value < zero))\ - goto raise_neg_overflow;\ - else\ - goto raise_overflow;\ - }\ - }\ - return (target_type) value;\ - } - -/* Declarations */ - #if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return ::std::complex< float >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return x + y*(__pyx_t_float_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - __pyx_t_float_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -/* Arithmetic */ - #if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - #if 1 - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - if (b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); - } else if (fabsf(b.real) >= fabsf(b.imag)) { - if (b.real == 0 && b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag); - } else { - float r = b.imag / b.real; - float s = (float)(1.0) / (b.real + b.imag * r); - return __pyx_t_float_complex_from_parts( - (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); - } - } else { - float r = b.real / b.imag; - float s = (float)(1.0) / (b.imag + b.real * r); - return __pyx_t_float_complex_from_parts( - (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); - } - } - #else - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - if (b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); - } else { - float denom = b.real * b.real + b.imag * b.imag; - return __pyx_t_float_complex_from_parts( - (a.real * b.real + a.imag * b.imag) / denom, - (a.imag * b.real - a.real * b.imag) / denom); - } - } - #endif - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrtf(z.real*z.real + z.imag*z.imag); - #else - return hypotf(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - float r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - float denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - return __Pyx_c_prod_float(a, a); - case 3: - z = __Pyx_c_prod_float(a, a); - return __Pyx_c_prod_float(z, a); - case 4: - z = __Pyx_c_prod_float(a, a); - return __Pyx_c_prod_float(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } else if (b.imag == 0) { - z.real = powf(a.real, b.real); - z.imag = 0; - return z; - } else if (a.real > 0) { - r = a.real; - theta = 0; - } else { - r = -a.real; - theta = atan2f(0.0, -1.0); - } - } else { - r = __Pyx_c_abs_float(a); - theta = atan2f(a.imag, a.real); - } - lnr = logf(r); - z_r = expf(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cosf(z_theta); - z.imag = z_r * sinf(z_theta); - return z; - } - #endif -#endif - -/* Declarations */ - #if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return ::std::complex< double >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return x + y*(__pyx_t_double_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - __pyx_t_double_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -/* Arithmetic */ - #if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - #if 1 - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - if (b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); - } else if (fabs(b.real) >= fabs(b.imag)) { - if (b.real == 0 && b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag); - } else { - double r = b.imag / b.real; - double s = (double)(1.0) / (b.real + b.imag * r); - return __pyx_t_double_complex_from_parts( - (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); - } - } else { - double r = b.real / b.imag; - double s = (double)(1.0) / (b.imag + b.real * r); - return __pyx_t_double_complex_from_parts( - (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); - } - } - #else - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - if (b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); - } else { - double denom = b.real * b.real + b.imag * b.imag; - return __pyx_t_double_complex_from_parts( - (a.real * b.real + a.imag * b.imag) / denom, - (a.imag * b.real - a.real * b.imag) / denom); - } - } - #endif - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrt(z.real*z.real + z.imag*z.imag); - #else - return hypot(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - double r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - double denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - return __Pyx_c_prod_double(a, a); - case 3: - z = __Pyx_c_prod_double(a, a); - return __Pyx_c_prod_double(z, a); - case 4: - z = __Pyx_c_prod_double(a, a); - return __Pyx_c_prod_double(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } else if (b.imag == 0) { - z.real = pow(a.real, b.real); - z.imag = 0; - return z; - } else if (a.real > 0) { - r = a.real; - theta = 0; - } else { - r = -a.real; - theta = atan2(0.0, -1.0); - } - } else { - r = __Pyx_c_abs_double(a); - theta = atan2(a.imag, a.real); - } - lnr = log(r); - z_r = exp(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cos(z_theta); - z.imag = z_r * sin(z_theta); - return z; - } - #endif -#endif - -/* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const int neg_one = (int) -1, const_zero = (int) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (int) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) - case -2: - if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - } -#endif - if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int"); - return (int) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const int neg_one = (int) -1, const_zero = (int) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(int) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), - little, !is_unsigned); - } -} - -/* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { - return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { - return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { - return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (long) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) - case -2: - if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - } -#endif - if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to long"); - return (long) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; -} - -/* FastTypeChecks */ - #if CYTHON_COMPILING_IN_CPYTHON -static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { - while (a) { - a = a->tp_base; - if (a == b) - return 1; - } - return b == &PyBaseObject_Type; -} -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { - PyObject *mro; - if (a == b) return 1; - mro = a->tp_mro; - if (likely(mro)) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(mro); - for (i = 0; i < n; i++) { - if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) - return 1; - } - return 0; - } - return __Pyx_InBases(a, b); -} -#if PY_MAJOR_VERSION == 2 -static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { - PyObject *exception, *value, *tb; - int res; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&exception, &value, &tb); - res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - if (!res) { - res = PyObject_IsSubclass(err, exc_type2); - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - } - __Pyx_ErrRestore(exception, value, tb); - return res; -} -#else -static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { - int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; - if (!res) { - res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); - } - return res; -} -#endif -static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - assert(PyExceptionClass_Check(exc_type)); - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; ip) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - if (PyObject_Hash(*t->p) == -1) - return -1; - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { - Py_ssize_t ignore; - return __Pyx_PyObject_AsStringAndSize(o, &ignore); -} -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -#if !CYTHON_PEP393_ENABLED -static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -} -#else -static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (likely(PyUnicode_IS_ASCII(o))) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } -#else - return PyUnicode_AsUTF8AndSize(o, length); -#endif -} -#endif -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { - return __Pyx_PyUnicode_AsStringAndSize(o, length); - } else -#endif -#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif - { - char* result; - int r = PyBytes_AsStringAndSize(o, &result, length); - if (unlikely(r < 0)) { - return NULL; - } else { - return result; - } - } -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { - int is_true = x == Py_True; - if (is_true | (x == Py_False) | (x == Py_None)) return is_true; - else return PyObject_IsTrue(x); -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { - int retval; - if (unlikely(!x)) return -1; - retval = __Pyx_PyObject_IsTrue(x); - Py_DECREF(x); - return retval; -} -static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { -#if PY_MAJOR_VERSION >= 3 - if (PyLong_Check(result)) { - if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, - "__int__ returned non-int (type %.200s). " - "The ability to return an instance of a strict subclass of int " - "is deprecated, and may be removed in a future version of Python.", - Py_TYPE(result)->tp_name)) { - Py_DECREF(result); - return NULL; - } - return result; - } -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - type_name, type_name, Py_TYPE(result)->tp_name); - Py_DECREF(result); - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { -#if CYTHON_USE_TYPE_SLOTS - PyNumberMethods *m; -#endif - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x) || PyLong_Check(x))) -#else - if (likely(PyLong_Check(x))) -#endif - return __Pyx_NewRef(x); -#if CYTHON_USE_TYPE_SLOTS - m = Py_TYPE(x)->tp_as_number; - #if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = m->nb_int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = m->nb_long(x); - } - #else - if (likely(m && m->nb_int)) { - name = "int"; - res = m->nb_int(x); - } - #endif -#else - if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { - res = PyNumber_Int(x); - } -#endif - if (likely(res)) { -#if PY_MAJOR_VERSION < 3 - if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { -#else - if (unlikely(!PyLong_CheckExact(res))) { -#endif - return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); - } - } - else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "an integer is required"); - } - return res; -} -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { - Py_ssize_t ival; - PyObject *x; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) { - if (sizeof(Py_ssize_t) >= sizeof(long)) - return PyInt_AS_LONG(b); - else - return PyInt_AsSsize_t(b); - } -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)b)->ob_digit; - const Py_ssize_t size = Py_SIZE(b); - if (likely(__Pyx_sst_abs(size) <= 1)) { - ival = likely(size) ? digits[0] : 0; - if (size == -1) ival = -ival; - return ival; - } else { - switch (size) { - case 2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - } - } - #endif - return PyLong_AsSsize_t(b); - } - x = PyNumber_Index(b); - if (!x) return -1; - ival = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { - return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { - return PyInt_FromSize_t(ival); -} - - -#endif /* Py_PYTHON_H */ diff --git a/landcover-L-SAR/tool/algorithm/algtools/filter/build/temp.win-amd64-3.8/Release/build/lee_Filter/lee_Filter_c.cp38-win_amd64.exp b/landcover-L-SAR/tool/algorithm/algtools/filter/build/temp.win-amd64-3.8/Release/build/lee_Filter/lee_Filter_c.cp38-win_amd64.exp deleted file mode 100644 index f83e40e..0000000 Binary files a/landcover-L-SAR/tool/algorithm/algtools/filter/build/temp.win-amd64-3.8/Release/build/lee_Filter/lee_Filter_c.cp38-win_amd64.exp and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/algtools/filter/build/temp.win-amd64-3.8/Release/build/lee_Filter/lee_Filter_c.cp38-win_amd64.lib b/landcover-L-SAR/tool/algorithm/algtools/filter/build/temp.win-amd64-3.8/Release/build/lee_Filter/lee_Filter_c.cp38-win_amd64.lib deleted file mode 100644 index 96b04a7..0000000 Binary files a/landcover-L-SAR/tool/algorithm/algtools/filter/build/temp.win-amd64-3.8/Release/build/lee_Filter/lee_Filter_c.cp38-win_amd64.lib and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/algtools/filter/build/temp.win-amd64-3.8/Release/build/lee_Filter/lee_Filter_c.obj b/landcover-L-SAR/tool/algorithm/algtools/filter/build/temp.win-amd64-3.8/Release/build/lee_Filter/lee_Filter_c.obj deleted file mode 100644 index 7a12ef4..0000000 Binary files a/landcover-L-SAR/tool/algorithm/algtools/filter/build/temp.win-amd64-3.8/Release/build/lee_Filter/lee_Filter_c.obj and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/algtools/filter/isce.log b/landcover-L-SAR/tool/algorithm/algtools/filter/isce.log deleted file mode 100644 index 6c23767..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/filter/isce.log +++ /dev/null @@ -1,7 +0,0 @@ -2023-02-17 06:06:22,434 - pyproj - DEBUG - PROJ_ERROR: proj_context_set_database_path: /cygdrive/e/soft/Anaconda/envs/micro/Library/share/proj/proj.db lacks DATABASE.LAYOUT.VERSION.MAJOR / DATABASE.LAYOUT.VERSION.MINOR metadata. It comes from another PROJ installation. -2023-02-17 06:13:33,366 - pyproj - DEBUG - PROJ_ERROR: proj_context_set_database_path: /cygdrive/e/soft/Anaconda/envs/micro/Library/share/proj/proj.db lacks DATABASE.LAYOUT.VERSION.MAJOR / DATABASE.LAYOUT.VERSION.MINOR metadata. It comes from another PROJ installation. -2023-02-17 06:43:15,623 - pyproj - DEBUG - PROJ_ERROR: proj_context_set_database_path: /cygdrive/e/soft/Anaconda/envs/micro/Library/share/proj/proj.db lacks DATABASE.LAYOUT.VERSION.MAJOR / DATABASE.LAYOUT.VERSION.MINOR metadata. It comes from another PROJ installation. -2023-02-17 06:46:12,386 - pyproj - DEBUG - PROJ_ERROR: proj_context_set_database_path: /cygdrive/e/soft/Anaconda/envs/micro/Library/share/proj/proj.db lacks DATABASE.LAYOUT.VERSION.MAJOR / DATABASE.LAYOUT.VERSION.MINOR metadata. It comes from another PROJ installation. -2023-02-17 07:58:59,262 - pyproj - DEBUG - PROJ_ERROR: proj_context_set_database_path: /cygdrive/e/soft/Anaconda/envs/micro/Library/share/proj/proj.db lacks DATABASE.LAYOUT.VERSION.MAJOR / DATABASE.LAYOUT.VERSION.MINOR metadata. It comes from another PROJ installation. -2023-02-17 07:59:05,563 - pyproj - DEBUG - PROJ_ERROR: proj_context_set_database_path: /cygdrive/e/soft/Anaconda/envs/micro/Library/share/proj/proj.db lacks DATABASE.LAYOUT.VERSION.MAJOR / DATABASE.LAYOUT.VERSION.MINOR metadata. It comes from another PROJ installation. -2023-02-17 07:59:28,169 - pyproj - DEBUG - PROJ_ERROR: proj_context_set_database_path: /cygdrive/e/soft/Anaconda/envs/micro/Library/share/proj/proj.db lacks DATABASE.LAYOUT.VERSION.MAJOR / DATABASE.LAYOUT.VERSION.MINOR metadata. It comes from another PROJ installation. diff --git a/landcover-L-SAR/tool/algorithm/algtools/filter/lee_Filter.py b/landcover-L-SAR/tool/algorithm/algtools/filter/lee_Filter.py deleted file mode 100644 index 08bd679..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/filter/lee_Filter.py +++ /dev/null @@ -1,302 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:lee_filter.py -@Function:lee_filter -@Contact: https://github.com/PyRadar/pyradar -@Author:SHJ -@Date:2021/8/30 8:42 -@Version:1.0.0 -""" - -import numpy as np -import math -from PIL import Image -import multiprocessing -import multiprocessing -from tool.algorithm.block.blockprocess import BlockProcess -import logging -import shutil -from tool.algorithm.image.ImageHandle import ImageHandler -from tool.file.fileHandle import fileHandle -from tool.algorithm.algtools.filter import lee_Filter_c as lee_Filter_c -logger = logging.getLogger("mylog") -file =fileHandle(False) -COEF_VAR_DEFAULT = 0.01 -CU_DEFAULT = 0.25 -import os - - -class Filter: - def __int__(self): - pass - - @staticmethod - def assert_window_size(win_size): - """ - Asserts invalid window size. - Window size must be odd and bigger than 3. - """ - assert win_size >= 3, 'ERROR: win size must be at least 3' - - if win_size % 2 == 0: - print('It is highly recommended to user odd window sizes.' - 'You provided %s, an even number.' % (win_size, )) - - @staticmethod - def assert_indices_in_range(width, height, xleft, xright, yup, ydown): - """ - Asserts index out of image range. - """ - - # assert xleft >= 0 and xleft <= width, \ - assert 0 <= xleft <= width, \ - "index xleft:%s out of range (%s<= xleft < %s)" % (xleft, 0, width) - - # assert xright >= 0 and xright <= width, \ - assert 0 <= xright <= width, "index xright:%s out of range (%s<= xright < %s)" % (xright, 0, width) - - # assert yup >= 0 and yup <= height, \ - assert 0 <= yup <= height, "index yup:%s out of range. (%s<= yup < %s)" % (yup, 0, height) - - # assert ydown >= 0 and ydown <= height, \ - assert 0 <= ydown <= height, "index ydown:%s out of range. (%s<= ydown < %s)" % (ydown, 0, height) - - @staticmethod - def weighting(window, cu=CU_DEFAULT): - """ - Computes the weighthing function for Lee filter using cu as the noise - coefficient. - """ - # cu is the noise variation coefficient - two_cu = cu * cu - - # ci is the variation coefficient in the window - window_mean = window.mean() - window_std = window.std() - ci = window_std / window_mean - - two_ci = ci * ci - - if not two_ci: # dirty patch to avoid zero division - two_ci = COEF_VAR_DEFAULT - - if cu > ci: - w_t = 0.0 - else: - w_t = 1.0 - (two_cu / two_ci) - - return w_t - - def lee_filter(self, in_path, out_path, win_size): - """ - Apply lee to a numpy matrix containing the image, with a window of - win_size x win_size. - """ - cu = CU_DEFAULT - self.assert_window_size(win_size) - # img = self.ImageHandler.get_band_array(img, 1) - array1 = Image.open(in_path) - img = np.array(array1) - # we process the entire img as float64 to avoid type overflow error - img = np.float64(img) - img_filtered = np.zeros_like(img) - # n, m = img.shape - # win_offset = win_size / 2 - # - # for i in range(0, n): - # xleft = i - win_offset - # xright = i + win_offset - # - # if xleft < 0: - # xleft = 0 - # if xright >= n: - # xright = n - # - # for j in range(0, m): - # yup = j - win_offset - # ydown = j + win_offset - # - # if yup < 0: - # yup = 0 - # if ydown >= m: - # ydown = m - # - # self.assert_indices_in_range(n, m, xleft, xright, yup, ydown) - # - # pix_value = img[i, j] - # - # window = img[math.ceil(xleft):int(xright)+1, math.ceil(yup):int(ydown)+1] - # w_t = self.weighting(window, cu) - # window_mean = window.mean() - # new_pix_value = (pix_value * w_t) + (window_mean * (1.0 - w_t)) - # - # if not new_pix_value > 0: - # new_pix_value = 0 - # img_filtered[i, j] = round(new_pix_value) - # # return img_filtered - self.lee_filter_array(img, img_filtered, win_size) - out_image = Image.fromarray(img_filtered) - out_image.save(out_path) - print("lee_filter finish! path:" + out_path) - return True - - @staticmethod - def lee_filter_array(in_arry, out_arry, win_size): - """ - Apply lee to a numpy matrix containing the image, with a window of - win_size x win_size. - """ - f = Filter() - #cu = CU_DEFAULT - f.assert_window_size(win_size) - img = in_arry - # we process the entire img as float64 to avoid type overflow error - img = np.float64(img) - img = img + 100 - - # lee_filter_array(np.ndarray[double,ndim=2] img,np.ndarray[double,ndim=2] out_arryint win_offset,int win_size): - newOUt=lee_Filter_c.lee_filter_array(img,out_arry,win_size) - newOUt=newOUt-100 - out_arry[:,:]=newOUt[:,:] - - # def lee_filter_array(self, in_arry, out_arry, win_size): - # """ - # Apply lee to a numpy matrix containing the image, with a window of - # win_size x win_size. - # """ - # cu = CU_DEFAULT - # self.assert_window_size(win_size) - # img = in_arry - # # we process the entire img as float64 to avoid type overflow error - # img = np.float64(img) - # img = img + 100 - # img_filtered = np.zeros_like(img) - # n, m = img.shape - # win_offset = win_size / 2 - # - # for i in range(0, n): - # xleft = i - win_offset - # xright = i + win_offset - # - # if xleft < 0: - # xleft = 0 - # if xright >= n: - # xright = n - # - # for j in range(0, m): - # yup = j - win_offset - # ydown = j + win_offset - # - # if yup < 0: - # yup = 0 - # if ydown >= m: - # ydown = m - # - # self.assert_indices_in_range(n, m, xleft, xright, yup, ydown) - # - # pix_value = img[i, j] - # - # window = img[math.ceil(xleft):int(xright)+1, math.ceil(yup):int(ydown)+1] - # w_t = self.weighting(window, cu) - # window_mean = window.mean() - # new_pix_value = (pix_value * w_t) + (window_mean * (1.0 - w_t)) - # - # if not new_pix_value > 0: - # new_pix_value = 0 - # out_arry[i, j] = round(new_pix_value) - # out_arry = out_arry - 100 - # - - def lee_filter_multiprocess(self, in_paths, out_paths, win_size =3,processes_num=10): - if len(in_paths) != len(out_paths): - return False - # 开启多进程处理 - pool = multiprocessing.Pool(processes=processes_num) - pl = [] - for i in range(len(in_paths)): - #self.lee_filter(in_paths[i], out_paths[i], win_size) - pl.append(pool.apply_async(self.lee_filter,(in_paths[i], out_paths[i], win_size))) - print("lee_filter runing! path:" + in_paths[i]) - pool.close() - pool.join() - return True - - - def lee_filter_block_multiprocess(self, in_path, out_path, win_size =3): - in_name = os.path.basename(in_path) - out_name = os.path.basename(out_path) - outDir= os.path.split(out_path)[0] - #创建工作文件夹 - src_path = os.path.join(outDir, "src_img") - block_path = os.path.join(outDir, "block") - block_filtered = os.path.join(outDir, "block_filtered") - file.creat_dirs([src_path, block_path, block_filtered]) - - shutil.copyfile(in_path, os.path.join(src_path, in_name)) - cols = ImageHandler.get_img_width(in_path) - rows = ImageHandler.get_img_height(in_path) - # 分块 - bp = BlockProcess() - block_size = bp.get_block_size(rows, cols) - bp.cut(src_path, block_path, ['tif', 'tiff'], 'tif', block_size) - logger.info('blocking tifs success!') - - img_dir, img_name = bp.get_file_names(block_path, ['tif']) - dir_dict = bp.get_same_img(img_dir, img_name) - - img_path_list = [value for value in dir_dict.values()][0] - - processes_num = min([len(img_path_list), multiprocessing.cpu_count() - 1]) - - out_img_path_list =[] - for in_path in img_path_list: - suffix = bp.get_suffix(os.path.basename(in_path)) - out_path = os.path.join(block_filtered, out_name.replace('.tif', suffix)) - out_img_path_list.append(out_path) - - self.lee_filter_multiprocess(img_path_list, out_img_path_list, win_size = win_size, processes_num=processes_num) - # 开启多进程处理 - # pool = multiprocessing.Pool(processes=processes_num) - # - # for i in range(len(hh_list)): - # block_img_path = hh_list[i] - # suffix = bp.get_suffix(os.path.basename(hh_list[i])) - # filed_block_img_path = os.path.join(block_filtered,out_name.replace('.tif',suffix)) - # pool.apply_async(self.lee_filter, (block_img_path, filed_block_img_path, win_size)) - # print("lee_filter runing! path:" + block_img_path) - # logger.info('total:%s, block:%s lee_filter!', len(hh_list), i) - # - # pool.close() - # pool.join() - # # 合并处理后的影像 - bp.combine(block_filtered, cols, rows, outDir, file_type=['tif'], datetype='float32') - - file.del_folder(src_path) - file.del_folder(block_path) - file.del_folder(block_filtered) - pass - - def lee_process_sar(self, in_sar, out_sar, win_size, noise_var): - ''' - # std::cout << "mode 12" - # std::cout << "SIMOrthoProgram.exe 12 in_sar_path out_sar_path win_size noise_var" - ''' - exe_path = r".\baseTool\x64\Release\SIMOrthoProgram-L-SAR.exe" - exe_cmd = r"set PROJ_LIB=.\baseTool\x64\Release; & {0} {1} {2} {3} {4} {5}".format(exe_path, 12, in_sar, - out_sar, win_size, noise_var) - print(exe_cmd) - print(os.system(exe_cmd)) - print("==========================================================================") - - -if __name__ == '__main__': - # 示例1: - # path = r"I:\MicroWorkspace\product\C-SAR\LeafAreaIndex\Temporary\cai_sartif\HV_0_512_0_512.tif" - # f = Filter() - # f.lee_filter(path,path,3) - #示例2: - - f = Filter() - f.lee_filter_block_multiprocess('I:\preprocessed\HH.tif','I:\preprocessed\HHf.tif') - pass diff --git a/landcover-L-SAR/tool/algorithm/algtools/filter/lee_Filter/lee_Filter_c.pyx b/landcover-L-SAR/tool/algorithm/algtools/filter/lee_Filter/lee_Filter_c.pyx deleted file mode 100644 index 413b8a6..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/filter/lee_Filter/lee_Filter_c.pyx +++ /dev/null @@ -1,124 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:lee_filter.py -@Function:lee_filter -@Contact: https://github.com/PyRadar/pyradar -@Author:SHJ -@Date:2021/8/30 8:42 -@Version:1.0.0 -""" - -import os -cimport cython # 必须导入 -import numpy as np##必须为c类型和python类型的数据都申明一个np -cimport numpy as np # 必须为c类型和python类型的数据都申明一个np -from libc.math cimport pi -from libc.math cimport atan as math_atan -from libc.math cimport log10 as math_log10 -from libc.math cimport log as math_log -from libc.math cimport floor as math_floor -from libc.math cimport sqrt as math_sqrt -from libc.math cimport exp as math_exp -from libc.math cimport sin as math_sin -from libc.math cimport cos as math_cos -from libc.math cimport tan as math_tan -from libc.math cimport asin as math_asin -from libc.math cimport acos as math_acos -from libc.math cimport tan as math_atan -from libc.math cimport sinh as math_sinh -from libc.math cimport cosh as math_cosh -from libc.math cimport tanh as math_tanh -from libc.math cimport floor as math_floor -from libc.math cimport ceil as math_ceil -from libc.math cimport lround as math_round - -cdef double COEF_VAR_DEFAULT = 0.01 -cdef double CU_DEFAULT = 0.25 - - -cdef int ceil_usr(double v): - return int(math_ceil(v)) - - - -cdef double weighting(np.ndarray[double,ndim=2] window,double cu): - """ - Computes the weighthing function for Lee filter using cu as the noise - coefficient. - """ - # cu is the noise variation coefficient - cdef double two_cu = cu * cu - - # ci is the variation coefficient in the window - cdef double window_mean = window.mean() - cdef double window_std = window.std() - cdef double ci = window_std / window_mean - - cdef double two_ci = ci * ci - cdef double w_t=0; - if not (two_ci==0): # dirty patch to avoid zero division - two_ci = COEF_VAR_DEFAULT - - if cu > ci: - w_t = 0.0 - else: - w_t = 1.0 - (two_cu / two_ci) - - return w_t - -cpdef np.ndarray[double,ndim=2] lee_filter_array(np.ndarray[double,ndim=2] img,np.ndarray[double,ndim=2] out_arry,int win_size): - """ - Apply lee to a numpy matrix containing the image, with a window of - win_size x win_size. - """ - # we process the entire img as float64 to avoid type overflow error - #n, m = img.shape - cdef double cu = CU_DEFAULT - cdef int i=0 - cdef int j=0 - cdef int xleft=0 - cdef int xright=0 - cdef int yup=0 - cdef int ydown=0 - cdef np.ndarray[double,ndim=2] window; - cdef double w_t=0; - cdef double window_mean=0; - cdef double new_pix_valu=0; - cdef int n = img.shape[0] - cdef int m=img.shape[1] - cdef int win_offset=int(win_size/2) - - while i= n: - xright = n - j=0 - while j= m: - ydown = m - - pix_value = img[i, j] - - window = img[xleft:xright+1, yup:ydown+1] - - w_t = weighting(window, cu) - - window_mean = np.mean(window) - new_pix_value = (pix_value * w_t) + (window_mean * (1.0 - w_t)) - - if not new_pix_value > 0: - new_pix_value = 0 - out_arry[i, j] = round(new_pix_value*100000.0)/100000.0 - j=j+1 - i=i+1 - return out_arry - diff --git a/landcover-L-SAR/tool/algorithm/algtools/filter/lee_Filter_c.cp38-win_amd64.pyd b/landcover-L-SAR/tool/algorithm/algtools/filter/lee_Filter_c.cp38-win_amd64.pyd deleted file mode 100644 index 0ed7504..0000000 Binary files a/landcover-L-SAR/tool/algorithm/algtools/filter/lee_Filter_c.cp38-win_amd64.pyd and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/algtools/filter/setup.py b/landcover-L-SAR/tool/algorithm/algtools/filter/setup.py deleted file mode 100644 index 184d396..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/filter/setup.py +++ /dev/null @@ -1,45 +0,0 @@ -from setuptools import setup -from setuptools.extension import Extension -from Cython.Distutils import build_ext -from Cython.Build import cythonize -import numpy -from pathlib import Path -import shutil - - -class MyBuildExt(build_ext): - def run(self): - build_ext.run(self) - - build_dir = Path(self.build_lib) - root_dir = Path(__file__).parent - target_dir = build_dir if not self.inplace else root_dir - - self.copy_file(Path('./lee_Filter') / '__init__.py', root_dir, target_dir) - #self.copy_file(Path('./pkg2') / '__init__.py', root_dir, target_dir) - self.copy_file(Path('.') / '__init__.py', root_dir, target_dir) - def copy_file(self, path, source_dir, destination_dir): - if not (source_dir / path).exists(): - return - shutil.copyfile(str(source_dir / path), str(destination_dir / path)) - -setup( - name="MyModule", - ext_modules=cythonize( - [ - #Extension("pkg1.*", ["root/pkg1/*.py"]), - Extension("pkg2.*", ["./lee_Filter/lee_Filter_c.pyx"]), - #Extension("1.*", ["root/*.py"]) - ], - build_dir="build", - compiler_directives=dict( - always_allow_keywords=True - )), - cmdclass=dict( - build_ext=MyBuildExt - ), - packages=[], - include_dirs=[numpy.get_include()], -) - -# 指令: python setup.py build_ext --inplace diff --git a/landcover-L-SAR/tool/algorithm/algtools/logHandler.py b/landcover-L-SAR/tool/algorithm/algtools/logHandler.py deleted file mode 100644 index be3ca11..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/logHandler.py +++ /dev/null @@ -1,106 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project :microproduct -@File :logHandler.py -@Function :日志检查、生成 -@Author :SHJ -@Date :2021/12/1 -@Version :1.0.0 -""" -import logging -import os -import time -import datetime - -import colorlog - - -class LogHandler: - """ - 生成日志 - """ - __logger = logging.getLogger("mylog") - __format_str = logging.Formatter("[%(asctime)s] [%(process)d] [%(levelname)s] - %(module)s.%(funcName)s " - "(%(filename)s:%(lineno)d) - %(message)s") - __log_path = None - - __log_colors_config = { - 'DEBUG': 'blue', - 'INFO': 'cyan', - 'WARNING': 'yellow', - 'ERROR': 'red', - 'CRITICAL': 'red', - } - - @staticmethod - def init_log_handler(log_name): - """ - 初始化日志 - :param log_name: 日志保存的路径和名称 - :return: - """ - path = os.getcwd() - current_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(time.time())) - LogHandler.__log_path = os.path.join(path, log_name + current_time + ".log") - para_dir = os.path.split(LogHandler.__log_path) - if not os.path.exists(para_dir[0]): - os.makedirs(para_dir[0]) - # 删除七天以前的文件 - LogHandler.delete_outdate_files(para_dir[0]) - - # 方法1:普通日志 - log_format = "[%(asctime)s] [%(process)d] [%(levelname)s]- %(message)s ---from: %(module)s.%(funcName)s" \ - " (%(filename)s:Line%(lineno)d) " - date_format = "%m/%d/%Y %H:%M:%S" - formatter = colorlog.ColoredFormatter( - "%(log_color)s[%(asctime)s] [%(process)d] [%(levelname)s]- %(message)s ---from: %(module)s.%(funcName)s" - " (%(filename)s:Line%(lineno)d) ", - log_colors=LogHandler.__log_colors_config) - fp = logging.FileHandler(LogHandler.__log_path, encoding='utf-8') - fs = logging.StreamHandler() - fs.setFormatter(formatter) - # logging.basicConfig(level=logging.INFO, format=log_format, datefmt=date_format, handlers=[fp, fs]) # 调用 - logging.basicConfig(level=logging.INFO, datefmt=date_format, handlers=[fp, fs]) # 调用 - - # 方法2:回滚日志 - # LogHandler.__logger.setLevel(logging.DEBUG) - # th = handlers.TimedRotatingFileHandler(filename=LogHandler.__log_path, when='S', interval=1, - # backupCount=2, encoding='utf-8') - # th.suffix = "%Y-%m-%d-%H-%M-%S.log" - # th.setFormatter(LogHandler.__format_str) - # th.setLevel(level=logging.DEBUG) - - # console = logging.StreamHandler() - # console.setLevel(logging.INFO) - # LogHandler.__logger.addHandler(console) - # LogHandler.__logger.addHandler(th) - - @staticmethod - def delete_outdate_files(path, date_interval=7): - """ - 删除目录下七天前创建的文件 - """ - current_time = time.strftime("%Y-%m-%d", time.localtime(time.time())) - current_time_list = current_time.split("-") - current_time_day = datetime.datetime(int(current_time_list[0]), int(current_time_list[1]), - int(current_time_list[2])) - for root, dirs, files in os.walk(path): - for item in files: - item_format = item.split(".", 2) - if item_format[1] == "log": - file_path = os.path.join(root, item) - create_time = time.strftime("%Y-%m-%d", time.localtime((os.stat(file_path)).st_mtime)) - create_time_list = create_time.split("-") - create_time_day = datetime.datetime(int(create_time_list[0]), int(create_time_list[1]), - int(create_time_list[2])) - time_difference = (current_time_day - create_time_day).days - if time_difference > date_interval: - os.remove(file_path) - -# -# if __name__ == "__main__": -# # eg2: -# log_handler = LogHandler() -# log_handler.init_log_handler(r"run_log\myrun1") -# logging.warning("1") -# print("done") diff --git a/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/oh2004/oh2004.c b/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/oh2004/oh2004.c deleted file mode 100644 index f0bbecc..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/oh2004/oh2004.c +++ /dev/null @@ -1,9665 +0,0 @@ -/* Generated by Cython 0.29.24 */ - -/* BEGIN: Cython Metadata -{ - "distutils": { - "depends": [], - "name": "oh2004", - "sources": [ - "./oh2004/oh2004.pyx" - ] - }, - "module_name": "oh2004" -} -END: Cython Metadata */ - -#ifndef PY_SSIZE_T_CLEAN -#define PY_SSIZE_T_CLEAN -#endif /* PY_SSIZE_T_CLEAN */ -#include "Python.h" -#ifndef Py_PYTHON_H - #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) - #error Cython requires Python 2.6+ or Python 3.3+. -#else -#define CYTHON_ABI "0_29_24" -#define CYTHON_HEX_VERSION 0x001D18F0 -#define CYTHON_FUTURE_DIVISION 0 -#include -#ifndef offsetof - #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !defined(WIN32) && !defined(MS_WINDOWS) - #ifndef __stdcall - #define __stdcall - #endif - #ifndef __cdecl - #define __cdecl - #endif - #ifndef __fastcall - #define __fastcall - #endif -#endif -#ifndef DL_IMPORT - #define DL_IMPORT(t) t -#endif -#ifndef DL_EXPORT - #define DL_EXPORT(t) t -#endif -#define __PYX_COMMA , -#ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x02070000 - #define HAVE_LONG_LONG - #endif -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION - #define CYTHON_COMPILING_IN_PYPY 1 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #undef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #if PY_VERSION_HEX < 0x03050000 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #undef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #undef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 1 - #undef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 0 - #undef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 0 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 - #undef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS 0 - #undef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK 0 -#elif defined(PYSTON_VERSION) - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 1 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 - #undef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS 0 - #undef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK 0 -#else - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 1 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) - #define CYTHON_USE_PYTYPE_LOOKUP 1 - #endif - #if PY_MAJOR_VERSION < 3 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #elif !defined(CYTHON_USE_PYLONG_INTERNALS) - #define CYTHON_USE_PYLONG_INTERNALS 1 - #endif - #ifndef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 1 - #endif - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #if PY_VERSION_HEX < 0x030300F0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #elif !defined(CYTHON_USE_UNICODE_WRITER) - #define CYTHON_USE_UNICODE_WRITER 1 - #endif - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #ifndef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 1 - #endif - #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 1 - #endif - #ifndef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) - #endif - #ifndef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) - #endif - #ifndef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) - #endif - #ifndef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) - #endif -#endif -#if !defined(CYTHON_FAST_PYCCALL) -#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) -#endif -#if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #undef SHIFT - #undef BASE - #undef MASK - #ifdef SIZEOF_VOID_P - enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; - #endif -#endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif -#ifndef __has_cpp_attribute - #define __has_cpp_attribute(x) 0 -#endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif -#endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) -#ifdef _MSC_VER - #ifndef _MSC_STDINT_H_ - #if _MSC_VER < 1300 - typedef unsigned char uint8_t; - typedef unsigned int uint32_t; - #else - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - #endif - #endif -#else - #include -#endif -#ifndef CYTHON_FALLTHROUGH - #if defined(__cplusplus) && __cplusplus >= 201103L - #if __has_cpp_attribute(fallthrough) - #define CYTHON_FALLTHROUGH [[fallthrough]] - #elif __has_cpp_attribute(clang::fallthrough) - #define CYTHON_FALLTHROUGH [[clang::fallthrough]] - #elif __has_cpp_attribute(gnu::fallthrough) - #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] - #endif - #endif - #ifndef CYTHON_FALLTHROUGH - #if __has_attribute(fallthrough) - #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) - #else - #define CYTHON_FALLTHROUGH - #endif - #endif - #if defined(__clang__ ) && defined(__apple_build_version__) - #if __apple_build_version__ < 7000000 - #undef CYTHON_FALLTHROUGH - #define CYTHON_FALLTHROUGH - #endif - #endif -#endif - -#ifndef CYTHON_INLINE - #if defined(__clang__) - #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) - #elif defined(__GNUC__) - #define CYTHON_INLINE __inline__ - #elif defined(_MSC_VER) - #define CYTHON_INLINE __inline - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_INLINE inline - #else - #define CYTHON_INLINE - #endif -#endif - -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) - #define Py_OptimizeFlag 0 -#endif -#define __PYX_BUILD_PY_SSIZE_T "n" -#define CYTHON_FORMAT_SSIZE_T "z" -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" -#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2 - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#else - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#endif - #define __Pyx_DefaultClassType PyType_Type -#endif -#ifndef Py_TPFLAGS_CHECKTYPES - #define Py_TPFLAGS_CHECKTYPES 0 -#endif -#ifndef Py_TPFLAGS_HAVE_INDEX - #define Py_TPFLAGS_HAVE_INDEX 0 -#endif -#ifndef Py_TPFLAGS_HAVE_NEWBUFFER - #define Py_TPFLAGS_HAVE_NEWBUFFER 0 -#endif -#ifndef Py_TPFLAGS_HAVE_FINALIZE - #define Py_TPFLAGS_HAVE_FINALIZE 0 -#endif -#ifndef METH_STACKLESS - #define METH_STACKLESS 0 -#endif -#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) - #ifndef METH_FASTCALL - #define METH_FASTCALL 0x80 - #endif - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); - typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, - Py_ssize_t nargs, PyObject *kwnames); -#else - #define __Pyx_PyCFunctionFast _PyCFunctionFast - #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords -#endif -#if CYTHON_FAST_PYCCALL -#define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) -#else -#define __Pyx_PyFastCFunction_Check(func) 0 -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) - #define PyObject_Malloc(s) PyMem_Malloc(s) - #define PyObject_Free(p) PyMem_Free(p) - #define PyObject_Realloc(p) PyMem_Realloc(p) -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 - #define PyMem_RawMalloc(n) PyMem_Malloc(n) - #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) - #define PyMem_RawFree(p) PyMem_Free(p) -#endif -#if CYTHON_COMPILING_IN_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) -#else - #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) -#endif -#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#elif PY_VERSION_HEX >= 0x03060000 - #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() -#elif PY_VERSION_HEX >= 0x03000000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#else - #define __Pyx_PyThreadState_Current _PyThreadState_Current -#endif -#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) -#include "pythread.h" -#define Py_tss_NEEDS_INIT 0 -typedef int Py_tss_t; -static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { - *key = PyThread_create_key(); - return 0; -} -static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { - Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); - *key = Py_tss_NEEDS_INIT; - return key; -} -static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { - PyObject_Free(key); -} -static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { - return *key != Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { - PyThread_delete_key(*key); - *key = Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { - return PyThread_set_key_value(*key, value); -} -static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { - return PyThread_get_key_value(*key); -} -#endif -#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) -#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) -#else -#define __Pyx_PyDict_NewPresized(n) PyDict_New() -#endif -#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS -#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) -#else -#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #if defined(PyUnicode_IS_READY) - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #else - #define __Pyx_PyUnicode_READY(op) (0) - #endif - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) - #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) - #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) - #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) - #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE) - #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) - #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) - #endif - #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) - #endif -#else - #define CYTHON_PEP393_ENABLED 0 - #define PyUnicode_1BYTE_KIND 1 - #define PyUnicode_2BYTE_KIND 2 - #define PyUnicode_4BYTE_KIND 4 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) -#endif -#if CYTHON_COMPILING_IN_PYPY - #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) -#else - #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ - PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) - #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) - #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) - #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) -#endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) - #define PyObject_ASCII(o) PyObject_Repr(o) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#ifndef PyObject_Unicode - #define PyObject_Unicode PyObject_Str -#endif -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#if PY_VERSION_HEX >= 0x030900A4 - #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) - #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) -#else - #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) - #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) -#endif -#if CYTHON_ASSUME_SAFE_MACROS - #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) -#else - #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) -#endif -#if CYTHON_USE_ASYNC_SLOTS - #if PY_VERSION_HEX >= 0x030500B1 - #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods - #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) - #else - #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef __Pyx_PyAsyncMethodsStruct - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; -#endif - -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES -#endif -#include -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) -#define __Pyx_truncl trunc -#else -#define __Pyx_truncl truncl -#endif - -#define __PYX_MARK_ERR_POS(f_index, lineno) \ - { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } -#define __PYX_ERR(f_index, lineno, Ln_error) \ - { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#define __PYX_HAVE__oh2004 -#define __PYX_HAVE_API__oh2004 -/* Early includes */ -#include -#include -#include "numpy/arrayobject.h" -#include "numpy/ndarrayobject.h" -#include "numpy/ndarraytypes.h" -#include "numpy/arrayscalars.h" -#include "numpy/ufuncobject.h" - - /* NumPy API declarations from "numpy/__init__.pxd" */ - -#include -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) -#define __PYX_DEFAULT_STRING_ENCODING "" -#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString -#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#define __Pyx_uchar_cast(c) ((unsigned char)c) -#define __Pyx_long_cast(x) ((long)x) -#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ - (sizeof(type) < sizeof(Py_ssize_t)) ||\ - (sizeof(type) > sizeof(Py_ssize_t) &&\ - likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX) &&\ - (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ - v == (type)PY_SSIZE_T_MIN))) ||\ - (sizeof(type) == sizeof(Py_ssize_t) &&\ - (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX))) ) -static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { - return (size_t) i < (size_t) limit; -} -#if defined (__cplusplus) && __cplusplus >= 201103L - #include - #define __Pyx_sst_abs(value) std::abs(value) -#elif SIZEOF_INT >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) abs(value) -#elif SIZEOF_LONG >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) labs(value) -#elif defined (_MSC_VER) - #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) -#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define __Pyx_sst_abs(value) llabs(value) -#elif defined (__GNUC__) - #define __Pyx_sst_abs(value) __builtin_llabs(value) -#else - #define __Pyx_sst_abs(value) ((value<0) ? -value : value) -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) -#define __Pyx_PyBytes_FromString PyBytes_FromString -#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) -#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) -#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) -#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) -#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); -#define __Pyx_PySequence_Tuple(obj)\ - (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -#if CYTHON_ASSUME_SAFE_MACROS -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) -#else -#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) -#endif -#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#endif - - -/* Test for GCC > 2.95 */ -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) -#else /* !__GNUC__ or GCC < 2.95 */ - #define likely(x) (x) - #define unlikely(x) (x) -#endif /* __GNUC__ */ -static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } - -static PyObject *__pyx_m = NULL; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime = NULL; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static PyObject *__pyx_empty_unicode; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - -/* Header.proto */ -#if !defined(CYTHON_CCOMPLEX) - #if defined(__cplusplus) - #define CYTHON_CCOMPLEX 1 - #elif defined(_Complex_I) - #define CYTHON_CCOMPLEX 1 - #else - #define CYTHON_CCOMPLEX 0 - #endif -#endif -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #include - #else - #include - #endif -#endif -#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) - #undef _Complex_I - #define _Complex_I 1.0fj -#endif - - -static const char *__pyx_f[] = { - "oh2004\\oh2004.pyx", - "__init__.pxd", - "type.pxd", -}; -/* BufferFormatStructs.proto */ -#define IS_UNSIGNED(type) (((type) -1) > 0) -struct __Pyx_StructField_; -#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) -typedef struct { - const char* name; - struct __Pyx_StructField_* fields; - size_t size; - size_t arraysize[8]; - int ndim; - char typegroup; - char is_unsigned; - int flags; -} __Pyx_TypeInfo; -typedef struct __Pyx_StructField_ { - __Pyx_TypeInfo* type; - const char* name; - size_t offset; -} __Pyx_StructField; -typedef struct { - __Pyx_StructField* field; - size_t parent_offset; -} __Pyx_BufFmt_StackElem; -typedef struct { - __Pyx_StructField root; - __Pyx_BufFmt_StackElem* head; - size_t fmt_offset; - size_t new_count, enc_count; - size_t struct_alignment; - int is_complex; - char enc_type; - char new_packmode; - char enc_packmode; - char is_valid_array; -} __Pyx_BufFmt_Context; - - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":690 - * # in Cython to enable them only on the right systems. - * - * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - */ -typedef npy_int8 __pyx_t_5numpy_int8_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":691 - * - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t - */ -typedef npy_int16 __pyx_t_5numpy_int16_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":692 - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< - * ctypedef npy_int64 int64_t - * #ctypedef npy_int96 int96_t - */ -typedef npy_int32 __pyx_t_5numpy_int32_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":693 - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< - * #ctypedef npy_int96 int96_t - * #ctypedef npy_int128 int128_t - */ -typedef npy_int64 __pyx_t_5numpy_int64_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":697 - * #ctypedef npy_int128 int128_t - * - * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - */ -typedef npy_uint8 __pyx_t_5numpy_uint8_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":698 - * - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t - */ -typedef npy_uint16 __pyx_t_5numpy_uint16_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":699 - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< - * ctypedef npy_uint64 uint64_t - * #ctypedef npy_uint96 uint96_t - */ -typedef npy_uint32 __pyx_t_5numpy_uint32_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":700 - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< - * #ctypedef npy_uint96 uint96_t - * #ctypedef npy_uint128 uint128_t - */ -typedef npy_uint64 __pyx_t_5numpy_uint64_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":704 - * #ctypedef npy_uint128 uint128_t - * - * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< - * ctypedef npy_float64 float64_t - * #ctypedef npy_float80 float80_t - */ -typedef npy_float32 __pyx_t_5numpy_float32_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":705 - * - * ctypedef npy_float32 float32_t - * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< - * #ctypedef npy_float80 float80_t - * #ctypedef npy_float128 float128_t - */ -typedef npy_float64 __pyx_t_5numpy_float64_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":714 - * # The int types are mapped a bit surprising -- - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t - */ -typedef npy_long __pyx_t_5numpy_int_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":715 - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong longlong_t - * - */ -typedef npy_longlong __pyx_t_5numpy_long_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":716 - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_ulong uint_t - */ -typedef npy_longlong __pyx_t_5numpy_longlong_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":718 - * ctypedef npy_longlong longlong_t - * - * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t - */ -typedef npy_ulong __pyx_t_5numpy_uint_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":719 - * - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulonglong_t - * - */ -typedef npy_ulonglong __pyx_t_5numpy_ulong_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":720 - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_intp intp_t - */ -typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":722 - * ctypedef npy_ulonglong ulonglong_t - * - * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< - * ctypedef npy_uintp uintp_t - * - */ -typedef npy_intp __pyx_t_5numpy_intp_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":723 - * - * ctypedef npy_intp intp_t - * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< - * - * ctypedef npy_double float_t - */ -typedef npy_uintp __pyx_t_5numpy_uintp_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":725 - * ctypedef npy_uintp uintp_t - * - * ctypedef npy_double float_t # <<<<<<<<<<<<<< - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t - */ -typedef npy_double __pyx_t_5numpy_float_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":726 - * - * ctypedef npy_double float_t - * ctypedef npy_double double_t # <<<<<<<<<<<<<< - * ctypedef npy_longdouble longdouble_t - * - */ -typedef npy_double __pyx_t_5numpy_double_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":727 - * ctypedef npy_double float_t - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cfloat cfloat_t - */ -typedef npy_longdouble __pyx_t_5numpy_longdouble_t; -/* Declarations.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< float > __pyx_t_float_complex; - #else - typedef float _Complex __pyx_t_float_complex; - #endif -#else - typedef struct { float real, imag; } __pyx_t_float_complex; -#endif -static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); - -/* Declarations.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< double > __pyx_t_double_complex; - #else - typedef double _Complex __pyx_t_double_complex; - #endif -#else - typedef struct { double real, imag; } __pyx_t_double_complex; -#endif -static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); - - -/*--- Type declarations ---*/ - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":729 - * ctypedef npy_longdouble longdouble_t - * - * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t - */ -typedef npy_cfloat __pyx_t_5numpy_cfloat_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":730 - * - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< - * ctypedef npy_clongdouble clongdouble_t - * - */ -typedef npy_cdouble __pyx_t_5numpy_cdouble_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":731 - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cdouble complex_t - */ -typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":733 - * ctypedef npy_clongdouble clongdouble_t - * - * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew1(a): - */ -typedef npy_cdouble __pyx_t_5numpy_complex_t; - -/* --- Runtime support code (head) --- */ -/* Refnanny.proto */ -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, const char*); - void (*FinishContext)(void**); - } __Pyx_RefNannyAPIStruct; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); - #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; -#ifdef WITH_THREAD - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - if (acquire_gil) {\ - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - PyGILState_Release(__pyx_gilstate_save);\ - } else {\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #define __Pyx_RefNannyFinishContext()\ - __Pyx_RefNanny->FinishContext(&__pyx_refnanny) - #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #define __Pyx_RefNannyFinishContext() - #define __Pyx_INCREF(r) Py_INCREF(r) - #define __Pyx_DECREF(r) Py_DECREF(r) - #define __Pyx_GOTREF(r) - #define __Pyx_GIVEREF(r) - #define __Pyx_XINCREF(r) Py_XINCREF(r) - #define __Pyx_XDECREF(r) Py_XDECREF(r) - #define __Pyx_XGOTREF(r) - #define __Pyx_XGIVEREF(r) -#endif -#define __Pyx_XDECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_XDECREF(tmp);\ - } while (0) -#define __Pyx_DECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_DECREF(tmp);\ - } while (0) -#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) -#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) - -/* PyObjectGetAttrStr.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -/* GetBuiltinName.proto */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name); - -/* PyDictVersioning.proto */ -#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS -#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) -#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) -#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ - (version_var) = __PYX_GET_DICT_VERSION(dict);\ - (cache_var) = (value); -#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ - static PY_UINT64_T __pyx_dict_version = 0;\ - static PyObject *__pyx_dict_cached_value = NULL;\ - if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ - (VAR) = __pyx_dict_cached_value;\ - } else {\ - (VAR) = __pyx_dict_cached_value = (LOOKUP);\ - __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ - }\ -} -static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); -static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); -static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); -#else -#define __PYX_GET_DICT_VERSION(dict) (0) -#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) -#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); -#endif - -/* GetModuleGlobalName.proto */ -#if CYTHON_USE_DICT_VERSIONS -#define __Pyx_GetModuleGlobalName(var, name) {\ - static PY_UINT64_T __pyx_dict_version = 0;\ - static PyObject *__pyx_dict_cached_value = NULL;\ - (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ - (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ - __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ -} -#define __Pyx_GetModuleGlobalNameUncached(var, name) {\ - PY_UINT64_T __pyx_dict_version;\ - PyObject *__pyx_dict_cached_value;\ - (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ -} -static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); -#else -#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) -#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) -static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); -#endif - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#define __Pyx_BUILD_ASSERT_EXPR(cond)\ - (sizeof(char [1 - 2*!(cond)]) - 1) -#ifndef Py_MEMBER_SIZE -#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) -#endif - static size_t __pyx_pyframe_localsplus_offset = 0; - #include "frameobject.h" - #define __Pxy_PyFrame_Initialize_Offsets()\ - ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ - (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) - #define __Pyx_PyFrame_GetLocalsplus(frame)\ - (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) -#endif - -/* PyObjectCall.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); -#else -#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) -#endif - -/* PyObjectCall2Args.proto */ -static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); - -/* PyObjectCallMethO.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); -#endif - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* ExtTypeTest.proto */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); - -/* IsLittleEndian.proto */ -static CYTHON_INLINE int __Pyx_Is_Little_Endian(void); - -/* BufferFormatCheck.proto */ -static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); -static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type); - -/* BufferGetAndValidate.proto */ -#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\ - ((obj == Py_None || obj == NULL) ?\ - (__Pyx_ZeroBuffer(buf), 0) :\ - __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)) -static int __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj, - __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); -static void __Pyx_ZeroBuffer(Py_buffer* buf); -static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); -static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - -/* BufferIndexError.proto */ -static void __Pyx_RaiseBufferIndexError(int axis); - -#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) -/* PyIntBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_SubtractCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); -#else -#define __Pyx_PyInt_SubtractCObj(op1, op2, intval, inplace, zerodivision_check)\ - (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2)) -#endif - -/* PyFloatBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyFloat_SubtractCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check); -#else -#define __Pyx_PyFloat_SubtractCObj(op1, op2, floatval, inplace, zerodivision_check)\ - (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2)) -#endif - -/* PyIntCompare.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace); - -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ - __Pyx_GetItemInt_Generic(o, to_py_func(i)))) -#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, - int is_list, int wraparound, int boundscheck); - -/* ObjectGetItem.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); -#else -#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) -#endif - -/* PyFloatBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyFloat_DivideObjC(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check); -#else -#define __Pyx_PyFloat_DivideObjC(op1, op2, floatval, inplace, zerodivision_check)\ - ((inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2))) - #endif - -/* PyFloatBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyFloat_AddCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check); -#else -#define __Pyx_PyFloat_AddCObj(op1, op2, floatval, inplace, zerodivision_check)\ - (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) -#endif - -/* PyThreadStateGet.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; -#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type -#else -#define __Pyx_PyThreadState_declare -#define __Pyx_PyThreadState_assign -#define __Pyx_PyErr_Occurred() PyErr_Occurred() -#endif - -/* PyErrFetchRestore.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) -#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) -#else -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#endif -#else -#define __Pyx_PyErr_Clear() PyErr_Clear() -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) -#endif - -/* RaiseArgTupleInvalid.proto */ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* WriteUnraisableException.proto */ -static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename, - int full_traceback, int nogil); - -/* BufferFallbackError.proto */ -static void __Pyx_RaiseBufferFallbackError(void); - -/* ArgTypeTest.proto */ -#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ - ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ - __Pyx__ArgTypeTest(obj, type, name, exact)) -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); - -/* GetTopmostException.proto */ -#if CYTHON_USE_EXC_INFO_STACK -static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); -#endif - -/* SaveResetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -#else -#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) -#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) -#endif - -/* PyErrExceptionMatches.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) -static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); -#else -#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) -#endif - -/* GetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); -#endif - -/* RaiseException.proto */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); - -/* TypeImport.proto */ -#ifndef __PYX_HAVE_RT_ImportType_proto -#define __PYX_HAVE_RT_ImportType_proto -enum __Pyx_ImportType_CheckSize { - __Pyx_ImportType_CheckSize_Error = 0, - __Pyx_ImportType_CheckSize_Warn = 1, - __Pyx_ImportType_CheckSize_Ignore = 2 -}; -static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size); -#endif - -/* Import.proto */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); - -/* ImportFrom.proto */ -static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); - -/* CLineInTraceback.proto */ -#ifdef CYTHON_CLINE_IN_TRACEBACK -#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) -#else -static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); -#endif - -/* CodeObjectCache.proto */ -typedef struct { - PyCodeObject* code_object; - int code_line; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -/* AddTraceback.proto */ -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); - -/* BufferStructDeclare.proto */ -typedef struct { - Py_ssize_t shape, strides, suboffsets; -} __Pyx_Buf_DimInfo; -typedef struct { - size_t refcount; - Py_buffer pybuffer; -} __Pyx_Buffer; -typedef struct { - __Pyx_Buffer *rcbuffer; - char *data; - __Pyx_Buf_DimInfo diminfo[8]; -} __Pyx_LocalBuf_ND; - -#if PY_MAJOR_VERSION < 3 - static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); - static void __Pyx_ReleaseBuffer(Py_buffer *view); -#else - #define __Pyx_GetBuffer PyObject_GetBuffer - #define __Pyx_ReleaseBuffer PyBuffer_Release -#endif - - -/* GCCDiagnostics.proto */ -#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) -#define __Pyx_HAS_GCC_DIAGNOSTIC -#endif - -/* RealImag.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #define __Pyx_CREAL(z) ((z).real()) - #define __Pyx_CIMAG(z) ((z).imag()) - #else - #define __Pyx_CREAL(z) (__real__(z)) - #define __Pyx_CIMAG(z) (__imag__(z)) - #endif -#else - #define __Pyx_CREAL(z) ((z).real) - #define __Pyx_CIMAG(z) ((z).imag) -#endif -#if defined(__cplusplus) && CYTHON_CCOMPLEX\ - && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) - #define __Pyx_SET_CREAL(z,x) ((z).real(x)) - #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) -#else - #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) - #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) -#endif - -/* Arithmetic.proto */ -#if CYTHON_CCOMPLEX - #define __Pyx_c_eq_float(a, b) ((a)==(b)) - #define __Pyx_c_sum_float(a, b) ((a)+(b)) - #define __Pyx_c_diff_float(a, b) ((a)-(b)) - #define __Pyx_c_prod_float(a, b) ((a)*(b)) - #define __Pyx_c_quot_float(a, b) ((a)/(b)) - #define __Pyx_c_neg_float(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zero_float(z) ((z)==(float)0) - #define __Pyx_c_conj_float(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_abs_float(z) (::std::abs(z)) - #define __Pyx_c_pow_float(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zero_float(z) ((z)==0) - #define __Pyx_c_conj_float(z) (conjf(z)) - #if 1 - #define __Pyx_c_abs_float(z) (cabsf(z)) - #define __Pyx_c_pow_float(a, b) (cpowf(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex); - static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex); - #if 1 - static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex); - #endif -#endif - -/* Arithmetic.proto */ -#if CYTHON_CCOMPLEX - #define __Pyx_c_eq_double(a, b) ((a)==(b)) - #define __Pyx_c_sum_double(a, b) ((a)+(b)) - #define __Pyx_c_diff_double(a, b) ((a)-(b)) - #define __Pyx_c_prod_double(a, b) ((a)*(b)) - #define __Pyx_c_quot_double(a, b) ((a)/(b)) - #define __Pyx_c_neg_double(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zero_double(z) ((z)==(double)0) - #define __Pyx_c_conj_double(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_abs_double(z) (::std::abs(z)) - #define __Pyx_c_pow_double(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zero_double(z) ((z)==0) - #define __Pyx_c_conj_double(z) (conj(z)) - #if 1 - #define __Pyx_c_abs_double(z) (cabs(z)) - #define __Pyx_c_pow_double(a, b) (cpow(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex); - static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex); - #if 1 - static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex); - #endif -#endif - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -/* FastTypeChecks.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); -#else -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) -#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) -#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) -#endif -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) - -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* InitStrings.proto */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); - - -/* Module declarations from 'cython' */ - -/* Module declarations from 'cpython.buffer' */ - -/* Module declarations from 'libc.string' */ - -/* Module declarations from 'libc.stdio' */ - -/* Module declarations from '__builtin__' */ - -/* Module declarations from 'cpython.type' */ -static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; - -/* Module declarations from 'cpython' */ - -/* Module declarations from 'cpython.object' */ - -/* Module declarations from 'cpython.ref' */ - -/* Module declarations from 'cpython.mem' */ - -/* Module declarations from 'numpy' */ - -/* Module declarations from 'numpy' */ -static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; -static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; -static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; -static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; -static PyTypeObject *__pyx_ptype_5numpy_generic = 0; -static PyTypeObject *__pyx_ptype_5numpy_number = 0; -static PyTypeObject *__pyx_ptype_5numpy_integer = 0; -static PyTypeObject *__pyx_ptype_5numpy_signedinteger = 0; -static PyTypeObject *__pyx_ptype_5numpy_unsignedinteger = 0; -static PyTypeObject *__pyx_ptype_5numpy_inexact = 0; -static PyTypeObject *__pyx_ptype_5numpy_floating = 0; -static PyTypeObject *__pyx_ptype_5numpy_complexfloating = 0; -static PyTypeObject *__pyx_ptype_5numpy_flexible = 0; -static PyTypeObject *__pyx_ptype_5numpy_character = 0; -static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; - -/* Module declarations from 'libc.math' */ - -/* Module declarations from 'oh2004' */ -static PyArrayObject *__pyx_f_6oh2004_inverse_oh2004(double, double, double, double, double, int __pyx_skip_dispatch); /*proto*/ -static double __pyx_f_6oh2004_lamda2freq(double, int __pyx_skip_dispatch); /*proto*/ -static double __pyx_f_6oh2004_freq2lamda(double, int __pyx_skip_dispatch); /*proto*/ -static int __pyx_f_6oh2004_retrieve_oh2004_main(int, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, double, int __pyx_skip_dispatch); /*proto*/ -static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 }; -static __Pyx_TypeInfo __Pyx_TypeInfo_int = { "int", NULL, sizeof(int), { 0 }, 0, IS_UNSIGNED(int) ? 'U' : 'I', IS_UNSIGNED(int), 0 }; -#define __Pyx_MODULE_NAME "oh2004" -extern int __pyx_module_is_main_oh2004; -int __pyx_module_is_main_oh2004 = 0; - -/* Implementation of 'oh2004' */ -static PyObject *__pyx_builtin_ImportError; -static const char __pyx_k_f[] = "f"; -static const char __pyx_k_h[] = "h"; -static const char __pyx_k_n[] = "n"; -static const char __pyx_k_mv[] = "mv"; -static const char __pyx_k_np[] = "np"; -static const char __pyx_k_pi[] = "pi"; -static const char __pyx_k_vh[] = "vh"; -static const char __pyx_k_abs[] = "abs"; -static const char __pyx_k_cos[] = "cos"; -static const char __pyx_k_exp[] = "exp"; -static const char __pyx_k_log[] = "log"; -static const char __pyx_k_max[] = "max"; -static const char __pyx_k_nan[] = "nan"; -static const char __pyx_k_sin[] = "sin"; -static const char __pyx_k_fmin[] = "fmin"; -static const char __pyx_k_freq[] = "freq"; -static const char __pyx_k_main[] = "__main__"; -static const char __pyx_k_mask[] = "mask"; -static const char __pyx_k_name[] = "__name__"; -static const char __pyx_k_ones[] = "ones"; -static const char __pyx_k_test[] = "__test__"; -static const char __pyx_k_lamda[] = "lamda"; -static const char __pyx_k_numpy[] = "numpy"; -static const char __pyx_k_power[] = "power"; -static const char __pyx_k_shape[] = "shape"; -static const char __pyx_k_theta[] = "theta"; -static const char __pyx_k_where[] = "where"; -static const char __pyx_k_arange[] = "arange"; -static const char __pyx_k_import[] = "__import__"; -static const char __pyx_k_nanmin[] = "nanmin"; -static const char __pyx_k_sigma0hhdB[] = "sigma0hhdB"; -static const char __pyx_k_sigma0hvdB[] = "sigma0hvdB"; -static const char __pyx_k_sigma0vvdB[] = "sigma0vvdB"; -static const char __pyx_k_ImportError[] = "ImportError"; -static const char __pyx_k_scipy_optimize[] = "scipy.optimize"; -static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; -static const char __pyx_k_Created_on_Tue_Jun_4_14_59_54_2[] = "\nCreated on Tue Jun 4 14:59:54 2013\n\n@author: Sat Kumar Tomer\n@email: satkumartomer@gmail.com\n@website: www.ambhas.com\n\n"; -static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import"; -static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import"; -static PyObject *__pyx_n_s_ImportError; -static PyObject *__pyx_n_s_abs; -static PyObject *__pyx_n_s_arange; -static PyObject *__pyx_n_s_cline_in_traceback; -static PyObject *__pyx_n_s_cos; -static PyObject *__pyx_n_s_exp; -static PyObject *__pyx_n_s_f; -static PyObject *__pyx_n_s_fmin; -static PyObject *__pyx_n_s_freq; -static PyObject *__pyx_n_s_h; -static PyObject *__pyx_n_s_import; -static PyObject *__pyx_n_s_lamda; -static PyObject *__pyx_n_s_log; -static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_mask; -static PyObject *__pyx_n_s_max; -static PyObject *__pyx_n_s_mv; -static PyObject *__pyx_n_s_n; -static PyObject *__pyx_n_s_name; -static PyObject *__pyx_n_s_nan; -static PyObject *__pyx_n_s_nanmin; -static PyObject *__pyx_n_s_np; -static PyObject *__pyx_n_s_numpy; -static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to; -static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor; -static PyObject *__pyx_n_s_ones; -static PyObject *__pyx_n_s_pi; -static PyObject *__pyx_n_s_power; -static PyObject *__pyx_n_s_scipy_optimize; -static PyObject *__pyx_n_s_shape; -static PyObject *__pyx_n_s_sigma0hhdB; -static PyObject *__pyx_n_s_sigma0hvdB; -static PyObject *__pyx_n_s_sigma0vvdB; -static PyObject *__pyx_n_s_sin; -static PyObject *__pyx_n_s_test; -static PyObject *__pyx_n_s_theta; -static PyObject *__pyx_n_s_vh; -static PyObject *__pyx_n_s_where; -static PyObject *__pyx_pf_6oh2004_inverse_oh2004(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_sigma0vvdB, double __pyx_v_sigma0hhdB, double __pyx_v_sigma0hvdB, double __pyx_v_theta, double __pyx_v_f); /* proto */ -static PyObject *__pyx_pf_6oh2004_2lamda2freq(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_lamda); /* proto */ -static PyObject *__pyx_pf_6oh2004_4freq2lamda(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_freq); /* proto */ -static PyObject *__pyx_pf_6oh2004_6retrieve_oh2004_main(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n, PyArrayObject *__pyx_v_mv, PyArrayObject *__pyx_v_h, PyArrayObject *__pyx_v_mask, PyArrayObject *__pyx_v_sigma0vvdB, PyArrayObject *__pyx_v_sigma0hhdB, PyArrayObject *__pyx_v_sigma0hvdB, PyArrayObject *__pyx_v_vh, PyArrayObject *__pyx_v_theta, double __pyx_v_f); /* proto */ -static PyObject *__pyx_float_1_; -static PyObject *__pyx_float_0_7; -static PyObject *__pyx_float_0_9; -static PyObject *__pyx_float_1_4; -static PyObject *__pyx_float_10_; -static PyObject *__pyx_float_2_2; -static PyObject *__pyx_float_0_01; -static PyObject *__pyx_float_0_05; -static PyObject *__pyx_float_0_11; -static PyObject *__pyx_float_0_13; -static PyObject *__pyx_float_0_35; -static PyObject *__pyx_float_0_095; -static PyObject *__pyx_float_0_556; -static PyObject *__pyx_float_neg_0_4; -static PyObject *__pyx_float_neg_1_3; -static PyObject *__pyx_float_neg_0_65; -static PyObject *__pyx_int_0; -static PyObject *__pyx_int_1; -static PyObject *__pyx_int_2; -static PyObject *__pyx_tuple_; -static PyObject *__pyx_tuple__2; -static PyObject *__pyx_tuple__3; -/* Late includes */ - -/* "oh2004.pyx":16 - * from scipy.optimize import fmin - * - * cpdef np.ndarray[double,ndim=1] inverse_oh2004(double sigma0vvdB,double sigma0hhdB,double sigma0hvdB,double theta,double f): # <<<<<<<<<<<<<< - * """ - * sigma0vvdB = -14.1 dB - */ - -static PyObject *__pyx_pw_6oh2004_1inverse_oh2004(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyArrayObject *__pyx_f_6oh2004_inverse_oh2004(double __pyx_v_sigma0vvdB, double __pyx_v_sigma0hhdB, double __pyx_v_sigma0hvdB, double __pyx_v_theta, double __pyx_v_f, CYTHON_UNUSED int __pyx_skip_dispatch) { - PyArrayObject *__pyx_v_result = 0; - double __pyx_v_k; - double __pyx_v_theta_rad; - double __pyx_v_sigma_0_vv; - double __pyx_v_sigma_0_hh; - double __pyx_v_sigma_0_hv; - double __pyx_v_p; - double __pyx_v_q; - PyArrayObject *__pyx_v_mv0 = 0; - PyArrayObject *__pyx_v_ks = 0; - PyArrayObject *__pyx_v_err = 0; - PyArrayObject *__pyx_v_abs_err = 0; - double __pyx_v_min_err; - double __pyx_v_mv1; - double __pyx_v_temp_ks1; - double __pyx_v_ks1; - double __pyx_v_s1; - double __pyx_v_ks2; - double __pyx_v_s2; - double __pyx_v_mv2; - double __pyx_v_yy; - double __pyx_v_xx; - double __pyx_v_mv3; - double __pyx_v_sf; - double __pyx_v_mvf; - __Pyx_LocalBuf_ND __pyx_pybuffernd_abs_err; - __Pyx_Buffer __pyx_pybuffer_abs_err; - __Pyx_LocalBuf_ND __pyx_pybuffernd_err; - __Pyx_Buffer __pyx_pybuffer_err; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ks; - __Pyx_Buffer __pyx_pybuffer_ks; - __Pyx_LocalBuf_ND __pyx_pybuffernd_mv0; - __Pyx_Buffer __pyx_pybuffer_mv0; - __Pyx_LocalBuf_ND __pyx_pybuffernd_result; - __Pyx_Buffer __pyx_pybuffer_result; - PyArrayObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyArrayObject *__pyx_t_4 = NULL; - double __pyx_t_5; - Py_ssize_t __pyx_t_6; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - int __pyx_t_10; - PyArrayObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - PyObject *__pyx_t_14 = NULL; - PyObject *__pyx_t_15 = NULL; - PyArrayObject *__pyx_t_16 = NULL; - PyArrayObject *__pyx_t_17 = NULL; - PyArrayObject *__pyx_t_18 = NULL; - int __pyx_t_19; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("inverse_oh2004", 0); - __pyx_pybuffer_result.pybuffer.buf = NULL; - __pyx_pybuffer_result.refcount = 0; - __pyx_pybuffernd_result.data = NULL; - __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result; - __pyx_pybuffer_mv0.pybuffer.buf = NULL; - __pyx_pybuffer_mv0.refcount = 0; - __pyx_pybuffernd_mv0.data = NULL; - __pyx_pybuffernd_mv0.rcbuffer = &__pyx_pybuffer_mv0; - __pyx_pybuffer_ks.pybuffer.buf = NULL; - __pyx_pybuffer_ks.refcount = 0; - __pyx_pybuffernd_ks.data = NULL; - __pyx_pybuffernd_ks.rcbuffer = &__pyx_pybuffer_ks; - __pyx_pybuffer_err.pybuffer.buf = NULL; - __pyx_pybuffer_err.refcount = 0; - __pyx_pybuffernd_err.data = NULL; - __pyx_pybuffernd_err.rcbuffer = &__pyx_pybuffer_err; - __pyx_pybuffer_abs_err.pybuffer.buf = NULL; - __pyx_pybuffer_abs_err.refcount = 0; - __pyx_pybuffernd_abs_err.data = NULL; - __pyx_pybuffernd_abs_err.rcbuffer = &__pyx_pybuffer_abs_err; - - /* "oh2004.pyx":25 - * """ - * #print("--------------------------------------------------------\n") - * cdef np.ndarray[double,ndim=1] result=np.ones((2)) # <<<<<<<<<<<<<< - * result[0]=np.nan - * result[1]=np.nan - */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ones); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_int_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_int_2); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 25, __pyx_L1_error) - __pyx_t_4 = ((PyArrayObject *)__pyx_t_1); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { - __pyx_v_result = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_result.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 25, __pyx_L1_error) - } else {__pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_4 = 0; - __pyx_v_result = ((PyArrayObject *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "oh2004.pyx":26 - * #print("--------------------------------------------------------\n") - * cdef np.ndarray[double,ndim=1] result=np.ones((2)) - * result[0]=np.nan # <<<<<<<<<<<<<< - * result[1]=np.nan - * #print("*************nan****************") - */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 26, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 26, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = 0; - __pyx_t_7 = -1; - if (__pyx_t_6 < 0) { - __pyx_t_6 += __pyx_pybuffernd_result.diminfo[0].shape; - if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 0; - } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_7 = 0; - if (unlikely(__pyx_t_7 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 26, __pyx_L1_error) - } - *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_t_5; - - /* "oh2004.pyx":27 - * cdef np.ndarray[double,ndim=1] result=np.ones((2)) - * result[0]=np.nan - * result[1]=np.nan # <<<<<<<<<<<<<< - * #print("*************nan****************") - * #print(sigma0vvdB,sigma0hhdB,sigma0hvdB,theta,f) - */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_nan); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = 1; - __pyx_t_7 = -1; - if (__pyx_t_6 < 0) { - __pyx_t_6 += __pyx_pybuffernd_result.diminfo[0].shape; - if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 0; - } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_7 = 0; - if (unlikely(__pyx_t_7 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 27, __pyx_L1_error) - } - *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_result.diminfo[0].strides) = __pyx_t_5; - - /* "oh2004.pyx":30 - * #print("*************nan****************") - * #print(sigma0vvdB,sigma0hhdB,sigma0hvdB,theta,f) - * cdef double k = 2*3.1415926*f/0.299792458; #calculate the wave number # <<<<<<<<<<<<<< - * cdef double theta_rad = theta*3.1415926/180; #represent angle in radians - * - */ - __pyx_v_k = (((2.0 * 3.1415926) * __pyx_v_f) / 0.299792458); - - /* "oh2004.pyx":31 - * #print(sigma0vvdB,sigma0hhdB,sigma0hvdB,theta,f) - * cdef double k = 2*3.1415926*f/0.299792458; #calculate the wave number - * cdef double theta_rad = theta*3.1415926/180; #represent angle in radians # <<<<<<<<<<<<<< - * - * cdef double sigma_0_vv = np.power(10.,(sigma0vvdB/10.)) #%represent data in linear scale - */ - __pyx_v_theta_rad = ((__pyx_v_theta * 3.1415926) / 180.0); - - /* "oh2004.pyx":33 - * cdef double theta_rad = theta*3.1415926/180; #represent angle in radians - * - * cdef double sigma_0_vv = np.power(10.,(sigma0vvdB/10.)) #%represent data in linear scale # <<<<<<<<<<<<<< - * cdef double sigma_0_hh = np.power(10.,(sigma0hhdB/10.)) - * cdef double sigma_0_hv = np.power(10.,(sigma0hvdB/10.)) - */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_power); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyFloat_FromDouble((__pyx_v_sigma0vvdB / 10.)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_float_10_, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_float_10_, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_8) { - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL; - } - __Pyx_INCREF(__pyx_float_10_); - __Pyx_GIVEREF(__pyx_float_10_); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_7, __pyx_float_10_); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_7, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_sigma_0_vv = __pyx_t_5; - - /* "oh2004.pyx":34 - * - * cdef double sigma_0_vv = np.power(10.,(sigma0vvdB/10.)) #%represent data in linear scale - * cdef double sigma_0_hh = np.power(10.,(sigma0hhdB/10.)) # <<<<<<<<<<<<<< - * cdef double sigma_0_hv = np.power(10.,(sigma0hvdB/10.)) - * - */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_power); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyFloat_FromDouble((__pyx_v_sigma0hhdB / 10.)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_9, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_9)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_float_10_, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_float_10_, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL; - } - __Pyx_INCREF(__pyx_float_10_); - __Pyx_GIVEREF(__pyx_float_10_); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_float_10_); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 34, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_sigma_0_hh = __pyx_t_5; - - /* "oh2004.pyx":35 - * cdef double sigma_0_vv = np.power(10.,(sigma0vvdB/10.)) #%represent data in linear scale - * cdef double sigma_0_hh = np.power(10.,(sigma0hhdB/10.)) - * cdef double sigma_0_hv = np.power(10.,(sigma0hvdB/10.)) # <<<<<<<<<<<<<< - * - * if sigma_0_vv==0: - */ - __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_power); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyFloat_FromDouble((__pyx_v_sigma0hvdB / 10.)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_2 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_8, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_8)) { - PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_float_10_, __pyx_t_9}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { - PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_float_10_, __pyx_t_9}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - { - __pyx_t_3 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (__pyx_t_2) { - __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL; - } - __Pyx_INCREF(__pyx_float_10_); - __Pyx_GIVEREF(__pyx_float_10_); - PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_float_10_); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_sigma_0_hv = __pyx_t_5; - - /* "oh2004.pyx":37 - * cdef double sigma_0_hv = np.power(10.,(sigma0hvdB/10.)) - * - * if sigma_0_vv==0: # <<<<<<<<<<<<<< - * #print("***********sigma_0_vv==0*************") - * return result - */ - __pyx_t_10 = ((__pyx_v_sigma_0_vv == 0.0) != 0); - if (__pyx_t_10) { - - /* "oh2004.pyx":39 - * if sigma_0_vv==0: - * #print("***********sigma_0_vv==0*************") - * return result # <<<<<<<<<<<<<< - * cdef double p = sigma_0_hh / sigma_0_vv; #calculate the p-ratio - * cdef double q = sigma_0_hv / sigma_0_vv; #calculate the q-ratio - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyArrayObject *)__pyx_v_result); - goto __pyx_L0; - - /* "oh2004.pyx":37 - * cdef double sigma_0_hv = np.power(10.,(sigma0hvdB/10.)) - * - * if sigma_0_vv==0: # <<<<<<<<<<<<<< - * #print("***********sigma_0_vv==0*************") - * return result - */ - } - - /* "oh2004.pyx":40 - * #print("***********sigma_0_vv==0*************") - * return result - * cdef double p = sigma_0_hh / sigma_0_vv; #calculate the p-ratio # <<<<<<<<<<<<<< - * cdef double q = sigma_0_hv / sigma_0_vv; #calculate the q-ratio - * - */ - if (unlikely(__pyx_v_sigma_0_vv == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division"); - __PYX_ERR(0, 40, __pyx_L1_error) - } - __pyx_v_p = (__pyx_v_sigma_0_hh / __pyx_v_sigma_0_vv); - - /* "oh2004.pyx":41 - * return result - * cdef double p = sigma_0_hh / sigma_0_vv; #calculate the p-ratio - * cdef double q = sigma_0_hv / sigma_0_vv; #calculate the q-ratio # <<<<<<<<<<<<<< - * - * - */ - if (unlikely(__pyx_v_sigma_0_vv == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division"); - __PYX_ERR(0, 41, __pyx_L1_error) - } - __pyx_v_q = (__pyx_v_sigma_0_hv / __pyx_v_sigma_0_vv); - - /* "oh2004.pyx":44 - * - * - * cdef np.ndarray[double,ndim=1] mv0 = np.arange(0.05,0.9,0.01) # set Gamma0 range of values (fine increments) # <<<<<<<<<<<<<< - * - * ## First estimates s1 and mv1 - */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_arange); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 44, __pyx_L1_error) - __pyx_t_11 = ((PyArrayObject *)__pyx_t_1); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mv0.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_mv0 = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_mv0.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 44, __pyx_L1_error) - } else {__pyx_pybuffernd_mv0.diminfo[0].strides = __pyx_pybuffernd_mv0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mv0.diminfo[0].shape = __pyx_pybuffernd_mv0.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_11 = 0; - __pyx_v_mv0 = ((PyArrayObject *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "oh2004.pyx":47 - * - * ## First estimates s1 and mv1 - * cdef np.ndarray[double,ndim=1] ks = ((-1.)*3.125*np.log(1 - sigma_0_hv/(0.11 * mv0**0.7 * (np.cos(theta_rad))**2.2)))**0.556 # <<<<<<<<<<<<<< - * cdef np.ndarray[double,ndim=1] err = (1. - (2.*theta_rad/np.pi)**(0.35*mv0**(-0.65)) * np.exp(-0.4 * ks**1.4))-p - * cdef np.ndarray[double,ndim=1] abs_err = np.abs(err); - */ - __pyx_t_1 = PyFloat_FromDouble((-1. * 3.125)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_log); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_sigma_0_hv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyNumber_Power(((PyObject *)__pyx_v_mv0), __pyx_float_0_7, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_12 = PyNumber_Multiply(__pyx_float_0_11, __pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_np); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_cos); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __pyx_t_13 = PyFloat_FromDouble(__pyx_v_theta_rad); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __pyx_t_15 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) { - __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14); - if (likely(__pyx_t_15)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); - __Pyx_INCREF(__pyx_t_15); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_14, function); - } - } - __pyx_t_2 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_15, __pyx_t_13) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_13); - __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyNumber_Power(__pyx_t_2, __pyx_float_2_2, Py_None); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_Multiply(__pyx_t_12, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_t_14, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { - __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_9); - if (likely(__pyx_t_14)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); - __Pyx_INCREF(__pyx_t_14); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_9, function); - } - } - __pyx_t_8 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_14, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2); - __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Multiply(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyNumber_Power(__pyx_t_9, __pyx_float_0_556, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 47, __pyx_L1_error) - __pyx_t_16 = ((PyArrayObject *)__pyx_t_8); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ks.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_ks = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ks.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 47, __pyx_L1_error) - } else {__pyx_pybuffernd_ks.diminfo[0].strides = __pyx_pybuffernd_ks.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ks.diminfo[0].shape = __pyx_pybuffernd_ks.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_16 = 0; - __pyx_v_ks = ((PyArrayObject *)__pyx_t_8); - __pyx_t_8 = 0; - - /* "oh2004.pyx":48 - * ## First estimates s1 and mv1 - * cdef np.ndarray[double,ndim=1] ks = ((-1.)*3.125*np.log(1 - sigma_0_hv/(0.11 * mv0**0.7 * (np.cos(theta_rad))**2.2)))**0.556 - * cdef np.ndarray[double,ndim=1] err = (1. - (2.*theta_rad/np.pi)**(0.35*mv0**(-0.65)) * np.exp(-0.4 * ks**1.4))-p # <<<<<<<<<<<<<< - * cdef np.ndarray[double,ndim=1] abs_err = np.abs(err); - * cdef double min_err = np.nanmin(abs_err); #find the value of minimum error - */ - __pyx_t_8 = PyFloat_FromDouble((2. * __pyx_v_theta_rad)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_pi); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Power(((PyObject *)__pyx_v_mv0), __pyx_float_neg_0_65, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyNumber_Multiply(__pyx_float_0_35, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Power(__pyx_t_9, __pyx_t_8, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_exp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Power(((PyObject *)__pyx_v_ks), __pyx_float_1_4, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_14 = PyNumber_Multiply(__pyx_float_neg_0_4, __pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - __pyx_t_8 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_9, __pyx_t_14) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_14); - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyFloat_SubtractCObj(__pyx_float_1_, __pyx_t_2, 1., 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_p); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyNumber_Subtract(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 48, __pyx_L1_error) - __pyx_t_17 = ((PyArrayObject *)__pyx_t_1); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_err.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_err = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_err.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 48, __pyx_L1_error) - } else {__pyx_pybuffernd_err.diminfo[0].strides = __pyx_pybuffernd_err.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_err.diminfo[0].shape = __pyx_pybuffernd_err.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_17 = 0; - __pyx_v_err = ((PyArrayObject *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "oh2004.pyx":49 - * cdef np.ndarray[double,ndim=1] ks = ((-1.)*3.125*np.log(1 - sigma_0_hv/(0.11 * mv0**0.7 * (np.cos(theta_rad))**2.2)))**0.556 - * cdef np.ndarray[double,ndim=1] err = (1. - (2.*theta_rad/np.pi)**(0.35*mv0**(-0.65)) * np.exp(-0.4 * ks**1.4))-p - * cdef np.ndarray[double,ndim=1] abs_err = np.abs(err); # <<<<<<<<<<<<<< - * cdef double min_err = np.nanmin(abs_err); #find the value of minimum error - * #print(np.where(abs_err == min_err)[0].shape) - */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_abs); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_8, function); - } - } - __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_2, ((PyObject *)__pyx_v_err)) : __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)__pyx_v_err)); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 49, __pyx_L1_error) - __pyx_t_18 = ((PyArrayObject *)__pyx_t_1); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_abs_err.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_abs_err = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_abs_err.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 49, __pyx_L1_error) - } else {__pyx_pybuffernd_abs_err.diminfo[0].strides = __pyx_pybuffernd_abs_err.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_abs_err.diminfo[0].shape = __pyx_pybuffernd_abs_err.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_18 = 0; - __pyx_v_abs_err = ((PyArrayObject *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "oh2004.pyx":50 - * cdef np.ndarray[double,ndim=1] err = (1. - (2.*theta_rad/np.pi)**(0.35*mv0**(-0.65)) * np.exp(-0.4 * ks**1.4))-p - * cdef np.ndarray[double,ndim=1] abs_err = np.abs(err); - * cdef double min_err = np.nanmin(abs_err); #find the value of minimum error # <<<<<<<<<<<<<< - * #print(np.where(abs_err == min_err)[0].shape) - * if min_err==np.nan or np.max(np.where(abs_err == min_err)[0].shape)==0 : - */ - __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 50, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_nanmin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_8, ((PyObject *)__pyx_v_abs_err)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_abs_err)); - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 50, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_min_err = __pyx_t_5; - - /* "oh2004.pyx":52 - * cdef double min_err = np.nanmin(abs_err); #find the value of minimum error - * #print(np.where(abs_err == min_err)[0].shape) - * if min_err==np.nan or np.max(np.where(abs_err == min_err)[0].shape)==0 : # <<<<<<<<<<<<<< - * #print("***************min_err==np.nan or np.max(np.where(abs_err == min_err)[0].shape)==0") - * return result - */ - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_min_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_nan); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_8, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (!__pyx_t_19) { - } else { - __pyx_t_10 = __pyx_t_19; - goto __pyx_L5_bool_binop_done; - } - __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_max); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_where); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyFloat_FromDouble(__pyx_v_min_err); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_abs_err), __pyx_t_14, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { - __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_9); - if (likely(__pyx_t_14)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); - __Pyx_INCREF(__pyx_t_14); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_9, function); - } - } - __pyx_t_8 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_14, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); - __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_2 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_t_2, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_10 = __pyx_t_19; - __pyx_L5_bool_binop_done:; - if (__pyx_t_10) { - - /* "oh2004.pyx":54 - * if min_err==np.nan or np.max(np.where(abs_err == min_err)[0].shape)==0 : - * #print("***************min_err==np.nan or np.max(np.where(abs_err == min_err)[0].shape)==0") - * return result # <<<<<<<<<<<<<< - * cdef double mv1 = mv0[np.where(abs_err == min_err)[0][0]] - * cdef double temp_ks1=1. - sigma_0_hv/(0.11 * mv1**0.7 * (np.cos(theta_rad))**2.2) - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyArrayObject *)__pyx_v_result); - goto __pyx_L0; - - /* "oh2004.pyx":52 - * cdef double min_err = np.nanmin(abs_err); #find the value of minimum error - * #print(np.where(abs_err == min_err)[0].shape) - * if min_err==np.nan or np.max(np.where(abs_err == min_err)[0].shape)==0 : # <<<<<<<<<<<<<< - * #print("***************min_err==np.nan or np.max(np.where(abs_err == min_err)[0].shape)==0") - * return result - */ - } - - /* "oh2004.pyx":55 - * #print("***************min_err==np.nan or np.max(np.where(abs_err == min_err)[0].shape)==0") - * return result - * cdef double mv1 = mv0[np.where(abs_err == min_err)[0][0]] # <<<<<<<<<<<<<< - * cdef double temp_ks1=1. - sigma_0_hv/(0.11 * mv1**0.7 * (np.cos(theta_rad))**2.2) - * if temp_ks1<0: - */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_where); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_min_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = PyObject_RichCompare(((PyObject *)__pyx_v_abs_err), __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_8, function); - } - } - __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_2, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_1, 0, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_8, 0, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_mv0), __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_8); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_v_mv1 = __pyx_t_5; - - /* "oh2004.pyx":56 - * return result - * cdef double mv1 = mv0[np.where(abs_err == min_err)[0][0]] - * cdef double temp_ks1=1. - sigma_0_hv/(0.11 * mv1**0.7 * (np.cos(theta_rad))**2.2) # <<<<<<<<<<<<<< - * if temp_ks1<0: - * #print("*********************temp_ks1<0") - */ - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_sigma_0_hv); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_1 = PyFloat_FromDouble((0.11 * pow(__pyx_v_mv1, 0.7))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_cos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_theta_rad); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_14 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_14)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_14); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - __pyx_t_9 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_14, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); - __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Power(__pyx_t_9, __pyx_float_2_2, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Multiply(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyFloat_SubtractCObj(__pyx_float_1_, __pyx_t_3, 1., 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_v_temp_ks1 = __pyx_t_5; - - /* "oh2004.pyx":57 - * cdef double mv1 = mv0[np.where(abs_err == min_err)[0][0]] - * cdef double temp_ks1=1. - sigma_0_hv/(0.11 * mv1**0.7 * (np.cos(theta_rad))**2.2) - * if temp_ks1<0: # <<<<<<<<<<<<<< - * #print("*********************temp_ks1<0") - * return result - */ - __pyx_t_10 = ((__pyx_v_temp_ks1 < 0.0) != 0); - if (__pyx_t_10) { - - /* "oh2004.pyx":59 - * if temp_ks1<0: - * #print("*********************temp_ks1<0") - * return result # <<<<<<<<<<<<<< - * cdef double ks1 = ((-1)*3.125*np.log(temp_ks1))**0.556 - * cdef double s1 = ks1/k - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyArrayObject *)__pyx_v_result); - goto __pyx_L0; - - /* "oh2004.pyx":57 - * cdef double mv1 = mv0[np.where(abs_err == min_err)[0][0]] - * cdef double temp_ks1=1. - sigma_0_hv/(0.11 * mv1**0.7 * (np.cos(theta_rad))**2.2) - * if temp_ks1<0: # <<<<<<<<<<<<<< - * #print("*********************temp_ks1<0") - * return result - */ - } - - /* "oh2004.pyx":60 - * #print("*********************temp_ks1<0") - * return result - * cdef double ks1 = ((-1)*3.125*np.log(temp_ks1))**0.556 # <<<<<<<<<<<<<< - * cdef double s1 = ks1/k - * - */ - __pyx_t_9 = PyFloat_FromDouble((-1.0 * 3.125)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_temp_ks1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Multiply(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Power(__pyx_t_1, __pyx_float_0_556, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_ks1 = __pyx_t_5; - - /* "oh2004.pyx":61 - * return result - * cdef double ks1 = ((-1)*3.125*np.log(temp_ks1))**0.556 - * cdef double s1 = ks1/k # <<<<<<<<<<<<<< - * - * ## Second estimate s2 and mv2 - */ - if (unlikely(__pyx_v_k == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division"); - __PYX_ERR(0, 61, __pyx_L1_error) - } - __pyx_v_s1 = (__pyx_v_ks1 / __pyx_v_k); - - /* "oh2004.pyx":64 - * - * ## Second estimate s2 and mv2 - * cdef double ks2 = (np.log(1-(q/(0.095 * (0.13 + np.sin(1.5*theta_rad))**1.4))) /(-1.3))**(10./9.) # <<<<<<<<<<<<<< - * cdef double s2 = ks2/k - * cdef double mv2 =0. - */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_log); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_q); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sin); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyFloat_FromDouble((1.5 * __pyx_v_theta_rad)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_12 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) { - __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_14); - if (likely(__pyx_t_12)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); - __Pyx_INCREF(__pyx_t_12); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_14, function); - } - } - __pyx_t_8 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_12, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_2); - __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = __Pyx_PyFloat_AddCObj(__pyx_float_0_13, __pyx_t_8, 0.13, 0, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyNumber_Power(__pyx_t_14, __pyx_float_1_4, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyNumber_Multiply(__pyx_float_0_095, __pyx_t_8); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_14); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_t_8, 1, 0, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_9, function); - } - } - __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_8, __pyx_t_14) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_14); - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyFloat_DivideObjC(__pyx_t_3, __pyx_float_neg_1_3, -1.3, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyFloat_FromDouble((10. / 9.)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_14 = PyNumber_Power(__pyx_t_9, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_14); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 64, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_v_ks2 = __pyx_t_5; - - /* "oh2004.pyx":65 - * ## Second estimate s2 and mv2 - * cdef double ks2 = (np.log(1-(q/(0.095 * (0.13 + np.sin(1.5*theta_rad))**1.4))) /(-1.3))**(10./9.) - * cdef double s2 = ks2/k # <<<<<<<<<<<<<< - * cdef double mv2 =0. - * cdef double yy =0. - */ - if (unlikely(__pyx_v_k == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division"); - __PYX_ERR(0, 65, __pyx_L1_error) - } - __pyx_v_s2 = (__pyx_v_ks2 / __pyx_v_k); - - /* "oh2004.pyx":66 - * cdef double ks2 = (np.log(1-(q/(0.095 * (0.13 + np.sin(1.5*theta_rad))**1.4))) /(-1.3))**(10./9.) - * cdef double s2 = ks2/k - * cdef double mv2 =0. # <<<<<<<<<<<<<< - * cdef double yy =0. - * cdef double xx = (1-p)/np.exp(-0.4 * ks2**1.4) - */ - __pyx_v_mv2 = 0.; - - /* "oh2004.pyx":67 - * cdef double s2 = ks2/k - * cdef double mv2 =0. - * cdef double yy =0. # <<<<<<<<<<<<<< - * cdef double xx = (1-p)/np.exp(-0.4 * ks2**1.4) - * if xx<=0: - */ - __pyx_v_yy = 0.; - - /* "oh2004.pyx":68 - * cdef double mv2 =0. - * cdef double yy =0. - * cdef double xx = (1-p)/np.exp(-0.4 * ks2**1.4) # <<<<<<<<<<<<<< - * if xx<=0: - * mv2 =0. - */ - __pyx_t_14 = PyFloat_FromDouble((1.0 - __pyx_v_p)); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_exp); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyFloat_FromDouble((-0.4 * pow(__pyx_v_ks2, 1.4))); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8); - if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_8, function); - } - } - __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_1, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_14, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_8); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_v_xx = __pyx_t_5; - - /* "oh2004.pyx":69 - * cdef double yy =0. - * cdef double xx = (1-p)/np.exp(-0.4 * ks2**1.4) - * if xx<=0: # <<<<<<<<<<<<<< - * mv2 =0. - * else: - */ - __pyx_t_10 = ((__pyx_v_xx <= 0.0) != 0); - if (__pyx_t_10) { - - /* "oh2004.pyx":70 - * cdef double xx = (1-p)/np.exp(-0.4 * ks2**1.4) - * if xx<=0: - * mv2 =0. # <<<<<<<<<<<<<< - * else: - * yy = np.log(xx)/(0.35*np.log(2*theta_rad/np.pi)) - */ - __pyx_v_mv2 = 0.; - - /* "oh2004.pyx":69 - * cdef double yy =0. - * cdef double xx = (1-p)/np.exp(-0.4 * ks2**1.4) - * if xx<=0: # <<<<<<<<<<<<<< - * mv2 =0. - * else: - */ - goto __pyx_L8; - } - - /* "oh2004.pyx":72 - * mv2 =0. - * else: - * yy = np.log(xx)/(0.35*np.log(2*theta_rad/np.pi)) # <<<<<<<<<<<<<< - * mv2=np.power(yy,-100.0/65) - * - */ - /*else*/ { - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_log); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_xx); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_14); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_14, function); - } - } - __pyx_t_8 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_9, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_3); - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_log); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyFloat_FromDouble((2.0 * __pyx_v_theta_rad)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_pi); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_9, function); - } - } - __pyx_t_14 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Multiply(__pyx_float_0_35, __pyx_t_14); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_14); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_v_yy = __pyx_t_5; - - /* "oh2004.pyx":73 - * else: - * yy = np.log(xx)/(0.35*np.log(2*theta_rad/np.pi)) - * mv2=np.power(yy,-100.0/65) # <<<<<<<<<<<<<< - * - * ## Third estimate mv3 - */ - __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_power); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyFloat_FromDouble(__pyx_v_yy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = PyFloat_FromDouble((-100.0 / 65.0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_8, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_8)) { - PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_9, __pyx_t_1}; - __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { - PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_9, __pyx_t_1}; - __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - { - __pyx_t_3 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (__pyx_t_2) { - __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL; - } - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_t_1); - __pyx_t_9 = 0; - __pyx_t_1 = 0; - __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_14); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_v_mv2 = __pyx_t_5; - } - __pyx_L8:; - - /* "oh2004.pyx":76 - * - * ## Third estimate mv3 - * cdef double mv3 = ((sigma_0_hv/(1 - np.exp(-0.32 * ks2**1.8)))/(0.11 * np.cos(theta_rad)**2.2))**(1/0.7) # <<<<<<<<<<<<<< - * ## weighted average s and mv------------------------------------- - * #print("q:\t",q) - */ - __pyx_t_14 = PyFloat_FromDouble(__pyx_v_sigma_0_hv); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyFloat_FromDouble((-0.32 * pow(__pyx_v_ks2, 1.8))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_8 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_9, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_SubtractCObj(__pyx_int_1, __pyx_t_8, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_14, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_cos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyFloat_FromDouble(__pyx_v_theta_rad); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_9 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_9, __pyx_t_14) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_14); - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Power(__pyx_t_1, __pyx_float_2_2, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Multiply(__pyx_float_0_11, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyFloat_FromDouble((1.0 / 0.7)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyNumber_Power(__pyx_t_3, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_8); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_v_mv3 = __pyx_t_5; - - /* "oh2004.pyx":84 - * #print("theta_rad:\t",theta_rad) - * - * cdef double sf = (s1 + 0.25*s2)/(1+0.25) # <<<<<<<<<<<<<< - * cdef double mvf = (mv1+mv2+mv3)/3 - * - */ - __pyx_v_sf = ((__pyx_v_s1 + (0.25 * __pyx_v_s2)) / (1.0 + 0.25)); - - /* "oh2004.pyx":85 - * - * cdef double sf = (s1 + 0.25*s2)/(1+0.25) - * cdef double mvf = (mv1+mv2+mv3)/3 # <<<<<<<<<<<<<< - * - * result[0]=mvf*1.0 - */ - __pyx_v_mvf = (((__pyx_v_mv1 + __pyx_v_mv2) + __pyx_v_mv3) / 3.0); - - /* "oh2004.pyx":87 - * cdef double mvf = (mv1+mv2+mv3)/3 - * - * result[0]=mvf*1.0 # <<<<<<<<<<<<<< - * result[1]=sf*1.0 - * #print("mv1:\t",mv1) - */ - __pyx_t_6 = 0; - __pyx_t_7 = -1; - if (__pyx_t_6 < 0) { - __pyx_t_6 += __pyx_pybuffernd_result.diminfo[0].shape; - if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 0; - } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_7 = 0; - if (unlikely(__pyx_t_7 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 87, __pyx_L1_error) - } - *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_result.diminfo[0].strides) = (__pyx_v_mvf * 1.0); - - /* "oh2004.pyx":88 - * - * result[0]=mvf*1.0 - * result[1]=sf*1.0 # <<<<<<<<<<<<<< - * #print("mv1:\t",mv1) - * #print("mv2:\t",mv2) - */ - __pyx_t_6 = 1; - __pyx_t_7 = -1; - if (__pyx_t_6 < 0) { - __pyx_t_6 += __pyx_pybuffernd_result.diminfo[0].shape; - if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 0; - } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_7 = 0; - if (unlikely(__pyx_t_7 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_7); - __PYX_ERR(0, 88, __pyx_L1_error) - } - *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_result.diminfo[0].strides) = (__pyx_v_sf * 1.0); - - /* "oh2004.pyx":97 - * #print("Estimated rms height s (m): ",result[1]) - * #print("\nend\n") - * return result # <<<<<<<<<<<<<< - * - * cpdef double lamda2freq(double lamda): - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyArrayObject *)__pyx_v_result); - goto __pyx_L0; - - /* "oh2004.pyx":16 - * from scipy.optimize import fmin - * - * cpdef np.ndarray[double,ndim=1] inverse_oh2004(double sigma0vvdB,double sigma0hhdB,double sigma0hvdB,double theta,double f): # <<<<<<<<<<<<<< - * """ - * sigma0vvdB = -14.1 dB - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_12); - __Pyx_XDECREF(__pyx_t_13); - __Pyx_XDECREF(__pyx_t_14); - __Pyx_XDECREF(__pyx_t_15); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_abs_err.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_err.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ks.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mv0.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("oh2004.inverse_oh2004", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_abs_err.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_err.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ks.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mv0.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XDECREF((PyObject *)__pyx_v_mv0); - __Pyx_XDECREF((PyObject *)__pyx_v_ks); - __Pyx_XDECREF((PyObject *)__pyx_v_err); - __Pyx_XDECREF((PyObject *)__pyx_v_abs_err); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_6oh2004_1inverse_oh2004(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6oh2004_inverse_oh2004[] = "\n sigma0vvdB = -14.1 dB\n sigma0hhdB = -16.0\n sigma0hvdB = -26.5\n theta = 35. \350\247\222\345\272\246\345\200\274 ##Incidence angle\n f = 5.0 ##GHz\n "; -static PyObject *__pyx_pw_6oh2004_1inverse_oh2004(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - double __pyx_v_sigma0vvdB; - double __pyx_v_sigma0hhdB; - double __pyx_v_sigma0hvdB; - double __pyx_v_theta; - double __pyx_v_f; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("inverse_oh2004 (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sigma0vvdB,&__pyx_n_s_sigma0hhdB,&__pyx_n_s_sigma0hvdB,&__pyx_n_s_theta,&__pyx_n_s_f,0}; - PyObject* values[5] = {0,0,0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma0vvdB)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma0hhdB)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("inverse_oh2004", 1, 5, 5, 1); __PYX_ERR(0, 16, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma0hvdB)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("inverse_oh2004", 1, 5, 5, 2); __PYX_ERR(0, 16, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 3: - if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_theta)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("inverse_oh2004", 1, 5, 5, 3); __PYX_ERR(0, 16, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 4: - if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_f)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("inverse_oh2004", 1, 5, 5, 4); __PYX_ERR(0, 16, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "inverse_oh2004") < 0)) __PYX_ERR(0, 16, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - } - __pyx_v_sigma0vvdB = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_sigma0vvdB == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 16, __pyx_L3_error) - __pyx_v_sigma0hhdB = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_sigma0hhdB == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 16, __pyx_L3_error) - __pyx_v_sigma0hvdB = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_sigma0hvdB == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 16, __pyx_L3_error) - __pyx_v_theta = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_theta == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 16, __pyx_L3_error) - __pyx_v_f = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_f == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 16, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("inverse_oh2004", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 16, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("oh2004.inverse_oh2004", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_6oh2004_inverse_oh2004(__pyx_self, __pyx_v_sigma0vvdB, __pyx_v_sigma0hhdB, __pyx_v_sigma0hvdB, __pyx_v_theta, __pyx_v_f); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_6oh2004_inverse_oh2004(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_sigma0vvdB, double __pyx_v_sigma0hhdB, double __pyx_v_sigma0hvdB, double __pyx_v_theta, double __pyx_v_f) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("inverse_oh2004", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)__pyx_f_6oh2004_inverse_oh2004(__pyx_v_sigma0vvdB, __pyx_v_sigma0hhdB, __pyx_v_sigma0hvdB, __pyx_v_theta, __pyx_v_f, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("oh2004.inverse_oh2004", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "oh2004.pyx":99 - * return result - * - * cpdef double lamda2freq(double lamda): # <<<<<<<<<<<<<< - * return 299792458.0/lamda - * - */ - -static PyObject *__pyx_pw_6oh2004_3lamda2freq(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static double __pyx_f_6oh2004_lamda2freq(double __pyx_v_lamda, CYTHON_UNUSED int __pyx_skip_dispatch) { - double __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("lamda2freq", 0); - - /* "oh2004.pyx":100 - * - * cpdef double lamda2freq(double lamda): - * return 299792458.0/lamda # <<<<<<<<<<<<<< - * - * cpdef double freq2lamda(double freq): - */ - if (unlikely(__pyx_v_lamda == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division"); - __PYX_ERR(0, 100, __pyx_L1_error) - } - __pyx_r = (299792458.0 / __pyx_v_lamda); - goto __pyx_L0; - - /* "oh2004.pyx":99 - * return result - * - * cpdef double lamda2freq(double lamda): # <<<<<<<<<<<<<< - * return 299792458.0/lamda - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_WriteUnraisable("oh2004.lamda2freq", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); - __pyx_r = 0; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_6oh2004_3lamda2freq(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_6oh2004_3lamda2freq(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - double __pyx_v_lamda; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("lamda2freq (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lamda,0}; - PyObject* values[1] = {0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lamda)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lamda2freq") < 0)) __PYX_ERR(0, 99, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - } - __pyx_v_lamda = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_lamda == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 99, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("lamda2freq", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 99, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("oh2004.lamda2freq", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_6oh2004_2lamda2freq(__pyx_self, __pyx_v_lamda); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_6oh2004_2lamda2freq(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_lamda) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("lamda2freq", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_f_6oh2004_lamda2freq(__pyx_v_lamda, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("oh2004.lamda2freq", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "oh2004.pyx":102 - * return 299792458.0/lamda - * - * cpdef double freq2lamda(double freq): # <<<<<<<<<<<<<< - * return 299792458.0/freq - * - */ - -static PyObject *__pyx_pw_6oh2004_5freq2lamda(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static double __pyx_f_6oh2004_freq2lamda(double __pyx_v_freq, CYTHON_UNUSED int __pyx_skip_dispatch) { - double __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("freq2lamda", 0); - - /* "oh2004.pyx":103 - * - * cpdef double freq2lamda(double freq): - * return 299792458.0/freq # <<<<<<<<<<<<<< - * - * # double sigma0vvdB,double sigma0hhdB,double sigma0hvdB,double theta,double f - */ - if (unlikely(__pyx_v_freq == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division"); - __PYX_ERR(0, 103, __pyx_L1_error) - } - __pyx_r = (299792458.0 / __pyx_v_freq); - goto __pyx_L0; - - /* "oh2004.pyx":102 - * return 299792458.0/lamda - * - * cpdef double freq2lamda(double freq): # <<<<<<<<<<<<<< - * return 299792458.0/freq - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_WriteUnraisable("oh2004.freq2lamda", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); - __pyx_r = 0; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_6oh2004_5freq2lamda(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_6oh2004_5freq2lamda(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - double __pyx_v_freq; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("freq2lamda (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_freq,0}; - PyObject* values[1] = {0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_freq)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "freq2lamda") < 0)) __PYX_ERR(0, 102, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - } - __pyx_v_freq = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_freq == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 102, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("freq2lamda", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 102, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("oh2004.freq2lamda", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_6oh2004_4freq2lamda(__pyx_self, __pyx_v_freq); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_6oh2004_4freq2lamda(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_freq) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("freq2lamda", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_f_6oh2004_freq2lamda(__pyx_v_freq, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("oh2004.freq2lamda", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "oh2004.pyx":106 - * - * # double sigma0vvdB,double sigma0hhdB,double sigma0hvdB,double theta,double f - * cpdef int retrieve_oh2004_main(int n,np.ndarray[double,ndim=1] mv,np.ndarray[double,ndim=1] h,np.ndarray[int,ndim=1] mask,np.ndarray[double,ndim=1] sigma0vvdB,np.ndarray[double,ndim=1] sigma0hhdB,np.ndarray[double,ndim=1] sigma0hvdB, np.ndarray[double,ndim=1] vh, np.ndarray[double,ndim=1] theta,double f): # <<<<<<<<<<<<<< - * cdef int i=0; - * cdef np.ndarray[double,ndim=1] result; - */ - -static PyObject *__pyx_pw_6oh2004_7retrieve_oh2004_main(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_6oh2004_retrieve_oh2004_main(int __pyx_v_n, PyArrayObject *__pyx_v_mv, PyArrayObject *__pyx_v_h, PyArrayObject *__pyx_v_mask, PyArrayObject *__pyx_v_sigma0vvdB, PyArrayObject *__pyx_v_sigma0hhdB, PyArrayObject *__pyx_v_sigma0hvdB, CYTHON_UNUSED PyArrayObject *__pyx_v_vh, PyArrayObject *__pyx_v_theta, double __pyx_v_f, CYTHON_UNUSED int __pyx_skip_dispatch) { - int __pyx_v_i; - PyArrayObject *__pyx_v_result = 0; - __Pyx_LocalBuf_ND __pyx_pybuffernd_h; - __Pyx_Buffer __pyx_pybuffer_h; - __Pyx_LocalBuf_ND __pyx_pybuffernd_mask; - __Pyx_Buffer __pyx_pybuffer_mask; - __Pyx_LocalBuf_ND __pyx_pybuffernd_mv; - __Pyx_Buffer __pyx_pybuffer_mv; - __Pyx_LocalBuf_ND __pyx_pybuffernd_result; - __Pyx_Buffer __pyx_pybuffer_result; - __Pyx_LocalBuf_ND __pyx_pybuffernd_sigma0hhdB; - __Pyx_Buffer __pyx_pybuffer_sigma0hhdB; - __Pyx_LocalBuf_ND __pyx_pybuffernd_sigma0hvdB; - __Pyx_Buffer __pyx_pybuffer_sigma0hvdB; - __Pyx_LocalBuf_ND __pyx_pybuffernd_sigma0vvdB; - __Pyx_Buffer __pyx_pybuffer_sigma0vvdB; - __Pyx_LocalBuf_ND __pyx_pybuffernd_theta; - __Pyx_Buffer __pyx_pybuffer_theta; - __Pyx_LocalBuf_ND __pyx_pybuffernd_vh; - __Pyx_Buffer __pyx_pybuffer_vh; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - Py_ssize_t __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - double __pyx_t_6; - Py_ssize_t __pyx_t_7; - Py_ssize_t __pyx_t_8; - Py_ssize_t __pyx_t_9; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("retrieve_oh2004_main", 0); - __pyx_pybuffer_result.pybuffer.buf = NULL; - __pyx_pybuffer_result.refcount = 0; - __pyx_pybuffernd_result.data = NULL; - __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result; - __pyx_pybuffer_mv.pybuffer.buf = NULL; - __pyx_pybuffer_mv.refcount = 0; - __pyx_pybuffernd_mv.data = NULL; - __pyx_pybuffernd_mv.rcbuffer = &__pyx_pybuffer_mv; - __pyx_pybuffer_h.pybuffer.buf = NULL; - __pyx_pybuffer_h.refcount = 0; - __pyx_pybuffernd_h.data = NULL; - __pyx_pybuffernd_h.rcbuffer = &__pyx_pybuffer_h; - __pyx_pybuffer_mask.pybuffer.buf = NULL; - __pyx_pybuffer_mask.refcount = 0; - __pyx_pybuffernd_mask.data = NULL; - __pyx_pybuffernd_mask.rcbuffer = &__pyx_pybuffer_mask; - __pyx_pybuffer_sigma0vvdB.pybuffer.buf = NULL; - __pyx_pybuffer_sigma0vvdB.refcount = 0; - __pyx_pybuffernd_sigma0vvdB.data = NULL; - __pyx_pybuffernd_sigma0vvdB.rcbuffer = &__pyx_pybuffer_sigma0vvdB; - __pyx_pybuffer_sigma0hhdB.pybuffer.buf = NULL; - __pyx_pybuffer_sigma0hhdB.refcount = 0; - __pyx_pybuffernd_sigma0hhdB.data = NULL; - __pyx_pybuffernd_sigma0hhdB.rcbuffer = &__pyx_pybuffer_sigma0hhdB; - __pyx_pybuffer_sigma0hvdB.pybuffer.buf = NULL; - __pyx_pybuffer_sigma0hvdB.refcount = 0; - __pyx_pybuffernd_sigma0hvdB.data = NULL; - __pyx_pybuffernd_sigma0hvdB.rcbuffer = &__pyx_pybuffer_sigma0hvdB; - __pyx_pybuffer_vh.pybuffer.buf = NULL; - __pyx_pybuffer_vh.refcount = 0; - __pyx_pybuffernd_vh.data = NULL; - __pyx_pybuffernd_vh.rcbuffer = &__pyx_pybuffer_vh; - __pyx_pybuffer_theta.pybuffer.buf = NULL; - __pyx_pybuffer_theta.refcount = 0; - __pyx_pybuffernd_theta.data = NULL; - __pyx_pybuffernd_theta.rcbuffer = &__pyx_pybuffer_theta; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mv.rcbuffer->pybuffer, (PyObject*)__pyx_v_mv, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_mv.diminfo[0].strides = __pyx_pybuffernd_mv.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mv.diminfo[0].shape = __pyx_pybuffernd_mv.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_h.rcbuffer->pybuffer, (PyObject*)__pyx_v_h, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_h.diminfo[0].strides = __pyx_pybuffernd_h.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_h.diminfo[0].shape = __pyx_pybuffernd_h.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sigma0vvdB.rcbuffer->pybuffer, (PyObject*)__pyx_v_sigma0vvdB, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_sigma0vvdB.diminfo[0].strides = __pyx_pybuffernd_sigma0vvdB.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sigma0vvdB.diminfo[0].shape = __pyx_pybuffernd_sigma0vvdB.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sigma0hhdB.rcbuffer->pybuffer, (PyObject*)__pyx_v_sigma0hhdB, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_sigma0hhdB.diminfo[0].strides = __pyx_pybuffernd_sigma0hhdB.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sigma0hhdB.diminfo[0].shape = __pyx_pybuffernd_sigma0hhdB.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sigma0hvdB.rcbuffer->pybuffer, (PyObject*)__pyx_v_sigma0hvdB, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_sigma0hvdB.diminfo[0].strides = __pyx_pybuffernd_sigma0hvdB.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sigma0hvdB.diminfo[0].shape = __pyx_pybuffernd_sigma0hvdB.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_vh, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_vh.diminfo[0].strides = __pyx_pybuffernd_vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_vh.diminfo[0].shape = __pyx_pybuffernd_vh.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_theta.rcbuffer->pybuffer, (PyObject*)__pyx_v_theta, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_theta.diminfo[0].strides = __pyx_pybuffernd_theta.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_theta.diminfo[0].shape = __pyx_pybuffernd_theta.rcbuffer->pybuffer.shape[0]; - - /* "oh2004.pyx":107 - * # double sigma0vvdB,double sigma0hhdB,double sigma0hvdB,double theta,double f - * cpdef int retrieve_oh2004_main(int n,np.ndarray[double,ndim=1] mv,np.ndarray[double,ndim=1] h,np.ndarray[int,ndim=1] mask,np.ndarray[double,ndim=1] sigma0vvdB,np.ndarray[double,ndim=1] sigma0hhdB,np.ndarray[double,ndim=1] sigma0hvdB, np.ndarray[double,ndim=1] vh, np.ndarray[double,ndim=1] theta,double f): - * cdef int i=0; # <<<<<<<<<<<<<< - * cdef np.ndarray[double,ndim=1] result; - * while i= __pyx_pybuffernd_mask.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 110, __pyx_L1_error) - } - __pyx_t_1 = (((*__Pyx_BufPtrStrided1d(int *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_mask.diminfo[0].strides)) < 0.5) != 0); - if (__pyx_t_1) { - - /* "oh2004.pyx":111 - * while i= __pyx_pybuffernd_mv.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 111, __pyx_L1_error) - } - *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_mv.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_mv.diminfo[0].strides) = __pyx_t_6; - - /* "oh2004.pyx":112 - * if mask[i]<0.5: - * mv[i]=np.nan - * h[i] =np.nan # <<<<<<<<<<<<<< - * else: - * #print(i) - */ - __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_nan); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_2 = __pyx_v_i; - __pyx_t_3 = -1; - if (__pyx_t_2 < 0) { - __pyx_t_2 += __pyx_pybuffernd_h.diminfo[0].shape; - if (unlikely(__pyx_t_2 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_2 >= __pyx_pybuffernd_h.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 112, __pyx_L1_error) - } - *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_h.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_h.diminfo[0].strides) = __pyx_t_6; - - /* "oh2004.pyx":110 - * cdef np.ndarray[double,ndim=1] result; - * while i= __pyx_pybuffernd_sigma0vvdB.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 116, __pyx_L1_error) - } - __pyx_t_7 = __pyx_v_i; - __pyx_t_3 = -1; - if (__pyx_t_7 < 0) { - __pyx_t_7 += __pyx_pybuffernd_sigma0hhdB.diminfo[0].shape; - if (unlikely(__pyx_t_7 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_7 >= __pyx_pybuffernd_sigma0hhdB.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 116, __pyx_L1_error) - } - __pyx_t_8 = __pyx_v_i; - __pyx_t_3 = -1; - if (__pyx_t_8 < 0) { - __pyx_t_8 += __pyx_pybuffernd_sigma0hvdB.diminfo[0].shape; - if (unlikely(__pyx_t_8 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_sigma0hvdB.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 116, __pyx_L1_error) - } - __pyx_t_9 = __pyx_v_i; - __pyx_t_3 = -1; - if (__pyx_t_9 < 0) { - __pyx_t_9 += __pyx_pybuffernd_theta.diminfo[0].shape; - if (unlikely(__pyx_t_9 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_theta.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 116, __pyx_L1_error) - } - __pyx_t_4 = ((PyObject *)__pyx_f_6oh2004_inverse_oh2004((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_sigma0vvdB.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_sigma0vvdB.diminfo[0].strides)), (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_sigma0hhdB.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_sigma0hhdB.diminfo[0].strides)), (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_sigma0hvdB.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_sigma0hvdB.diminfo[0].strides)), (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_theta.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_theta.diminfo[0].strides)), __pyx_v_f, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); - __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_4), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); - if (unlikely(__pyx_t_3 < 0)) { - PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); - __Pyx_RaiseBufferFallbackError(); - } else { - PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12); - } - __pyx_t_10 = __pyx_t_11 = __pyx_t_12 = 0; - } - __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; - if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 116, __pyx_L1_error) - } - __Pyx_XDECREF_SET(__pyx_v_result, ((PyArrayObject *)__pyx_t_4)); - __pyx_t_4 = 0; - - /* "oh2004.pyx":118 - * result= inverse_oh2004(sigma0vvdB[i], sigma0hhdB[i],sigma0hvdB[i], theta[i], f) - * ##print(result) - * mv[i]=result[0] # <<<<<<<<<<<<<< - * h[i] =result[1] - * ##print(mv[i],h[i]) - */ - __pyx_t_9 = 0; - __pyx_t_3 = -1; - if (__pyx_t_9 < 0) { - __pyx_t_9 += __pyx_pybuffernd_result.diminfo[0].shape; - if (unlikely(__pyx_t_9 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 118, __pyx_L1_error) - } - __pyx_t_8 = __pyx_v_i; - __pyx_t_3 = -1; - if (__pyx_t_8 < 0) { - __pyx_t_8 += __pyx_pybuffernd_mv.diminfo[0].shape; - if (unlikely(__pyx_t_8 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_mv.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 118, __pyx_L1_error) - } - *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_mv.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_mv.diminfo[0].strides) = (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_result.diminfo[0].strides)); - - /* "oh2004.pyx":119 - * ##print(result) - * mv[i]=result[0] - * h[i] =result[1] # <<<<<<<<<<<<<< - * ##print(mv[i],h[i]) - * ##print(result[0],result[1]) - */ - __pyx_t_9 = 1; - __pyx_t_3 = -1; - if (__pyx_t_9 < 0) { - __pyx_t_9 += __pyx_pybuffernd_result.diminfo[0].shape; - if (unlikely(__pyx_t_9 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_result.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 119, __pyx_L1_error) - } - __pyx_t_8 = __pyx_v_i; - __pyx_t_3 = -1; - if (__pyx_t_8 < 0) { - __pyx_t_8 += __pyx_pybuffernd_h.diminfo[0].shape; - if (unlikely(__pyx_t_8 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_h.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 119, __pyx_L1_error) - } - *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_h.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_h.diminfo[0].strides) = (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_result.diminfo[0].strides)); - } - __pyx_L5:; - - /* "oh2004.pyx":122 - * ##print(mv[i],h[i]) - * ##print(result[0],result[1]) - * i=i+1 # <<<<<<<<<<<<<< - * return 1 - * - */ - __pyx_v_i = (__pyx_v_i + 1); - } - - /* "oh2004.pyx":123 - * ##print(result[0],result[1]) - * i=i+1 - * return 1 # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = 1; - goto __pyx_L0; - - /* "oh2004.pyx":106 - * - * # double sigma0vvdB,double sigma0hhdB,double sigma0hvdB,double theta,double f - * cpdef int retrieve_oh2004_main(int n,np.ndarray[double,ndim=1] mv,np.ndarray[double,ndim=1] h,np.ndarray[int,ndim=1] mask,np.ndarray[double,ndim=1] sigma0vvdB,np.ndarray[double,ndim=1] sigma0hhdB,np.ndarray[double,ndim=1] sigma0hvdB, np.ndarray[double,ndim=1] vh, np.ndarray[double,ndim=1] theta,double f): # <<<<<<<<<<<<<< - * cdef int i=0; - * cdef np.ndarray[double,ndim=1] result; - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_h.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mv.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0hhdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0hvdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0vvdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_theta.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_WriteUnraisable("oh2004.retrieve_oh2004_main", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); - __pyx_r = 0; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_h.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mv.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0hhdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0hvdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0vvdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_theta.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_6oh2004_7retrieve_oh2004_main(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_6oh2004_7retrieve_oh2004_main(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_v_n; - PyArrayObject *__pyx_v_mv = 0; - PyArrayObject *__pyx_v_h = 0; - PyArrayObject *__pyx_v_mask = 0; - PyArrayObject *__pyx_v_sigma0vvdB = 0; - PyArrayObject *__pyx_v_sigma0hhdB = 0; - PyArrayObject *__pyx_v_sigma0hvdB = 0; - PyArrayObject *__pyx_v_vh = 0; - PyArrayObject *__pyx_v_theta = 0; - double __pyx_v_f; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("retrieve_oh2004_main (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,&__pyx_n_s_mv,&__pyx_n_s_h,&__pyx_n_s_mask,&__pyx_n_s_sigma0vvdB,&__pyx_n_s_sigma0hhdB,&__pyx_n_s_sigma0hvdB,&__pyx_n_s_vh,&__pyx_n_s_theta,&__pyx_n_s_f,0}; - PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); - CYTHON_FALLTHROUGH; - case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); - CYTHON_FALLTHROUGH; - case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); - CYTHON_FALLTHROUGH; - case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); - CYTHON_FALLTHROUGH; - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - CYTHON_FALLTHROUGH; - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mv)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("retrieve_oh2004_main", 1, 10, 10, 1); __PYX_ERR(0, 106, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("retrieve_oh2004_main", 1, 10, 10, 2); __PYX_ERR(0, 106, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 3: - if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("retrieve_oh2004_main", 1, 10, 10, 3); __PYX_ERR(0, 106, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 4: - if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma0vvdB)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("retrieve_oh2004_main", 1, 10, 10, 4); __PYX_ERR(0, 106, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 5: - if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma0hhdB)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("retrieve_oh2004_main", 1, 10, 10, 5); __PYX_ERR(0, 106, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 6: - if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma0hvdB)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("retrieve_oh2004_main", 1, 10, 10, 6); __PYX_ERR(0, 106, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 7: - if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_vh)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("retrieve_oh2004_main", 1, 10, 10, 7); __PYX_ERR(0, 106, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 8: - if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_theta)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("retrieve_oh2004_main", 1, 10, 10, 8); __PYX_ERR(0, 106, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 9: - if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_f)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("retrieve_oh2004_main", 1, 10, 10, 9); __PYX_ERR(0, 106, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "retrieve_oh2004_main") < 0)) __PYX_ERR(0, 106, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 10) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - values[6] = PyTuple_GET_ITEM(__pyx_args, 6); - values[7] = PyTuple_GET_ITEM(__pyx_args, 7); - values[8] = PyTuple_GET_ITEM(__pyx_args, 8); - values[9] = PyTuple_GET_ITEM(__pyx_args, 9); - } - __pyx_v_n = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 106, __pyx_L3_error) - __pyx_v_mv = ((PyArrayObject *)values[1]); - __pyx_v_h = ((PyArrayObject *)values[2]); - __pyx_v_mask = ((PyArrayObject *)values[3]); - __pyx_v_sigma0vvdB = ((PyArrayObject *)values[4]); - __pyx_v_sigma0hhdB = ((PyArrayObject *)values[5]); - __pyx_v_sigma0hvdB = ((PyArrayObject *)values[6]); - __pyx_v_vh = ((PyArrayObject *)values[7]); - __pyx_v_theta = ((PyArrayObject *)values[8]); - __pyx_v_f = __pyx_PyFloat_AsDouble(values[9]); if (unlikely((__pyx_v_f == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 106, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("retrieve_oh2004_main", 1, 10, 10, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 106, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("oh2004.retrieve_oh2004_main", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mv), __pyx_ptype_5numpy_ndarray, 1, "mv", 0))) __PYX_ERR(0, 106, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_h), __pyx_ptype_5numpy_ndarray, 1, "h", 0))) __PYX_ERR(0, 106, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_5numpy_ndarray, 1, "mask", 0))) __PYX_ERR(0, 106, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sigma0vvdB), __pyx_ptype_5numpy_ndarray, 1, "sigma0vvdB", 0))) __PYX_ERR(0, 106, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sigma0hhdB), __pyx_ptype_5numpy_ndarray, 1, "sigma0hhdB", 0))) __PYX_ERR(0, 106, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sigma0hvdB), __pyx_ptype_5numpy_ndarray, 1, "sigma0hvdB", 0))) __PYX_ERR(0, 106, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vh), __pyx_ptype_5numpy_ndarray, 1, "vh", 0))) __PYX_ERR(0, 106, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_theta), __pyx_ptype_5numpy_ndarray, 1, "theta", 0))) __PYX_ERR(0, 106, __pyx_L1_error) - __pyx_r = __pyx_pf_6oh2004_6retrieve_oh2004_main(__pyx_self, __pyx_v_n, __pyx_v_mv, __pyx_v_h, __pyx_v_mask, __pyx_v_sigma0vvdB, __pyx_v_sigma0hhdB, __pyx_v_sigma0hvdB, __pyx_v_vh, __pyx_v_theta, __pyx_v_f); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_6oh2004_6retrieve_oh2004_main(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n, PyArrayObject *__pyx_v_mv, PyArrayObject *__pyx_v_h, PyArrayObject *__pyx_v_mask, PyArrayObject *__pyx_v_sigma0vvdB, PyArrayObject *__pyx_v_sigma0hhdB, PyArrayObject *__pyx_v_sigma0hvdB, PyArrayObject *__pyx_v_vh, PyArrayObject *__pyx_v_theta, double __pyx_v_f) { - __Pyx_LocalBuf_ND __pyx_pybuffernd_h; - __Pyx_Buffer __pyx_pybuffer_h; - __Pyx_LocalBuf_ND __pyx_pybuffernd_mask; - __Pyx_Buffer __pyx_pybuffer_mask; - __Pyx_LocalBuf_ND __pyx_pybuffernd_mv; - __Pyx_Buffer __pyx_pybuffer_mv; - __Pyx_LocalBuf_ND __pyx_pybuffernd_sigma0hhdB; - __Pyx_Buffer __pyx_pybuffer_sigma0hhdB; - __Pyx_LocalBuf_ND __pyx_pybuffernd_sigma0hvdB; - __Pyx_Buffer __pyx_pybuffer_sigma0hvdB; - __Pyx_LocalBuf_ND __pyx_pybuffernd_sigma0vvdB; - __Pyx_Buffer __pyx_pybuffer_sigma0vvdB; - __Pyx_LocalBuf_ND __pyx_pybuffernd_theta; - __Pyx_Buffer __pyx_pybuffer_theta; - __Pyx_LocalBuf_ND __pyx_pybuffernd_vh; - __Pyx_Buffer __pyx_pybuffer_vh; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("retrieve_oh2004_main", 0); - __pyx_pybuffer_mv.pybuffer.buf = NULL; - __pyx_pybuffer_mv.refcount = 0; - __pyx_pybuffernd_mv.data = NULL; - __pyx_pybuffernd_mv.rcbuffer = &__pyx_pybuffer_mv; - __pyx_pybuffer_h.pybuffer.buf = NULL; - __pyx_pybuffer_h.refcount = 0; - __pyx_pybuffernd_h.data = NULL; - __pyx_pybuffernd_h.rcbuffer = &__pyx_pybuffer_h; - __pyx_pybuffer_mask.pybuffer.buf = NULL; - __pyx_pybuffer_mask.refcount = 0; - __pyx_pybuffernd_mask.data = NULL; - __pyx_pybuffernd_mask.rcbuffer = &__pyx_pybuffer_mask; - __pyx_pybuffer_sigma0vvdB.pybuffer.buf = NULL; - __pyx_pybuffer_sigma0vvdB.refcount = 0; - __pyx_pybuffernd_sigma0vvdB.data = NULL; - __pyx_pybuffernd_sigma0vvdB.rcbuffer = &__pyx_pybuffer_sigma0vvdB; - __pyx_pybuffer_sigma0hhdB.pybuffer.buf = NULL; - __pyx_pybuffer_sigma0hhdB.refcount = 0; - __pyx_pybuffernd_sigma0hhdB.data = NULL; - __pyx_pybuffernd_sigma0hhdB.rcbuffer = &__pyx_pybuffer_sigma0hhdB; - __pyx_pybuffer_sigma0hvdB.pybuffer.buf = NULL; - __pyx_pybuffer_sigma0hvdB.refcount = 0; - __pyx_pybuffernd_sigma0hvdB.data = NULL; - __pyx_pybuffernd_sigma0hvdB.rcbuffer = &__pyx_pybuffer_sigma0hvdB; - __pyx_pybuffer_vh.pybuffer.buf = NULL; - __pyx_pybuffer_vh.refcount = 0; - __pyx_pybuffernd_vh.data = NULL; - __pyx_pybuffernd_vh.rcbuffer = &__pyx_pybuffer_vh; - __pyx_pybuffer_theta.pybuffer.buf = NULL; - __pyx_pybuffer_theta.refcount = 0; - __pyx_pybuffernd_theta.data = NULL; - __pyx_pybuffernd_theta.rcbuffer = &__pyx_pybuffer_theta; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mv.rcbuffer->pybuffer, (PyObject*)__pyx_v_mv, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_mv.diminfo[0].strides = __pyx_pybuffernd_mv.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mv.diminfo[0].shape = __pyx_pybuffernd_mv.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_h.rcbuffer->pybuffer, (PyObject*)__pyx_v_h, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_h.diminfo[0].strides = __pyx_pybuffernd_h.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_h.diminfo[0].shape = __pyx_pybuffernd_h.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sigma0vvdB.rcbuffer->pybuffer, (PyObject*)__pyx_v_sigma0vvdB, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_sigma0vvdB.diminfo[0].strides = __pyx_pybuffernd_sigma0vvdB.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sigma0vvdB.diminfo[0].shape = __pyx_pybuffernd_sigma0vvdB.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sigma0hhdB.rcbuffer->pybuffer, (PyObject*)__pyx_v_sigma0hhdB, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_sigma0hhdB.diminfo[0].strides = __pyx_pybuffernd_sigma0hhdB.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sigma0hhdB.diminfo[0].shape = __pyx_pybuffernd_sigma0hhdB.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sigma0hvdB.rcbuffer->pybuffer, (PyObject*)__pyx_v_sigma0hvdB, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_sigma0hvdB.diminfo[0].strides = __pyx_pybuffernd_sigma0hvdB.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sigma0hvdB.diminfo[0].shape = __pyx_pybuffernd_sigma0hvdB.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_vh, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_vh.diminfo[0].strides = __pyx_pybuffernd_vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_vh.diminfo[0].shape = __pyx_pybuffernd_vh.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_theta.rcbuffer->pybuffer, (PyObject*)__pyx_v_theta, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 106, __pyx_L1_error) - } - __pyx_pybuffernd_theta.diminfo[0].strides = __pyx_pybuffernd_theta.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_theta.diminfo[0].shape = __pyx_pybuffernd_theta.rcbuffer->pybuffer.shape[0]; - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_6oh2004_retrieve_oh2004_main(__pyx_v_n, __pyx_v_mv, __pyx_v_h, __pyx_v_mask, __pyx_v_sigma0vvdB, __pyx_v_sigma0hhdB, __pyx_v_sigma0hvdB, __pyx_v_vh, __pyx_v_theta, __pyx_v_f, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_h.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mv.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0hhdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0hvdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0vvdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_theta.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_vh.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("oh2004.retrieve_oh2004_main", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_h.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mv.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0hhdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0hvdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sigma0vvdB.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_theta.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_vh.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":735 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":736 - * - * cdef inline object PyArray_MultiIterNew1(a): - * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew2(a, b): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 736, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":735 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":738 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":739 - * - * cdef inline object PyArray_MultiIterNew2(a, b): - * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 739, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":738 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":741 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":742 - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 742, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":741 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":744 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":745 - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 745, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":744 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":747 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":748 - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 748, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":747 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":750 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":751 - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< - * return d.subarray.shape - * else: - */ - __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); - if (__pyx_t_1) { - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":752 - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape # <<<<<<<<<<<<<< - * else: - * return () - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape)); - __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":751 - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< - * return d.subarray.shape - * else: - */ - } - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":754 - * return d.subarray.shape - * else: - * return () # <<<<<<<<<<<<<< - * - * - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_empty_tuple); - __pyx_r = __pyx_empty_tuple; - goto __pyx_L0; - } - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":750 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":931 - * int _import_umath() except -1 - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) - */ - -static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_array_base", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":932 - * - * cdef inline void set_array_base(ndarray arr, object base): - * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< - * PyArray_SetBaseObject(arr, base) - * - */ - Py_INCREF(__pyx_v_base); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":933 - * cdef inline void set_array_base(ndarray arr, object base): - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< - * - * cdef inline object get_array_base(ndarray arr): - */ - (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":931 - * int _import_umath() except -1 - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":935 - * PyArray_SetBaseObject(arr, base) - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * base = PyArray_BASE(arr) - * if base is NULL: - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { - PyObject *__pyx_v_base; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("get_array_base", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":936 - * - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< - * if base is NULL: - * return None - */ - __pyx_v_base = PyArray_BASE(__pyx_v_arr); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":937 - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) - * if base is NULL: # <<<<<<<<<<<<<< - * return None - * return base - */ - __pyx_t_1 = ((__pyx_v_base == NULL) != 0); - if (__pyx_t_1) { - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":938 - * base = PyArray_BASE(arr) - * if base is NULL: - * return None # <<<<<<<<<<<<<< - * return base - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":937 - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) - * if base is NULL: # <<<<<<<<<<<<<< - * return None - * return base - */ - } - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":939 - * if base is NULL: - * return None - * return base # <<<<<<<<<<<<<< - * - * # Versions of the import_* functions which are more suitable for - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_base)); - __pyx_r = ((PyObject *)__pyx_v_base); - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":935 - * PyArray_SetBaseObject(arr, base) - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * base = PyArray_BASE(arr) - * if base is NULL: - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":943 - * # Versions of the import_* functions which are more suitable for - * # Cython code. - * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< - * try: - * __pyx_import_array() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_array", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":945 - * cdef inline int import_array() except -1: - * try: - * __pyx_import_array() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") - */ - __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 945, __pyx_L3_error) - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":946 - * try: - * __pyx_import_array() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.multiarray failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 946, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":947 - * __pyx_import_array() - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_umath() except -1: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 947, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 947, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":943 - * # Versions of the import_* functions which are more suitable for - * # Cython code. - * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< - * try: - * __pyx_import_array() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":949 - * raise ImportError("numpy.core.multiarray failed to import") - * - * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_umath", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":951 - * cdef inline int import_umath() except -1: - * try: - * _import_umath() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.umath failed to import") - */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 951, __pyx_L3_error) - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":952 - * try: - * _import_umath() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.umath failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 952, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":953 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_ufunc() except -1: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 953, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 953, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":949 - * raise ImportError("numpy.core.multiarray failed to import") - * - * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":955 - * raise ImportError("numpy.core.umath failed to import") - * - * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_ufunc", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":957 - * cdef inline int import_ufunc() except -1: - * try: - * _import_umath() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.umath failed to import") - */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 957, __pyx_L3_error) - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":958 - * try: - * _import_umath() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.umath failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 958, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":959 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef extern from *: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 959, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 959, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":955 - * raise ImportError("numpy.core.umath failed to import") - * - * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":969 - * - * - * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.timedelta64)` - */ - -static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_obj) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_timedelta64_object", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":981 - * bool - * """ - * return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type) # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyTimedeltaArrType_Type)); - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":969 - * - * - * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.timedelta64)` - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":984 - * - * - * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.datetime64)` - */ - -static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_obj) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_datetime64_object", 0); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":996 - * bool - * """ - * return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type) # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyDatetimeArrType_Type)); - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":984 - * - * - * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.datetime64)` - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":999 - * - * - * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy datetime64 object - */ - -static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject *__pyx_v_obj) { - npy_datetime __pyx_r; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1006 - * also needed. That can be found using `get_datetime64_unit`. - * """ - * return (obj).obval # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = ((PyDatetimeScalarObject *)__pyx_v_obj)->obval; - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":999 - * - * - * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy datetime64 object - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1009 - * - * - * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy timedelta64 object - */ - -static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject *__pyx_v_obj) { - npy_timedelta __pyx_r; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1013 - * returns the int64 value underlying scalar numpy timedelta64 object - * """ - * return (obj).obval # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = ((PyTimedeltaScalarObject *)__pyx_v_obj)->obval; - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1009 - * - * - * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy timedelta64 object - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - -static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObject *__pyx_v_obj) { - NPY_DATETIMEUNIT __pyx_r; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1020 - * returns the unit part of the dtype for a numpy datetime64 object. - * """ - * return (obj).obmeta.base # <<<<<<<<<<<<<< - */ - __pyx_r = ((NPY_DATETIMEUNIT)((PyDatetimeScalarObject *)__pyx_v_obj)->obmeta.base); - goto __pyx_L0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -static PyMethodDef __pyx_methods[] = { - {"inverse_oh2004", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6oh2004_1inverse_oh2004, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6oh2004_inverse_oh2004}, - {"lamda2freq", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6oh2004_3lamda2freq, METH_VARARGS|METH_KEYWORDS, 0}, - {"freq2lamda", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6oh2004_5freq2lamda, METH_VARARGS|METH_KEYWORDS, 0}, - {"retrieve_oh2004_main", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6oh2004_7retrieve_oh2004_main, METH_VARARGS|METH_KEYWORDS, 0}, - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -#if CYTHON_PEP489_MULTI_PHASE_INIT -static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ -static int __pyx_pymod_exec_oh2004(PyObject* module); /*proto*/ -static PyModuleDef_Slot __pyx_moduledef_slots[] = { - {Py_mod_create, (void*)__pyx_pymod_create}, - {Py_mod_exec, (void*)__pyx_pymod_exec_oh2004}, - {0, NULL} -}; -#endif - -static struct PyModuleDef __pyx_moduledef = { - PyModuleDef_HEAD_INIT, - "oh2004", - __pyx_k_Created_on_Tue_Jun_4_14_59_54_2, /* m_doc */ - #if CYTHON_PEP489_MULTI_PHASE_INIT - 0, /* m_size */ - #else - -1, /* m_size */ - #endif - __pyx_methods /* m_methods */, - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_moduledef_slots, /* m_slots */ - #else - NULL, /* m_reload */ - #endif - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif -#ifndef CYTHON_SMALL_CODE -#if defined(__clang__) - #define CYTHON_SMALL_CODE -#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) - #define CYTHON_SMALL_CODE __attribute__((cold)) -#else - #define CYTHON_SMALL_CODE -#endif -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, - {&__pyx_n_s_abs, __pyx_k_abs, sizeof(__pyx_k_abs), 0, 0, 1, 1}, - {&__pyx_n_s_arange, __pyx_k_arange, sizeof(__pyx_k_arange), 0, 0, 1, 1}, - {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, - {&__pyx_n_s_cos, __pyx_k_cos, sizeof(__pyx_k_cos), 0, 0, 1, 1}, - {&__pyx_n_s_exp, __pyx_k_exp, sizeof(__pyx_k_exp), 0, 0, 1, 1}, - {&__pyx_n_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 1}, - {&__pyx_n_s_fmin, __pyx_k_fmin, sizeof(__pyx_k_fmin), 0, 0, 1, 1}, - {&__pyx_n_s_freq, __pyx_k_freq, sizeof(__pyx_k_freq), 0, 0, 1, 1}, - {&__pyx_n_s_h, __pyx_k_h, sizeof(__pyx_k_h), 0, 0, 1, 1}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_n_s_lamda, __pyx_k_lamda, sizeof(__pyx_k_lamda), 0, 0, 1, 1}, - {&__pyx_n_s_log, __pyx_k_log, sizeof(__pyx_k_log), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1}, - {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1}, - {&__pyx_n_s_mv, __pyx_k_mv, sizeof(__pyx_k_mv), 0, 0, 1, 1}, - {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_n_s_nan, __pyx_k_nan, sizeof(__pyx_k_nan), 0, 0, 1, 1}, - {&__pyx_n_s_nanmin, __pyx_k_nanmin, sizeof(__pyx_k_nanmin), 0, 0, 1, 1}, - {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, - {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, - {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0}, - {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0}, - {&__pyx_n_s_ones, __pyx_k_ones, sizeof(__pyx_k_ones), 0, 0, 1, 1}, - {&__pyx_n_s_pi, __pyx_k_pi, sizeof(__pyx_k_pi), 0, 0, 1, 1}, - {&__pyx_n_s_power, __pyx_k_power, sizeof(__pyx_k_power), 0, 0, 1, 1}, - {&__pyx_n_s_scipy_optimize, __pyx_k_scipy_optimize, sizeof(__pyx_k_scipy_optimize), 0, 0, 1, 1}, - {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, - {&__pyx_n_s_sigma0hhdB, __pyx_k_sigma0hhdB, sizeof(__pyx_k_sigma0hhdB), 0, 0, 1, 1}, - {&__pyx_n_s_sigma0hvdB, __pyx_k_sigma0hvdB, sizeof(__pyx_k_sigma0hvdB), 0, 0, 1, 1}, - {&__pyx_n_s_sigma0vvdB, __pyx_k_sigma0vvdB, sizeof(__pyx_k_sigma0vvdB), 0, 0, 1, 1}, - {&__pyx_n_s_sin, __pyx_k_sin, sizeof(__pyx_k_sin), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_theta, __pyx_k_theta, sizeof(__pyx_k_theta), 0, 0, 1, 1}, - {&__pyx_n_s_vh, __pyx_k_vh, sizeof(__pyx_k_vh), 0, 0, 1, 1}, - {&__pyx_n_s_where, __pyx_k_where, sizeof(__pyx_k_where), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 947, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "oh2004.pyx":44 - * - * - * cdef np.ndarray[double,ndim=1] mv0 = np.arange(0.05,0.9,0.01) # set Gamma0 range of values (fine increments) # <<<<<<<<<<<<<< - * - * ## First estimates s1 and mv1 - */ - __pyx_tuple_ = PyTuple_Pack(3, __pyx_float_0_05, __pyx_float_0_9, __pyx_float_0_01); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":947 - * __pyx_import_array() - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_umath() except -1: - */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 947, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__2); - __Pyx_GIVEREF(__pyx_tuple__2); - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":953 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_ufunc() except -1: - */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 953, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - __pyx_float_1_ = PyFloat_FromDouble(1.); if (unlikely(!__pyx_float_1_)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_0_7 = PyFloat_FromDouble(0.7); if (unlikely(!__pyx_float_0_7)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_0_9 = PyFloat_FromDouble(0.9); if (unlikely(!__pyx_float_0_9)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_1_4 = PyFloat_FromDouble(1.4); if (unlikely(!__pyx_float_1_4)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_10_ = PyFloat_FromDouble(10.); if (unlikely(!__pyx_float_10_)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_2_2 = PyFloat_FromDouble(2.2); if (unlikely(!__pyx_float_2_2)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_0_01 = PyFloat_FromDouble(0.01); if (unlikely(!__pyx_float_0_01)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_0_05 = PyFloat_FromDouble(0.05); if (unlikely(!__pyx_float_0_05)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_0_11 = PyFloat_FromDouble(0.11); if (unlikely(!__pyx_float_0_11)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_0_13 = PyFloat_FromDouble(0.13); if (unlikely(!__pyx_float_0_13)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_0_35 = PyFloat_FromDouble(0.35); if (unlikely(!__pyx_float_0_35)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_0_095 = PyFloat_FromDouble(0.095); if (unlikely(!__pyx_float_0_095)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_0_556 = PyFloat_FromDouble(0.556); if (unlikely(!__pyx_float_0_556)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_neg_0_4 = PyFloat_FromDouble(-0.4); if (unlikely(!__pyx_float_neg_0_4)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_neg_1_3 = PyFloat_FromDouble(-1.3); if (unlikely(!__pyx_float_neg_1_3)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_float_neg_0_65 = PyFloat_FromDouble(-0.65); if (unlikely(!__pyx_float_neg_0_65)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ - -static int __Pyx_modinit_global_init_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); - /*--- Global init code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_variable_export_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); - /*--- Variable export code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_function_export_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); - /*--- Function export code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_type_init_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); - /*--- Type init code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_type_import_code(void) { - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); - /*--- Type import code ---*/ - __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", - #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 - sizeof(PyTypeObject), - #else - sizeof(PyHeapTypeObject), - #endif - __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 200, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 200, __pyx_L1_error) - __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 223, __pyx_L1_error) - __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 227, __pyx_L1_error) - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 239, __pyx_L1_error) - __pyx_ptype_5numpy_generic = __Pyx_ImportType(__pyx_t_1, "numpy", "generic", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_generic) __PYX_ERR(1, 771, __pyx_L1_error) - __pyx_ptype_5numpy_number = __Pyx_ImportType(__pyx_t_1, "numpy", "number", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_number) __PYX_ERR(1, 773, __pyx_L1_error) - __pyx_ptype_5numpy_integer = __Pyx_ImportType(__pyx_t_1, "numpy", "integer", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_integer) __PYX_ERR(1, 775, __pyx_L1_error) - __pyx_ptype_5numpy_signedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "signedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_signedinteger) __PYX_ERR(1, 777, __pyx_L1_error) - __pyx_ptype_5numpy_unsignedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "unsignedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_unsignedinteger) __PYX_ERR(1, 779, __pyx_L1_error) - __pyx_ptype_5numpy_inexact = __Pyx_ImportType(__pyx_t_1, "numpy", "inexact", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_inexact) __PYX_ERR(1, 781, __pyx_L1_error) - __pyx_ptype_5numpy_floating = __Pyx_ImportType(__pyx_t_1, "numpy", "floating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_floating) __PYX_ERR(1, 783, __pyx_L1_error) - __pyx_ptype_5numpy_complexfloating = __Pyx_ImportType(__pyx_t_1, "numpy", "complexfloating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_complexfloating) __PYX_ERR(1, 785, __pyx_L1_error) - __pyx_ptype_5numpy_flexible = __Pyx_ImportType(__pyx_t_1, "numpy", "flexible", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_flexible) __PYX_ERR(1, 787, __pyx_L1_error) - __pyx_ptype_5numpy_character = __Pyx_ImportType(__pyx_t_1, "numpy", "character", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_5numpy_character) __PYX_ERR(1, 789, __pyx_L1_error) - __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore); - if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 827, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_modinit_variable_import_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); - /*--- Variable import code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_function_import_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); - /*--- Function import code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - - -#ifndef CYTHON_NO_PYINIT_EXPORT -#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC -#elif PY_MAJOR_VERSION < 3 -#ifdef __cplusplus -#define __Pyx_PyMODINIT_FUNC extern "C" void -#else -#define __Pyx_PyMODINIT_FUNC void -#endif -#else -#ifdef __cplusplus -#define __Pyx_PyMODINIT_FUNC extern "C" PyObject * -#else -#define __Pyx_PyMODINIT_FUNC PyObject * -#endif -#endif - - -#if PY_MAJOR_VERSION < 3 -__Pyx_PyMODINIT_FUNC initoh2004(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC initoh2004(void) -#else -__Pyx_PyMODINIT_FUNC PyInit_oh2004(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC PyInit_oh2004(void) -#if CYTHON_PEP489_MULTI_PHASE_INIT -{ - return PyModuleDef_Init(&__pyx_moduledef); -} -static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { - #if PY_VERSION_HEX >= 0x030700A1 - static PY_INT64_T main_interpreter_id = -1; - PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); - if (main_interpreter_id == -1) { - main_interpreter_id = current_id; - return (unlikely(current_id == -1)) ? -1 : 0; - } else if (unlikely(main_interpreter_id != current_id)) - #else - static PyInterpreterState *main_interpreter = NULL; - PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; - if (!main_interpreter) { - main_interpreter = current_interpreter; - } else if (unlikely(main_interpreter != current_interpreter)) - #endif - { - PyErr_SetString( - PyExc_ImportError, - "Interpreter change detected - this module can only be loaded into one interpreter per process."); - return -1; - } - return 0; -} -static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { - PyObject *value = PyObject_GetAttrString(spec, from_name); - int result = 0; - if (likely(value)) { - if (allow_none || value != Py_None) { - result = PyDict_SetItemString(moddict, to_name, value); - } - Py_DECREF(value); - } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - } else { - result = -1; - } - return result; -} -static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { - PyObject *module = NULL, *moddict, *modname; - if (__Pyx_check_single_interpreter()) - return NULL; - if (__pyx_m) - return __Pyx_NewRef(__pyx_m); - modname = PyObject_GetAttrString(spec, "name"); - if (unlikely(!modname)) goto bad; - module = PyModule_NewObject(modname); - Py_DECREF(modname); - if (unlikely(!module)) goto bad; - moddict = PyModule_GetDict(module); - if (unlikely(!moddict)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; - return module; -bad: - Py_XDECREF(module); - return NULL; -} - - -static CYTHON_SMALL_CODE int __pyx_pymod_exec_oh2004(PyObject *__pyx_pyinit_module) -#endif -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannyDeclarations - #if CYTHON_PEP489_MULTI_PHASE_INIT - if (__pyx_m) { - if (__pyx_m == __pyx_pyinit_module) return 0; - PyErr_SetString(PyExc_RuntimeError, "Module 'oh2004' has already been imported. Re-initialisation is not supported."); - return -1; - } - #elif PY_MAJOR_VERSION >= 3 - if (__pyx_m) return __Pyx_NewRef(__pyx_m); - #endif - #if CYTHON_REFNANNY -__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); -if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); -} -#endif - __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_oh2004(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pxy_PyFrame_Initialize_Offsets - __Pxy_PyFrame_Initialize_Offsets(); - #endif - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_AsyncGen_USED - if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - PyEval_InitThreads(); - #endif - /*--- Module creation code ---*/ - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_m = __pyx_pyinit_module; - Py_INCREF(__pyx_m); - #else - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("oh2004", __pyx_methods, __pyx_k_Created_on_Tue_Jun_4_14_59_54_2, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_b); - __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_cython_runtime); - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main_oh2004) { - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "oh2004")) { - if (unlikely(PyDict_SetItemString(modules, "oh2004", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global type/function init code ---*/ - (void)__Pyx_modinit_global_init_code(); - (void)__Pyx_modinit_variable_export_code(); - (void)__Pyx_modinit_function_export_code(); - (void)__Pyx_modinit_type_init_code(); - if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - (void)__Pyx_modinit_variable_import_code(); - (void)__Pyx_modinit_function_import_code(); - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - - /* "oh2004.pyx":11 - * """ - * cimport cython # - * import numpy as np##cpythonnp # <<<<<<<<<<<<<< - * cimport numpy as np # cpythonnp - * from libc.math cimport pi - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "oh2004.pyx":14 - * cimport numpy as np # cpythonnp - * from libc.math cimport pi - * from scipy.optimize import fmin # <<<<<<<<<<<<<< - * - * cpdef np.ndarray[double,ndim=1] inverse_oh2004(double sigma0vvdB,double sigma0hhdB,double sigma0hvdB,double theta,double f): - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_fmin); - __Pyx_GIVEREF(__pyx_n_s_fmin); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_fmin); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_scipy_optimize, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_fmin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_fmin, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "oh2004.pyx":1 - * # -*- coding: utf-8 -*- # <<<<<<<<<<<<<< - * """ - * Created on Tue Jun 4 14:59:54 2013 - */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "E:/soft/Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init oh2004", __pyx_clineno, __pyx_lineno, __pyx_filename); - } - Py_CLEAR(__pyx_m); - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init oh2004"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if CYTHON_PEP489_MULTI_PHASE_INIT - return (__pyx_m != NULL) ? 0 : -1; - #elif PY_MAJOR_VERSION >= 3 - return __pyx_m; - #else - return; - #endif -} - -/* --- Runtime support code --- */ -/* Refnanny */ -#if CYTHON_REFNANNY -static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule(modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, "RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif - -/* PyObjectGetAttrStr */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#endif - -/* GetBuiltinName */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -/* PyDictVersioning */ -#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; -} -static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { - PyObject **dictptr = NULL; - Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; - if (offset) { -#if CYTHON_COMPILING_IN_CPYTHON - dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); -#else - dictptr = _PyObject_GetDictPtr(obj); -#endif - } - return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; -} -static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) - return 0; - return obj_dict_version == __Pyx_get_object_dict_version(obj); -} -#endif - -/* GetModuleGlobalName */ -#if CYTHON_USE_DICT_VERSIONS -static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) -#else -static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) -#endif -{ - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 - result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } else if (unlikely(PyErr_Occurred())) { - return NULL; - } -#else - result = PyDict_GetItem(__pyx_d, name); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } -#endif -#else - result = PyObject_GetItem(__pyx_d, name); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } - PyErr_Clear(); -#endif - return __Pyx_GetBuiltinName(name); -} - -/* PyCFunctionFastCall */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); - } else { - return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); - } -} -#endif - -/* PyFunctionFastCall */ -#if CYTHON_FAST_PYCALL -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = __Pyx_PyFrame_GetLocalsplus(f); - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif -#endif - -/* PyObjectCall */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = Py_TYPE(func)->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = (*call)(func, arg, kw); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCall2Args */ -static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { - PyObject *args, *result = NULL; - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyFunction_FastCall(function, args, 2); - } - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyCFunction_FastCall(function, args, 2); - } - #endif - args = PyTuple_New(2); - if (unlikely(!args)) goto done; - Py_INCREF(arg1); - PyTuple_SET_ITEM(args, 0, arg1); - Py_INCREF(arg2); - PyTuple_SET_ITEM(args, 1, arg2); - Py_INCREF(function); - result = __Pyx_PyObject_Call(function, args, NULL); - Py_DECREF(args); - Py_DECREF(function); -done: - return result; -} - -/* PyObjectCallMethO */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { - PyObject *self, *result; - PyCFunction cfunc; - cfunc = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = cfunc(self, arg); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallOneArg */ -#if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif - if (likely(PyCFunction_Check(func))) { - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (__Pyx_PyFastCFunction_Check(func)) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - -/* ExtTypeTest */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (likely(__Pyx_TypeCheck(obj, type))) - return 1; - PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", - Py_TYPE(obj)->tp_name, type->tp_name); - return 0; -} - -/* IsLittleEndian */ -static CYTHON_INLINE int __Pyx_Is_Little_Endian(void) -{ - union { - uint32_t u32; - uint8_t u8[4]; - } S; - S.u32 = 0x01020304; - return S.u8[0] == 4; -} - -/* BufferFormatCheck */ -static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type) { - stack[0].field = &ctx->root; - stack[0].parent_offset = 0; - ctx->root.type = type; - ctx->root.name = "buffer dtype"; - ctx->root.offset = 0; - ctx->head = stack; - ctx->head->field = &ctx->root; - ctx->fmt_offset = 0; - ctx->head->parent_offset = 0; - ctx->new_packmode = '@'; - ctx->enc_packmode = '@'; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->is_complex = 0; - ctx->is_valid_array = 0; - ctx->struct_alignment = 0; - while (type->typegroup == 'S') { - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = 0; - type = type->fields->type; - } -} -static int __Pyx_BufFmt_ParseNumber(const char** ts) { - int count; - const char* t = *ts; - if (*t < '0' || *t > '9') { - return -1; - } else { - count = *t++ - '0'; - while (*t >= '0' && *t <= '9') { - count *= 10; - count += *t++ - '0'; - } - } - *ts = t; - return count; -} -static int __Pyx_BufFmt_ExpectNumber(const char **ts) { - int number = __Pyx_BufFmt_ParseNumber(ts); - if (number == -1) - PyErr_Format(PyExc_ValueError,\ - "Does not understand character buffer dtype format string ('%c')", **ts); - return number; -} -static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { - PyErr_Format(PyExc_ValueError, - "Unexpected format string character: '%c'", ch); -} -static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { - switch (ch) { - case '?': return "'bool'"; - case 'c': return "'char'"; - case 'b': return "'signed char'"; - case 'B': return "'unsigned char'"; - case 'h': return "'short'"; - case 'H': return "'unsigned short'"; - case 'i': return "'int'"; - case 'I': return "'unsigned int'"; - case 'l': return "'long'"; - case 'L': return "'unsigned long'"; - case 'q': return "'long long'"; - case 'Q': return "'unsigned long long'"; - case 'f': return (is_complex ? "'complex float'" : "'float'"); - case 'd': return (is_complex ? "'complex double'" : "'double'"); - case 'g': return (is_complex ? "'complex long double'" : "'long double'"); - case 'T': return "a struct"; - case 'O': return "Python object"; - case 'P': return "a pointer"; - case 's': case 'p': return "a string"; - case 0: return "end"; - default: return "unparseable format string"; - } -} -static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return 2; - case 'i': case 'I': case 'l': case 'L': return 4; - case 'q': case 'Q': return 8; - case 'f': return (is_complex ? 8 : 4); - case 'd': return (is_complex ? 16 : 8); - case 'g': { - PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); - return 0; - } - case 'O': case 'P': return sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(short); - case 'i': case 'I': return sizeof(int); - case 'l': case 'L': return sizeof(long); - #ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(PY_LONG_LONG); - #endif - case 'f': return sizeof(float) * (is_complex ? 2 : 1); - case 'd': return sizeof(double) * (is_complex ? 2 : 1); - case 'g': return sizeof(long double) * (is_complex ? 2 : 1); - case 'O': case 'P': return sizeof(void*); - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } - } -} -typedef struct { char c; short x; } __Pyx_st_short; -typedef struct { char c; int x; } __Pyx_st_int; -typedef struct { char c; long x; } __Pyx_st_long; -typedef struct { char c; float x; } __Pyx_st_float; -typedef struct { char c; double x; } __Pyx_st_double; -typedef struct { char c; long double x; } __Pyx_st_longdouble; -typedef struct { char c; void *x; } __Pyx_st_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_st_float) - sizeof(float); - case 'd': return sizeof(__Pyx_st_double) - sizeof(double); - case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -/* These are for computing the padding at the end of the struct to align - on the first member of the struct. This will probably the same as above, - but we don't have any guarantees. - */ -typedef struct { short x; char c; } __Pyx_pad_short; -typedef struct { int x; char c; } __Pyx_pad_int; -typedef struct { long x; char c; } __Pyx_pad_long; -typedef struct { float x; char c; } __Pyx_pad_float; -typedef struct { double x; char c; } __Pyx_pad_double; -typedef struct { long double x; char c; } __Pyx_pad_longdouble; -typedef struct { void *x; char c; } __Pyx_pad_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); - case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); - case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { - switch (ch) { - case 'c': - return 'H'; - case 'b': case 'h': case 'i': - case 'l': case 'q': case 's': case 'p': - return 'I'; - case '?': case 'B': case 'H': case 'I': case 'L': case 'Q': - return 'U'; - case 'f': case 'd': case 'g': - return (is_complex ? 'C' : 'R'); - case 'O': - return 'O'; - case 'P': - return 'P'; - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } - } -} -static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { - if (ctx->head == NULL || ctx->head->field == &ctx->root) { - const char* expected; - const char* quote; - if (ctx->head == NULL) { - expected = "end"; - quote = ""; - } else { - expected = ctx->head->field->type->name; - quote = "'"; - } - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected %s%s%s but got %s", - quote, expected, quote, - __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); - } else { - __Pyx_StructField* field = ctx->head->field; - __Pyx_StructField* parent = (ctx->head - 1)->field; - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", - field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), - parent->type->name, field->name); - } -} -static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { - char group; - size_t size, offset, arraysize = 1; - if (ctx->enc_type == 0) return 0; - if (ctx->head->field->type->arraysize[0]) { - int i, ndim = 0; - if (ctx->enc_type == 's' || ctx->enc_type == 'p') { - ctx->is_valid_array = ctx->head->field->type->ndim == 1; - ndim = 1; - if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { - PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %zu", - ctx->head->field->type->arraysize[0], ctx->enc_count); - return -1; - } - } - if (!ctx->is_valid_array) { - PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", - ctx->head->field->type->ndim, ndim); - return -1; - } - for (i = 0; i < ctx->head->field->type->ndim; i++) { - arraysize *= ctx->head->field->type->arraysize[i]; - } - ctx->is_valid_array = 0; - ctx->enc_count = 1; - } - group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); - do { - __Pyx_StructField* field = ctx->head->field; - __Pyx_TypeInfo* type = field->type; - if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { - size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); - } else { - size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); - } - if (ctx->enc_packmode == '@') { - size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); - size_t align_mod_offset; - if (align_at == 0) return -1; - align_mod_offset = ctx->fmt_offset % align_at; - if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; - if (ctx->struct_alignment == 0) - ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, - ctx->is_complex); - } - if (type->size != size || type->typegroup != group) { - if (type->typegroup == 'C' && type->fields != NULL) { - size_t parent_offset = ctx->head->parent_offset + field->offset; - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = parent_offset; - continue; - } - if ((type->typegroup == 'H' || group == 'H') && type->size == size) { - } else { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; - } - } - offset = ctx->head->parent_offset + field->offset; - if (ctx->fmt_offset != offset) { - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", - (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); - return -1; - } - ctx->fmt_offset += size; - if (arraysize) - ctx->fmt_offset += (arraysize - 1) * size; - --ctx->enc_count; - while (1) { - if (field == &ctx->root) { - ctx->head = NULL; - if (ctx->enc_count != 0) { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; - } - break; - } - ctx->head->field = ++field; - if (field->type == NULL) { - --ctx->head; - field = ctx->head->field; - continue; - } else if (field->type->typegroup == 'S') { - size_t parent_offset = ctx->head->parent_offset + field->offset; - if (field->type->fields->type == NULL) continue; - field = field->type->fields; - ++ctx->head; - ctx->head->field = field; - ctx->head->parent_offset = parent_offset; - break; - } else { - break; - } - } - } while (ctx->enc_count); - ctx->enc_type = 0; - ctx->is_complex = 0; - return 0; -} -static PyObject * -__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) -{ - const char *ts = *tsp; - int i = 0, number, ndim; - ++ts; - if (ctx->new_count != 1) { - PyErr_SetString(PyExc_ValueError, - "Cannot handle repeated arrays in format string"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ndim = ctx->head->field->type->ndim; - while (*ts && *ts != ')') { - switch (*ts) { - case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; - default: break; - } - number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) - return PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %d", - ctx->head->field->type->arraysize[i], number); - if (*ts != ',' && *ts != ')') - return PyErr_Format(PyExc_ValueError, - "Expected a comma in format string, got '%c'", *ts); - if (*ts == ',') ts++; - i++; - } - if (i != ndim) - return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", - ctx->head->field->type->ndim, i); - if (!*ts) { - PyErr_SetString(PyExc_ValueError, - "Unexpected end of format string, expected ')'"); - return NULL; - } - ctx->is_valid_array = 1; - ctx->new_count = 1; - *tsp = ++ts; - return Py_None; -} -static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { - int got_Z = 0; - while (1) { - switch(*ts) { - case 0: - if (ctx->enc_type != 0 && ctx->head == NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - if (ctx->head != NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - return ts; - case ' ': - case '\r': - case '\n': - ++ts; - break; - case '<': - if (!__Pyx_Is_Little_Endian()) { - PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '>': - case '!': - if (__Pyx_Is_Little_Endian()) { - PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '=': - case '@': - case '^': - ctx->new_packmode = *ts++; - break; - case 'T': - { - const char* ts_after_sub; - size_t i, struct_count = ctx->new_count; - size_t struct_alignment = ctx->struct_alignment; - ctx->new_count = 1; - ++ts; - if (*ts != '{') { - PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - ctx->enc_count = 0; - ctx->struct_alignment = 0; - ++ts; - ts_after_sub = ts; - for (i = 0; i != struct_count; ++i) { - ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); - if (!ts_after_sub) return NULL; - } - ts = ts_after_sub; - if (struct_alignment) ctx->struct_alignment = struct_alignment; - } - break; - case '}': - { - size_t alignment = ctx->struct_alignment; - ++ts; - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - if (alignment && ctx->fmt_offset % alignment) { - ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); - } - } - return ts; - case 'x': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->fmt_offset += ctx->new_count; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->enc_packmode = ctx->new_packmode; - ++ts; - break; - case 'Z': - got_Z = 1; - ++ts; - if (*ts != 'f' && *ts != 'd' && *ts != 'g') { - __Pyx_BufFmt_RaiseUnexpectedChar('Z'); - return NULL; - } - CYTHON_FALLTHROUGH; - case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': - case 'l': case 'L': case 'q': case 'Q': - case 'f': case 'd': case 'g': - case 'O': case 'p': - if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) && - (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) { - ctx->enc_count += ctx->new_count; - ctx->new_count = 1; - got_Z = 0; - ++ts; - break; - } - CYTHON_FALLTHROUGH; - case 's': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_count = ctx->new_count; - ctx->enc_packmode = ctx->new_packmode; - ctx->enc_type = *ts; - ctx->is_complex = got_Z; - ++ts; - ctx->new_count = 1; - got_Z = 0; - break; - case ':': - ++ts; - while(*ts != ':') ++ts; - ++ts; - break; - case '(': - if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; - break; - default: - { - int number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - ctx->new_count = (size_t)number; - } - } - } -} - -/* BufferGetAndValidate */ - static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { - if (unlikely(info->buf == NULL)) return; - if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; - __Pyx_ReleaseBuffer(info); -} -static void __Pyx_ZeroBuffer(Py_buffer* buf) { - buf->buf = NULL; - buf->obj = NULL; - buf->strides = __Pyx_zeros; - buf->shape = __Pyx_zeros; - buf->suboffsets = __Pyx_minusones; -} -static int __Pyx__GetBufferAndValidate( - Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, - int nd, int cast, __Pyx_BufFmt_StackElem* stack) -{ - buf->buf = NULL; - if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) { - __Pyx_ZeroBuffer(buf); - return -1; - } - if (unlikely(buf->ndim != nd)) { - PyErr_Format(PyExc_ValueError, - "Buffer has wrong number of dimensions (expected %d, got %d)", - nd, buf->ndim); - goto fail; - } - if (!cast) { - __Pyx_BufFmt_Context ctx; - __Pyx_BufFmt_Init(&ctx, stack, dtype); - if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; - } - if (unlikely((size_t)buf->itemsize != dtype->size)) { - PyErr_Format(PyExc_ValueError, - "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", - buf->itemsize, (buf->itemsize > 1) ? "s" : "", - dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); - goto fail; - } - if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; - return 0; -fail:; - __Pyx_SafeReleaseBuffer(buf); - return -1; -} - -/* BufferIndexError */ - static void __Pyx_RaiseBufferIndexError(int axis) { - PyErr_Format(PyExc_IndexError, - "Out of bounds on buffer access (axis %d)", axis); -} - -/* PyIntBinop */ - #if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_SubtractCObj(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { - (void)inplace; - (void)zerodivision_check; - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op2))) { - const long a = intval; - long x; - long b = PyInt_AS_LONG(op2); - x = (long)((unsigned long)a - b); - if (likely((x^a) >= 0 || (x^~b) >= 0)) - return PyInt_FromLong(x); - return PyLong_Type.tp_as_number->nb_subtract(op1, op2); - } - #endif - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op2))) { - const long a = intval; - long b, x; -#ifdef HAVE_LONG_LONG - const PY_LONG_LONG lla = intval; - PY_LONG_LONG llb, llx; -#endif - const digit* digits = ((PyLongObject*)op2)->ob_digit; - const Py_ssize_t size = Py_SIZE(op2); - if (likely(__Pyx_sst_abs(size) <= 1)) { - b = likely(size) ? digits[0] : 0; - if (size == -1) b = -b; - } else { - switch (size) { - case -2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - b = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - llb = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case -3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - b = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - llb = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - llb = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case -4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - b = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - llb = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - llb = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2); - } - } - x = a - b; - return PyLong_FromLong(x); -#ifdef HAVE_LONG_LONG - long_long: - llx = lla - llb; - return PyLong_FromLongLong(llx); -#endif - - - } - #endif - if (PyFloat_CheckExact(op2)) { - const long a = intval; - double b = PyFloat_AS_DOUBLE(op2); - double result; - PyFPE_START_PROTECT("subtract", return NULL) - result = ((double)a) - (double)b; - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); - } - return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2); -} -#endif - -/* PyFloatBinop */ - #if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyFloat_SubtractCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) { - const double a = floatval; - double b, result; - (void)inplace; - (void)zerodivision_check; - if (likely(PyFloat_CheckExact(op2))) { - b = PyFloat_AS_DOUBLE(op2); - - } else - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op2))) { - b = (double) PyInt_AS_LONG(op2); - - } else - #endif - if (likely(PyLong_CheckExact(op2))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)op2)->ob_digit; - const Py_ssize_t size = Py_SIZE(op2); - switch (size) { - case 0: b = 0.0; break; - case -1: b = -(double) digits[0]; break; - case 1: b = (double) digits[0]; break; - case -2: - case 2: - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) { - b = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -2) - b = -b; - break; - } - } - CYTHON_FALLTHROUGH; - case -3: - case 3: - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) { - b = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -3) - b = -b; - break; - } - } - CYTHON_FALLTHROUGH; - case -4: - case 4: - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) { - b = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -4) - b = -b; - break; - } - } - CYTHON_FALLTHROUGH; - default: - #else - { - #endif - b = PyLong_AsDouble(op2); - if (unlikely(b == -1.0 && PyErr_Occurred())) return NULL; - - } - } else { - return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2); - } - - PyFPE_START_PROTECT("subtract", return NULL) - result = a - b; - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); -} -#endif - -/* PyIntCompare */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) { - if (op1 == op2) { - Py_RETURN_TRUE; - } - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op1))) { - const long b = intval; - long a = PyInt_AS_LONG(op1); - if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE; - } - #endif - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op1))) { - int unequal; - unsigned long uintval; - Py_ssize_t size = Py_SIZE(op1); - const digit* digits = ((PyLongObject*)op1)->ob_digit; - if (intval == 0) { - if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE; - } else if (intval < 0) { - if (size >= 0) - Py_RETURN_FALSE; - intval = -intval; - size = -size; - } else { - if (size <= 0) - Py_RETURN_FALSE; - } - uintval = (unsigned long) intval; -#if PyLong_SHIFT * 4 < SIZEOF_LONG*8 - if (uintval >> (PyLong_SHIFT * 4)) { - unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) - | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); - } else -#endif -#if PyLong_SHIFT * 3 < SIZEOF_LONG*8 - if (uintval >> (PyLong_SHIFT * 3)) { - unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) - | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); - } else -#endif -#if PyLong_SHIFT * 2 < SIZEOF_LONG*8 - if (uintval >> (PyLong_SHIFT * 2)) { - unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) - | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); - } else -#endif -#if PyLong_SHIFT * 1 < SIZEOF_LONG*8 - if (uintval >> (PyLong_SHIFT * 1)) { - unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) - | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); - } else -#endif - unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK)); - if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE; - } - #endif - if (PyFloat_CheckExact(op1)) { - const long b = intval; - double a = PyFloat_AS_DOUBLE(op1); - if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE; - } - return ( - PyObject_RichCompare(op1, op2, Py_EQ)); -} - -/* GetItemInt */ - static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!j) return NULL; - r = PyObject_GetItem(o, j); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyList_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyTuple_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* ObjectGetItem */ - #if CYTHON_USE_TYPE_SLOTS -static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { - PyObject *runerr; - Py_ssize_t key_value; - PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; - if (unlikely(!(m && m->sq_item))) { - PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); - return NULL; - } - key_value = __Pyx_PyIndex_AsSsize_t(index); - if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { - return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); - } - if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { - PyErr_Clear(); - PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); - } - return NULL; -} -static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { - PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; - if (likely(m && m->mp_subscript)) { - return m->mp_subscript(obj, key); - } - return __Pyx_PyObject_GetIndex(obj, key); -} -#endif - -/* PyFloatBinop */ - #if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyFloat_DivideObjC(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) { - const double b = floatval; - double a, result; - (void)inplace; - (void)zerodivision_check; - if (likely(PyFloat_CheckExact(op1))) { - a = PyFloat_AS_DOUBLE(op1); - - } else - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op1))) { - a = (double) PyInt_AS_LONG(op1); - - } else - #endif - if (likely(PyLong_CheckExact(op1))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)op1)->ob_digit; - const Py_ssize_t size = Py_SIZE(op1); - switch (size) { - case 0: a = 0.0; break; - case -1: a = -(double) digits[0]; break; - case 1: a = (double) digits[0]; break; - case -2: - case 2: - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) { - a = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -2) - a = -a; - break; - } - } - CYTHON_FALLTHROUGH; - case -3: - case 3: - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) { - a = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -3) - a = -a; - break; - } - } - CYTHON_FALLTHROUGH; - case -4: - case 4: - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) { - a = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -4) - a = -a; - break; - } - } - CYTHON_FALLTHROUGH; - default: - #else - { - #endif - a = PyLong_AsDouble(op1); - if (unlikely(a == -1.0 && PyErr_Occurred())) return NULL; - - } - } else { - return (inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2)); - } - - PyFPE_START_PROTECT("divide", return NULL) - result = a / b; - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); -} -#endif - -/* PyFloatBinop */ - #if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyFloat_AddCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) { - const double a = floatval; - double b, result; - (void)inplace; - (void)zerodivision_check; - if (likely(PyFloat_CheckExact(op2))) { - b = PyFloat_AS_DOUBLE(op2); - - } else - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op2))) { - b = (double) PyInt_AS_LONG(op2); - - } else - #endif - if (likely(PyLong_CheckExact(op2))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)op2)->ob_digit; - const Py_ssize_t size = Py_SIZE(op2); - switch (size) { - case 0: b = 0.0; break; - case -1: b = -(double) digits[0]; break; - case 1: b = (double) digits[0]; break; - case -2: - case 2: - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) { - b = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -2) - b = -b; - break; - } - } - CYTHON_FALLTHROUGH; - case -3: - case 3: - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) { - b = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -3) - b = -b; - break; - } - } - CYTHON_FALLTHROUGH; - case -4: - case 4: - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) { - b = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) { - if (size == -4) - b = -b; - break; - } - } - CYTHON_FALLTHROUGH; - default: - #else - { - #endif - b = PyLong_AsDouble(op2); - if (unlikely(b == -1.0 && PyErr_Occurred())) return NULL; - - } - } else { - return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); - } - - PyFPE_START_PROTECT("add", return NULL) - result = a + b; - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); -} -#endif - -/* PyErrFetchRestore */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -} -#endif - -/* RaiseArgTupleInvalid */ - static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} - -/* RaiseDoubleKeywords */ - static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -/* ParseKeywords */ - static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* WriteUnraisableException */ - static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, - CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, - int full_traceback, CYTHON_UNUSED int nogil) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - __Pyx_PyThreadState_declare -#ifdef WITH_THREAD - PyGILState_STATE state; - if (nogil) - state = PyGILState_Ensure(); -#ifdef _MSC_VER - else state = (PyGILState_STATE)-1; -#endif -#endif - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); - if (full_traceback) { - Py_XINCREF(old_exc); - Py_XINCREF(old_val); - Py_XINCREF(old_tb); - __Pyx_ErrRestore(old_exc, old_val, old_tb); - PyErr_PrintEx(1); - } - #if PY_MAJOR_VERSION < 3 - ctx = PyString_FromString(name); - #else - ctx = PyUnicode_FromString(name); - #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } -#ifdef WITH_THREAD - if (nogil) - PyGILState_Release(state); -#endif -} - -/* BufferFallbackError */ - static void __Pyx_RaiseBufferFallbackError(void) { - PyErr_SetString(PyExc_ValueError, - "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); -} - -/* ArgTypeTest */ - static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) -{ - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - else if (exact) { - #if PY_MAJOR_VERSION == 2 - if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif - } - else { - if (likely(__Pyx_TypeCheck(obj, type))) return 1; - } - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); - return 0; -} - -/* GetTopmostException */ - #if CYTHON_USE_EXC_INFO_STACK -static _PyErr_StackItem * -__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) -{ - _PyErr_StackItem *exc_info = tstate->exc_info; - while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && - exc_info->previous_item != NULL) - { - exc_info = exc_info->previous_item; - } - return exc_info; -} -#endif - -/* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - #if CYTHON_USE_EXC_INFO_STACK - _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); - *type = exc_info->exc_type; - *value = exc_info->exc_value; - *tb = exc_info->exc_traceback; - #else - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - #endif - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -} -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - #if CYTHON_USE_EXC_INFO_STACK - _PyErr_StackItem *exc_info = tstate->exc_info; - tmp_type = exc_info->exc_type; - tmp_value = exc_info->exc_value; - tmp_tb = exc_info->exc_traceback; - exc_info->exc_type = type; - exc_info->exc_value = value; - exc_info->exc_traceback = tb; - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -#endif - -/* PyErrExceptionMatches */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; icurexc_type; - if (exc_type == err) return 1; - if (unlikely(!exc_type)) return 0; - if (unlikely(PyTuple_Check(err))) - return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); - return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); -} -#endif - -/* GetException */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) -#endif -{ - PyObject *local_type, *local_value, *local_tb; -#if CYTHON_FAST_THREAD_STATE - PyObject *tmp_type, *tmp_value, *tmp_tb; - local_type = tstate->curexc_type; - local_value = tstate->curexc_value; - local_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -#else - PyErr_Fetch(&local_type, &local_value, &local_tb); -#endif - PyErr_NormalizeException(&local_type, &local_value, &local_tb); -#if CYTHON_FAST_THREAD_STATE - if (unlikely(tstate->curexc_type)) -#else - if (unlikely(PyErr_Occurred())) -#endif - goto bad; - #if PY_MAJOR_VERSION >= 3 - if (local_tb) { - if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) - goto bad; - } - #endif - Py_XINCREF(local_tb); - Py_XINCREF(local_type); - Py_XINCREF(local_value); - *type = local_type; - *value = local_value; - *tb = local_tb; -#if CYTHON_FAST_THREAD_STATE - #if CYTHON_USE_EXC_INFO_STACK - { - _PyErr_StackItem *exc_info = tstate->exc_info; - tmp_type = exc_info->exc_type; - tmp_value = exc_info->exc_value; - tmp_tb = exc_info->exc_traceback; - exc_info->exc_type = local_type; - exc_info->exc_value = local_value; - exc_info->exc_traceback = local_tb; - } - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = local_type; - tstate->exc_value = local_value; - tstate->exc_traceback = local_tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(local_type, local_value, local_tb); -#endif - return 0; -bad: - *type = 0; - *value = 0; - *tb = 0; - Py_XDECREF(local_type); - Py_XDECREF(local_value); - Py_XDECREF(local_tb); - return -1; -} - -/* RaiseException */ - #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - __Pyx_PyThreadState_declare - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - } - if (PyType_Check(type)) { -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; - } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - value = type; - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - } - __Pyx_PyThreadState_assign - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { - PyObject* owned_instance = NULL; - if (tb == Py_None) { - tb = 0; - } else if (tb && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto bad; - } - if (value == Py_None) - value = 0; - if (PyExceptionInstance_Check(type)) { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto bad; - } - value = type; - type = (PyObject*) Py_TYPE(value); - } else if (PyExceptionClass_Check(type)) { - PyObject *instance_class = NULL; - if (value && PyExceptionInstance_Check(value)) { - instance_class = (PyObject*) Py_TYPE(value); - if (instance_class != type) { - int is_subclass = PyObject_IsSubclass(instance_class, type); - if (!is_subclass) { - instance_class = NULL; - } else if (unlikely(is_subclass == -1)) { - goto bad; - } else { - type = instance_class; - } - } - } - if (!instance_class) { - PyObject *args; - if (!value) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } else - args = PyTuple_Pack(1, value); - if (!args) - goto bad; - owned_instance = PyObject_Call(type, args, NULL); - Py_DECREF(args); - if (!owned_instance) - goto bad; - value = owned_instance; - if (!PyExceptionInstance_Check(value)) { - PyErr_Format(PyExc_TypeError, - "calling %R should have returned an instance of " - "BaseException, not %R", - type, Py_TYPE(value)); - goto bad; - } - } - } else { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto bad; - } - if (cause) { - PyObject *fixed_cause; - if (cause == Py_None) { - fixed_cause = NULL; - } else if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); - if (fixed_cause == NULL) - goto bad; - } else if (PyExceptionInstance_Check(cause)) { - fixed_cause = cause; - Py_INCREF(fixed_cause); - } else { - PyErr_SetString(PyExc_TypeError, - "exception causes must derive from " - "BaseException"); - goto bad; - } - PyException_SetCause(value, fixed_cause); - } - PyErr_SetObject(type, value); - if (tb) { -#if CYTHON_COMPILING_IN_PYPY - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); - Py_INCREF(tb); - PyErr_Restore(tmp_type, tmp_value, tb); - Py_XDECREF(tmp_tb); -#else - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject* tmp_tb = tstate->curexc_traceback; - if (tb != tmp_tb) { - Py_INCREF(tb); - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_tb); - } -#endif - } -bad: - Py_XDECREF(owned_instance); - return; -} -#endif - -/* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType -#define __PYX_HAVE_RT_ImportType -static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, - size_t size, enum __Pyx_ImportType_CheckSize check_size) -{ - PyObject *result = 0; - char warning[200]; - Py_ssize_t basicsize; -#ifdef Py_LIMITED_API - PyObject *py_basicsize; -#endif - result = PyObject_GetAttrString(module, class_name); - if (!result) - goto bad; - if (!PyType_Check(result)) { - PyErr_Format(PyExc_TypeError, - "%.200s.%.200s is not a type object", - module_name, class_name); - goto bad; - } -#ifndef Py_LIMITED_API - basicsize = ((PyTypeObject *)result)->tp_basicsize; -#else - py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); - if (!py_basicsize) - goto bad; - basicsize = PyLong_AsSsize_t(py_basicsize); - Py_DECREF(py_basicsize); - py_basicsize = 0; - if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) - goto bad; -#endif - if ((size_t)basicsize < size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - goto bad; - } - if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - goto bad; - } - else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) { - PyOS_snprintf(warning, sizeof(warning), - "%s.%s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; - } - return (PyTypeObject *)result; -bad: - Py_XDECREF(result); - return NULL; -} -#endif - -/* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_MAJOR_VERSION < 3 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; - } - #endif - if (!module) { - #if PY_MAJOR_VERSION < 3 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } -bad: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_list); - Py_XDECREF(empty_dict); - return module; -} - -/* ImportFrom */ - static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { - PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); - if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Format(PyExc_ImportError, - #if PY_MAJOR_VERSION < 3 - "cannot import name %.230s", PyString_AS_STRING(name)); - #else - "cannot import name %S", name); - #endif - } - return value; -} - -/* CLineInTraceback */ - #ifndef CYTHON_CLINE_IN_TRACEBACK -static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) { - PyObject *use_cline; - PyObject *ptype, *pvalue, *ptraceback; -#if CYTHON_COMPILING_IN_CPYTHON - PyObject **cython_runtime_dict; -#endif - if (unlikely(!__pyx_cython_runtime)) { - return c_line; - } - __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); -#if CYTHON_COMPILING_IN_CPYTHON - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (likely(cython_runtime_dict)) { - __PYX_PY_DICT_LOOKUP_IF_MODIFIED( - use_cline, *cython_runtime_dict, - __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) - } else -#endif - { - PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); - if (use_cline_obj) { - use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; - Py_DECREF(use_cline_obj); - } else { - PyErr_Clear(); - use_cline = NULL; - } - } - if (!use_cline) { - c_line = 0; - PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); - } - else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { - c_line = 0; - } - __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); - return c_line; -} -#endif - -/* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { - int start = 0, mid = 0, end = count - 1; - if (end >= 0 && code_line > entries[end].code_line) { - return count; - } - while (start < end) { - mid = start + (end - start) / 2; - if (code_line < entries[mid].code_line) { - end = mid; - } else if (code_line > entries[mid].code_line) { - start = mid + 1; - } else { - return mid; - } - } - if (code_line <= entries[mid].code_line) { - return mid; - } else { - return mid + 1; - } -} -static PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_code_cache.count = 1; - entries[0].code_line = code_line; - entries[0].code_object = code_object; - Py_INCREF(code_object); - } - return; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -/* AddTraceback */ - #include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, - 0, - 0, - 0, - 0, - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - return NULL; -} -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyFrameObject *py_frame = 0; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - if (c_line) { - c_line = __Pyx_CLineForTraceback(tstate, c_line); - } - py_code = __pyx_find_code_object(c_line ? -c_line : py_line); - if (!py_code) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); - } - py_frame = PyFrame_New( - tstate, /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __pyx_d, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - __Pyx_PyFrame_SetLineNumber(py_frame, py_line); - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} - -#if PY_MAJOR_VERSION < 3 -static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { - if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); - PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); - return -1; -} -static void __Pyx_ReleaseBuffer(Py_buffer *view) { - PyObject *obj = view->obj; - if (!obj) return; - if (PyObject_CheckBuffer(obj)) { - PyBuffer_Release(view); - return; - } - if ((0)) {} - view->obj = NULL; - Py_DECREF(obj); -} -#endif - - - /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) -#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) -#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ - {\ - func_type value = func_value;\ - if (sizeof(target_type) < sizeof(func_type)) {\ - if (unlikely(value != (func_type) (target_type) value)) {\ - func_type zero = 0;\ - if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ - return (target_type) -1;\ - if (is_unsigned && unlikely(value < zero))\ - goto raise_neg_overflow;\ - else\ - goto raise_overflow;\ - }\ - }\ - return (target_type) value;\ - } - -/* Declarations */ - #if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return ::std::complex< float >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return x + y*(__pyx_t_float_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - __pyx_t_float_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -/* Arithmetic */ - #if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - #if 1 - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - if (b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); - } else if (fabsf(b.real) >= fabsf(b.imag)) { - if (b.real == 0 && b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag); - } else { - float r = b.imag / b.real; - float s = (float)(1.0) / (b.real + b.imag * r); - return __pyx_t_float_complex_from_parts( - (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); - } - } else { - float r = b.real / b.imag; - float s = (float)(1.0) / (b.imag + b.real * r); - return __pyx_t_float_complex_from_parts( - (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); - } - } - #else - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - if (b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); - } else { - float denom = b.real * b.real + b.imag * b.imag; - return __pyx_t_float_complex_from_parts( - (a.real * b.real + a.imag * b.imag) / denom, - (a.imag * b.real - a.real * b.imag) / denom); - } - } - #endif - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrtf(z.real*z.real + z.imag*z.imag); - #else - return hypotf(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - float r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - float denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - return __Pyx_c_prod_float(a, a); - case 3: - z = __Pyx_c_prod_float(a, a); - return __Pyx_c_prod_float(z, a); - case 4: - z = __Pyx_c_prod_float(a, a); - return __Pyx_c_prod_float(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } else if (b.imag == 0) { - z.real = powf(a.real, b.real); - z.imag = 0; - return z; - } else if (a.real > 0) { - r = a.real; - theta = 0; - } else { - r = -a.real; - theta = atan2f(0.0, -1.0); - } - } else { - r = __Pyx_c_abs_float(a); - theta = atan2f(a.imag, a.real); - } - lnr = logf(r); - z_r = expf(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cosf(z_theta); - z.imag = z_r * sinf(z_theta); - return z; - } - #endif -#endif - -/* Declarations */ - #if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return ::std::complex< double >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return x + y*(__pyx_t_double_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - __pyx_t_double_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -/* Arithmetic */ - #if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - #if 1 - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - if (b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); - } else if (fabs(b.real) >= fabs(b.imag)) { - if (b.real == 0 && b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag); - } else { - double r = b.imag / b.real; - double s = (double)(1.0) / (b.real + b.imag * r); - return __pyx_t_double_complex_from_parts( - (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); - } - } else { - double r = b.real / b.imag; - double s = (double)(1.0) / (b.imag + b.real * r); - return __pyx_t_double_complex_from_parts( - (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); - } - } - #else - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - if (b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); - } else { - double denom = b.real * b.real + b.imag * b.imag; - return __pyx_t_double_complex_from_parts( - (a.real * b.real + a.imag * b.imag) / denom, - (a.imag * b.real - a.real * b.imag) / denom); - } - } - #endif - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrt(z.real*z.real + z.imag*z.imag); - #else - return hypot(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - double r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - double denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - return __Pyx_c_prod_double(a, a); - case 3: - z = __Pyx_c_prod_double(a, a); - return __Pyx_c_prod_double(z, a); - case 4: - z = __Pyx_c_prod_double(a, a); - return __Pyx_c_prod_double(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } else if (b.imag == 0) { - z.real = pow(a.real, b.real); - z.imag = 0; - return z; - } else if (a.real > 0) { - r = a.real; - theta = 0; - } else { - r = -a.real; - theta = atan2(0.0, -1.0); - } - } else { - r = __Pyx_c_abs_double(a); - theta = atan2(a.imag, a.real); - } - lnr = log(r); - z_r = exp(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cos(z_theta); - z.imag = z_r * sin(z_theta); - return z; - } - #endif -#endif - -/* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const int neg_one = (int) -1, const_zero = (int) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (int) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) - case -2: - if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - } -#endif - if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int"); - return (int) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const int neg_one = (int) -1, const_zero = (int) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(int) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), - little, !is_unsigned); - } -} - -/* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { - return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { - return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { - return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (long) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) - case -2: - if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - } -#endif - if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to long"); - return (long) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; -} - -/* FastTypeChecks */ - #if CYTHON_COMPILING_IN_CPYTHON -static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { - while (a) { - a = a->tp_base; - if (a == b) - return 1; - } - return b == &PyBaseObject_Type; -} -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { - PyObject *mro; - if (a == b) return 1; - mro = a->tp_mro; - if (likely(mro)) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(mro); - for (i = 0; i < n; i++) { - if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) - return 1; - } - return 0; - } - return __Pyx_InBases(a, b); -} -#if PY_MAJOR_VERSION == 2 -static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { - PyObject *exception, *value, *tb; - int res; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&exception, &value, &tb); - res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - if (!res) { - res = PyObject_IsSubclass(err, exc_type2); - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - } - __Pyx_ErrRestore(exception, value, tb); - return res; -} -#else -static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { - int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; - if (!res) { - res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); - } - return res; -} -#endif -static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - assert(PyExceptionClass_Check(exc_type)); - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; ip) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - if (PyObject_Hash(*t->p) == -1) - return -1; - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { - Py_ssize_t ignore; - return __Pyx_PyObject_AsStringAndSize(o, &ignore); -} -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -#if !CYTHON_PEP393_ENABLED -static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -} -#else -static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (likely(PyUnicode_IS_ASCII(o))) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } -#else - return PyUnicode_AsUTF8AndSize(o, length); -#endif -} -#endif -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { - return __Pyx_PyUnicode_AsStringAndSize(o, length); - } else -#endif -#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif - { - char* result; - int r = PyBytes_AsStringAndSize(o, &result, length); - if (unlikely(r < 0)) { - return NULL; - } else { - return result; - } - } -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { - int is_true = x == Py_True; - if (is_true | (x == Py_False) | (x == Py_None)) return is_true; - else return PyObject_IsTrue(x); -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { - int retval; - if (unlikely(!x)) return -1; - retval = __Pyx_PyObject_IsTrue(x); - Py_DECREF(x); - return retval; -} -static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { -#if PY_MAJOR_VERSION >= 3 - if (PyLong_Check(result)) { - if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, - "__int__ returned non-int (type %.200s). " - "The ability to return an instance of a strict subclass of int " - "is deprecated, and may be removed in a future version of Python.", - Py_TYPE(result)->tp_name)) { - Py_DECREF(result); - return NULL; - } - return result; - } -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - type_name, type_name, Py_TYPE(result)->tp_name); - Py_DECREF(result); - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { -#if CYTHON_USE_TYPE_SLOTS - PyNumberMethods *m; -#endif - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x) || PyLong_Check(x))) -#else - if (likely(PyLong_Check(x))) -#endif - return __Pyx_NewRef(x); -#if CYTHON_USE_TYPE_SLOTS - m = Py_TYPE(x)->tp_as_number; - #if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = m->nb_int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = m->nb_long(x); - } - #else - if (likely(m && m->nb_int)) { - name = "int"; - res = m->nb_int(x); - } - #endif -#else - if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { - res = PyNumber_Int(x); - } -#endif - if (likely(res)) { -#if PY_MAJOR_VERSION < 3 - if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { -#else - if (unlikely(!PyLong_CheckExact(res))) { -#endif - return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); - } - } - else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "an integer is required"); - } - return res; -} -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { - Py_ssize_t ival; - PyObject *x; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) { - if (sizeof(Py_ssize_t) >= sizeof(long)) - return PyInt_AS_LONG(b); - else - return PyInt_AsSsize_t(b); - } -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)b)->ob_digit; - const Py_ssize_t size = Py_SIZE(b); - if (likely(__Pyx_sst_abs(size) <= 1)) { - ival = likely(size) ? digits[0] : 0; - if (size == -1) ival = -ival; - return ival; - } else { - switch (size) { - case 2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - } - } - #endif - return PyLong_AsSsize_t(b); - } - x = PyNumber_Index(b); - if (!x) return -1; - ival = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { - return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { - return PyInt_FromSize_t(ival); -} - - -#endif /* Py_PYTHON_H */ diff --git a/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/temp.win-amd64-3.8/Release/build/oh2004/oh2004.cp38-win_amd64.exp b/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/temp.win-amd64-3.8/Release/build/oh2004/oh2004.cp38-win_amd64.exp deleted file mode 100644 index ce17292..0000000 Binary files a/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/temp.win-amd64-3.8/Release/build/oh2004/oh2004.cp38-win_amd64.exp and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/temp.win-amd64-3.8/Release/build/oh2004/oh2004.cp38-win_amd64.lib b/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/temp.win-amd64-3.8/Release/build/oh2004/oh2004.cp38-win_amd64.lib deleted file mode 100644 index f721eee..0000000 Binary files a/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/temp.win-amd64-3.8/Release/build/oh2004/oh2004.cp38-win_amd64.lib and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/temp.win-amd64-3.8/Release/build/oh2004/oh2004.obj b/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/temp.win-amd64-3.8/Release/build/oh2004/oh2004.obj deleted file mode 100644 index 376ebbc..0000000 Binary files a/landcover-L-SAR/tool/algorithm/algtools/oh2004/build/temp.win-amd64-3.8/Release/build/oh2004/oh2004.obj and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/algtools/oh2004/oh2004.cp38-win_amd64.pyd b/landcover-L-SAR/tool/algorithm/algtools/oh2004/oh2004.cp38-win_amd64.pyd deleted file mode 100644 index 648d72f..0000000 Binary files a/landcover-L-SAR/tool/algorithm/algtools/oh2004/oh2004.cp38-win_amd64.pyd and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/algtools/oh2004/oh2004/Oh2004_inversion.py b/landcover-L-SAR/tool/algorithm/algtools/oh2004/oh2004/Oh2004_inversion.py deleted file mode 100644 index 9a6648a..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/oh2004/oh2004/Oh2004_inversion.py +++ /dev/null @@ -1,90 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Sun Mar 14 18:53:14 2021 - -@author: Dipankar -References ----------- -Oh (2004): Quantitative retrieval of soil moisture content and surface roughness from multipolarized radar observations of bare soil surface. IEEE TGRS 42(3). 596-601. -""" - - # --------------------------------------------------------------------------------------- - # Copyright (C) 2021 by Microwave Remote Sensing Lab, IITBombay http://www.mrslab.in - - # This program is free software; you can redistribute it and/or modify it - # under the terms of the GNU General Public License as published by the Free - # Software Foundation; either version 3 of the License, or (at your option) - # any later version. - # This program is distributed in the hope that it will be useful, but WITHOUT - # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - # more details. - - # You should have received a copy of the GNU General Public License along - # with this program; if not, see http://www.gnu.org/licenses/ - # --------------------------------------------------------------------------------------- - - -import numpy as np -#import matplotlib.pyplot as plt - - -## Description: Given sigma_0_vv, sigma_0_hh, and sigma_0_hv, the inverse -## model computes s, and mv - -sigma0vvdB = -14.1 -sigma0hhdB = -16.0 -sigma0hvdB = -26.5 -theta = 35. ##Incidence angle -f = 5.0 ##GHz - -k = 2*np.pi*f/0.3 #calculate the wave number - - - - -theta_rad = theta*np.pi/180 #represent angle in radians - -sigma_0_vv = np.power(10,(sigma0vvdB/10)) #%represent data in linear scale -sigma_0_hh = np.power(10,(sigma0hhdB/10)) -sigma_0_hv = np.power(10,(sigma0hvdB/10)) - - -p = sigma_0_hh / sigma_0_vv #calculate the p-ratio -q = sigma_0_hv / sigma_0_vv #calculate the q-ratio - -mv0 = np.arange(0.05,0.5,0.01) # set Gamma0 range of values (fine increments) - - - -## First estimates s1 and mv1 -ks = ((-1)*3.125*np.log(1 - sigma_0_hv/(0.11 * mv0**0.7 * (np.cos(theta_rad))**2.2)))**0.556 -err = (1 - (2.*theta_rad/np.pi)**(0.35*mv0**(-0.65)) * np.exp(-0.4 * ks**1.4))-p -abs_err = np.abs(err) -min_err = np.min(abs_err) #find the value of minimum error -mv1 = mv0[np.where(abs_err == min_err)] -ks1 = ((-1)*3.125*np.log(1 - sigma_0_hv/(0.11 * mv1**0.7 * (np.cos(theta_rad))**2.2)))**0.556 -s1 = ks1/k - - -## Second estimate s2 and mv2 -ks2 = (np.log(1-(q/(0.095 * (0.13 + np.sin(1.5*theta_rad))**1.4))) /(-1.3))**(10./9.) -s2 = ks2/k - -xx = (1-p)/np.exp(-0.4 * ks2**1.4) -if xx<=0: - mv2 =0 -else: - yy = np.log(xx)/(0.35*np.log(2*theta_rad/np.pi)) - mv2 = yy**(-100/65) - print(mv2,yy,np.power(yy,-100/65)) -## Third estimate mv3 -mv3 = ((sigma_0_hv/(1 - np.exp(-0.32 * ks2**1.8)))/(0.11 * np.cos(theta_rad)**2.2))**(1/0.7) - -## weighted average s and mv------------------------------------- -sf = (s1 + 0.25*s2)/(1+0.25) -mvf = (mv1+mv2+mv3)/3 -print(mv1,mv2,mv3,s1,s2) - -print('Estimated rms height s (cm): ', sf*100) -print('Estimated volumetric soil moisture: ', mvf) \ No newline at end of file diff --git a/landcover-L-SAR/tool/algorithm/algtools/oh2004/oh2004/oh2004.pyx b/landcover-L-SAR/tool/algorithm/algtools/oh2004/oh2004/oh2004.pyx deleted file mode 100644 index ca2b08d..0000000 --- a/landcover-L-SAR/tool/algorithm/algtools/oh2004/oh2004/oh2004.pyx +++ /dev/null @@ -1,128 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Tue Jun 4 14:59:54 2013 - -@author: Sat Kumar Tomer -@email: satkumartomer@gmail.com -@website: www.ambhas.com - -""" -cimport cython # 必须导入 -import numpy as np##必须为c类型和python类型的数据都申明一个np -cimport numpy as np # 必须为c类型和python类型的数据都申明一个np -from libc.math cimport pi -from scipy.optimize import fmin - -cpdef np.ndarray[double,ndim=1] inverse_oh2004(double sigma0vvdB,double sigma0hhdB,double sigma0hvdB,double theta,double f): - """ - sigma0vvdB = -14.1 dB - sigma0hhdB = -16.0 - sigma0hvdB = -26.5 - theta = 35. 角度值 ##Incidence angle - f = 5.0 ##GHz - """ - #print("--------------------------------------------------------\n") - cdef np.ndarray[double,ndim=1] result=np.ones((2)) - result[0]=np.nan - result[1]=np.nan - #print("*************设置为nan****************") - #print(sigma0vvdB,sigma0hhdB,sigma0hvdB,theta,f) - cdef double k = 2*3.1415926*f/0.299792458; #calculate the wave number - cdef double theta_rad = theta*3.1415926/180; #represent angle in radians - - cdef double sigma_0_vv = np.power(10.,(sigma0vvdB/10.)) #%represent data in linear scale - cdef double sigma_0_hh = np.power(10.,(sigma0hhdB/10.)) - cdef double sigma_0_hv = np.power(10.,(sigma0hvdB/10.)) - - if sigma_0_vv==0: - #print("***********sigma_0_vv==0*************") - return result - cdef double p = sigma_0_hh / sigma_0_vv; #calculate the p-ratio - cdef double q = sigma_0_hv / sigma_0_vv; #calculate the q-ratio - - - cdef np.ndarray[double,ndim=1] mv0 = np.arange(0.05,0.9,0.01) # set Gamma0 range of values (fine increments) - - ## First estimates s1 and mv1 - cdef np.ndarray[double,ndim=1] ks = ((-1.)*3.125*np.log(1 - sigma_0_hv/(0.11 * mv0**0.7 * (np.cos(theta_rad))**2.2)))**0.556 - cdef np.ndarray[double,ndim=1] err = (1. - (2.*theta_rad/np.pi)**(0.35*mv0**(-0.65)) * np.exp(-0.4 * ks**1.4))-p - cdef np.ndarray[double,ndim=1] abs_err = np.abs(err); - cdef double min_err = np.nanmin(abs_err); #find the value of minimum error - #print(np.where(abs_err == min_err)[0].shape) - if min_err==np.nan or np.max(np.where(abs_err == min_err)[0].shape)==0 : - #print("***************min_err==np.nan or np.max(np.where(abs_err == min_err)[0].shape)==0") - return result - cdef double mv1 = mv0[np.where(abs_err == min_err)[0][0]] - cdef double temp_ks1=1. - sigma_0_hv/(0.11 * mv1**0.7 * (np.cos(theta_rad))**2.2) - if temp_ks1<0: - #print("*********************temp_ks1<0") - return result - cdef double ks1 = ((-1)*3.125*np.log(temp_ks1))**0.556 - cdef double s1 = ks1/k - - ## Second estimate s2 and mv2 - cdef double ks2 = (np.log(1-(q/(0.095 * (0.13 + np.sin(1.5*theta_rad))**1.4))) /(-1.3))**(10./9.) - cdef double s2 = ks2/k - cdef double mv2 =0. - cdef double yy =0. - cdef double xx = (1-p)/np.exp(-0.4 * ks2**1.4) - if xx<=0: - mv2 =0. - else: - yy = np.log(xx)/(0.35*np.log(2*theta_rad/np.pi)) - mv2=np.power(yy,-100.0/65) - - ## Third estimate mv3 - cdef double mv3 = ((sigma_0_hv/(1 - np.exp(-0.32 * ks2**1.8)))/(0.11 * np.cos(theta_rad)**2.2))**(1/0.7) - ## weighted average s and mv------------------------------------- - #print("q:\t",q) - #print("k:\t",k) - #print("ks1:\t",ks1) - #print("ks2:\t",ks2) - #print("theta_rad:\t",theta_rad) - - cdef double sf = (s1 + 0.25*s2)/(1+0.25) - cdef double mvf = (mv1+mv2+mv3)/3 - - result[0]=mvf*1.0 - result[1]=sf*1.0 - #print("mv1:\t",mv1) - #print("mv2:\t",mv2) - #print("mv3:\t",mv3) - #print("s1:\t",s1) - #print("s2:\t",s2) - #print("Estimated volumetric soil moisture: ",result[0]) - #print("Estimated rms height s (m): ",result[1]) - #print("\nend\n") - return result - -cpdef double lamda2freq(double lamda): - return 299792458.0/lamda - -cpdef double freq2lamda(double freq): - return 299792458.0/freq - -# double sigma0vvdB,double sigma0hhdB,double sigma0hvdB,double theta,double f -cpdef int retrieve_oh2004_main(int n,np.ndarray[double,ndim=1] mv,np.ndarray[double,ndim=1] h,np.ndarray[int,ndim=1] mask,np.ndarray[double,ndim=1] sigma0vvdB,np.ndarray[double,ndim=1] sigma0hhdB,np.ndarray[double,ndim=1] sigma0hvdB, np.ndarray[double,ndim=1] vh, np.ndarray[double,ndim=1] theta,double f): - cdef int i=0; - cdef np.ndarray[double,ndim=1] result; - while i 2048 and cols > 2048: - block_size = 1024 - return block_size - - # def get_block_size(rows, cols, block_size_config): - # block_size = 512 if block_size_config < 512 else block_size_config - # if rows > 2048 and cols > 2048: - # block_size = block_size_config - # return block_size - - @staticmethod - def get_suffix(path_name): - name = path_name - suffix = '_' + name.split('_')[-4] + '_' + name.split('_')[-3] + '_' + name.split('_')[-2] + '_' + \ - name.split('_')[-1] - return suffix - - @staticmethod - def get_file_names(data_dir, file_type=['tif', 'tiff']): - """ - 获取data_dir文件夹下file_type类型的文件路径 - """ - result_dir = [] - result_name = [] - for maindir, subdir, file_name_list in os.walk(data_dir): - for filename in file_name_list: - apath = os.path.join(maindir, filename) - ext = apath.split('.')[-1] - if ext in file_type: - result_dir.append(apath) - result_name.append(filename) - else: - pass - return result_dir, result_name - - @staticmethod - def get_same_img(img_dir, img_name): - """ - 在img_dir路径下,用img_name的子图像路径集合,将集合以字典输出 - """ - result = {} - for idx, name in enumerate(img_name): - temp_name = '' - for idx2, item in enumerate(name.split('_')[:-4]): - if idx2 == 0: - temp_name = temp_name + item - else: - temp_name = temp_name + '_' + item - - if temp_name in result: - result[temp_name].append(img_dir[idx]) - else: - result[temp_name] = [] - result[temp_name].append(img_dir[idx]) - return result - - @staticmethod - def assign_spatial_reference_byfile(src_path, dst_path): - """ - 将src_path的地理信息,输入到dst_path图像中 - """ - src_ds = gdal.Open(src_path, gdal.GA_ReadOnly) - if src_ds is None: - return False - sr = osr.SpatialReference() - sr.ImportFromWkt(src_ds.GetProjectionRef()) - geo_transform = src_ds.GetGeoTransform() - - dst_ds = gdal.Open(dst_path, gdal.GA_Update) - if dst_ds is None: - return False - dst_ds.SetProjection(sr.ExportToWkt()) - dst_ds.SetGeoTransform(geo_transform) - del dst_ds - del src_ds - return True - - @staticmethod - def assign_spatial_reference_bypoint(row_begin, col_begin, src_proj, src_geo, img_path): - """ - 将src_path的地理信息,输入到dst_path图像中 - """ - - sr = osr.SpatialReference() - sr.ImportFromWkt(src_proj) - geo_transform = src_geo - geo_transform[0] = src_geo[0] + col_begin * src_geo[1] + row_begin * src_geo[2] - geo_transform[3] = src_geo[3] + col_begin * src_geo[4] + row_begin * src_geo[5] - dst_ds = gdal.Open(img_path, gdal.GA_Update) - if dst_ds is None: - return False - dst_ds.SetProjection(sr.ExportToWkt()) - dst_ds.SetGeoTransform(geo_transform) - del dst_ds - return True - - @staticmethod - def __get_band_array(filename, num): - """ - :param filename: tif路径 - :param num: 波段序号 - :return: 对应波段的矩阵数据 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - bands = dataset.GetRasterBand(num) - array = bands.ReadAsArray(0, 0, bands.XSize, bands.YSize) - del dataset - return array - - @staticmethod - def get_data(filename): - """ - :param filename: tif路径 - :return: 获取所有波段的数据 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - im_width = dataset.RasterXSize - im_height = dataset.RasterYSize - im_data = dataset.ReadAsArray(0, 0, im_width, im_height) - del dataset - return im_data - - def get_tif_dtype(self, filename): - """ - :param filename: tif路径 - :return: tif数据类型 - """ - image = self.__get_band_array(filename, 1) - return image.dtype.name - - def cut(self, in_dir, out_dir, file_type=['tif', 'tiff'], out_type='tif', out_size=2048): - """ - :param in_dir:存放待裁剪的影像文件夹,不用指定到tif文件 - :param out_dir:存放裁剪结果的影像文件夹 - :param file_type:待裁剪的影像文件类型tif、tiff、bmp、jpg、png等等 - :param out_type:裁剪结果影像文件类型 - :param out_size:裁剪尺寸,裁剪为n*n的方形 - :return: True or Flase - """ - if not os.path.exists(out_dir): - os.makedirs(out_dir) - data_dir_list, _ = self.get_file_names(in_dir, file_type) - count = 0 - - for each_dir in data_dir_list: - - name_suffix = os.path.basename(each_dir) - img_name = os.path.splitext(name_suffix)[0] - - # gdal读取方法 - image = self.__get_band_array(each_dir, 1) - - cut_factor_row = int(np.ceil(image.shape[0] / out_size)) - cut_factor_clo = int(np.ceil(image.shape[1] / out_size)) - for i in range(cut_factor_row): - for j in range(cut_factor_clo): - - if i == cut_factor_row - 1: - i = image.shape[0] / out_size - 1 - else: - pass - - if j == cut_factor_clo - 1: - j = image.shape[1] / out_size - 1 - else: - pass - - start_x = int(np.rint(i * out_size)) - start_y = int(np.rint(j * out_size)) - end_x = int(np.rint((i + 1) * out_size)) - end_y = int(np.rint((j + 1) * out_size)) - out_dir_images = os.path.join(out_dir, img_name + '_' + str(start_x) + '_' + str(end_x) + '_' + str(start_y) + '_' + str( - end_y) + '.' + out_type) - # + '/' + img_name \ - # + '_' + str(start_x) + '_' + str(end_x) + '_' + str(start_y) + '_' + str( - # end_y) + '.' + out_type - - # temp_image = image[start_x:end_x, start_y:end_y] - # out_image = Image.fromarray(temp_data) - # out_image = Image.fromarray(temp_image) - # out_image.save(out_dir_images) - - data = ImageHandler.get_data(each_dir) - if ImageHandler.get_bands(each_dir) > 1: - temp_data = data[:,start_x:end_x, start_y:end_y] - else: - temp_data = data[start_x:end_x, start_y:end_y] - ImageHandler.write_img(out_dir_images, '', [0, 0, 0, 0, 0, 0], temp_data) - count += 1 - return True - - def cut_new(self, in_dir, out_dir, file_type=['tif', 'tiff'], out_type='tif', out_size=2048): - """ - :param in_dir:存放待裁剪的影像文件夹,不用指定到tif文件 - :param out_dir:存放裁剪结果的影像文件夹 - :param file_type:待裁剪的影像文件类型tif、tiff、bmp、jpg、png等等 - :param out_type:裁剪结果影像文件类型 - :param out_size:裁剪尺寸,裁剪为n*n的方形 - :return: True or Flase - 20230831修改 ----tjx - """ - if not os.path.exists(out_dir): - os.makedirs(out_dir) - data_dir_list, _ = self.get_file_names(in_dir, file_type) - count = 0 - - for each_dir in data_dir_list: - - name_suffix = os.path.basename(each_dir) - img_name = os.path.splitext(name_suffix)[0] - - # gdal读取方法 - image = self.__get_band_array(each_dir, 1) - - block_x = int(np.ceil(image.shape[1] / out_size)) - block_y = int(np.ceil(image.shape[0] / out_size)) # todo 修改分块 - for i in range(block_y): - for j in range(block_x): - start_x = j * out_size - start_y = i * out_size - end_x = image.shape[1] if (j + 1) * out_size > image.shape[1] else (j + 1) * out_size - end_y = image.shape[0] if (i + 1) * out_size > image.shape[0] else (i + 1) * out_size - - out_dir_images = os.path.join(out_dir, img_name + '_' + str(start_x) + '_' + str(end_x) + '_' + str(start_y) + '_' + str( - end_y) + '.' + out_type) - # print(out_dir_images) - - data = ImageHandler.get_data(each_dir) - if ImageHandler.get_bands(each_dir) > 1: - # temp_data = data[:,start_x:end_x, start_y:end_y] - temp_data = data[:,start_y:end_y, start_x:end_x] - else: - # temp_data = data[start_x:end_x, start_y:end_y] - temp_data = data[start_y:end_y, start_x:end_x] - ImageHandler.write_img(out_dir_images, '', [0, 0, 0, 0, 0, 0], temp_data) - count += 1 - return True - - def combine(self, data_dir, w, h, out_dir, out_type='tif', file_type=['tif', 'tiff'], datetype='float16'): - """ - :param data_dir: 存放待裁剪的影像文件夹,不用指定到tif文件 - :param w 拼接影像的宽度, - :param h 拼接影像的高度 - :param out_dir: 存放裁剪结果的影像文件夹 - :param out_type: 裁剪结果影像文件类型 - :param file_type: 待裁剪的影像文件类型 - :param datetype:数据类型 int8,int16,float16,float32 等 - :return: True or Flase - """ - if not os.path.exists(out_dir): - os.makedirs(out_dir) - img_dir, img_name = self.get_file_names(data_dir, file_type) - - dir_dict = self.get_same_img(img_dir, img_name) - count = 0 - for key in dir_dict.keys(): - temp_label = np.zeros(shape=(h, w), dtype=datetype) - dir_list = dir_dict[key] - for item in dir_list: - name_split = item.split('_') - x_start = int(name_split[-4]) - x_end = int(name_split[-3]) - y_start = int(name_split[-2]) - y_end = int(name_split[-1].split('.')[0]) - # img = Image.open(item) - img = ImageHandler.get_band_array(item, 1) - img = np.array(img) - - temp_label[x_start:x_end, y_start:y_end] = img - - img_name = key + '.' + out_type - new_out_dir = os.path.join(out_dir, img_name) - ImageHandler.write_img(new_out_dir, '', [0, 0, 0, 0, 0, 0], temp_label) - # label = Image.fromarray(temp_label) - # label.save(new_out_dir) - - count += 1 - return True - - # todo 20230901 修改分块同步修改合并代码 - def combine_new(self, data_dir, w, h, out_dir, out_type='tif', file_type=['tif', 'tiff'], datetype='float16'): - """ - :param data_dir: 存放待裁剪的影像文件夹,不用指定到tif文件 - :param w 拼接影像的宽度, - :param h 拼接影像的高度 - :param out_dir: 存放裁剪结果的影像文件夹 - :param out_type: 裁剪结果影像文件类型 - :param file_type: 待裁剪的影像文件类型 - :param datetype:数据类型 int8,int16,float16,float32 等 - :return: True or Flase - """ - if not os.path.exists(out_dir): - os.makedirs(out_dir) - img_dir, img_name = self.get_file_names(data_dir, file_type) - - dir_dict = self.get_same_img(img_dir, img_name) - count = 0 - for key in dir_dict.keys(): - dir_list = dir_dict[key] - bands = ImageHandler.get_bands(dir_list[0]) - if bands > 1: - temp_label = np.zeros(shape=(bands, h, w), dtype=datetype) - for item in dir_list: - name_split = item.split('_') - x_start = int(name_split[-4]) - x_end = int(name_split[-3]) - y_start = int(name_split[-2]) - y_end = int(name_split[-1].split('.')[0]) - # img = Image.open(item) - img = ImageHandler.get_band_array(item, 1) - img = np.array(img) - - temp_label[:, y_start:y_end, x_start:x_end] = img - - img_name = key + '.' + out_type - new_out_dir = os.path.join(out_dir, img_name) - ImageHandler.write_img(new_out_dir, '', [0, 0, 0, 0, 0, 0], temp_label) - # label = Image.fromarray(temp_label) - # label.save(new_out_dir) - count += 1 - else: - temp_label = np.zeros(shape=(h, w), dtype=datetype) - for item in dir_list: - name_split = item.split('_') - x_start = int(name_split[-4]) - x_end = int(name_split[-3]) - y_start = int(name_split[-2]) - y_end = int(name_split[-1].split('.')[0]) - # img = Image.open(item) - img = ImageHandler.get_band_array(item, 1) - img = np.array(img) - - temp_label[y_start:y_end, x_start:x_end] = img - - img_name = key + '.' + out_type - new_out_dir = os.path.join(out_dir, img_name) - ImageHandler.write_img(new_out_dir, '', [0, 0, 0, 0, 0, 0], temp_label) - # label = Image.fromarray(temp_label) - # label.save(new_out_dir) - - count += 1 - return True - - def combine_Tif(self, data_dir, w, h, out_dir, proj, geo, out_type='tif', file_type=['tif', 'tiff'], - datetype='float16'): - """ - 将文件夹下的tif拼接成一个大的tif - :param data_dir: 存放待裁剪的影像文件夹,不用指定到tif文件 - :param w 拼接影像的宽度, - :param h 拼接影像的高度 - :param out_dir: 存放裁剪结果的影像文件夹 - :param proj: 指定投影系 - :param geo: 指定变换参数 - :param out_type: 裁剪结果影像文件类型 - :param file_type: 待裁剪的影像文件类型 - :param datetype:数据类型 int8,int16,float16,float32 等 - :return: True or Flase - """ - image_handler = ImageHandler() - if not os.path.exists(out_dir): - os.makedirs(out_dir) - img_dir, img_name = self.get_file_names(data_dir, file_type) - - dir_dict = self.get_same_img(img_dir, img_name) - count = 0 - for key in dir_dict.keys(): - temp_label = np.zeros(shape=(h, w), dtype=datetype) - dir_list = dir_dict[key] - for item in dir_list: - name_split = item.split('_') - x_start = int(name_split[-4]) - x_end = int(name_split[-3]) - y_start = int(name_split[-2]) - y_end = int(name_split[-1].split('.')[0]) - img = image_handler.get_data(item) - temp_label[x_start:x_end, y_start:y_end] = img - - img_name = key + '.' + out_type - new_out_dir = os.path.join(out_dir,img_name) - image_handler.write_img(new_out_dir, proj, geo, temp_label) - count += 1 - return True - -# if __name__ == '__main__': -# bp = BlockProcess() -# # # cut -# data_dir = r"D:\micro\WorkSpace\LandCover\Temporary\processing\feature_tif\cut" -# out_dir = r"D:\micro\WorkSpace\LandCover\Temporary\processing\feature_tif\combine" -# file_type = ['tif'] -# out_type = 'tif' -# cut_size = 1024 -# # -# bp.cut_new(data_dir, out_dir, file_type, out_type, cut_size) -# # # combine -# # data_dir=r"D:\Workspace\SoilMoisture\Temporary\test" -# w= 5043 -# h= 1239 -# out_dirs=r"D:\BaiduNetdiskDownload\HF\cut_outs" -# # out_type='tif' -# # file_type=['tif'] -# datetype = 'float' -# # src_path = r"D:\Workspace\SoilMoisture\Temporary\preprocessed\HH_preprocessed.tif" -# # datetype = bp.get_tif_dtype(src_path) -# bp.combine_new(out_dir, w, h, out_dirs, out_type, file_type, datetype) - - # - # # 添加地理信息 - # new_out_dir =r"D:\DATA\testdata1\combine\TEST_20200429_NDVI.tif" - # bp.assign_spatial_reference_byfile(src_path, new_out_dir) - - # fn = r'D:\Workspace\SoilMoisture\Temporary\combine\soil_moisture.tif' - # product_path = r'D:\Workspace\SoilMoisture\Temporary\combine\soil_moisture_1.tif' - # - # proj, geos, img = ImageHandler.read_img(fn) - # img[img>1] = 1 - # img[img<0] = 0 - # ImageHandler.write_img(product_path, proj, geos, img) - diff --git a/landcover-L-SAR/tool/algorithm/image/ImageHandle.py b/landcover-L-SAR/tool/algorithm/image/ImageHandle.py deleted file mode 100644 index 5aaa021..0000000 --- a/landcover-L-SAR/tool/algorithm/image/ImageHandle.py +++ /dev/null @@ -1,752 +0,0 @@ -""" -@Project :microproduct -@File :ImageHandle.py -@Function :实现对待处理SAR数据的读取、格式标准化和处理完后保存文件功能 -@Author :LMM -@Date :2021/10/19 14:39 -@Version :1.0.0 -""" -import os -import time - -from PIL import Image -from osgeo import gdal -from osgeo import osr -import numpy as np -from PIL import Image -import cv2 -import logging - -import math -logger = logging.getLogger("mylog") - - -class ImageHandler: - """ - 影像读取、编辑、保存 - """ - def __init__(self): - pass - @staticmethod - def get_dataset(filename): - """ - :param filename: tif路径 - :return: 图像句柄 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - return dataset - - def get_scope(self, filename): - """ - :param filename: tif路径 - :return: 图像范围 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - im_scope = self.cal_img_scope(dataset) - del dataset - return im_scope - - @staticmethod - def get_projection(filename): - """ - :param filename: tif路径 - :return: 地图投影信息 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - im_proj = dataset.GetProjection() - del dataset - return im_proj - - @staticmethod - def get_geotransform(filename): - """ - :param filename: tif路径 - :return: 从图像坐标空间(行、列),也称为(像素、线)到地理参考坐标空间(投影或地理坐标)的仿射变换 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - geotransform = dataset.GetGeoTransform() - del dataset - return geotransform - - def get_invgeotransform(filename): - """ - :param filename: tif路径 - :return: 从地理参考坐标空间(投影或地理坐标)的到图像坐标空间(行、列 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - geotransform = dataset.GetGeoTransform() - geotransform=gdal.InvGeoTransform(geotransform) - del dataset - return geotransform - - @staticmethod - def get_bands(filename): - """ - :param filename: tif路径 - :return: 影像的波段数 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - bands = dataset.RasterCount - del dataset - return bands - - @staticmethod - def geo2lonlat(dataset, x, y): - """ - 将投影坐标转为经纬度坐标(具体的投影坐标系由给定数据确定) - :param dataset: GDAL地理数据 - :param x: 投影坐标x - :param y: 投影坐标y - :return: 投影坐标(x, y)对应的经纬度坐标(lon, lat) - """ - prosrs = osr.SpatialReference() - prosrs.ImportFromWkt(dataset.GetProjection()) - geosrs = prosrs.CloneGeogCS() - ct = osr.CoordinateTransformation(prosrs, geosrs) - coords = ct.TransformPoint(x, y) - return coords[:2] - - @staticmethod - def get_band_array(filename, num=1): - """ - :param filename: tif路径 - :param num: 波段序号 - :return: 对应波段的矩阵数据 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - bands = dataset.GetRasterBand(num) - array = bands.ReadAsArray(0, 0, bands.XSize, bands.YSize) - - # if 'int' in str(array.dtype): - # array[np.where(array == -9999)] = np.inf - # else: - # array[np.where(array < -9000.0)] = np.nan - - del dataset - return array - - @staticmethod - def get_data(filename): - """ - :param filename: tif路径 - :return: 获取所有波段的数据 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - im_width = dataset.RasterXSize - im_height = dataset.RasterYSize - im_data = dataset.ReadAsArray(0, 0, im_width, im_height) - del dataset - return im_data - - @staticmethod - def get_dataset(filename): - """ - :param filename: tif路径 - :return: 获取所有波段的数据 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - return dataset - - @staticmethod - def get_all_band_array(filename): - """ - (大气延迟算法) - 将ERA-5影像所有波段存为一个数组, 波段数在第三维度 get_data()->(37,8,8) - :param filename: 影像路径 get_all_band_array ->(8,8,37) - :return: 影像数组 - """ - dataset = gdal.Open(filename) - x_size = dataset.RasterXSize - y_size = dataset.RasterYSize - nums = dataset.RasterCount - array = np.zeros((y_size, x_size, nums), dtype=float) - if nums == 1: - bands_0 = dataset.GetRasterBand(1) - array = bands_0.ReadAsArray(0, 0, x_size, y_size) - else: - for i in range(0, nums): - bands = dataset.GetRasterBand(i+1) - arr = bands.ReadAsArray(0, 0, x_size, y_size) - array[:, :, i] = arr - return array - - @staticmethod - def get_img_width(filename): - """ - :param filename: tif路径 - :return: 影像宽度 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - width = dataset.RasterXSize - - del dataset - return width - - @staticmethod - def get_img_height(filename): - """ - :param filename: tif路径 - :return: 影像高度 - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - height = dataset.RasterYSize - del dataset - return height - - @staticmethod - def read_img(filename): - """ - 影像读取 - :param filename: - :return: - """ - gdal.AllRegister() - img_dataset = gdal.Open(filename) # 打开文件 - - if img_dataset is None: - msg = 'Could not open ' + filename - logger.error(msg) - return None, None, None - - im_proj = img_dataset.GetProjection() # 地图投影信息 - if im_proj is None: - return None, None, None - im_geotrans = img_dataset.GetGeoTransform() # 仿射矩阵 - - im_width = img_dataset.RasterXSize # 栅格矩阵的行数 - im_height = img_dataset.RasterYSize # 栅格矩阵的行数 - im_arr = img_dataset.ReadAsArray(0, 0, im_width, im_height) - del img_dataset - return im_proj, im_geotrans, im_arr - - def cal_img_scope(self, dataset): - """ - 计算影像的地理坐标范围 - 根据GDAL的六参数模型将影像图上坐标(行列号)转为投影坐标或地理坐标(根据具体数据的坐标系统转换) - :param dataset :GDAL地理数据 - :return: list[point_upleft, point_upright, point_downleft, point_downright] - """ - if dataset is None: - return None - - img_geotrans = dataset.GetGeoTransform() - if img_geotrans is None: - return None - - width = dataset.RasterXSize # 栅格矩阵的列数 - height = dataset.RasterYSize # 栅格矩阵的行数 - - point_upleft = self.trans_rowcol2geo(img_geotrans, 0, 0) - point_upright = self.trans_rowcol2geo(img_geotrans, width, 0) - point_downleft = self.trans_rowcol2geo(img_geotrans, 0, height) - point_downright = self.trans_rowcol2geo(img_geotrans, width, height) - - return [point_upleft, point_upright, point_downleft, point_downright] - - @staticmethod - def get_scope_ori_sim(filename): - """ - 计算影像的地理坐标范围 - 根据GDAL的六参数模型将影像图上坐标(行列号)转为投影坐标或地理坐标(根据具体数据的坐标系统转换) - :param dataset :GDAL地理数据 - :return: list[point_upleft, point_upright, point_downleft, point_downright] - """ - gdal.AllRegister() - dataset = gdal.Open(filename) - if dataset is None: - return None - - width = dataset.RasterXSize # 栅格矩阵的列数 - height = dataset.RasterYSize # 栅格矩阵的行数 - - band1 = dataset.GetRasterBand(1) - array1 = band1.ReadAsArray(0, 0, band1.XSize, band1.YSize) - - band2 = dataset.GetRasterBand(2) - array2 = band2.ReadAsArray(0, 0, band2.XSize, band2.YSize) - - if array1[0, 0] < array1[0, width-1]: - point_upleft = [array1[0, 0], array2[0, 0]] - point_upright = [array1[0, width-1], array2[0, width-1]] - else: - point_upright = [array1[0, 0], array2[0, 0]] - point_upleft = [array1[0, width-1], array2[0, width-1]] - - - if array1[height-1, 0] < array1[height-1, width-1]: - point_downleft = [array1[height - 1, 0], array2[height - 1, 0]] - point_downright = [array1[height - 1, width - 1], array2[height - 1, width - 1]] - else: - point_downright = [array1[height - 1, 0], array2[height - 1, 0]] - point_downleft = [array1[height - 1, width - 1], array2[height - 1, width - 1]] - - - if(array2[0, 0] < array2[height - 1, 0]): - #上下调换顺序 - tmp1 = point_upleft - point_upleft = point_downleft - point_downleft = tmp1 - - tmp2 = point_upright - point_upright = point_downright - point_downright = tmp2 - - return [point_upleft, point_upright, point_downleft, point_downright] - - - @staticmethod - def trans_rowcol2geo(img_geotrans,img_col, img_row): - """ - 据GDAL的六参数模型仿射矩阵将影像图上坐标(行列号)转为投影坐标或地理坐标(根据具体数据的坐标系统转换) - :param img_geotrans: 仿射矩阵 - :param img_col:图像纵坐标 - :param img_row:图像横坐标 - :return: [geo_x,geo_y] - """ - geo_x = img_geotrans[0] + img_geotrans[1] * img_col + img_geotrans[2] * img_row - geo_y = img_geotrans[3] + img_geotrans[4] * img_col + img_geotrans[5] * img_row - return [geo_x, geo_y] - - @staticmethod - def write_era_into_img(filename, im_proj, im_geotrans, im_data): - """ - 影像保存 - :param filename: - :param im_proj: - :param im_geotrans: - :param im_data: - :return: - """ - gdal_dtypes = { - 'int8': gdal.GDT_Byte, - 'unit16': gdal.GDT_UInt16, - 'int16': gdal.GDT_Int16, - 'unit32': gdal.GDT_UInt32, - 'int32': gdal.GDT_Int32, - 'float32': gdal.GDT_Float32, - 'float64': gdal.GDT_Float64, - } - if not gdal_dtypes.get(im_data.dtype.name, None) is None: - datatype = gdal_dtypes[im_data.dtype.name] - else: - datatype = gdal.GDT_Float32 - - # 判读数组维数 - if len(im_data.shape) == 3: - im_height, im_width, im_bands = im_data.shape # shape[0] 行数 - else: - im_bands, (im_height, im_width) = 1, im_data.shape - - # 创建文件 - if os.path.exists(os.path.split(filename)[0]) is False: - os.makedirs(os.path.split(filename)[0]) - - driver = gdal.GetDriverByName("GTiff") # 数据类型必须有,因为要计算需要多大内存空间 - dataset = driver.Create(filename, im_width, im_height, im_bands, datatype) - dataset.SetGeoTransform(im_geotrans) # 写入仿射变换参数 - dataset.SetProjection(im_proj) # 写入投影 - - if im_bands == 1: - dataset.GetRasterBand(1).WriteArray(im_data) # 写入数组数据 - else: - for i in range(im_bands): - dataset.GetRasterBand(i + 1).WriteArray(im_data[:, :, i]) - # dataset.GetRasterBand(i + 1).WriteArray(im_data[i]) - del dataset - - # 写GeoTiff文件 - - @staticmethod - def lat_lon_to_pixel(raster_dataset_path, location): - """From zacharybears.com/using-python-to-translate-latlon-locations-to-pixels-on-a-geotiff/.""" - gdal.AllRegister() - raster_dataset = gdal.Open(raster_dataset_path) - if raster_dataset is None: - return None - ds = raster_dataset - gt = ds.GetGeoTransform() - srs = osr.SpatialReference() - srs.ImportFromWkt(ds.GetProjection()) - srs_lat_lon = srs.CloneGeogCS() - ct = osr.CoordinateTransformation(srs_lat_lon, srs) - new_location = [None, None] - # Change the point locations into the GeoTransform space - (new_location[1], new_location[0], holder) = ct.TransformPoint(location[1], location[0]) - # Translate the x and y coordinates into pixel values - Xp = new_location[0] - Yp = new_location[1] - dGeoTrans = gt - dTemp = dGeoTrans[1] * dGeoTrans[5] - dGeoTrans[2] * dGeoTrans[4] - Xpixel = (dGeoTrans[5] * (Xp - dGeoTrans[0]) - dGeoTrans[2] * (Yp - dGeoTrans[3])) / dTemp - Yline = (dGeoTrans[1] * (Yp - dGeoTrans[3]) - dGeoTrans[4] * (Xp - dGeoTrans[0])) / dTemp - del raster_dataset - return (Xpixel, Yline) - - @staticmethod - def write_img(filename, im_proj, im_geotrans, im_data, no_data='0'): - """ - 影像保存 - :param filename: 保存的路径 - :param im_proj: - :param im_geotrans: - :param im_data: - :param no_data: 把无效值设置为 nodata - :return: - """ - - gdal_dtypes = { - 'int8': gdal.GDT_Byte, - 'unit16': gdal.GDT_UInt16, - 'int16': gdal.GDT_Int16, - 'unit32': gdal.GDT_UInt32, - 'int32': gdal.GDT_Int32, - 'float32': gdal.GDT_Float32, - 'float64': gdal.GDT_Float64, - } - if not gdal_dtypes.get(im_data.dtype.name, None) is None: - datatype = gdal_dtypes[im_data.dtype.name] - else: - datatype = gdal.GDT_Float32 - flag = False - # 判读数组维数 - if len(im_data.shape) == 3: - im_bands, im_height, im_width = im_data.shape - flag = True - else: - im_bands, (im_height, im_width) = 1, im_data.shape - - # 创建文件 - if os.path.exists(os.path.split(filename)[0]) is False: - os.makedirs(os.path.split(filename)[0]) - - driver = gdal.GetDriverByName("GTiff") # 数据类型必须有,因为要计算需要多大内存空间 - dataset = driver.Create(filename, im_width, im_height, im_bands, datatype) - - dataset.SetGeoTransform(im_geotrans) # 写入仿射变换参数 - - dataset.SetProjection(im_proj) # 写入投影 - - if im_bands == 1: - # outRaster.GetRasterBand(1).WriteArray(array) # 写入数组数据 - if flag: - outband = dataset.GetRasterBand(1) - outband.WriteArray(im_data[0]) - if no_data != 'null': - outband.SetNoDataValue(np.double(no_data)) - outband.FlushCache() - else: - outband = dataset.GetRasterBand(1) - outband.WriteArray(im_data) - if no_data != 'null': - outband.SetNoDataValue(np.double(no_data)) - outband.FlushCache() - else: - for i in range(im_bands): - outband = dataset.GetRasterBand(1 + i) - outband.WriteArray(im_data[i]) - if no_data != 'null': - outband.SetNoDataValue(np.double(no_data)) - outband.FlushCache() - # outRaster.GetRasterBand(i + 1).WriteArray(array[i]) - del dataset - - # 写GeoTiff文件 - - @staticmethod - def write_img_envi(filename, im_proj, im_geotrans, im_data, no_data='null'): - """ - 影像保存 - :param filename: 保存的路径 - :param im_proj: - :param im_geotrans: - :param im_data: - :param no_data: 把无效值设置为 nodata - :return: - """ - - gdal_dtypes = { - 'int8': gdal.GDT_Byte, - 'unit16': gdal.GDT_UInt16, - 'int16': gdal.GDT_Int16, - 'unit32': gdal.GDT_UInt32, - 'int32': gdal.GDT_Int32, - 'float32': gdal.GDT_Float32, - 'float64': gdal.GDT_Float64, - } - if not gdal_dtypes.get(im_data.dtype.name, None) is None: - datatype = gdal_dtypes[im_data.dtype.name] - else: - datatype = gdal.GDT_Float32 - - # 判读数组维数 - if len(im_data.shape) == 3: - im_bands, im_height, im_width = im_data.shape - else: - im_bands, (im_height, im_width) = 1, im_data.shape - - # 创建文件 - if os.path.exists(os.path.split(filename)[0]) is False: - os.makedirs(os.path.split(filename)[0]) - - driver = gdal.GetDriverByName("ENVI") # 数据类型必须有,因为要计算需要多大内存空间 - dataset = driver.Create(filename, im_width, im_height, im_bands, datatype) - - dataset.SetGeoTransform(im_geotrans) # 写入仿射变换参数 - - dataset.SetProjection(im_proj) # 写入投影 - - if im_bands == 1: - # outRaster.GetRasterBand(1).WriteArray(array) # 写入数组数据 - outband = dataset.GetRasterBand(1) - outband.WriteArray(im_data) - if no_data != 'null': - outband.SetNoDataValue(no_data) - outband.FlushCache() - else: - for i in range(im_bands): - outband = dataset.GetRasterBand(1 + i) - outband.WriteArray(im_data[i]) - outband.FlushCache() - # outRaster.GetRasterBand(i + 1).WriteArray(array[i]) - del dataset - - @staticmethod - def write_img_rpc(filename, im_proj, im_geotrans, im_data, rpc_dict): - """ - 图像中写入rpc信息 - """ - # 判断栅格数据的数据类型 - if 'int8' in im_data.dtype.name: - datatype = gdal.GDT_Byte - elif 'int16' in im_data.dtype.name: - datatype = gdal.GDT_Int16 - else: - datatype = gdal.GDT_Float32 - - # 判读数组维数 - if len(im_data.shape) == 3: - im_bands, im_height, im_width = im_data.shape - else: - im_bands, (im_height, im_width) = 1, im_data.shape - - # 创建文件 - driver = gdal.GetDriverByName("GTiff") - dataset = driver.Create(filename, im_width, im_height, im_bands, datatype) - - dataset.SetGeoTransform(im_geotrans) # 写入仿射变换参数 - dataset.SetProjection(im_proj) # 写入投影 - - # 写入RPC参数 - for k in rpc_dict.keys(): - dataset.SetMetadataItem(k, rpc_dict[k], 'RPC') - - if im_bands == 1: - dataset.GetRasterBand(1).WriteArray(im_data) # 写入数组数据 - else: - for i in range(im_bands): - dataset.GetRasterBand(i + 1).WriteArray(im_data[i]) - - del dataset - - - def transtif2mask(self,out_tif_path, in_tif_path, threshold): - """ - :param out_tif_path:输出路径 - :param in_tif_path:输入的路径 - :param threshold:阈值 - """ - im_proj, im_geotrans, im_arr, im_scope = self.read_img(in_tif_path) - im_arr_mask = (im_arr < threshold).astype(int) - self.write_img(out_tif_path, im_proj, im_geotrans, im_arr_mask) - - def write_quick_view(self, tif_path, color_img=False, quick_view_path=None): - """ - 生成快视图,默认快视图和影像同路径且同名 - :param tif_path:影像路径 - :param color_img:是否生成随机伪彩色图 - :param quick_view_path:快视图路径 - """ - if quick_view_path is None: - quick_view_path = os.path.splitext(tif_path)[0]+'.jpg' - - n = self.get_bands(tif_path) - if n == 1: # 单波段 - t_data = self.get_data(tif_path) - else: # 多波段,转为强度数据 - t_data = self.get_data(tif_path) - t_data = t_data.astype(float) - t_data = np.sqrt(t_data[0] ** 2 + t_data[1] ** 2) - - t_r = self.get_img_height(tif_path) - t_c = self.get_img_width(tif_path) - if t_r > 10000 or t_c > 10000: - q_r = int(t_r / 10) - q_c = int(t_c / 10) - elif 1024 < t_r < 10000 or 1024 < t_c < 10000: - if t_r > t_c: - q_r = 1024 - q_c = int(t_c/t_r * 1024) - else: - q_c = 1024 - q_r = int(t_r/t_c * 1024) - else: - q_r = t_r - q_c = t_c - - if color_img is True: - # 生成伪彩色图 - img = np.zeros((t_r, t_c, 3), dtype=np.uint8) # (高,宽,维度) - u = np.unique(t_data) - for i in u: - if i != 0: - w = np.where(t_data == i) - img[w[0], w[1], 0] = np.random.randint(0, 255) # 随机生成一个0到255之间的整数 可以通过挑参数设定不同的颜色范围 - img[w[0], w[1], 1] = np.random.randint(0, 255) - img[w[0], w[1], 2] = np.random.randint(0, 255) - - img = cv2.resize(img, (q_c, q_r)) # (宽,高) - cv2.imwrite(quick_view_path, img) - # cv2.imshow("result4", img) - # cv2.waitKey(0) - else: - # 灰度图 - min = np.percentile(t_data, 2) # np.nanmin(t_data) - max = np.percentile(t_data, 98) # np.nanmax(t_data) - t_data[np.isnan(t_data)] = max - if (max - min) < 256: - t_data = (t_data - min) / (max - min) * 255 - out_img = Image.fromarray(t_data) - out_img = out_img.resize((q_c, q_r)) # 重采样 - out_img = out_img.convert("L") # 转换成灰度图 - out_img.save(quick_view_path) - - def limit_field(self, out_path, in_path, min_value, max_value): - """ - :param out_path:输出路径 - :param in_path:主mask路径,输出影像采用主mask的地理信息 - :param min_value - :param max_value - """ - proj = self.get_projection(in_path) - geotrans = self.get_geotransform(in_path) - array = self.get_band_array(in_path, 1) - array[array < min_value] = min_value - array[array > max_value] = max_value - self.write_img(out_path, proj, geotrans, array) - return True - - def band_merge(self, lon, lat, ori_sim): - lon_arr = self.get_data(lon) - lat_arr = self.get_data(lat) - temp = np.zeros((2, lon_arr.shape[0], lon_arr.shape[1]), dtype=float) - temp[0, :, :] = lon_arr[:, :] - temp[1, :, :] = lat_arr[:, :] - self.write_img(ori_sim, '', [0.0, 1.0, 0.0, 0.0, 0.0, 1.0], temp, '0') - - - def get_scopes(self, ori_sim): - ori_sim_data = self.get_data(ori_sim) - lon = ori_sim_data[0, :, :] - lat = ori_sim_data[1, :, :] - - min_lon = np.nanmin(np.where((lon != 0) & ~np.isnan(lon), lon, np.inf)) - max_lon = np.nanmax(np.where((lon != 0) & ~np.isnan(lon), lon, -np.inf)) - min_lat = np.nanmin(np.where((lat != 0) & ~np.isnan(lat), lat, np.inf)) - max_lat = np.nanmax(np.where((lat != 0) & ~np.isnan(lat), lat, -np.inf)) - - scopes = [[min_lon, max_lat], [max_lon, max_lat], [min_lon, min_lat], [max_lon, min_lat]] - return scopes - - @staticmethod - def dem_merged(in_dem_path, out_dem_path): - ''' - DEM重采样函数,默认坐标系为WGS84 - agrs: - in_dem_path: 输入的DEM文件夹路径 - meta_file_path: 输入的xml元文件路径 - out_dem_path: 输出的DEM文件夹路径 - ''' - # 读取文件夹中所有的DEM - dem_file_paths = [os.path.join(in_dem_path, dem_name) for dem_name in os.listdir(in_dem_path) if - dem_name.find(".tif") >= 0 and dem_name.find(".tif.") == -1] - spatialreference = osr.SpatialReference() - spatialreference.SetWellKnownGeogCS("WGS84") # 设置地理坐标,单位为度 degree # 设置投影坐标,单位为度 degree - spatialproj = spatialreference.ExportToWkt() # 导出投影结果 - # 将DEM拼接成一张大图 - mergeFile = gdal.BuildVRT(os.path.join(out_dem_path, "mergedDEM_VRT.tif"), dem_file_paths) - out_DEM = os.path.join(out_dem_path, "mergedDEM.tif") - gdal.Warp(out_DEM, - mergeFile, - format="GTiff", - dstSRS=spatialproj, - dstNodata=-9999, - outputType=gdal.GDT_Float32) - time.sleep(3) - # gdal.CloseDir(out_DEM) - return out_DEM - - -if __name__ == '__main__': - fn = r'D:\micro\LWork\20230404\20230404_Range.npy' - a = np.load(fn) - LIGHTSPEED = 299792458 - nRange = 4.96786423292669768E-03 * (LIGHTSPEED / 2) - r = 1.66551365555555564 - slrange = nRange + 6684 * r - - print(a) - # flatEffect = ((-4) * np.pi / 0.511) * a - # h, w = flatEffect.shape - # Range = np.zeros((h, w), dtype=float) - # one = np.ones((1, w), dtype=int) - # Range[0:500, :] = one - # print(flatEffect) - # fn = r'D:\micro\WorkSpace\LandCover-old\Output\GF3_KSC_QPSI_036065_E116.4_N44.2_20230616_L1A_AHV_L10006792277-ortho-LANDClASS\GF3_KSC_QPSI_036065_E116.4_N44.2_20230616_L1A_AHV_L10006792277-ortho-LANDCLASS.tif' - # out = r'D:\micro\WorkSpace\LandCover-old\Output\GF3_KSC_QPSI_036065_E116.4_N44.2_20230616_L1A_AHV_L10006792277-ortho-LANDClASS\test.tif' - # im_proj, im_geotrans, im_arr = ImageHandler.read_img(fn) - # im_arr[np.where(im_arr == 302)] = 32 - # im_arr[np.where(im_arr == 204)] = 24 - # im_arr[np.where(im_arr == 401)] = 41 - # im_arr[np.where(im_arr == 501)] = 51 - # ImageHandler.write_img(out, im_proj, im_geotrans, im_arr, '0') - - -# path = r'D:\BaiduNetdiskDownload\GZ\lon.rdr' -# path2 = r'D:\BaiduNetdiskDownload\GZ\lat.rdr' -# path3 = r'D:\BaiduNetdiskDownload\GZ\lon_lat.tif' -# s = ImageHandler().band_merge(path, path2, path3) -# print(s) -# pass \ No newline at end of file diff --git a/landcover-L-SAR/tool/algorithm/ml/MonteCarloSampling.py b/landcover-L-SAR/tool/algorithm/ml/MonteCarloSampling.py deleted file mode 100644 index 00af9cc..0000000 --- a/landcover-L-SAR/tool/algorithm/ml/MonteCarloSampling.py +++ /dev/null @@ -1,185 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:SalinityMain.py -@File:MonteCarloSampling.py -@Function:基于蒙特卡洛随机抽样的最优特征选择算法 -@Contact: -@Author:SHJ -@Date:2021/10/19 11:30 -@Version:1.0.0 -""" -import numpy as np -from numpy import random -import matplotlib.pyplot as plt -import seaborn as sns -import logging -logger = logging.getLogger("mylog") - - -def api_sel_feature(x_list, iter=100, alpha=0.5, ts=-0.5, iter_ratio=0.2): - """ - :para x_list: k类别的单个特征的训练样本 [X1,X2,X3,...,Xi,...,Xk], - Xi = np.array([x1,x2,x3...xn]), 第i类别的训练样本数为n - :para iter: 迭代次数 - :para alpha: 调节因子 - :para ts: com_sep_coef的阈值 - :para iter_ratio : 迭代次数阈值 - :return : True-特征与类别相关度高,False-特征与类别相关度低 - """ - com_sep_coef_old = cal_com_sep_coef(x_list, alpha) - # print('com_sep_coef_old:', com_sep_coef_old) - if com_sep_coef_old < ts: - return False, com_sep_coef_old - - X = np.zeros(1) # x_list组合为行向量X - x_len_list = [] # 记录每个类别x的位置 - num_sampler = 0 # 样本总数 - t = 0 - flag = 0 - for x in x_list: - len_x = len(x) - if t == 0: - X = x - x_len_list.append(len_x) - else: - X = np.hstack([X, x]) - x_len_list.append(x_len_list[t - 1] + len_x) - num_sampler += len_x - t += 1 - x_len_list.pop() - num = int(np.ceil(num_sampler / 3)) - - for i in range(iter): - # 生成随机数组 - randmtx = np.random.rand(1, num) - randmtx_ceil = np.ceil(randmtx * num_sampler).astype(int) - randmtx_ceil = np.sort(randmtx_ceil[0, :]) - 1 - - # 随机取值,重排后,替换原来的数据,组成新数组 - X_new_sel = X.copy() - X_new_sel[randmtx_ceil] = np.random.permutation(X[randmtx_ceil]) - - X_new_list = np.split(X_new_sel, x_len_list) - com_sep_coef_new = cal_com_sep_coef(X_new_list, alpha) - if com_sep_coef_new <= com_sep_coef_old: - flag += 1 - # print('com_sep_coef_new:', com_sep_coef_new) - logger.info('flag:' + str(flag) +', iter:' + str(iter) + ', falg/iter:' + str(int(flag)/int(iter))) - if flag > (iter * iter_ratio): - return False, com_sep_coef_old - return True, com_sep_coef_old - -def cal_com_coef(x_list): - """ - :para x_list: k类别的单个特征的训练样本 [X1,X2,X3,...,Xi,...,Xk],Xi = np.array([x1,x2,x3...xn]), 第i类别的训练样本数为n - :return com_coef : 类内聚合因子(Compactness Coefficient) - """ - class_num = len(x_list) - coef_array = np.full((1, class_num), 0.0) - for m in range(class_num): - sample_num = len(x_list[m]) - c = np.full((1, sample_num), 0.0) - for u in range(sample_num): - l = np.full((1, sample_num), x_list[m][u]) - c[0, u] = np.sum(np.abs(l - x_list[m])) - coef_array[0, m] = np.sum(c) / (sample_num * (sample_num - 1)) - com_coef = np.sum(coef_array) / class_num - return com_coef - -def cal_sep_coef(x_list): - """ - :para x_list : k类别的单个特征的训练样本 [X1,X2,X3,...,Xi,...,Xk],Xi = np.array([x1,x2,x3...xn]), 第i类别的训练样本数为n - :return sep_coef : 类间离散度(Separation Coefficient) - """ - class_num = len(x_list) - coef_list = [] - coef_sum = 0 - for m in range(class_num): - xm = x_list[m] - l_xm = len(xm) - for n in range(class_num): - if not n == m: - xn = x_list[n] - l_xn = len(xn) - xm = np.expand_dims(xm, 1) - coef_list.append(np.sum(np.abs(xm - xn)) / (l_xm * l_xn)) - for coef in coef_list: - coef_sum = coef_sum + coef - - if class_num == 1 or class_num == 0: - sep_coef = coef_sum - else: - sep_coef = coef_sum / (class_num * (class_num - 1)) - return sep_coef - -def cal_com_sep_coef(x_list, alpha = 0.5): - """ - :para x_list: k类别的单个特征的训练样本 [X1,X2,X3,...,Xi,...,Xk],Xi = np.array([x1,x2,x3...xn]), 第i类别的训练样本数为n - :para alpha : 调节因子 - :return com_sep_coef: 类内聚合度和类间离散度的因子(Compactness- Separation Coeffcient) - """ - if not alpha >= 0 and alpha <= 1: - raise ('input_para_alpha beyond (0,1)!') - com_coef = cal_com_coef(x_list) - sep_coef = cal_sep_coef(x_list) - com_sep_coef = alpha * com_coef - (1-alpha) * sep_coef - return com_sep_coef - -def get_logistic_rand_number(num, u=0.4): #弃用 - randmtx = np.full((1, num), 0.0) - # randmtx[0,0] = np.random.rand(1, 1) #随机初始值 - randmtx[0, 0] = 0.5 #初始值 - - for i in range(1, num): - randmtx[0, i] = u * randmtx[0, i-1]*(1-randmtx[0, i-1]) - randmtx = randmtx * 3 * num - randmtx_ceil = np.ceil(randmtx) - - # 绘制随机数分布图 - # randmty = np.arange(0,num,1) - # randmty = np.expand_dims( randmty, 1) - # fig, axes = plt.subplots(1, 1, figsize=(5, 5)) - # axes.scatter(randmty, randmtx_ceil, alpha=.3, label='ground truth') - # axes.legend() - # plt.tight_layout() - # plt.show() - return randmtx_ceil - -def test(): - '''测试生成随机数''' - # 插入 - # a = np.array([3.4, 2.5, 1.8, 4.7, 5.6, 2.1]) - # b = np.array([2.5, 4.7, 5.6]) - # c = a[[0,1]] - # a[[0,1]] = np.array([1, 1]) - - # 随机排列 - random.shuffle() - - # logist随机数 - sns.distplot(random.normal(scale=2, size=1000), hist=False, label='normal') - sns.distplot(random.logistic(loc=2, scale=0.5, size=1000), hist=False, label='logistic') - plt.show() - - # 绘制随机数 - randmtx = random.logistic(loc=0.5, scale=0.5, size=100) - randmtx.sort(axis=0) - randmty = np.arange(0,100,1) - randmty = np.expand_dims(randmty, 1) - fig, axes = plt.subplots(1, 1, figsize=(5, 5)) - axes.scatter(randmty, randmtx, alpha=.3, label='ground truth') - axes.legend() - plt.tight_layout() - plt.show() - -# if __name__ == '__main__': - # 例子 - # x1 = np.array([1, 1.1]) - # x2 = np.array([2, 2.1, 2.2]) - # x3 = np.array([3, 3.4, 3.1]) - # x_list = [x1, x2, x3] - # com_sep_coef = cal_com_sep_coef(x_list, 0.5) - # flag = api_sel_feature(x_list) - # print('done') - - diff --git a/landcover-L-SAR/tool/algorithm/ml/machineLearning.py b/landcover-L-SAR/tool/algorithm/ml/machineLearning.py deleted file mode 100644 index 0036a7c..0000000 --- a/landcover-L-SAR/tool/algorithm/ml/machineLearning.py +++ /dev/null @@ -1,422 +0,0 @@ -import sklearn # 用于解决打包错误 -import sklearn.utils # 用于解决打包错误 -import sklearn.utils._cython_blas # 用于解决打包错误 -import sklearn.utils._weight_vector # 用于解决打包错误 -import sklearn.neighbors # 用于解决打包错误 -import sklearn.neighbors._typedefs # 用于解决打包错误 -import sklearn.neighbors._partition_nodes # 用于解决打包错误 -import sklearn.neighbors._quad_tree # 用于解决打包错误 -import sklearn.tree._utils # 用于解决打包错误 -from sklearn.cross_decomposition import PLSRegression -from sklearn.ensemble import ExtraTreesClassifier -from sklearn.ensemble import RandomForestClassifier -from sklearn.ensemble import ExtraTreesClassifier -from sklearn.svm import SVC -import numpy as np -from scipy.stats import pearsonr -from tool.algorithm.image.ImageHandle import ImageHandler -from tool.algorithm.block.blockprocess import BlockProcess -import logging -import os -import glob -from PIL import Image -from tool.file.fileHandle import fileHandle -import multiprocessing -logger = logging.getLogger("mylog") -file = fileHandle() - -class MachineLeaning: - """ - 机器学习库 - """ - def __init__(self): - pass - - @staticmethod - def gene_optimal_train_set(train_data_dic, feature_tif_dir, important_threshold=0.3, correlation_threshold=0.7): # todo 修改特征重要性 - ml = MachineLeaning() - name_list = ml.get_name_list(feature_tif_dir) - X_train, Y_train = ml.gene_train_set(train_data_dic, feature_tif_dir) - optimal_feature = ml.sel_optimal_feature_set(X_train, Y_train, threshold=important_threshold) - optimal_feature = ml.remove_correlation_feature(X_train, optimal_feature, threshold=correlation_threshold) - X_train = X_train[:, optimal_feature] - logger.info('train_feature:%s', np.array(name_list)[optimal_feature]) - return X_train, Y_train, optimal_feature - - @ staticmethod - def sel_optimal_feature(X_train, Y_train, name_list,important_threshold=0.3, correlation_threshold=0.7): - ml = MachineLeaning() - optimal_feature = ml.sel_optimal_feature_set(X_train, Y_train, threshold=important_threshold) - optimal_feature = ml.remove_correlation_feature(X_train, optimal_feature, threshold=correlation_threshold) - X_train = X_train[:, optimal_feature] - logger.info('train_feature:%s', np.array(name_list)[optimal_feature]) - return X_train, Y_train, optimal_feature - - @staticmethod - def gene_test_set(feature_tif_dir, optimal_feature): - """ - 生成测试集 - :param feature_tif_dir : 特征影像路径字典 - :param optimal_feature : 最优特征子集 - :return X_test_list : 分块测试集影像路径 - """ - in_tif_paths = list(glob.glob(os.path.join(feature_tif_dir, '*.tif'))) - cols = ImageHandler.get_img_width(in_tif_paths[0]) - rows = ImageHandler.get_img_height(in_tif_paths[0]) - workspace_block_tif_path = os.path.join(feature_tif_dir, 'block') - workspace_block_feature_path = os.path.join(feature_tif_dir, 'feature') - file.creat_dirs([workspace_block_tif_path, workspace_block_feature_path]) - - # 特征分块 - bp = BlockProcess() - block_size = bp.get_block_size(rows, cols) - - bp.cut(feature_tif_dir, workspace_block_tif_path, ['tif', 'tiff'], 'tif', block_size) - img_dir, img_name = bp.get_file_names(workspace_block_tif_path, ['tif']) - dir_dict_all = bp.get_same_img(img_dir, img_name) - - # 选择最优特征子集特征影像 - dir_dict = {} - for n, key in zip(range(len(dir_dict_all)), dir_dict_all): - if n in optimal_feature: - dir_dict.update({key: dir_dict_all[key]}) - logger.info('test_feature:%s', dir_dict.keys()) - logger.info('blocking tifs success!') - X_test_list = [] - # 特征维度合并 - for key in dir_dict: - key_name = key - block_num = len(dir_dict[key]) - break - for n in range(block_num): - name = os.path.basename(dir_dict[key_name][n]) - suffix = '_' + name.split('_')[-4] + "_" + name.split('_')[-3] + "_" + name.split('_')[-2] + "_" + name.split('_')[-1] - features_path = os.path.join(workspace_block_feature_path, "features" + suffix) # + "\\features" + suffix - X_test_list.append(features_path) - features_array = np.zeros((len(dir_dict), block_size, block_size), dtype='float32') - for m, value in zip(range(len(dir_dict)), dir_dict.values()): - features_array[m, :, :] = ImageHandler.get_band_array(value[n]) - features_array[np.isnan(features_array)] = 0.0 # 异常值转为0 - ImageHandler.write_img(features_path, '', [0, 0, 0, 0, 0, 0], features_array) - logger.info('create features matrix success!') - # file.del_folder(workspace_block_tif_path) - # file.del_folder(workspace_block_feature_path) - return X_test_list - - @staticmethod - def predict_blok(clf, X_test, rows, cols, img_path, row_begin, col_begin, block_sum, n): - logger.info('total:%s,block:%s testing data !path:%s', block_sum, n, img_path) - - Y_test = clf.predict(X_test) - img = Y_test.reshape(rows, cols) - out_image = Image.fromarray(img) - out_image.save(img_path) - # bp = BlockProcess() - # bp.assign_spatial_reference_bypoint(row_begin, col_begin, self.__proj, self.__geo, img_path) - # sr = osr.SpatialReference() - # sr.ImportFromWkt(self.__proj) - # geo_transform = (self.__geo[0] + col_begin * self.__geo[1] + row_begin * self.__geo[2], - # self.__geo[1], - # self.__geo[2], - # self.__geo[3] + col_begin * self.__geo[4] + row_begin * self.__geo[5], - # self.__geo[4], - # self.__geo[5] - # ) - # dst_ds = gdal.Open(img_path, gdal.GA_Update) - # if dst_ds is None: - # return False - # dst_ds.SetProjection(sr.ExportToWkt()) - # dst_ds.SetGeoTransform(geo_transform) - # del dst_ds - logger.info('total:%s,block:%s test data finished !path:%s', block_sum, n, img_path) - return True - - @staticmethod - def predict(clf, X_test_list, out_tif_name, workspace_processing_path,rows, cols): - """ - 预测数据 - :param clf : svm模型 - :return X_test_list: 分块测试集影像路径 - """ - ml = MachineLeaning() - # 开启多进程处理 - bp = BlockProcess() - block_size = bp.get_block_size(rows, cols) - - block_features_dir = X_test_list - bp_cover_dir = os.path.join(workspace_processing_path, out_tif_name + '\\') # workspace_processing_path + out_tif_name + '\\' - file.creat_dirs([bp_cover_dir]) - - processes_num = min([len(block_features_dir), multiprocessing.cpu_count() - 1]) - pool = multiprocessing.Pool(processes=processes_num) - - for path, n in zip(block_features_dir, range(len(block_features_dir))): - name = os.path.split(path)[1] - band = ImageHandler.get_bands(path) - if band == 1: - features_array = np.zeros((1, 1024, 1024), dtype=float) - feature_array = ImageHandler.get_data(path) - features_array[0, :, :] = feature_array - else: - features_array = ImageHandler.get_data(path) - - X_test = np.reshape(features_array, (features_array.shape[0], features_array[0].size)).T - - suffix = '_' + name.split('_')[-4] + "_" + name.split('_')[-3] + "_" + name.split('_')[-2] + "_" + name.split('_')[-1] - img_path = os.path.join(bp_cover_dir, out_tif_name + suffix) # bp_cover_dir + out_tif_name + suffix - row_begin = int(name.split('_')[-4]) - col_begin = int(name.split('_')[-2]) - pool.apply_async(ml.predict_blok, (clf, X_test, block_size, block_size, img_path, row_begin, col_begin, len(block_features_dir), n)) - - pool.close() - pool.join() - - # 合并影像 - data_dir = bp_cover_dir - out_path = workspace_processing_path[0:-1] - bp.combine(data_dir, cols, rows, out_path, file_type=['tif'], datetype='float32') - - # 添加地理信息 - cover_path = os.path.join(workspace_processing_path, out_tif_name + ".tif") # workspace_processing_path + out_tif_name + ".tif" - # bp.assign_spatial_reference_byfile(self.__ref_img_path, cover_path) - return cover_path - - @staticmethod - def predict_VP(clf, X_test_list, out_tif_name, workspace_processing_path, rows, cols): - """ - 预测数据 - :param clf : svm模型 - :return X_test_list: 分块测试集影像路径 - """ - ml = MachineLeaning() - # 开启多进程处理 - bp = BlockProcess() - block_size = bp.get_block_size(rows, cols) - - block_features_dir = X_test_list - bp_cover_dir = os.path.join(workspace_processing_path, out_tif_name, - 'pre_result\\') # workspace_processing_path + out_tif_name + '\\' - file.creat_dirs([bp_cover_dir]) - - processes_num = min([len(block_features_dir), multiprocessing.cpu_count() - 1]) - pool = multiprocessing.Pool(processes=processes_num) - - for path, n in zip(block_features_dir, range(len(block_features_dir))): - name = os.path.split(path)[1] - features_array = ImageHandler.get_data(path) - - X_test = np.reshape(features_array, (features_array.shape[0], features_array[0].size)).T - - suffix = '_' + name.split('_')[-4] + "_" + name.split('_')[-3] + "_" + name.split('_')[-2] + "_" + \ - name.split('_')[-1] - img_path = os.path.join(bp_cover_dir, out_tif_name + suffix) # bp_cover_dir + out_tif_name + suffix - row_begin = int(name.split('_')[-4]) - col_begin = int(name.split('_')[-2]) - pool.apply_async(ml.predict_blok, ( - clf, X_test, block_size, block_size, img_path, row_begin, col_begin, len(block_features_dir), n)) - - pool.close() - pool.join() - - # 合并影像 - data_dir = bp_cover_dir - out_path = workspace_processing_path[0:-1] - bp.combine(data_dir, cols, rows, out_path, file_type=['tif'], datetype='float32') - - # 添加地理信息 - cover_path = os.path.join(workspace_processing_path, - out_tif_name + ".tif") # workspace_processing_path + out_tif_name + ".tif" - # bp.assign_spatial_reference_byfile(self.__ref_img_path, cover_path) - return cover_path - - @staticmethod - def get_name_list(feature_tif_dir): - in_tif_paths = list(glob.glob(os.path.join(feature_tif_dir, '*.tif'))) - name_list = [] - dim = len(in_tif_paths) - for n, path in zip(range(dim), in_tif_paths): - name_list.append(str(n)+': '+os.path.split(path)[1]) - logger.info('feature_list:%s', name_list) - return name_list - - - @staticmethod - def gene_train_set(train_data_dic, feature_tif_dir): - """ - 生成训练集 - :param train_data_dic : 从csv读取的训练数据 - :param feature_tif_dir : 特征影像路径路径 - :return X_train, Y_train : 训练数据 - """ - in_tif_paths = list(glob.glob(os.path.join(feature_tif_dir, '*.tif'))) - dim = len(in_tif_paths) - X_train = np.empty(shape=(0, dim)) - Y_train = np.empty(shape=(0, 1)) - - ids = train_data_dic['ids'] - positions = train_data_dic['positions'] - for id, points in zip(ids, positions): - # for data in train_data_list: - if points == []: - raise Exception('data is empty!') - row, col = zip(*points) - l = len(points) - X = np.empty(shape=(l, dim)) - - for n, tif_path in zip(range(dim), in_tif_paths): - feature_array = ImageHandler.get_data(tif_path) - feature_array[np.isnan(feature_array)] = 0 # 异常值填充为0 - x = feature_array[row, col].T - X[:, n] = x - - Y = np.full((l, 1), id) - X_train = np.vstack((X_train, X)) - Y_train = np.vstack((Y_train, Y)) - Y_train = Y_train.T[0, :] - - logger.info("gene_train_set success!") - return X_train, Y_train - - @staticmethod - def standardization(data, num=1): - # 矩阵标准化到[0,1] - min = np.nanmin(data) - max = np.nanmax(data) - data[np.isnan(data)] = min # 异常值填充为0 - _range = max - min - return (data - min) / _range * num - - @staticmethod - def sel_optimal_feature_set(X_train, Y_train, threshold=0.01): - """ - 筛选最优特征组合(极度随机树) - """ - model = ExtraTreesClassifier() - max = np.max(Y_train) - if max < 0.1: - Y_train = (Y_train*10000).astype('int') - model.fit(X_train, Y_train.astype('int')) - # select the relative importance of each attribute - importances = model.feature_importances_ - logger.info('importances:%s,threshold=%s', importances, threshold) - - importances_resort = -np.sort(-importances) # 从大到小排序 - imp_argsort = np.argsort(-importances) # 输出从大到小的序号 - - optimal_feature = list(imp_argsort[np.where(importances_resort > threshold)]) # 过滤重要性低的特征 - logger.info('optimal_feature:%s', optimal_feature) - - if len(optimal_feature)==0: - logger.error('optimal_feature is empty') - optimal_feature = list(imp_argsort) - return optimal_feature - - @staticmethod - def correlation_map(x, y): - # https://blog.csdn.net/weixin_39836726/article/details/110783640 - # cc matrix based on scipy pearsonr - n_row_x = x.shape[0] - n_row_y = x.shape[0] - ccmtx_xy = np.empty((n_row_x, n_row_y)) - for n in range(n_row_x): - for m in range(n_row_y): - ccmtx_xy[n, m] = pearsonr(x[n, :], y[m, :])[0] - return ccmtx_xy - - @staticmethod - def remove_correlation_feature(X_train,validity_list, threshold=0.85): - """ - 相关性抑制,去除相关性 - :param X_train : 训练集 - :param validity_list : 最优特征子集 - :param threshold: 相关性阈值 - :return validity_list : 最优特征子集 - """ - ccmtx = MachineLeaning().correlation_map(X_train[:, validity_list].T, X_train[:, validity_list].T) - ccmtx = np.abs(ccmtx) - for r in range(len(validity_list)): - for c in range(len(validity_list)): - if c <= r: - ccmtx[r, c] = 0 - logger.info('correlation_map:\n %s', ccmtx) - # 相关性大于0.85的特征,删除com_sep_coef较大的特征 - high_corr = np.unique(np.where(ccmtx > threshold)[1]) # 删除的特征序号 - validity_list = np.delete(validity_list, high_corr) - logger.info('validity_list_corr:%s', validity_list) - logger.info(validity_list) - return validity_list - - @staticmethod - def gene_train_data(block_features_dir,rows,cols,block_size,measured_data_img): - # 生成训练集 - X_train = [] - Y_train = [] - - block_rows = int(np.ceil(rows/block_size)) - block_cols = int(np.ceil(cols/block_size)) - - for data, n in zip(measured_data_img, range(len(measured_data_img))): - row = data[0] - col = data[1] - block_row = row//block_size - block_col = col//block_size - - if block_row == block_rows-1: - part_img_row = row - (rows - block_size) - else: - part_img_row = row % block_size - - if block_col == block_cols-1: - part_img_col = col - (cols-block_size) - else: - part_img_col = col % block_size - - features_path = block_features_dir[block_row*block_rows + block_col] - features_array = ImageHandler().get_data(features_path) - - feature = features_array[:, part_img_row, part_img_col] - if not np.isnan(feature).any() or np.isinf(feature).any(): - X_train.append(list(feature)) - Y_train.append([data[2]]) - logger.info('total:%s,num:%s create train set success!', len(measured_data_img), n) - return np.array(X_train), np.array(Y_train) - - @staticmethod - def trainRF(X_train, Y_train): - #随机森林 - logger.info('RF trainning') - clf = RandomForestClassifier() - clf.fit(X_train, Y_train) - return clf - - @staticmethod - def trainSVM(X_train, Y_train, cost=1, kernel='rbf'): - logger.info('svm trainning') - clf = SVC(decision_function_shape='ovo') - clf.fit(X_train, Y_train) - SVC(C=cost, cache_size=1000, class_weight='balanced', coef0=0.0, decision_function_shape='ovr', - degree=3, gamma='auto', kernel=kernel, max_iter=-1, probability=False, random_state=None, - shrinking=True, tol=0.001, verbose=True) - return clf - @staticmethod - def vegetationPhenology_combine_feature(feature_dir,workspace_processing_path, name, rows, cols, debug =False): - ml = MachineLeaning() - path_list = list(glob.glob(os.path.join(feature_dir, '*.tif'))) - #多维矩阵合并为一个 - name_featuresPath_dic = {} - dim = len(path_list) - features_path = workspace_processing_path + name + "/"+ name +'_features.tif' - if debug== False: - features_array = np.zeros((dim, rows, cols), dtype='float16') - for m, path in zip(range(dim), path_list): - data = ImageHandler.get_data(path) - data = ml.standardization(data) - features_array[m, :, :] = data - # 异常值转为0 - features_array[np.isnan(features_array)] = 0.0 - features_array[np.isinf(features_array)] = 0.0 - ImageHandler.write_img(features_path, '', [0, 0, 0, 0, 0, 0], features_array) - name_featuresPath_dic.update({name: features_path}) - return name_featuresPath_dic - - diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/AHVToPolsarpro.py b/landcover-L-SAR/tool/algorithm/polsarpro/AHVToPolsarpro.py deleted file mode 100644 index ef60b54..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/AHVToPolsarpro.py +++ /dev/null @@ -1,491 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:AHVToPolsarpro.py -@Function:全极化影像转成polsarpro格式T3数据 -@Contact: -@Author:SHJ -@Date:2021/9/18 16:44 -@Version:1.0.0 -""" -import os -import numpy as np -import glob -import struct -from tool.algorithm.image.ImageHandle import ImageHandler - - -class AHVToPolsarpro: - """ - 全极化影像转换为bin格式T3矩阵,支持polsarpro处理 - """ - - def __init__(self, hh_hv_vh_vv_path_list=[]): - self._hh_hv_vh_vv_path_list = hh_hv_vh_vv_path_list - pass - - @staticmethod - def __ahv_to_s2_veg(ahv_dir): - """ - 全极化影像转S2矩阵 - :param ahv_dir: 全极化影像文件夹路径 - :return: 极化散射矩阵S2 - """ - global s11 - in_tif_paths = list(glob.glob(os.path.join(ahv_dir, '*.tif'))) - in_tif_paths1 = list(glob.glob(os.path.join(ahv_dir, '*.tiff'))) - in_tif_paths += in_tif_paths1 - s11, s12, s21, s22 = None, None, None, None - flag_list = [0, 0, 0, 0] - for in_tif_path in in_tif_paths: - - # 读取原始SAR影像 - proj, geotrans, data = ImageHandler.read_img(in_tif_path) - - # 获取极化类型 - if '_HH' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s11 = data_real + 1j * data_imag - flag_list[0] = 1 - elif '_HV' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s12 = data_real + 1j * data_imag - flag_list[1] = 1 - elif '_VH' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s21 = data_real + 1j * data_imag - flag_list[2] = 1 - elif '_VV' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s22 = data_real + 1j * data_imag - flag_list[3] = 1 - else: - continue - if not flag_list == [1, 1, 1, 1]: - raise Exception('HH or HV or VH or VV is not in path :%s', ahv_dir) - return s11, s12, s21, s22 - - @staticmethod - def __ahv_to_s2_soil(ahv_dir): - """ - 全极化影像转S2矩阵 - :param ahv_dir: 全极化影像文件夹路径 - :return: 极化散射矩阵S2 - """ - global s11 - in_tif_paths = list(glob.glob(os.path.join(ahv_dir, '*.tif'))) - in_tif_paths1 = list(glob.glob(os.path.join(ahv_dir, '*.tiff'))) - in_tif_paths += in_tif_paths1 - s11, s12, s21, s22 = None, None, None, None - flag_list = [0, 0, 0, 0] - for in_tif_path in in_tif_paths: - - # 读取原始SAR影像 - proj, geotrans, data = ImageHandler.read_img(in_tif_path) - - # 获取极化类型 - if 'HH' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s11 = data_real + 1j * data_imag - flag_list[0] = 1 - elif 'HV' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s12 = data_real + 1j * data_imag - flag_list[1] = 1 - elif 'VH' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s21 = data_real + 1j * data_imag - flag_list[2] = 1 - elif 'VV' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s22 = data_real + 1j * data_imag - flag_list[3] = 1 - else: - continue - if not flag_list == [1, 1, 1, 1]: - raise Exception('HH or HV or VH or VV is not in path :%s', ahv_dir) - return s11, s12, s21, s22 - - @staticmethod - def __ahv_to_s2_list(ahv_path_list): - """ - 全极化影像转S2矩阵 - :param ahv_dir: 全极化影像文件夹路径 - :return: 极化散射矩阵S2 - """ - global s11 - in_tif_paths = ahv_path_list - s11, s12, s21, s22 = None, None, None, None - flag_list = [0, 0, 0, 0] - for in_tif_path in in_tif_paths: - - # 读取原始SAR影像 - proj, geotrans, data = ImageHandler.read_img(in_tif_path) - - # 获取极化类型 - if 'HH' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s11 = data_real + 1j * data_imag - flag_list[0] = 1 - elif 'HV' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s12 = data_real + 1j * data_imag - flag_list[1] = 1 - elif 'VH' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s21 = data_real + 1j * data_imag - flag_list[2] = 1 - elif 'VV' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s22 = data_real + 1j * data_imag - flag_list[3] = 1 - else: - continue - if not flag_list == [1, 1, 1, 1]: - raise Exception('HH or HV or VH or VV is not in path') - return s11, s12, s21, s22 - - - @staticmethod - def __ahv_to_s2_list_2(hh_hv_vh_vv_path_list): - """ - 全极化影像转S2矩阵 - :param ahv_dir: 全极化影像文件夹路径 - :return: 极化散射矩阵S2 - """ - global s11 - in_tif_paths = hh_hv_vh_vv_path_list - s11, s12, s21, s22 = None, None, None, None - flag_list = [0, 0, 0, 0] - for in_tif_path, n in zip(in_tif_paths, range(len(in_tif_paths))): - - # 读取原始SAR影像 - proj, geotrans, data = ImageHandler.read_img(in_tif_path) - - # 获取极化类型 - if n == 0: - data_real = data[0, :, :] - data_imag = data[1, :, :] - s11 = data_real + 1j * data_imag - flag_list[0] = 1 - elif n == 1: - data_real = data[0, :, :] - data_imag = data[1, :, :] - s12 = data_real + 1j * data_imag - flag_list[1] = 1 - elif n == 2: - data_real = data[0, :, :] - data_imag = data[1, :, :] - s21 = data_real + 1j * data_imag - flag_list[2] = 1 - elif n == 3: - data_real = data[0, :, :] - data_imag = data[1, :, :] - s22 = data_real + 1j * data_imag - flag_list[3] = 1 - else: - continue - if not flag_list == [1, 1, 1, 1]: - raise Exception('HH or HV or VH or VV is not in path') - return s11, s12, s21, s22 - - @staticmethod - def __s2_to_t3(s11, s12, s21, s22): - """ - S2矩阵转T3矩阵 - :param s11: HH极化数据 - :param s12: HV极化数据 - :param s21: VH极化数据 - :param s22: VV极化数据 - :return: 极化相干矩阵T3 - """ - HH = s11 - HV = s12 - VH = s21 - VV = s22 - - t11 = (np.abs(HH + VV)) ** 2 / 2 - t12 = (HH + VV) * np.conj(HH - VV) / 2 - t13 = (HH + VV) * np.conj(HV + VH) - - t21 = (HH - VV) * np.conj(HH + VV) / 2 - t22 = np.abs(HH - VV) ** 2 / 2 - t23 = (HH - VV) * np.conj(HV + VH) - - t31 = (HV + VH) * np.conj(HH + VV) - t32 = (HV + VH) * np.conj(HH - VV) - t33 = 2 * np.abs(HV + VH) ** 2 - return t11, t12, t13, t21, t22, t23, t31, t32, t33 - - def __t3_to_polsarpro_t3(self, out_dir, t11, t12, t13, t22, t23, t33): - """ - T3矩阵转bin格式,支持 polsarpro处理 - :param out_dir: 输出的文件夹路径 - :param t11: - :param t12: - :param t13: - :param t22: - :param t23: - :param t33: - :return: bin格式矩阵T3和头文件 - """ - if not os.path.exists(out_dir): - os.makedirs(out_dir) - - rows = t11.shape[0] - cols = t11.shape[1] - bins_dict = { - 'T11.bin': t11, - 'T12_real.bin': t12.real, - 'T12_imag.bin': t12.imag, - 'T13_real.bin': t13.real, - 'T13_imag.bin': t13.imag, - 'T22.bin': t22, - 'T23_real.bin': t23.real, - 'T23_imag.bin': t23.imag, - 'T33.bin': t33} - - for name, data in bins_dict.items(): - bin_path = os.path.join(out_dir, name) - self.__write_img_bin(data, bin_path) # todo 修改T3阵保存方式 - # data.tofile(bin_path) - out_hdr_path = bin_path + '.hdr' - self.__write_bin_hdr(out_hdr_path, bin_path, rows, cols) - - self.__write_config_file(out_dir, rows, cols) - - def rows(self): - """获取影像行数""" - return self._rows - - def cols(self): - """获取影像列数""" - return self._cols - - def __write_img_bin(self, im, file_path): - """ - 写入影像到bin文件中,保存为float32类型 - :param im : 影像矩阵数据,暂支持单通道影像数据 - :param file_path: bin文件的完整路径 - """ - with open(file_path, 'wb') as f: - self._rows = im.shape[0] - self._cols = im.shape[1] - for row in range(self._rows): - im_bin = struct.pack("f" * self._cols, *np.reshape(im[row, :], (self._cols, 1), order='F')) - f.write(im_bin) - f.close() - - @staticmethod - def __write_bin_hdr(out_hdr_path, bin_path, rows, cols): - """ - 写入影像的头文件 - :param out_hdr_path : 头文件的路径 - :param bin_path: bin文件的路径 - :param rows: 影像的行数 - :param cols: 影像的列数 - """ - h1 = 'ENVI' - h2 = 'description = {' - h3 = 'File Imported into ENVI. }' - h4 = 'samples = ' + str(cols) # 列 - h5 = 'lines = ' + str(rows) # 行 - h6 = 'bands = 1 ' # 波段数 - h7 = 'header offset = 0' - h8 = 'file type = ENVI Standard' - h9 = 'data type = 4' # 数据格式 - h10 = 'interleave = bsq' # 存储格式 - h11 = 'sensor type = Unknown' - h12 = 'byte order = 0' - h13 = 'band names = {' - h14 = bin_path + '}' - # h = [h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14] - # doc = open(out_hdr_path, 'w') - # for i in range(0, 14): - # print(h[i], end='', file=doc) - # print('\n', end='', file=doc) - h = [h1, h4, h5, h6, h7, h8, h9, h10, h12] - doc = open(out_hdr_path, 'w') - for i in range(0, 9): - print(h[i], end='', file=doc) - print('\n', end='', file=doc) - doc.close() - - @staticmethod - def __write_config_file(out_config_dir, rows, cols): - """ - 写入polsarpro配置文件 - :param out_config_dir : 配置文件路径 - :param rows: 影像的行数 - :param cols: 影像的列数 - """ - h1 = 'Nrow' - h2 = str(rows) - h3 = '---------' - h4 = 'Ncol' - h5 = str(cols) - h6 = '---------' - h7 = 'PolarCase' - h8 = 'monostatic' - h9 = '---------' - h10 = 'PolarType' - h11 = 'full' - h = [h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11] - - out_config_path = os.path.join(out_config_dir, 'config.txt') - doc = open(out_config_path, 'w') - for i in range(0, 11): - print(h[i], end='', file=doc) - print('\n', end='', file=doc) - doc.close() - - def incidence_tif2bin(self, incidence_file, out_path): - if not os.path.exists(out_path): - os.mkdir(out_path) - incidence_bin = os.path.join(out_path, 'incidence.bin') - data = ImageHandler().get_data(incidence_file) - rows = data.shape[0] - cols = data.shape[1] - self.__write_img_bin(data, incidence_bin) - if not os.path.exists(incidence_bin): - raise Exception('incidence to bin failed') - out_hdr_path = incidence_bin + '.hdr' - self.__write_bin_hdr(out_hdr_path, incidence_bin, rows, cols) - return incidence_bin - - def ahv_to_polsarpro_t3_veg(self, out_file_dir, in_ahv_dir=''): - - if self._hh_hv_vh_vv_path_list == [] : - s11, s12, s21, s22 = self.__ahv_to_s2_veg(in_ahv_dir) - else: - s11, s12, s21, s22 = self.__ahv_to_s2_list_2(self._hh_hv_vh_vv_path_list) - - t11, t12, t13, t21, t22, t23, t31, t32, t33 = self.__s2_to_t3( - s11, s12, s21, s22) - - self.__t3_to_polsarpro_t3(out_file_dir, t11, t12, t13, t22, t23, t33) - - - def ahv_to_polsarpro_t3_soil(self, out_file_dir, in_ahv_dir=''): - - if self._hh_hv_vh_vv_path_list == [] : - s11, s12, s21, s22 = self.__ahv_to_s2_soil(in_ahv_dir) - else: - s11, s12, s21, s22 = self.__ahv_to_s2_list_2(self._hh_hv_vh_vv_path_list) - - t11, t12, t13, t21, t22, t23, t31, t32, t33 = self.__s2_to_t3( - s11, s12, s21, s22) - - self.__t3_to_polsarpro_t3(out_file_dir, t11, t12, t13, t22, t23, t33) - - def calibration(self, calibration_value, in_ahv_dir='', name=''): - if name == '': - out_dir = os.path.join(in_ahv_dir, 'calibration') - else: - out_dir = os.path.join(in_ahv_dir, name, 'calibration') - flag_list = [0, 0, 0, 0] - if self._hh_hv_vh_vv_path_list == []: # 地表覆盖、土壤盐碱度 - in_tif_paths = list(glob.glob(os.path.join(in_ahv_dir, '*.tif'))) - in_tif_paths1 = list(glob.glob(os.path.join(in_ahv_dir, '*.tiff'))) - in_tif_paths += in_tif_paths1 - for in_tif_path in in_tif_paths: - # 读取原始SAR影像 - proj, geotrans, data = ImageHandler.read_img(in_tif_path) - name = os.path.basename(in_tif_path) - data_new = np.zeros(data.shape) - # 获取极化类型 - if 'HH' in os.path.basename(in_tif_path): - data_new[0, :, :] = data[0, :, :] * calibration_value[0] - data_new[1, :, :] = data[1, :, :] * calibration_value[0] - ImageHandler.write_img(os.path.join(out_dir, name), proj, geotrans, data_new) - flag_list[0] = 1 - elif 'HV' in os.path.basename(in_tif_path): - data_new[0, :, :] = data[0, :, :] * calibration_value[1] - data_new[1, :, :] = data[1, :, :] * calibration_value[1] - ImageHandler.write_img(os.path.join(out_dir, name), proj, geotrans, data_new) - flag_list[1] = 1 - elif 'VH' in os.path.basename(in_tif_path): - data_new[0, :, :] = data[0, :, :] * calibration_value[2] - data_new[1, :, :] = data[1, :, :] * calibration_value[2] - ImageHandler.write_img(os.path.join(out_dir, name), proj, geotrans, data_new) - flag_list[2] = 1 - elif 'VV' in os.path.basename(in_tif_path): - data_new[0, :, :] = data[0, :, :] * calibration_value[3] - data_new[1, :, :] = data[1, :, :] * calibration_value[3] - ImageHandler.write_img(os.path.join(out_dir, name), proj, geotrans, data_new) - flag_list[3] = 1 - if not flag_list == [1, 1, 1, 1]: - raise Exception('calibration error! ') - else: - for in_tif_path in self._hh_hv_vh_vv_path_list: # 植被物候 - # 读取原始SAR影像 - proj, geotrans, data = ImageHandler.read_img(in_tif_path) - name = os.path.basename(in_tif_path) - data_new = np.zeros(data.shape) - - # 获取极化类型 - if '_HH' in os.path.basename(in_tif_path): - data_new[0, :, :] = data[0, :, :] * calibration_value[0] - data_new[1, :, :] = data[1, :, :] * calibration_value[0] - ImageHandler.write_img(os.path.join(out_dir, name), proj, geotrans, data_new) - flag_list[0] = 1 - elif '_HV' in os.path.basename(in_tif_path): - data_new[0, :, :] = data[0, :, :] * calibration_value[1] - data_new[1, :, :] = data[1, :, :] * calibration_value[1] - ImageHandler.write_img(os.path.join(out_dir, name), proj, geotrans, data_new) - flag_list[1] = 1 - elif '_VH' in os.path.basename(in_tif_path): - data_new[0, :, :] = data[0, :, :] * calibration_value[2] - data_new[1, :, :] = data[1, :, :] * calibration_value[2] - ImageHandler.write_img(os.path.join(out_dir, name), proj, geotrans, data_new) - flag_list[2] = 1 - elif '_VV' in os.path.basename(in_tif_path): - data_new[0, :, :] = data[0, :, :] * calibration_value[3] - data_new[1, :, :] = data[1, :, :] * calibration_value[3] - ImageHandler.write_img(os.path.join(out_dir, name), proj, geotrans, data_new) - flag_list[3] = 1 - if not flag_list == [1, 1, 1, 1]: - raise Exception('calibration error! ') - self._hh_hv_vh_vv_path_list = [] - return out_dir - - - -if __name__ == '__main__': - #实例1: - # atp = AHVToPolsarpro() - # ahv_path = 'D:\\DATA\\GAOFEN3\\2-GF3_MYN_WAV_020086_E107.2_N27.6_20200603_L1A_AHV_L10004843087\\' - # # ahv_path = 'D:\\DATA\\GAOFEN3\\2598957_Paris\\' - # out_file_path = 'D:\\bintest0923\\' - # atp.ahv_to_polsarpro_t3(out_file_path, ahv_path) - - # # 极化分解得到T3矩阵 - # atp = AHVToPolsarpro() - # ahv_path = r"I:\MicroWorkspace\product\C-SAR\SoilSalinity\GF3B_MYC_QPSI_003581_E120.6_N31.3_20220729_L1A_AHV_L10000073024_RPC" - # t3_path = ahv_path + 'psp_t3\\' - # atp.ahv_to_polsarpro_t3(t3_path, ahv_path) - - #实例2: - # dir = r'D:\MicroWorkspace\product\C-SAR\VegetationPhenology\Temporary\preprocessed/' - # path_list = [dir +'GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422_RPC_HH_preprocessed.tif', - # dir +'GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422_RPC_HV_preprocessed.tif', - # dir +'GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422_RPC_VH_preprocessed.tif', - # dir +'GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422_RPC_VV_preprocessed.tif'] - # - # - # atp = AHVToPolsarpro(path_list) - # atp.ahv_to_polsarpro_t3(r'D:\MicroWorkspace\product\C-SAR\VegetationPhenology\Temporary\processing\GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422_RPC/t3') - - print("done") diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/AHVToPolsarproS2.py b/landcover-L-SAR/tool/algorithm/polsarpro/AHVToPolsarproS2.py deleted file mode 100644 index 1b6fa83..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/AHVToPolsarproS2.py +++ /dev/null @@ -1,228 +0,0 @@ -""" -@Project :microproduct -@File :AHVToPolsarpro.PY -@Function :将四个极化数据转成S2矩阵文件 -@Author :LMM -@Date :2021/10/19 14:39 -@Version :1.0.0 -""" -import os -import numpy as np -import glob -import struct -from tool.algorithm.image.ImageHandle import ImageHandler - - -class AHVToPolsarproS2: - """ - 全极化影像转换为bin格式S2矩阵,支持polsarpro处理 - """ - def __init__(self): - - pass - - @staticmethod - def __ahv_to_s2(ahv_dir): - """ - 全极化影像转S2矩阵 - :param ahv_dir: 全极化影像文件夹路径 - :return: 极化散射矩阵S2 - """ - in_tif_paths = list(glob.glob(os.path.join(ahv_dir, '*.tif'))) - - if in_tif_paths == []: - in_tif_paths = list(glob.glob(os.path.join(ahv_dir, '*.tiff'))) - s11, s12, s21, s22 = None,None,None,None - flag_list = [0, 0, 0, 0] - for in_tif_path in in_tif_paths: - - # 读取原始SAR影像 - proj, geotrans, data = ImageHandler.read_img(in_tif_path) - - # 获取极化类型 - if 'HH' in os.path.basename(in_tif_path): - data_real = data[0, :, :] # 获取第一个波段 (实部) - data_imag = data[1, :, :] # 获取第二个波段 (虚部) - s11 = data_real + 1j * data_imag - flag_list[0] = 1 - elif 'HV' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s12 = data_real + 1j * data_imag - flag_list[1] = 1 - elif 'VH' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s21 = data_real + 1j * data_imag - flag_list[2] = 1 - elif 'VV' in os.path.basename(in_tif_path): - data_real = data[0, :, :] - data_imag = data[1, :, :] - s22 = data_real + 1j * data_imag - flag_list[3] = 1 - else: - continue - if not flag_list == [1, 1, 1, 1]: - raise Exception('tif of HH or HV or VH or VV is not in path :%s', ahv_dir) - return s11, s12, s21, s22 - - def __s2_to_bin(self, out_dir, s11, s12, s21, s22): - """ - S2矩阵转bin格式,支持 polsarpro处理 - :param out_dir: 输出的文件夹路径 - :param s11: - :param s12: - :param s21 - :param s22: - :return: bin格式矩阵S2和头文件 - """ - if not os.path.exists(out_dir): - os.makedirs(out_dir) - - rows = s11.shape[0] - cols = s11.shape[1] - bins_dict = {'s11.bin': s11, - 's12.bin': s12, - 's21.bin': s21, - 's22.bin': s22} - - - for name, data in bins_dict.items(): - - bin_path = os.path.join(out_dir, name) - self.__write_slc_img_bin(data, bin_path,name) - out_hdr_path = bin_path+'.hdr' - self.__write_bin_hdr(out_hdr_path, bin_path, rows, cols) - - self.__write_config_file(out_dir, rows, cols) - - @staticmethod - def __write_slc_img_bin(im, file_path,name): - """ - 写入影像到bin文件中,保存为float32类型 - :param im : 影像矩阵数据,暂支持单通道影像数据 - :param file_path: bin文件的完整路径 - """ - with open(file_path, 'wb') as f: - rows = im.shape[0] - cols = im.shape[1] - cre_im = np.zeros((rows, 2*cols), dtype=float) - cre_im[:, ::2] = im.real #存 real - cre_im[:, 1::2] = im.imag #存 imag - for row in range(rows): - cre_im_bin = struct.pack("f" * 2*cols, *np.reshape(cre_im[row, :], (2*cols, 1), order='F')) - f.write(cre_im_bin) - f.close() - - @staticmethod - def read_slc_bin_to_img(bin_path): - """ - 读取bin格式二进制数据,输出为矩阵 - :param bin_path : bin文件的路径,包含.bin,.config - :return : 矩阵信息 - """ - (bin_dir, bin_name) = os.path.split(bin_path) - config_path = os.path.join(bin_dir, 'config.txt') - config = open(config_path, 'r').read().split('\n', -1) - rows = int(config[1]) - cols = int(config[4]) - - bin_file = open(bin_path, 'rb') # 打开二进制文件 - size = os.path.getsize(bin_path) # 获得文件大小 - if size < rows * cols * 4 * 2: - raise Exception( - 'bin size less than rows*cols*4! size:', - size, - 'byte, rows:', - rows, - 'cols:', - cols) - - bin_data = np.zeros([rows, cols*2], dtype=np.float32) - img_array = np.zeros([2,rows, cols], dtype=np.float32) - for row in range(rows): - data = bin_file.read(4 * cols * 2) # 每次读取一行的二进制数据 - row_data = struct.unpack('f' * cols*2, data) # 转为一行float数据 - bin_data[row, :] = row_data - bin_file.close() - img_array[0] = bin_data[:, ::2] # real - img_array[1] = bin_data[:, 1::2] # imag - return img_array - - - @staticmethod - def __write_bin_hdr(out_hdr_path, bin_path, rows, cols): - """ - 写入影像的头文件 - :param out_hdr_path : 头文件的路径 - :param bin_path: bin文件的路径 - :param rows: 影像的行数 - :param cols: 影像的列数 - """ - h1 = 'ENVI' - h2 = 'description = {' - h3 = 'ENVI File, Created [] }' - h4 = 'samples = ' + str(cols) # 列 - h5 = 'lines = ' + str(rows) # 行 - h6 = 'bands = 1 ' # 波段数 - h7 = 'header offset = 0' - h8 = 'file type = ENVI Standard' - h9 = 'data type = 6' # 数据格式,6代表复数 - h10 = 'interleave = bsq' # 存储格式 - h11 = 'sensor type = Unknown' - h12 = 'byte order = 0' - h13 = 'wavelength units = Unknown' - h14 = 'complex function = Power' - h = [h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14] - doc = open(out_hdr_path, 'w') - for i in range(0, 14): - print(h[i], end='', file=doc) - print('\n', end='', file=doc) - doc.close() - - @staticmethod - def __write_config_file(out_config_dir, rows, cols): - """ - 写入polsarpro配置文件 - :param out_config_dir : 配置文件路径 - :param rows: 影像的行数 - :param cols: 影像的列数 - """ - h1 = 'Nrow' - h2 = str(rows) - h3 = '---------' - h4 = 'Ncol' - h5 = str(cols) - h6 = '---------' - h7 = 'PolarCase' - # h8 = 'monostatic' - h8 = 'bistatic' - h9 = '---------' - h10 = 'PolarType' - h11 = 'full' - h = [h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11] - - out_config_path = os.path.join(out_config_dir, 'config.txt') - doc = open(out_config_path, 'w') - for i in range(0, 11): - print(h[i], end='', file=doc) - print('\n', end='', file=doc) - doc.close() - - def api_ahv_to_polsarpro_s2(self, out_file_dir, in_ahv_dir): - - s11, s12, s21, s22 = self.__ahv_to_s2(in_ahv_dir) - - self.__s2_to_bin(out_file_dir, s11, s12, s21, s22) - - -# if __name__ == '__main__': -# # test() -# atp = AHVToPolsarproS2() -# ahv_path = r'D:\DATA\GAOFEN3\2-GF3_MYN_WAV_020086_E107.2_N27.6_20200603_L1A_AHV_L10004843087' -# # ahv_path = 'D:\\DATA\\GAOFEN3\\2598957_Paris\\' -# out_file_path = r'D:\DATA\GAOFEN3\2-GF3_MYN_WAV_020086_E107.2_N27.6_20200603_L1A_AHV_L10004843087\SLC_SHJ_2' -# atp.api_ahv_to_polsarpro_s2(out_file_path, ahv_path) -# bin_path = r'D:\DATA\GAOFEN3\2-GF3_MYN_WAV_020086_E107.2_N27.6_20200603_L1A_AHV_L10004843087\SLC_SHJ\s11.bin' -# # data = atp.read_slc_bin_to_img(bin_path) -# print("done") diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/DualPolarToPolsarproC2.py b/landcover-L-SAR/tool/algorithm/polsarpro/DualPolarToPolsarproC2.py deleted file mode 100644 index ca0950b..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/DualPolarToPolsarproC2.py +++ /dev/null @@ -1,196 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:DualPolarToPolsarproC2.py -@Function:双极化影像转成polsarpro格式C2数据 -@Contact: -@Author:SHJ -@Date:2021/11/5 -@Version:1.0.0 -""" -import os -import numpy as np -import glob -import struct -import gc -from tool.algorithm.image.ImageHandle import ImageHandler - - -class DualPolarToPolsarproC2: - """ - 双极化影像转换为bin格式C2矩阵,支持polsarpro处理 - """ - - def __init__(self): - pass - - @staticmethod - def __dual_polar_to_c2(dual_polar_dir): - """ - 双影像转S2矩阵 - :param dual_polar_dir: 双极化影像文件夹路径 - :return: C2矩阵 - """ - in_tif_paths = list(glob.glob(os.path.join(dual_polar_dir, '*.tif'))) - - if in_tif_paths == []: - in_tif_paths = list(glob.glob(os.path.join(dual_polar_dir, '*.tiff'))) - s11, s22 = None, None - flag_list = [0, 0, 0, 0] - for in_tif_path in in_tif_paths: - # 读取原始SAR影像 - proj, geotrans, data = ImageHandler.read_img(in_tif_path) - # 获取极化类型 - if 'HH' in os.path.basename(in_tif_path): - s11 = data[0, :, :] + 1j * data[1, :, :] - flag_list[0] = 1 - elif 'HV' in os.path.basename(in_tif_path): - s22 = data[0, :, :] + 1j * data[1, :, :] - flag_list[1] = 1 - elif 'VH' in os.path.basename(in_tif_path): - s22 = data[0, :, :] + 1j * data[1, :, :] - flag_list[2] = 1 - elif 'VV' in os.path.basename(in_tif_path): - s11 = data[0, :, :] + 1j * data[1, :, :] - flag_list[3] = 1 - else: - continue - del data - gc.collect() - - if flag_list != [1, 1, 0, 0] and flag_list != [0, 0, 1, 1] : - raise Exception('Dual-Polarization SAR is not in path :%s',in_tif_path) - - c11,c12,c22 = None, None, None - c11 = np.abs(s11)** 2 - c12 = s11 * np.conj(s22) - del s11 - gc.collect() - c22 = np.abs(s22)**2 - return c11, c12, c22 - - def __c2_to_polsarpro_c2(self, out_dir, c11, c12, c22): - """ - C2矩阵转bin格式,支持 polsarpro处理 - :param out_dir: 输出的文件夹路径 - :param c11: - :param c12: - :param c21: - :param c22: - :return: bin格式矩阵C3和头文件 - """ - if not os.path.exists(out_dir): - os.makedirs(out_dir) - - rows = c11.shape[0] - cols = c11.shape[1] - bins_dict = { - 'C11.bin': c11, - 'C12_real.bin': c12.real, - 'C12_imag.bin': c12.imag, - 'C22.bin': c22} - - for name, data in bins_dict.items(): - bin_path = os.path.join(out_dir, name) - self.__write_img_bin(data, bin_path) - out_hdr_path = bin_path + '.hdr' - self.__write_bin_hdr(out_hdr_path, bin_path, rows, cols) - - self.__write_config_file(out_dir, rows, cols) - - def rows(self): - """获取影像行数""" - return self._rows - - def cols(self): - """获取影像列数""" - return self._cols - - def __write_img_bin(self, im, file_path): - """ - 写入影像到bin文件中,保存为float32类型 - :param im : 影像矩阵数据,暂支持单通道影像数据 - :param file_path: bin文件的完整路径 - """ - with open(file_path, 'wb') as f: - self._rows = im.shape[0] - self._cols = im.shape[1] - for row in range(self._rows): - im_bin = struct.pack("f" * self._cols, *np.reshape(im[row, :], (self._cols, 1), order='F')) - f.write(im_bin) - f.close() - - @staticmethod - def __write_bin_hdr(out_hdr_path, bin_path, rows, cols): - """ - 写入影像的头文件 - :param out_hdr_path : 头文件的路径 - :param bin_path: bin文件的路径 - :param rows: 影像的行数 - :param cols: 影像的列数 - """ - name = os.path.split(bin_path)[1] - h1 = 'ENVI' - h2 = 'description = {' - h3 = 'File Imported into ENVI. }' - h4 = 'samples = ' + str(cols) # 列 - h5 = 'lines = ' + str(rows) # 行 - h6 = 'bands = 1 ' # 波段数 - h7 = 'header offset = 0' - h8 = 'file type = ENVI Standard' - h9 = 'data type = 4' # 数据格式 浮点型 - h10 = 'interleave = bsq' # 存储格式 - h11 = 'sensor type = Unknown' - h12 = 'byte order = 0' - h13 = 'band names = {' - h14 = name + '}' - h = [h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, h14] - doc = open(out_hdr_path, 'w') - for i in range(0, 14): - print(h[i], end='', file=doc) - print('\n', end='', file=doc) - doc.close() - - @staticmethod - def __write_config_file(out_config_dir, rows, cols): - """ - 写入polsarpro配置文件 - :param out_config_dir : 配置文件路径 - :param rows: 影像的行数 - :param cols: 影像的列数 - """ - h1 = 'Nrow' - h2 = str(rows) - h3 = '---------' - h4 = 'Ncol' - h5 = str(cols) - h6 = '---------' - h7 = 'PolarCase' - h8 = 'monostatic' - h9 = '---------' - h10 = 'PolarType' - h11 = 'pp1' - h = [h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11] - - out_config_path = os.path.join(out_config_dir, 'config.txt') - doc = open(out_config_path, 'w') - for i in range(0, 11): - print(h[i], end='', file=doc) - print('\n', end='', file=doc) - doc.close() - - - def api_dual_polar__to_polsarpro_c2(self, out_file_dir, dual_polar_dir): - c11, c12, c22 = self.__dual_polar_to_c2(dual_polar_dir) - self.__c2_to_polsarpro_c2(out_file_dir,c11, c12, c22) - - -# if __name__ == '__main__': -# tp = DualPolarToPolsarproC2() -# out_dic = 'E:\\3-GF3_KAS_FSI_020253_E110.8_N25.5_20200614_L1A_HHHV_L10004871459\\SLC_SHJ1' -# in_dic = 'E:\\3-GF3_KAS_FSI_020253_E110.8_N25.5_20200614_L1A_HHHV_L10004871459\\' -# # out_file_path = 'D:\\bintest0923\\' -# tp.api_dual_polar__to_polsarpro_c2(out_dic,in_dic) -# # atp.ahv_to_polsarpro_t3(out_file_path, ahv_path) -# -# print("done") diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/GLCM_当前没用到灰度共生矩阵特征.py b/landcover-L-SAR/tool/algorithm/polsarpro/GLCM_当前没用到灰度共生矩阵特征.py deleted file mode 100644 index 01d86dd..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/GLCM_当前没用到灰度共生矩阵特征.py +++ /dev/null @@ -1,97 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project :onestar -@File :GLDM.py -@Contact: -scikit-image feature计算图像特征:https://blog.csdn.net/lyxleft/article/details/102904909 -python如何在二维图像上进行卷积:https://www.xz577.com/j/281686.html -利用python的skimage计算灰度共生矩阵:https://zhuanlan.zhihu.com/p/147066037 -@function :计算图像灰度共生矩阵 -@Author :SHJ -@Date :2021/11/10 14:42 -@Version :1.0.0 -""" -import numpy as np -import os -from skimage.feature import greycomatrix, greycoprops -import datetime -from tool.algorithm.image.ImageHandle import ImageHandler - -class GLDM: - def __init__(self,win_size = 15, step=2,levels=16,angles=[0,45,90,135], - prop=['contrast', 'dissimilarity', 'homogeneity', 'energy', 'correlation', 'ASM']): - self._win_size = win_size # 计算灰度共生矩阵窗口尺寸,为奇数 - self._step = step # 步长 - self._levels = levels # 灰度等级:例如16,256 - self._angles = list(np.deg2rad(np.array(angles))) #角度,使用弧度制 - """ - 'contrast':对比度:反映了图像的清晰度和纹理沟纹深浅的程度 - 'dissimilarity':差异性 - 'homogeneity':同质性/逆差距:度量图像纹理局部变化的多少。其值大则说明图像纹理的不同区域间缺少变化,局部非常均匀。 - 'energy':能量:是灰度共生矩阵元素值的平方和,所以也称能量,反映了图像灰度分布均匀程度和纹理粗细度 - 'correlation':相关性:它度量空间灰度共生矩阵元素在行或列方向上的相似程度 - 'ASM':二阶距 - """ - self._prop = prop #纹理特征名称 - - def get_glcm_value(self,input): - values_temp = [] - # 统计得到glcm - # 得到共生矩阵,参数:图像矩阵,距离,方向,灰度级别,是否对称,是否标准化 - # para2: [0, np.pi / 4, np.pi / 2, np.pi * 3 / 4] 一共计算了四个方向,你也可以选择一个方向 - glcm = greycomatrix(input, [self._step], self._angles, self._levels, symmetric=False, normed=True) - # print(glcm.shape) - # 循环计算表征纹理的参数 - for prop in self._prop: - temp = greycoprops(glcm, prop) - # print(temp) - values_temp.append(np.mean(temp)) - return values_temp - - - def get_glcm_array(self,inputs: np.ndarray, win_size): - h, w = inputs.shape - pad = (win_size - 1) // 2 - inputs = np.pad(inputs, pad_width=[(pad, pad), (pad, pad)], mode="constant", constant_values=0) - glcm_array ={} - for name in self._prop: - glcm_array.update({name:np.zeros(shape=(h, w),dtype=np.float32)}) - - for i in range(h): # 行号 - for j in range(w): # 列号 - window = inputs[i: i + win_size, j: j + win_size] - value = self.get_glcm_value(window) - print('i:%s,j:%s',i,j) - # print(value) - for n,array in zip(range(len(glcm_array)),glcm_array.values()): - array[i,j] = value[n] - return glcm_array - - @staticmethod - def standardization(data, num=1): - # 矩阵标准化到[0,1] - data[np.isnan(data)] = np.min(data) # 异常值填充为0 - _range = np.max(data) - np.min(data) - return (data - np.min(data)) / _range * num - - def api_get_glcm_array(self,out_dir,in_tif_path,name=''): - - ih = ImageHandler() - proj, geotrans, array = ih.read_img(in_tif_path) - array[np.where(array > 500000)]=500000 #去除过大的值,避免标准化时,大部分的值都接近0 - array = self.standardization(array,self._levels-1) #标准化到0~(self._levels-1) - array = np.uint8(array) - glcm_array = self.get_glcm_array(array, self._win_size) - for key,value in glcm_array.items(): - out_path = os.path.join(out_dir,name+'_'+key+'.tif') - ih.write_img(out_path, proj, geotrans,value) - -if __name__ == '__main__': - start = datetime.datetime.now() - gldm = GLDM(win_size=9,levels=16,step=3,angles=[0,45,90,135]) - gldm.api_get_glcm_array('D:\glcm','D:\glcm\src_img.tif',) - end = datetime.datetime.now() - msg = 'running use time: %s ' % (end - start) - print(msg) - - # 666*720尺寸影像消耗的running use time: 0:04:23.155424 \ No newline at end of file diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/bin2tif.py b/landcover-L-SAR/tool/algorithm/polsarpro/bin2tif.py deleted file mode 100644 index a970584..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/bin2tif.py +++ /dev/null @@ -1,85 +0,0 @@ -import os -import glob -import numpy as np -import struct -from PIL import Image -from tool.algorithm.ml.machineLearning import MachineLeaning as ml - - -def read_bin_to_img(bin_path): - """ - 读取bin格式二进制数据,输出为矩阵 - :param bin_path : bin文件的路径,包含.bin,.config - :return : 矩阵信息 - """ - (bin_dir, bin_name) = os.path.split(bin_path) - config_path = os.path.join(bin_dir, 'config.txt') - config = open(config_path, 'r').read().split('\n', -1) - rows = int(config[1]) - cols = int(config[4]) - - bin_file = open(bin_path, 'rb') # 打开二进制文件 - size = os.path.getsize(bin_path) # 获得文件大小 - if size < rows * cols * 4: - raise Exception( - 'bin size less than rows*cols*4! size:', - size, - 'byte, rows:', - rows, - 'cols:', - cols) - - img = np.zeros([rows, cols], dtype=np.float32) - for row in range(rows): - data = bin_file.read(4 * cols) # 每次读取一行的二进制数据 - row_data = struct.unpack('f' * cols, data) # 转为一行float数据 - img[row, :] = row_data - bin_file.close() - return img - -def write_bin_to_tif(out_tif_dir, bin_dir): - """ - 读取H-A-Alpha分解二进制数据,输出为矩阵格式的字典 - :param out_tif_dir : tif的输出路径 - :param bin_dir : 二进制数据的目录,包含.bin,.config - :return out_tif_path: 生成tif的路径字典 - """ - bin_paths = list(glob.glob(os.path.join(bin_dir, '*.bin'))) - out_tif_path = {} - for in_path in bin_paths: - name = os.path.split(in_path)[1].split('.')[0] - out_path = os.path.join(out_tif_dir, name + '.tif') - out_tif_path.update({name: out_path}) - if os.path.exists(os.path.split(out_path)[0]) is False: - os.makedirs(os.path.split(out_path)[0]) - img_array = read_bin_to_img(in_path) - img_array[np.isnan(img_array)] = 0 # 异常值填充为0 - img_array = ml.standardization(img_array) # 数据标准化到[0,1] - out_image = Image.fromarray(img_array) - out_image.save(out_path) - return out_tif_path - -def write_bin_to_tif_soil(out_tif_dir, bin_dir): - """ - 读取H-A-Alpha分解二进制数据,输出为矩阵格式的字典 - :param out_tif_dir : tif的输出路径 - :param bin_dir : 二进制数据的目录,包含.bin,.config - :return out_tif_path: 生成tif的路径字典 - """ - bin_paths = list(glob.glob(os.path.join(bin_dir, '*.bin'))) - out_tif_path = {} - for in_path in bin_paths: - name = os.path.split(in_path)[1].split('.')[0] - out_path = os.path.join(out_tif_dir, name + '.tif') - out_tif_path.update({name: out_path}) - if os.path.exists(os.path.split(out_path)[0]) is False: - os.makedirs(os.path.split(out_path)[0]) - img_array = read_bin_to_img(in_path) - img_array[np.isnan(img_array)] = 0 # 异常值填充为0 - # img_array = ml.standardization(img_array) # 数据标准化到[0,1] - out_image = Image.fromarray(img_array) - out_image.save(out_path) - return out_tif_path - - - diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/createfeature.py b/landcover-L-SAR/tool/algorithm/polsarpro/createfeature.py deleted file mode 100644 index 6640d49..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/createfeature.py +++ /dev/null @@ -1,190 +0,0 @@ -from tool.algorithm.algtools.MetaDataHandler import Calibration -from tool.algorithm.polsarpro.AHVToPolsarpro import AHVToPolsarpro -from tool.algorithm.polsarpro.pspLeeRefinedFilterT3 import LeeRefinedFilterT3 -from tool.algorithm.polsarpro.pspCloudePottierDecomposition import PspCloudePottierDecomposition -from tool.algorithm.polsarpro.pspFreemanDecomposition import PspFreemanDecomposition -from tool.algorithm.polsarpro.pspYamaguchiDecomposition import PspYamaguchiDecomposition -from tool.algorithm.polsarpro.pspTouziDecomposition import PspTouziDecomposition -from tool.algorithm.polsarpro.bin2tif import write_bin_to_tif -from tool.algorithm.polsarpro.pspHAAlphaDecomposition import PspHAAlphaDecomposition -from tool.algorithm.xml.AlgXmlHandle import InitPara -import logging -import os -import shutil -import glob -logger = logging.getLogger("mylog") - -class CreateFeature: - """ - 生产特征 - """ - def __init__(self, debug = False, exe_dir = ''): - self._debug = debug - self._exe_dir = exe_dir - pass - - - def ahv_to_t3(self, workspace_processing_path, workspace_preprocessing_path, hh_hv_vh_vv_list, name='',FILTER_SIZE=3): - # 全极化tif转bin格式T3数据 - atp = AHVToPolsarpro() - - atp = AHVToPolsarpro(hh_hv_vh_vv_list) - lee_filter_path = os.path.join(workspace_processing_path, name, 'lee_filter\\') # workspace_processing_path + name + '\\lee_filter\\' - if self._debug == False: - - t3_path = os.path.join(workspace_processing_path, name, 'psp_t3\\') # workspace_processing_path + name + '\\psp_t3\\' - # atp.ahv_to_polsarpro_t3(t3_path, tif_path) - - polarization = ['HH', 'HV', 'VH', 'VV'] - if os.path.exists(workspace_preprocessing_path + name + '\\'): - meta_xml_paths = list(glob.glob(os.path.join(workspace_preprocessing_path + name, '*.meta.xml'))) - meta_dic = InitPara.get_meta_dic_new(meta_xml_paths, name) - calibration = Calibration.get_Calibration_coefficient(meta_dic['Origin_META'], polarization) - tif_path = atp.calibration(calibration, workspace_preprocessing_path, name) - atp.ahv_to_polsarpro_t3_veg(t3_path, tif_path) - - # Lee滤波 - leeFilter = LeeRefinedFilterT3() - leeFilter.api_lee_refined_filter_T3('', t3_path, lee_filter_path, 0, 0, atp.rows(), atp.cols(), FILTER_SIZE) - logger.info("refine_lee filter success!") - return lee_filter_path - - def decompose(self,workspace_processing_path, name, t3_path, rows, cols, hh_hv_vh_vv_dic={},FeatureInput=['Freeman', 'Yamaguchi', 'Cloude']): # , 'Touzi' - """ - 极化分解:Freeman、Touzi、Yamaguchi、Cloude - :param t3_path: t3文件路径 - :param rows: 影像行数 - :return cols:影像列数 - """ - # 计算特征组合 - exeDir = self._exe_dir - outFolderDic = {} - if 'Freeman' in FeatureInput: - # freeman分解 - freemanOutDir = os.path.join(workspace_processing_path, name + '\\freeman\\') - if self._debug == False: - freemDecom = PspFreemanDecomposition(exeDir, t3_path, freemanOutDir) - flag = freemDecom.api_freeman_decomposition_T3(0, 0, rows, cols) - if not flag: - logger.error('FreemanDecomposition err') - return False, None - outFolderDic['Freeman'] = freemanOutDir - - # Touzi分解 - if 'Touzi' in FeatureInput: - - touziOutDir = os.path.join(workspace_processing_path, name + '\\touzi\\') - if not os.path.exists(touziOutDir): - os.makedirs(touziOutDir) - if self._debug == False: - # touzi分解耗时较长,且对特征表达效果较差 - p = PspTouziDecomposition(hh_hv_vh_vv_dic, touziOutDir) - p.Touzi_decomposition_multiprocessing() - outFolderDic['Touzi'] = touziOutDir - - if 'Yamaguchi' in FeatureInput: - # Yamaguchi分解 - yamaguchiOutDir = os.path.join(workspace_processing_path, name + '\\yamaguchi\\') - if self._debug == False: - yamaguchiDecom = PspYamaguchiDecomposition(exeDir, t3_path, yamaguchiOutDir) - flag = yamaguchiDecom.api_yamaguchi_4components_decomposition_T3(0, 0, rows, cols) - if not flag: - logger.error('CloudePottierDecomposition err') - return False, None - outFolderDic['Yamaguchi'] = yamaguchiOutDir - - if 'Cloude' in FeatureInput: - # CloudePottier分解 - cloudeOutDir = os.path.join(workspace_processing_path, name + '\\cloude\\') - if self._debug == False: - cloudeDecom = PspCloudePottierDecomposition( - exeDir, t3_path, cloudeOutDir) - flag = cloudeDecom.api_h_a_alpha_decomposition_T3( - 0, 0, rows, cols) - if not flag: - logger.error('CloudePottierDecomposition err') - return False, None - outFolderDic['Cloude'] = cloudeOutDir - return True, outFolderDic - - def creat_h_a_alpha_features(self, t3_path, out_dir): - logger.info('ahv transform to polsarpro T3 matrix success!') - logger.info('progress bar: 20%') - h_a_alpha_decomposition_T3_path = os.path.join(self._exe_dir, 'h_a_alpha_decomposition_T3.exe') - h_a_alpha_eigenvalue_set_T3_path = os.path.join(self._exe_dir, 'h_a_alpha_eigenvalue_set_T3.exe') - h_a_alpha_eigenvector_set_T3_path = os.path.join(self._exe_dir, 'h_a_alpha_eigenvector_set_T3.exe') - - if self._debug == False: - haa = PspHAAlphaDecomposition(normalization=True) - haa.api_creat_h_a_alpha_features(h_a_alpha_out_dir=out_dir, - h_a_alpha_decomposition_T3_path=h_a_alpha_decomposition_T3_path , - h_a_alpha_eigenvalue_set_T3_path=h_a_alpha_eigenvalue_set_T3_path , - h_a_alpha_eigenvector_set_T3_path=h_a_alpha_eigenvector_set_T3_path, - polsarpro_in_dir=t3_path) - - - def cereat_features_dic(self,outFolderDic, feature_tif_dir): - - if not os.path.exists(feature_tif_dir): - os.makedirs(feature_tif_dir) - - feature_tif_paths = {} - for key in outFolderDic: - feature_bin_dic = outFolderDic[key] - if key == 'Touzi': - for path in list(glob.glob(os.path.join(feature_bin_dic, '*.tif'))): - name = os.path.split(path)[1].split('.')[0] - if self._debug == False: - shutil.copyfile(path, os.path.join(feature_tif_dir, name + '.tif')) # feature_tif_dir + '\\' + name + '.tif') - feature_tif_paths.update({name: os.path.join(feature_tif_dir, name + '.tif')}) # feature_tif_dir + '\\' + name + '.tif' - else: - feature_tif_paths.update(write_bin_to_tif(feature_tif_dir, feature_bin_dic)) - return feature_tif_paths - - @staticmethod - def decompose_single_tar(hh_hv_vh_vv_list, workspace_processing_path, workspace_preprocessing_path, name, exe_dir, rows, cols, FILTER_SIZE = 3, debug =False, FeatureInput=['Freeman', 'Yamaguchi', 'Cloude']): - hh_hv_vh_vv_dic = {} - hh_hv_vh_vv_dic.update({'HH': hh_hv_vh_vv_list[0]}) - hh_hv_vh_vv_dic.update({'HV': hh_hv_vh_vv_list[1]}) - hh_hv_vh_vv_dic.update({'VH': hh_hv_vh_vv_list[2]}) - hh_hv_vh_vv_dic.update({'VV': hh_hv_vh_vv_list[3]}) - t3_path = os.path.join(workspace_processing_path, name, "lee_filter") # workspace_processing_path + name + "\\lee_filter" - feature_tif_dir = os.path.join(workspace_processing_path, name, 'features') # workspace_processing_path + name + "\\features" - - cfeature = CreateFeature(debug, exe_dir) - - cfeature.creat_h_a_alpha_features(t3_path, feature_tif_dir) - - t3_path = cfeature.ahv_to_t3(workspace_processing_path, workspace_preprocessing_path, hh_hv_vh_vv_list, name, FILTER_SIZE) - flag, outFolderDic = cfeature.decompose(workspace_processing_path, name, t3_path, rows, cols, hh_hv_vh_vv_dic, FeatureInput) # , 'Touzi' - cfeature.cereat_features_dic(outFolderDic, feature_tif_dir) - return feature_tif_dir - -if __name__ == '__main__': - # # 实例1: - # exe_dir = os.getcwd() - # dir = r'D:\MicroWorkspace\product\C-SAR\VegetationPhenology\Temporary\preprocessed/' - # hh_hv_vh_vv_list = [dir +'GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422_RPC_HH_preprocessed.tif', - # dir +'GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422_RPC_HV_preprocessed.tif', - # dir +'GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422_RPC_VH_preprocessed.tif', - # dir +'GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422_RPC_VV_preprocessed.tif'] - # - # workspace_processing_path= r"D:\MicroWorkspace\product\C-SAR\VegetationPhenology\Temporary\processing/" - # name= 'GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422_RPC' - # hh_hv_vh_vv_dic = {} - # hh_hv_vh_vv_dic.update({'HH': hh_hv_vh_vv_list[0]}) - # hh_hv_vh_vv_dic.update({'HV': hh_hv_vh_vv_list[1]}) - # hh_hv_vh_vv_dic.update({'VH': hh_hv_vh_vv_list[2]}) - # hh_hv_vh_vv_dic.update({'VV': hh_hv_vh_vv_list[3]}) - # t3_path = workspace_processing_path + name + "\\lee_filter" - # feature_tif_dir = workspace_processing_path + name + "\\features" - # - # cfeature = CreateFeature(False, exe_dir) - # - # cfeature.creat_h_a_alpha_features(t3_path, feature_tif_dir) - # - # t3_path = cfeature.ahv_to_t3(workspace_processing_path, hh_hv_vh_vv_list, name, 3) - # flag, outFolderDic = cfeature.decompose(workspace_processing_path, name, t3_path, 997, 1227, hh_hv_vh_vv_dic, FeatureInput=['Freeman', 'Touzi', 'Yamaguchi', 'Cloude']) - # - # feature_tifs_dic = cfeature.cereat_features_dic(outFolderDic, feature_tif_dir) - pass \ No newline at end of file diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/polarizationDecomposition.py b/landcover-L-SAR/tool/algorithm/polsarpro/polarizationDecomposition.py deleted file mode 100644 index 5e1798d..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/polarizationDecomposition.py +++ /dev/null @@ -1,2283 +0,0 @@ -# -*- coding: UTF-8 -*- - -from typing import Union -import os -from osgeo import gdal -import numpy as np -import cv2 -import math -import cmath -import scipy.linalg as la -import struct - -"*** ======================================================================================== ***" -" This program is written to implement the miscellaneous target decomposition theorems in the domain " \ - -"of polarimetric radar remote sensing using full polarimetric information" - - -"*** Programmer - Raktim Ghosh (MSc, University of Twente) Date Written - May, 2020***" - - -""" List of scattering power decompositions implemented """ - -"""========================================================================""" - -"Touzi Decomposition - Class Name (ModTouzi) *** Including orientation angle" - -"Touzi Decomposition - CLass Name (Touzi) *** Excluding orientation angle" - -"H/A/Alpha Decompositions (Cloude-Pottier) - Class Name (HAAlpha)" - -"Sinclair Decomposition - Class Name (Sinclair)" - -"Cloude Decomposition - CLass Name (Cloude)" - -"Pauli Decomposition - Class Name (Pauli)" - -"Van Zyl Decomposition - Class Name (Vanzyl)" - -"FreeMan-Durden Decomposition Class Name (FreeMan)" - -"Yamaguchi 4-Component Decomposition Class Name (Yamaguchi2005) *** Original - Introduced Helix Scattering" - -"Yamaguchi 4-Component Decomposition Class Name (Yamaguchi2011) *** Modified - Rotated Coherency Matrix" - -"General 4-Component Decomposition (Singh) Class Name (General4SD)" - -"Model-based 6-Component Decomposition (Singh) Class Name (General6SD) *** Extension of General 4SD" - -"Seven Component Decomposition (Singh) Class Name (General7SD) *** Extension of 6SD" - -"""========================================================================""" - - -class Polarimetry: - def __init__(self, b, w): - - self.__band = b - self.__w = w - self.__band_list = list() - self.__band_list_avg = list() - - """ - A list is created to append all the full polarimetric channels with conjugates - """ - for item in self.__band: - for i in range(1, item.RasterCount + 1): - self.__temp = item.GetRasterBand(i).ReadAsArray().astype(float) - self.__band_list.append(self.__temp) - - for i in range(len(self.__band_list)): - self.__band_list_avg.append(cv2.blur(self.__band_list[i], (self.__w, self.__w))) - - """ - The private variables are consisting of the fully polarimetric channels. As for a fully polarimetric - synthetic aperture radar system, there are four components according to the Sinclair matrix. - - :param s_hh: represents the horizontal-horizontal channel - :param s_hh_conj: represents the conjugate of horizontal-horizontal channel - :param s_hv: represents the horizontal-vertical channel - :param s_hv_conj: represents the conjugate of horizontal-horizontal channel - :param s_vh: represents the vertical-horizontal channel - :param s_vh_conj: represents the conjugate of horizontal-horizontal channel - :param s_vv: represents the vertical-vertical channel - :param s_vv_conj: represents the conjugate of horizontal-horizontal channel - :param b: represents the object of bands - """ - - self.__S_hh = self.__band_list_avg[0] + 1j * self.__band_list_avg[1] - self.__S_hh_conj = self.__band_list_avg[0] - 1j * self.__band_list_avg[1] - self.__S_hv = self.__band_list_avg[2] + 1j * self.__band_list_avg[3] - self.__S_hv_conj = self.__band_list_avg[2] - 1j * self.__band_list_avg[3] - self.__S_vh = self.__band_list_avg[4] + 1j * self.__band_list_avg[5] - self.__S_vh_conj = self.__band_list_avg[4] - 1j * self.__band_list_avg[5] - self.__S_vv = self.__band_list_avg[6] + 1j * self.__band_list_avg[7] - self.__S_vv_conj = self.__band_list_avg[6] - 1j * self.__band_list_avg[7] - - def get_cov_mat_img(self): - - """ - This function returns the 3 * 3 covariance matrix based on physically measurable parameters. - The covariance matrix consists of 9 components. - - Format of the covariance matrix: - - [ 2 ^ 0.5 * - <2 ^ 0.5 * <2 * 2 ^ 0.5 * - 2 ^ 0.5 * ] - - :return: It returns the nine parameters. t_ij represents the components of covariance matrix with - ith row and jth column - """ - - s_11 = abs(self.__S_hh * self.__S_hh_conj) - s_12 = np.sqrt(2) * self.__S_hh * self.__S_hv_conj - s_13 = self.__S_hh * self.__S_vv_conj - s_21 = np.sqrt(2) * self.__S_hv * self.__S_hh_conj - s_22 = abs(2 * self.__S_hv * self.__S_hv_conj) - s_23 = np.sqrt(2) * self.__S_hv * self.__S_vv_conj - s_31 = self.__S_vv * self.__S_hh_conj - s_32 = np.sqrt(2) * self.__S_vv * self.__S_hv_conj - s_33 = abs(self.__S_vv * self.__S_vv_conj) - - return [s_11, s_12, s_13, s_21, s_22, s_23, s_31, s_32, s_33] - - def get_coh_mat_img(self): - - """ - This function returns the 3 * 3 coherency (Pauli-based covariance) matrix based on - physically measurable parameters based on mathematically and orthogonal Pauli matrix components. - The coherency matrix consists of 9 components. - - Format of the coherency matrix: - - 0.5 * [<(Shh + Svv) * conj(Shh + Svv)> <(Shh + Svv) * conj(Shh + Svv)> 2 * <(Shh + Svv) * conj(Shv)> - <(Shh - Svv) * conj(Shh + Svv)> <(Shh - Svv) * conj(Shh - Svv)> 2 * <(Shh - Svv) * conj(Shv)> - <2 * Shv * conj(Shh + Svv)> <2 * Shv * conj(Shh - Svv)> 4 * ] - - :return: It returns the nine parameters. s_ij represents the components of covariance matrix with - ith row and jth column - """ - - t_11 = 0.5 * abs((self.__S_hh + self.__S_vv) * (self.__S_hh_conj + self.__S_vv_conj)) - t_12 = 0.5 * (self.__S_hh + self.__S_vv) * (self.__S_hh_conj - self.__S_vv_conj) - t_13 = (self.__S_hh + self.__S_vv) * self.__S_hv_conj - t_21 = 0.5 * (self.__S_hh - self.__S_vv) * (self.__S_hh_conj + self.__S_vv_conj) - t_22 = 0.5 * abs((self.__S_hh - self.__S_vv) * (self.__S_hh_conj - self.__S_vv_conj)) - t_23 = (self.__S_hh - self.__S_vv) * self.__S_hv_conj - t_31 = self.__S_hv * (self.__S_hh_conj + self.__S_vv_conj) - t_32 = self.__S_hv * (self.__S_hh_conj - self.__S_vv_conj) - t_33 = 2 * abs(self.__S_hv * self.__S_hv_conj) - - return [t_11, t_12, t_13, t_21, t_22, t_23, t_31, t_32, t_33] - - def get_eig_val(self): - - """ - This function returns the eigen values extracted from the 3 * 3 coherency matrix. - """ - - coh_mat = self.get_coh_mat_img() - - rows, cols = np.shape(coh_mat[0])[0], np.shape(coh_mat[0])[1] - - t11, t12, t13 = coh_mat[0], coh_mat[1], coh_mat[2] - t21, t22, t23 = coh_mat[3], coh_mat[4], coh_mat[5] - t31, t32, t33 = coh_mat[6], coh_mat[7], coh_mat[8] - - ev1 = np.zeros([rows, cols], dtype=complex) - ev2 = np.zeros([rows, cols], dtype=complex) - ev3 = np.zeros([rows, cols], dtype=complex) - - for i in range(rows): - for j in range(cols): - - x = np.array([ - [t11[i, j], t12[i, j], t13[i, j]], - [t21[i, j], t22[i, j], t23[i, j]], - [t31[i, j], t32[i, j], t33[i, j]] - ]) - eigV = la.eig(x)[0] - ev1[i, j] = abs(eigV[0]) - ev2[i, j] = abs(eigV[1]) - ev3[i, j] = abs(eigV[2]) - - if ev2[i, j] < ev3[i, j]: - ev2[i, j], ev3[i, j] = ev3[i, j], ev2[i, j] - - ev1[~np.isfinite(ev1)] = 0 - ev2[~np.isfinite(ev2)] = 0 - ev3[~np.isfinite(ev3)] = 0 - - trt = t11 + t22 + t33 - - return [ev1, ev2, ev3, trt] - - def get_eig_vect(self): - - """ - This function returns the normalized eigen vectors extracted from the coherency matrix - """ - - coh_mat = self.get_coh_mat_img() - - rows, cols = np.shape(coh_mat[0])[0], np.shape(coh_mat[0])[1] - - t11, t12, t13 = coh_mat[0], coh_mat[1], coh_mat[2] - t21, t22, t23 = coh_mat[3], coh_mat[4], coh_mat[5] - t31, t32, t33 = coh_mat[6], coh_mat[7], coh_mat[8] - - list2 = list() - - for i in range(rows): - list1 = list() - for j in range(cols): - - x = np.array([ - [t11[i, j], t12[i, j], t13[i, j]], - [t21[i, j], t22[i, j], t23[i, j]], - [t31[i, j], t32[i, j], t33[i, j]] - ]) - list1.append(la.eig(x)[1]) - - list2.append(list1) - - # print(len(list2)) - x = np.array(list2) - y = np.reshape(x, (rows, cols, 3, 3)) - # print(np.shape(y)) - # print(type(y[1, 1][1, 1])) - - return y - - def rot_coh_mat_img(self): - - """ - This function returns rotated version of the 3 * 3 coherency (Pauli-based covariance) matrix based on - physically measurable parameters based on mathematically and orthogonal Pauli matrix components. - The rotated coherency matrix consists of 9 components. - - t_ij_theta: the components of rotated coherency matrix is derived by multiplying the 3 * 3 rotation - matrices and its transpose conjugate. - - Format of the rotation matrix: - - [1 0 0 - Rp(theta) = 0 cos(2 * theta) sin(2 * theta) - 0 - sin(2 * theta) cos(2 * theta)] - - - T(theta) = Rp(theta) * T * transpose(conj(Rp(theta)) - - T => Denote the coherency matrix - theta => Denote the rotation angle - T(theta) => Denote the rotated coherency matrix - - :return: It returns the nine parameters. t_ij_theta represents the components of - rotated coherency matrix with ith row and jth column - """ - - t = self.get_coh_mat_img() - rows, cols = np.shape(t[0])[0], np.shape(t[0])[1] - t_theta_mat = np.zeros([rows, cols]) - - for i in range(rows): - for j in range(cols): - a = t[5][i, j].real - b, c = t[4][i, j], t[8][i, j] - if b == c: - t_theta_mat[i, j] = math.pi / 4 - else: - t_theta_mat[i, j] = 0.5 * math.atan((2 * a.real) / (b - c)) - - t_11_theta = t[0] - t_12_theta = t[1] * np.cos(t_theta_mat) + t[2] * np.sin(t_theta_mat) - t_13_theta = - t[1] * np.sin(t_theta_mat) + t[2] * np.cos(t_theta_mat) - t_21_theta = np.conj(t_12_theta) - t_22_theta = t[4] * (np.cos(t_theta_mat) ** 2) + t[8] * (np.sin(t_theta_mat) ** 2) - t_22_theta += np.real(t[5]) * np.sin(2 * t_theta_mat) - t_23_theta = np.imag(t[5]) * 1j - t_31_theta = np.conj(t_13_theta) - t_32_theta = - np.imag(t[5]) * 1j - t_33_theta = t[8] * (np.cos(t_theta_mat) ** 2) + t[4] * (np.sin(t_theta_mat) ** 2) - t_33_theta -= np.real(t[5]) * (np.sin(t_theta_mat) ** 2) - - return [t_11_theta, t_12_theta, t_13_theta, t_21_theta, t_22_theta, - t_23_theta, t_31_theta, t_32_theta, t_33_theta] - - def get_image(self, ps, pd, pv, pc): - - """ - After estimating the corresponding power term, we generate the decomposed power images of surface, - double-bounce and volume scattering respectively. - - :param ps: power term associated with surface scattering - :param pd: power term associated with double-bounce scattering - :param pv: power term associated with volume scattering - :param pc: power term associated with helix scattering - :return: Images of surface, double-bounce, and volume scattering - """ - - cols, rows = pd.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'helix_Scattering_yamaguchi' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.__band[0].GetProjection()) - out_data.SetGeoTransform(self.__band[0].GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(pc / (ps + pd + pv + pc)) - - def get_band(self): - return self.__band - - -class ModTouzi(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - self.__band = b - self.__w = w - - def get_psi(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Paper Details: "Target Scattering Decomposition in Terms of Roll-Invariant Target Parameters" - - IEEEXplore: https://ieeexplore.ieee.org/document/4039635 - - DOI: 10.1109/TGRS.2006.886176 - - With the projection of Kennaugh-Huynen scattering matrix into the Pauli basis, this model established - the basis invariant representation of coherent target scattering. - - alp: for symmetric scattering type magnitude (normalized) - phi: for symmetric scattering type phase (normalized) - psi: orientation angle (Kennaugh-Huynen maximum polarization parameter (normalized) - tau: target helicity (normalized) - - :return: It returns alp, psi, tau, phi - """ - - ev = self.get_eig_val() - ev1, ev2, ev3, trt = ev[0], ev[1], ev[2], ev[3] - - p1 = ev1 / trt - p2 = ev2 / trt - p3 = ev3 / trt - - rows, cols = np.shape(ev[0])[0], np.shape(ev[0])[1] - eig_vect = self.get_eig_vect() - - alp1, alp2, alp3 = np.zeros([rows, cols]), np.zeros([rows, cols]), np.zeros([rows, cols]) - psi1, psi2, psi3 = np.zeros([rows, cols]), np.zeros([rows, cols]), np.zeros([rows, cols]) - tau1, tau2, tau3 = np.zeros([rows, cols]), np.zeros([rows, cols]), np.zeros([rows, cols]) - phis1, phis2, phis3 = np.zeros([rows, cols]), np.zeros([rows, cols]), np.zeros([rows, cols]) - - print(np.shape(eig_vect)) - - for i in range(rows): - for j in range(cols): - u = np.array([ - [eig_vect[i, j][0, 0], eig_vect[i, j][0, 1], eig_vect[i, j][0, 2]], - [eig_vect[i, j][1, 0], eig_vect[i, j][1, 1], eig_vect[i, j][1, 2]], - [eig_vect[i, j][2, 0], eig_vect[i, j][2, 1], eig_vect[i, j][2, 2]] - ]) - - psi1[i, j] = 0.5 * np.arctan(abs(np.real(u[2, 0]) / np.real(u[1, 0]))) * 180 / math.pi - alp1[i, j] = np.arcsin(abs(np.real(u[1, 0]) / np.cos(2 * psi1[i, j] * math.pi / 180))) * 180 / math.pi - tau1[i, j] = 0.5 * np.arccos(np.real(u[0, 0]) / np.cos(alp1[i, j] * math.pi / 180)) * 180 / math.pi - - psi2[i, j] = 0.5 * np.arctan(abs(np.real(u[2, 1]) / np.real(u[1, 1]))) * 180 / math.pi - alp2[i, j] = np.arcsin(abs(np.real(u[1, 1]) / np.cos(2 * psi2[i, j] * math.pi / 180))) * 180 / math.pi - tau2[i, j] = 0.5 * np.arccos(np.real(u[0, 1]) / np.cos(alp2[i, j] * math.pi / 180)) * 180 / math.pi - - psi3[i, j] = 0.5 * np.arctan(abs(np.real(u[2, 2]) / np.real(u[1, 2]))) * 180 / math.pi - alp3[i, j] = np.arcsin(abs(np.real(u[1, 2]) / np.cos(2 * psi3[i, j] * math.pi / 180))) * 180 / math.pi - tau3[i, j] = 0.5 * np.arccos(np.real(u[0, 2]) / np.cos(alp3[i, j] * math.pi / 180)) * 180 / math.pi - - phis1[i, j] = np.arctan(np.imag(u[1, 0]) / np.real(u[1, 0])) * 180 / math.pi - phis2[i, j] = np.arctan(np.imag(u[1, 1]) / np.real(u[1, 1])) * 180 / math.pi - phis3[i, j] = np.arctan(np.imag(u[1, 2]) / np.real(u[1, 2])) * 180 / math.pi - - alp = p1 * alp1 + p2 * alp2 + p3 * alp3 - psi = p1 * psi1 + p2 * psi2 + p3 * psi3 - tau = p1 * tau1 + p2 * tau2 + p3 * tau3 - phi = p1 * phis1 + p2 * phis2 + p3 * phis3 - - return [alp, psi, tau, phi] - - def get_result(self, saveFolder): - x = self.get_psi() - scattering_list = ['alpha', 'psi', 'tau', 'phi'] - for i in range(len(x)): - - cols, rows = x[0].shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'Touzi_New' - outfile += '.tif' - # 创建文件 - #if os.path.exists(os.path.split(outfile)) is False: - # os.makedirs(os.path.split(outfile)) - out_data = driver.Create(os.path.join(saveFolder,outfile) , rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band()[0].GetProjection()) - out_data.SetGeoTransform(self.get_band()[0].GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i]) - - def get_result_block(self, saveFolder, suffix): - x = self.get_psi() - scattering_list = ['alpha', 'psi', 'tau', 'phi'] - for i in range(len(x)): - - cols, rows = x[0].shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'Touzi_New' - outfile += suffix - # 创建文件 - #if os.path.exists(os.path.split(outfile)) is False: - # os.makedirs(os.path.split(outfile)) - out_data = driver.Create(os.path.join(saveFolder,outfile) , rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band()[0].GetProjection()) - out_data.SetGeoTransform(self.get_band()[0].GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i]) - -class Touzi(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - self.__band = b - self.__w = w - - def get_eig_value(self): - coh_mat = self.get_coh_mat_img() - - rows, cols = np.shape(coh_mat[0])[0], np.shape(coh_mat[0])[1] - - t11, t12, t13 = coh_mat[0], coh_mat[1], coh_mat[2] - t21, t22, t23 = coh_mat[3], coh_mat[4], coh_mat[5] - t31, t32, t33 = coh_mat[6], coh_mat[7], coh_mat[8] - - ev1 = np.zeros([rows, cols], dtype=complex) - ev2 = np.zeros([rows, cols], dtype=complex) - ev3 = np.zeros([rows, cols], dtype=complex) - - for i in range(rows): - for j in range(cols): - - x = np.array([ - [t11[i, j], t12[i, j], t13[i, j]], - [t21[i, j], t22[i, j], t23[i, j]], - [t31[i, j], t32[i, j], t33[i, j]] - ]) - - ev1[i, j] = abs(la.eig(x)[0][0]) - ev2[i, j] = abs(la.eig(x)[0][1]) - ev3[i, j] = abs(la.eig(x)[0][2]) - - if ev2[i, j] < ev3[i, j]: - ev2[i, j], ev3[i, j] = ev3[i, j], ev2[i, j] - - ev1[~np.isfinite(ev1)] = 0 - ev2[~np.isfinite(ev2)] = 0 - ev3[~np.isfinite(ev3)] = 0 - - trt = t11 + t22 + t33 - """ - det = t11 * t22 * t33 - t33 * t12 * np.conj(t12) - t22 * t13 * np.conj(t13) - det += t12 * np.conj(t13) * t23 + np.conj(t12) * t13 * np.conj(t23) - t11 * t23 * np.conj(t23) - det = abs(det) - - a = abs(t11 * t22 + t11 * t33 + t22 * t33 - t12 * np.conj(t12) - t13 * np.conj(t13) - t23 * np.conj(t23)) - - b = t11 * t11 - t11 * t22 + t22 * t22 - t11 * t33 - t22 * t33 + t33 * t33 - b = b + 3.0 * (t12 * np.conj(t12) + t13 * np.conj(t13) + t23 * np.conj(t23)) - - c = 27.0 * det - 9.0 * a * trt + 2.0 * (trt ** 3) - c = c + 0.0j - c = c + np.sqrt(c ** 2.0 - 4.0 * b ** 3.0) - c = c ** (1.0 / 3.0) - - trt = (1.0 / 3.0) * trt - - eig1 = trt + ((2 ** (1.0 / 3.0)) * b) / (3.0 * c) + c / (3.0 * 2 ** (1.0 / 3.0)) - eig2 = trt - complex(1, math.sqrt(3)) * b / (3 * 2 ** (2 / 3) * c) - complex( - 1, -math.sqrt(3)) * c / (6 * 2 ** (1 / 3)) - eig3 = trt - complex(1, -math.sqrt(3)) * b / (3 * 2 ** (2 / 3) * c) - complex( - 1, math.sqrt(3)) * c / (6 * 2 ** (1 / 3)) - - eig1, eig2, eig3 = abs(eig1), abs(eig2), abs(eig3) - - eig1[~np.isfinite(eig1)] = 0 - eig2[~np.isfinite(eig2)] = 0 - eig3[~np.isfinite(eig3)] = 0 - - x = eig2 >= eig3 - y = eig2 < eig3 - - ref_eig2 = x * eig2 + y * eig3 - ref_eig3 = x * eig3 + y * eig2 - - print(ref_eig2[200:205, 200:205], ref_eig3[200:205, 200:205]) - - trt = t11 + t22 + t33 - """ - - return [ev1, ev2, ev3, trt] - - def get_params(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Paper Details: "Target Scattering Decomposition in Terms of Roll-Invariant Target Parameters" - - IEEEXplore: https://ieeexplore.ieee.org/document/4039635 - - DOI: 10.1109/TGRS.2006.886176 - - With the projection of Kennaugh-Huynen scattering matrix into the Pauli basis, this model established - the basis invariant representation of coherent target scattering. - - U3 = [cos(alp1)*cos(2*taum1) cos(alp2)*cos(2*taum2) cos(alp3)*cos(2*taum3) - sin(alp1)*exp(j*phi1) sin(alp2)*exp(j*phi2) sin(alp3)*exp(j*phi3) - -j*cos(alp1)*sin(2*taum1) -j*cos(alp2)*sin(2*taum2) -j*cos(alp3)*sin(2*taum3)] - - T = U3 * [lambda1 0 0 * Transpose(conj(U3)) - 0 lambda2 0 - 0 0 lambda3] - - alp: for symmetric scattering type magnitude (normalized) - phi: for symmetric scattering type phase (normalized) - psi: orientation angle (Kennaugh-Huynen maximum polarization parameter (normalized) - tau: target helicity (normalized) - - Pseudo Probability = The pseudo probability is estimated by normalizing each eigen values with the - total summation of all the eigen values - - :return: It returns u11, u12, u13, u21, u22, u23 of U3 matrix and pseudo probabilities - - ** Note: In this implementation, orientation angle has been neglected. Please refer ModTouzi for the - orientation angle - """ - - coh_mat = self.get_coh_mat_img() - x = self.get_eig_value() - ev1, ev2, ev3 = x[0], x[1], x[2] - - t11, t12, t13 = coh_mat[0], coh_mat[1], coh_mat[2] - t21, t22, t23 = coh_mat[3], coh_mat[4], coh_mat[5] - t31, t32, t33 = coh_mat[6], coh_mat[7], coh_mat[8] - - t12c, t13c, t23c = np.conj(t12), np.conj(t13), np.conj(t23) - - u11 = (ev1 - t33) / t13c + ((ev1 - t33) * t12c + t13c * t23) * t23c / ( - ((t22 - ev1) * t13c - t12c * t23c) * t13c) - - u21 = ((ev1 - t33) * t12c + t13c * t23) / ((t22 - ev1) * t13c - t12c * t23c) - - nrm = np.sqrt(u11 * np.conj(u11) + u21 * np.conj(u21) + 1) - - u11 = u11 / nrm - u21 = u21 / nrm - - u11[~np.isfinite(u11)] = 0 - u21[~np.isfinite(u21)] = 0 - - u12 = (ev2 - t33) / t13c + ((ev2 - t33) * t12c + t13c * t23) * t23c / ( - ((t22 - ev2) * t13c - t12c * t23c) * t13c) - - u22 = ((ev2 - t33) * t12c + t13c * t23) / ((t22 - ev2) * t13c - t12c * t23c) - - nrm = np.sqrt(u12 * np.conj(u12) + u22 * np.conj(u22) + 1) - - u12 = u12 / nrm - u22 = u22 / nrm - - u12[~np.isfinite(u12)] = 0 - u22[~np.isfinite(u22)] = 0 - - u13 = (ev3 - t33) / t13c + ((ev3 - t33) * t12c + t13c * t23) * t23c / ( - ((t22 - ev3) * t13c - t12c * t23c) * t13c) - - u23 = ((ev3 - t33) * t12c + t13c * t23) / ((t22 - ev3) * t13c - t12c * t23c) - - nrm = np.sqrt(u13 * np.conj(u13) + u23 * np.conj(u23) + 1) - - u13 = u13 / nrm - u23 = u23 / nrm - - u13[~np.isfinite(u13)] = 0 - u23[~np.isfinite(u23)] = 0 - - trt = t11 + t22 + t33 - - p1 = ev1 / trt - p2 = ev2 / trt - p3 = ev3 / trt - - p1[~np.isfinite(p1)] = 0 - p2[~np.isfinite(p2)] = 0 - p3[~np.isfinite(p3)] = 0 - - return [u11, u12, u13, u21, u22, u23, p1, p2, p3] - - def get_alpha(self): - - """ - The alpha parameter is introduced as a symmetric scattering type magnitude - - tan(alpha) * exp(phi) = {(mu1 - mu2) / (mu1 + mu2)} - mu1, mu2 are coneignevalues - - :return: It returns the normalized alpha using the linear combination of pseudo probabilities and alpha - parameters (p1 * alpha1 + p2 * alpha2 + p3 * alpha3) - """ - - x = self.get_params() - u11, u12, u13 = x[0], x[1], x[2] - u21, u22, u23 = x[3], x[4], x[5] - p1, p2, p3 = x[6], x[7], x[8] - - alps1 = np.arcsin(abs(u21)) * 180 / math.pi - alps2 = np.arcsin(abs(u22)) * 180 / math.pi - alps3 = np.arcsin(abs(u23)) * 180 / math.pi - - alps1[~np.isfinite(alps1)] = 0 - alps2[~np.isfinite(alps2)] = 0 - alps3[~np.isfinite(alps3)] = 0 - - alps = p1 * alps1 + p2 * alps2 + p3 * alps3 - - return [u11, u12, u13, u21, u22, u23, p1, p2, p3, alps] - - def get_tau(self): - - """ - The tau parameter is defined as the target helicity. Under the assumption of target reciprocity, the Kennaugh- - Huynen condiagonalization is performed using: - - [S] = [R(psi)].[T(taum)].[Sd].[T(taum)].[R(-psi)] - - [R(psi)] = [cos(psi) - sin(psi) [T(taum)] = [cos(taum) -j * sin(taum) Sd = [mu1 0 - sin(psi) cos(psi)] -j * sin(taum) cos(taum)] 0 mu2] - - :return: It returns the normalized tau using the linear combination of pseudo probabilities and tau - parameters (p1 * tau1 + p2 * tau2 + p3 * tau3) - """ - - x = self.get_alpha() - u11, u12, u13 = x[0], x[1], x[2] - u21, u22, u23 = x[3], x[4], x[5] - p1, p2, p3 = x[6], x[7], x[8] - alps = x[9] - - taum1 = 0.5 * np.arccos(abs(u11 / (np.cos(u21 * math.pi / 180)))) * 180 / math.pi - taum2 = 0.5 * np.arccos(abs(u12 / (np.cos(u22 * math.pi / 180)))) * 180 / math.pi - taum3 = 0.5 * np.arccos(abs(u13 / (np.cos(u23 * math.pi / 180)))) * 180 / math.pi - - taum1[~np.isfinite(taum1)] = 0 - taum2[~np.isfinite(taum2)] = 0 - taum3[~np.isfinite(taum3)] = 0 - - taum = p1 * taum1 + p2 * taum2 + p3 * taum3 - - return [u11, u12, u13, u21, u22, u23, p1, p2, p3, alps, taum] - - def get_phi(self): - - """ - The parameter phi is the phase difference between the vector components in the trihedral-dihedral basis - - :return: It returns the normalized phi using the linear combination of pseudo probabilities and phi - parameters (p1 * tau1 + p2 * tau2 + p3 * tau3) - """ - - x = self.get_tau() - # u11, u12, u13 = x[0], x[1], x[2] - u21, u22, u23 = x[3], x[4], x[5] - p1, p2, p3 = x[6], x[7], x[8] - alps, taum = x[9], x[10] - - phis1 = np.arctan(np.imag(u21) / np.real(u21)) * 180 / math.pi - phis2 = np.arctan(np.imag(u22) / np.real(u22)) * 180 / math.pi - phis3 = np.arctan(np.imag(u23) / np.real(u23)) * 180 / math.pi - - phis = p1 * phis1 + p2 * phis2 + p3 * phis3 - - return [alps, taum, phis] - - def get_result(self): - x = self.get_phi() - - scattering_list = ['alpha', 'tau', 'phi'] - - for i in range(len(x)): - - cols, rows = x[0].shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'Touzi' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i]) - - -class HAAlpha(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - self.__band = b - self.__w = w - - def get_eigen_value(self): - - coh_mat = self.get_coh_mat_img() - - rows, cols = np.shape(coh_mat[0])[0], np.shape(coh_mat[0])[1] - - t11, t12, t13 = coh_mat[0], coh_mat[1], coh_mat[2] - t21, t22, t23 = coh_mat[3], coh_mat[4], coh_mat[5] - t31, t32, t33 = coh_mat[6], coh_mat[7], coh_mat[8] - - ev1 = np.zeros([rows, cols], dtype=complex) - ev2 = np.zeros([rows, cols], dtype=complex) - ev3 = np.zeros([rows, cols], dtype=complex) - - for i in range(rows): - for j in range(cols): - - x = np.array([ - [t11[i, j], t12[i, j], t13[i, j]], - [t21[i, j], t22[i, j], t23[i, j]], - [t31[i, j], t32[i, j], t33[i, j]] - ]) - - ev1[i, j] = abs(la.eig(x)[0][0]) - ev2[i, j] = abs(la.eig(x)[0][1]) - ev3[i, j] = abs(la.eig(x)[0][2]) - - if ev2[i, j] < ev3[i, j]: - ev2[i, j], ev3[i, j] = ev3[i, j], ev2[i, j] - - ev1[~np.isfinite(ev1)] = 0 - ev2[~np.isfinite(ev2)] = 0 - ev3[~np.isfinite(ev3)] = 0 - - trt = t11 + t22 + t33 - """ - det = t11 * t22 * t33 - t33 * t12 * np.conj(t12) - t22 * t13 * np.conj(t13) - det += t12 * np.conj(t13) * t23 + np.conj(t12) * t13 * np.conj(t23) - t11 * t23 * np.conj(t23) - det = abs(det) - - a = abs(t11 * t22 + t11 * t33 + t22 * t33 - t12 * np.conj(t12) - t13 * np.conj(t13) - t23 * np.conj(t23)) - - b = t11 * t11 - t11 * t22 + t22 * t22 - t11 * t33 - t22 * t33 + t33 * t33 - b = b + 3.0 * (t12 * np.conj(t12) + t13 * np.conj(t13) + t23 * np.conj(t23)) - - c = 27.0 * det - 9.0 * a * trt + 2.0 * (trt ** 3) - c = c + 0.0j - c = c + np.sqrt(c ** 2.0 - 4.0 * b ** 3.0) - c = c ** (1.0 / 3.0) - - trt = (1.0 / 3.0) * trt - - eig1 = trt + ((2 ** (1.0 / 3.0)) * b) / (3.0 * c) + c / (3.0 * 2 ** (1.0 / 3.0)) - eig2 = trt - complex(1, math.sqrt(3)) * b / (3 * 2 ** (2 / 3) * c) - complex( - 1, -math.sqrt(3)) * c / (6 * 2 ** (1 / 3)) - eig3 = trt - complex(1, -math.sqrt(3)) * b / (3 * 2 ** (2 / 3) * c) - complex( - 1, math.sqrt(3)) * c / (6 * 2 ** (1 / 3)) - - eig1, eig2, eig3 = abs(eig1), abs(eig2), abs(eig3) - - eig1[~np.isfinite(eig1)] = 0 - eig2[~np.isfinite(eig2)] = 0 - eig3[~np.isfinite(eig3)] = 0 - - x = eig2 >= eig3 - y = eig2 < eig3 - - ref_eig2 = x * eig2 + y * eig3 - ref_eig3 = x * eig3 + y * eig2 - - print(ref_eig2[200:205, 200:205], ref_eig3[200:205, 200:205]) - - trt = t11 + t22 + t33 - """ - - return [ev1, ev2, ev3, trt] - - def get_entropy(self): - - """ - The scattering entropy is associated with the degree of randomness under the assumption of reflection symmetric - media. The entropy is calculated using the eigen values and pseudo probabilities as follows: - - H = - (p1 * log3(p1) + p2 * log3(p2) + p3 * log3(p3)) - - The pseudo probabilities are estimated as - - p1 = lambda1 / (lambda1 + lambda2 + lambda3) - p2 = lambda2 / (lambda1 + lambda2 + lambda3) - p3 = lambda3 / (lambda1 + lambda2 + lambda3) - - :return: It returns primarily the entropy along with three eigen values extracted from the 3 * 3 coherency - matrices - """ - - x = self.get_eigen_value() - ev1, ev2, ev3, trt = x[0], x[1], x[2], x[3] - - p1 = ev1 / trt - p2 = ev2 / trt - p3 = ev3 / trt - - ent = - (p1 * (np.log(p1) / np.log(3)) + p2 * (np.log(p2) / np.log(3)) + p3 * (np.log(p3) / np.log(3))) - ent[~np.isfinite(ent)] = 0 - - return [ent, ev1, ev2, ev3] - - def get_anisotropy(self): - - """ - The anisotropy is the measure of the amount of the forward direction retained after a single scattering event - - :return:It returns majorly the anisotropy - """ - - x = self.get_entropy() - ent = x[0] - ev1, ev2, ev3 = x[1], x[2], x[3] - - ani = abs((ev2 - ev3) / (ev2 + ev3)) - - ani[~np.isfinite(ani)] = 0 - - return [ani, ev1, ev2, ev3, ent] - - def get_alpha(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Paper Details: "An entropy based classification scheme for land applications of polarimetric SAR" - - IEEEXplore: https://ieeexplore.ieee.org/document/551935 - - DOI: 10.1109/36.551935 - - This method employs the eigen value analysis of coherency matrix by employing 3-level Bernoulli - statistical model to estimate the average target scattering parameters. - - U3 = [cos(alp1) cos(alp2) cos(alp3) - sin(alp1)*cos(beta1)*exp(j*del1) sin(alp1)*cos(beta1)*exp(j*del2) sin(alp1)*cos(beta3)*exp(j*del3) - sin(alp1)*sin(beta1)*exp(j*gama1) sin(alp2)*cos(beta2)*exp(j*gama2) sin(alp3)*sin(beta3)*exp(j*gama3)] - - T = U3 * [lambda1 0 0 * Transpose(conj(U3)) - 0 lambda2 0 - 0 0 lambda3] - - Pseudo Probability = The pseudo probability is estimated by normalizing each eigen values with the - total summation of all the eigen values - - :return: It returns the alpha parameter along with entropy and anisotropy - """ - - coh_mat = self.get_coh_mat_img() - x = self.get_anisotropy() - ev1, ev2, ev3 = x[1], x[2], x[3] - ent, ani = x[4], x[0] - - t11, t12, t13 = coh_mat[0], coh_mat[1], coh_mat[2] - t21, t22, t23 = coh_mat[3], coh_mat[4], coh_mat[5] - t31, t32, t33 = coh_mat[6], coh_mat[7], coh_mat[8] - - t12c, t13c, t23c = np.conj(t12), np.conj(t13), np.conj(t23) - - u11 = (ev1 - t33) / t13c + ((ev1 - t33) * t12c + t13c * t23) * t23c / ( - ((t22 - ev1) * t13c - t12c * t23c) * t13c) - - u21 = ((ev1 - t33) * t12c + t13c * t23) / ((t22 - ev1) * t13c - t12c * t23c) - - nrm = np.sqrt(u11 * np.conj(u11) + u21 * np.conj(u21) + 1) - - u11 = u11 / nrm - u21 = u21 / nrm - - u11[~np.isfinite(u11)] = 0 - u21[~np.isfinite(u21)] = 0 - - u12 = (ev2 - t33) / t13c + ((ev2 - t33) * t12c + t13c * t23) * t23c / ( - ((t22 - ev2) * t13c - t12c * t23c) * t13c) - - u22 = ((ev2 - t33) * t12c + t13c * t23) / ((t22 - ev2) * t13c - t12c * t23c) - - nrm = np.sqrt(u12 * np.conj(u12) + u22 * np.conj(u22) + 1) - - u12 = u12 / nrm - u22 = u22 / nrm - - u12[~np.isfinite(u12)] = 0 - u22[~np.isfinite(u22)] = 0 - - u13 = (ev3 - t33) / t13c + ((ev3 - t33) * t12c + t13c * t23) * t23c / ( - ((t22 - ev3) * t13c - t12c * t23c) * t13c) - - u23 = ((ev3 - t33) * t12c + t13c * t23) / ((t22 - ev3) * t13c - t12c * t23c) - - nrm = np.sqrt(u13 * np.conj(u13) + u23 * np.conj(u23) + 1) - - u13 = u13 / nrm - u23 = u23 / nrm - - u13[~np.isfinite(u13)] = 0 - u23[~np.isfinite(u23)] = 0 - - trt = t11 + t22 + t33 - - p1 = ev1 / trt - p2 = ev2 / trt - p3 = ev3 / trt - - p1[~np.isfinite(p1)] = 0 - p2[~np.isfinite(p2)] = 0 - p3[~np.isfinite(p3)] = 0 - - alp1 = np.arccos(abs(u11)) * 180 / math.pi - alp2 = np.arccos(abs(u12)) * 180 / math.pi - alp3 = np.arccos(abs(u13)) * 180 / math.pi - - alp1[~np.isfinite(alp1)] = 0 - alp2[~np.isfinite(alp2)] = 0 - alp3[~np.isfinite(alp3)] = 0 - - alp = p1 * alp1 + p2 * alp2 + p3 * alp3 - - return [ent, ani, alp] - - def get_result(self): - x = self.get_alpha() - ent, ani, alp = x[0], x[1], x[2] - - scattering_list = ['entropy', 'anisotropy', 'alpha'] - - for i in range(len(x)): - - cols, rows = ent.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'Cloude_Pottier' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i]) - - -class Sinclair(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - self.__band = b - self.__w = w - self.__band_list = list() - self.__band_list_avg = list() - - for i in range(self.__band.RasterCount): - self.__band_list.append(self.__band.GetRasterBand(i).ReadAsArray().astype(float)) - - for i in range(len(self.__band_list)): - self.__band_list_avg.append(cv2.blur(self.__band_list[i], (5, 5))) - - """ - The private variables are consisting of the fully polarimetric channels. As for a fully polarimetric - synthetic aperture radar system, there are four components according to the Sinclair matrix. - - :param s_hh: represents the horizontal-horizontal channel - :param s_hh_conj: represents the conjugate of horizontal-horizontal channel - :param s_hv: represents the horizontal-vertical channel - :param s_hv_conj: represents the conjugate of horizontal-horizontal channel - :param s_vh: represents the vertical-horizontal channel - :param s_vh_conj: represents the conjugate of horizontal-horizontal channel - :param s_vv: represents the vertical-vertical channel - :param s_vv_conj: represents the conjugate of horizontal-horizontal channel - :param b: represents the object of bands - """ - - self.__S_hh = self.__band_list_avg[0] + 1j * self.__band_list_avg[1] - self.__S_hh_conj = self.__band_list_avg[0] - 1j * self.__band_list_avg[1] - self.__S_hv = self.__band_list_avg[2] + 1j * self.__band_list_avg[3] - self.__S_hv_conj = self.__band_list_avg[2] - 1j * self.__band_list_avg[3] - self.__S_vh = self.__band_list_avg[4] + 1j * self.__band_list_avg[5] - self.__S_vh_conj = self.__band_list_avg[4] - 1j * self.__band_list_avg[5] - self.__S_vv = self.__band_list_avg[6] + 1j * self.__band_list_avg[7] - self.__S_vv_conj = self.__band_list_avg[6] - 1j * self.__band_list_avg[7] - - def get_decomposition(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Book: Polarimetric Radar Imaging: From basics to applications - - General form of Sinclair matrix - [S] = [S11 S12 - S21 S22] - - :return: It returns the three intensity parameters based on Sinclair Matrix - """ - intensity1 = abs(self.__S_vv * self.__S_vv_conj) - intensity2 = 0.25 * abs((self.__S_hv + self.__S_vh) * (self.__S_hv_conj + self.__S_vh_conj)) - intensity3 = abs(self.__S_hh * self.__S_hh_conj) - - return [10 * np.log10(abs(intensity1)), 10 * np.log10(abs(intensity2)), 10 * np.log10(abs(intensity3))] - - def get_result(self): - x = self.get_decomposition() - intensity1, intensity2, intensity3 = x[0], x[1], x[2] - - scattering_list = ['intensity1', 'intensity2', 'intensity3'] - - for i in range(len(x)): - - cols, rows = intensity1.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'Sinclair' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i] / (intensity1 + intensity2 + intensity3)) - - -class Cloude(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - self.__band = b - self.__w = w - self.__band_list = list() - self.__band_list_avg = list() - - for i in range(self.__band.RasterCount): - self.__band_list.append(self.__band.GetRasterBand(i).ReadAsArray().astype(float)) - - for i in range(len(self.__band_list)): - self.__band_list_avg.append(cv2.blur(self.__band_list[i], (5, 5))) - - """ - The private variables are consisting of the fully polarimetric channels. As for a fully polarimetric - synthetic aperture radar system, there are four components according to the Sinclair matrix. - - :param s_hh: represents the horizontal-horizontal channel - :param s_hh_conj: represents the conjugate of horizontal-horizontal channel - :param s_hv: represents the horizontal-vertical channel - :param s_hv_conj: represents the conjugate of horizontal-horizontal channel - :param s_vh: represents the vertical-horizontal channel - :param s_vh_conj: represents the conjugate of horizontal-horizontal channel - :param s_vv: represents the vertical-vertical channel - :param s_vv_conj: represents the conjugate of horizontal-horizontal channel - :param b: represents the object of bands - """ - - self.__S_hh = self.__band_list_avg[0] + 1j * self.__band_list_avg[1] - self.__S_hh_conj = self.__band_list_avg[0] - 1j * self.__band_list_avg[1] - self.__S_hv = self.__band_list_avg[2] + 1j * self.__band_list_avg[3] - self.__S_hv_conj = self.__band_list_avg[2] - 1j * self.__band_list_avg[3] - self.__S_vh = self.__band_list_avg[4] + 1j * self.__band_list_avg[5] - self.__S_vh_conj = self.__band_list_avg[4] - 1j * self.__band_list_avg[5] - self.__S_vv = self.__band_list_avg[6] + 1j * self.__band_list_avg[7] - self.__S_vv_conj = self.__band_list_avg[6] - 1j * self.__band_list_avg[7] - - def get_decomposition(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Book: Polarimetric Radar Imaging: From basics to applications - - Cloude introduced the concept of eigen-vector based decomposition which utilized teh largest eigen-value to - identify the dominant scattering mechanism - - The corresponding target vector can thus be expressed as - - k1 = sqrt(Lambda1) * u1 = exp(j*phi) / sqrt(2*A0) transpose([2*A0 C + j*D H - j*G]) - - k1 = exp(j*phi) * transpose([sqrt(2*A0) sqrt(B0 + B)*exp(j*arctan(D/C)) sqrt(B0 - B)*exp(j*arctan(G/H))]) - - The three target structure generators are in one-to-one correspondence between Kennaugh Matrix and coherency - matrix (T): - - T = [2A0 C - J*D H + J*G - C + J*D B0 + B E + J*F - H - J*G E - J*F B0 - B] - - A0 => target symmetry, (B0 + B) => target irregularity, (B0 - B) => target nonsymmetry - - :return: It returns the three parameters representing the surface scattering, dihedral-scattering and volume - scattering - """ - - ps = 0.5 * abs((self.__S_hh + self.__S_vv) * (self.__S_hh_conj + self.__S_vv_conj)) - pd = 0.5 * abs((self.__S_hh - self.__S_vv) * (self.__S_hh_conj - self.__S_vv_conj)) - pv = 0.5 * abs((self.__S_hv + self.__S_vh) * (self.__S_hv_conj + self.__S_vh_conj)) - - return [10 * np.log10(abs(ps)), 10 * np.log10(abs(pd)), 10 * np.log10(abs(pv))] - - def get_result(self): - x = self.get_decomposition() - intensity1, intensity2, intensity3 = x[0], x[1], x[2] - - scattering_list = ['surface', 'double_bounce', 'volume'] - - for i in range(len(x)): - - cols, rows = intensity1.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'Cloude' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i] / (intensity1 + intensity2 + intensity3)) - - -class Pauli(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - self.__band = b - self.__w = w - self.__band_list = list() - self.__band_list_avg = list() - - for i in range(self.__band.RasterCount): - self.__band_list.append(self.__band.GetRasterBand(i).ReadAsArray().astype(float)) - - for i in range(len(self.__band_list)): - self.__band_list_avg.append(cv2.blur(self.__band_list[i], (5, 5))) - - """ - The private variables are consisting of the fully polarimetric channels. As for a fully polarimetric - synthetic aperture radar system, there are four components according to the Sinclair matrix. - - :param s_hh: represents the horizontal-horizontal channel - :param s_hh_conj: represents the conjugate of horizontal-horizontal channel - :param s_hv: represents the horizontal-vertical channel - :param s_hv_conj: represents the conjugate of horizontal-horizontal channel - :param s_vh: represents the vertical-horizontal channel - :param s_vh_conj: represents the conjugate of horizontal-horizontal channel - :param s_vv: represents the vertical-vertical channel - :param s_vv_conj: represents the conjugate of horizontal-horizontal channel - :param b: represents the object of bands - """ - - self.__S_hh = self.__band_list_avg[0] + 1j * self.__band_list_avg[1] - self.__S_hh_conj = self.__band_list_avg[0] - 1j * self.__band_list_avg[1] - self.__S_hv = self.__band_list_avg[2] + 1j * self.__band_list_avg[3] - self.__S_hv_conj = self.__band_list_avg[2] - 1j * self.__band_list_avg[3] - self.__S_vh = self.__band_list_avg[4] + 1j * self.__band_list_avg[5] - self.__S_vh_conj = self.__band_list_avg[4] - 1j * self.__band_list_avg[5] - self.__S_vv = self.__band_list_avg[6] + 1j * self.__band_list_avg[7] - self.__S_vv_conj = self.__band_list_avg[6] - 1j * self.__band_list_avg[7] - - def get_decomposition(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Book: Polarimetric Radar Imaging: From basics to applications - - The coherent target decompositions express the measured scattering matrix as a combinations of basis - matrices corresponding to canonical scattering mechanisms - - The Pauli decomposition is the basis of the coherency matrix formulation. - - S = [Sxx Sxy The target vector is constructed as k = V(S) = 0.5 * Trace(S * Psi) - Syx Syy] - - The complex Pauli Spin matrix basis set is represented as - - Psi = { sqrt(2) * [1 0 sqrt(2) * [1 0 sqrt(2) * [0 1 } - 0 1] 0 -1] 1 0] - - So the resulting target vector will be => sqrt(2) * transpose[(Sxx + Syy) (Sxx - Syy) 2*Sxy] - - :return: - """ - - intensity1 = 0.5 * abs((self.__S_hh - self.__S_vv) * (self.__S_hh_conj - self.__S_vv_conj)) - intensity2 = 0.5 * abs((self.__S_hv + self.__S_vh) * (self.__S_hv_conj + self.__S_vh_conj)) - intensity3 = 0.5 * abs((self.__S_hh + self.__S_vv) * (self.__S_hh_conj + self.__S_vv_conj)) - - return [10 * np.log10(abs(intensity1)), 10 * np.log10(abs(intensity2)), 10 * np.log10(abs(intensity3))] - - def get_result(self): - x = self.get_decomposition() - intensity1, intensity2, intensity3 = x[0], x[1], x[2] - - scattering_list = ['intensity1', 'intensity2', 'intensity3'] - - for i in range(len(x)): - - cols, rows = intensity1.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'Sinclair' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i] / (intensity1 + intensity2 + intensity3)) - - -class Vanzyl(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - def get_coef(self): - cov_mat = self.get_cov_mat_img() - alpha = cov_mat[0] - rho = cov_mat[2] / alpha - eta = cov_mat[4] / alpha - mu = cov_mat[8] / alpha - - return [alpha, rho, eta, mu] - - def get_eigen_values(self): - coef = self.get_coef() - alpha, rho, eta, mu = coef[0], coef[1], coef[2], coef[3] - - del1 = ((1 - mu) ** 2) + 4 * abs(rho * np.conj(rho)) - lambda1 = (alpha / 2) * (1 + mu + del1 ** 0.5) - lambda2 = (alpha / 2) * (1 + mu - del1 ** 0.5) - lambda3 = alpha * eta - - return [lambda1, lambda2, lambda3, coef, del1] - - def get_decomposition(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Paper Details: "Application of Cloude's target decomposition theorem to polarimetric imaging radar data" - - SemanticScholar: https://www.semanticscholar.org/paper - /Application-of-Cloude's-target-decomposition-to-Zyl/bad4b80ea872e5c00798c089f76b8fa7390fed34 - - DOI: 10.1117/12.140615 - - In this paper the Cloude's decomposition has been incorporated using general description of the - covariance matrix for azimuthally symmetrical natural terrain in the monostatic case - - T = C * [1 0 rho - 0 eta 0 C = rho = / C - rho* 0 zeta] eta = 2 / C zeta = / C - - The correspoding eigen-values and eigen-vector can be extracted from T - - :return: It returns ps, pd, and pv which are associated with fs, fd, and fv - """ - - eigen_values = self.get_eigen_values() - lambda1, lambda2, lambda3, coef = eigen_values[0], eigen_values[1], eigen_values[2], eigen_values[3] - del1 = eigen_values[4] - alpha, rho, eta, mu = coef[0], coef[1], coef[2], coef[3] - - alpha1 = (2 * rho) / (mu - 1 + del1 ** 0.5) - beta1 = (2 * rho) / (mu - 1 - del1 ** 0.5) - - intensity1 = lambda1 / (1 + abs(alpha1 * np.conj(alpha1))) - intensity2 = lambda2 / (1 + abs(beta1 * np.conj(beta1))) - intensity3 = lambda3 - - return [10 * np.log10(abs(intensity1)), 10 * np.log10(abs(intensity2)), 10 * np.log10(abs(intensity3))] - - def get_result(self): - x = self.get_decomposition() - ps, pd, pv = x[0], x[1], x[2] - - scattering_list = ['intensity1', 'intensity2', 'intensity3'] - - for i in range(len(x)): - - cols, rows = ps.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'Vanzyl' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i]) - - -class FreeMan(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - def get_decomposition(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Paper Details: "A three-component scattering model for polarimetric SAR data" - - IEEEXplore: https://ieeexplore.ieee.org/document/673687 - - DOI: 10.1109/36.673687 - - The coefficients (fs, fv, fd) represents the scattering contributions to the corresponding - channels associated with the scattering matrix. - - fs: for surface scattering - fd: for double-bounce scattering - fv: for volume scattering - - alpha: associated with the double-bounce scattering - beta: associated with the surface scattering (First order Bragg model with second order - statistics - - ps: scattered power return associated with surface scattering - pd: scattered power return associated with double-bounce scattering - pv: scattered power return associated with volume scattering - - :return: It returns ps, pd, and pv which are associated with fs, fd, and fv - """ - - cov_mat = self.get_cov_mat_img() - fv = 3 * cov_mat[4] - s_hh = cov_mat[0] - fv - s_vv = cov_mat[8] - fv - s_hh_vv_conj = cov_mat[2] - fv / 3 - rows, cols = np.shape(cov_mat[0])[0], np.shape(cov_mat[0])[1] - ps, pd = np.zeros([rows, cols]), np.zeros([rows, cols]) - pv = (8 * fv) / 3 - - for i in range(np.shape(s_hh)[0]): - for j in range(np.shape(s_hh)[1]): - if s_hh_vv_conj[i, j].real > 0: - alpha = -1 - beta = ((s_hh[i, j] - s_vv[i, j]) / (s_hh_vv_conj[i, j] + s_vv[i, j])) + 1 - fs = (s_vv[i, j] + s_hh_vv_conj[i, j]) / (1 + beta) - fd = s_vv[i, j] - fs - else: - beta = 1 - alpha = ((s_hh[i, j] - s_vv[i, j]) / (s_hh_vv_conj[i, j] - s_vv[i, j])) - 1 - fd = (s_hh_vv_conj[i, j] - s_vv[i, j]) / (alpha - 1) - fs = s_vv[i, j] - fd - - ps[i, j] = (abs(fs) ** 2) * (1 + abs(beta) ** 2) - pd[i, j] = (abs(fd) ** 2) * (1 + abs(alpha) ** 2) - - return [10 * np.log10(abs(ps)), 10 * np.log10(abs(pd)), 10 * np.log10(abs(pv))] - - def get_result(self): - x = self.get_decomposition() - ps, pd, pv = x[0], x[1], x[2] - - scattering_list = ['ps', 'pd', 'pv'] - - for i in range(len(x)): - - cols, rows = ps.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'FreeMan_3SD' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i]) - - -class Yamaguchi2005(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - def get_decomposition(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Paper Details: "Four-component scattering model for polarimetric SAR image decomposition" - - link: https://ieeexplore.ieee.org/document/1487628 - - DOI: 10.1109/TGRS.2005.852084 - - The coefficients (fs, fv, fd, fc) represents the scattering contributions to the corresponding - channels associated with the scattering matrix. - - <[C]> = fs * <[Cs]> + fd * <[Cd]> + fv * <[Cv]> + fc * <[Cc]> - - fs: for surface scattering - fd: for double-bounce scattering - fv: for volume scattering - fc: for helix scattering - - alpha: associated with the double-bounce scattering - beta: associated with the surface scattering (First order Bragg model with second order - statistics - - ps: scattered power return associated with surface scattering - pd: scattered power return associated with double-bounce scattering - pv: scattered power return associated with volume scattering - pc: scattered power return associated with helix scattering - - :return: It returns ps, pd, pv, and pc which are associated with fs, fd, fv, and fc - """ - - cov_mat = self.get_cov_mat_img() - rows, cols = np.shape(cov_mat[0])[0], np.shape(cov_mat[0])[1] - - fc = 2 * abs(np.imag((cov_mat[1] + cov_mat[5]) / np.sqrt(2))) - fv = np.zeros([rows, cols]) - ps = np.zeros([rows, cols]) - pd = np.zeros([rows, cols]) - - for i in range(rows): - for j in range(cols): - - if cov_mat[8][i, j] <= 0 or cov_mat[0][i, j] <= 0: - cov_mat[8][i, j], cov_mat[0][i, j] = 1.0, 1.0 - - if 10 * math.log10(cov_mat[8][i, j] / cov_mat[0][i, j]) < -2: - - fv[i, j] = 7.5 * (0.5 * cov_mat[4][i, j] - 0.25 * fc[i, j]) - a = cov_mat[0][i, j] - (8 / 15) * fv[i, j] - 0.25 * fc[i, j] - b = cov_mat[8][i, j] - (3 / 15) * fv[i, j] - 0.25 * fc[i, j] - c = cov_mat[2][i, j] - (2 / 15) * fv[i, j] + 0.25 * fc[i, j] - - if cov_mat[4][i, j] < cov_mat[0][i, j] or cov_mat[4][i, j] < cov_mat[8][i, j]: - - if np.real(cov_mat[2][i, j]) > 0: - alpha = -1 - beta = (a + c) / (b + c) - fs = (a - b) / (abs(beta * np.conj(beta)) - 1) - fd = b - fs - - else: - beta = 1 - alpha = (a - b) / (c - b) - fd = (a - b) / (abs(alpha * np.conj(alpha)) - 1) - fs = b - fd - - else: - fv[i, j], fc[i, j] = 0, 0 - a, b, c = cov_mat[0][i, j], cov_mat[8][i, j], cov_mat[2][i, j] - - if np.real(cov_mat[2][i, j]) > 0: - alpha = -1 - beta = (a + c) / (b + c) - fs = (a - b) / (abs(beta * np.conj(beta)) - 1) - fd = b - fs - - else: - beta = 1 - alpha = (a - b) / (c - b) - fd = (a - b) / (abs(alpha * np.conj(alpha)) - 1) - fs = b - fd - - elif 10 * math.log10(cov_mat[8][i, j] / cov_mat[0][i, j]) > 2: - - fv[i, j] = 7.5 * (0.5 * cov_mat[4][i, j] - 0.25 * fc[i, j]) - a = cov_mat[0][i, j] - (3 / 15) * fv[i, j] - 0.25 * fc[i, j] - b = cov_mat[8][i, j] - (8 / 15) * fv[i, j] - 0.25 * fc[i, j] - c = cov_mat[2][i, j] - (2 / 15) * fv[i, j] + 0.25 * fc[i, j] - - if cov_mat[4][i, j] < cov_mat[0][i, j] or cov_mat[4][i, j] < cov_mat[8][i, j]: - - if np.real(cov_mat[2][i, j]) > 0: - alpha = -1 - beta = (a + c) / (b + c) - fs = (a - b) / (abs(beta * np.conj(beta)) - 1) - fd = b - fs - - else: - beta = 1 - alpha = (a - b) / (c - b) - fd = (a - b) / (abs(alpha * np.conj(alpha)) - 1) - fs = b - fd - - else: - fv[i, j], fc[i, j] = 0, 0 - a, b, c = cov_mat[0][i, j], cov_mat[8][i, j], cov_mat[2][i, j] - - if np.real(cov_mat[2][i, j]) > 0: - alpha = -1 - beta = (a + c) / (b + c) - fs = (a - b) / (abs(beta * np.conj(beta)) - 1) - fd = b - fs - - else: - beta = 1 - alpha = (a - b) / (c - b) - fd = (a - b) / (abs(alpha * np.conj(alpha)) - 1) - fs = b - fd - - else: - fv[i, j] = 8 * (0.5 * cov_mat[4][i, j] - 0.25 * fc[i, j]) - a = cov_mat[0][i, j] - (3 / 8) * fv[i, j] - 0.25 * fc[i, j] - b = cov_mat[8][i, j] - (3 / 8) * fv[i, j] - 0.25 * fc[i, j] - c = cov_mat[2][i, j] - (1 / 8) * fv[i, j] + 0.25 * fc[i, j] - - if cov_mat[4][i, j] < cov_mat[0][i, j] or cov_mat[4][i, j] < cov_mat[8][i, j]: - - if np.real(cov_mat[2][i, j]) > 0: - alpha = -1 - beta = (a + c) / (b + c) - fs = (a - b) / (abs(beta * np.conj(beta)) - 1) - fd = b - fs - - else: - beta = 1 - alpha = (a - b) / (c - b) - fd = (a - b) / (abs(alpha * np.conj(alpha)) - 1) - fs = b - fd - - else: - fv[i, j], fc[i, j] = 0, 0 - a, b, c = cov_mat[0][i, j], cov_mat[8][i, j], cov_mat[2][i, j] - - if np.real(cov_mat[2][i, j]) > 0: - alpha = -1 - beta = (a + c) / (b + c) - fs = (a - b) / (abs(beta * np.conj(beta)) - 1) - fd = b - fs - - else: - beta = 1 - alpha = (a - b) / (c - b) - fd = (a - b) / (abs(alpha * np.conj(alpha)) - 1) - fs = b - fd - - ps[i, j] = fs * (1 + abs(beta * np.conj(beta))) - pd[i, j] = fd * (1 + abs(alpha * np.conj(alpha))) - - return [10 * np.log10(abs(ps)), 10 * np.log10(abs(pd)), - 10 * np.log10(abs(fv)), 10 * np.log10(abs(fc))] - - def get_result(self): - x = self.get_decomposition() - ps, pd, pv, pc = x[0], x[1], x[2], x[3] - - scattering_list = ['ps', 'pd', 'pv', 'pc'] - - for i in range(len(x)): - - cols, rows = ps.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'Yamaguchi2005_4SD' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i]) - - -class Yamaguchi2011(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - def get_scattering_power(self): - - cov_mat = self.get_cov_mat_img() - rot_coh_mat = self.rot_coh_mat_img() - rows, cols = np.shape(cov_mat[0])[0], np.shape(cov_mat[0])[1] - - pc = 2 * abs(np.imag(rot_coh_mat[5])) - pv = np.zeros([rows, cols]) - s = np.zeros([rows, cols]) - d = np.zeros([rows, cols]) - c = np.zeros([rows, cols], dtype=complex) - - for i in range(rows): - for j in range(cols): - - if cov_mat[8][i, j] <= 0 or cov_mat[0][i, j] <= 0: - cov_mat[8][i, j], cov_mat[0][i, j] = 1.0, 1.0 - - if 10 * math.log10(cov_mat[8][i, j] / cov_mat[0][i, j]) < -2: - - pv[i, j] = (15 / 4) * rot_coh_mat[8][i, j] - (15 / 8) * pc[i, j] - - if pv[i, j] < 0: - pc[i, j] = 0 - - pv[i, j] = (15 / 4) * rot_coh_mat[8][i, j] - (15 / 18) * pc[i, j] - s[i, j] = rot_coh_mat[0][i, j] - 0.5 * pv[i, j] - d[i, j] = rot_coh_mat[4][i, j] - (7 / 30) * pv[i, j] - 0.5 * pc[i, j] - c[i, j] = rot_coh_mat[1][i, j] - (1 / 6) * pv[i, j] - - elif 10 * math.log10(cov_mat[8][i, j] / cov_mat[0][i, j]) > 2: - - pv[i, j] = (15 / 4) * rot_coh_mat[8][i, j] - (15 / 8) * pc[i, j] - - if pv[i, j] < 0: - pc[i, j] = 0 - - pv[i, j] = (15 / 4) * rot_coh_mat[8][i, j] - (15 / 8) * pc[i, j] - s[i, j] = rot_coh_mat[0][i, j] - 0.5 * pv[i, j] - d[i, j] = rot_coh_mat[4][i, j] - (7 / 30) * pv[i, j] - c[i, j] = rot_coh_mat[1][i, j] + (1 / 6) * pv[i, j] - - else: - pv[i, j] = 4 * rot_coh_mat[8][i, j] - 2 * pc[i, j] - - if pv[i, j] < 0: - pc[i, j] = 0 - - pv[i, j] = 4 * rot_coh_mat[8][i, j] - 2 * pc[i, j] - s[i, j] = rot_coh_mat[0][i, j] - 0.5 * pv[i, j] - d[i, j] = rot_coh_mat[4][i, j] - rot_coh_mat[8][i, j] - c[i, j] = rot_coh_mat[1][i, j] - - return [pc, pv, s, d, c, rot_coh_mat] - - def get_decomposition(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Paper Details: "Four-Component Scattering Power Decomposition With Rotation of Coherency Matrix" - - IEEEXplore: https://ieeexplore.ieee.org/document/5710415?arnumber=5710415 - - DOI: 10.1109/TGRS.2010.2099124 - - In this paper, the rotation of the coherency matrix is utilized to minimized the cross-polarized - component. As the oriented urban structures and vegetation structures are decomposed into the same - scattering mechanism. - - fs: for surface scattering - fd: for double-bounce scattering - fv: for volume scattering - fc: for helix scattering - - <[T]> = fs * <[Ts]> + fd * <[Td]> + fv * <[Tv]> + fc * <[Tc]> - - <[T(theta)]> = R(theta) * <[T]> * transpose(conj(R(theta)) - - R(theta) = [1 0 0 - 0 cos(2*theta) -sin(2*theta) - 0 sin(2*theta) cos(2*theta)] - - ps: scattered power return associated with surface scattering - pd: scattered power return associated with double-bounce scattering - pv: scattered power return associated with volume scattering - pc: scattered power return associated with helix scattering - - :return: It returns ps, pd, pv, and pc - """ - - x = self.get_scattering_power() - rot_coh_mat = x[5] - t_11_theta, t_22_theta, t_33_theta = rot_coh_mat[0], rot_coh_mat[4], rot_coh_mat[8] - rows, cols = np.shape(rot_coh_mat[0])[0], np.shape(rot_coh_mat[0])[1] - pc, pv, s, d, c = x[0], x[1], x[2], x[3], x[4] - # print(np.shape(pc), np.shape(pv), np.shape(s), np.shape(d), np.shape(c)) - ps, pd = np.zeros([rows, cols]), np.zeros([rows, cols]) - - for i in range(rows): - for j in range(cols): - - tp = t_11_theta[i, j] + t_22_theta[i, j] + t_33_theta[i, j] - print(tp) - if pv[i, j] + pc[i, j] > tp: - ps[i, j], pd[i, j] = 0, 0 - pv[i, j] = tp - pc[i, j] - - else: - - c1 = t_11_theta[i, j] - t_22_theta[i, j] - t_33_theta[i, j] + pc[i, j] - - if c1 > 0: - ps[i, j] = s[i, j] + abs((c[i, j] * np.conj(c[i, j]))) / s[i, j] - pd[i, j] = d[i, j] - abs((c[i, j] * np.conj(c[i, j]))) / s[i, j] - - else: - ps[i, j] = s[i, j] - abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - pd[i, j] = d[i, j] + abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - - if ps[i, j] > 0 > pd[i, j]: - pd[i, j] = 0 - ps[i, j] = tp - pv[i, j] - pc[i, j] - - elif pd[i, j] > 0 > ps[i, j]: - ps[i, j] = 0 - pd[i, j] = tp - pv[i, j] - pc[i, j] - - return [10 * np.log10(abs(ps)), 10 * np.log10(abs(pd)), - 10 * np.log10(abs(pv)), 10 * np.log10(abs(pc))] - - def get_result(self): - x = self.get_decomposition() - ps, pd, pv, pc = x[0], x[1], x[2], x[3] - - scattering_list = ['ps', 'pd', 'pv', 'pc'] - - for i in range(len(x)): - - cols, rows = ps.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'Yamaguchi2011_4SD' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i]) - - -class General4SD(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - def get_scattering_power(self): - - cov_mat = self.get_cov_mat_img() - rot_coh_mat = self.rot_coh_mat_img() - rows, cols = np.shape(cov_mat[0])[0], np.shape(cov_mat[0])[1] - - pc = 2 * abs(np.imag(rot_coh_mat[5])) - pv = np.zeros([rows, cols]) - s = np.zeros([rows, cols]) - d = np.zeros([rows, cols]) - c = np.zeros([rows, cols], dtype=complex) - c1 = rot_coh_mat[0] - rot_coh_mat[4] + (7 / 8) * (1 / 16) * pc - - for i in range(rows): - for j in range(cols): - - tp = rot_coh_mat[0][i, j] + rot_coh_mat[4][i, j] + rot_coh_mat[8][i, j] - - if c1[i, j] > 0: - - if cov_mat[8][i, j] <= 0 or cov_mat[0][i, j] <= 0: - - cov_mat[8][i, j], cov_mat[0][i, j] = 1.0, 1.0 - - print(cov_mat[8][i, j], cov_mat[0][i, j]) - - if 10 * math.log10(cov_mat[8][i, j] / cov_mat[0][i, j]) < -2: - - pv[i, j] = (15 / 8) * (2 * rot_coh_mat[8][i, j] - pc[i, j]) - - if pv[i, j] < 0: - pc[i, j] = 0 - - pv[i, j] = (15 / 8) * (2 * rot_coh_mat[8][i, j] - pc[i, j]) - s[i, j] = rot_coh_mat[0][i, j] - 0.5 * pv[i, j] - d[i, j] = tp - pv[i, j] - pc[i, j] - s[i, j] - c[i, j] = rot_coh_mat[1][i, j] + rot_coh_mat[2][i, j] - (1 / 6) * pv[i, j] - - elif 10 * math.log10(cov_mat[8][i, j] / cov_mat[0][i, j]) > 2: - - pv[i, j] = (15 / 8) * (2 * rot_coh_mat[8][i, j] - pc[i, j]) - - if pv[i, j] < 0: - pc[i, j] = 0 - - pv[i, j] = (15 / 8) * (2 * rot_coh_mat[8][i, j] - pc[i, j]) - s[i, j] = rot_coh_mat[0][i, j] - 0.5 * pv[i, j] - d[i, j] = tp - pv[i, j] - pc[i, j] - s[i, j] - c[i, j] = rot_coh_mat[1][i, j] + rot_coh_mat[2][i, j] + (1 / 6) * pv[i, j] - - else: - - pv[i, j] = 2 * (2 * rot_coh_mat[8][i, j] - pc[i, j]) - - if pv[i, j] < 0: - pc[i, j] = 0 - - pv[i, j] = 2 * (2 * rot_coh_mat[8][i, j] - pc[i, j]) - s[i, j] = rot_coh_mat[0][i, j] - 0.5 * pv[i, j] - d[i, j] = tp - pv[i, j] - pc[i, j] - s[i, j] - c[i, j] = rot_coh_mat[1][i, j] + rot_coh_mat[2][i, j] - - else: - pv[i, j] = (15 / 16) * (2 * rot_coh_mat[8][i, j] - pc[i, j]) - - if pv[i, j] < 0: - pc[i, j] = 0 - - pv[i, j] = (15 / 16) * (2 * rot_coh_mat[8][i, j] - pc[i, j]) - s[i, j] = rot_coh_mat[0][i, j] - d[i, j] = tp - pv[i, j] - pc[i, j] - s[i, j] - c[i, j] = rot_coh_mat[1][i, j] + rot_coh_mat[2][i, j] - - return [pc, pv, s, d, c, rot_coh_mat, c1] - - def get_decomposition(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Paper Details: "General Four-Component Scattering Power Decomposition With Unitary Transformation - of Coherency Matrix" - - IEEEXplore: https://ieeexplore.ieee.org/document/6311461 - - DOI: 10.1109/TGRS.2012.2212446 - - This paper presents a new general four component scattering power methods by unitary transformation of - the coherency matrix. By additional transformation, it became possible to reduce the number of independent - parameters from eight to seven. - - The model can be written as: - - <[T(theta)]> = fs * <[Ts]> + fd * <[Td]> + fv * <[Tv]> + fc * <[Tc]> - - <[T(phi)]> = U(phi) * <[T(theta)]> * transpose(conj(U(phi)) - - <[T(phi)]> = U(phi) * (fs * <[Ts]> + fd * <[Td]> + fv * <[Tv]> + fc * <[Tc]>) * transpose(conj(U(phi)) - - <[T(phi)]> = fs * <[T(phi)s]> + fd * <[T(phi)d]> + fv * <[T(phi)v]> + fc * <[T(phi)c]> - - U(phi) = [1 0 0 - 0 cos(phi) j * sin(phi) - 0 j * sin(phi) cos(phi)] - - fs: for surface scattering - fd: for double-bounce scattering - fv: for volume scattering - fc: for helix scattering - - ps: scattered power return associated with surface scattering - pd: scattered power return associated with double-bounce scattering - pv: scattered power return associated with volume scattering - pc: scattered power return associated with helix scattering - - :return: It returns ps, pd, pv, and pc which are associated with fs, fd, fv, and fc - """ - - x = self.get_scattering_power() - rot_coh_mat, c1 = x[5], x[6] - t_11_theta, t_22_theta, t_33_theta = rot_coh_mat[0], rot_coh_mat[4], rot_coh_mat[8] - rows, cols = np.shape(rot_coh_mat[0])[0], np.shape(rot_coh_mat[0])[1] - pc, pv, s, d, c = x[0], x[1], x[2], x[3], x[4] - print(np.shape(pc), np.shape(pv), np.shape(s), np.shape(d), np.shape(c)) - ps, pd = np.zeros([rows, cols]), np.zeros([rows, cols]) - - for i in range(rows): - for j in range(cols): - - tp = rot_coh_mat[0][i, j] + rot_coh_mat[4][i, j] + rot_coh_mat[8][i, j] - - if c1[i, j] < 0: - pd[i, j] = d[i, j] + abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - ps[i, j] = s[i, j] - abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - - else: - if pv[i, j] + pc[i, j] > tp: - ps[i, j], pd[i, j] = 0, 0 - pv[i, j] = tp - pc[i, j] - - else: - c0 = 2 * t_11_theta[i, j] + pc[i, j] - tp - - if c0 > 0: - ps[i, j] = s[i, j] + abs((c[i, j] * np.conj(c[i, j]))) / s[i, j] - pd[i, j] = d[i, j] - abs((c[i, j] * np.conj(c[i, j]))) / s[i, j] - - else: - ps[i, j] = s[i, j] - abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - pd[i, j] = d[i, j] + abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - - if ps[i, j] > 0 > pd[i, j]: - pd[i, j] = 0 - ps[i, j] = tp - pv[i, j] - pc[i, j] - - elif pd[i, j] > 0 > ps[i, j]: - ps[i, j] = 0 - pd[i, j] = tp - pv[i, j] - pc[i, j] - - return [10 * np.log10(abs(ps)), 10 * np.log10(abs(pd)), - 10 * np.log10(abs(pv)), 10 * np.log10(abs(pc))] - - def get_result(self): - x = self.get_decomposition() - ps, pd, pv, pc = x[0], x[1], x[2], x[3] - - scattering_list = ['ps', 'pd', 'pv', 'pc'] - - for i in range(len(x)): - - cols, rows = ps.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'singh_4SD' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i]) - - -class General6SD(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - def scattering_power(self): - - cov_mat = self.get_cov_mat_img() - coh_mat = self.get_coh_mat_img() - rot_coh_mat = self.rot_coh_mat_img() - t_11_theta, t_22_theta, t_33_theta = rot_coh_mat[0], rot_coh_mat[4], rot_coh_mat[8] - t_12_theta = rot_coh_mat[1] - rows, cols = np.shape(cov_mat[0])[0], np.shape(cov_mat[0])[1] - - ph = 2 * abs(np.imag(coh_mat[5])) - pcd = 2 * abs(np.imag(rot_coh_mat[2])) - pod = 2 * abs(np.real(rot_coh_mat[2])) - pcw = pcd + pod - pv = 2 * rot_coh_mat[8] - ph - pod - pcd - s = np.zeros([rows, cols]) - d = np.zeros([rows, cols]) - c = np.zeros([rows, cols], dtype=complex) - c1_mat = np.zeros([rows, cols]) - - for i in range(rows): - for j in range(cols): - - c1 = t_11_theta[i, j] - t_22_theta[i, j] + (7 / 8) * t_33_theta[i, j] - c1 += (1 / 16) * ph[i, j] - (15 / 16) * (pod[i, j] + pcd[i, j]) - c1_mat[i, j] = c1 - - if c1 > 0: - if pv[i, j] < 0: - ph[i, j] = 0 - pod[i, j] = 0 - pcd[i, j] = 0 - pv[i, j] = 2 * t_33_theta[i, j] - - if cov_mat[8][i, j] <= 0 or cov_mat[0][i, j] <= 0: - cov_mat[8][i, j], cov_mat[0][i, j] = 1.0, 1.0 - - if 10 * math.log10(cov_mat[8][i, j] / cov_mat[0][i, j]) < -2: - pv[i, j] = (15 / 8) * pv[i, j] - s[i, j] = t_11_theta[i, j] - 0.5 * pv[i, j] - 0.5 * pod[i, j] - 0.5 * pcd[i, j] - d[i, j] = t_22_theta[i, j] - (7 / 30) * pv[i, j] - 0.5 * ph[i, j] - c[i, j] = t_12_theta[i, j] - (1 / 6) * pv[i, j] - - elif 10 * math.log10(cov_mat[8][i, j] / cov_mat[0][i, j]) > 2: - pv[i, j] = (15 / 8) * pv[i, j] - s[i, j] = t_11_theta[i, j] - 0.5 * pv[i, j] - 0.5 * pod[i, j] - 0.5 * pcd[i, j] - d[i, j] = t_22_theta[i, j] - (7 / 30) * pv[i, j] - 0.5 * ph[i, j] - c[i, j] = t_12_theta[i, j] + (1 / 6) * pv[i, j] - - else: - pv[i, j] = 2 * pv[i, j] - s[i, j] = t_11_theta[i, j] - 0.5 * pv[i, j] - 0.5 * pod[i, j] - 0.5 * pcd[i, j] - d[i, j] = t_22_theta[i, j] - 0.25 * pv[i, j] - 0.5 * ph[i, j] - c[i, j] = t_12_theta[i, j] - - else: - - if pv[i, j] < 0: - pv[i, j] = 0 - - if ph[i, j] > pcw[i, j]: - pcw[i, j] = 2 * t_33_theta[i, j] - ph[i, j] - - if pcw[i, j] < 0: - pcw[i, j] = 0 - - if pod[i, j] > pcd[i, j]: - pcd[i, j] = pcw[i, j] - pod[i, j] - else: - pod[i, j] = pcw[i, j] - pcd[i, j] - - else: - ph[i, j] = 2 * t_33_theta[i, j] - pcw[i, j] - - if ph[i, j] < 0: - ph[i, j] = 0 - - pv[i, j] = (15 / 16) * pv[i, j] - s[i, j] = t_11_theta[i, j] - 0.5 * pod[i, j] - 0.5 * pcd[i, j] - d[i, j] = t_22_theta[i, j] - (7 / 15) * pv[i, j] - 0.5 * ph[i, j] - c[i, j] = t_12_theta[i, j] - - return [ph, pcd, pod, pv, pcw, s, d, c, cov_mat, rot_coh_mat, c1_mat] - - def get_decomposition(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Paper Details: "Model-Based Six-Component Scattering Matrix Power Decomposition" - - IEEEXplore: https://ieeexplore.ieee.org/document/8356711 - - DOI: 10.1109/TGRS.2018.2824322 - - The major accomplishment of this paper was associated with the inclusion of 2 new types of physical - scattering submodels against the existing 4 component scattering power decomposition(4SD - - Refer Yamaguchi, Singh4SD) to account for the real and imaginary part of the T13 of the coherency matrix. - - *** One is oriented dipole scattering and other is oriented quarter wave reflector *** - - The total scattered power can be written as: - - [T] = ps*[Ts] + pd*[Ts] + pv*[Tv] + ph*[Th] + pod*[Tod] + pcd*[Tcd] - - ps: surface scattering - pd: double bounce scattering - pv: volume scattering - ph: helix scattering - pcd: compound dipole scattering - pod: oriented dipole scattering - - :return: It returns the decibel units of ps, pd, pv, ph, pod, pcd - """ - - x = self.scattering_power() - ph, pcd, pod, pv, pcw, s, d, c = x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7] - cov_mat, rot_coh_mat = x[8], x[9] - c1_mat = x[10] - t_11_theta, t_22_theta, t_33_theta = rot_coh_mat[0], rot_coh_mat[4], rot_coh_mat[8] - rows, cols = np.shape(ph)[0], np.shape(ph)[1] - ps, pd = np.zeros([rows, cols]), np.zeros([rows, cols]) - - for i in range(rows): - for j in range(cols): - - tp = t_11_theta[i, j] + t_22_theta[i, j] + t_33_theta[i, j] - - if c1_mat[i, j] < 0: - ps[i, j] = s[i, j] - abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - pd[i, j] = d[i, j] + abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - - else: - - if pv[i, j] + ph[i, j] + pcw[i, j] > tp: - ps[i, j], pd[i, j] = 0, 0 - pv[i, j] = tp - ph[i, j] - pod[i, j] - pcd[i, j] - - else: - c0 = 2 * t_11_theta[i, j] + ph[i, j] - tp - - if c0 > 0: - ps[i, j] = s[i, j] + abs((c[i, j] * np.conj(c[i, j]))) / s[i, j] - pd[i, j] = d[i, j] - abs((c[i, j] * np.conj(c[i, j]))) / s[i, j] - - else: - ps[i, j] = s[i, j] - abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - pd[i, j] = d[i, j] + abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - - if ps[i, j] > 0 > pd[i, j]: - pd[i, j] = 0 - ps[i, j] = tp - pv[i, j] - ph[i, j] - pod[i, j] - pcd[i, j] - - elif pd[i, j] > 0 > ps[i, j]: - ps[i, j] = 0 - pd[i, j] = tp - pv[i, j] - ph[i, j] - pod[i, j] - pcd[i, j] - - return [10 * np.log10(abs(ps)), 10 * np.log10(abs(pd)), 10 * np.log10(abs(pv)), - 10 * np.log10(abs(ph)), 10 * np.log10(abs(pod)), 10 * np.log10(abs(pcd))] - - def get_result(self): - x = self.get_decomposition() - ps, pd, pv, ph, pod, pcd = x[0], x[1], x[2], x[3], x[4], x[5] - - scattering_list = ['ps', 'pd', 'pv', 'ph', 'pod', 'pcd'] - - for i in range(len(x)): - - cols, rows = ps.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'singh_6SD' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i]) - - -class General7SD(Polarimetry): - def __init__(self, b, w): - super().__init__(b, w) - - def scattering_power(self): - - cov_mat = self.get_cov_mat_img() - coh_mat = self.get_coh_mat_img() - t_11, t_22, t_33 = coh_mat[0], coh_mat[4], coh_mat[8] - t_12 = coh_mat[1] - rows, cols = np.shape(cov_mat[0])[0], np.shape(cov_mat[0])[1] - - ph = 2 * abs(np.imag(coh_mat[5])) - pcd = 2 * abs(np.imag(coh_mat[2])) - pod = 2 * abs(np.real(coh_mat[2])) - pmd = 2 * abs(np.real(coh_mat[5])) - pmw = pmd + ph - pcw = pcd + pod - pv = 2 * t_33 - ph - pod - pcd - pmd - s = np.zeros([rows, cols]) - d = np.zeros([rows, cols]) - c = np.zeros([rows, cols], dtype=complex) - c1_mat = np.zeros([rows, cols]) - - for i in range(rows): - for j in range(cols): - - c1 = t_11[i, j] - t_22[i, j] - (7 / 8) * t_33[i, j] - c1 += (1 / 16) * (pmd[i, j] + ph[i, j]) - (15 / 16) * (pcd[i, j] + pod[i, j]) - - c1_mat[i, j] = c1 - - if c1 > 0: - if pv[i, j] < 0: - ph[i, j], pod[i, j] = 0, 0 - pmd[i, j], pcd[i, j] = 0, 0 - pv[i, j] = 2 * t_33[i, j] - - if cov_mat[8][i, j] <= 0 or cov_mat[0][i, j] <= 0: - cov_mat[8][i, j], cov_mat[0][i, j] = 1.0, 1.0 - - if 10 * math.log10(cov_mat[8][i, j] / cov_mat[0][i, j]) < -2: - pv[i, j] = (15 / 8) * pv[i, j] - s[i, j] = t_11[i, j] - 0.5 * pv[i, j] - 0.5 * pod[i, j] - 0.5 * pcd[i, j] - d[i, j] = t_22[i, j] - (7 / 30) * pv[i, j] - 0.5 * ph[i, j] - 0.5 * pmd[i, j] - c[i, j] = t_12[i, j] - (1 / 6) * pv[i, j] - - elif 10 * math.log10(cov_mat[8][i, j] / cov_mat[0][i, j]) > 2: - pv[i, j] = (15 / 8) * pv[i, j] - s[i, j] = t_11[i, j] - 0.5 * pv[i, j] - 0.5 * pod[i, j] - 0.5 * pcd[i, j] - d[i, j] = t_22[i, j] - (7 / 30) * pv[i, j] - 0.5 * ph[i, j] - 0.5 * pmd[i, j] - c[i, j] = t_12[i, j] + (1 / 6) * pv[i, j] - - else: - pv[i, j] = 2 * pv[i, j] - s[i, j] = t_11[i, j] - 0.5 * pv[i, j] - 0.5 * pod[i, j] - 0.5 * pcd[i, j] - d[i, j] = t_22[i, j] - 0.25 * pv[i, j] - 0.5 * ph[i, j] - 0.5 * pmd[i, j] - c[i, j] = t_12[i, j] - - else: - if pv[i, j] < 0: - pv[i, j] = 0 - - if pmw[i, j] > pcw[i, j]: - pcw[i, j] = 2 * t_33[i, j] - pmw[i, j] - - if pcw[i, j] < 0: - pcw[i, j] = 0 - - if pod[i, j] > pcd[i, j]: - pcd[i, j] = pcw[i, j] - pod[i, j] - - if pcd[i, j] < 0: - pcd[i, j] = 0 - - else: - pod[i, j] = pcw[i, j] - pcd[i, j] - - if pod[i, j] < 0: - pod[i, j] = 0 - - else: - pmw[i, j] = 2 * t_33[i, j] - pcw[i, j] - - if pmw[i, j] < 0: - pmw[i, j] = 0 - - if pmd[i, j] > ph[i, j]: - ph[i, j] = pmw[i, j] - pmd[i, j] - - if ph[i, j] < 0: - ph[i, j] = 0 - - else: - pmd[i, j] = pmw[i, j] - ph[i, j] - if pmd[i, j] < 0: - pmd[i, j] = 0 - - pv[i, j] = (15 / 16) * pv[i, j] - s[i, j] = t_11[i, j] - 0.5 * pod[i, j] - 0.5 * pcd[i, j] - d[i, j] = t_22[i, j] - (7 / 15) * pv[i, j] - 0.5 * ph[i, j] - 0.5 * pmd[i, j] - c[i, j] = t_12[i, j] - - return [ph, pcd, pcw, pmd, pmw, pod, pv, s, d, c, cov_mat, coh_mat, c1_mat] - - def get_decomposition(self): - - """ - PROGRAMMER: Raktim Ghosh, MSc (University of Twente) - Date Written (May, 2020) - - Paper Details: "Seven-Component Scattering Power Decomposition of POLSAR Coherency Matrix" - - IEEEXplore: https://ieeexplore.ieee.org/document/8751154 - - DOI: 10.1109/TGRS.2019.2920762 - - The 9 independent parameters of target coherency matrix, are assocaited with some phsical scattering models. - This paper attempts to assign one such physical scattering model to the real part of T23, and develop a new - scattering power decomposition model. - - The establised 7SD model is a extension of previosly developed 6SD model (Refer General 6SD) - - [T] = ps*[Ts] + pd*[Ts] + pv*[Tv] + ph*[Th] + pod*[Tod] + pcd*[Tcd] - - The scattering powers (ps, pd, pv, ph, pod, pcd, pmd) represents the scattering contributions - to the corresponding channels associated with the scattering matrix. - - ps: surface scattering - pd: double bounce scattering - pv: volume scattering - ph: helix scattering - pcd: compound dipole scattering - pod: oriented dipole scattering - pmd: mixed dipole scattering - - :return: It returns decibel unit of ps, pd, pv, ph, pcd, pod, pmd - """ - - x = self.scattering_power() - ph, pcd, pcw, pmd, pmw, pod, pv = x[0], x[1], x[2], x[3], x[4], x[5], x[6] - s, d, c = x[7], x[8], x[9] - cov_mat, coh_mat = x[10], x[11] - c1_mat = x[12] - t_11, t_22, t_33 = coh_mat[0], coh_mat[4], coh_mat[8] - rows, cols = np.shape(ph)[0], np.shape(ph)[1] - ps, pd = np.zeros([rows, cols]), np.zeros([rows, cols]) - - for i in range(rows): - for j in range(cols): - - tp = t_11[i, j] + t_22[i, j] + t_33[i, j] - - if c1_mat[i, j] < 0: - ps[i, j] = s[i, j] - abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - pd[i, j] = d[i, j] + abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - - else: - - if pv[i, j] + pmw[i, j] + pcw[i, j] > tp: - ps[i, j], pd[i, j] = 0, 0 - pv[i, j] = tp - ph[i, j] - pmd[i, j] - pod[i, j] - pcd[i, j] - - else: - c0 = 2 * t_11[i, j] + ph[i, j] + pmd[i, j] - tp - - if c0 > 0: - ps[i, j] = s[i, j] + abs((c[i, j] * np.conj(c[i, j]))) / s[i, j] - pd[i, j] = d[i, j] - abs((c[i, j] * np.conj(c[i, j]))) / s[i, j] - - else: - ps[i, j] = s[i, j] - abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - pd[i, j] = d[i, j] + abs((c[i, j] * np.conj(c[i, j]))) / d[i, j] - - if ps[i, j] > 0 > pd[i, j]: - pd[i, j] = 0 - ps[i, j] = tp - pv[i, j] - ph[i, j] - pod[i, j] - pcd[i, j] - - elif pd[i, j] > 0 > ps[i, j]: - ps[i, j] = 0 - pd[i, j] = tp - pv[i, j] - ph[i, j] - pod[i, j] - pcd[i, j] - - return [10 * np.log10(ps), 10 * np.log10(pd), 10 * np.log10(pv), - 10 * np.log10(ph), 10 * np.log10(pod), 10 * np.log10(pcd), - 10 * np.log10(pmd)] - - def get_result(self): - x = self.get_decomposition() - ps, pd, pv, ph, pod, pcd, pmd = x[0], x[1], x[2], x[3], x[4], x[5], x[6] - - scattering_list = ['ps', 'pd', 'pv', 'ph', 'pod', 'pcd', 'pmd'] - - for i in range(len(x)): - - cols, rows = ps.shape - driver = gdal.GetDriverByName("GTiff") - outfile = 'scattering' + '_' + scattering_list[i] + '_' + 'singh_7SD' - outfile += '.tiff' - out_data = driver.Create(outfile, rows, cols, 1, gdal.GDT_Float32) - out_data.SetProjection(self.get_band().GetProjection()) - out_data.SetGeoTransform(self.get_band().GetGeoTransform()) - out_data.GetRasterBand(1).WriteArray(x[i]) -""" -band = gdal.Open("HH.tif") -#band = gdal.Open("C:/Users/ThisPc/RS2-SLC-FQ2-DES-15-Apr-2008_14.38-PDS_05116980_Cal.tif") -# band = gdal.Open("C:/Users/ThisPc/RS2-SLC-FQ2-DES-15-Apr-2008_14.tif") - -decomposition = ModTouzi(band, 5) -decomposition.get_result() -""" \ No newline at end of file diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/pspCloudePottierDecomposition.py b/landcover-L-SAR/tool/algorithm/polsarpro/pspCloudePottierDecomposition.py deleted file mode 100644 index fb31608..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/pspCloudePottierDecomposition.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:pspHAAlphaDecomposition.py Cloude-Pottier分解 -@Function: Cloude-Pottier eigenvector/eigenvalue based decomposition of a 3x3 coherency matrix [T3] - (Averaging using a sliding window) - V1.0.1:(1)可选分解特征;(2)bin转tif格式 -@Contact: -@Author:SHJ -@Date:2021/9/24 9:06 -@Version:1.0.1 -""" - -import os -import shutil -import subprocess -import logging - -logger = logging.getLogger("mylog") - - -class PspCloudePottierDecomposition: - """ - 调用polsarpro4.2.0的Cloude-Pottier极化分解 h_a_alpha_decomposition_T3.exe - """ - - def __init__( - self, - exeDir, - inT3Dir, - outDir, - exeDecomposeName='h_a_alpha_decomposition_T3.exe'): - """ - :param exeDir:exe所在目录 - :param inT3Dir:T3矩阵目录 - :param outDir:输出目录 - """ - self.__exeName = exeDecomposeName - self.__exeDir = exeDir - self.__inT3Dir = inT3Dir - self.__outDir = outDir - self.__DecompostFlag = False - pass - - def api_h_a_alpha_decomposition_T3( - self, - rectX, - rectY, - rectWidth, - rectHeight, - Nwin=1): - """ - :param rectX:有效区域x - :param rectY:有效区域y - :param rectWidth:有效区域宽 - :param rectHeight:有效区域高 - :param Nwin :Size of the (Nwin, Nwin) sliding window used to compute local estimates. (int) - """ - if self.__DecompostFlag: - return True - if len(self.__exeDir) == 0: - if not os.path.exists(self.__exeName): - logger.error(self.__exeName + ' not exists.') - return False - exePath = self.__exeName - else: - if not os.path.exists(self.__exeDir + '\\' + self.__exeName): - logger.error(self.__exeName + ' not exists.') - return False - exePath = self.__exeDir + '\\' + self.__exeName - - if not self._checkT3Matrix(self.__inT3Dir): - logger.error('T3 Matrix check failed.') - return False - if not os.path.exists(self.__outDir): - os.makedirs(self.__outDir) - - alpbetdelgam = 1 - Lambda = 1 - alpha = 1 - entropy = 1 - anisotropy = 1 - - CombHA = 1 - CombH1mA = 1 - Comb1mHA = 1 - Comb1mH1mA = 1 - - Off_lig = rectX - Off_col = rectY - Sub_Nlig = rectWidth - Sub_Ncol = rectHeight - - para_list = [ - exePath, - self.__inT3Dir, - self.__outDir, - Nwin, - Off_lig, - Off_col, - Sub_Nlig, - Sub_Ncol, - alpbetdelgam, - Lambda, - alpha, - entropy, - anisotropy, - CombHA, - CombH1mA, - Comb1mHA, - Comb1mH1mA] - cmd = " ".join(str(i) for i in para_list) - config_path = os.path.join(self.__inT3Dir, 'config.txt') - shutil.copyfile(config_path, os.path.join(self.__outDir, 'config.txt')) - result_tuple = subprocess.getstatusoutput(cmd) - - if result_tuple[0] != 1 or result_tuple[1].find('error') != -1: - raise Exception(result_tuple[1]) - self.__DecompostFlag = True - return True - @staticmethod - def _checkT3Matrix(T3Dir): - # 检测T3矩阵 - if not os.path.exists(T3Dir): - return False - file_name_in_out = ['T11.bin', 'T12_real.bin', 'T12_imag.bin', - 'T13_real.bin', 'T13_imag.bin', 'T22.bin', - 'T23_real.bin', 'T23_imag.bin', 'T33.bin'] - for item in file_name_in_out: - if not os.path.exists(T3Dir + "\\" + item): - return False - return True diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/pspFreemanDecomposition.py b/landcover-L-SAR/tool/algorithm/polsarpro/pspFreemanDecomposition.py deleted file mode 100644 index 656f81a..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/pspFreemanDecomposition.py +++ /dev/null @@ -1,109 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:pspFreemanDecomposition.py -@Function: -@Contact: -@Author:LVY -@Date:2021/10/12 18:45 -@Version:1.0.0 -""" - -import os -import shutil -import subprocess -import logging -logger = logging.getLogger("mylog") - - -class PspFreemanDecomposition: - """ - Freeman分解 - """ - - def __init__( - self, - exeDir, - inT3Dir, - outDir, - exeDecomposeName='freeman_decomposition_T3.exe'): - """ - :param exeDir:exe所在目录 - :param inT3Dir:T3矩阵目录 - :param outDir:输出目录 - """ - self.__exeName = exeDecomposeName - self.__exeDir = exeDir - self.__inT3Dir = inT3Dir - self.__outDir = outDir - self.__DecompostFlag = False - pass - - def api_freeman_decomposition_T3( - self, - rectX, - rectY, - rectWidth, - rectHeight, - Nwin=1): - """ - :param rectX:有效区域x - :param rectY:有效区域y - :param rectWidth:有效区域宽 - :param rectHeight:有效区域高 - :param Nwin :Size of the (Nwin, Nwin) sliding window used to compute local estimates. (int) - """ - if self.__DecompostFlag: - return True - if len(self.__exeDir) == 0: - if not os.path.exists(self.__exeName): - logger.error(self.__exeName + ' not exists.') - return False - exePath = self.__exeName - else: - if not os.path.exists(self.__exeDir + '\\' + self.__exeName): - logger.error(self.__exeName + ' not exists.') - return False - exePath = self.__exeDir + '\\' + self.__exeName - - if not self._checkT3Matrix(self.__inT3Dir): - logger.error('T3 Matrix check failed.') - return False - if not os.path.exists(self.__outDir): - os.makedirs(self.__outDir) - - Off_lig = rectX - Off_col = rectY - Sub_Nlig = rectWidth - Sub_Ncol = rectHeight - - para_list = [ - exePath, - self.__inT3Dir, - self.__outDir, - Nwin, - Off_lig, - Off_col, - Sub_Nlig, - Sub_Ncol] - cmd = " ".join(str(i) for i in para_list) - config_path = os.path.join(self.__inT3Dir, 'config.txt') - shutil.copyfile(config_path, os.path.join(self.__outDir, 'config.txt')) - result_tuple = subprocess.getstatusoutput(cmd) - - if result_tuple[0] != 1 or result_tuple[1].find('error') != -1: - raise Exception(result_tuple[1]) - self.__DecompostFlag = True - return True - @staticmethod - def _checkT3Matrix(T3Dir): - # 检测T3矩阵 - if not os.path.exists(T3Dir): - return False - file_name_in_out = ['T11.bin', 'T12_real.bin', 'T12_imag.bin', - 'T13_real.bin', 'T13_imag.bin', 'T22.bin', - 'T23_real.bin', 'T23_imag.bin', 'T33.bin'] - for item in file_name_in_out: - if not os.path.exists(T3Dir + "\\" + item): - return False - return True diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/pspHAAlphaDecomposition.py b/landcover-L-SAR/tool/algorithm/polsarpro/pspHAAlphaDecomposition.py deleted file mode 100644 index 041a124..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/pspHAAlphaDecomposition.py +++ /dev/null @@ -1,435 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:pspHAAlphaDecomposition.py -@Function: Cloude-Pottier eigenvector/eigenvalue based decomposition of a 3x3 coherency matrix [T3] - (Averaging using a sliding window) - V1.0.1:(1)可选分解特征;(2)bin转tif格式 -@Contact: -@Author:SHJ -@Date:2021/9/24 9:06 -@Version:1.0.1 -""" - -import os -import shutil -import subprocess -import struct -import numpy as np -import glob -from PIL import Image -import logging -logger = logging.getLogger("mylog") -import multiprocessing - -class PspHAAlphaDecomposition: - """ - 调用polsarpro4.2.0的Cloude-Pottier极化分解 - """ - def __init__(self,normalization = False): - self.__normalization = normalization #是否做归一化 - self.__res_h_a_alpha_decomposition_T3 = {} - self.__res_h_a_alpha_eigenvalue_set_T3 = {} - self.__res_h_a_alpha_eigenvector_set_T3 = {} - pass - - def api_creat_h_a_alpha_features_single_process(self, h_a_alpha_out_dir, - h_a_alpha_decomposition_T3_path, h_a_alpha_eigenvalue_set_T3_path, - h_a_alpha_eigenvector_set_T3_path, polsarpro_in_dir,is_trans_to_tif=True, is_read_to_dic=False): - """ - 对porsarpro格式T3矩阵做Cloude-Pottier分解(h_a_alpha_decomposition、h_a_alpha_eigenvalue_set 和 h_a_alpha_eigenvector_set) - :param h_a_alpha_out_dir : 输出h_a_alpha二进制数据的目录 - :param h_a_alpha_decomposition_T3_path: haalphadecompositionT3.exe路径 - :param h_a_alpha_eigenvalue_set_T3_path: h_a_alpha_eigenvalue_set_T3.exe路径 - :param h_a_alpha_eigenvector_set_T3_path: h_a_alpha_eigenvector_set_T3.exe路径 - :param polsarpro_in_dir:输入porsarpro格式T3矩阵目录,包含.bin,.config - """ - h_a_alpha_features ={} - h_a_alpha_features.update(self.api_h_a_alpha_decomposition_T3(h_a_alpha_out_dir, h_a_alpha_decomposition_T3_path, polsarpro_in_dir, is_trans_to_tif,is_read_to_dic, *(1, 1, 1, 1, 1, 1, 1, 1, 1))) - logger.info("run h_a_alpha_decomposition_T3 success!") - logger.info('progress bar: 40%') - h_a_alpha_features.update(self.api_h_a_alpha_eigenvalue_set_T3(h_a_alpha_out_dir, h_a_alpha_eigenvalue_set_T3_path, polsarpro_in_dir, is_trans_to_tif, is_read_to_dic, *(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1))) - logger.info("run h_a_alpha_eigenvalue_set_T3 success!") - logger.info('progress bar: 60%') - h_a_alpha_features.update(self.api_h_a_alpha_eigenvector_set_T3(h_a_alpha_out_dir, h_a_alpha_eigenvector_set_T3_path, polsarpro_in_dir, is_trans_to_tif,is_read_to_dic, *(1, 1, 1, 1, 1))) - logger.info("run h_a_alpha_eigenvector_set_T3 success!") - logger.info('progress bar: 80%') - if is_trans_to_tif: - self.api_trans_T3_to_tif(h_a_alpha_out_dir, polsarpro_in_dir) - if is_read_to_dic: - h_a_alpha_features.update(self.api_read_T3_matrix(polsarpro_in_dir)) - return h_a_alpha_features - - def api_creat_h_a_alpha_features(self, h_a_alpha_out_dir, - h_a_alpha_decomposition_T3_path, h_a_alpha_eigenvalue_set_T3_path, - h_a_alpha_eigenvector_set_T3_path, polsarpro_in_dir,is_trans_to_tif=True, is_read_to_dic=False): - """ - 对porsarpro格式T3矩阵做Cloude-Pottier分解(h_a_alpha_decomposition、h_a_alpha_eigenvalue_set 和 h_a_alpha_eigenvector_set) - :param h_a_alpha_out_dir : 输出h_a_alpha二进制数据的目录 - :param h_a_alpha_decomposition_T3_path: haalphadecompositionT3.exe路径 - :param h_a_alpha_eigenvalue_set_T3_path: h_a_alpha_eigenvalue_set_T3.exe路径 - :param h_a_alpha_eigenvector_set_T3_path: h_a_alpha_eigenvector_set_T3.exe路径 - :param polsarpro_in_dir:输入porsarpro格式T3矩阵目录,包含.bin,.config - """ - - pool = multiprocessing.Pool(processes=3) - pl = [] - - logger.info("run h_a_alpha_decomposition_T3!") - pl.append(pool.apply_async(self.api_h_a_alpha_decomposition_T3, (h_a_alpha_out_dir, h_a_alpha_decomposition_T3_path, polsarpro_in_dir, is_trans_to_tif, is_read_to_dic, *(1, 1, 1, 1, 1, 1, 1, 1, 1)))) - logger.info("run h_a_alpha_eigenvalue_set_T3!") - pl.append(pool.apply_async(self.api_h_a_alpha_eigenvalue_set_T3, (h_a_alpha_out_dir, h_a_alpha_eigenvalue_set_T3_path, polsarpro_in_dir, is_trans_to_tif, is_read_to_dic, *(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)))) - logger.info("run h_a_alpha_eigenvector_set_T3!") - pl.append(pool.apply_async(self.api_h_a_alpha_eigenvector_set_T3, (h_a_alpha_out_dir, h_a_alpha_eigenvector_set_T3_path, polsarpro_in_dir, is_trans_to_tif,is_read_to_dic, *(1, 1, 1, 1, 1)))) - - pool.close() - pool.join() - logger.info(pl) - logger.info('progress bar: 60%') - - h_a_alpha_features = {} - h_a_alpha_features.update(self.__res_h_a_alpha_decomposition_T3) - logger.info("run h_a_alpha_decomposition_T3 success!") - h_a_alpha_features.update(self.__res_h_a_alpha_eigenvalue_set_T3) - logger.info("run h_a_alpha_eigenvalue_set_T3 success!") - h_a_alpha_features.update(self.__res_h_a_alpha_eigenvector_set_T3) - logger.info("run h_a_alpha_eigenvector_set_T3 success!") - if is_trans_to_tif: - self.api_trans_T3_to_tif(h_a_alpha_out_dir, polsarpro_in_dir) - if is_read_to_dic: - h_a_alpha_features.update(self.api_read_T3_matrix(polsarpro_in_dir)) - return h_a_alpha_features - - def api_h_a_alpha_decomposition_T3(self, h_a_alpha_out_dir, h_a_alpha_decomposition_T3_path, polsarpro_in_dir, is_trans_to_tif=True, is_read_to_dic=False, *args): - """ - 对porsarpro格式T3矩阵做Cloude-Pottier分解(H-A-Alpha分解) - :param h_a_alpha_out_dir : 输出h_a_alpha二进制数据的目录 - :param h_a_alpha_decomposition_T3_path: haalphadecompositionT3.exe路径 - :param polsarpro_in_dir:输入porsarpro格式T3矩阵目录,包含.bin,.config - :param is_trans_to_tif:分解特征是否转换为tif - :param is_read_to_dic:分解特征是否以字典输出 - :param *args:9个可选分解特征(alpbetdelgam,Lambda,alpha,entropy,anisotropy, - CombHA,CombH1mA,Comb1mHA,Comb1mH1mA),不输出:0,输出:1 - :return : 包含分解特征的字典 - """ - if not os.path.exists(h_a_alpha_out_dir): - os.makedirs(h_a_alpha_out_dir) - self.__h_a_alpha_decomposition_T3(h_a_alpha_out_dir, h_a_alpha_decomposition_T3_path, polsarpro_in_dir, *args) - name_list = ['entropy', 'anisotropy', 'alpha', 'beta', 'delta', 'gamma', 'lambda', - 'combination_1mH1mA', 'combination_1mHA', 'combination_H1mA', 'combination_HA'] - if is_trans_to_tif: - self.__write_haalpha_to_tif(h_a_alpha_out_dir, h_a_alpha_out_dir, name_list) - - if is_read_to_dic: - self.__res_h_a_alpha_decomposition_T3 = self.__read_haalpha(h_a_alpha_out_dir, name_list) - return self.__res_h_a_alpha_decomposition_T3 - else: - return {} - - def api_h_a_alpha_eigenvalue_set_T3(self, h_a_alpha_out_dir, h_a_alpha_eigenvalue_set_T3_path, polsarpro_in_dir, is_trans_to_tif=True, is_read_to_dic=False, *args): - - """ - Cloude-Pottier eigenvalue based decomposition of a coherency matrix - :param h_a_alpha_out_dir : Cloude-Pottier eigenvalue - :param h_a_alpha_eigenvalue_set_T3_path: h_a_alpha_eigenvalue_set_T3.exe路径 - :param polsarpro_in_dir:输入porsarpro格式T3矩阵目录,包含.bin,.config - :param is_trans_to_tif:分解特征是否转换为tif - :param is_read_to_dic:分解特征是否以字典输出 - :param *args:9个可选分解特征(alpbetdelgam,Lambda,alpha,entropy,anisotropy, - CombHA,CombH1mA,Comb1mHA,Comb1mH1mA),不输出:0,输出:1 - :return : 包含分解特征的字典 - """ - if not os.path.exists(h_a_alpha_out_dir): - os.makedirs(h_a_alpha_out_dir) - self.__h_a_alpha_eigenvalue_set_T3(h_a_alpha_out_dir, h_a_alpha_eigenvalue_set_T3_path, polsarpro_in_dir, *args) - name_list = ['anisotropy', 'anisotropy_lueneburg', 'anisotropy12', 'asymetry', 'derd', 'derd_norm', 'entropy_shannon', - 'entropy_shannon_I', 'entropy_shannon_I_norm', 'entropy_shannon_norm', 'entropy_shannon_P', - 'entropy_shannon_P_norm', 'l1', 'l2', 'l3', 'p1', 'p2', 'p3', 'pedestal', 'polarisation_fraction', - 'rvi', 'serd', 'serd_norm'] - if is_trans_to_tif: - self.__write_haalpha_to_tif(h_a_alpha_out_dir, h_a_alpha_out_dir, name_list) - - if is_read_to_dic: - self.__res_h_a_alpha_eigenvalue_set_T3 = self.__read_haalpha(h_a_alpha_out_dir, name_list) - return self.__res_h_a_alpha_eigenvalue_set_T3 - else: - return {} - - def api_h_a_alpha_eigenvector_set_T3(self, h_a_alpha_out_dir, h_a_alpha_eigenvector_set_T3_path, polsarpro_in_dir, is_trans_to_tif=True, is_read_to_dic=False, *args): - - """ - Cloude-Pottier eigenvector based decomposition of a coherency matrix - :param h_a_alpha_out_dir : Cloude-Pottier eigenvector - :param h_a_alpha_eigenvector_set_T3_path: h_a_alpha_eigenvector_set_T3.exe路径 - :param polsarpro_in_dir:输入porsarpro格式T3矩阵目录,包含.bin,.config - :param is_trans_to_tif:分解特征是否转换为tif - :param is_read_to_dic:分解特征是否以字典输出 - :param *args:9个可选分解特征(alpbetdelgam,Lambda,alpha,entropy,anisotropy, - CombHA,CombH1mA,Comb1mHA,Comb1mH1mA),不输出:0,输出:1 - :return : 包含分解特征的字典 - """ - if not os.path.exists(h_a_alpha_out_dir): - os.makedirs(h_a_alpha_out_dir) - self.__h_a_alpha_eigenvector_set_T3(h_a_alpha_out_dir, h_a_alpha_eigenvector_set_T3_path, polsarpro_in_dir, *args) - name_list = ['alpha', 'alpha1', 'alpha2', 'alpha3', - 'beta', 'beta1', 'beta2', 'beta3', - 'delta', 'delta1', 'delta2', 'delta3', - 'gamma', 'gamma1', 'gamma2', 'gamma3'] - if is_trans_to_tif: - self.__write_haalpha_to_tif(h_a_alpha_out_dir, h_a_alpha_out_dir, name_list) - - if is_read_to_dic: - self.__res_h_a_alpha_eigenvector_set_T3 = self.__read_haalpha(h_a_alpha_out_dir, name_list) - return self.__res_h_a_alpha_eigenvector_set_T3 - else: - return {} - - def api_read_T3_matrix(self,polsarpro_T3_dir): - """ - 读取T3矩阵,转换字典 - :param polsarpro_in_dir:输入porsarpro格式T3矩阵目录,包含.bin,.config - :return : 包含T3矩阵的字典 - """ - name_list = ['T11', 'T12_imag', 'T12_real', - 'T22', 'T13_imag', 'T13_real', - 'T33', 'T23_imag', 'T23_real'] - return self.__read_haalpha(polsarpro_T3_dir, name_list) - - def api_trans_T3_to_tif(self, out_tif_dir, polsarpro_T3_dir): - """ - 将T3矩阵从bin格式转换为tif格式 - :param out_tif_dir:保存路径 - :param polsarpro_in_dir:输入porsarpro格式T3矩阵目录,包含.bin,.config - """ - name_list = ['T11', 'T12_imag', 'T12_real', - 'T22', 'T13_imag', 'T13_real', - 'T33', 'T23_imag', 'T23_real'] - self.__write_haalpha_to_tif(out_tif_dir, polsarpro_T3_dir, name_list) - - @staticmethod - def __h_a_alpha_decomposition_T3(h_a_alpha_out_dir, h_a_alpha_decomposition_T3_path, polsarpro_in_dir, *args): - """ - 对porsarpro格式T3矩阵做Cloude-Pottier分解(H-A-Alpha分解) - :param h_a_alpha_out_dir : 输出h_a_alpha二进制数据的目录 - :param h_a_alpha_decomposition_T3_path: haalphadecompositionT3.exe路径 - :param polsarpro_in_dir:输入porsarpro格式T3矩阵目录,包含.bin,.config - :param *args:9个可选输出变量(alpbetdelgam,Lambda,alpha,entropy,anisotropy, - CombHA,CombH1mA,Comb1mHA,Comb1mH1mA),不输出:0,输出:1 - """ - if not os.path.exists(h_a_alpha_decomposition_T3_path): - raise Exception(h_a_alpha_decomposition_T3_path +' is not exists!') - - NwinFilter = 1 - offsetRow = 0 - offsetCol = 0 - - config_path = os.path.join(polsarpro_in_dir, 'config.txt') - config = open(config_path, 'r').read().split('\n', -1) - - numRow = int(config[1]) - numCol = int(config[4]) - - alpbetdelgam = int(args[0]) - Lambda = int(args[1]) - alpha = int(args[2]) - entropy = int(args[3]) - anisotropy = int(args[4]) - - CombHA = int(args[5]) - CombH1mA = int(args[6]) - Comb1mHA = int(args[7]) - Comb1mH1mA = int(args[8]) - - para_list = [h_a_alpha_decomposition_T3_path, polsarpro_in_dir, h_a_alpha_out_dir, - str(NwinFilter), str(offsetRow), str(offsetCol), str(numRow), str(numCol), - str(alpbetdelgam), str(Lambda), str(alpha), str(entropy), str(anisotropy), - str(CombHA), str(CombH1mA), str(Comb1mHA), str(Comb1mH1mA)] - cmd = ' '.join(para_list) - - result_tuple = subprocess.getstatusoutput(cmd) - if result_tuple[0] != 1 or result_tuple[1].find('error') != -1 or result_tuple[1].find('Could not open') != -1: - raise Exception(result_tuple[1]) - shutil.copyfile(config_path, os.path.join(h_a_alpha_out_dir, 'config.txt')) - - @staticmethod - def __h_a_alpha_eigenvalue_set_T3(h_a_alpha_out_dir, h_a_alpha_eigenvalue_set_T3_path, polsarpro_in_dir, *args): - - """ - Cloude-Pottier eigenvalue based decomposition of a coherency matrix - :param h_a_alpha_out_dir : Cloude-Pottier eigenvalue - :param h_a_alpha_eigenvalue_set_T3_path: h_a_alpha_eigenvalue_set_T3.exe路径 - :param polsarpro_in_dir:输入porsarpro格式T3矩阵目录,包含.bin,.config - :param *args:11个可选输出变量(eigen123,proba123,anisotropy,anisotropy12,asymetry, - polarisation_fraction,erd,rvi,pedestal,shannon,lueneburg),不输出:0,输出:1 - """ - if not os.path.exists(h_a_alpha_eigenvalue_set_T3_path): - raise Exception(h_a_alpha_eigenvalue_set_T3_path +' is not exists!') - NwinFilter = 1 - offsetRow = 0 - offsetCol = 0 - - config_path = os.path.join(polsarpro_in_dir, 'config.txt') - config = open(config_path, 'r').read().split('\n', -1) - - numRow = int(config[1]) - numCol = int(config[4]) - - eigen123 = int(args[0]) - proba123 = int(args[1]) - anisotropy = int(args[2]) - anisotropy12 = int(args[3]) - asymetry = int(args[4]) - polarisation_fraction = int(args[5]) - erd = int(args[6]) - rvi = int(args[7]) - pedestal = int(args[8]) - shannon = int(args[9]) - lueneburg = int(args[10]) - - para_list = [h_a_alpha_eigenvalue_set_T3_path, polsarpro_in_dir, h_a_alpha_out_dir, - str(NwinFilter), str(offsetRow), str(offsetCol), str(numRow), str(numCol), - str(eigen123), str(proba123), str(anisotropy), str(anisotropy12), str(asymetry), - str(polarisation_fraction), str(erd), str(rvi), str(pedestal), - str(shannon), str(lueneburg)] - cmd = ' '.join(para_list) - - result_tuple = subprocess.getstatusoutput(cmd) - if result_tuple[0] != 1 or result_tuple[1].find('error') != -1 or result_tuple[1].find('Could not open') != -1: - raise Exception(result_tuple[1]) - shutil.copyfile(config_path, os.path.join(h_a_alpha_out_dir, 'config.txt')) - - @staticmethod - def __h_a_alpha_eigenvector_set_T3(h_a_alpha_out_dir, h_a_alpha_eigenvector_set_T3_path, polsarpro_in_dir, *args): - - """ - Cloude-Pottier eigenvector based decomposition of a coherency matrix - :param h_a_alpha_out_dir : Cloude-Pottier eigenvector - :param h_a_alpha_eigenvector_set_T3_set_T3_path: h_a_alpha_eigenvector_set_T3.exe路径 - :param polsarpro_in_dir:输入porsarpro格式T3矩阵目录,包含.bin,.config - :param *args:5个可选输出变量(alpha123,beta123,delta123,gamma123,alpbetdelgam),不输出:0,输出:1 - """ - if not os.path.exists(h_a_alpha_eigenvector_set_T3_path): - raise Exception(h_a_alpha_eigenvector_set_T3_path +' is not exists!') - NwinFilter = 1 - offsetRow = 0 - offsetCol = 0 - - config_path = os.path.join(polsarpro_in_dir, 'config.txt') - config = open(config_path, 'r').read().split('\n', -1) - - numRow = int(config[1]) - numCol = int(config[4]) - - alpha123 = int(args[0]) - beta123 = int(args[1]) - delta123 = int(args[2]) - gamma123 = int(args[3]) - alpbetdelgam = int(args[4]) - - para_list = [h_a_alpha_eigenvector_set_T3_path, polsarpro_in_dir, h_a_alpha_out_dir, - str(NwinFilter), str(offsetRow), str(offsetCol), str(numRow), str(numCol), - str(alpha123), str(beta123), str(delta123), str(gamma123), str(alpbetdelgam)] - cmd = ' '.join(para_list) - - result_tuple = subprocess.getstatusoutput(cmd) - if result_tuple[0] != 1 or result_tuple[1].find('error') != -1 or result_tuple[1].find('Could not open') != -1: - raise Exception(result_tuple[1]) - shutil.copyfile(config_path, os.path.join(h_a_alpha_out_dir, 'config.txt')) - - def __read_haalpha(self, h_a_alpha_dir, name_list): - """ - 读取H-A-Alpha分解二进制数据,输出为矩阵格式的字典 - :param h_a_alpha_dir : h_a_alpha二进制数据的目录,包含.bin,.config - :name_list : 需要组合的名称集合['entropy', 'anisotropy', 'alpha', 'beta', 'delta', 'gamma', 'lambda', - 'combination_1mH1mA', 'combination_1mHA', 'combination_H1mA', 'combination_HA'] - :return : 包含H-A-Alpha矩阵信息的字典 - """ - dir = os.path.join(h_a_alpha_dir, '*.bin') - bin_paths = list(glob.glob(dir)) - haalpha_dic ={} - for name in name_list: - path = os.path.join(h_a_alpha_dir, name + '.bin') - if path in bin_paths: - img = self.__read_bin_to_img(path) - haalpha_dic.update({name: img}) - return haalpha_dic - - def standardization(self, data, num=1): - # 矩阵标准化到[0,1] - data[np.isnan(data)] = np.min(data) # 异常值填充为0 - _range = np.max(data) - np.min(data) - return (data - np.min(data)) / _range * num - - def __write_haalpha_to_tif(self, out_tif_dir, h_a_alpha_dir, name_list): - """ - 读取H-A-Alpha分解二进制数据,输出为矩阵格式的字典 - :param out_tif_dir : tif的输出路径 - :param h_a_alpha_dir : h_a_alpha二进制数据的目录,包含.bin,.config - :name_list : 需要组合的名称集合['entropy', 'anisotropy', 'alpha', 'beta', 'delta', 'gamma', 'lambda', - 'combination_1mH1mA', 'combination_1mHA', 'combination_H1mA', 'combination_HA'] - - """ - dir = os.path.join(h_a_alpha_dir, '*.bin') - bin_paths = list(glob.glob(dir)) - - for name in name_list: - in_path = os.path.join(h_a_alpha_dir, name + '.bin') - out_path = os.path.join(out_tif_dir, name + '.tif') - if in_path in bin_paths: - img_array = self.__read_bin_to_img(in_path) - if self.__normalization is True: - img_array = self.standardization(img_array, num=1) - out_image = Image.fromarray(img_array) - out_image.save(out_path) - - @staticmethod - def __read_bin_to_img(bin_path): - """ - 读取bin格式二进制数据,输出为矩阵 - :param bin_path : bin文件的路径,包含.bin,.config - :return : 矩阵信息 - """ - (bin_dir, bin_name) = os.path.split(bin_path) - config_path = os.path.join(bin_dir, 'config.txt') - config = open(config_path, 'r').read().split('\n', -1) - rows = int(config[1]) - cols = int(config[4]) - - bin_file = open(bin_path, 'rb') # 打开二进制文件 - size = os.path.getsize(bin_path) # 获得文件大小 - if size < rows*cols*4: - raise Exception('bin size less than rows*cols*4! size:', size, 'byte, rows:', rows, 'cols:', cols) - - img = np.zeros([rows, cols], dtype=np.float32) - for row in range(rows): - data = bin_file.read(4 * cols) # 每次读取一行的二进制数据 - row_data = struct.unpack('f' * cols, data) # 转为一行float数据 - img[row, :] = row_data - bin_file.close() - return img - - -# if __name__ == '__main__': - # h_a_alpha_decomposition_T3_path = 'D:\\PolSARpro_v4.2.0\\Soft\data_process_sngl\\h_a_alpha_decomposition_T3.exe' - # h_a_alpha_eigenvalue_set_T3_path = 'D:\\PolSARpro_v4.2.0\\Soft\data_process_sngl\\h_a_alpha_eigenvalue_set_T3.exe' - # h_a_alpha_eigenvector_set_T3_path = 'D:\\PolSARpro_v4.2.0\\Soft\data_process_sngl\\h_a_alpha_eigenvector_set_T3.exe' - # polsarpro_in_dir = 'D:\\PolSARpro_v4.2.0\\in' - # haalpha_out_dir = 'D:\\PolSARpro_v4.2.0\\out' - # h_a_alpha_eigenvalue_set_T3_out = 'D:\\PolSARpro_v4.2.0\\out\\h_a_alpha_eigenvalue_set_T3' - # h_a_alpha_eigenvector_set_T3_out = 'D:\\PolSARpro_v4.2.0\\out\\h_a_alpha_eigenvector_set_T3' - # - # haa = PspHAAlphaDecomposition() - # h_a_alpha_features = haa.api_creat_h_a_alpha_features(haalpha_out_dir, h_a_alpha_decomposition_T3_path, h_a_alpha_eigenvalue_set_T3_path, h_a_alpha_eigenvector_set_T3_path, polsarpro_in_dir) - - - # haa = PspHAAlphaDecomposition(normalization=True) - # psp_path = r"I:\MicroWorkspace\product\C-SAR\SoilSalinity\GF3B_MYC_QPSI_003581_E120.6_N31.3_20220729_L1A_AHV_L10000073024_RPCpsp_t3" - # t3_path = r"I:\MicroWorkspace\product\C-SAR\SoilSalinity\t3" - # exe_dir = r"I:\microproduct\soilSalinity/" - # haa.api_creat_h_a_alpha_features(h_a_alpha_out_dir=t3_path, - # h_a_alpha_decomposition_T3_path= exe_dir + 'h_a_alpha_decomposition_T3.exe', - # h_a_alpha_eigenvalue_set_T3_path= exe_dir + 'h_a_alpha_eigenvalue_set_T3.exe', - # h_a_alpha_eigenvector_set_T3_path=exe_dir +'h_a_alpha_eigenvector_set_T3.exe', - # polsarpro_in_dir=psp_path) - - # print('done') diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/pspLeeRefinedFilterC2.py b/landcover-L-SAR/tool/algorithm/polsarpro/pspLeeRefinedFilterC2.py deleted file mode 100644 index 079e090..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/pspLeeRefinedFilterC2.py +++ /dev/null @@ -1,170 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:pspLeeRefinedFilterC2.py -@Function: -@Contact: -@Author:SHJ -@Date:2021/11/5 -@Version:1.0.0 -""" -import logging -import os -import shutil -import subprocess -import glob -import numpy as np -import struct -from PIL import Image - -logger = logging.getLogger("mylog") - - -class LeeRefinedFilterC2: - """ - 调用polsarpro4.2.0的lee_refined_filter_C2.exe做精致Lee滤波 - """ - - def __init__(self, exeFilterName='lee_refined_filter_C2.exe'): - self.__exeName = exeFilterName - pass - - def api_lee_refined_filter_C2( - self, - exeDir, - inC2Dir, - outDir, - off_row, - off_col, - Nrow, - Ncol, - Nwin=7, - Nlook=1): - """ - :param exeDir:exe所在目录 - :param inC2Dir:C2矩阵目录 - :param outDir:输出目录 - :param off_row:行偏移,行启始位置 - :param off_col:列偏移,列启始位置 - :param Nrow:终止行 - :param Ncol:终止列 - :param Nwin:滤波窗口大小 3 5 7 9 11 - :param Nlook:一般是1 - """ - if len(exeDir) == 0: - if not os.path.exists(self.__exeName): - raise Exception(self.__exeName + ' not exists.') - exePath = self.__exeName - else: - if not os.path.exists(exeDir + '\\' + self.__exeName): - raise Exception( - exeDir + - '\\' + - self.__exeName + - ' not exists.') - exePath = exeDir + '\\' + self.__exeName - - # if not self._checkT3Matrix(inT3Dir): - # raise Exception('T3 Matrix check failed.') - if not os.path.exists(outDir): - os.makedirs(outDir) - if (Nwin % 2) == 0 or Nwin < 0: # 如果为偶数或小于0,则使用默认值 - Nwin = 7 - - Off_lig = off_row - Off_col = off_col - Sub_Nlig = Nrow - Sub_Ncol = Ncol - - para_list = [ - exePath, - inC2Dir, - outDir, - Nlook, - Nwin, - Off_lig, - Off_col, - Sub_Nlig, - Sub_Ncol] - cmd = ' '.join(str(i) for i in para_list) - result_tuple = subprocess.getstatusoutput(cmd) - if result_tuple[0] != 1 or result_tuple[1].find('error') != -1: - raise Exception(result_tuple[1]) - config_path = os.path.join(inC2Dir, 'config.txt') - if config_path != os.path.join(outDir, 'config.txt'): - shutil.copyfile(config_path, os.path.join(outDir, 'config.txt')) - @staticmethod - def _checkC2Matrix(C2Dir): - # 检测C2矩阵 - if not os.path.exists(C2Dir): - return False - file_name_in_out = ['C11.bin', 'C12_real.bin', 'C12_imag.bin', 'C22.bin','config.txt'] - for item in file_name_in_out: - if not os.path.exists(C2Dir + "\\" + item): - return False - return True - def write_bin_to_tif(self, out_tif_dir, bin_dir): - """ - 读取H-A-Alpha分解二进制数据,输出为矩阵格式的字典 - :param out_tif_dir : tif的输出路径 - :param bin_dir : 二进制数据的目录,包含.bin,.config - :return out_tif_path: 生成tif的路径字典 - """ - bin_paths = list(glob.glob(os.path.join(bin_dir, '*.bin'))) - out_tif_path = {} - for in_path in bin_paths: - name = os.path.split(in_path)[1].split('.')[0] - out_path = os.path.join(out_tif_dir, name + '.tif') - out_tif_path.update({name: out_path}) - if os.path.exists(os.path.split(out_path)[0]) is False: - os.makedirs(os.path.split(out_path)[0]) - img_array = self.__read_bin_to_img(in_path) - img_array[np.isnan(img_array)] = 0 # 异常值填充为0 - # img_array = self.standardization(img_array) # 数据标准化到[0,1] - out_image = Image.fromarray(img_array) - out_image.save(out_path) - return out_tif_path - @staticmethod - - def __read_bin_to_img(bin_path): - """ - 读取bin格式二进制数据,输出为矩阵 - :param bin_path : bin文件的路径,包含.bin,.config - :return : 矩阵信息 - """ - (bin_dir, bin_name) = os.path.split(bin_path) - config_path = os.path.join(bin_dir, 'config.txt') - config = open(config_path, 'r').read().split('\n', -1) - rows = int(config[1]) - cols = int(config[4]) - - bin_file = open(bin_path, 'rb') # 打开二进制文件 - size = os.path.getsize(bin_path) # 获得文件大小 - if size < rows * cols * 4: - raise Exception( - 'bin size less than rows*cols*4! size:', - size, - 'byte, rows:', - rows, - 'cols:', - cols) - - img = np.zeros([rows, cols], dtype=np.float32) - for row in range(rows): - data = bin_file.read(4 * cols) # 每次读取一行的二进制数据 - row_data = struct.unpack('f' * cols, data) # 转为一行float数据 - img[row, :] = row_data - bin_file.close() - return img - -if __name__ == '__main__': - tp =LeeRefinedFilterC2() - inC2Dir=r'E:\MicroWorkspace\LandCover\HHHV1' - outDir =r'E:\MicroWorkspace\LandCover\HHHV1_f' - off_row = 0 - off_col = 0 - Nrow = 666 - Ncol = 746 - tp.api_lee_refined_filter_C2( '',inC2Dir,outDir,off_row,off_col,Nrow,Ncol) - tp.write_bin_to_tif(outDir,outDir) - print('done') \ No newline at end of file diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/pspLeeRefinedFilterT3.py b/landcover-L-SAR/tool/algorithm/polsarpro/pspLeeRefinedFilterT3.py deleted file mode 100644 index e8c3911..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/pspLeeRefinedFilterT3.py +++ /dev/null @@ -1,104 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:pspLeeRefinedFilterT3.py -@Function: Cloude-Pottier eigenvector/eigenvalue based decomposition of a 3x3 coherency matrix [T3] - (Averaging using a sliding window) -@Contact: -@Author:LVY -@Date:2021/10/12 9:06 -@Version:1.0.0 -""" -import logging -import os -import shutil -import subprocess - -logger = logging.getLogger("mylog") - - -class LeeRefinedFilterT3: - """ - 调用polsarpro4.2.0的lee_refined_filter_T3.exe做精致Lee滤波 - """ - - def __init__(self, exeFilterName='lee_refined_filter_T3.exe'): - self.__exeName = exeFilterName - pass - - def api_lee_refined_filter_T3( - self, - exeDir, - inT3Dir, - outDir, - rectX, - rectY, - rectWidth, - rectHeight, - Nwin=7, - Nlook=1): - """ - :param exeDir:exe所在目录 - :param inT3Dir:T3矩阵目录 - :param outDir:输出目录 - :param rectX:有效区域x - :param rectY:有效区域y - :param rectWidth:有效区域宽 - :param rectHeight:有效区域高 - :param Nwin:滤波窗口大小 3 5 7 9 11 - :param Nlook:一般是1 - """ - if len(exeDir) == 0: - if not os.path.exists(self.__exeName): - raise Exception(self.__exeName + ' not exists.') - exePath = self.__exeName - else: - if not os.path.exists(exeDir + '\\' + self.__exeName): - raise Exception( - exeDir + - '\\' + - self.__exeName + - ' not exists.') - exePath = exeDir + '\\' + self.__exeName - - if not self._checkT3Matrix(inT3Dir): - raise Exception('T3 Matrix check failed.') - if not os.path.exists(outDir): - os.makedirs(outDir) - if (Nwin % 2) == 0 or Nwin < 0: # 如果为偶数或小于0,则使用默认值 - Nwin = 7 - - Off_lig = rectX - Off_col = rectY - Sub_Nlig = rectWidth - Sub_Ncol = rectHeight - - para_list = [ - exePath, - inT3Dir, - outDir, - Nlook, - Nwin, - Off_lig, - Off_col, - Sub_Nlig, - Sub_Ncol] - cmd = ' '.join(str(i) for i in para_list) - config_path = os.path.join(inT3Dir, 'config.txt') - shutil.copyfile(config_path, os.path.join(outDir, 'config.txt')) - result_tuple = subprocess.getstatusoutput(cmd) - - if result_tuple[0] != 1 or result_tuple[1].find('error') != -1: - raise Exception(result_tuple[1]) - @staticmethod - def _checkT3Matrix(T3Dir): - # 检测T3矩阵 - if not os.path.exists(T3Dir): - return False - file_name_in_out = ['T11.bin', 'T12_real.bin', 'T12_imag.bin', - 'T13_real.bin', 'T13_imag.bin', 'T22.bin', - 'T23_real.bin', 'T23_imag.bin', 'T33.bin'] - for item in file_name_in_out: - if not os.path.exists(T3Dir + "\\" + item): - return False - return True diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/pspSurfaceInversion.py b/landcover-L-SAR/tool/algorithm/polsarpro/pspSurfaceInversion.py deleted file mode 100644 index b8463a2..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/pspSurfaceInversion.py +++ /dev/null @@ -1,393 +0,0 @@ -import logging -import os -import shutil -import subprocess - -logger = logging.getLogger("mylog") - - -class SurfaceInversionDubois: - """ - 调用polsarpro4.2.0的surface_inversion_dubois.exe做土壤水分反演 - """ - - def __init__(self, exeFilterName='surface_inversion_dubois.exe'): - self.__exeName = exeFilterName - pass - - def api_surface_inversion_dubois( - self, - exeDir, - inT3Dir, - outDir, - incidence, - rectX, - rectY, - row, - col, - frequency, # GHZ - angleFlag, # 0:deg, 1:rad - ): - """ - :param exeDir:exe所在目录 - :param inT3Dir:T3矩阵目录 - :param outDir:输出目录 - :param rectX:有效区域x - :param rectY:有效区域y - :param rectWidth:有效区域宽 - :param rectHeight:有效区域高 - :param Nwin:滤波窗口大小 3 5 7 9 11 - :param Nlook:一般是1 - """ - if len(exeDir) == 0: - if not os.path.exists(self.__exeName): - raise Exception(self.__exeName + ' not exists.') - exePath = self.__exeName - else: - if not os.path.exists(exeDir + '\\' + self.__exeName): - raise Exception( - exeDir + - '\\' + - self.__exeName + - ' not exists.') - exePath = exeDir + '\\' + self.__exeName - - if not self._checkT3Matrix(inT3Dir): - raise Exception('T3 Matrix check failed.') - if not os.path.exists(outDir): - os.makedirs(outDir) - - Off_lig = rectX - Off_col = rectY - Sub_Nlig = row - Sub_Ncol = col - dataFormat = 'T3' - calibration_flag = 1 - calibration_coefficient = 0.0 - threshold_HHHH_VVVV = 0.0 - threshold_HVHV_VVVV = 0.0 - - para_list = [ - exePath, - inT3Dir, - outDir, - dataFormat, - incidence, - Off_lig, - Off_col, - Sub_Nlig, - Sub_Ncol, - frequency, # GHZ - angleFlag, - ] - - cmd = "surface_inversion_dubois.exe -id {} -od {} -iodf {} -ang {} -ofr {} -ofc {} -fnr {} -fnc {} -fr {} -un {} -caf {} -cac {} -th1 {} -th2 {}".format( - inT3Dir, outDir, dataFormat, incidence, Off_lig, Off_col, Sub_Nlig, Sub_Ncol, frequency, angleFlag, - calibration_flag, calibration_coefficient, threshold_HHHH_VVVV, threshold_HVHV_VVVV) - - logger.info('surface_inversion_dubois:{}'.format(cmd)) - result = os.system(cmd) - logger.info('cmd_result:{}'.format(result)) - logger.info('surface_inversion_dubois finish!') - - config_path = os.path.join(inT3Dir, 'config.txt') - shutil.copyfile(config_path, os.path.join(outDir, 'config.txt')) - - # cmd = ' '.join(str(i) for i in para_list) - # config_path = os.path.join(inT3Dir, 'config.txt') - # shutil.copyfile(config_path, os.path.join(outDir, 'config.txt')) - # result_tuple = subprocess.getstatusoutput(cmd) - # - # if result_tuple[0] != 1 or result_tuple[1].find('error') != -1: - # raise Exception(result_tuple[1]) - @staticmethod - def _checkT3Matrix(T3Dir): - # 检测T3矩阵 - if not os.path.exists(T3Dir): - return False - file_name_in_out = ['T11.bin', 'T12_real.bin', 'T12_imag.bin', - 'T13_real.bin', 'T13_imag.bin', 'T22.bin', - 'T23_real.bin', 'T23_imag.bin', 'T33.bin'] - for item in file_name_in_out: - if not os.path.exists(T3Dir + "\\" + item): - return False - return True - - -class SurfaceInversionHisto: - """ - 调用polsarpro4.2.0的surface_inversion_histo.exe做土壤水分反演 - """ - - def __init__(self, exeFilterName='surface_inversion_histo.exe'): - self.__exeName = exeFilterName - pass - - def api_surface_inversion_histo( - self, - exeDir, - inT3Dir, - outDir, - rectX, - rectY, - rectWidth, - rectHeight, - Nwin=7, - Nlook=1): - """ - :param exeDir:exe所在目录 - :param inT3Dir:T3矩阵目录 - :param outDir:输出目录 - :param rectX:有效区域x - :param rectY:有效区域y - :param rectWidth:有效区域宽 - :param rectHeight:有效区域高 - :param Nwin:滤波窗口大小 3 5 7 9 11 - :param Nlook:一般是1 - """ - if len(exeDir) == 0: - if not os.path.exists(self.__exeName): - raise Exception(self.__exeName + ' not exists.') - exePath = self.__exeName - else: - if not os.path.exists(exeDir + '\\' + self.__exeName): - raise Exception( - exeDir + - '\\' + - self.__exeName + - ' not exists.') - exePath = exeDir + '\\' + self.__exeName - - if not self._checkT3Matrix(inT3Dir): - raise Exception('T3 Matrix check failed.') - if not os.path.exists(outDir): - os.makedirs(outDir) - if (Nwin % 2) == 0 or Nwin < 0: # 如果为偶数或小于0,则使用默认值 - Nwin = 7 - - Off_lig = rectX - Off_col = rectY - Sub_Nlig = rectWidth - Sub_Ncol = rectHeight - - para_list = [ - exePath, - inT3Dir, - outDir, - Nlook, - Nwin, - Off_lig, - Off_col, - Sub_Nlig, - Sub_Ncol] - cmd = ' '.join(str(i) for i in para_list) - config_path = os.path.join(inT3Dir, 'config.txt') - shutil.copyfile(config_path, os.path.join(outDir, 'config.txt')) - result_tuple = subprocess.getstatusoutput(cmd) - - if result_tuple[0] != 1 or result_tuple[1].find('error') != -1: - raise Exception(result_tuple[1]) - @staticmethod - def _checkT3Matrix(T3Dir): - # 检测T3矩阵 - if not os.path.exists(T3Dir): - return False - file_name_in_out = ['T11.bin', 'T12_real.bin', 'T12_imag.bin', - 'T13_real.bin', 'T13_imag.bin', 'T22.bin', - 'T23_real.bin', 'T23_imag.bin', 'T33.bin'] - for item in file_name_in_out: - if not os.path.exists(T3Dir + "\\" + item): - return False - return True - - -class SurfaceInversionOh: - """ - 调用polsarpro4.2.0的surface_inversion_oh.exe做土壤水分反演 - """ - - def __init__(self, exeFilterName='surface_inversion_oh.exe'): - self.__exeName = exeFilterName - pass - - def api_surface_inversion_oh( - self, - exeDir, - inT3Dir, - outDir, - rectX, - rectY, - rectWidth, - rectHeight, - Nwin=7, - Nlook=1): - """ - :param exeDir:exe所在目录 - :param inT3Dir:T3矩阵目录 - :param outDir:输出目录 - :param rectX:有效区域x - :param rectY:有效区域y - :param rectWidth:有效区域宽 - :param rectHeight:有效区域高 - :param Nwin:滤波窗口大小 3 5 7 9 11 - :param Nlook:一般是1 - """ - if len(exeDir) == 0: - if not os.path.exists(self.__exeName): - raise Exception(self.__exeName + ' not exists.') - exePath = self.__exeName - else: - if not os.path.exists(exeDir + '\\' + self.__exeName): - raise Exception( - exeDir + - '\\' + - self.__exeName + - ' not exists.') - exePath = exeDir + '\\' + self.__exeName - - if not self._checkT3Matrix(inT3Dir): - raise Exception('T3 Matrix check failed.') - if not os.path.exists(outDir): - os.makedirs(outDir) - if (Nwin % 2) == 0 or Nwin < 0: # 如果为偶数或小于0,则使用默认值 - Nwin = 7 - - Off_lig = rectX - Off_col = rectY - Sub_Nlig = rectWidth - Sub_Ncol = rectHeight - - para_list = [ - exePath, - inT3Dir, - outDir, - Nlook, - Nwin, - Off_lig, - Off_col, - Sub_Nlig, - Sub_Ncol] - cmd = ' '.join(str(i) for i in para_list) - config_path = os.path.join(inT3Dir, 'config.txt') - shutil.copyfile(config_path, os.path.join(outDir, 'config.txt')) - result_tuple = subprocess.getstatusoutput(cmd) - - if result_tuple[0] != 1 or result_tuple[1].find('error') != -1: - raise Exception(result_tuple[1]) - @staticmethod - def _checkT3Matrix(T3Dir): - # 检测T3矩阵 - if not os.path.exists(T3Dir): - return False - file_name_in_out = ['T11.bin', 'T12_real.bin', 'T12_imag.bin', - 'T13_real.bin', 'T13_imag.bin', 'T22.bin', - 'T23_real.bin', 'T23_imag.bin', 'T33.bin'] - for item in file_name_in_out: - if not os.path.exists(T3Dir + "\\" + item): - return False - return True - - -class SurfaceInversionOh2004: - """ - 调用polsarpro4.2.0的surface_inversion_oh2004.exe做土壤水分反演 - """ - - def __init__(self, exeFilterName='surface_inversion_oh2004.exe'): - self.__exeName = exeFilterName - pass - - def api_surface_inversion_oh2004( - self, - exeDir, - inT3Dir, - outDir, - incidence, - rectY, - rectX, - row, - col, - frequency, # GHZ - angleFlag): - """ - :param exeDir:exe所在目录 - :param inT3Dir:T3矩阵目录 - :param outDir:输出目录 - :param rectX:有效区域x - :param rectY:有效区域y - :param rectWidth:有效区域宽 - :param rectHeight:有效区域高 - :param Nwin:滤波窗口大小 3 5 7 9 11 - :param Nlook:一般是1 - """ - if len(exeDir) == 0: - if not os.path.exists(self.__exeName): - raise Exception(self.__exeName + ' not exists.') - exePath = self.__exeName - else: - if not os.path.exists(exeDir + '\\' + self.__exeName): - raise Exception( - exeDir + - '\\' + - self.__exeName + - ' not exists.') - exePath = exeDir + '\\' + self.__exeName - - if not self._checkT3Matrix(inT3Dir): - raise Exception('T3 Matrix check failed.') - if not os.path.exists(outDir): - os.makedirs(outDir) - - Off_lig = rectX - Off_col = rectY - Sub_Nlig = row - Sub_Ncol = col - dataFormat = 'T3' - threshold_mv = 1.0 - threshold_s = 7.0 - - para_list = [ - exePath, - inT3Dir, - outDir, - dataFormat, - incidence, - Off_lig, - Off_col, - Sub_Nlig, - Sub_Ncol, - frequency, # GHZ - angleFlag, - threshold_mv, - threshold_s] - cmd = "surface_inversion_oh2004.exe -id {} -od {} -iodf {} -ang {} -ofr {} -ofc {} -fnr {} -fnc {} -fr {} -un {} -th1 {} -th2 {}".format( - inT3Dir, outDir, dataFormat, incidence, Off_lig, Off_col, Sub_Nlig, Sub_Ncol, frequency, angleFlag, threshold_mv, threshold_s) - - logger.info('surface_inversion_oh2004:{}'.format(cmd)) - result = os.system(cmd) - logger.info('cmd_result:{}'.format(result)) - logger.info('surface_inversion_oh2004 finish!') - - - config_path = os.path.join(inT3Dir, 'config.txt') - shutil.copyfile(config_path, os.path.join(outDir, 'config.txt')) - # cmd = ' '.join(str(i) for i in para_list) - # result_tuple = subprocess.getstatusoutput(cmd) - # # - # if result_tuple[0] != 1 or result_tuple[1].find('error') != -1: - # raise Exception(result_tuple[1]) - @staticmethod - def _checkT3Matrix(T3Dir): - # 检测T3矩阵 - if not os.path.exists(T3Dir): - return False - file_name_in_out = ['T11.bin', 'T12_real.bin', 'T12_imag.bin', - 'T13_real.bin', 'T13_imag.bin', 'T22.bin', - 'T23_real.bin', 'T23_imag.bin', 'T33.bin'] - # file_name_in_out = ['T11.img', 'T12_real.img', 'T12_imag.img', - # 'T13_real.img', 'T13_imag.img', 'T22.img', - # 'T23_real.img', 'T23_imag.img', 'T33.img'] - for item in file_name_in_out: - if not os.path.exists(T3Dir + "\\" + item): - return False - return True \ No newline at end of file diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/pspTouziDecomposition.py b/landcover-L-SAR/tool/algorithm/polsarpro/pspTouziDecomposition.py deleted file mode 100644 index 35ed6ca..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/pspTouziDecomposition.py +++ /dev/null @@ -1,146 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:pspTouziDecomposition.py -@Function: -@Contact: -@Author:LVY -@Date:2021/10/14 10:11 -@Version:1.0.0 -""" -import os -import logging -from tool.algorithm.polsarpro.polarizationDecomposition import ModTouzi as TouziDecomp -from osgeo import gdal -import multiprocessing -from tool.algorithm.block.blockprocess import BlockProcess -import shutil -from tool.algorithm.image.ImageHandle import ImageHandler -from tool.file.fileHandle import fileHandle -logger = logging.getLogger("mylog") -file =fileHandle(False) - -class PspTouziDecomposition: - """ - Touzi分解 - """ - def __init__(self, inDic, outDir): - """ - :param inDic:T3矩阵目录 - :param outDir:输出目录 - """ - self.__inDic = inDic - self.__outDir = outDir - self.__DecompostFlag = False - if self._checkTifFileDic(self.__inDic) is False: - return False - if not os.path.exists(self.__outDir): - os.makedirs(self.__outDir) - - def api_Touzi_decomposition_TIF(self, Nwin = 5): - """ - :param Nwin:滤波窗口大小 3 5 7 9 11 - """ - bandHH = gdal.Open(self.__inDic["HH"]) - bandHV = gdal.Open(self.__inDic["HV"]) - bandVH = gdal.Open(self.__inDic["VH"]) - bandVV = gdal.Open(self.__inDic["VV"]) - bandAll = [bandHH, bandHV, bandVH, bandVV] - decomposition = TouziDecomp(bandAll, Nwin) - decomposition.get_result(self.__outDir) - return True - - def Touzi_decomposition_TIF(self,hh_path,hv_path,vh_path,vv_path,out_dir,suffix,Nwin = 5): - """ - :param Nwin:滤波窗口大小 3 5 7 9 11 - """ - bandHH = gdal.Open(hh_path) - bandHV = gdal.Open(hv_path) - bandVH = gdal.Open(vh_path) - bandVV = gdal.Open(vv_path) - bandAll = [bandHH, bandHV, bandVH, bandVV] - decomposition = TouziDecomp(bandAll, Nwin) - decomposition.get_result_block(out_dir, suffix) - return True - - @staticmethod - def _checkTifFileDic(inDic): - file_name_in_out = ['HH', 'VV', 'HV', 'VH'] - for item in file_name_in_out: - if item in inDic: - print(inDic[item]) - if not os.path.exists(os.path.join(inDic[item])): - return False - else: - return False - return True - - def Touzi_decomposition_multiprocessing(self): - - #创建工作文件夹 - src_path = os.path.join(self.__outDir, "src_img") - block_path = os.path.join(self.__outDir, "block") - decomposition_path = os.path.join(self.__outDir, "feature") - file.creat_dirs([src_path,block_path,decomposition_path]) - - shutil.copyfile(self.__inDic["HH"], os.path.join(src_path, "HH.tif")) - shutil.copyfile(self.__inDic["HV"], os.path.join(src_path, "HV.tif")) - shutil.copyfile(self.__inDic["VH"], os.path.join(src_path, "VH.tif")) - shutil.copyfile(self.__inDic["VV"], os.path.join(src_path, "VV.tif")) - self.__cols = ImageHandler.get_img_width(self.__inDic["HH"]) - self.__rows = ImageHandler.get_img_height(self.__inDic["HH"]) - # 分块 - bp = BlockProcess() - block_size = bp.get_block_size(self.__rows, self.__cols) - bp.cut(src_path, block_path, ['tif', 'tiff'], 'tif', block_size) - logger.info('blocking tifs success!') - - img_dir, img_name = bp.get_file_names(block_path, ['tif']) - dir_dict = bp.get_same_img(img_dir, img_name) - - hh_list, vv_list, hv_list, vh_list = None, None, None, None - for key in dir_dict.keys(): - tmp = key.split('_', 2)[0] - if tmp == 'HH': - hh_list = dir_dict[key] - elif tmp == 'VV': - vv_list = dir_dict[key] - elif tmp == 'HV': - hv_list = dir_dict[key] - elif tmp == 'VH': - vh_list = dir_dict[key] - - processes_num = min([len(hh_list), multiprocessing.cpu_count() - 1]) - - # 开启多进程处理 - pool = multiprocessing.Pool(processes=processes_num) - - for i in range(len(hh_list)): - suffix = bp.get_suffix(os.path.basename(hh_list[i])) - # self.Touzi_decomposition_TIF(hh_list[i], hv_list[i], vh_list[i], vv_list[i], block_path, suffix,5) - pool.apply_async(self.Touzi_decomposition_TIF, (hh_list[i], hv_list[i], vh_list[i], vv_list[i], decomposition_path, suffix,5)) - logger.info('total:%s, block:%s touzi!', len(hh_list), i) - - pool.close() - pool.join() - # 合并处理后的影像 - bp.combine(decomposition_path, self.__cols, self.__rows, self.__outDir, file_type=['tif'], datetype='float16') - - file.del_folder(src_path) - file.del_folder(block_path) - file.del_folder(decomposition_path) - pass - - -# if __name__ == '__main__': -# dir = {} -# dir.update({"HH":"I:\preprocessed\HH_preprocessed.tif"}) -# dir.update({"HV":"I:\preprocessed\HV_preprocessed.tif"}) -# dir.update({"VH":"I:\preprocessed\VH_preprocessed.tif"}) -# dir.update({"VV":"I:\preprocessed\VV_preprocessed.tif"}) -# -# -# p = PspTouziDecomposition(dir, "I:/preprocessed/") -# p.Touzi_decomposition_multiprocessing() -# pass - diff --git a/landcover-L-SAR/tool/algorithm/polsarpro/pspYamaguchiDecomposition.py b/landcover-L-SAR/tool/algorithm/polsarpro/pspYamaguchiDecomposition.py deleted file mode 100644 index dd4f9e8..0000000 --- a/landcover-L-SAR/tool/algorithm/polsarpro/pspYamaguchiDecomposition.py +++ /dev/null @@ -1,104 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project:__init__.py -@File:pspFreemanDecomposition.py -@Function: -@Contact: -@Author:LVY -@Date:2021/10/12 18:45 -@Version:1.0.0 -""" - -import os -import shutil -import subprocess -import logging -logger = logging.getLogger("mylog") - - -class PspYamaguchiDecomposition: - """ - Yamaguchi yamaguchi_3components_decomposition_T3.exe yamaguchi_4components_decomposition_T3.exe - """ - - def __init__( - self, - exeDir, - inT3Dir, - outDir, - exeDecomposeName='yamaguchi_4components_decomposition_T3.exe'): - """ - :param exeDir:exe所在目录 - :param inT3Dir:T3矩阵目录 - :param outDir:输出目录 - """ - self.__exeName = exeDecomposeName - self.__exeDir = exeDir - self.__inT3Dir = inT3Dir - self.__outDir = outDir - self.__DecompostFlag = False - pass - - def api_yamaguchi_4components_decomposition_T3( - self, rectX, rectY, rectWidth, rectHeight, Nwin=1): - """ - :param rectX:有效区域x - :param rectY:有效区域y - :param rectWidth:有效区域宽 - :param rectHeight:有效区域高 - :param Nwin :Size of the (Nwin, Nwin) sliding window used to compute local estimates. (int) - """ - if self.__DecompostFlag: - return True - if len(self.__exeDir) == 0: - if not os.path.exists(self.__exeName): - logger.error(self.__exeName + ' not exists.') - return False - exePath = self.__exeName - else: - if not os.path.exists(self.__exeDir + '\\' + self.__exeName): - logger.error(self.__exeName + ' not exists.') - return False - exePath = self.__exeDir + '\\' + self.__exeName - - if not self._checkT3Matrix(self.__inT3Dir): - logger.error('T3 Matrix check failed.') - return False - if not os.path.exists(self.__outDir): - os.makedirs(self.__outDir) - - Off_lig = rectX - Off_col = rectY - Sub_Nlig = rectWidth - Sub_Ncol = rectHeight - - para_list = [ - exePath, - self.__inT3Dir, - self.__outDir, - Nwin, - Off_lig, - Off_col, - Sub_Nlig, - Sub_Ncol] - cmd = " ".join(str(i) for i in para_list) - config_path = os.path.join(self.__inT3Dir, 'config.txt') - shutil.copyfile(config_path, os.path.join(self.__outDir, 'config.txt')) - result_tuple = subprocess.getstatusoutput(cmd) - - if result_tuple[0] != 1 or result_tuple[1].find('error') != -1: - raise Exception(result_tuple[1]) - self.__DecompostFlag = True - return True - @staticmethod - def _checkT3Matrix(T3Dir): - # 检测T3矩阵 - if not os.path.exists(T3Dir): - return False - file_name_in_out = ['T11.bin', 'T12_real.bin', 'T12_imag.bin', - 'T13_real.bin', 'T13_imag.bin', 'T22.bin', - 'T23_real.bin', 'T23_imag.bin', 'T33.bin'] - for item in file_name_in_out: - if not os.path.exists(T3Dir + "\\" + item): - return False - return True diff --git a/landcover-L-SAR/tool/algorithm/transforml1a/SAR_GEO.cp38-win_amd64.pyd b/landcover-L-SAR/tool/algorithm/transforml1a/SAR_GEO.cp38-win_amd64.pyd deleted file mode 100644 index 642f519..0000000 Binary files a/landcover-L-SAR/tool/algorithm/transforml1a/SAR_GEO.cp38-win_amd64.pyd and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/transforml1a/SAR_geo/SAR_GEO.pyx b/landcover-L-SAR/tool/algorithm/transforml1a/SAR_geo/SAR_GEO.pyx deleted file mode 100644 index c443ac3..0000000 --- a/landcover-L-SAR/tool/algorithm/transforml1a/SAR_geo/SAR_GEO.pyx +++ /dev/null @@ -1,194 +0,0 @@ -import os -cimport cython # 必须导入 -import numpy as np##必须为c类型和python类型的数据都申明一个np -cimport numpy as np # 必须为c类型和python类型的数据都申明一个np -from libc.math cimport pi,ceil,floor -from scipy.interpolate import griddata - - - - - -##################### -# 结构定义区 -#################### -cdef struct Point: # 结构 - double x - double y - - - - - - - - -###################### -# 射线法 -###################### -cdef int rayCasting(Point p,np.ndarray[double,ndim=2] poly): - cdef double px = p.x, - cdef double py = p.y, - cdef int flag = 0 - - cdef int i=0 - cdef int l=poly.shape[0] - cdef int j=l-1 - - cdef double sx - cdef double sy - cdef double tx - cdef double ty - cdef x=0 - while(i= py) or (sy >= py and ty < py)) : - #// 线段上与射线 Y 坐标相同的点的 X 坐标 - x = sx + (py - sy) * (tx - sx) / (ty - sy) - #// 点在多边形的边上 - if(x == px): - return 1 - - #// 射线穿过多边形的边界 - if(x > px): - flag = 0 if flag==1 else 1 - # 循环体 - j=i - i=i+1 - - #// 射线穿过多边形边界的次数为奇数时点在多边形内 - return 1 if flag==1 else 0 - -cpdef np.ndarray[double,ndim=2] insert_data(np.ndarray[double,ndim=2] ori2geo_img,np.ndarray[int , ndim=1] row_ids,np.ndarray[int,ndim=1] col_ids,np.ndarray[double,ndim=1] data): - cdef int i=0 - cdef int count=row_ids.shape[0] - while i=0 and temp_col>=0 and temp_row=0 and temp_col>=0 and temp_row=0 and temp_col>=0 and temp_row=0 and temp_col>=0 and temp_rowp1.x or max_lonmax_lat: - continue - c=c+1 - - - - - - - - - - - -# 测试程序 -cpdef np.ndarray[double,ndim=2] Add(np.ndarray[double,ndim=2] a,double x): - cdef double d=0; # 声明 注意 cython没有 bool类型 - print("调用成功") - print(a) - print(x) - return a+x - diff --git a/landcover-L-SAR/tool/algorithm/transforml1a/build/SAR_geo/SAR_GEO.c b/landcover-L-SAR/tool/algorithm/transforml1a/build/SAR_geo/SAR_GEO.c deleted file mode 100644 index 626b2ed..0000000 --- a/landcover-L-SAR/tool/algorithm/transforml1a/build/SAR_geo/SAR_GEO.c +++ /dev/null @@ -1,9744 +0,0 @@ -/* Generated by Cython 0.29.24 */ - -/* BEGIN: Cython Metadata -{ - "distutils": { - "depends": [], - "name": "SAR_GEO", - "sources": [ - "./SAR_geo/SAR_GEO.pyx" - ] - }, - "module_name": "SAR_GEO" -} -END: Cython Metadata */ - -#ifndef PY_SSIZE_T_CLEAN -#define PY_SSIZE_T_CLEAN -#endif /* PY_SSIZE_T_CLEAN */ -#include "Python.h" -#ifndef Py_PYTHON_H - #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) - #error Cython requires Python 2.6+ or Python 3.3+. -#else -#define CYTHON_ABI "0_29_24" -#define CYTHON_HEX_VERSION 0x001D18F0 -#define CYTHON_FUTURE_DIVISION 0 -#include -#ifndef offsetof - #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !defined(WIN32) && !defined(MS_WINDOWS) - #ifndef __stdcall - #define __stdcall - #endif - #ifndef __cdecl - #define __cdecl - #endif - #ifndef __fastcall - #define __fastcall - #endif -#endif -#ifndef DL_IMPORT - #define DL_IMPORT(t) t -#endif -#ifndef DL_EXPORT - #define DL_EXPORT(t) t -#endif -#define __PYX_COMMA , -#ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x02070000 - #define HAVE_LONG_LONG - #endif -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION - #define CYTHON_COMPILING_IN_PYPY 1 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #undef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #if PY_VERSION_HEX < 0x03050000 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #undef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #undef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 1 - #undef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 0 - #undef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 0 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 - #undef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS 0 - #undef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK 0 -#elif defined(PYSTON_VERSION) - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 1 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 - #undef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS 0 - #undef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK 0 -#else - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 1 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) - #define CYTHON_USE_PYTYPE_LOOKUP 1 - #endif - #if PY_MAJOR_VERSION < 3 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #elif !defined(CYTHON_USE_PYLONG_INTERNALS) - #define CYTHON_USE_PYLONG_INTERNALS 1 - #endif - #ifndef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 1 - #endif - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #if PY_VERSION_HEX < 0x030300F0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #elif !defined(CYTHON_USE_UNICODE_WRITER) - #define CYTHON_USE_UNICODE_WRITER 1 - #endif - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #ifndef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 1 - #endif - #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 1 - #endif - #ifndef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) - #endif - #ifndef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) - #endif - #ifndef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) - #endif - #ifndef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) - #endif -#endif -#if !defined(CYTHON_FAST_PYCCALL) -#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) -#endif -#if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #undef SHIFT - #undef BASE - #undef MASK - #ifdef SIZEOF_VOID_P - enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; - #endif -#endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif -#ifndef __has_cpp_attribute - #define __has_cpp_attribute(x) 0 -#endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif -#endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) -#ifdef _MSC_VER - #ifndef _MSC_STDINT_H_ - #if _MSC_VER < 1300 - typedef unsigned char uint8_t; - typedef unsigned int uint32_t; - #else - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - #endif - #endif -#else - #include -#endif -#ifndef CYTHON_FALLTHROUGH - #if defined(__cplusplus) && __cplusplus >= 201103L - #if __has_cpp_attribute(fallthrough) - #define CYTHON_FALLTHROUGH [[fallthrough]] - #elif __has_cpp_attribute(clang::fallthrough) - #define CYTHON_FALLTHROUGH [[clang::fallthrough]] - #elif __has_cpp_attribute(gnu::fallthrough) - #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] - #endif - #endif - #ifndef CYTHON_FALLTHROUGH - #if __has_attribute(fallthrough) - #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) - #else - #define CYTHON_FALLTHROUGH - #endif - #endif - #if defined(__clang__ ) && defined(__apple_build_version__) - #if __apple_build_version__ < 7000000 - #undef CYTHON_FALLTHROUGH - #define CYTHON_FALLTHROUGH - #endif - #endif -#endif - -#ifndef CYTHON_INLINE - #if defined(__clang__) - #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) - #elif defined(__GNUC__) - #define CYTHON_INLINE __inline__ - #elif defined(_MSC_VER) - #define CYTHON_INLINE __inline - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_INLINE inline - #else - #define CYTHON_INLINE - #endif -#endif - -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) - #define Py_OptimizeFlag 0 -#endif -#define __PYX_BUILD_PY_SSIZE_T "n" -#define CYTHON_FORMAT_SSIZE_T "z" -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" -#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2 - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#else - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#endif - #define __Pyx_DefaultClassType PyType_Type -#endif -#ifndef Py_TPFLAGS_CHECKTYPES - #define Py_TPFLAGS_CHECKTYPES 0 -#endif -#ifndef Py_TPFLAGS_HAVE_INDEX - #define Py_TPFLAGS_HAVE_INDEX 0 -#endif -#ifndef Py_TPFLAGS_HAVE_NEWBUFFER - #define Py_TPFLAGS_HAVE_NEWBUFFER 0 -#endif -#ifndef Py_TPFLAGS_HAVE_FINALIZE - #define Py_TPFLAGS_HAVE_FINALIZE 0 -#endif -#ifndef METH_STACKLESS - #define METH_STACKLESS 0 -#endif -#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) - #ifndef METH_FASTCALL - #define METH_FASTCALL 0x80 - #endif - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); - typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, - Py_ssize_t nargs, PyObject *kwnames); -#else - #define __Pyx_PyCFunctionFast _PyCFunctionFast - #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords -#endif -#if CYTHON_FAST_PYCCALL -#define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) -#else -#define __Pyx_PyFastCFunction_Check(func) 0 -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) - #define PyObject_Malloc(s) PyMem_Malloc(s) - #define PyObject_Free(p) PyMem_Free(p) - #define PyObject_Realloc(p) PyMem_Realloc(p) -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 - #define PyMem_RawMalloc(n) PyMem_Malloc(n) - #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) - #define PyMem_RawFree(p) PyMem_Free(p) -#endif -#if CYTHON_COMPILING_IN_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) -#else - #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) -#endif -#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#elif PY_VERSION_HEX >= 0x03060000 - #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() -#elif PY_VERSION_HEX >= 0x03000000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#else - #define __Pyx_PyThreadState_Current _PyThreadState_Current -#endif -#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) -#include "pythread.h" -#define Py_tss_NEEDS_INIT 0 -typedef int Py_tss_t; -static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { - *key = PyThread_create_key(); - return 0; -} -static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { - Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); - *key = Py_tss_NEEDS_INIT; - return key; -} -static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { - PyObject_Free(key); -} -static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { - return *key != Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { - PyThread_delete_key(*key); - *key = Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { - return PyThread_set_key_value(*key, value); -} -static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { - return PyThread_get_key_value(*key); -} -#endif -#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) -#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) -#else -#define __Pyx_PyDict_NewPresized(n) PyDict_New() -#endif -#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS -#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) -#else -#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #if defined(PyUnicode_IS_READY) - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #else - #define __Pyx_PyUnicode_READY(op) (0) - #endif - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) - #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) - #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) - #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) - #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE) - #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) - #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) - #endif - #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) - #endif -#else - #define CYTHON_PEP393_ENABLED 0 - #define PyUnicode_1BYTE_KIND 1 - #define PyUnicode_2BYTE_KIND 2 - #define PyUnicode_4BYTE_KIND 4 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) -#endif -#if CYTHON_COMPILING_IN_PYPY - #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) -#else - #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ - PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) - #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) - #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) - #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) -#endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) - #define PyObject_ASCII(o) PyObject_Repr(o) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#ifndef PyObject_Unicode - #define PyObject_Unicode PyObject_Str -#endif -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#if PY_VERSION_HEX >= 0x030900A4 - #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) - #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) -#else - #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) - #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) -#endif -#if CYTHON_ASSUME_SAFE_MACROS - #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) -#else - #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) -#endif -#if CYTHON_USE_ASYNC_SLOTS - #if PY_VERSION_HEX >= 0x030500B1 - #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods - #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) - #else - #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef __Pyx_PyAsyncMethodsStruct - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; -#endif - -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES -#endif -#include -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) -#define __Pyx_truncl trunc -#else -#define __Pyx_truncl truncl -#endif - -#define __PYX_MARK_ERR_POS(f_index, lineno) \ - { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } -#define __PYX_ERR(f_index, lineno, Ln_error) \ - { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#define __PYX_HAVE__SAR_GEO -#define __PYX_HAVE_API__SAR_GEO -/* Early includes */ -#include -#include -#include "numpy/arrayobject.h" -#include "numpy/ndarrayobject.h" -#include "numpy/ndarraytypes.h" -#include "numpy/arrayscalars.h" -#include "numpy/ufuncobject.h" - - /* NumPy API declarations from "numpy/__init__.pxd" */ - -#include -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) -#define __PYX_DEFAULT_STRING_ENCODING "" -#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString -#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#define __Pyx_uchar_cast(c) ((unsigned char)c) -#define __Pyx_long_cast(x) ((long)x) -#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ - (sizeof(type) < sizeof(Py_ssize_t)) ||\ - (sizeof(type) > sizeof(Py_ssize_t) &&\ - likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX) &&\ - (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ - v == (type)PY_SSIZE_T_MIN))) ||\ - (sizeof(type) == sizeof(Py_ssize_t) &&\ - (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX))) ) -static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { - return (size_t) i < (size_t) limit; -} -#if defined (__cplusplus) && __cplusplus >= 201103L - #include - #define __Pyx_sst_abs(value) std::abs(value) -#elif SIZEOF_INT >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) abs(value) -#elif SIZEOF_LONG >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) labs(value) -#elif defined (_MSC_VER) - #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) -#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define __Pyx_sst_abs(value) llabs(value) -#elif defined (__GNUC__) - #define __Pyx_sst_abs(value) __builtin_llabs(value) -#else - #define __Pyx_sst_abs(value) ((value<0) ? -value : value) -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) -#define __Pyx_PyBytes_FromString PyBytes_FromString -#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) -#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) -#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) -#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) -#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); -#define __Pyx_PySequence_Tuple(obj)\ - (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -#if CYTHON_ASSUME_SAFE_MACROS -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) -#else -#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) -#endif -#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#endif - - -/* Test for GCC > 2.95 */ -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) -#else /* !__GNUC__ or GCC < 2.95 */ - #define likely(x) (x) - #define unlikely(x) (x) -#endif /* __GNUC__ */ -static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } - -static PyObject *__pyx_m = NULL; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime = NULL; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static PyObject *__pyx_empty_unicode; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - -/* Header.proto */ -#if !defined(CYTHON_CCOMPLEX) - #if defined(__cplusplus) - #define CYTHON_CCOMPLEX 1 - #elif defined(_Complex_I) - #define CYTHON_CCOMPLEX 1 - #else - #define CYTHON_CCOMPLEX 0 - #endif -#endif -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #include - #else - #include - #endif -#endif -#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) - #undef _Complex_I - #define _Complex_I 1.0fj -#endif - - -static const char *__pyx_f[] = { - "SAR_geo\\SAR_GEO.pyx", - "__init__.pxd", - "type.pxd", -}; -/* BufferFormatStructs.proto */ -#define IS_UNSIGNED(type) (((type) -1) > 0) -struct __Pyx_StructField_; -#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) -typedef struct { - const char* name; - struct __Pyx_StructField_* fields; - size_t size; - size_t arraysize[8]; - int ndim; - char typegroup; - char is_unsigned; - int flags; -} __Pyx_TypeInfo; -typedef struct __Pyx_StructField_ { - __Pyx_TypeInfo* type; - const char* name; - size_t offset; -} __Pyx_StructField; -typedef struct { - __Pyx_StructField* field; - size_t parent_offset; -} __Pyx_BufFmt_StackElem; -typedef struct { - __Pyx_StructField root; - __Pyx_BufFmt_StackElem* head; - size_t fmt_offset; - size_t new_count, enc_count; - size_t struct_alignment; - int is_complex; - char enc_type; - char new_packmode; - char enc_packmode; - char is_valid_array; -} __Pyx_BufFmt_Context; - - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":690 - * # in Cython to enable them only on the right systems. - * - * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - */ -typedef npy_int8 __pyx_t_5numpy_int8_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":691 - * - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t - */ -typedef npy_int16 __pyx_t_5numpy_int16_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":692 - * ctypedef npy_int8 int8_t - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< - * ctypedef npy_int64 int64_t - * #ctypedef npy_int96 int96_t - */ -typedef npy_int32 __pyx_t_5numpy_int32_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":693 - * ctypedef npy_int16 int16_t - * ctypedef npy_int32 int32_t - * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< - * #ctypedef npy_int96 int96_t - * #ctypedef npy_int128 int128_t - */ -typedef npy_int64 __pyx_t_5numpy_int64_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":697 - * #ctypedef npy_int128 int128_t - * - * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - */ -typedef npy_uint8 __pyx_t_5numpy_uint8_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":698 - * - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t - */ -typedef npy_uint16 __pyx_t_5numpy_uint16_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":699 - * ctypedef npy_uint8 uint8_t - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< - * ctypedef npy_uint64 uint64_t - * #ctypedef npy_uint96 uint96_t - */ -typedef npy_uint32 __pyx_t_5numpy_uint32_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":700 - * ctypedef npy_uint16 uint16_t - * ctypedef npy_uint32 uint32_t - * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< - * #ctypedef npy_uint96 uint96_t - * #ctypedef npy_uint128 uint128_t - */ -typedef npy_uint64 __pyx_t_5numpy_uint64_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":704 - * #ctypedef npy_uint128 uint128_t - * - * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< - * ctypedef npy_float64 float64_t - * #ctypedef npy_float80 float80_t - */ -typedef npy_float32 __pyx_t_5numpy_float32_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":705 - * - * ctypedef npy_float32 float32_t - * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< - * #ctypedef npy_float80 float80_t - * #ctypedef npy_float128 float128_t - */ -typedef npy_float64 __pyx_t_5numpy_float64_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":714 - * # The int types are mapped a bit surprising -- - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t - */ -typedef npy_long __pyx_t_5numpy_int_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":715 - * # numpy.int corresponds to 'l' and numpy.long to 'q' - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< - * ctypedef npy_longlong longlong_t - * - */ -typedef npy_longlong __pyx_t_5numpy_long_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":716 - * ctypedef npy_long int_t - * ctypedef npy_longlong long_t - * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_ulong uint_t - */ -typedef npy_longlong __pyx_t_5numpy_longlong_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":718 - * ctypedef npy_longlong longlong_t - * - * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t - */ -typedef npy_ulong __pyx_t_5numpy_uint_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":719 - * - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< - * ctypedef npy_ulonglong ulonglong_t - * - */ -typedef npy_ulonglong __pyx_t_5numpy_ulong_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":720 - * ctypedef npy_ulong uint_t - * ctypedef npy_ulonglong ulong_t - * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< - * - * ctypedef npy_intp intp_t - */ -typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":722 - * ctypedef npy_ulonglong ulonglong_t - * - * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< - * ctypedef npy_uintp uintp_t - * - */ -typedef npy_intp __pyx_t_5numpy_intp_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":723 - * - * ctypedef npy_intp intp_t - * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< - * - * ctypedef npy_double float_t - */ -typedef npy_uintp __pyx_t_5numpy_uintp_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":725 - * ctypedef npy_uintp uintp_t - * - * ctypedef npy_double float_t # <<<<<<<<<<<<<< - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t - */ -typedef npy_double __pyx_t_5numpy_float_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":726 - * - * ctypedef npy_double float_t - * ctypedef npy_double double_t # <<<<<<<<<<<<<< - * ctypedef npy_longdouble longdouble_t - * - */ -typedef npy_double __pyx_t_5numpy_double_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":727 - * ctypedef npy_double float_t - * ctypedef npy_double double_t - * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cfloat cfloat_t - */ -typedef npy_longdouble __pyx_t_5numpy_longdouble_t; -/* Declarations.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< float > __pyx_t_float_complex; - #else - typedef float _Complex __pyx_t_float_complex; - #endif -#else - typedef struct { float real, imag; } __pyx_t_float_complex; -#endif -static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); - -/* Declarations.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - typedef ::std::complex< double > __pyx_t_double_complex; - #else - typedef double _Complex __pyx_t_double_complex; - #endif -#else - typedef struct { double real, imag; } __pyx_t_double_complex; -#endif -static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); - - -/*--- Type declarations ---*/ - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":729 - * ctypedef npy_longdouble longdouble_t - * - * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t - */ -typedef npy_cfloat __pyx_t_5numpy_cfloat_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":730 - * - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< - * ctypedef npy_clongdouble clongdouble_t - * - */ -typedef npy_cdouble __pyx_t_5numpy_cdouble_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":731 - * ctypedef npy_cfloat cfloat_t - * ctypedef npy_cdouble cdouble_t - * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< - * - * ctypedef npy_cdouble complex_t - */ -typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":733 - * ctypedef npy_clongdouble clongdouble_t - * - * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew1(a): - */ -typedef npy_cdouble __pyx_t_5numpy_complex_t; -struct __pyx_t_7SAR_GEO_Point; - -/* "SAR_GEO.pyx":15 - * # - * #################### - * cdef struct Point: # # <<<<<<<<<<<<<< - * double x - * double y - */ -struct __pyx_t_7SAR_GEO_Point { - double x; - double y; -}; - -/* --- Runtime support code (head) --- */ -/* Refnanny.proto */ -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, const char*); - void (*FinishContext)(void**); - } __Pyx_RefNannyAPIStruct; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); - #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; -#ifdef WITH_THREAD - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - if (acquire_gil) {\ - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - PyGILState_Release(__pyx_gilstate_save);\ - } else {\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #define __Pyx_RefNannyFinishContext()\ - __Pyx_RefNanny->FinishContext(&__pyx_refnanny) - #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #define __Pyx_RefNannyFinishContext() - #define __Pyx_INCREF(r) Py_INCREF(r) - #define __Pyx_DECREF(r) Py_DECREF(r) - #define __Pyx_GOTREF(r) - #define __Pyx_GIVEREF(r) - #define __Pyx_XINCREF(r) Py_XINCREF(r) - #define __Pyx_XDECREF(r) Py_XDECREF(r) - #define __Pyx_XGOTREF(r) - #define __Pyx_XGIVEREF(r) -#endif -#define __Pyx_XDECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_XDECREF(tmp);\ - } while (0) -#define __Pyx_DECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_DECREF(tmp);\ - } while (0) -#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) -#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) - -/* IsLittleEndian.proto */ -static CYTHON_INLINE int __Pyx_Is_Little_Endian(void); - -/* BufferFormatCheck.proto */ -static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); -static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type); - -/* BufferGetAndValidate.proto */ -#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\ - ((obj == Py_None || obj == NULL) ?\ - (__Pyx_ZeroBuffer(buf), 0) :\ - __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)) -static int __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj, - __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); -static void __Pyx_ZeroBuffer(Py_buffer* buf); -static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); -static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - -/* BufferIndexError.proto */ -static void __Pyx_RaiseBufferIndexError(int axis); - -#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) -/* PyThreadStateGet.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; -#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type -#else -#define __Pyx_PyThreadState_declare -#define __Pyx_PyThreadState_assign -#define __Pyx_PyErr_Occurred() PyErr_Occurred() -#endif - -/* PyErrFetchRestore.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) -#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) -#else -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#endif -#else -#define __Pyx_PyErr_Clear() PyErr_Clear() -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) -#endif - -/* WriteUnraisableException.proto */ -static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename, - int full_traceback, int nogil); - -#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0) -/* RaiseArgTupleInvalid.proto */ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* ArgTypeTest.proto */ -#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ - ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ - __Pyx__ArgTypeTest(obj, type, name, exact)) -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); - -/* PyObjectGetAttrStr.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -/* GetBuiltinName.proto */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name); - -/* PyDictVersioning.proto */ -#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS -#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) -#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) -#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ - (version_var) = __PYX_GET_DICT_VERSION(dict);\ - (cache_var) = (value); -#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ - static PY_UINT64_T __pyx_dict_version = 0;\ - static PyObject *__pyx_dict_cached_value = NULL;\ - if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ - (VAR) = __pyx_dict_cached_value;\ - } else {\ - (VAR) = __pyx_dict_cached_value = (LOOKUP);\ - __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ - }\ -} -static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); -static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); -static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); -#else -#define __PYX_GET_DICT_VERSION(dict) (0) -#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) -#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); -#endif - -/* GetModuleGlobalName.proto */ -#if CYTHON_USE_DICT_VERSIONS -#define __Pyx_GetModuleGlobalName(var, name) {\ - static PY_UINT64_T __pyx_dict_version = 0;\ - static PyObject *__pyx_dict_cached_value = NULL;\ - (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ - (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ - __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ -} -#define __Pyx_GetModuleGlobalNameUncached(var, name) {\ - PY_UINT64_T __pyx_dict_version;\ - PyObject *__pyx_dict_cached_value;\ - (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ -} -static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); -#else -#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) -#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) -static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); -#endif - -/* PyObjectCall.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); -#else -#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) -#endif - -/* ExtTypeTest.proto */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); - -#define __Pyx_BufPtrStrided3d(type, buf, i0, s0, i1, s1, i2, s2) (type)((char*)buf + i0 * s0 + i1 * s1 + i2 * s2) -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#define __Pyx_BUILD_ASSERT_EXPR(cond)\ - (sizeof(char [1 - 2*!(cond)]) - 1) -#ifndef Py_MEMBER_SIZE -#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) -#endif - static size_t __pyx_pyframe_localsplus_offset = 0; - #include "frameobject.h" - #define __Pxy_PyFrame_Initialize_Offsets()\ - ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ - (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) - #define __Pyx_PyFrame_GetLocalsplus(frame)\ - (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) -#endif - -/* PyObjectCall2Args.proto */ -static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); - -/* PyObjectCallMethO.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); -#endif - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ - __Pyx_GetItemInt_Generic(o, to_py_func(i)))) -#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, - int is_list, int wraparound, int boundscheck); - -/* ObjectGetItem.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); -#else -#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) -#endif - -/* GetTopmostException.proto */ -#if CYTHON_USE_EXC_INFO_STACK -static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); -#endif - -/* SaveResetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -#else -#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) -#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) -#endif - -/* PyErrExceptionMatches.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) -static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); -#else -#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) -#endif - -/* GetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); -#endif - -/* RaiseException.proto */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); - -/* TypeImport.proto */ -#ifndef __PYX_HAVE_RT_ImportType_proto -#define __PYX_HAVE_RT_ImportType_proto -enum __Pyx_ImportType_CheckSize { - __Pyx_ImportType_CheckSize_Error = 0, - __Pyx_ImportType_CheckSize_Warn = 1, - __Pyx_ImportType_CheckSize_Ignore = 2 -}; -static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size); -#endif - -/* Import.proto */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); - -/* ImportFrom.proto */ -static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); - -/* CLineInTraceback.proto */ -#ifdef CYTHON_CLINE_IN_TRACEBACK -#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) -#else -static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); -#endif - -/* CodeObjectCache.proto */ -typedef struct { - PyCodeObject* code_object; - int code_line; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -/* AddTraceback.proto */ -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); - -/* BufferStructDeclare.proto */ -typedef struct { - Py_ssize_t shape, strides, suboffsets; -} __Pyx_Buf_DimInfo; -typedef struct { - size_t refcount; - Py_buffer pybuffer; -} __Pyx_Buffer; -typedef struct { - __Pyx_Buffer *rcbuffer; - char *data; - __Pyx_Buf_DimInfo diminfo[8]; -} __Pyx_LocalBuf_ND; - -#if PY_MAJOR_VERSION < 3 - static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); - static void __Pyx_ReleaseBuffer(Py_buffer *view); -#else - #define __Pyx_GetBuffer PyObject_GetBuffer - #define __Pyx_ReleaseBuffer PyBuffer_Release -#endif - - -/* GCCDiagnostics.proto */ -#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) -#define __Pyx_HAS_GCC_DIAGNOSTIC -#endif - -/* Print.proto */ -static int __Pyx_Print(PyObject*, PyObject *, int); -#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3 -static PyObject* __pyx_print = 0; -static PyObject* __pyx_print_kwargs = 0; -#endif - -/* RealImag.proto */ -#if CYTHON_CCOMPLEX - #ifdef __cplusplus - #define __Pyx_CREAL(z) ((z).real()) - #define __Pyx_CIMAG(z) ((z).imag()) - #else - #define __Pyx_CREAL(z) (__real__(z)) - #define __Pyx_CIMAG(z) (__imag__(z)) - #endif -#else - #define __Pyx_CREAL(z) ((z).real) - #define __Pyx_CIMAG(z) ((z).imag) -#endif -#if defined(__cplusplus) && CYTHON_CCOMPLEX\ - && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) - #define __Pyx_SET_CREAL(z,x) ((z).real(x)) - #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) -#else - #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) - #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) -#endif - -/* Arithmetic.proto */ -#if CYTHON_CCOMPLEX - #define __Pyx_c_eq_float(a, b) ((a)==(b)) - #define __Pyx_c_sum_float(a, b) ((a)+(b)) - #define __Pyx_c_diff_float(a, b) ((a)-(b)) - #define __Pyx_c_prod_float(a, b) ((a)*(b)) - #define __Pyx_c_quot_float(a, b) ((a)/(b)) - #define __Pyx_c_neg_float(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zero_float(z) ((z)==(float)0) - #define __Pyx_c_conj_float(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_abs_float(z) (::std::abs(z)) - #define __Pyx_c_pow_float(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zero_float(z) ((z)==0) - #define __Pyx_c_conj_float(z) (conjf(z)) - #if 1 - #define __Pyx_c_abs_float(z) (cabsf(z)) - #define __Pyx_c_pow_float(a, b) (cpowf(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex); - static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex); - #if 1 - static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex); - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex); - #endif -#endif - -/* Arithmetic.proto */ -#if CYTHON_CCOMPLEX - #define __Pyx_c_eq_double(a, b) ((a)==(b)) - #define __Pyx_c_sum_double(a, b) ((a)+(b)) - #define __Pyx_c_diff_double(a, b) ((a)-(b)) - #define __Pyx_c_prod_double(a, b) ((a)*(b)) - #define __Pyx_c_quot_double(a, b) ((a)/(b)) - #define __Pyx_c_neg_double(a) (-(a)) - #ifdef __cplusplus - #define __Pyx_c_is_zero_double(z) ((z)==(double)0) - #define __Pyx_c_conj_double(z) (::std::conj(z)) - #if 1 - #define __Pyx_c_abs_double(z) (::std::abs(z)) - #define __Pyx_c_pow_double(a, b) (::std::pow(a, b)) - #endif - #else - #define __Pyx_c_is_zero_double(z) ((z)==0) - #define __Pyx_c_conj_double(z) (conj(z)) - #if 1 - #define __Pyx_c_abs_double(z) (cabs(z)) - #define __Pyx_c_pow_double(a, b) (cpow(a, b)) - #endif - #endif -#else - static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex); - static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex); - #if 1 - static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex); - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex); - #endif -#endif - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -/* PrintOne.proto */ -static int __Pyx_PrintOne(PyObject* stream, PyObject *o); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -/* FastTypeChecks.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); -#else -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) -#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) -#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) -#endif -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) - -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* InitStrings.proto */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); - - -/* Module declarations from 'cython' */ - -/* Module declarations from 'cpython.buffer' */ - -/* Module declarations from 'libc.string' */ - -/* Module declarations from 'libc.stdio' */ - -/* Module declarations from '__builtin__' */ - -/* Module declarations from 'cpython.type' */ -static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; - -/* Module declarations from 'cpython' */ - -/* Module declarations from 'cpython.object' */ - -/* Module declarations from 'cpython.ref' */ - -/* Module declarations from 'cpython.mem' */ - -/* Module declarations from 'numpy' */ - -/* Module declarations from 'numpy' */ -static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; -static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; -static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; -static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; -static PyTypeObject *__pyx_ptype_5numpy_generic = 0; -static PyTypeObject *__pyx_ptype_5numpy_number = 0; -static PyTypeObject *__pyx_ptype_5numpy_integer = 0; -static PyTypeObject *__pyx_ptype_5numpy_signedinteger = 0; -static PyTypeObject *__pyx_ptype_5numpy_unsignedinteger = 0; -static PyTypeObject *__pyx_ptype_5numpy_inexact = 0; -static PyTypeObject *__pyx_ptype_5numpy_floating = 0; -static PyTypeObject *__pyx_ptype_5numpy_complexfloating = 0; -static PyTypeObject *__pyx_ptype_5numpy_flexible = 0; -static PyTypeObject *__pyx_ptype_5numpy_character = 0; -static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; - -/* Module declarations from 'libc.math' */ - -/* Module declarations from 'SAR_GEO' */ -static int __pyx_f_7SAR_GEO_rayCasting(struct __pyx_t_7SAR_GEO_Point, PyArrayObject *); /*proto*/ -static PyArrayObject *__pyx_f_7SAR_GEO_insert_data(PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); /*proto*/ -static PyArrayObject *__pyx_f_7SAR_GEO_cut_L1A_img(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); /*proto*/ -static PyArrayObject *__pyx_f_7SAR_GEO_gereratorMask(PyArrayObject *, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); /*proto*/ -static PyArrayObject *__pyx_f_7SAR_GEO_get_r_c(PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); /*proto*/ -static PyArrayObject *__pyx_f_7SAR_GEO_Add(PyArrayObject *, double, int __pyx_skip_dispatch); /*proto*/ -static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 }; -static __Pyx_TypeInfo __Pyx_TypeInfo_int = { "int", NULL, sizeof(int), { 0 }, 0, IS_UNSIGNED(int) ? 'U' : 'I', IS_UNSIGNED(int), 0 }; -#define __Pyx_MODULE_NAME "SAR_GEO" -extern int __pyx_module_is_main_SAR_GEO; -int __pyx_module_is_main_SAR_GEO = 0; - -/* Implementation of 'SAR_GEO' */ -static PyObject *__pyx_builtin_ImportError; -static const char __pyx_k_a[] = "a"; -static const char __pyx_k_x[] = "x"; -static const char __pyx_k__4[] = "\350\260\203\347\224\250\346\210\220\345\212\237"; -static const char __pyx_k_np[] = "np"; -static const char __pyx_k_os[] = "os"; -static const char __pyx_k_end[] = "end"; -static const char __pyx_k_max[] = "max"; -static const char __pyx_k_min[] = "min"; -static const char __pyx_k_nan[] = "nan"; -static const char __pyx_k_data[] = "data"; -static const char __pyx_k_file[] = "file"; -static const char __pyx_k_main[] = "__main__"; -static const char __pyx_k_mask[] = "mask"; -static const char __pyx_k_name[] = "__name__"; -static const char __pyx_k_ones[] = "ones"; -static const char __pyx_k_test[] = "__test__"; -static const char __pyx_k_clist[] = "clist"; -static const char __pyx_k_dtype[] = "dtype"; -static const char __pyx_k_numpy[] = "numpy"; -static const char __pyx_k_print[] = "print"; -static const char __pyx_k_rlist[] = "rlist"; -static const char __pyx_k_zeros[] = "zeros"; -static const char __pyx_k_import[] = "__import__"; -static const char __pyx_k_col_ids[] = "col_ids"; -static const char __pyx_k_float64[] = "float64"; -static const char __pyx_k_lon_lat[] = "lon_lat"; -static const char __pyx_k_ori2geo[] = "ori2geo"; -static const char __pyx_k_row_ids[] = "row_ids"; -static const char __pyx_k_griddata[] = "griddata"; -static const char __pyx_k_roi_list[] = "roi_list"; -static const char __pyx_k_ImportError[] = "ImportError"; -static const char __pyx_k_ori2geo_img[] = "ori2geo_img"; -static const char __pyx_k_scipy_interpolate[] = "scipy.interpolate"; -static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; -static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import"; -static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import"; -static PyObject *__pyx_n_s_ImportError; -static PyObject *__pyx_kp_s__4; -static PyObject *__pyx_n_s_a; -static PyObject *__pyx_n_s_cline_in_traceback; -static PyObject *__pyx_n_s_clist; -static PyObject *__pyx_n_s_col_ids; -static PyObject *__pyx_n_s_data; -static PyObject *__pyx_n_s_dtype; -static PyObject *__pyx_n_s_end; -static PyObject *__pyx_n_s_file; -static PyObject *__pyx_n_s_float64; -static PyObject *__pyx_n_s_griddata; -static PyObject *__pyx_n_s_import; -static PyObject *__pyx_n_s_lon_lat; -static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_mask; -static PyObject *__pyx_n_s_max; -static PyObject *__pyx_n_s_min; -static PyObject *__pyx_n_s_name; -static PyObject *__pyx_n_s_nan; -static PyObject *__pyx_n_s_np; -static PyObject *__pyx_n_s_numpy; -static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to; -static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor; -static PyObject *__pyx_n_s_ones; -static PyObject *__pyx_n_s_ori2geo; -static PyObject *__pyx_n_s_ori2geo_img; -static PyObject *__pyx_n_s_os; -static PyObject *__pyx_n_s_print; -static PyObject *__pyx_n_s_rlist; -static PyObject *__pyx_n_s_roi_list; -static PyObject *__pyx_n_s_row_ids; -static PyObject *__pyx_n_s_scipy_interpolate; -static PyObject *__pyx_n_s_test; -static PyObject *__pyx_n_s_x; -static PyObject *__pyx_n_s_zeros; -static PyObject *__pyx_pf_7SAR_GEO_insert_data(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_ori2geo_img, PyArrayObject *__pyx_v_row_ids, PyArrayObject *__pyx_v_col_ids, PyArrayObject *__pyx_v_data); /* proto */ -static PyObject *__pyx_pf_7SAR_GEO_2cut_L1A_img(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_ori2geo_img, PyArrayObject *__pyx_v_roi_list); /* proto */ -static PyObject *__pyx_pf_7SAR_GEO_4gereratorMask(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_rlist, PyArrayObject *__pyx_v_clist, PyArrayObject *__pyx_v_mask); /* proto */ -static PyObject *__pyx_pf_7SAR_GEO_6get_r_c(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_ori2geo, PyArrayObject *__pyx_v_lon_lat); /* proto */ -static PyObject *__pyx_pf_7SAR_GEO_8Add(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_a, double __pyx_v_x); /* proto */ -static PyObject *__pyx_int_0; -static PyObject *__pyx_int_1; -static PyObject *__pyx_int_2; -static PyObject *__pyx_int_neg_1; -static PyObject *__pyx_slice_; -static PyObject *__pyx_tuple__2; -static PyObject *__pyx_tuple__3; -static PyObject *__pyx_tuple__5; -static PyObject *__pyx_tuple__6; -/* Late includes */ - -/* "SAR_GEO.pyx":29 - * # - * ###################### - * cdef int rayCasting(Point p,np.ndarray[double,ndim=2] poly): # <<<<<<<<<<<<<< - * cdef double px = p.x, - * cdef double py = p.y, - */ - -static int __pyx_f_7SAR_GEO_rayCasting(struct __pyx_t_7SAR_GEO_Point __pyx_v_p, PyArrayObject *__pyx_v_poly) { - double __pyx_v_px; - double __pyx_v_py; - int __pyx_v_flag; - int __pyx_v_i; - int __pyx_v_l; - int __pyx_v_j; - double __pyx_v_sx; - double __pyx_v_sy; - double __pyx_v_tx; - double __pyx_v_ty; - PyObject *__pyx_v_x = 0; - __Pyx_LocalBuf_ND __pyx_pybuffernd_poly; - __Pyx_Buffer __pyx_pybuffer_poly; - int __pyx_r; - __Pyx_RefNannyDeclarations - double __pyx_t_1; - int __pyx_t_2; - Py_ssize_t __pyx_t_3; - Py_ssize_t __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - double __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("rayCasting", 0); - __pyx_pybuffer_poly.pybuffer.buf = NULL; - __pyx_pybuffer_poly.refcount = 0; - __pyx_pybuffernd_poly.data = NULL; - __pyx_pybuffernd_poly.rcbuffer = &__pyx_pybuffer_poly; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_poly.rcbuffer->pybuffer, (PyObject*)__pyx_v_poly, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 29, __pyx_L1_error) - } - __pyx_pybuffernd_poly.diminfo[0].strides = __pyx_pybuffernd_poly.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_poly.diminfo[0].shape = __pyx_pybuffernd_poly.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_poly.diminfo[1].strides = __pyx_pybuffernd_poly.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_poly.diminfo[1].shape = __pyx_pybuffernd_poly.rcbuffer->pybuffer.shape[1]; - - /* "SAR_GEO.pyx":30 - * ###################### - * cdef int rayCasting(Point p,np.ndarray[double,ndim=2] poly): - * cdef double px = p.x, # <<<<<<<<<<<<<< - * cdef double py = p.y, - * cdef int flag = 0 - */ - __pyx_t_1 = __pyx_v_p.x; - __pyx_v_px = __pyx_t_1; - - /* "SAR_GEO.pyx":31 - * cdef int rayCasting(Point p,np.ndarray[double,ndim=2] poly): - * cdef double px = p.x, - * cdef double py = p.y, # <<<<<<<<<<<<<< - * cdef int flag = 0 - * - */ - __pyx_t_1 = __pyx_v_p.y; - __pyx_v_py = __pyx_t_1; - - /* "SAR_GEO.pyx":32 - * cdef double px = p.x, - * cdef double py = p.y, - * cdef int flag = 0 # <<<<<<<<<<<<<< - * - * cdef int i=0 - */ - __pyx_v_flag = 0; - - /* "SAR_GEO.pyx":34 - * cdef int flag = 0 - * - * cdef int i=0 # <<<<<<<<<<<<<< - * cdef int l=poly.shape[0] - * cdef int j=l-1 - */ - __pyx_v_i = 0; - - /* "SAR_GEO.pyx":35 - * - * cdef int i=0 - * cdef int l=poly.shape[0] # <<<<<<<<<<<<<< - * cdef int j=l-1 - * - */ - __pyx_v_l = (__pyx_v_poly->dimensions[0]); - - /* "SAR_GEO.pyx":36 - * cdef int i=0 - * cdef int l=poly.shape[0] - * cdef int j=l-1 # <<<<<<<<<<<<<< - * - * cdef double sx - */ - __pyx_v_j = (__pyx_v_l - 1); - - /* "SAR_GEO.pyx":42 - * cdef double tx - * cdef double ty - * cdef x=0 # <<<<<<<<<<<<<< - * while(i= __pyx_pybuffernd_poly.diminfo[0].shape)) __pyx_t_5 = 0; - if (__pyx_t_4 < 0) { - __pyx_t_4 += __pyx_pybuffernd_poly.diminfo[1].shape; - if (unlikely(__pyx_t_4 < 0)) __pyx_t_5 = 1; - } else if (unlikely(__pyx_t_4 >= __pyx_pybuffernd_poly.diminfo[1].shape)) __pyx_t_5 = 1; - if (unlikely(__pyx_t_5 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_5); - __PYX_ERR(0, 44, __pyx_L1_error) - } - __pyx_v_sx = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_poly.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_poly.diminfo[0].strides, __pyx_t_4, __pyx_pybuffernd_poly.diminfo[1].strides)); - - /* "SAR_GEO.pyx":45 - * while(i= __pyx_pybuffernd_poly.diminfo[0].shape)) __pyx_t_5 = 0; - if (__pyx_t_3 < 0) { - __pyx_t_3 += __pyx_pybuffernd_poly.diminfo[1].shape; - if (unlikely(__pyx_t_3 < 0)) __pyx_t_5 = 1; - } else if (unlikely(__pyx_t_3 >= __pyx_pybuffernd_poly.diminfo[1].shape)) __pyx_t_5 = 1; - if (unlikely(__pyx_t_5 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_5); - __PYX_ERR(0, 45, __pyx_L1_error) - } - __pyx_v_sy = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_poly.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_poly.diminfo[0].strides, __pyx_t_3, __pyx_pybuffernd_poly.diminfo[1].strides)); - - /* "SAR_GEO.pyx":46 - * sx=poly[i,0] - * sy=poly[i,1] - * tx=poly[j,0] # <<<<<<<<<<<<<< - * ty=poly[j,1] - * # - */ - __pyx_t_3 = __pyx_v_j; - __pyx_t_4 = 0; - __pyx_t_5 = -1; - if (__pyx_t_3 < 0) { - __pyx_t_3 += __pyx_pybuffernd_poly.diminfo[0].shape; - if (unlikely(__pyx_t_3 < 0)) __pyx_t_5 = 0; - } else if (unlikely(__pyx_t_3 >= __pyx_pybuffernd_poly.diminfo[0].shape)) __pyx_t_5 = 0; - if (__pyx_t_4 < 0) { - __pyx_t_4 += __pyx_pybuffernd_poly.diminfo[1].shape; - if (unlikely(__pyx_t_4 < 0)) __pyx_t_5 = 1; - } else if (unlikely(__pyx_t_4 >= __pyx_pybuffernd_poly.diminfo[1].shape)) __pyx_t_5 = 1; - if (unlikely(__pyx_t_5 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_5); - __PYX_ERR(0, 46, __pyx_L1_error) - } - __pyx_v_tx = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_poly.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_poly.diminfo[0].strides, __pyx_t_4, __pyx_pybuffernd_poly.diminfo[1].strides)); - - /* "SAR_GEO.pyx":47 - * sy=poly[i,1] - * tx=poly[j,0] - * ty=poly[j,1] # <<<<<<<<<<<<<< - * # - * if((sx == px and sy == py) or (tx == px and ty == py)): - */ - __pyx_t_4 = __pyx_v_j; - __pyx_t_3 = 1; - __pyx_t_5 = -1; - if (__pyx_t_4 < 0) { - __pyx_t_4 += __pyx_pybuffernd_poly.diminfo[0].shape; - if (unlikely(__pyx_t_4 < 0)) __pyx_t_5 = 0; - } else if (unlikely(__pyx_t_4 >= __pyx_pybuffernd_poly.diminfo[0].shape)) __pyx_t_5 = 0; - if (__pyx_t_3 < 0) { - __pyx_t_3 += __pyx_pybuffernd_poly.diminfo[1].shape; - if (unlikely(__pyx_t_3 < 0)) __pyx_t_5 = 1; - } else if (unlikely(__pyx_t_3 >= __pyx_pybuffernd_poly.diminfo[1].shape)) __pyx_t_5 = 1; - if (unlikely(__pyx_t_5 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_5); - __PYX_ERR(0, 47, __pyx_L1_error) - } - __pyx_v_ty = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_poly.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_poly.diminfo[0].strides, __pyx_t_3, __pyx_pybuffernd_poly.diminfo[1].strides)); - - /* "SAR_GEO.pyx":49 - * ty=poly[j,1] - * # - * if((sx == px and sy == py) or (tx == px and ty == py)): # <<<<<<<<<<<<<< - * return 1 - * #// - */ - __pyx_t_6 = ((__pyx_v_sx == __pyx_v_px) != 0); - if (!__pyx_t_6) { - goto __pyx_L7_next_or; - } else { - } - __pyx_t_6 = ((__pyx_v_sy == __pyx_v_py) != 0); - if (!__pyx_t_6) { - } else { - __pyx_t_2 = __pyx_t_6; - goto __pyx_L6_bool_binop_done; - } - __pyx_L7_next_or:; - __pyx_t_6 = ((__pyx_v_tx == __pyx_v_px) != 0); - if (__pyx_t_6) { - } else { - __pyx_t_2 = __pyx_t_6; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_6 = ((__pyx_v_ty == __pyx_v_py) != 0); - __pyx_t_2 = __pyx_t_6; - __pyx_L6_bool_binop_done:; - if (__pyx_t_2) { - - /* "SAR_GEO.pyx":50 - * # - * if((sx == px and sy == py) or (tx == px and ty == py)): - * return 1 # <<<<<<<<<<<<<< - * #// - * if((sy < py and ty >= py) or (sy >= py and ty < py)) : - */ - __pyx_r = 1; - goto __pyx_L0; - - /* "SAR_GEO.pyx":49 - * ty=poly[j,1] - * # - * if((sx == px and sy == py) or (tx == px and ty == py)): # <<<<<<<<<<<<<< - * return 1 - * #// - */ - } - - /* "SAR_GEO.pyx":52 - * return 1 - * #// - * if((sy < py and ty >= py) or (sy >= py and ty < py)) : # <<<<<<<<<<<<<< - * #// Y X - * x = sx + (py - sy) * (tx - sx) / (ty - sy) - */ - __pyx_t_6 = ((__pyx_v_sy < __pyx_v_py) != 0); - if (!__pyx_t_6) { - goto __pyx_L12_next_or; - } else { - } - __pyx_t_6 = ((__pyx_v_ty >= __pyx_v_py) != 0); - if (!__pyx_t_6) { - } else { - __pyx_t_2 = __pyx_t_6; - goto __pyx_L11_bool_binop_done; - } - __pyx_L12_next_or:; - __pyx_t_6 = ((__pyx_v_sy >= __pyx_v_py) != 0); - if (__pyx_t_6) { - } else { - __pyx_t_2 = __pyx_t_6; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_6 = ((__pyx_v_ty < __pyx_v_py) != 0); - __pyx_t_2 = __pyx_t_6; - __pyx_L11_bool_binop_done:; - if (__pyx_t_2) { - - /* "SAR_GEO.pyx":54 - * if((sy < py and ty >= py) or (sy >= py and ty < py)) : - * #// Y X - * x = sx + (py - sy) * (tx - sx) / (ty - sy) # <<<<<<<<<<<<<< - * #// - * if(x == px): - */ - __pyx_t_1 = ((__pyx_v_py - __pyx_v_sy) * (__pyx_v_tx - __pyx_v_sx)); - __pyx_t_7 = (__pyx_v_ty - __pyx_v_sy); - if (unlikely(__pyx_t_7 == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "float division"); - __PYX_ERR(0, 54, __pyx_L1_error) - } - __pyx_t_8 = PyFloat_FromDouble((__pyx_v_sx + (__pyx_t_1 / __pyx_t_7))); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 54, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_8); - __pyx_t_8 = 0; - - /* "SAR_GEO.pyx":56 - * x = sx + (py - sy) * (tx - sx) / (ty - sy) - * #// - * if(x == px): # <<<<<<<<<<<<<< - * return 1 - * - */ - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_px); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_9 = PyObject_RichCompare(__pyx_v_x, __pyx_t_8, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - if (__pyx_t_2) { - - /* "SAR_GEO.pyx":57 - * #// - * if(x == px): - * return 1 # <<<<<<<<<<<<<< - * - * #// - */ - __pyx_r = 1; - goto __pyx_L0; - - /* "SAR_GEO.pyx":56 - * x = sx + (py - sy) * (tx - sx) / (ty - sy) - * #// - * if(x == px): # <<<<<<<<<<<<<< - * return 1 - * - */ - } - - /* "SAR_GEO.pyx":60 - * - * #// - * if(x > px): # <<<<<<<<<<<<<< - * flag = 0 if flag==1 else 1 - * # - */ - __pyx_t_9 = PyFloat_FromDouble(__pyx_v_px); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_8 = PyObject_RichCompare(__pyx_v_x, __pyx_t_9, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (__pyx_t_2) { - - /* "SAR_GEO.pyx":61 - * #// - * if(x > px): - * flag = 0 if flag==1 else 1 # <<<<<<<<<<<<<< - * # - * j=i - */ - if (((__pyx_v_flag == 1) != 0)) { - __pyx_t_5 = 0; - } else { - __pyx_t_5 = 1; - } - __pyx_v_flag = __pyx_t_5; - - /* "SAR_GEO.pyx":60 - * - * #// - * if(x > px): # <<<<<<<<<<<<<< - * flag = 0 if flag==1 else 1 - * # - */ - } - - /* "SAR_GEO.pyx":52 - * return 1 - * #// - * if((sy < py and ty >= py) or (sy >= py and ty < py)) : # <<<<<<<<<<<<<< - * #// Y X - * x = sx + (py - sy) * (tx - sx) / (ty - sy) - */ - } - - /* "SAR_GEO.pyx":63 - * flag = 0 if flag==1 else 1 - * # - * j=i # <<<<<<<<<<<<<< - * i=i+1 - * - */ - __pyx_v_j = __pyx_v_i; - - /* "SAR_GEO.pyx":64 - * # - * j=i - * i=i+1 # <<<<<<<<<<<<<< - * - * #// - */ - __pyx_v_i = (__pyx_v_i + 1); - } - - /* "SAR_GEO.pyx":67 - * - * #// - * return 1 if flag==1 else 0 # <<<<<<<<<<<<<< - * - * cpdef np.ndarray[double,ndim=2] insert_data(np.ndarray[double,ndim=2] ori2geo_img,np.ndarray[int , ndim=1] row_ids,np.ndarray[int,ndim=1] col_ids,np.ndarray[double,ndim=1] data): - */ - if (((__pyx_v_flag == 1) != 0)) { - __pyx_t_5 = 1; - } else { - __pyx_t_5 = 0; - } - __pyx_r = __pyx_t_5; - goto __pyx_L0; - - /* "SAR_GEO.pyx":29 - * # - * ###################### - * cdef int rayCasting(Point p,np.ndarray[double,ndim=2] poly): # <<<<<<<<<<<<<< - * cdef double px = p.x, - * cdef double py = p.y, - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_poly.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_WriteUnraisable("SAR_GEO.rayCasting", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); - __pyx_r = 0; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_poly.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF(__pyx_v_x); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "SAR_GEO.pyx":69 - * return 1 if flag==1 else 0 - * - * cpdef np.ndarray[double,ndim=2] insert_data(np.ndarray[double,ndim=2] ori2geo_img,np.ndarray[int , ndim=1] row_ids,np.ndarray[int,ndim=1] col_ids,np.ndarray[double,ndim=1] data): # <<<<<<<<<<<<<< - * cdef int i=0 - * cdef int count=row_ids.shape[0] - */ - -static PyObject *__pyx_pw_7SAR_GEO_1insert_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyArrayObject *__pyx_f_7SAR_GEO_insert_data(PyArrayObject *__pyx_v_ori2geo_img, PyArrayObject *__pyx_v_row_ids, PyArrayObject *__pyx_v_col_ids, PyArrayObject *__pyx_v_data, CYTHON_UNUSED int __pyx_skip_dispatch) { - int __pyx_v_i; - int __pyx_v_count; - __Pyx_LocalBuf_ND __pyx_pybuffernd_col_ids; - __Pyx_Buffer __pyx_pybuffer_col_ids; - __Pyx_LocalBuf_ND __pyx_pybuffernd_data; - __Pyx_Buffer __pyx_pybuffer_data; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ori2geo_img; - __Pyx_Buffer __pyx_pybuffer_ori2geo_img; - __Pyx_LocalBuf_ND __pyx_pybuffernd_row_ids; - __Pyx_Buffer __pyx_pybuffer_row_ids; - PyArrayObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - Py_ssize_t __pyx_t_2; - int __pyx_t_3; - Py_ssize_t __pyx_t_4; - Py_ssize_t __pyx_t_5; - Py_ssize_t __pyx_t_6; - Py_ssize_t __pyx_t_7; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("insert_data", 0); - __pyx_pybuffer_ori2geo_img.pybuffer.buf = NULL; - __pyx_pybuffer_ori2geo_img.refcount = 0; - __pyx_pybuffernd_ori2geo_img.data = NULL; - __pyx_pybuffernd_ori2geo_img.rcbuffer = &__pyx_pybuffer_ori2geo_img; - __pyx_pybuffer_row_ids.pybuffer.buf = NULL; - __pyx_pybuffer_row_ids.refcount = 0; - __pyx_pybuffernd_row_ids.data = NULL; - __pyx_pybuffernd_row_ids.rcbuffer = &__pyx_pybuffer_row_ids; - __pyx_pybuffer_col_ids.pybuffer.buf = NULL; - __pyx_pybuffer_col_ids.refcount = 0; - __pyx_pybuffernd_col_ids.data = NULL; - __pyx_pybuffernd_col_ids.rcbuffer = &__pyx_pybuffer_col_ids; - __pyx_pybuffer_data.pybuffer.buf = NULL; - __pyx_pybuffer_data.refcount = 0; - __pyx_pybuffernd_data.data = NULL; - __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer, (PyObject*)__pyx_v_ori2geo_img, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 69, __pyx_L1_error) - } - __pyx_pybuffernd_ori2geo_img.diminfo[0].strides = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ori2geo_img.diminfo[0].shape = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ori2geo_img.diminfo[1].strides = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ori2geo_img.diminfo[1].shape = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_row_ids.rcbuffer->pybuffer, (PyObject*)__pyx_v_row_ids, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 69, __pyx_L1_error) - } - __pyx_pybuffernd_row_ids.diminfo[0].strides = __pyx_pybuffernd_row_ids.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_row_ids.diminfo[0].shape = __pyx_pybuffernd_row_ids.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_col_ids.rcbuffer->pybuffer, (PyObject*)__pyx_v_col_ids, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 69, __pyx_L1_error) - } - __pyx_pybuffernd_col_ids.diminfo[0].strides = __pyx_pybuffernd_col_ids.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_col_ids.diminfo[0].shape = __pyx_pybuffernd_col_ids.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 69, __pyx_L1_error) - } - __pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0]; - - /* "SAR_GEO.pyx":70 - * - * cpdef np.ndarray[double,ndim=2] insert_data(np.ndarray[double,ndim=2] ori2geo_img,np.ndarray[int , ndim=1] row_ids,np.ndarray[int,ndim=1] col_ids,np.ndarray[double,ndim=1] data): - * cdef int i=0 # <<<<<<<<<<<<<< - * cdef int count=row_ids.shape[0] - * while idimensions[0]); - - /* "SAR_GEO.pyx":72 - * cdef int i=0 - * cdef int count=row_ids.shape[0] - * while i= __pyx_pybuffernd_data.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 73, __pyx_L1_error) - } - __pyx_t_4 = __pyx_v_i; - __pyx_t_3 = -1; - if (__pyx_t_4 < 0) { - __pyx_t_4 += __pyx_pybuffernd_row_ids.diminfo[0].shape; - if (unlikely(__pyx_t_4 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_4 >= __pyx_pybuffernd_row_ids.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 73, __pyx_L1_error) - } - __pyx_t_5 = __pyx_v_i; - __pyx_t_3 = -1; - if (__pyx_t_5 < 0) { - __pyx_t_5 += __pyx_pybuffernd_col_ids.diminfo[0].shape; - if (unlikely(__pyx_t_5 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_col_ids.diminfo[0].shape)) __pyx_t_3 = 0; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 73, __pyx_L1_error) - } - __pyx_t_6 = (*__Pyx_BufPtrStrided1d(int *, __pyx_pybuffernd_row_ids.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_row_ids.diminfo[0].strides)); - __pyx_t_7 = (*__Pyx_BufPtrStrided1d(int *, __pyx_pybuffernd_col_ids.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_col_ids.diminfo[0].strides)); - __pyx_t_3 = -1; - if (__pyx_t_6 < 0) { - __pyx_t_6 += __pyx_pybuffernd_ori2geo_img.diminfo[0].shape; - if (unlikely(__pyx_t_6 < 0)) __pyx_t_3 = 0; - } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_ori2geo_img.diminfo[0].shape)) __pyx_t_3 = 0; - if (__pyx_t_7 < 0) { - __pyx_t_7 += __pyx_pybuffernd_ori2geo_img.diminfo[1].shape; - if (unlikely(__pyx_t_7 < 0)) __pyx_t_3 = 1; - } else if (unlikely(__pyx_t_7 >= __pyx_pybuffernd_ori2geo_img.diminfo[1].shape)) __pyx_t_3 = 1; - if (unlikely(__pyx_t_3 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_3); - __PYX_ERR(0, 73, __pyx_L1_error) - } - *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_ori2geo_img.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_ori2geo_img.diminfo[1].strides) = (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_data.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_data.diminfo[0].strides)); - - /* "SAR_GEO.pyx":74 - * while ipybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_row_ids.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("SAR_GEO.insert_data", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_col_ids.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_row_ids.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_7SAR_GEO_1insert_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_7SAR_GEO_1insert_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_ori2geo_img = 0; - PyArrayObject *__pyx_v_row_ids = 0; - PyArrayObject *__pyx_v_col_ids = 0; - PyArrayObject *__pyx_v_data = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("insert_data (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ori2geo_img,&__pyx_n_s_row_ids,&__pyx_n_s_col_ids,&__pyx_n_s_data,0}; - PyObject* values[4] = {0,0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ori2geo_img)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_row_ids)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("insert_data", 1, 4, 4, 1); __PYX_ERR(0, 69, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_col_ids)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("insert_data", 1, 4, 4, 2); __PYX_ERR(0, 69, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 3: - if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("insert_data", 1, 4, 4, 3); __PYX_ERR(0, 69, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "insert_data") < 0)) __PYX_ERR(0, 69, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - } - __pyx_v_ori2geo_img = ((PyArrayObject *)values[0]); - __pyx_v_row_ids = ((PyArrayObject *)values[1]); - __pyx_v_col_ids = ((PyArrayObject *)values[2]); - __pyx_v_data = ((PyArrayObject *)values[3]); - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("insert_data", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 69, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("SAR_GEO.insert_data", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ori2geo_img), __pyx_ptype_5numpy_ndarray, 1, "ori2geo_img", 0))) __PYX_ERR(0, 69, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_row_ids), __pyx_ptype_5numpy_ndarray, 1, "row_ids", 0))) __PYX_ERR(0, 69, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_col_ids), __pyx_ptype_5numpy_ndarray, 1, "col_ids", 0))) __PYX_ERR(0, 69, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), __pyx_ptype_5numpy_ndarray, 1, "data", 0))) __PYX_ERR(0, 69, __pyx_L1_error) - __pyx_r = __pyx_pf_7SAR_GEO_insert_data(__pyx_self, __pyx_v_ori2geo_img, __pyx_v_row_ids, __pyx_v_col_ids, __pyx_v_data); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_7SAR_GEO_insert_data(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_ori2geo_img, PyArrayObject *__pyx_v_row_ids, PyArrayObject *__pyx_v_col_ids, PyArrayObject *__pyx_v_data) { - __Pyx_LocalBuf_ND __pyx_pybuffernd_col_ids; - __Pyx_Buffer __pyx_pybuffer_col_ids; - __Pyx_LocalBuf_ND __pyx_pybuffernd_data; - __Pyx_Buffer __pyx_pybuffer_data; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ori2geo_img; - __Pyx_Buffer __pyx_pybuffer_ori2geo_img; - __Pyx_LocalBuf_ND __pyx_pybuffernd_row_ids; - __Pyx_Buffer __pyx_pybuffer_row_ids; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("insert_data", 0); - __pyx_pybuffer_ori2geo_img.pybuffer.buf = NULL; - __pyx_pybuffer_ori2geo_img.refcount = 0; - __pyx_pybuffernd_ori2geo_img.data = NULL; - __pyx_pybuffernd_ori2geo_img.rcbuffer = &__pyx_pybuffer_ori2geo_img; - __pyx_pybuffer_row_ids.pybuffer.buf = NULL; - __pyx_pybuffer_row_ids.refcount = 0; - __pyx_pybuffernd_row_ids.data = NULL; - __pyx_pybuffernd_row_ids.rcbuffer = &__pyx_pybuffer_row_ids; - __pyx_pybuffer_col_ids.pybuffer.buf = NULL; - __pyx_pybuffer_col_ids.refcount = 0; - __pyx_pybuffernd_col_ids.data = NULL; - __pyx_pybuffernd_col_ids.rcbuffer = &__pyx_pybuffer_col_ids; - __pyx_pybuffer_data.pybuffer.buf = NULL; - __pyx_pybuffer_data.refcount = 0; - __pyx_pybuffernd_data.data = NULL; - __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer, (PyObject*)__pyx_v_ori2geo_img, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 69, __pyx_L1_error) - } - __pyx_pybuffernd_ori2geo_img.diminfo[0].strides = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ori2geo_img.diminfo[0].shape = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ori2geo_img.diminfo[1].strides = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ori2geo_img.diminfo[1].shape = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.shape[1]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_row_ids.rcbuffer->pybuffer, (PyObject*)__pyx_v_row_ids, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 69, __pyx_L1_error) - } - __pyx_pybuffernd_row_ids.diminfo[0].strides = __pyx_pybuffernd_row_ids.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_row_ids.diminfo[0].shape = __pyx_pybuffernd_row_ids.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_col_ids.rcbuffer->pybuffer, (PyObject*)__pyx_v_col_ids, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 69, __pyx_L1_error) - } - __pyx_pybuffernd_col_ids.diminfo[0].strides = __pyx_pybuffernd_col_ids.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_col_ids.diminfo[0].shape = __pyx_pybuffernd_col_ids.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 69, __pyx_L1_error) - } - __pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0]; - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)__pyx_f_7SAR_GEO_insert_data(__pyx_v_ori2geo_img, __pyx_v_row_ids, __pyx_v_col_ids, __pyx_v_data, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_col_ids.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_row_ids.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("SAR_GEO.insert_data", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_col_ids.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_row_ids.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "SAR_GEO.pyx":77 - * return ori2geo_img - * - * cpdef np.ndarray[double,ndim=2] cut_L1A_img(np.ndarray[double,ndim=3] ori2geo_img,np.ndarray[double,ndim=2] roi_list): # <<<<<<<<<<<<<< - * """ roi - * """ - */ - -static PyObject *__pyx_pw_7SAR_GEO_3cut_L1A_img(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyArrayObject *__pyx_f_7SAR_GEO_cut_L1A_img(PyArrayObject *__pyx_v_ori2geo_img, PyArrayObject *__pyx_v_roi_list, CYTHON_UNUSED int __pyx_skip_dispatch) { - int __pyx_v_height; - int __pyx_v_width; - int __pyx_v_i; - int __pyx_v_j; - struct __pyx_t_7SAR_GEO_Point __pyx_v_temp_p; - PyArrayObject *__pyx_v_mask = 0; - __Pyx_LocalBuf_ND __pyx_pybuffernd_mask; - __Pyx_Buffer __pyx_pybuffer_mask; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ori2geo_img; - __Pyx_Buffer __pyx_pybuffer_ori2geo_img; - __Pyx_LocalBuf_ND __pyx_pybuffernd_roi_list; - __Pyx_Buffer __pyx_pybuffer_roi_list; - PyArrayObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyArrayObject *__pyx_t_6 = NULL; - int __pyx_t_7; - Py_ssize_t __pyx_t_8; - Py_ssize_t __pyx_t_9; - Py_ssize_t __pyx_t_10; - int __pyx_t_11; - double __pyx_t_12; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("cut_L1A_img", 0); - __pyx_pybuffer_mask.pybuffer.buf = NULL; - __pyx_pybuffer_mask.refcount = 0; - __pyx_pybuffernd_mask.data = NULL; - __pyx_pybuffernd_mask.rcbuffer = &__pyx_pybuffer_mask; - __pyx_pybuffer_ori2geo_img.pybuffer.buf = NULL; - __pyx_pybuffer_ori2geo_img.refcount = 0; - __pyx_pybuffernd_ori2geo_img.data = NULL; - __pyx_pybuffernd_ori2geo_img.rcbuffer = &__pyx_pybuffer_ori2geo_img; - __pyx_pybuffer_roi_list.pybuffer.buf = NULL; - __pyx_pybuffer_roi_list.refcount = 0; - __pyx_pybuffernd_roi_list.data = NULL; - __pyx_pybuffernd_roi_list.rcbuffer = &__pyx_pybuffer_roi_list; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer, (PyObject*)__pyx_v_ori2geo_img, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 77, __pyx_L1_error) - } - __pyx_pybuffernd_ori2geo_img.diminfo[0].strides = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ori2geo_img.diminfo[0].shape = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ori2geo_img.diminfo[1].strides = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ori2geo_img.diminfo[1].shape = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_ori2geo_img.diminfo[2].strides = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_ori2geo_img.diminfo[2].shape = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.shape[2]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_roi_list.rcbuffer->pybuffer, (PyObject*)__pyx_v_roi_list, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 77, __pyx_L1_error) - } - __pyx_pybuffernd_roi_list.diminfo[0].strides = __pyx_pybuffernd_roi_list.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_roi_list.diminfo[0].shape = __pyx_pybuffernd_roi_list.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_roi_list.diminfo[1].strides = __pyx_pybuffernd_roi_list.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_roi_list.diminfo[1].shape = __pyx_pybuffernd_roi_list.rcbuffer->pybuffer.shape[1]; - - /* "SAR_GEO.pyx":80 - * """ roi - * """ - * cdef int height=ori2geo_img.shape[1] # <<<<<<<<<<<<<< - * cdef int width=ori2geo_img.shape[2] - * cdef int i=0 - */ - __pyx_v_height = (__pyx_v_ori2geo_img->dimensions[1]); - - /* "SAR_GEO.pyx":81 - * """ - * cdef int height=ori2geo_img.shape[1] - * cdef int width=ori2geo_img.shape[2] # <<<<<<<<<<<<<< - * cdef int i=0 - * cdef int j=0 - */ - __pyx_v_width = (__pyx_v_ori2geo_img->dimensions[2]); - - /* "SAR_GEO.pyx":82 - * cdef int height=ori2geo_img.shape[1] - * cdef int width=ori2geo_img.shape[2] - * cdef int i=0 # <<<<<<<<<<<<<< - * cdef int j=0 - * cdef Point temp_p - */ - __pyx_v_i = 0; - - /* "SAR_GEO.pyx":83 - * cdef int width=ori2geo_img.shape[2] - * cdef int i=0 - * cdef int j=0 # <<<<<<<<<<<<<< - * cdef Point temp_p - * cdef np.ndarray[double,ndim=2] mask=np.zeros((height,width),dtype=np.float64) - */ - __pyx_v_j = 0; - - /* "SAR_GEO.pyx":85 - * cdef int j=0 - * cdef Point temp_p - * cdef np.ndarray[double,ndim=2] mask=np.zeros((height,width),dtype=np.float64) # <<<<<<<<<<<<<< - * while ipybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { - __pyx_v_mask = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 85, __pyx_L1_error) - } else {__pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_mask.diminfo[1].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_mask.diminfo[1].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[1]; - } - } - __pyx_t_6 = 0; - __pyx_v_mask = ((PyArrayObject *)__pyx_t_5); - __pyx_t_5 = 0; - - /* "SAR_GEO.pyx":86 - * cdef Point temp_p - * cdef np.ndarray[double,ndim=2] mask=np.zeros((height,width),dtype=np.float64) - * while i= __pyx_pybuffernd_ori2geo_img.diminfo[0].shape)) __pyx_t_11 = 0; - if (__pyx_t_9 < 0) { - __pyx_t_9 += __pyx_pybuffernd_ori2geo_img.diminfo[1].shape; - if (unlikely(__pyx_t_9 < 0)) __pyx_t_11 = 1; - } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_ori2geo_img.diminfo[1].shape)) __pyx_t_11 = 1; - if (__pyx_t_10 < 0) { - __pyx_t_10 += __pyx_pybuffernd_ori2geo_img.diminfo[2].shape; - if (unlikely(__pyx_t_10 < 0)) __pyx_t_11 = 2; - } else if (unlikely(__pyx_t_10 >= __pyx_pybuffernd_ori2geo_img.diminfo[2].shape)) __pyx_t_11 = 2; - if (unlikely(__pyx_t_11 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_11); - __PYX_ERR(0, 89, __pyx_L1_error) - } - __pyx_v_temp_p.x = (*__Pyx_BufPtrStrided3d(double *, __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_ori2geo_img.diminfo[0].strides, __pyx_t_9, __pyx_pybuffernd_ori2geo_img.diminfo[1].strides, __pyx_t_10, __pyx_pybuffernd_ori2geo_img.diminfo[2].strides)); - - /* "SAR_GEO.pyx":90 - * while j= __pyx_pybuffernd_ori2geo_img.diminfo[0].shape)) __pyx_t_11 = 0; - if (__pyx_t_9 < 0) { - __pyx_t_9 += __pyx_pybuffernd_ori2geo_img.diminfo[1].shape; - if (unlikely(__pyx_t_9 < 0)) __pyx_t_11 = 1; - } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_ori2geo_img.diminfo[1].shape)) __pyx_t_11 = 1; - if (__pyx_t_8 < 0) { - __pyx_t_8 += __pyx_pybuffernd_ori2geo_img.diminfo[2].shape; - if (unlikely(__pyx_t_8 < 0)) __pyx_t_11 = 2; - } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_ori2geo_img.diminfo[2].shape)) __pyx_t_11 = 2; - if (unlikely(__pyx_t_11 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_11); - __PYX_ERR(0, 90, __pyx_L1_error) - } - __pyx_v_temp_p.y = (*__Pyx_BufPtrStrided3d(double *, __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_ori2geo_img.diminfo[0].strides, __pyx_t_9, __pyx_pybuffernd_ori2geo_img.diminfo[1].strides, __pyx_t_8, __pyx_pybuffernd_ori2geo_img.diminfo[2].strides)); - - /* "SAR_GEO.pyx":91 - * temp_p.x=ori2geo_img[0,i,j] # temp_p - * temp_p.y=ori2geo_img[1,i,j] # temp_p - * if rayCasting(temp_p,roi_list)==1: # <<<<<<<<<<<<<< - * mask[i,j]=1 - * else: - */ - __pyx_t_7 = ((__pyx_f_7SAR_GEO_rayCasting(__pyx_v_temp_p, ((PyArrayObject *)__pyx_v_roi_list)) == 1) != 0); - if (__pyx_t_7) { - - /* "SAR_GEO.pyx":92 - * temp_p.y=ori2geo_img[1,i,j] # temp_p - * if rayCasting(temp_p,roi_list)==1: - * mask[i,j]=1 # <<<<<<<<<<<<<< - * else: - * mask[i,j]=np.nan - */ - __pyx_t_8 = __pyx_v_i; - __pyx_t_9 = __pyx_v_j; - __pyx_t_11 = -1; - if (__pyx_t_8 < 0) { - __pyx_t_8 += __pyx_pybuffernd_mask.diminfo[0].shape; - if (unlikely(__pyx_t_8 < 0)) __pyx_t_11 = 0; - } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_mask.diminfo[0].shape)) __pyx_t_11 = 0; - if (__pyx_t_9 < 0) { - __pyx_t_9 += __pyx_pybuffernd_mask.diminfo[1].shape; - if (unlikely(__pyx_t_9 < 0)) __pyx_t_11 = 1; - } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_mask.diminfo[1].shape)) __pyx_t_11 = 1; - if (unlikely(__pyx_t_11 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_11); - __PYX_ERR(0, 92, __pyx_L1_error) - } - *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_9, __pyx_pybuffernd_mask.diminfo[1].strides) = 1.0; - - /* "SAR_GEO.pyx":91 - * temp_p.x=ori2geo_img[0,i,j] # temp_p - * temp_p.y=ori2geo_img[1,i,j] # temp_p - * if rayCasting(temp_p,roi_list)==1: # <<<<<<<<<<<<<< - * mask[i,j]=1 - * else: - */ - goto __pyx_L7; - } - - /* "SAR_GEO.pyx":94 - * mask[i,j]=1 - * else: - * mask[i,j]=np.nan # <<<<<<<<<<<<<< - * j=j+1 - * i=i+1 - */ - /*else*/ { - __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 94, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_nan); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 94, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_9 = __pyx_v_i; - __pyx_t_8 = __pyx_v_j; - __pyx_t_11 = -1; - if (__pyx_t_9 < 0) { - __pyx_t_9 += __pyx_pybuffernd_mask.diminfo[0].shape; - if (unlikely(__pyx_t_9 < 0)) __pyx_t_11 = 0; - } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_mask.diminfo[0].shape)) __pyx_t_11 = 0; - if (__pyx_t_8 < 0) { - __pyx_t_8 += __pyx_pybuffernd_mask.diminfo[1].shape; - if (unlikely(__pyx_t_8 < 0)) __pyx_t_11 = 1; - } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_mask.diminfo[1].shape)) __pyx_t_11 = 1; - if (unlikely(__pyx_t_11 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_11); - __PYX_ERR(0, 94, __pyx_L1_error) - } - *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_mask.diminfo[1].strides) = __pyx_t_12; - } - __pyx_L7:; - - /* "SAR_GEO.pyx":95 - * else: - * mask[i,j]=np.nan - * j=j+1 # <<<<<<<<<<<<<< - * i=i+1 - * return mask - */ - __pyx_v_j = (__pyx_v_j + 1); - } - - /* "SAR_GEO.pyx":96 - * mask[i,j]=np.nan - * j=j+1 - * i=i+1 # <<<<<<<<<<<<<< - * return mask - * - */ - __pyx_v_i = (__pyx_v_i + 1); - } - - /* "SAR_GEO.pyx":97 - * j=j+1 - * i=i+1 - * return mask # <<<<<<<<<<<<<< - * - * cpdef np.ndarray[double,ndim=2] gereratorMask(np.ndarray[double,ndim=1] rlist,np.ndarray[double,ndim=1] clist,np.ndarray[double,ndim=2] mask): - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_mask)); - __pyx_r = ((PyArrayObject *)__pyx_v_mask); - goto __pyx_L0; - - /* "SAR_GEO.pyx":77 - * return ori2geo_img - * - * cpdef np.ndarray[double,ndim=2] cut_L1A_img(np.ndarray[double,ndim=3] ori2geo_img,np.ndarray[double,ndim=2] roi_list): # <<<<<<<<<<<<<< - * """ roi - * """ - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_roi_list.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("SAR_GEO.cut_L1A_img", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_roi_list.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_mask); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_7SAR_GEO_3cut_L1A_img(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7SAR_GEO_2cut_L1A_img[] = " \346\240\271\346\215\256roi \350\216\267\345\217\226\346\240\205\346\240\274\345\257\271\350\261\241\n "; -static PyObject *__pyx_pw_7SAR_GEO_3cut_L1A_img(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_ori2geo_img = 0; - PyArrayObject *__pyx_v_roi_list = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("cut_L1A_img (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ori2geo_img,&__pyx_n_s_roi_list,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ori2geo_img)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_roi_list)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("cut_L1A_img", 1, 2, 2, 1); __PYX_ERR(0, 77, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cut_L1A_img") < 0)) __PYX_ERR(0, 77, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_ori2geo_img = ((PyArrayObject *)values[0]); - __pyx_v_roi_list = ((PyArrayObject *)values[1]); - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("cut_L1A_img", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 77, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("SAR_GEO.cut_L1A_img", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ori2geo_img), __pyx_ptype_5numpy_ndarray, 1, "ori2geo_img", 0))) __PYX_ERR(0, 77, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_roi_list), __pyx_ptype_5numpy_ndarray, 1, "roi_list", 0))) __PYX_ERR(0, 77, __pyx_L1_error) - __pyx_r = __pyx_pf_7SAR_GEO_2cut_L1A_img(__pyx_self, __pyx_v_ori2geo_img, __pyx_v_roi_list); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_7SAR_GEO_2cut_L1A_img(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_ori2geo_img, PyArrayObject *__pyx_v_roi_list) { - __Pyx_LocalBuf_ND __pyx_pybuffernd_ori2geo_img; - __Pyx_Buffer __pyx_pybuffer_ori2geo_img; - __Pyx_LocalBuf_ND __pyx_pybuffernd_roi_list; - __Pyx_Buffer __pyx_pybuffer_roi_list; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("cut_L1A_img", 0); - __pyx_pybuffer_ori2geo_img.pybuffer.buf = NULL; - __pyx_pybuffer_ori2geo_img.refcount = 0; - __pyx_pybuffernd_ori2geo_img.data = NULL; - __pyx_pybuffernd_ori2geo_img.rcbuffer = &__pyx_pybuffer_ori2geo_img; - __pyx_pybuffer_roi_list.pybuffer.buf = NULL; - __pyx_pybuffer_roi_list.refcount = 0; - __pyx_pybuffernd_roi_list.data = NULL; - __pyx_pybuffernd_roi_list.rcbuffer = &__pyx_pybuffer_roi_list; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer, (PyObject*)__pyx_v_ori2geo_img, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 77, __pyx_L1_error) - } - __pyx_pybuffernd_ori2geo_img.diminfo[0].strides = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ori2geo_img.diminfo[0].shape = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ori2geo_img.diminfo[1].strides = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ori2geo_img.diminfo[1].shape = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_ori2geo_img.diminfo[2].strides = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_ori2geo_img.diminfo[2].shape = __pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer.shape[2]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_roi_list.rcbuffer->pybuffer, (PyObject*)__pyx_v_roi_list, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 77, __pyx_L1_error) - } - __pyx_pybuffernd_roi_list.diminfo[0].strides = __pyx_pybuffernd_roi_list.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_roi_list.diminfo[0].shape = __pyx_pybuffernd_roi_list.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_roi_list.diminfo[1].strides = __pyx_pybuffernd_roi_list.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_roi_list.diminfo[1].shape = __pyx_pybuffernd_roi_list.rcbuffer->pybuffer.shape[1]; - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)__pyx_f_7SAR_GEO_cut_L1A_img(__pyx_v_ori2geo_img, __pyx_v_roi_list, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_roi_list.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("SAR_GEO.cut_L1A_img", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo_img.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_roi_list.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "SAR_GEO.pyx":99 - * return mask - * - * cpdef np.ndarray[double,ndim=2] gereratorMask(np.ndarray[double,ndim=1] rlist,np.ndarray[double,ndim=1] clist,np.ndarray[double,ndim=2] mask): # <<<<<<<<<<<<<< - * cdef int rcount=rlist.shape[0] - * cdef int ccount=clist.shape[0] - */ - -static PyObject *__pyx_pw_7SAR_GEO_5gereratorMask(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyArrayObject *__pyx_f_7SAR_GEO_gereratorMask(PyArrayObject *__pyx_v_rlist, PyArrayObject *__pyx_v_clist, PyArrayObject *__pyx_v_mask, CYTHON_UNUSED int __pyx_skip_dispatch) { - int __pyx_v_rcount; - int __pyx_v_ccount; - int __pyx_v_count; - int __pyx_v_i; - CYTHON_UNUSED int __pyx_v_j; - int __pyx_v_temp_row; - int __pyx_v_temp_col; - int __pyx_v_height; - int __pyx_v_width; - __Pyx_LocalBuf_ND __pyx_pybuffernd_clist; - __Pyx_Buffer __pyx_pybuffer_clist; - __Pyx_LocalBuf_ND __pyx_pybuffernd_mask; - __Pyx_Buffer __pyx_pybuffer_mask; - __Pyx_LocalBuf_ND __pyx_pybuffernd_rlist; - __Pyx_Buffer __pyx_pybuffer_rlist; - PyArrayObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - Py_ssize_t __pyx_t_3; - int __pyx_t_4; - Py_ssize_t __pyx_t_5; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gereratorMask", 0); - __pyx_pybuffer_rlist.pybuffer.buf = NULL; - __pyx_pybuffer_rlist.refcount = 0; - __pyx_pybuffernd_rlist.data = NULL; - __pyx_pybuffernd_rlist.rcbuffer = &__pyx_pybuffer_rlist; - __pyx_pybuffer_clist.pybuffer.buf = NULL; - __pyx_pybuffer_clist.refcount = 0; - __pyx_pybuffernd_clist.data = NULL; - __pyx_pybuffernd_clist.rcbuffer = &__pyx_pybuffer_clist; - __pyx_pybuffer_mask.pybuffer.buf = NULL; - __pyx_pybuffer_mask.refcount = 0; - __pyx_pybuffernd_mask.data = NULL; - __pyx_pybuffernd_mask.rcbuffer = &__pyx_pybuffer_mask; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_rlist.rcbuffer->pybuffer, (PyObject*)__pyx_v_rlist, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 99, __pyx_L1_error) - } - __pyx_pybuffernd_rlist.diminfo[0].strides = __pyx_pybuffernd_rlist.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_rlist.diminfo[0].shape = __pyx_pybuffernd_rlist.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_clist.rcbuffer->pybuffer, (PyObject*)__pyx_v_clist, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 99, __pyx_L1_error) - } - __pyx_pybuffernd_clist.diminfo[0].strides = __pyx_pybuffernd_clist.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_clist.diminfo[0].shape = __pyx_pybuffernd_clist.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 99, __pyx_L1_error) - } - __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_mask.diminfo[1].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_mask.diminfo[1].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[1]; - - /* "SAR_GEO.pyx":100 - * - * cpdef np.ndarray[double,ndim=2] gereratorMask(np.ndarray[double,ndim=1] rlist,np.ndarray[double,ndim=1] clist,np.ndarray[double,ndim=2] mask): - * cdef int rcount=rlist.shape[0] # <<<<<<<<<<<<<< - * cdef int ccount=clist.shape[0] - * cdef int count=rcount if rcountdimensions[0]); - - /* "SAR_GEO.pyx":101 - * cpdef np.ndarray[double,ndim=2] gereratorMask(np.ndarray[double,ndim=1] rlist,np.ndarray[double,ndim=1] clist,np.ndarray[double,ndim=2] mask): - * cdef int rcount=rlist.shape[0] - * cdef int ccount=clist.shape[0] # <<<<<<<<<<<<<< - * cdef int count=rcount if rcountdimensions[0]); - - /* "SAR_GEO.pyx":102 - * cdef int rcount=rlist.shape[0] - * cdef int ccount=clist.shape[0] - * cdef int count=rcount if rcountdimensions[0]); - - /* "SAR_GEO.pyx":108 - * cdef int temp_col=0 - * cdef int height=mask.shape[0] - * cdef int width=mask.shape[1] # <<<<<<<<<<<<<< - * while idimensions[1]); - - /* "SAR_GEO.pyx":109 - * cdef int height=mask.shape[0] - * cdef int width=mask.shape[1] - * while i= __pyx_pybuffernd_rlist.diminfo[0].shape)) __pyx_t_1 = 0; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 112, __pyx_L1_error) - } - __pyx_v_temp_row = ((int)ceil((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_rlist.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_rlist.diminfo[0].strides)))); - - /* "SAR_GEO.pyx":113 - * # 1 - * temp_row=int(ceil(rlist[i])) - * temp_col=int(ceil(clist[i])) # <<<<<<<<<<<<<< - * - * if temp_row>=0 and temp_col>=0 and temp_row= __pyx_pybuffernd_clist.diminfo[0].shape)) __pyx_t_1 = 0; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 113, __pyx_L1_error) - } - __pyx_v_temp_col = ((int)ceil((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_clist.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_clist.diminfo[0].strides)))); - - /* "SAR_GEO.pyx":115 - * temp_col=int(ceil(clist[i])) - * - * if temp_row>=0 and temp_col>=0 and temp_row= 0) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_col >= 0) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_row < __pyx_v_height) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_col < __pyx_v_width) != 0); - __pyx_t_2 = __pyx_t_4; - __pyx_L6_bool_binop_done:; - if (__pyx_t_2) { - - /* "SAR_GEO.pyx":116 - * - * if temp_row>=0 and temp_col>=0 and temp_row= __pyx_pybuffernd_mask.diminfo[0].shape)) __pyx_t_1 = 0; - if (__pyx_t_5 < 0) { - __pyx_t_5 += __pyx_pybuffernd_mask.diminfo[1].shape; - if (unlikely(__pyx_t_5 < 0)) __pyx_t_1 = 1; - } else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_mask.diminfo[1].shape)) __pyx_t_1 = 1; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 116, __pyx_L1_error) - } - *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_5, __pyx_pybuffernd_mask.diminfo[1].strides) = 1.0; - - /* "SAR_GEO.pyx":115 - * temp_col=int(ceil(clist[i])) - * - * if temp_row>=0 and temp_col>=0 and temp_row=0 and temp_col>=0 and temp_row= __pyx_pybuffernd_rlist.diminfo[0].shape)) __pyx_t_1 = 0; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 119, __pyx_L1_error) - } - __pyx_v_temp_row = ((int)floor((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_rlist.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_rlist.diminfo[0].strides)))); - - /* "SAR_GEO.pyx":120 - * # 2 - * temp_row=int(floor(rlist[i])) - * temp_col=int(ceil(clist[i])) # <<<<<<<<<<<<<< - * if temp_row>=0 and temp_col>=0 and temp_row= __pyx_pybuffernd_clist.diminfo[0].shape)) __pyx_t_1 = 0; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 120, __pyx_L1_error) - } - __pyx_v_temp_col = ((int)ceil((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_clist.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_clist.diminfo[0].strides)))); - - /* "SAR_GEO.pyx":121 - * temp_row=int(floor(rlist[i])) - * temp_col=int(ceil(clist[i])) - * if temp_row>=0 and temp_col>=0 and temp_row= 0) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_col >= 0) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_row < __pyx_v_height) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_col < __pyx_v_width) != 0); - __pyx_t_2 = __pyx_t_4; - __pyx_L11_bool_binop_done:; - if (__pyx_t_2) { - - /* "SAR_GEO.pyx":122 - * temp_col=int(ceil(clist[i])) - * if temp_row>=0 and temp_col>=0 and temp_row= __pyx_pybuffernd_mask.diminfo[0].shape)) __pyx_t_1 = 0; - if (__pyx_t_3 < 0) { - __pyx_t_3 += __pyx_pybuffernd_mask.diminfo[1].shape; - if (unlikely(__pyx_t_3 < 0)) __pyx_t_1 = 1; - } else if (unlikely(__pyx_t_3 >= __pyx_pybuffernd_mask.diminfo[1].shape)) __pyx_t_1 = 1; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 122, __pyx_L1_error) - } - *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_3, __pyx_pybuffernd_mask.diminfo[1].strides) = 1.0; - - /* "SAR_GEO.pyx":121 - * temp_row=int(floor(rlist[i])) - * temp_col=int(ceil(clist[i])) - * if temp_row>=0 and temp_col>=0 and temp_row=0 and temp_col>=0 and temp_row= __pyx_pybuffernd_rlist.diminfo[0].shape)) __pyx_t_1 = 0; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 125, __pyx_L1_error) - } - __pyx_v_temp_row = ((int)ceil((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_rlist.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_rlist.diminfo[0].strides)))); - - /* "SAR_GEO.pyx":126 - * # 3 - * temp_row=int(ceil(rlist[i])) - * temp_col=int(floor(clist[i])) # <<<<<<<<<<<<<< - * if temp_row>=0 and temp_col>=0 and temp_row= __pyx_pybuffernd_clist.diminfo[0].shape)) __pyx_t_1 = 0; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 126, __pyx_L1_error) - } - __pyx_v_temp_col = ((int)floor((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_clist.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_clist.diminfo[0].strides)))); - - /* "SAR_GEO.pyx":127 - * temp_row=int(ceil(rlist[i])) - * temp_col=int(floor(clist[i])) - * if temp_row>=0 and temp_col>=0 and temp_row= 0) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L16_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_col >= 0) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L16_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_row < __pyx_v_height) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L16_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_col < __pyx_v_width) != 0); - __pyx_t_2 = __pyx_t_4; - __pyx_L16_bool_binop_done:; - if (__pyx_t_2) { - - /* "SAR_GEO.pyx":128 - * temp_col=int(floor(clist[i])) - * if temp_row>=0 and temp_col>=0 and temp_row= __pyx_pybuffernd_mask.diminfo[0].shape)) __pyx_t_1 = 0; - if (__pyx_t_5 < 0) { - __pyx_t_5 += __pyx_pybuffernd_mask.diminfo[1].shape; - if (unlikely(__pyx_t_5 < 0)) __pyx_t_1 = 1; - } else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_mask.diminfo[1].shape)) __pyx_t_1 = 1; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 128, __pyx_L1_error) - } - *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_5, __pyx_pybuffernd_mask.diminfo[1].strides) = 1.0; - - /* "SAR_GEO.pyx":127 - * temp_row=int(ceil(rlist[i])) - * temp_col=int(floor(clist[i])) - * if temp_row>=0 and temp_col>=0 and temp_row=0 and temp_col>=0 and temp_row= __pyx_pybuffernd_rlist.diminfo[0].shape)) __pyx_t_1 = 0; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 130, __pyx_L1_error) - } - __pyx_v_temp_row = ((int)floor((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_rlist.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_rlist.diminfo[0].strides)))); - - /* "SAR_GEO.pyx":131 - * # 4 - * temp_row=int(floor(rlist[i])) - * temp_col=int(floor(clist[i])) # <<<<<<<<<<<<<< - * if temp_row>=0 and temp_col>=0 and temp_row= __pyx_pybuffernd_clist.diminfo[0].shape)) __pyx_t_1 = 0; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 131, __pyx_L1_error) - } - __pyx_v_temp_col = ((int)floor((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_clist.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_clist.diminfo[0].strides)))); - - /* "SAR_GEO.pyx":132 - * temp_row=int(floor(rlist[i])) - * temp_col=int(floor(clist[i])) - * if temp_row>=0 and temp_col>=0 and temp_row= 0) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L21_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_col >= 0) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L21_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_row < __pyx_v_height) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L21_bool_binop_done; - } - __pyx_t_4 = ((__pyx_v_temp_col < __pyx_v_width) != 0); - __pyx_t_2 = __pyx_t_4; - __pyx_L21_bool_binop_done:; - if (__pyx_t_2) { - - /* "SAR_GEO.pyx":133 - * temp_col=int(floor(clist[i])) - * if temp_row>=0 and temp_col>=0 and temp_row= __pyx_pybuffernd_mask.diminfo[0].shape)) __pyx_t_1 = 0; - if (__pyx_t_3 < 0) { - __pyx_t_3 += __pyx_pybuffernd_mask.diminfo[1].shape; - if (unlikely(__pyx_t_3 < 0)) __pyx_t_1 = 1; - } else if (unlikely(__pyx_t_3 >= __pyx_pybuffernd_mask.diminfo[1].shape)) __pyx_t_1 = 1; - if (unlikely(__pyx_t_1 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_1); - __PYX_ERR(0, 133, __pyx_L1_error) - } - *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_mask.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_mask.diminfo[0].strides, __pyx_t_3, __pyx_pybuffernd_mask.diminfo[1].strides) = 1.0; - - /* "SAR_GEO.pyx":132 - * temp_row=int(floor(rlist[i])) - * temp_col=int(floor(clist[i])) - * if temp_row>=0 and temp_col>=0 and temp_row=0 and temp_col>=0 and temp_rowpybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_rlist.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("SAR_GEO.gereratorMask", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_clist.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_rlist.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_7SAR_GEO_5gereratorMask(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_7SAR_GEO_5gereratorMask(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_rlist = 0; - PyArrayObject *__pyx_v_clist = 0; - PyArrayObject *__pyx_v_mask = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("gereratorMask (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_rlist,&__pyx_n_s_clist,&__pyx_n_s_mask,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rlist)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_clist)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("gereratorMask", 1, 3, 3, 1); __PYX_ERR(0, 99, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("gereratorMask", 1, 3, 3, 2); __PYX_ERR(0, 99, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gereratorMask") < 0)) __PYX_ERR(0, 99, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_rlist = ((PyArrayObject *)values[0]); - __pyx_v_clist = ((PyArrayObject *)values[1]); - __pyx_v_mask = ((PyArrayObject *)values[2]); - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("gereratorMask", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 99, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("SAR_GEO.gereratorMask", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_rlist), __pyx_ptype_5numpy_ndarray, 1, "rlist", 0))) __PYX_ERR(0, 99, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_clist), __pyx_ptype_5numpy_ndarray, 1, "clist", 0))) __PYX_ERR(0, 99, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_5numpy_ndarray, 1, "mask", 0))) __PYX_ERR(0, 99, __pyx_L1_error) - __pyx_r = __pyx_pf_7SAR_GEO_4gereratorMask(__pyx_self, __pyx_v_rlist, __pyx_v_clist, __pyx_v_mask); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_7SAR_GEO_4gereratorMask(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_rlist, PyArrayObject *__pyx_v_clist, PyArrayObject *__pyx_v_mask) { - __Pyx_LocalBuf_ND __pyx_pybuffernd_clist; - __Pyx_Buffer __pyx_pybuffer_clist; - __Pyx_LocalBuf_ND __pyx_pybuffernd_mask; - __Pyx_Buffer __pyx_pybuffer_mask; - __Pyx_LocalBuf_ND __pyx_pybuffernd_rlist; - __Pyx_Buffer __pyx_pybuffer_rlist; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("gereratorMask", 0); - __pyx_pybuffer_rlist.pybuffer.buf = NULL; - __pyx_pybuffer_rlist.refcount = 0; - __pyx_pybuffernd_rlist.data = NULL; - __pyx_pybuffernd_rlist.rcbuffer = &__pyx_pybuffer_rlist; - __pyx_pybuffer_clist.pybuffer.buf = NULL; - __pyx_pybuffer_clist.refcount = 0; - __pyx_pybuffernd_clist.data = NULL; - __pyx_pybuffernd_clist.rcbuffer = &__pyx_pybuffer_clist; - __pyx_pybuffer_mask.pybuffer.buf = NULL; - __pyx_pybuffer_mask.refcount = 0; - __pyx_pybuffernd_mask.data = NULL; - __pyx_pybuffernd_mask.rcbuffer = &__pyx_pybuffer_mask; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_rlist.rcbuffer->pybuffer, (PyObject*)__pyx_v_rlist, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 99, __pyx_L1_error) - } - __pyx_pybuffernd_rlist.diminfo[0].strides = __pyx_pybuffernd_rlist.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_rlist.diminfo[0].shape = __pyx_pybuffernd_rlist.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_clist.rcbuffer->pybuffer, (PyObject*)__pyx_v_clist, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 99, __pyx_L1_error) - } - __pyx_pybuffernd_clist.diminfo[0].strides = __pyx_pybuffernd_clist.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_clist.diminfo[0].shape = __pyx_pybuffernd_clist.rcbuffer->pybuffer.shape[0]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 99, __pyx_L1_error) - } - __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_mask.diminfo[1].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_mask.diminfo[1].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[1]; - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)__pyx_f_7SAR_GEO_gereratorMask(__pyx_v_rlist, __pyx_v_clist, __pyx_v_mask, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_clist.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_rlist.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("SAR_GEO.gereratorMask", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_clist.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_rlist.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "SAR_GEO.pyx":139 - * - * - * cdef double distance_powe(Point p1,Point p2): # <<<<<<<<<<<<<< - * return (p1.x-p2.x)**2+(p1.y-p2.y)**2 - * - */ - -static double __pyx_f_7SAR_GEO_distance_powe(struct __pyx_t_7SAR_GEO_Point __pyx_v_p1, struct __pyx_t_7SAR_GEO_Point __pyx_v_p2) { - double __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("distance_powe", 0); - - /* "SAR_GEO.pyx":140 - * - * cdef double distance_powe(Point p1,Point p2): - * return (p1.x-p2.x)**2+(p1.y-p2.y)**2 # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = (pow((__pyx_v_p1.x - __pyx_v_p2.x), 2.0) + pow((__pyx_v_p1.y - __pyx_v_p2.y), 2.0)); - goto __pyx_L0; - - /* "SAR_GEO.pyx":139 - * - * - * cdef double distance_powe(Point p1,Point p2): # <<<<<<<<<<<<<< - * return (p1.x-p2.x)**2+(p1.y-p2.y)**2 - * - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "SAR_GEO.pyx":149 - * - * - * cpdef np.ndarray[int,ndim=2] get_r_c(np.ndarray[double,ndim=3] ori2geo,np.ndarray[double,ndim=2] lon_lat): # <<<<<<<<<<<<<< - * cdef int p_count=lon_lat.shape[0] - * cdef int height=ori2geo.shape[1] - */ - -static PyObject *__pyx_pw_7SAR_GEO_7get_r_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyArrayObject *__pyx_f_7SAR_GEO_get_r_c(PyArrayObject *__pyx_v_ori2geo, PyArrayObject *__pyx_v_lon_lat, CYTHON_UNUSED int __pyx_skip_dispatch) { - int __pyx_v_p_count; - CYTHON_UNUSED int __pyx_v_height; - CYTHON_UNUSED int __pyx_v_width; - CYTHON_UNUSED int __pyx_v_i; - CYTHON_UNUSED int __pyx_v_j; - int __pyx_v_c; - CYTHON_UNUSED double __pyx_v_dist; - CYTHON_UNUSED double __pyx_v_temp_dist; - struct __pyx_t_7SAR_GEO_Point __pyx_v_p1; - struct __pyx_t_7SAR_GEO_Point __pyx_v_p2; - CYTHON_UNUSED PyArrayObject *__pyx_v_result = 0; - double __pyx_v_min_lon; - double __pyx_v_max_lon; - double __pyx_v_min_lat; - double __pyx_v_max_lat; - __Pyx_LocalBuf_ND __pyx_pybuffernd_lon_lat; - __Pyx_Buffer __pyx_pybuffer_lon_lat; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ori2geo; - __Pyx_Buffer __pyx_pybuffer_ori2geo; - __Pyx_LocalBuf_ND __pyx_pybuffernd_result; - __Pyx_Buffer __pyx_pybuffer_result; - PyArrayObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyArrayObject *__pyx_t_5 = NULL; - double __pyx_t_6; - int __pyx_t_7; - Py_ssize_t __pyx_t_8; - Py_ssize_t __pyx_t_9; - int __pyx_t_10; - int __pyx_t_11; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_r_c", 0); - __pyx_pybuffer_result.pybuffer.buf = NULL; - __pyx_pybuffer_result.refcount = 0; - __pyx_pybuffernd_result.data = NULL; - __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result; - __pyx_pybuffer_ori2geo.pybuffer.buf = NULL; - __pyx_pybuffer_ori2geo.refcount = 0; - __pyx_pybuffernd_ori2geo.data = NULL; - __pyx_pybuffernd_ori2geo.rcbuffer = &__pyx_pybuffer_ori2geo; - __pyx_pybuffer_lon_lat.pybuffer.buf = NULL; - __pyx_pybuffer_lon_lat.refcount = 0; - __pyx_pybuffernd_lon_lat.data = NULL; - __pyx_pybuffernd_lon_lat.rcbuffer = &__pyx_pybuffer_lon_lat; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ori2geo.rcbuffer->pybuffer, (PyObject*)__pyx_v_ori2geo, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 149, __pyx_L1_error) - } - __pyx_pybuffernd_ori2geo.diminfo[0].strides = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ori2geo.diminfo[0].shape = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ori2geo.diminfo[1].strides = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ori2geo.diminfo[1].shape = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_ori2geo.diminfo[2].strides = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_ori2geo.diminfo[2].shape = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.shape[2]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_lon_lat.rcbuffer->pybuffer, (PyObject*)__pyx_v_lon_lat, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 149, __pyx_L1_error) - } - __pyx_pybuffernd_lon_lat.diminfo[0].strides = __pyx_pybuffernd_lon_lat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_lon_lat.diminfo[0].shape = __pyx_pybuffernd_lon_lat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_lon_lat.diminfo[1].strides = __pyx_pybuffernd_lon_lat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_lon_lat.diminfo[1].shape = __pyx_pybuffernd_lon_lat.rcbuffer->pybuffer.shape[1]; - - /* "SAR_GEO.pyx":150 - * - * cpdef np.ndarray[int,ndim=2] get_r_c(np.ndarray[double,ndim=3] ori2geo,np.ndarray[double,ndim=2] lon_lat): - * cdef int p_count=lon_lat.shape[0] # <<<<<<<<<<<<<< - * cdef int height=ori2geo.shape[1] - * cdef int width=ori2geo.shape[2] - */ - __pyx_v_p_count = (__pyx_v_lon_lat->dimensions[0]); - - /* "SAR_GEO.pyx":151 - * cpdef np.ndarray[int,ndim=2] get_r_c(np.ndarray[double,ndim=3] ori2geo,np.ndarray[double,ndim=2] lon_lat): - * cdef int p_count=lon_lat.shape[0] - * cdef int height=ori2geo.shape[1] # <<<<<<<<<<<<<< - * cdef int width=ori2geo.shape[2] - * cdef int i=0 - */ - __pyx_v_height = (__pyx_v_ori2geo->dimensions[1]); - - /* "SAR_GEO.pyx":152 - * cdef int p_count=lon_lat.shape[0] - * cdef int height=ori2geo.shape[1] - * cdef int width=ori2geo.shape[2] # <<<<<<<<<<<<<< - * cdef int i=0 - * cdef int j=0 - */ - __pyx_v_width = (__pyx_v_ori2geo->dimensions[2]); - - /* "SAR_GEO.pyx":153 - * cdef int height=ori2geo.shape[1] - * cdef int width=ori2geo.shape[2] - * cdef int i=0 # <<<<<<<<<<<<<< - * cdef int j=0 - * cdef int c=0 - */ - __pyx_v_i = 0; - - /* "SAR_GEO.pyx":154 - * cdef int width=ori2geo.shape[2] - * cdef int i=0 - * cdef int j=0 # <<<<<<<<<<<<<< - * cdef int c=0 - * cdef double dist=999 - */ - __pyx_v_j = 0; - - /* "SAR_GEO.pyx":155 - * cdef int i=0 - * cdef int j=0 - * cdef int c=0 # <<<<<<<<<<<<<< - * cdef double dist=999 - * cdef double temp_dist=0 - */ - __pyx_v_c = 0; - - /* "SAR_GEO.pyx":156 - * cdef int j=0 - * cdef int c=0 - * cdef double dist=999 # <<<<<<<<<<<<<< - * cdef double temp_dist=0 - * cdef Point p1 - */ - __pyx_v_dist = 999.0; - - /* "SAR_GEO.pyx":157 - * cdef int c=0 - * cdef double dist=999 - * cdef double temp_dist=0 # <<<<<<<<<<<<<< - * cdef Point p1 - * cdef Point p2 - */ - __pyx_v_temp_dist = 0.0; - - /* "SAR_GEO.pyx":162 - * cdef int min_i - * cdef int min_j - * cdef np.ndarray[double,ndim=2] result=np.ones((p_count,2))*-1 # <<<<<<<<<<<<<< - * - * - */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ones); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_p_count); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); - __Pyx_INCREF(__pyx_int_2); - __Pyx_GIVEREF(__pyx_int_2); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_2); - __pyx_t_2 = 0; - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_int_neg_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 162, __pyx_L1_error) - __pyx_t_5 = ((PyArrayObject *)__pyx_t_3); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { - __pyx_v_result = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_result.rcbuffer->pybuffer.buf = NULL; - __PYX_ERR(0, 162, __pyx_L1_error) - } else {__pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_result.diminfo[1].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_result.diminfo[1].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[1]; - } - } - __pyx_t_5 = 0; - __pyx_v_result = ((PyArrayObject *)__pyx_t_3); - __pyx_t_3 = 0; - - /* "SAR_GEO.pyx":166 - * - * # - * cdef double min_lon=np.min(ori2geo[0,:,:]) # <<<<<<<<<<<<<< - * cdef double max_lon=np.max(ori2geo[0,:,:]) - * cdef double min_lat=np.min(ori2geo[1,:,:]) - */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_min); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_ori2geo), __pyx_tuple__2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_min_lon = __pyx_t_6; - - /* "SAR_GEO.pyx":167 - * # - * cdef double min_lon=np.min(ori2geo[0,:,:]) - * cdef double max_lon=np.max(ori2geo[0,:,:]) # <<<<<<<<<<<<<< - * cdef double min_lat=np.min(ori2geo[1,:,:]) - * cdef double max_lat=np.max(ori2geo[1,:,:]) - */ - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_max); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_ori2geo), __pyx_tuple__2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 167, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_max_lon = __pyx_t_6; - - /* "SAR_GEO.pyx":168 - * cdef double min_lon=np.min(ori2geo[0,:,:]) - * cdef double max_lon=np.max(ori2geo[0,:,:]) - * cdef double min_lat=np.min(ori2geo[1,:,:]) # <<<<<<<<<<<<<< - * cdef double max_lat=np.max(ori2geo[1,:,:]) - * while cp1.x or max_lonmax_lat: - */ - __pyx_t_8 = __pyx_v_c; - __pyx_t_9 = 0; - __pyx_t_10 = -1; - if (__pyx_t_8 < 0) { - __pyx_t_8 += __pyx_pybuffernd_lon_lat.diminfo[0].shape; - if (unlikely(__pyx_t_8 < 0)) __pyx_t_10 = 0; - } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_lon_lat.diminfo[0].shape)) __pyx_t_10 = 0; - if (__pyx_t_9 < 0) { - __pyx_t_9 += __pyx_pybuffernd_lon_lat.diminfo[1].shape; - if (unlikely(__pyx_t_9 < 0)) __pyx_t_10 = 1; - } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_lon_lat.diminfo[1].shape)) __pyx_t_10 = 1; - if (unlikely(__pyx_t_10 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 171, __pyx_L1_error) - } - __pyx_v_p1.x = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_lon_lat.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_lon_lat.diminfo[0].strides, __pyx_t_9, __pyx_pybuffernd_lon_lat.diminfo[1].strides)); - - /* "SAR_GEO.pyx":172 - * while cp1.x or max_lonmax_lat: - * continue - */ - __pyx_t_9 = __pyx_v_c; - __pyx_t_8 = 1; - __pyx_t_10 = -1; - if (__pyx_t_9 < 0) { - __pyx_t_9 += __pyx_pybuffernd_lon_lat.diminfo[0].shape; - if (unlikely(__pyx_t_9 < 0)) __pyx_t_10 = 0; - } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_lon_lat.diminfo[0].shape)) __pyx_t_10 = 0; - if (__pyx_t_8 < 0) { - __pyx_t_8 += __pyx_pybuffernd_lon_lat.diminfo[1].shape; - if (unlikely(__pyx_t_8 < 0)) __pyx_t_10 = 1; - } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_lon_lat.diminfo[1].shape)) __pyx_t_10 = 1; - if (unlikely(__pyx_t_10 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_10); - __PYX_ERR(0, 172, __pyx_L1_error) - } - __pyx_v_p1.y = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_lon_lat.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_lon_lat.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_lon_lat.diminfo[1].strides)); - - /* "SAR_GEO.pyx":173 - * p1.x=lon_lat[c,0] - * p1.y=lon_lat[c,1] - * if min_lon>p1.x or max_lonmax_lat: # <<<<<<<<<<<<<< - * continue - * c=c+1 - */ - __pyx_t_11 = ((__pyx_v_min_lon > __pyx_v_p1.x) != 0); - if (!__pyx_t_11) { - } else { - __pyx_t_7 = __pyx_t_11; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_11 = ((__pyx_v_max_lon < __pyx_v_p1.x) != 0); - if (!__pyx_t_11) { - } else { - __pyx_t_7 = __pyx_t_11; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_11 = ((__pyx_v_p2.y < __pyx_v_min_lat) != 0); - if (!__pyx_t_11) { - } else { - __pyx_t_7 = __pyx_t_11; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_11 = ((__pyx_v_p2.y > __pyx_v_max_lat) != 0); - __pyx_t_7 = __pyx_t_11; - __pyx_L6_bool_binop_done:; - if (__pyx_t_7) { - - /* "SAR_GEO.pyx":174 - * p1.y=lon_lat[c,1] - * if min_lon>p1.x or max_lonmax_lat: - * continue # <<<<<<<<<<<<<< - * c=c+1 - * - */ - goto __pyx_L3_continue; - - /* "SAR_GEO.pyx":173 - * p1.x=lon_lat[c,0] - * p1.y=lon_lat[c,1] - * if min_lon>p1.x or max_lonmax_lat: # <<<<<<<<<<<<<< - * continue - * c=c+1 - */ - } - - /* "SAR_GEO.pyx":175 - * if min_lon>p1.x or max_lonmax_lat: - * continue - * c=c+1 # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_c = (__pyx_v_c + 1); - __pyx_L3_continue:; - } - - /* "SAR_GEO.pyx":149 - * - * - * cpdef np.ndarray[int,ndim=2] get_r_c(np.ndarray[double,ndim=3] ori2geo,np.ndarray[double,ndim=2] lon_lat): # <<<<<<<<<<<<<< - * cdef int p_count=lon_lat.shape[0] - * cdef int height=ori2geo.shape[1] - */ - - /* function exit code */ - __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lon_lat.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("SAR_GEO.get_r_c", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lon_lat.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_7SAR_GEO_7get_r_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_7SAR_GEO_7get_r_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_ori2geo = 0; - PyArrayObject *__pyx_v_lon_lat = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_r_c (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ori2geo,&__pyx_n_s_lon_lat,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ori2geo)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lon_lat)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("get_r_c", 1, 2, 2, 1); __PYX_ERR(0, 149, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_r_c") < 0)) __PYX_ERR(0, 149, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_ori2geo = ((PyArrayObject *)values[0]); - __pyx_v_lon_lat = ((PyArrayObject *)values[1]); - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_r_c", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 149, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("SAR_GEO.get_r_c", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ori2geo), __pyx_ptype_5numpy_ndarray, 1, "ori2geo", 0))) __PYX_ERR(0, 149, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_lon_lat), __pyx_ptype_5numpy_ndarray, 1, "lon_lat", 0))) __PYX_ERR(0, 149, __pyx_L1_error) - __pyx_r = __pyx_pf_7SAR_GEO_6get_r_c(__pyx_self, __pyx_v_ori2geo, __pyx_v_lon_lat); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_7SAR_GEO_6get_r_c(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_ori2geo, PyArrayObject *__pyx_v_lon_lat) { - __Pyx_LocalBuf_ND __pyx_pybuffernd_lon_lat; - __Pyx_Buffer __pyx_pybuffer_lon_lat; - __Pyx_LocalBuf_ND __pyx_pybuffernd_ori2geo; - __Pyx_Buffer __pyx_pybuffer_ori2geo; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_r_c", 0); - __pyx_pybuffer_ori2geo.pybuffer.buf = NULL; - __pyx_pybuffer_ori2geo.refcount = 0; - __pyx_pybuffernd_ori2geo.data = NULL; - __pyx_pybuffernd_ori2geo.rcbuffer = &__pyx_pybuffer_ori2geo; - __pyx_pybuffer_lon_lat.pybuffer.buf = NULL; - __pyx_pybuffer_lon_lat.refcount = 0; - __pyx_pybuffernd_lon_lat.data = NULL; - __pyx_pybuffernd_lon_lat.rcbuffer = &__pyx_pybuffer_lon_lat; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ori2geo.rcbuffer->pybuffer, (PyObject*)__pyx_v_ori2geo, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 149, __pyx_L1_error) - } - __pyx_pybuffernd_ori2geo.diminfo[0].strides = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ori2geo.diminfo[0].shape = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ori2geo.diminfo[1].strides = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ori2geo.diminfo[1].shape = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_ori2geo.diminfo[2].strides = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_ori2geo.diminfo[2].shape = __pyx_pybuffernd_ori2geo.rcbuffer->pybuffer.shape[2]; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_lon_lat.rcbuffer->pybuffer, (PyObject*)__pyx_v_lon_lat, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 149, __pyx_L1_error) - } - __pyx_pybuffernd_lon_lat.diminfo[0].strides = __pyx_pybuffernd_lon_lat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_lon_lat.diminfo[0].shape = __pyx_pybuffernd_lon_lat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_lon_lat.diminfo[1].strides = __pyx_pybuffernd_lon_lat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_lon_lat.diminfo[1].shape = __pyx_pybuffernd_lon_lat.rcbuffer->pybuffer.shape[1]; - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)__pyx_f_7SAR_GEO_get_r_c(__pyx_v_ori2geo, __pyx_v_lon_lat, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lon_lat.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("SAR_GEO.get_r_c", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_lon_lat.rcbuffer->pybuffer); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ori2geo.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "SAR_GEO.pyx":188 - * - * # - * cpdef np.ndarray[double,ndim=2] Add(np.ndarray[double,ndim=2] a,double x): # <<<<<<<<<<<<<< - * cdef double d=0; # cython bool - * print("") - */ - -static PyObject *__pyx_pw_7SAR_GEO_9Add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyArrayObject *__pyx_f_7SAR_GEO_Add(PyArrayObject *__pyx_v_a, double __pyx_v_x, CYTHON_UNUSED int __pyx_skip_dispatch) { - CYTHON_UNUSED double __pyx_v_d; - __Pyx_LocalBuf_ND __pyx_pybuffernd_a; - __Pyx_Buffer __pyx_pybuffer_a; - PyArrayObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("Add", 0); - __pyx_pybuffer_a.pybuffer.buf = NULL; - __pyx_pybuffer_a.refcount = 0; - __pyx_pybuffernd_a.data = NULL; - __pyx_pybuffernd_a.rcbuffer = &__pyx_pybuffer_a; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_a.rcbuffer->pybuffer, (PyObject*)__pyx_v_a, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 188, __pyx_L1_error) - } - __pyx_pybuffernd_a.diminfo[0].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_a.diminfo[0].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_a.diminfo[1].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_a.diminfo[1].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[1]; - - /* "SAR_GEO.pyx":189 - * # - * cpdef np.ndarray[double,ndim=2] Add(np.ndarray[double,ndim=2] a,double x): - * cdef double d=0; # cython bool # <<<<<<<<<<<<<< - * print("") - * print(a) - */ - __pyx_v_d = 0.0; - - /* "SAR_GEO.pyx":190 - * cpdef np.ndarray[double,ndim=2] Add(np.ndarray[double,ndim=2] a,double x): - * cdef double d=0; # cython bool - * print("") # <<<<<<<<<<<<<< - * print(a) - * print(x) - */ - if (__Pyx_PrintOne(0, __pyx_kp_s__4) < 0) __PYX_ERR(0, 190, __pyx_L1_error) - - /* "SAR_GEO.pyx":191 - * cdef double d=0; # cython bool - * print("") - * print(a) # <<<<<<<<<<<<<< - * print(x) - * return a+x - */ - if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_a)) < 0) __PYX_ERR(0, 191, __pyx_L1_error) - - /* "SAR_GEO.pyx":192 - * print("") - * print(a) - * print(x) # <<<<<<<<<<<<<< - * return a+x - * - */ - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "SAR_GEO.pyx":193 - * print(a) - * print(x) - * return a+x # <<<<<<<<<<<<<< - * - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_a), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 193, __pyx_L1_error) - __pyx_r = ((PyArrayObject *)__pyx_t_2); - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "SAR_GEO.pyx":188 - * - * # - * cpdef np.ndarray[double,ndim=2] Add(np.ndarray[double,ndim=2] a,double x): # <<<<<<<<<<<<<< - * cdef double d=0; # cython bool - * print("") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("SAR_GEO.Add", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_7SAR_GEO_9Add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_7SAR_GEO_9Add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyArrayObject *__pyx_v_a = 0; - double __pyx_v_x; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("Add (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_x,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("Add", 1, 2, 2, 1); __PYX_ERR(0, 188, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Add") < 0)) __PYX_ERR(0, 188, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_a = ((PyArrayObject *)values[0]); - __pyx_v_x = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_x == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 188, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("Add", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 188, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("SAR_GEO.Add", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_5numpy_ndarray, 1, "a", 0))) __PYX_ERR(0, 188, __pyx_L1_error) - __pyx_r = __pyx_pf_7SAR_GEO_8Add(__pyx_self, __pyx_v_a, __pyx_v_x); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_7SAR_GEO_8Add(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_a, double __pyx_v_x) { - __Pyx_LocalBuf_ND __pyx_pybuffernd_a; - __Pyx_Buffer __pyx_pybuffer_a; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("Add", 0); - __pyx_pybuffer_a.pybuffer.buf = NULL; - __pyx_pybuffer_a.refcount = 0; - __pyx_pybuffernd_a.data = NULL; - __pyx_pybuffernd_a.rcbuffer = &__pyx_pybuffer_a; - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_a.rcbuffer->pybuffer, (PyObject*)__pyx_v_a, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 188, __pyx_L1_error) - } - __pyx_pybuffernd_a.diminfo[0].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_a.diminfo[0].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_a.diminfo[1].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_a.diminfo[1].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[1]; - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)__pyx_f_7SAR_GEO_Add(__pyx_v_a, __pyx_v_x, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer); - __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} - __Pyx_AddTraceback("SAR_GEO.Add", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - goto __pyx_L2; - __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_a.rcbuffer->pybuffer); - __pyx_L2:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":735 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":736 - * - * cdef inline object PyArray_MultiIterNew1(a): - * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew2(a, b): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 736, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":735 - * ctypedef npy_cdouble complex_t - * - * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(1, a) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":738 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":739 - * - * cdef inline object PyArray_MultiIterNew2(a, b): - * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 739, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":738 - * return PyArray_MultiIterNew(1, a) - * - * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(2, a, b) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":741 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":742 - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): - * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 742, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":741 - * return PyArray_MultiIterNew(2, a, b) - * - * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(3, a, b, c) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":744 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":745 - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): - * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 745, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":744 - * return PyArray_MultiIterNew(3, a, b, c) - * - * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(4, a, b, c, d) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":747 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":748 - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): - * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 748, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":747 - * return PyArray_MultiIterNew(4, a, b, c, d) - * - * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":750 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":751 - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< - * return d.subarray.shape - * else: - */ - __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); - if (__pyx_t_1) { - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":752 - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape # <<<<<<<<<<<<<< - * else: - * return () - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape)); - __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":751 - * - * cdef inline tuple PyDataType_SHAPE(dtype d): - * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< - * return d.subarray.shape - * else: - */ - } - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":754 - * return d.subarray.shape - * else: - * return () # <<<<<<<<<<<<<< - * - * - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_empty_tuple); - __pyx_r = __pyx_empty_tuple; - goto __pyx_L0; - } - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":750 - * return PyArray_MultiIterNew(5, a, b, c, d, e) - * - * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< - * if PyDataType_HASSUBARRAY(d): - * return d.subarray.shape - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":931 - * int _import_umath() except -1 - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) - */ - -static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("set_array_base", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":932 - * - * cdef inline void set_array_base(ndarray arr, object base): - * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< - * PyArray_SetBaseObject(arr, base) - * - */ - Py_INCREF(__pyx_v_base); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":933 - * cdef inline void set_array_base(ndarray arr, object base): - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< - * - * cdef inline object get_array_base(ndarray arr): - */ - (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":931 - * int _import_umath() except -1 - * - * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< - * Py_INCREF(base) # important to do this before stealing the reference below! - * PyArray_SetBaseObject(arr, base) - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":935 - * PyArray_SetBaseObject(arr, base) - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * base = PyArray_BASE(arr) - * if base is NULL: - */ - -static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { - PyObject *__pyx_v_base; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("get_array_base", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":936 - * - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< - * if base is NULL: - * return None - */ - __pyx_v_base = PyArray_BASE(__pyx_v_arr); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":937 - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) - * if base is NULL: # <<<<<<<<<<<<<< - * return None - * return base - */ - __pyx_t_1 = ((__pyx_v_base == NULL) != 0); - if (__pyx_t_1) { - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":938 - * base = PyArray_BASE(arr) - * if base is NULL: - * return None # <<<<<<<<<<<<<< - * return base - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":937 - * cdef inline object get_array_base(ndarray arr): - * base = PyArray_BASE(arr) - * if base is NULL: # <<<<<<<<<<<<<< - * return None - * return base - */ - } - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":939 - * if base is NULL: - * return None - * return base # <<<<<<<<<<<<<< - * - * # Versions of the import_* functions which are more suitable for - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_base)); - __pyx_r = ((PyObject *)__pyx_v_base); - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":935 - * PyArray_SetBaseObject(arr, base) - * - * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< - * base = PyArray_BASE(arr) - * if base is NULL: - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":943 - * # Versions of the import_* functions which are more suitable for - * # Cython code. - * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< - * try: - * __pyx_import_array() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_array", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":945 - * cdef inline int import_array() except -1: - * try: - * __pyx_import_array() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") - */ - __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 945, __pyx_L3_error) - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":946 - * try: - * __pyx_import_array() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.multiarray failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 946, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":947 - * __pyx_import_array() - * except Exception: - * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_umath() except -1: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 947, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 947, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":944 - * # Cython code. - * cdef inline int import_array() except -1: - * try: # <<<<<<<<<<<<<< - * __pyx_import_array() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":943 - * # Versions of the import_* functions which are more suitable for - * # Cython code. - * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< - * try: - * __pyx_import_array() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":949 - * raise ImportError("numpy.core.multiarray failed to import") - * - * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_umath", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":951 - * cdef inline int import_umath() except -1: - * try: - * _import_umath() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.umath failed to import") - */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 951, __pyx_L3_error) - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":952 - * try: - * _import_umath() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.umath failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 952, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":953 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef inline int import_ufunc() except -1: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 953, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 953, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":950 - * - * cdef inline int import_umath() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":949 - * raise ImportError("numpy.core.multiarray failed to import") - * - * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":955 - * raise ImportError("numpy.core.umath failed to import") - * - * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - -static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("import_ufunc", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - /*try:*/ { - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":957 - * cdef inline int import_ufunc() except -1: - * try: - * _import_umath() # <<<<<<<<<<<<<< - * except Exception: - * raise ImportError("numpy.core.umath failed to import") - */ - __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 957, __pyx_L3_error) - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - } - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L8_try_end; - __pyx_L3_error:; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":958 - * try: - * _import_umath() - * except Exception: # <<<<<<<<<<<<<< - * raise ImportError("numpy.core.umath failed to import") - * - */ - __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); - if (__pyx_t_4) { - __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 958, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GOTREF(__pyx_t_7); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":959 - * _import_umath() - * except Exception: - * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< - * - * cdef extern from *: - */ - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 959, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(1, 959, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":956 - * - * cdef inline int import_ufunc() except -1: - * try: # <<<<<<<<<<<<<< - * _import_umath() - * except Exception: - */ - __Pyx_XGIVEREF(__pyx_t_1); - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); - goto __pyx_L1_error; - __pyx_L8_try_end:; - } - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":955 - * raise ImportError("numpy.core.umath failed to import") - * - * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< - * try: - * _import_umath() - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":969 - * - * - * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.timedelta64)` - */ - -static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_obj) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_timedelta64_object", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":981 - * bool - * """ - * return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type) # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyTimedeltaArrType_Type)); - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":969 - * - * - * cdef inline bint is_timedelta64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.timedelta64)` - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":984 - * - * - * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.datetime64)` - */ - -static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_obj) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_datetime64_object", 0); - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":996 - * bool - * """ - * return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type) # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyDatetimeArrType_Type)); - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":984 - * - * - * cdef inline bint is_datetime64_object(object obj): # <<<<<<<<<<<<<< - * """ - * Cython equivalent of `isinstance(obj, np.datetime64)` - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":999 - * - * - * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy datetime64 object - */ - -static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject *__pyx_v_obj) { - npy_datetime __pyx_r; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1006 - * also needed. That can be found using `get_datetime64_unit`. - * """ - * return (obj).obval # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = ((PyDatetimeScalarObject *)__pyx_v_obj)->obval; - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":999 - * - * - * cdef inline npy_datetime get_datetime64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy datetime64 object - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1009 - * - * - * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy timedelta64 object - */ - -static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject *__pyx_v_obj) { - npy_timedelta __pyx_r; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1013 - * returns the int64 value underlying scalar numpy timedelta64 object - * """ - * return (obj).obval # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = ((PyTimedeltaScalarObject *)__pyx_v_obj)->obval; - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1009 - * - * - * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the int64 value underlying scalar numpy timedelta64 object - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - -static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObject *__pyx_v_obj) { - NPY_DATETIMEUNIT __pyx_r; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1020 - * returns the unit part of the dtype for a numpy datetime64 object. - * """ - * return (obj).obmeta.base # <<<<<<<<<<<<<< - */ - __pyx_r = ((NPY_DATETIMEUNIT)((PyDatetimeScalarObject *)__pyx_v_obj)->obmeta.base); - goto __pyx_L0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -static PyMethodDef __pyx_methods[] = { - {"insert_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7SAR_GEO_1insert_data, METH_VARARGS|METH_KEYWORDS, 0}, - {"cut_L1A_img", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7SAR_GEO_3cut_L1A_img, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7SAR_GEO_2cut_L1A_img}, - {"gereratorMask", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7SAR_GEO_5gereratorMask, METH_VARARGS|METH_KEYWORDS, 0}, - {"get_r_c", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7SAR_GEO_7get_r_c, METH_VARARGS|METH_KEYWORDS, 0}, - {"Add", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7SAR_GEO_9Add, METH_VARARGS|METH_KEYWORDS, 0}, - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -#if CYTHON_PEP489_MULTI_PHASE_INIT -static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ -static int __pyx_pymod_exec_SAR_GEO(PyObject* module); /*proto*/ -static PyModuleDef_Slot __pyx_moduledef_slots[] = { - {Py_mod_create, (void*)__pyx_pymod_create}, - {Py_mod_exec, (void*)__pyx_pymod_exec_SAR_GEO}, - {0, NULL} -}; -#endif - -static struct PyModuleDef __pyx_moduledef = { - PyModuleDef_HEAD_INIT, - "SAR_GEO", - 0, /* m_doc */ - #if CYTHON_PEP489_MULTI_PHASE_INIT - 0, /* m_size */ - #else - -1, /* m_size */ - #endif - __pyx_methods /* m_methods */, - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_moduledef_slots, /* m_slots */ - #else - NULL, /* m_reload */ - #endif - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif -#ifndef CYTHON_SMALL_CODE -#if defined(__clang__) - #define CYTHON_SMALL_CODE -#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) - #define CYTHON_SMALL_CODE __attribute__((cold)) -#else - #define CYTHON_SMALL_CODE -#endif -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, - {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0}, - {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1}, - {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, - {&__pyx_n_s_clist, __pyx_k_clist, sizeof(__pyx_k_clist), 0, 0, 1, 1}, - {&__pyx_n_s_col_ids, __pyx_k_col_ids, sizeof(__pyx_k_col_ids), 0, 0, 1, 1}, - {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1}, - {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, - {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1}, - {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1}, - {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, - {&__pyx_n_s_griddata, __pyx_k_griddata, sizeof(__pyx_k_griddata), 0, 0, 1, 1}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_n_s_lon_lat, __pyx_k_lon_lat, sizeof(__pyx_k_lon_lat), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1}, - {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1}, - {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_n_s_nan, __pyx_k_nan, sizeof(__pyx_k_nan), 0, 0, 1, 1}, - {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, - {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, - {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0}, - {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0}, - {&__pyx_n_s_ones, __pyx_k_ones, sizeof(__pyx_k_ones), 0, 0, 1, 1}, - {&__pyx_n_s_ori2geo, __pyx_k_ori2geo, sizeof(__pyx_k_ori2geo), 0, 0, 1, 1}, - {&__pyx_n_s_ori2geo_img, __pyx_k_ori2geo_img, sizeof(__pyx_k_ori2geo_img), 0, 0, 1, 1}, - {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1}, - {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1}, - {&__pyx_n_s_rlist, __pyx_k_rlist, sizeof(__pyx_k_rlist), 0, 0, 1, 1}, - {&__pyx_n_s_roi_list, __pyx_k_roi_list, sizeof(__pyx_k_roi_list), 0, 0, 1, 1}, - {&__pyx_n_s_row_ids, __pyx_k_row_ids, sizeof(__pyx_k_row_ids), 0, 0, 1, 1}, - {&__pyx_n_s_scipy_interpolate, __pyx_k_scipy_interpolate, sizeof(__pyx_k_scipy_interpolate), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, - {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 947, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "SAR_GEO.pyx":166 - * - * # - * cdef double min_lon=np.min(ori2geo[0,:,:]) # <<<<<<<<<<<<<< - * cdef double max_lon=np.max(ori2geo[0,:,:]) - * cdef double min_lat=np.min(ori2geo[1,:,:]) - */ - __pyx_slice_ = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice_); - __Pyx_GIVEREF(__pyx_slice_); - __pyx_tuple__2 = PyTuple_Pack(3, __pyx_int_0, __pyx_slice_, __pyx_slice_); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__2); - __Pyx_GIVEREF(__pyx_tuple__2); - - /* "SAR_GEO.pyx":168 - * cdef double min_lon=np.min(ori2geo[0,:,:]) - * cdef double max_lon=np.max(ori2geo[0,:,:]) - * cdef double min_lat=np.min(ori2geo[1,:,:]) # <<<<<<<<<<<<<< - * cdef double max_lat=np.max(ori2geo[1,:,:]) - * while c= 0x030700A1 - static PY_INT64_T main_interpreter_id = -1; - PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); - if (main_interpreter_id == -1) { - main_interpreter_id = current_id; - return (unlikely(current_id == -1)) ? -1 : 0; - } else if (unlikely(main_interpreter_id != current_id)) - #else - static PyInterpreterState *main_interpreter = NULL; - PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; - if (!main_interpreter) { - main_interpreter = current_interpreter; - } else if (unlikely(main_interpreter != current_interpreter)) - #endif - { - PyErr_SetString( - PyExc_ImportError, - "Interpreter change detected - this module can only be loaded into one interpreter per process."); - return -1; - } - return 0; -} -static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { - PyObject *value = PyObject_GetAttrString(spec, from_name); - int result = 0; - if (likely(value)) { - if (allow_none || value != Py_None) { - result = PyDict_SetItemString(moddict, to_name, value); - } - Py_DECREF(value); - } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - } else { - result = -1; - } - return result; -} -static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { - PyObject *module = NULL, *moddict, *modname; - if (__Pyx_check_single_interpreter()) - return NULL; - if (__pyx_m) - return __Pyx_NewRef(__pyx_m); - modname = PyObject_GetAttrString(spec, "name"); - if (unlikely(!modname)) goto bad; - module = PyModule_NewObject(modname); - Py_DECREF(modname); - if (unlikely(!module)) goto bad; - moddict = PyModule_GetDict(module); - if (unlikely(!moddict)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; - return module; -bad: - Py_XDECREF(module); - return NULL; -} - - -static CYTHON_SMALL_CODE int __pyx_pymod_exec_SAR_GEO(PyObject *__pyx_pyinit_module) -#endif -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannyDeclarations - #if CYTHON_PEP489_MULTI_PHASE_INIT - if (__pyx_m) { - if (__pyx_m == __pyx_pyinit_module) return 0; - PyErr_SetString(PyExc_RuntimeError, "Module 'SAR_GEO' has already been imported. Re-initialisation is not supported."); - return -1; - } - #elif PY_MAJOR_VERSION >= 3 - if (__pyx_m) return __Pyx_NewRef(__pyx_m); - #endif - #if CYTHON_REFNANNY -__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); -if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); -} -#endif - __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_SAR_GEO(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pxy_PyFrame_Initialize_Offsets - __Pxy_PyFrame_Initialize_Offsets(); - #endif - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_AsyncGen_USED - if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - PyEval_InitThreads(); - #endif - /*--- Module creation code ---*/ - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_m = __pyx_pyinit_module; - Py_INCREF(__pyx_m); - #else - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("SAR_GEO", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_b); - __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_cython_runtime); - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main_SAR_GEO) { - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "SAR_GEO")) { - if (unlikely(PyDict_SetItemString(modules, "SAR_GEO", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global type/function init code ---*/ - (void)__Pyx_modinit_global_init_code(); - (void)__Pyx_modinit_variable_export_code(); - (void)__Pyx_modinit_function_export_code(); - (void)__Pyx_modinit_type_init_code(); - if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - (void)__Pyx_modinit_variable_import_code(); - (void)__Pyx_modinit_function_import_code(); - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - - /* "SAR_GEO.pyx":1 - * import os # <<<<<<<<<<<<<< - * cimport cython # - * import numpy as np##cpythonnp - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "SAR_GEO.pyx":3 - * import os - * cimport cython # - * import numpy as np##cpythonnp # <<<<<<<<<<<<<< - * cimport numpy as np # cpythonnp - * from libc.math cimport pi,ceil,floor - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "SAR_GEO.pyx":6 - * cimport numpy as np # cpythonnp - * from libc.math cimport pi,ceil,floor - * from scipy.interpolate import griddata # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_griddata); - __Pyx_GIVEREF(__pyx_n_s_griddata); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_griddata); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_scipy_interpolate, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_griddata); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_griddata, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "SAR_GEO.pyx":1 - * import os # <<<<<<<<<<<<<< - * cimport cython # - * import numpy as np##cpythonnp - */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "../../../../../Anaconda/envs/micro/lib/site-packages/numpy/__init__.pxd":1016 - * - * - * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil: # <<<<<<<<<<<<<< - * """ - * returns the unit part of the dtype for a numpy datetime64 object. - */ - - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init SAR_GEO", __pyx_clineno, __pyx_lineno, __pyx_filename); - } - Py_CLEAR(__pyx_m); - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init SAR_GEO"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if CYTHON_PEP489_MULTI_PHASE_INIT - return (__pyx_m != NULL) ? 0 : -1; - #elif PY_MAJOR_VERSION >= 3 - return __pyx_m; - #else - return; - #endif -} - -/* --- Runtime support code --- */ -/* Refnanny */ -#if CYTHON_REFNANNY -static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule(modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, "RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif - -/* IsLittleEndian */ -static CYTHON_INLINE int __Pyx_Is_Little_Endian(void) -{ - union { - uint32_t u32; - uint8_t u8[4]; - } S; - S.u32 = 0x01020304; - return S.u8[0] == 4; -} - -/* BufferFormatCheck */ -static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, - __Pyx_BufFmt_StackElem* stack, - __Pyx_TypeInfo* type) { - stack[0].field = &ctx->root; - stack[0].parent_offset = 0; - ctx->root.type = type; - ctx->root.name = "buffer dtype"; - ctx->root.offset = 0; - ctx->head = stack; - ctx->head->field = &ctx->root; - ctx->fmt_offset = 0; - ctx->head->parent_offset = 0; - ctx->new_packmode = '@'; - ctx->enc_packmode = '@'; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->is_complex = 0; - ctx->is_valid_array = 0; - ctx->struct_alignment = 0; - while (type->typegroup == 'S') { - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = 0; - type = type->fields->type; - } -} -static int __Pyx_BufFmt_ParseNumber(const char** ts) { - int count; - const char* t = *ts; - if (*t < '0' || *t > '9') { - return -1; - } else { - count = *t++ - '0'; - while (*t >= '0' && *t <= '9') { - count *= 10; - count += *t++ - '0'; - } - } - *ts = t; - return count; -} -static int __Pyx_BufFmt_ExpectNumber(const char **ts) { - int number = __Pyx_BufFmt_ParseNumber(ts); - if (number == -1) - PyErr_Format(PyExc_ValueError,\ - "Does not understand character buffer dtype format string ('%c')", **ts); - return number; -} -static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { - PyErr_Format(PyExc_ValueError, - "Unexpected format string character: '%c'", ch); -} -static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { - switch (ch) { - case '?': return "'bool'"; - case 'c': return "'char'"; - case 'b': return "'signed char'"; - case 'B': return "'unsigned char'"; - case 'h': return "'short'"; - case 'H': return "'unsigned short'"; - case 'i': return "'int'"; - case 'I': return "'unsigned int'"; - case 'l': return "'long'"; - case 'L': return "'unsigned long'"; - case 'q': return "'long long'"; - case 'Q': return "'unsigned long long'"; - case 'f': return (is_complex ? "'complex float'" : "'float'"); - case 'd': return (is_complex ? "'complex double'" : "'double'"); - case 'g': return (is_complex ? "'complex long double'" : "'long double'"); - case 'T': return "a struct"; - case 'O': return "Python object"; - case 'P': return "a pointer"; - case 's': case 'p': return "a string"; - case 0: return "end"; - default: return "unparseable format string"; - } -} -static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return 2; - case 'i': case 'I': case 'l': case 'L': return 4; - case 'q': case 'Q': return 8; - case 'f': return (is_complex ? 8 : 4); - case 'd': return (is_complex ? 16 : 8); - case 'g': { - PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); - return 0; - } - case 'O': case 'P': return sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(short); - case 'i': case 'I': return sizeof(int); - case 'l': case 'L': return sizeof(long); - #ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(PY_LONG_LONG); - #endif - case 'f': return sizeof(float) * (is_complex ? 2 : 1); - case 'd': return sizeof(double) * (is_complex ? 2 : 1); - case 'g': return sizeof(long double) * (is_complex ? 2 : 1); - case 'O': case 'P': return sizeof(void*); - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } - } -} -typedef struct { char c; short x; } __Pyx_st_short; -typedef struct { char c; int x; } __Pyx_st_int; -typedef struct { char c; long x; } __Pyx_st_long; -typedef struct { char c; float x; } __Pyx_st_float; -typedef struct { char c; double x; } __Pyx_st_double; -typedef struct { char c; long double x; } __Pyx_st_longdouble; -typedef struct { char c; void *x; } __Pyx_st_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_st_float) - sizeof(float); - case 'd': return sizeof(__Pyx_st_double) - sizeof(double); - case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -/* These are for computing the padding at the end of the struct to align - on the first member of the struct. This will probably the same as above, - but we don't have any guarantees. - */ -typedef struct { short x; char c; } __Pyx_pad_short; -typedef struct { int x; char c; } __Pyx_pad_int; -typedef struct { long x; char c; } __Pyx_pad_long; -typedef struct { float x; char c; } __Pyx_pad_float; -typedef struct { double x; char c; } __Pyx_pad_double; -typedef struct { long double x; char c; } __Pyx_pad_longdouble; -typedef struct { void *x; char c; } __Pyx_pad_void_p; -#ifdef HAVE_LONG_LONG -typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; -#endif -static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { - switch (ch) { - case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; - case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); - case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); - case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); -#ifdef HAVE_LONG_LONG - case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); -#endif - case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); - case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); - case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); - case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); - default: - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } -} -static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { - switch (ch) { - case 'c': - return 'H'; - case 'b': case 'h': case 'i': - case 'l': case 'q': case 's': case 'p': - return 'I'; - case '?': case 'B': case 'H': case 'I': case 'L': case 'Q': - return 'U'; - case 'f': case 'd': case 'g': - return (is_complex ? 'C' : 'R'); - case 'O': - return 'O'; - case 'P': - return 'P'; - default: { - __Pyx_BufFmt_RaiseUnexpectedChar(ch); - return 0; - } - } -} -static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { - if (ctx->head == NULL || ctx->head->field == &ctx->root) { - const char* expected; - const char* quote; - if (ctx->head == NULL) { - expected = "end"; - quote = ""; - } else { - expected = ctx->head->field->type->name; - quote = "'"; - } - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected %s%s%s but got %s", - quote, expected, quote, - __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); - } else { - __Pyx_StructField* field = ctx->head->field; - __Pyx_StructField* parent = (ctx->head - 1)->field; - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", - field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), - parent->type->name, field->name); - } -} -static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { - char group; - size_t size, offset, arraysize = 1; - if (ctx->enc_type == 0) return 0; - if (ctx->head->field->type->arraysize[0]) { - int i, ndim = 0; - if (ctx->enc_type == 's' || ctx->enc_type == 'p') { - ctx->is_valid_array = ctx->head->field->type->ndim == 1; - ndim = 1; - if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { - PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %zu", - ctx->head->field->type->arraysize[0], ctx->enc_count); - return -1; - } - } - if (!ctx->is_valid_array) { - PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", - ctx->head->field->type->ndim, ndim); - return -1; - } - for (i = 0; i < ctx->head->field->type->ndim; i++) { - arraysize *= ctx->head->field->type->arraysize[i]; - } - ctx->is_valid_array = 0; - ctx->enc_count = 1; - } - group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); - do { - __Pyx_StructField* field = ctx->head->field; - __Pyx_TypeInfo* type = field->type; - if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { - size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); - } else { - size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); - } - if (ctx->enc_packmode == '@') { - size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); - size_t align_mod_offset; - if (align_at == 0) return -1; - align_mod_offset = ctx->fmt_offset % align_at; - if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; - if (ctx->struct_alignment == 0) - ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, - ctx->is_complex); - } - if (type->size != size || type->typegroup != group) { - if (type->typegroup == 'C' && type->fields != NULL) { - size_t parent_offset = ctx->head->parent_offset + field->offset; - ++ctx->head; - ctx->head->field = type->fields; - ctx->head->parent_offset = parent_offset; - continue; - } - if ((type->typegroup == 'H' || group == 'H') && type->size == size) { - } else { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; - } - } - offset = ctx->head->parent_offset + field->offset; - if (ctx->fmt_offset != offset) { - PyErr_Format(PyExc_ValueError, - "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", - (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); - return -1; - } - ctx->fmt_offset += size; - if (arraysize) - ctx->fmt_offset += (arraysize - 1) * size; - --ctx->enc_count; - while (1) { - if (field == &ctx->root) { - ctx->head = NULL; - if (ctx->enc_count != 0) { - __Pyx_BufFmt_RaiseExpected(ctx); - return -1; - } - break; - } - ctx->head->field = ++field; - if (field->type == NULL) { - --ctx->head; - field = ctx->head->field; - continue; - } else if (field->type->typegroup == 'S') { - size_t parent_offset = ctx->head->parent_offset + field->offset; - if (field->type->fields->type == NULL) continue; - field = field->type->fields; - ++ctx->head; - ctx->head->field = field; - ctx->head->parent_offset = parent_offset; - break; - } else { - break; - } - } - } while (ctx->enc_count); - ctx->enc_type = 0; - ctx->is_complex = 0; - return 0; -} -static PyObject * -__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) -{ - const char *ts = *tsp; - int i = 0, number, ndim; - ++ts; - if (ctx->new_count != 1) { - PyErr_SetString(PyExc_ValueError, - "Cannot handle repeated arrays in format string"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ndim = ctx->head->field->type->ndim; - while (*ts && *ts != ')') { - switch (*ts) { - case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; - default: break; - } - number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) - return PyErr_Format(PyExc_ValueError, - "Expected a dimension of size %zu, got %d", - ctx->head->field->type->arraysize[i], number); - if (*ts != ',' && *ts != ')') - return PyErr_Format(PyExc_ValueError, - "Expected a comma in format string, got '%c'", *ts); - if (*ts == ',') ts++; - i++; - } - if (i != ndim) - return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", - ctx->head->field->type->ndim, i); - if (!*ts) { - PyErr_SetString(PyExc_ValueError, - "Unexpected end of format string, expected ')'"); - return NULL; - } - ctx->is_valid_array = 1; - ctx->new_count = 1; - *tsp = ++ts; - return Py_None; -} -static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { - int got_Z = 0; - while (1) { - switch(*ts) { - case 0: - if (ctx->enc_type != 0 && ctx->head == NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - if (ctx->head != NULL) { - __Pyx_BufFmt_RaiseExpected(ctx); - return NULL; - } - return ts; - case ' ': - case '\r': - case '\n': - ++ts; - break; - case '<': - if (!__Pyx_Is_Little_Endian()) { - PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '>': - case '!': - if (__Pyx_Is_Little_Endian()) { - PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); - return NULL; - } - ctx->new_packmode = '='; - ++ts; - break; - case '=': - case '@': - case '^': - ctx->new_packmode = *ts++; - break; - case 'T': - { - const char* ts_after_sub; - size_t i, struct_count = ctx->new_count; - size_t struct_alignment = ctx->struct_alignment; - ctx->new_count = 1; - ++ts; - if (*ts != '{') { - PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); - return NULL; - } - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - ctx->enc_count = 0; - ctx->struct_alignment = 0; - ++ts; - ts_after_sub = ts; - for (i = 0; i != struct_count; ++i) { - ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); - if (!ts_after_sub) return NULL; - } - ts = ts_after_sub; - if (struct_alignment) ctx->struct_alignment = struct_alignment; - } - break; - case '}': - { - size_t alignment = ctx->struct_alignment; - ++ts; - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_type = 0; - if (alignment && ctx->fmt_offset % alignment) { - ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); - } - } - return ts; - case 'x': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->fmt_offset += ctx->new_count; - ctx->new_count = 1; - ctx->enc_count = 0; - ctx->enc_type = 0; - ctx->enc_packmode = ctx->new_packmode; - ++ts; - break; - case 'Z': - got_Z = 1; - ++ts; - if (*ts != 'f' && *ts != 'd' && *ts != 'g') { - __Pyx_BufFmt_RaiseUnexpectedChar('Z'); - return NULL; - } - CYTHON_FALLTHROUGH; - case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': - case 'l': case 'L': case 'q': case 'Q': - case 'f': case 'd': case 'g': - case 'O': case 'p': - if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) && - (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) { - ctx->enc_count += ctx->new_count; - ctx->new_count = 1; - got_Z = 0; - ++ts; - break; - } - CYTHON_FALLTHROUGH; - case 's': - if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; - ctx->enc_count = ctx->new_count; - ctx->enc_packmode = ctx->new_packmode; - ctx->enc_type = *ts; - ctx->is_complex = got_Z; - ++ts; - ctx->new_count = 1; - got_Z = 0; - break; - case ':': - ++ts; - while(*ts != ':') ++ts; - ++ts; - break; - case '(': - if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; - break; - default: - { - int number = __Pyx_BufFmt_ExpectNumber(&ts); - if (number == -1) return NULL; - ctx->new_count = (size_t)number; - } - } - } -} - -/* BufferGetAndValidate */ - static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { - if (unlikely(info->buf == NULL)) return; - if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; - __Pyx_ReleaseBuffer(info); -} -static void __Pyx_ZeroBuffer(Py_buffer* buf) { - buf->buf = NULL; - buf->obj = NULL; - buf->strides = __Pyx_zeros; - buf->shape = __Pyx_zeros; - buf->suboffsets = __Pyx_minusones; -} -static int __Pyx__GetBufferAndValidate( - Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, - int nd, int cast, __Pyx_BufFmt_StackElem* stack) -{ - buf->buf = NULL; - if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) { - __Pyx_ZeroBuffer(buf); - return -1; - } - if (unlikely(buf->ndim != nd)) { - PyErr_Format(PyExc_ValueError, - "Buffer has wrong number of dimensions (expected %d, got %d)", - nd, buf->ndim); - goto fail; - } - if (!cast) { - __Pyx_BufFmt_Context ctx; - __Pyx_BufFmt_Init(&ctx, stack, dtype); - if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; - } - if (unlikely((size_t)buf->itemsize != dtype->size)) { - PyErr_Format(PyExc_ValueError, - "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", - buf->itemsize, (buf->itemsize > 1) ? "s" : "", - dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); - goto fail; - } - if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; - return 0; -fail:; - __Pyx_SafeReleaseBuffer(buf); - return -1; -} - -/* BufferIndexError */ - static void __Pyx_RaiseBufferIndexError(int axis) { - PyErr_Format(PyExc_IndexError, - "Out of bounds on buffer access (axis %d)", axis); -} - -/* PyErrFetchRestore */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -} -#endif - -/* WriteUnraisableException */ - static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, - CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, - int full_traceback, CYTHON_UNUSED int nogil) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - __Pyx_PyThreadState_declare -#ifdef WITH_THREAD - PyGILState_STATE state; - if (nogil) - state = PyGILState_Ensure(); -#ifdef _MSC_VER - else state = (PyGILState_STATE)-1; -#endif -#endif - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); - if (full_traceback) { - Py_XINCREF(old_exc); - Py_XINCREF(old_val); - Py_XINCREF(old_tb); - __Pyx_ErrRestore(old_exc, old_val, old_tb); - PyErr_PrintEx(1); - } - #if PY_MAJOR_VERSION < 3 - ctx = PyString_FromString(name); - #else - ctx = PyUnicode_FromString(name); - #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } -#ifdef WITH_THREAD - if (nogil) - PyGILState_Release(state); -#endif -} - -/* RaiseArgTupleInvalid */ - static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} - -/* RaiseDoubleKeywords */ - static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -/* ParseKeywords */ - static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* ArgTypeTest */ - static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) -{ - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - else if (exact) { - #if PY_MAJOR_VERSION == 2 - if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif - } - else { - if (likely(__Pyx_TypeCheck(obj, type))) return 1; - } - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); - return 0; -} - -/* PyObjectGetAttrStr */ - #if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#endif - -/* GetBuiltinName */ - static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -/* PyDictVersioning */ - #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; -} -static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { - PyObject **dictptr = NULL; - Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; - if (offset) { -#if CYTHON_COMPILING_IN_CPYTHON - dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); -#else - dictptr = _PyObject_GetDictPtr(obj); -#endif - } - return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; -} -static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) - return 0; - return obj_dict_version == __Pyx_get_object_dict_version(obj); -} -#endif - -/* GetModuleGlobalName */ - #if CYTHON_USE_DICT_VERSIONS -static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) -#else -static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) -#endif -{ - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 - result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } else if (unlikely(PyErr_Occurred())) { - return NULL; - } -#else - result = PyDict_GetItem(__pyx_d, name); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } -#endif -#else - result = PyObject_GetItem(__pyx_d, name); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } - PyErr_Clear(); -#endif - return __Pyx_GetBuiltinName(name); -} - -/* PyObjectCall */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = Py_TYPE(func)->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = (*call)(func, arg, kw); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* ExtTypeTest */ - static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (likely(__Pyx_TypeCheck(obj, type))) - return 1; - PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", - Py_TYPE(obj)->tp_name, type->tp_name); - return 0; -} - -/* PyCFunctionFastCall */ - #if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); - } else { - return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); - } -} -#endif - -/* PyFunctionFastCall */ - #if CYTHON_FAST_PYCALL -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = __Pyx_PyFrame_GetLocalsplus(f); - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif -#endif - -/* PyObjectCall2Args */ - static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { - PyObject *args, *result = NULL; - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyFunction_FastCall(function, args, 2); - } - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyCFunction_FastCall(function, args, 2); - } - #endif - args = PyTuple_New(2); - if (unlikely(!args)) goto done; - Py_INCREF(arg1); - PyTuple_SET_ITEM(args, 0, arg1); - Py_INCREF(arg2); - PyTuple_SET_ITEM(args, 1, arg2); - Py_INCREF(function); - result = __Pyx_PyObject_Call(function, args, NULL); - Py_DECREF(args); - Py_DECREF(function); -done: - return result; -} - -/* PyObjectCallMethO */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { - PyObject *self, *result; - PyCFunction cfunc; - cfunc = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = cfunc(self, arg); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallOneArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif - if (likely(PyCFunction_Check(func))) { - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (__Pyx_PyFastCFunction_Check(func)) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - -/* GetItemInt */ - static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!j) return NULL; - r = PyObject_GetItem(o, j); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyList_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyTuple_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* ObjectGetItem */ - #if CYTHON_USE_TYPE_SLOTS -static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { - PyObject *runerr; - Py_ssize_t key_value; - PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; - if (unlikely(!(m && m->sq_item))) { - PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); - return NULL; - } - key_value = __Pyx_PyIndex_AsSsize_t(index); - if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { - return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); - } - if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { - PyErr_Clear(); - PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); - } - return NULL; -} -static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { - PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; - if (likely(m && m->mp_subscript)) { - return m->mp_subscript(obj, key); - } - return __Pyx_PyObject_GetIndex(obj, key); -} -#endif - -/* GetTopmostException */ - #if CYTHON_USE_EXC_INFO_STACK -static _PyErr_StackItem * -__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) -{ - _PyErr_StackItem *exc_info = tstate->exc_info; - while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && - exc_info->previous_item != NULL) - { - exc_info = exc_info->previous_item; - } - return exc_info; -} -#endif - -/* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - #if CYTHON_USE_EXC_INFO_STACK - _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); - *type = exc_info->exc_type; - *value = exc_info->exc_value; - *tb = exc_info->exc_traceback; - #else - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - #endif - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -} -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - #if CYTHON_USE_EXC_INFO_STACK - _PyErr_StackItem *exc_info = tstate->exc_info; - tmp_type = exc_info->exc_type; - tmp_value = exc_info->exc_value; - tmp_tb = exc_info->exc_traceback; - exc_info->exc_type = type; - exc_info->exc_value = value; - exc_info->exc_traceback = tb; - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -#endif - -/* PyErrExceptionMatches */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; icurexc_type; - if (exc_type == err) return 1; - if (unlikely(!exc_type)) return 0; - if (unlikely(PyTuple_Check(err))) - return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); - return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); -} -#endif - -/* GetException */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) -#endif -{ - PyObject *local_type, *local_value, *local_tb; -#if CYTHON_FAST_THREAD_STATE - PyObject *tmp_type, *tmp_value, *tmp_tb; - local_type = tstate->curexc_type; - local_value = tstate->curexc_value; - local_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -#else - PyErr_Fetch(&local_type, &local_value, &local_tb); -#endif - PyErr_NormalizeException(&local_type, &local_value, &local_tb); -#if CYTHON_FAST_THREAD_STATE - if (unlikely(tstate->curexc_type)) -#else - if (unlikely(PyErr_Occurred())) -#endif - goto bad; - #if PY_MAJOR_VERSION >= 3 - if (local_tb) { - if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) - goto bad; - } - #endif - Py_XINCREF(local_tb); - Py_XINCREF(local_type); - Py_XINCREF(local_value); - *type = local_type; - *value = local_value; - *tb = local_tb; -#if CYTHON_FAST_THREAD_STATE - #if CYTHON_USE_EXC_INFO_STACK - { - _PyErr_StackItem *exc_info = tstate->exc_info; - tmp_type = exc_info->exc_type; - tmp_value = exc_info->exc_value; - tmp_tb = exc_info->exc_traceback; - exc_info->exc_type = local_type; - exc_info->exc_value = local_value; - exc_info->exc_traceback = local_tb; - } - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = local_type; - tstate->exc_value = local_value; - tstate->exc_traceback = local_tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(local_type, local_value, local_tb); -#endif - return 0; -bad: - *type = 0; - *value = 0; - *tb = 0; - Py_XDECREF(local_type); - Py_XDECREF(local_value); - Py_XDECREF(local_tb); - return -1; -} - -/* RaiseException */ - #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - __Pyx_PyThreadState_declare - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - } - if (PyType_Check(type)) { -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; - } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - value = type; - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - } - __Pyx_PyThreadState_assign - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { - PyObject* owned_instance = NULL; - if (tb == Py_None) { - tb = 0; - } else if (tb && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto bad; - } - if (value == Py_None) - value = 0; - if (PyExceptionInstance_Check(type)) { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto bad; - } - value = type; - type = (PyObject*) Py_TYPE(value); - } else if (PyExceptionClass_Check(type)) { - PyObject *instance_class = NULL; - if (value && PyExceptionInstance_Check(value)) { - instance_class = (PyObject*) Py_TYPE(value); - if (instance_class != type) { - int is_subclass = PyObject_IsSubclass(instance_class, type); - if (!is_subclass) { - instance_class = NULL; - } else if (unlikely(is_subclass == -1)) { - goto bad; - } else { - type = instance_class; - } - } - } - if (!instance_class) { - PyObject *args; - if (!value) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } else - args = PyTuple_Pack(1, value); - if (!args) - goto bad; - owned_instance = PyObject_Call(type, args, NULL); - Py_DECREF(args); - if (!owned_instance) - goto bad; - value = owned_instance; - if (!PyExceptionInstance_Check(value)) { - PyErr_Format(PyExc_TypeError, - "calling %R should have returned an instance of " - "BaseException, not %R", - type, Py_TYPE(value)); - goto bad; - } - } - } else { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto bad; - } - if (cause) { - PyObject *fixed_cause; - if (cause == Py_None) { - fixed_cause = NULL; - } else if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); - if (fixed_cause == NULL) - goto bad; - } else if (PyExceptionInstance_Check(cause)) { - fixed_cause = cause; - Py_INCREF(fixed_cause); - } else { - PyErr_SetString(PyExc_TypeError, - "exception causes must derive from " - "BaseException"); - goto bad; - } - PyException_SetCause(value, fixed_cause); - } - PyErr_SetObject(type, value); - if (tb) { -#if CYTHON_COMPILING_IN_PYPY - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); - Py_INCREF(tb); - PyErr_Restore(tmp_type, tmp_value, tb); - Py_XDECREF(tmp_tb); -#else - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject* tmp_tb = tstate->curexc_traceback; - if (tb != tmp_tb) { - Py_INCREF(tb); - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_tb); - } -#endif - } -bad: - Py_XDECREF(owned_instance); - return; -} -#endif - -/* TypeImport */ - #ifndef __PYX_HAVE_RT_ImportType -#define __PYX_HAVE_RT_ImportType -static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, - size_t size, enum __Pyx_ImportType_CheckSize check_size) -{ - PyObject *result = 0; - char warning[200]; - Py_ssize_t basicsize; -#ifdef Py_LIMITED_API - PyObject *py_basicsize; -#endif - result = PyObject_GetAttrString(module, class_name); - if (!result) - goto bad; - if (!PyType_Check(result)) { - PyErr_Format(PyExc_TypeError, - "%.200s.%.200s is not a type object", - module_name, class_name); - goto bad; - } -#ifndef Py_LIMITED_API - basicsize = ((PyTypeObject *)result)->tp_basicsize; -#else - py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); - if (!py_basicsize) - goto bad; - basicsize = PyLong_AsSsize_t(py_basicsize); - Py_DECREF(py_basicsize); - py_basicsize = 0; - if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) - goto bad; -#endif - if ((size_t)basicsize < size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - goto bad; - } - if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - goto bad; - } - else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) { - PyOS_snprintf(warning, sizeof(warning), - "%s.%s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; - } - return (PyTypeObject *)result; -bad: - Py_XDECREF(result); - return NULL; -} -#endif - -/* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_MAJOR_VERSION < 3 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; - } - #endif - if (!module) { - #if PY_MAJOR_VERSION < 3 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } -bad: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_list); - Py_XDECREF(empty_dict); - return module; -} - -/* ImportFrom */ - static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { - PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); - if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Format(PyExc_ImportError, - #if PY_MAJOR_VERSION < 3 - "cannot import name %.230s", PyString_AS_STRING(name)); - #else - "cannot import name %S", name); - #endif - } - return value; -} - -/* CLineInTraceback */ - #ifndef CYTHON_CLINE_IN_TRACEBACK -static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) { - PyObject *use_cline; - PyObject *ptype, *pvalue, *ptraceback; -#if CYTHON_COMPILING_IN_CPYTHON - PyObject **cython_runtime_dict; -#endif - if (unlikely(!__pyx_cython_runtime)) { - return c_line; - } - __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); -#if CYTHON_COMPILING_IN_CPYTHON - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (likely(cython_runtime_dict)) { - __PYX_PY_DICT_LOOKUP_IF_MODIFIED( - use_cline, *cython_runtime_dict, - __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) - } else -#endif - { - PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); - if (use_cline_obj) { - use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; - Py_DECREF(use_cline_obj); - } else { - PyErr_Clear(); - use_cline = NULL; - } - } - if (!use_cline) { - c_line = 0; - PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); - } - else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { - c_line = 0; - } - __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); - return c_line; -} -#endif - -/* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { - int start = 0, mid = 0, end = count - 1; - if (end >= 0 && code_line > entries[end].code_line) { - return count; - } - while (start < end) { - mid = start + (end - start) / 2; - if (code_line < entries[mid].code_line) { - end = mid; - } else if (code_line > entries[mid].code_line) { - start = mid + 1; - } else { - return mid; - } - } - if (code_line <= entries[mid].code_line) { - return mid; - } else { - return mid + 1; - } -} -static PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_code_cache.count = 1; - entries[0].code_line = code_line; - entries[0].code_object = code_object; - Py_INCREF(code_object); - } - return; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -/* AddTraceback */ - #include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, - 0, - 0, - 0, - 0, - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - return NULL; -} -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyFrameObject *py_frame = 0; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - if (c_line) { - c_line = __Pyx_CLineForTraceback(tstate, c_line); - } - py_code = __pyx_find_code_object(c_line ? -c_line : py_line); - if (!py_code) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); - } - py_frame = PyFrame_New( - tstate, /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __pyx_d, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - __Pyx_PyFrame_SetLineNumber(py_frame, py_line); - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} - -#if PY_MAJOR_VERSION < 3 -static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { - if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); - PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); - return -1; -} -static void __Pyx_ReleaseBuffer(Py_buffer *view) { - PyObject *obj = view->obj; - if (!obj) return; - if (PyObject_CheckBuffer(obj)) { - PyBuffer_Release(view); - return; - } - if ((0)) {} - view->obj = NULL; - Py_DECREF(obj); -} -#endif - - - /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) -#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) -#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ - {\ - func_type value = func_value;\ - if (sizeof(target_type) < sizeof(func_type)) {\ - if (unlikely(value != (func_type) (target_type) value)) {\ - func_type zero = 0;\ - if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ - return (target_type) -1;\ - if (is_unsigned && unlikely(value < zero))\ - goto raise_neg_overflow;\ - else\ - goto raise_overflow;\ - }\ - }\ - return (target_type) value;\ - } - -/* Print */ - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 -static PyObject *__Pyx_GetStdout(void) { - PyObject *f = PySys_GetObject((char *)"stdout"); - if (!f) { - PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); - } - return f; -} -static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { - int i; - if (!f) { - if (!(f = __Pyx_GetStdout())) - return -1; - } - Py_INCREF(f); - for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) { - PyObject* v; - if (PyFile_SoftSpace(f, 1)) { - if (PyFile_WriteString(" ", f) < 0) - goto error; - } - v = PyTuple_GET_ITEM(arg_tuple, i); - if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) - goto error; - if (PyString_Check(v)) { - char *s = PyString_AsString(v); - Py_ssize_t len = PyString_Size(v); - if (len > 0) { - switch (s[len-1]) { - case ' ': break; - case '\f': case '\r': case '\n': case '\t': case '\v': - PyFile_SoftSpace(f, 0); - break; - default: break; - } - } - } - } - if (newline) { - if (PyFile_WriteString("\n", f) < 0) - goto error; - PyFile_SoftSpace(f, 0); - } - Py_DECREF(f); - return 0; -error: - Py_DECREF(f); - return -1; -} -#else -static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { - PyObject* kwargs = 0; - PyObject* result = 0; - PyObject* end_string; - if (unlikely(!__pyx_print)) { - __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print); - if (!__pyx_print) - return -1; - } - if (stream) { - kwargs = PyDict_New(); - if (unlikely(!kwargs)) - return -1; - if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0)) - goto bad; - if (!newline) { - end_string = PyUnicode_FromStringAndSize(" ", 1); - if (unlikely(!end_string)) - goto bad; - if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) { - Py_DECREF(end_string); - goto bad; - } - Py_DECREF(end_string); - } - } else if (!newline) { - if (unlikely(!__pyx_print_kwargs)) { - __pyx_print_kwargs = PyDict_New(); - if (unlikely(!__pyx_print_kwargs)) - return -1; - end_string = PyUnicode_FromStringAndSize(" ", 1); - if (unlikely(!end_string)) - return -1; - if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) { - Py_DECREF(end_string); - return -1; - } - Py_DECREF(end_string); - } - kwargs = __pyx_print_kwargs; - } - result = PyObject_Call(__pyx_print, arg_tuple, kwargs); - if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs)) - Py_DECREF(kwargs); - if (!result) - return -1; - Py_DECREF(result); - return 0; -bad: - if (kwargs != __pyx_print_kwargs) - Py_XDECREF(kwargs); - return -1; -} -#endif - -/* Declarations */ - #if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return ::std::complex< float >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - return x + y*(__pyx_t_float_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { - __pyx_t_float_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -/* Arithmetic */ - #if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - #if 1 - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - if (b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); - } else if (fabsf(b.real) >= fabsf(b.imag)) { - if (b.real == 0 && b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag); - } else { - float r = b.imag / b.real; - float s = (float)(1.0) / (b.real + b.imag * r); - return __pyx_t_float_complex_from_parts( - (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); - } - } else { - float r = b.real / b.imag; - float s = (float)(1.0) / (b.imag + b.real * r); - return __pyx_t_float_complex_from_parts( - (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); - } - } - #else - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - if (b.imag == 0) { - return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); - } else { - float denom = b.real * b.real + b.imag * b.imag; - return __pyx_t_float_complex_from_parts( - (a.real * b.real + a.imag * b.imag) / denom, - (a.imag * b.real - a.real * b.imag) / denom); - } - } - #endif - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) { - __pyx_t_float_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrtf(z.real*z.real + z.imag*z.imag); - #else - return hypotf(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { - __pyx_t_float_complex z; - float r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - float denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - return __Pyx_c_prod_float(a, a); - case 3: - z = __Pyx_c_prod_float(a, a); - return __Pyx_c_prod_float(z, a); - case 4: - z = __Pyx_c_prod_float(a, a); - return __Pyx_c_prod_float(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } else if (b.imag == 0) { - z.real = powf(a.real, b.real); - z.imag = 0; - return z; - } else if (a.real > 0) { - r = a.real; - theta = 0; - } else { - r = -a.real; - theta = atan2f(0.0, -1.0); - } - } else { - r = __Pyx_c_abs_float(a); - theta = atan2f(a.imag, a.real); - } - lnr = logf(r); - z_r = expf(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cosf(z_theta); - z.imag = z_r * sinf(z_theta); - return z; - } - #endif -#endif - -/* Declarations */ - #if CYTHON_CCOMPLEX - #ifdef __cplusplus - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return ::std::complex< double >(x, y); - } - #else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - return x + y*(__pyx_t_double_complex)_Complex_I; - } - #endif -#else - static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { - __pyx_t_double_complex z; - z.real = x; - z.imag = y; - return z; - } -#endif - -/* Arithmetic */ - #if CYTHON_CCOMPLEX -#else - static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - return (a.real == b.real) && (a.imag == b.imag); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real + b.real; - z.imag = a.imag + b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real - b.real; - z.imag = a.imag - b.imag; - return z; - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - z.real = a.real * b.real - a.imag * b.imag; - z.imag = a.real * b.imag + a.imag * b.real; - return z; - } - #if 1 - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - if (b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); - } else if (fabs(b.real) >= fabs(b.imag)) { - if (b.real == 0 && b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag); - } else { - double r = b.imag / b.real; - double s = (double)(1.0) / (b.real + b.imag * r); - return __pyx_t_double_complex_from_parts( - (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); - } - } else { - double r = b.real / b.imag; - double s = (double)(1.0) / (b.imag + b.real * r); - return __pyx_t_double_complex_from_parts( - (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); - } - } - #else - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - if (b.imag == 0) { - return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); - } else { - double denom = b.real * b.real + b.imag * b.imag; - return __pyx_t_double_complex_from_parts( - (a.real * b.real + a.imag * b.imag) / denom, - (a.imag * b.real - a.real * b.imag) / denom); - } - } - #endif - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = -a.real; - z.imag = -a.imag; - return z; - } - static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) { - return (a.real == 0) && (a.imag == 0); - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) { - __pyx_t_double_complex z; - z.real = a.real; - z.imag = -a.imag; - return z; - } - #if 1 - static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) { - #if !defined(HAVE_HYPOT) || defined(_MSC_VER) - return sqrt(z.real*z.real + z.imag*z.imag); - #else - return hypot(z.real, z.imag); - #endif - } - static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { - __pyx_t_double_complex z; - double r, lnr, theta, z_r, z_theta; - if (b.imag == 0 && b.real == (int)b.real) { - if (b.real < 0) { - double denom = a.real * a.real + a.imag * a.imag; - a.real = a.real / denom; - a.imag = -a.imag / denom; - b.real = -b.real; - } - switch ((int)b.real) { - case 0: - z.real = 1; - z.imag = 0; - return z; - case 1: - return a; - case 2: - return __Pyx_c_prod_double(a, a); - case 3: - z = __Pyx_c_prod_double(a, a); - return __Pyx_c_prod_double(z, a); - case 4: - z = __Pyx_c_prod_double(a, a); - return __Pyx_c_prod_double(z, z); - } - } - if (a.imag == 0) { - if (a.real == 0) { - return a; - } else if (b.imag == 0) { - z.real = pow(a.real, b.real); - z.imag = 0; - return z; - } else if (a.real > 0) { - r = a.real; - theta = 0; - } else { - r = -a.real; - theta = atan2(0.0, -1.0); - } - } else { - r = __Pyx_c_abs_double(a); - theta = atan2(a.imag, a.real); - } - lnr = log(r); - z_r = exp(lnr * b.real - theta * b.imag); - z_theta = theta * b.real + lnr * b.imag; - z.real = z_r * cos(z_theta); - z.imag = z_r * sin(z_theta); - return z; - } - #endif -#endif - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const int neg_one = (int) -1, const_zero = (int) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(int) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), - little, !is_unsigned); - } -} - -/* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const int neg_one = (int) -1, const_zero = (int) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (int) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) - case -2: - if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - } -#endif - if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int"); - return (int) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; -} - -/* PrintOne */ - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 -static int __Pyx_PrintOne(PyObject* f, PyObject *o) { - if (!f) { - if (!(f = __Pyx_GetStdout())) - return -1; - } - Py_INCREF(f); - if (PyFile_SoftSpace(f, 0)) { - if (PyFile_WriteString(" ", f) < 0) - goto error; - } - if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0) - goto error; - if (PyFile_WriteString("\n", f) < 0) - goto error; - Py_DECREF(f); - return 0; -error: - Py_DECREF(f); - return -1; - /* the line below is just to avoid C compiler - * warnings about unused functions */ - return __Pyx_Print(f, NULL, 0); -} -#else -static int __Pyx_PrintOne(PyObject* stream, PyObject *o) { - int res; - PyObject* arg_tuple = PyTuple_Pack(1, o); - if (unlikely(!arg_tuple)) - return -1; - res = __Pyx_Print(stream, arg_tuple, 1); - Py_DECREF(arg_tuple); - return res; -} -#endif - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { - return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { - return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { - return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (long) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) - case -2: - if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - } -#endif - if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to long"); - return (long) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; -} - -/* FastTypeChecks */ - #if CYTHON_COMPILING_IN_CPYTHON -static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { - while (a) { - a = a->tp_base; - if (a == b) - return 1; - } - return b == &PyBaseObject_Type; -} -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { - PyObject *mro; - if (a == b) return 1; - mro = a->tp_mro; - if (likely(mro)) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(mro); - for (i = 0; i < n; i++) { - if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) - return 1; - } - return 0; - } - return __Pyx_InBases(a, b); -} -#if PY_MAJOR_VERSION == 2 -static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { - PyObject *exception, *value, *tb; - int res; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&exception, &value, &tb); - res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - if (!res) { - res = PyObject_IsSubclass(err, exc_type2); - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - } - __Pyx_ErrRestore(exception, value, tb); - return res; -} -#else -static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { - int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; - if (!res) { - res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); - } - return res; -} -#endif -static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - assert(PyExceptionClass_Check(exc_type)); - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; ip) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - if (PyObject_Hash(*t->p) == -1) - return -1; - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { - Py_ssize_t ignore; - return __Pyx_PyObject_AsStringAndSize(o, &ignore); -} -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -#if !CYTHON_PEP393_ENABLED -static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -} -#else -static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (likely(PyUnicode_IS_ASCII(o))) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } -#else - return PyUnicode_AsUTF8AndSize(o, length); -#endif -} -#endif -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { - return __Pyx_PyUnicode_AsStringAndSize(o, length); - } else -#endif -#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif - { - char* result; - int r = PyBytes_AsStringAndSize(o, &result, length); - if (unlikely(r < 0)) { - return NULL; - } else { - return result; - } - } -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { - int is_true = x == Py_True; - if (is_true | (x == Py_False) | (x == Py_None)) return is_true; - else return PyObject_IsTrue(x); -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { - int retval; - if (unlikely(!x)) return -1; - retval = __Pyx_PyObject_IsTrue(x); - Py_DECREF(x); - return retval; -} -static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { -#if PY_MAJOR_VERSION >= 3 - if (PyLong_Check(result)) { - if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, - "__int__ returned non-int (type %.200s). " - "The ability to return an instance of a strict subclass of int " - "is deprecated, and may be removed in a future version of Python.", - Py_TYPE(result)->tp_name)) { - Py_DECREF(result); - return NULL; - } - return result; - } -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - type_name, type_name, Py_TYPE(result)->tp_name); - Py_DECREF(result); - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { -#if CYTHON_USE_TYPE_SLOTS - PyNumberMethods *m; -#endif - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x) || PyLong_Check(x))) -#else - if (likely(PyLong_Check(x))) -#endif - return __Pyx_NewRef(x); -#if CYTHON_USE_TYPE_SLOTS - m = Py_TYPE(x)->tp_as_number; - #if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = m->nb_int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = m->nb_long(x); - } - #else - if (likely(m && m->nb_int)) { - name = "int"; - res = m->nb_int(x); - } - #endif -#else - if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { - res = PyNumber_Int(x); - } -#endif - if (likely(res)) { -#if PY_MAJOR_VERSION < 3 - if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { -#else - if (unlikely(!PyLong_CheckExact(res))) { -#endif - return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); - } - } - else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "an integer is required"); - } - return res; -} -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { - Py_ssize_t ival; - PyObject *x; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) { - if (sizeof(Py_ssize_t) >= sizeof(long)) - return PyInt_AS_LONG(b); - else - return PyInt_AsSsize_t(b); - } -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)b)->ob_digit; - const Py_ssize_t size = Py_SIZE(b); - if (likely(__Pyx_sst_abs(size) <= 1)) { - ival = likely(size) ? digits[0] : 0; - if (size == -1) ival = -ival; - return ival; - } else { - switch (size) { - case 2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - } - } - #endif - return PyLong_AsSsize_t(b); - } - x = PyNumber_Index(b); - if (!x) return -1; - ival = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { - return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { - return PyInt_FromSize_t(ival); -} - - -#endif /* Py_PYTHON_H */ diff --git a/landcover-L-SAR/tool/algorithm/transforml1a/build/temp.win-amd64-3.8/Release/build/SAR_geo/SAR_GEO.cp38-win_amd64.exp b/landcover-L-SAR/tool/algorithm/transforml1a/build/temp.win-amd64-3.8/Release/build/SAR_geo/SAR_GEO.cp38-win_amd64.exp deleted file mode 100644 index ce0cc3b..0000000 Binary files a/landcover-L-SAR/tool/algorithm/transforml1a/build/temp.win-amd64-3.8/Release/build/SAR_geo/SAR_GEO.cp38-win_amd64.exp and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/transforml1a/build/temp.win-amd64-3.8/Release/build/SAR_geo/SAR_GEO.cp38-win_amd64.lib b/landcover-L-SAR/tool/algorithm/transforml1a/build/temp.win-amd64-3.8/Release/build/SAR_geo/SAR_GEO.cp38-win_amd64.lib deleted file mode 100644 index 5582029..0000000 Binary files a/landcover-L-SAR/tool/algorithm/transforml1a/build/temp.win-amd64-3.8/Release/build/SAR_geo/SAR_GEO.cp38-win_amd64.lib and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/transforml1a/build/temp.win-amd64-3.8/Release/build/SAR_geo/SAR_GEO.obj b/landcover-L-SAR/tool/algorithm/transforml1a/build/temp.win-amd64-3.8/Release/build/SAR_geo/SAR_GEO.obj deleted file mode 100644 index d22d27a..0000000 Binary files a/landcover-L-SAR/tool/algorithm/transforml1a/build/temp.win-amd64-3.8/Release/build/SAR_geo/SAR_GEO.obj and /dev/null differ diff --git a/landcover-L-SAR/tool/algorithm/transforml1a/setup.py b/landcover-L-SAR/tool/algorithm/transforml1a/setup.py deleted file mode 100644 index 5183e0c..0000000 --- a/landcover-L-SAR/tool/algorithm/transforml1a/setup.py +++ /dev/null @@ -1,45 +0,0 @@ -from setuptools import setup -from setuptools.extension import Extension -from Cython.Distutils import build_ext -from Cython.Build import cythonize -import numpy -from pathlib import Path -import shutil - - -class MyBuildExt(build_ext): - def run(self): - build_ext.run(self) - - build_dir = Path(self.build_lib) - root_dir = Path(__file__).parent - target_dir = build_dir if not self.inplace else root_dir - - self.copy_file(Path('./SAR_geo') / '__init__.py', root_dir, target_dir) - #self.copy_file(Path('./pkg2') / '__init__.py', root_dir, target_dir) - self.copy_file(Path('.') / '__init__.py', root_dir, target_dir) - def copy_file(self, path, source_dir, destination_dir): - if not (source_dir / path).exists(): - return - shutil.copyfile(str(source_dir / path), str(destination_dir / path)) - -setup( - name="MyModule", - ext_modules=cythonize( - [ - #Extension("pkg1.*", ["root/pkg1/*.py"]), - Extension("pkg2.*", ["./SAR_geo/SAR_GEO.pyx"]), - #Extension("1.*", ["root/*.py"]) - ], - build_dir="build", - compiler_directives=dict( - always_allow_keywords=True - )), - cmdclass=dict( - build_ext=MyBuildExt - ), - packages=[], - include_dirs=[numpy.get_include()], -) - -# 指令: python setup.py build_ext --inplace diff --git a/landcover-L-SAR/tool/algorithm/transforml1a/transHandle.py b/landcover-L-SAR/tool/algorithm/transforml1a/transHandle.py deleted file mode 100644 index 891b6c8..0000000 --- a/landcover-L-SAR/tool/algorithm/transforml1a/transHandle.py +++ /dev/null @@ -1,1096 +0,0 @@ -from tool.algorithm.transforml1a import SAR_GEO as SAR_GEO -from tool.algorithm.image import ImageHandle -import numpy as np -import scipy -from scipy.interpolate import griddata, RegularGridInterpolator -import logging -import pyresample as pr -# 插值模块 -from pyresample.bilinear import NumpyBilinearResampler -from pyresample import geometry -from pyresample.geometry import AreaDefinition -from osgeo import osr -import os -import math - -# os.environ['PROJ_LIB'] = r"D:\Anaconda\envs\micro\Lib\site-packages\osgeo\data\proj" - -logger = logging.getLogger("mylog") - - -############## -# 多项式回归组件 -############## -# -def griddata_geo(points, data, lon_grid, lat_grid, method, i, end_i): - grid_data = griddata(points, data, (lon_grid, lat_grid), method=method, ) - grid_data = grid_data[:, :, 0] - return [i, end_i, grid_data] - - -def griddataBlock(start_x, len_x, start_y, len_y, grid_data_input, grid_x, grid_y, method): - grid_x = grid_x.reshape(-1) - grid_y = grid_y.reshape(-1) - grid_data_input = grid_data_input.reshape(-1) - x_list = np.array(list(range(len_x))) + start_x - y_list = np.array(list(range(len_y))) + start_y - - x_grid, y_grid = np.meshgrid(x_list, y_list) - idx = np.argsort(grid_x) - grid_x = grid_x[idx].reshape(-1) - grid_y = grid_y[idx].reshape(-1) - grid_data_input = grid_data_input[idx].reshape(-1) - interp_func = RegularGridInterpolator((grid_x.reshape(-1), grid_y.reshape(-1)), grid_data_input.reshape(-1), - method='slinear', bounds_error=False, fill_value=np.nan) - grid_data = interp_func((x_grid, y_grid)) - # grid_data = griddata(p, grid_data_input, (x_grid, y_grid), method=method) - grid_data = grid_data[:, :, 0] - return (x_grid, y_grid, grid_data) - - -class polyfit2d_U: - def __init__(self, x, y, z) -> None: - # 定义参数 - - X = np.ones((x.shape[0], 10)) - X[:, 0] = 1 - X[:, 1] = x - X[:, 2] = y - X[:, 3] = x * y - X[:, 4] = x ** 2 - X[:, 5] = y ** 2 - X[:, 6] = x * X[:, 5] - X[:, 7] = y * X[:, 4] - X[:, 8] = x ** 3 - X[:, 9] = y ** 3 - Y = z.reshape(-1, 1) - A = np.matmul(np.matmul(np.linalg.inv(np.matmul(X.T, X)), X.T), Y) - self.paras_fit = A - - def fit(self, x, y): - X = np.ones((x.shape[0], 10)) - X[:, 0] = 1 - X[:, 1] = x - X[:, 2] = y - X[:, 3] = x * y - X[:, 4] = x ** 2 - X[:, 5] = y ** 2 - X[:, 6] = x * X[:, 5] - X[:, 7] = y * X[:, 4] - X[:, 8] = x ** 3 - X[:, 9] = y ** 3 - z = np.matmul(X, self.paras_fit) - return np.sum(z) - - -class TransImgL1A: - def __init__(self, ori_sim_path, roi, l1a_height, l1a_width): - self._begin_r, self._begin_c, self._end_r, self._end_c = 0, 0, 0, 0 - self.ori2geo_img = None - self._mask = None - self.l1a_height = l1a_height - self.l1a_width = l1a_width - self._min_lon, self._max_lon, self._min_lat, self._max_lat = 0, 0, 0, 0 - self.init_trans_para(ori_sim_path, roi) - - def get_roi_points(self): - rowcol = np.where(self._mask == 1) - data = [(self._begin_r + row, self._begin_c + col) for (row, col) in zip(rowcol[0], rowcol[1])] - return data - - def get_lonlat_points(self): - lon = self.ori2geo_img[0, :, :][np.where(self._mask == 1)] - lat = self.ori2geo_img[1, :, :][np.where(self._mask == 1)] - data = [(row, col) for (row, col) in zip(lon, lat)] - return data - - ###################### - # 插值方法 - ###################### - def init_trans_para(self, sim_ori_path, roi): - """裁剪L1a_img --裁剪L1A影像 - --- 修改 ori_sim 变换为 sim_ori - Args: - src_img_path (_type_): 原始L1A影像 - cuted_img_path (_type_): 待裁剪对象 - roi (_type_): 裁剪roi - """ - ori2geo_img_height = ImageHandle.ImageHandler.get_img_height(sim_ori_path) - ori2geo_img_width = ImageHandle.ImageHandler.get_img_width(sim_ori_path) - ori2geo_img = ImageHandle.ImageHandler.get_data(sim_ori_path) - ori2geo_gt = ImageHandle.ImageHandler.get_geotransform(sim_ori_path) - point_list = np.array(roi) - min_lon = np.nanmin(point_list[:, 0]) - max_lon = np.nanmax(point_list[:, 0]) - min_lat = np.nanmin(point_list[:, 1]) - max_lat = np.nanmax(point_list[:, 1]) - self._min_lon, self._max_lon, self._min_lat, self._max_lat = min_lon, max_lon, min_lat, max_lat - # 根据 min_lon max_lon - # 根据 min_lat max_lat - - (x_min, y_min) = ImageHandle.ImageHandler.lat_lon_to_pixel(sim_ori_path, (min_lon, min_lat)) - (x_max, y_max) = ImageHandle.ImageHandler.lat_lon_to_pixel(sim_ori_path, (max_lon, max_lat)) - - xmin = x_min if x_min < x_max else x_max - xmax = x_min if x_min > x_max else x_max - - ymin = y_min if y_min < y_max else y_max - ymax = y_min if y_min > y_max else y_max - - xmin = int(math.floor(xmin)) # 列号 - xmax = int(math.ceil(xmax)) # 因为python 的索引机制 - # xmax = int(math.ceil(xmax)) + 1 # 因为python 的索引机制 - ymin = int(math.floor(ymin)) # 行号 - ymax = int(math.ceil(ymax)) # 因为pytohn的索引机制 - # ymax = int(math.ceil(ymax)) + 1 # 因为pytohn的索引机制 - - # 处理最大最小范围 - xmin = 0 if 0 > xmin else xmin - ymin = 0 if 0 > ymin else ymin - xmax = xmax if ori2geo_img_width > xmax else ori2geo_img_width - ymax = ymax if ori2geo_img_height > ymax else ori2geo_img_height - - # 判断条件 - xmax = xmax + 1 if xmax == xmin else xmax - ymax = ymax + 1 if ymax == ymin else ymax - - if ymax <= ymin or xmax <= xmin or ymax > ori2geo_img_height or xmax > ori2geo_img_width or xmin < 0 or ymin < 0 or xmin > ori2geo_img_width or ymin > ori2geo_img_height or ymax < 0 or xmax < 0: - msg = 'csv_roi:' + str(roi) + 'not in box,please revise csv data!' - print(msg) - else: - r_arr = ori2geo_img[0, ymin:ymax, xmin:xmax] - c_arr = ori2geo_img[1, ymin:ymax, xmin:xmax] - - # 构建坐标矩阵 - ori2geo_mask_r_count = ymax - ymin - ori2geo_mask_c_count = xmax - xmin - - lon_lat_arr = np.ones((2, ori2geo_mask_r_count, ori2geo_mask_c_count)) - col_arr = np.arange(xmin, xmax) * np.ones((ori2geo_mask_r_count, ori2geo_mask_c_count)) - row_arr = ((np.arange(ymin, ymax)) * np.ones((ori2geo_mask_c_count, ori2geo_mask_r_count))).T - - img_geotrans = ori2geo_gt - lon_arr = img_geotrans[0] + img_geotrans[1] * col_arr + img_geotrans[2] * row_arr - lat_arr = img_geotrans[3] + img_geotrans[4] * col_arr + img_geotrans[5] * row_arr - lon_lat_arr[0, :, :] = lon_arr - lon_lat_arr[1, :, :] = lat_arr - - # print("csv_roi:") - # print(roi) - r_min = np.floor(np.nanmin(r_arr)) # 获取 L1A 的行列号范围 - r_max = np.ceil(np.nanmax(r_arr)) + 1 - c_min = np.floor(np.nanmin(c_arr)) - c_max = np.ceil(np.nanmax(c_arr)) + 1 - - # 判断是否越界 - r_min = 0 if r_min < 0 else r_min - r_max = self.l1a_height if r_max > self.l1a_height else r_max - c_min = 0 if c_min < 0 else c_min - c_max = self.l1a_width if c_max > self.l1a_width else c_max - - # 判断条件 - r_max = r_max + 1 if r_min == r_max else r_max - c_max = c_max + 1 if c_min == c_max else c_max - if r_max <= r_min or c_max <= c_min or r_max > self.l1a_height or c_max > self.l1a_width or r_min < 0 or c_min < 0 or c_min > self.l1a_width or r_min > self.l1a_height or r_max < 0 or c_max < 0: - msg = 'csv_roi:' + str(roi) + 'not in box,please revise csv data!' - else: - pass - mask_geo = SAR_GEO.cut_L1A_img(lon_lat_arr, point_list) # 在地理坐标系下裁剪对应影像 - - mask_geo = mask_geo.reshape(-1) - r_arr = r_arr.reshape(-1) - c_arr = c_arr.reshape(-1) - - mask_geo_idx = np.where(mask_geo == 1)[0] - if mask_geo_idx.shape[0] == 0: - msg = 'csv_roi:' + str(roi) + 'not in box,please revise csv data!' - print(msg) - else: - r_idx = r_arr[mask_geo_idx] - c_idx = c_arr[mask_geo_idx] - - r_idx = r_idx - r_min # offset row - c_idx = c_idx - c_min # offset col - r_count = r_max - r_min # 行数 - c_count = c_max - c_min # 列数 - - # - mask_l1a = np.zeros((r_count, c_count)) * np.nan # 创建目标大小的行列号 - mask = SAR_GEO.gereratorMask(r_idx.astype(np.float64), c_idx.astype(np.float64).astype(np.float64), - mask_l1a) # 这个函数修改了 - - self._begin_r = r_min - self._end_r = r_max - self._begin_c = c_min - self._end_c = c_max - self._mask = mask - - def cut_L1A(self, in_path, out_path): - img = ImageHandle.ImageHandler.get_data(in_path) - if len(img.shape) == 3: - cut_img = img[:, self._begin_r:self._end_r, self._begin_c:self._end_c] - cut_img[0, :, :] = cut_img[0, :, :] * self._mask - cut_img[1, :, :] = cut_img[1, :, :] * self._mask - ImageHandle.ImageHandler.write_img(out_path, '', [0, 0, 0, 0, 0, 0], cut_img) - else: - cut_img = img[self._begin_r:self._end_r + 1, self._begin_c:self._end_c + 1] - cut_img[:, :] = cut_img[:, :] * self._mask - cut_img[:, :] = cut_img[:, :] * self._mask - ImageHandle.ImageHandler.write_img(out_path, '', [0, 0, 0, 0, 0, 0], cut_img) - - def grid_interp_to_station(self, all_data, station_lon, station_lat, method='linear'): - ''' - func: 将等经纬度网格值 插值到 离散站点。使用griddata进行插值 - inputs: - all_data,形式为:[grid_lon,grid_lat,data] 即[经度网格,纬度网格,数值网格] - station_lon: 站点经度 - station_lat: 站点纬度。可以是 单个点,列表或者一维数组 - method: 插值方法,默认使用 linear - ''' - station_lon = np.array(station_lon).reshape(-1, 1) - station_lat = np.array(station_lat).reshape(-1, 1) - - lon = all_data[0].reshape(-1, 1) - lat = all_data[1].reshape(-1, 1) - data = all_data[2].reshape(-1, 1) - - points = np.concatenate([lon, lat], axis=1) - - station_value = griddata(points, data, (station_lon, station_lat), method=method) - - station_value = station_value[:, :, 0] - - return station_value - - ##################### - # 当存在 ori2geo.tif - ##################### - - @staticmethod - def cut_L1a_img(src_img_path, cuted_img_path, roi): - """裁剪L1a_img - Args: - src_img_path (_type_): 原始L1A影像 - cuted_img_path (_type_): 待裁剪对象 - roi (_type_): 裁剪roi - """ - ori2geo_img = ImageHandle.ImageHandler.get_data(src_img_path) - point_list = np.array(roi) - # 开始调用组件 计算 - mask = SAR_GEO.cut_L1A_img(ori2geo_img.astype(np.float64), point_list) - # - ori2geo_img[0, :, :] = ori2geo_img[0, :, :] * mask - ori2geo_img[1, :, :] = ori2geo_img[1, :, :] * mask - - ImageHandle.ImageHandler.write_img(cuted_img_path, '', [0, 0, 0, 0, 0, 0], ori2geo_img) - return ori2geo_img # 保存成影像 - - def tran_geo_to_l1a(self, geo_img_path, out_l1a_img_path, ori_sim_img_path, is_class=False): - """裁剪后的有投影信息的影像(cover、ndvi)转换到L1A裁剪影像的尺寸 - Args: - geo_img_path (_type_): _description_ - out_l1a_img_path (_type_): _description_ - ori_sim_img_path (_type_): _description_ - - geo_img_path:地理影像路径 - out_l1a_img_path:转换L1A坐标系图像路径 - ori_sim_img_path:裁剪后模拟影像路径 - is_clss: 是否是 定性类产品 - - """ - inverse_gt = ImageHandle.ImageHandler.get_invgeotransform(geo_img_path) - ori2geo_tif = ImageHandle.ImageHandler.get_data(ori_sim_img_path) - height = ImageHandle.ImageHandler.get_img_height(geo_img_path) - width = ImageHandle.ImageHandler.get_img_width(geo_img_path) - # 计算投影 - x = ori2geo_tif[0, :, :] # lon lat x,y - y = ori2geo_tif[1, :, :] - ori2geo_tif[0, :, :] = inverse_gt[0] + inverse_gt[1] * x + inverse_gt[2] * y # x - ori2geo_tif[1, :, :] = inverse_gt[3] + inverse_gt[4] * x + inverse_gt[5] * y # y - - del x, y - geo_tif = ImageHandle.ImageHandler.get_data(geo_img_path) # 获取目标影像 - ori2geo_tif_shape = ori2geo_tif.shape # height,width - - if is_class: - ori2geo_tif = np.round(ori2geo_tif).astype(np.int32) - mask = (ori2geo_tif[0, :, :] >= 0) & (ori2geo_tif[0, :, :] < width) & (ori2geo_tif[1, :, :] >= 0) & ( - ori2geo_tif[1, :, :] < height) - ori2geo_tif[0, :, :] = ori2geo_tif[0, :, :] * mask - ori2geo_tif[1, :, :] = ori2geo_tif[1, :, :] * mask - geo_tif_shape = geo_tif.shape - geo_tif_l1a = geo_tif[ori2geo_tif[1, :, :].reshape(-1), ori2geo_tif[0, :, :].reshape(-1)].reshape( - ori2geo_tif.shape[1], ori2geo_tif.shape[2]).astype(np.float32) - del ori2geo_tif, geo_tif - one_ids = np.where(mask == False) - geo_tif_l1a[one_ids[0], one_ids[1]] = np.nan - - ImageHandle.ImageHandler.write_img(out_l1a_img_path, '', [0, 0, 0, 0, 0, 0], geo_tif_l1a) - # save_temp_L1A(out_l1a_img_path,geo_tif_l1a) - return geo_tif_l1a - else: # 数值性插值 - mask = (ori2geo_tif[0, :, :] > 0) & (ori2geo_tif[0, :, :] < width - 1) & (ori2geo_tif[1, :, :] > 0) & ( - ori2geo_tif[1, :, :] < height - 1) - one_ids = np.where(mask == 1) - x, y = np.meshgrid(np.arange(0, width), np.arange(0, height)) - result_data = self.grid_interp_to_station([y.reshape(-1), x.reshape(-1), geo_tif.reshape(-1)], - ori2geo_tif[1, one_ids[0], one_ids[1]].reshape(-1), - ori2geo_tif[0, one_ids[0], one_ids[1]].reshape(-1), - method='linear').reshape(-1) - mask = mask.reshape(-1) - result_data_result = np.zeros((ori2geo_tif.shape[1], ori2geo_tif.shape[2])) - result_data_result[:, :] = np.nan - result_data_result = SAR_GEO.insert_data(result_data_result, one_ids[0].astype(np.int32), - one_ids[1].astype(np.int32), result_data) - ImageHandle.ImageHandler.write_img(out_l1a_img_path, '', [0, 0, 0, 0, 0, 0], result_data_result) - # save_temp_L1A(out_l1a_img_path,result_data_result) - return result_data_result - - def tran_lonlats_to_rowcols(self, lonlats, ori_sim_img_path): - """ - 功能:输入经纬度坐标,输出图像行列号 - 函数名称:tran_lonlats_to_rowcols(lonlats,out_rowcols,ori_sim_img_path) - Lonlats:经纬度坐标,示例[[120.53, 31.5], [120.61, 31.5], [120.53, 31.45], [120.61, 31.45]] - out_rowcols:图像行列号,示例[[0, 0], [7000, 0], [7000, 8000], [0, 8000]] - ori_sim_img_path:裁剪后模拟影像路径 - """ - ori2geo_tif = ImageHandle.ImageHandler.get_data(ori_sim_img_path) - min_lon = np.nanmin(ori2geo_tif[0, :, :]) - max_lon = np.nanmax(ori2geo_tif[0, :, :]) - min_lat = np.nanmin(ori2geo_tif[1, :, :]) - max_lat = np.nanmax(ori2geo_tif[1, :, :]) - - result = [] - for i in range(len(lonlats)): - p = lonlats[i] - if min_lon > p[0] or max_lon < p[0] or min_lat > p[1] or max_lat < p[1]: - result.append([-1, -1]) - continue - temp_x = np.square(ori2geo_tif[0, :, :] - p[0]) + np.square(ori2geo_tif[1, :, :] - p[1]) - r_c_list = [] - r_c = np.argmin(temp_x) - r_c = [r_c // temp_x.shape[1], r_c % temp_x.shape[1]] - r_c_list.append([r_c[0], r_c[1], ori2geo_tif[0, r_c[0], r_c[1]], ori2geo_tif[1, r_c[0], r_c[1]]]) - # 插值 - for i in range(r_c[0] - 3, r_c[0] + 3): - if i < 0 or i > temp_x.shape[0] - 1: - continue - for j in range(r_c[1] - 3, r_c[1] + 3): - if j < 0 or j > temp_x.shape[1] - 1: - continue - r_c_list.append([i, j, ori2geo_tif[0, i, j], ori2geo_tif[1, i, j]]) - r_c_list = np.array(r_c_list) - points = r_c_list[:, 2:] - f_r = scipy.interpolate.interp2d(r_c_list[:, 2], r_c_list[:, 3], r_c_list[:, 0], kind='linear') - f_c = scipy.interpolate.interp2d(r_c_list[:, 2], r_c_list[:, 3], r_c_list[:, 1], kind='linear') - tar_get_r = f_r(p[0], p[1])[0] - tar_get_c = f_c(p[0], p[1])[0] - if tar_get_r < ori2geo_tif.shape[1] and tar_get_c < ori2geo_tif.shape[2] and tar_get_r>=0 and tar_get_c>=0: - lon_temp = ori2geo_tif[0, int(round(tar_get_r)), int(round(tar_get_c))] - lon_lat = ori2geo_tif[1, int(round(tar_get_r)), int(round(tar_get_c))] - # 增加条件筛选 - result.append([tar_get_r, tar_get_c]) - else: - result.append([-1, -1]) - return result - - def tran_lonlats_to_L1A_rowcols(self, meas_data, ori_sim_path, row, col): - lonlats = [] - data_roi = [] - rowcols = [] - measdata_list = [] - data_sim = ImageHandle.ImageHandler.get_all_band_array(ori_sim_path) - for data in meas_data: - lon = float(data[1]) - lat = float(data[2]) - if (lon > self._min_lon and lon < self._max_lon and lat > self._min_lat and lat < self._max_lat): - lonlats.append([lon, lat]) - data_roi.append(data) - - for lonlat in lonlats: - (x, y) = ImageHandle.ImageHandler.lat_lon_to_pixel(ori_sim_path, lonlat) - rowcols.append([x, y]) - - for data, rowcol in zip(data_roi, rowcols): - img_x = round(data_sim[round(rowcol[1]), round(rowcol[0]), 0]) - img_y = round(data_sim[round(rowcol[1]), round(rowcol[0]), 1]) - if (img_x > 0 and img_x < row and img_y > 0 and img_y < col): - measdata_list.append([img_x, img_y, float(data[3])]) - - # rowcols = self.tran_lonlats_to_rowcols(lonlats, ori_sim_path) - # measdata_list = [] - # for data, rowcol in zip(data_roi, rowcols): - # if (rowcol[0] != -1 and rowcol[1] != -1): - # measdata_list.append( - # [round(rowcol[0]) - self._begin_r, round(rowcol[1]) - self._begin_c, float(data[3])]) - return measdata_list - - @staticmethod - def get_radius_of_influence(lalo_step, src_meta='radar2geo', ratio=3): - EARTH_RADIUS = 6378122.65 # m - """Get radius of influence based on the lookup table resolution in lat/lon direction""" - if src_meta == "geo2radar": - # geo2radar - radius = 100e3 - else: - # radar2geo - step_deg = max(np.abs(lalo_step)) - step_m = step_deg * np.pi / 180.0 * EARTH_RADIUS - radius = step_m * ratio - return radius - - def interp2d_station_to_grid(self, lon, lat, data, loc_range=[18, 54, 73, 135], - det_grid=1, method='linear', projCode=4326): - # 参考链接 https://blog.csdn.net/weixin_43718675/article/details/103497930 - ''' - func : 将站点数据插值到等经纬度格点 - inputs: - lon: 站点的经度 - lat: 站点的纬度 - data: 对应经纬度站点的 气象要素值 - loc_range: [lat_min,lat_max,lon_min,lon_max]。站点数据插值到loc_range这个范围 - det_grid: 插值形成的网格空间分辨率 - method: 所选插值方法,默认 0.125 - return: - - [lon_grid,lat_grid,data_grid] - ''' - # step1: 先将 lon,lat,data转换成 n*1 的array数组 - lon = np.array(lon).reshape(-1, 1) - lat = np.array(lat).reshape(-1, 1) - data = np.array(data).reshape(-1, 1) - - # step2:确定插值区域的经纬度网格 - lat_min = loc_range[0] # y - lat_max = loc_range[1] # y - lon_min = loc_range[2] # x - lon_max = loc_range[3] # x - gt = [0, 0, 0, 0, 0, 0] - gt[0] = lon_min # x - gt[1] = det_grid - gt[3] = lat_max # y - gt[5] = -det_grid - lat_count = int((lat_max - lat_min) / det_grid + 1) # y - lon_count = int((lon_max - lon_min) / det_grid + 1) # x - # 替换为pyresample 插值方法 - proj_osr = osr.SpatialReference() - proj_osr.ImportFromEPSG(projCode) - projection = proj_osr.ExportToPROJJSON() - # (lower_left_x、lower_left_y、upper_right_x、upper_right_y) - target_def = AreaDefinition("id1", "WGS84", "proj_id", projection, - lon_count, lat_count, [lon_min, lat_min, lon_max, lat_max]) - source_def = geometry.SwathDefinition(lons=lon, lats=lat) - lalo_step = [det_grid, -det_grid] - radius = TransImgL1A.get_radius_of_influence(lalo_step, src_meta='radar2geo') - result = pr.bilinear.resample_bilinear(data, source_def, target_def, - radius=radius, neighbours=32, - nprocs=8, fill_value=np.nan, - epsilon=0) - # - return result - - def geocoding(self, ori_geo_tif, produc_arr, pixel_delta=1, method='linear'): - # 参考链接 https://blog.csdn.net/weixin_43718675/article/details/103497930 - ori_geo_tif[np.isnan(ori_geo_tif)] = -1 - lon_data = ori_geo_tif[0, :, :].reshape(-1) - lat_data = ori_geo_tif[1, :, :].reshape(-1) - idx = np.where(lat_data != -1) - lat_data = lat_data[idx] - lon_data = lon_data[idx] - idx = np.where(lon_data != -1) - - lat_data = lat_data[idx] - lon_data = lon_data[idx] - # ########################################### - result = self.interp2d_station_to_grid(lon_data, lat_data, produc_arr, - [self._min_lat, self._max_lat, self._min_lon, self._max_lon], - det_grid=pixel_delta, method=method) - return result - - # def l1a_2_geo(self, ori_geo_path, l1a_produc_path, geo_produc_path, method='linear'): - # ori_geo_tif = ImageHandle.ImageHandler.get_data(ori_geo_path) - # # l1a_produc = ImageHandle.ImageHandler.get_data(l1a_produc_path) - # l1a_produc = ImageHandle.ImageHandler.get_band_array(l1a_produc_path, 1) - # pixel_delta_y = (self._max_lat - self._min_lat) / (self._end_r - self._begin_r) # 0.001 - # pixel_delta_x = (self._max_lon - self._min_lon) / (self._end_c - self._begin_c) - # - # lon_data = ori_geo_tif[0, :, :].reshape(-1) - # lat_data = ori_geo_tif[1, :, :].reshape(-1) - # l1a_produc = l1a_produc.reshape(-1) - # idx = np.logical_not(np.isnan(lon_data)) - # lat_data = lat_data[idx] - # lon_data = lon_data[idx] - # l1a_produc = l1a_produc[idx] - # idx = np.logical_not(np.isnan(lat_data)) - # lat_data = lat_data[idx] - # lon_data = lon_data[idx] - # l1a_produc = l1a_produc[idx] - # - # gt = [self._min_lon, pixel_delta_x, 0.0, - # self._max_lat, 0.0, -pixel_delta_y] - # [lat_min, lat_max, lon_min, lon_max] = [self._min_lat, self._max_lat, self._min_lon, self._max_lon] - # lat_count = int((lat_max - lat_min) / pixel_delta_y + 1) # y - # lon_count = int((lon_max - lon_min) / pixel_delta_x + 1) # x - # - # # 获取地理坐标系统信息,用于选取需要的地理坐标系统 - # srs = osr.SpatialReference() - # srs.ImportFromEPSG(4326) # 定义输出的坐标系为"WGS 84" - # proj = srs.ExportToWkt() - # - # projection = srs.ExportToPROJJSON() - # # (lower_left_x、lower_left_y、upper_right_x、upper_right_y) - # target_def = AreaDefinition("id1", "WGS84", "proj_id", projection, - # lon_count, lat_count, [lon_min, lat_min, lon_max, lat_max]) - # lon_data = lon_data.reshape(-1, 1) - # lat_data = lat_data.reshape(-1, 1) - # l1a_produc = l1a_produc.reshape(-1, 1) - # source_def = geometry.SwathDefinition(lons=lon_data, lats=lat_data) - # lalo_step = [pixel_delta_x, -pixel_delta_y] - # radius = TransImgL1A.get_radius_of_influence(lalo_step, src_meta='radar2geo') - # geo_produc = pr.bilinear.resample_bilinear(l1a_produc, source_def, target_def, - # radius=radius, neighbours=32, - # nprocs=8, fill_value=np.nan, - # epsilon=0) - # - # ImageHandle.ImageHandler.write_img(geo_produc_path, proj, gt, geo_produc, np.nan) - # - # def l1a_2_geo_int(self, ori_geo_path, l1a_produc_path, geo_produc_path, method='nearest'): - # ori_geo_tif = ImageHandle.ImageHandler.get_data(ori_geo_path) - # # l1a_produc = ImageHandle.ImageHandler.get_data(l1a_produc_path) - # l1a_produc = ImageHandle.ImageHandler.get_band_array(l1a_produc_path, 1) - # pixel_delta_y = (self._max_lat - self._min_lat) / (self._end_r - self._begin_r) # 0.001 - # pixel_delta_x = (self._max_lon - self._min_lon) / (self._end_c - self._begin_c) - # - # lon_data = ori_geo_tif[0, :, :].reshape(-1) - # lat_data = ori_geo_tif[1, :, :].reshape(-1) - # l1a_produc = l1a_produc.reshape(-1) - # idx = np.logical_not(np.isnan(lon_data)) - # lat_data = lat_data[idx] - # lon_data = lon_data[idx] - # l1a_produc = l1a_produc[idx] - # idx = np.logical_not(np.isnan(lat_data)) - # lat_data = lat_data[idx] - # lon_data = lon_data[idx] - # l1a_produc = l1a_produc[idx] - # - # gt = [self._min_lon, pixel_delta_x, 0.0, - # self._max_lat, 0.0, -pixel_delta_y] - # [lat_min, lat_max, lon_min, lon_max] = [self._min_lat, self._max_lat, self._min_lon, self._max_lon] - # lat_count = int((lat_max - lat_min) / pixel_delta_y + 1) # y - # lon_count = int((lon_max - lon_min) / pixel_delta_x + 1) # x - # - # # 获取地理坐标系统信息,用于选取需要的地理坐标系统 - # srs = osr.SpatialReference() - # srs.ImportFromEPSG(4326) # 定义输出的坐标系为"WGS 84" - # proj = srs.ExportToWkt() - # - # projection = srs.ExportToPROJJSON() - # # (lower_left_x、lower_left_y、upper_right_x、upper_right_y) - # target_def = AreaDefinition("id1", "WGS84", "proj_id", projection, - # lon_count, lat_count, [lon_min, lat_min, lon_max, lat_max]) - # lon_data = lon_data.reshape(-1, 1) - # lat_data = lat_data.reshape(-1, 1) - # l1a_produc = l1a_produc.reshape(-1, 1) - # source_def = geometry.SwathDefinition(lons=lon_data, lats=lat_data) - # lalo_step = [pixel_delta_x, -pixel_delta_y] - # radius = TransImgL1A.get_radius_of_influence(lalo_step, src_meta='radar2geo') - # if method == 'linear': - # geo_produc = pr.bilinear.resample_bilinear(l1a_produc, source_def, target_def, - # radius=radius, neighbours=32, - # nprocs=8, fill_value=0, - # epsilon=0) - # elif method == 'nearest': - # geo_produc = pr.kd_tree.resample_nearest(source_def, l1a_produc, target_def, epsilon=0, - # radius_of_influence=50000, - # fill_value=0, nprocs=8 - # ) - # geo_produc = geo_produc[:,:,0] - # ImageHandle.ImageHandler.write_img(geo_produc_path, proj, gt, geo_produc) - - @property - def mask(self): - return self._mask - -class TransImgL1A_ori: - def __init__(self, ori_sim_path, roi): - self._begin_r, self._begin_c, self._end_r, self._end_c = 0, 0, 0, 0 - self._mask = None - self._min_lon, self._max_lon, self._min_lat, self._max_lat = 0, 0, 0, 0 - self.init_trans_para(ori_sim_path, roi) - - def get_roi_points(self): - rowcol = np.where(self._mask == 1) - data = [(self._begin_r + row, self._begin_c + col) for (row, col) in zip(rowcol[0], rowcol[1])] - return data - - ###################### - # 插值方法 - ###################### - def init_trans_para(self, ori_sim_path, roi): - """裁剪L1a_img - Args: - src_img_path (_type_): 原始L1A影像 - cuted_img_path (_type_): 待裁剪对象 - roi (_type_): 裁剪roi - """ - ori2geo_img = ImageHandle.ImageHandler.get_data(ori_sim_path) - point_list = np.array(roi) - min_lon = np.nanmin(point_list[:, 0]) - max_lon = np.nanmax(point_list[:, 0]) - min_lat = np.nanmin(point_list[:, 1]) - max_lat = np.nanmax(point_list[:, 1]) - self._min_lon, self._max_lon, self._min_lat, self._max_lat = min_lon, max_lon, min_lat, max_lat - - r_c_list = np.where( - (ori2geo_img[0, :, :] >= min_lon) & (ori2geo_img[0, :, :] <= max_lon) - & (ori2geo_img[1, :, :] >= min_lat) & (ori2geo_img[1, :, :] <= max_lat)) # - - if len(r_c_list) == 0 or r_c_list[0] == [] or r_c_list[1] == [] or np.array(r_c_list).size == 0: - msg = 'csv_roi:' + str(roi) + 'not in box,please revise csv data!' - print(msg) - else: - # print("csv_roi:") - # print(roi) - r_min = np.nanmin(r_c_list[0]) - r_max = np.nanmax(r_c_list[0]) - c_min = np.nanmin(r_c_list[1]) - c_max = np.nanmax(r_c_list[1]) - ori2geo_img = ori2geo_img[:, r_min:r_max + 1, c_min:c_max + 1] - # 开始调用组件 计算 - - mask = SAR_GEO.cut_L1A_img(ori2geo_img.astype(np.float64), point_list) - self._begin_r = r_min - self._end_r = r_max - self._begin_c = c_min - self._end_c = c_max - self._mask = mask - - def cut_L1A(self, in_path, out_path): - img = ImageHandle.ImageHandler.get_data(in_path) - if len(img.shape) == 3: - cut_img = img[:, self._begin_r:self._end_r + 1, self._begin_c:self._end_c + 1] - cut_img[0, :, :] = cut_img[0, :, :] * self._mask - cut_img[1, :, :] = cut_img[1, :, :] * self._mask - ImageHandle.ImageHandler.write_img(out_path, '', [0, 0, 0, 0, 0, 0], cut_img) - else: - cut_img = img[self._begin_r:self._end_r + 1, self._begin_c:self._end_c + 1] - cut_img[:, :] = cut_img[:, :] * self._mask - cut_img[:, :] = cut_img[:, :] * self._mask - ImageHandle.ImageHandler.write_img(out_path, '', [0, 0, 0, 0, 0, 0], cut_img) - - def grid_interp_to_station(self, all_data, station_lon, station_lat, method='linear'): - ''' - func: 将等经纬度网格值 插值到 离散站点。使用griddata进行插值 - inputs: - all_data,形式为:[grid_lon,grid_lat,data] 即[经度网格,纬度网格,数值网格] - station_lon: 站点经度 - station_lat: 站点纬度。可以是 单个点,列表或者一维数组 - method: 插值方法,默认使用 linear - ''' - station_lon = np.array(station_lon).reshape(-1, 1) - station_lat = np.array(station_lat).reshape(-1, 1) - - lon = all_data[0].reshape(-1, 1) - lat = all_data[1].reshape(-1, 1) - data = all_data[2].reshape(-1, 1) - - points = np.concatenate([lon, lat], axis=1) - - station_value = griddata(points, data, (station_lon, station_lat), method=method) - - station_value = station_value[:, :, 0] - - return station_value - - ##################### - # 当存在 ori2geo.tif - ##################### - - @staticmethod - def cut_L1a_img(src_img_path, cuted_img_path, roi): - """裁剪L1a_img - Args: - src_img_path (_type_): 原始L1A影像 - cuted_img_path (_type_): 待裁剪对象 - roi (_type_): 裁剪roi - """ - ori2geo_img = ImageHandle.ImageHandler.get_data(src_img_path) - point_list = np.array(roi) - # 开始调用组件 计算 - mask = SAR_GEO.cut_L1A_img(ori2geo_img.astype(np.float64), point_list) - # - ori2geo_img[0, :, :] = ori2geo_img[0, :, :] * mask - ori2geo_img[1, :, :] = ori2geo_img[1, :, :] * mask - - ImageHandle.ImageHandler.write_img(cuted_img_path, '', [0, 0, 0, 0, 0, 0], ori2geo_img) - return ori2geo_img # 保存成影像 - - def tran_geo_to_l1a(self, geo_img_path, out_l1a_img_path, ori_sim_img_path, is_class=False): - """裁剪后的有投影信息的影像(cover、ndvi)转换到L1A裁剪影像的尺寸 - Args: - geo_img_path (_type_): _description_ - out_l1a_img_path (_type_): _description_ - ori_sim_img_path (_type_): _description_ - - geo_img_path:地理影像路径 - out_l1a_img_path:转换L1A坐标系图像路径 - ori_sim_img_path:裁剪后模拟影像路径 - is_clss: 是否是 定性类产品 - - """ - inverse_gt = ImageHandle.ImageHandler.get_invgeotransform(geo_img_path) - ori2geo_tif = ImageHandle.ImageHandler.get_data(ori_sim_img_path) - height = ImageHandle.ImageHandler.get_img_height(geo_img_path) - width = ImageHandle.ImageHandler.get_img_width(geo_img_path) - # 计算投影 - x = ori2geo_tif[0, :, :] # lon lat x,y - y = ori2geo_tif[1, :, :] - ori2geo_tif[0, :, :] = inverse_gt[0] + inverse_gt[1] * x + inverse_gt[2] * y # x - ori2geo_tif[1, :, :] = inverse_gt[3] + inverse_gt[4] * x + inverse_gt[5] * y # y - - del x, y - geo_tif = ImageHandle.ImageHandler.get_data(geo_img_path) # 获取目标影像 - ori2geo_tif_shape = ori2geo_tif.shape # height,width - - if is_class: - ori2geo_tif = np.round(ori2geo_tif).astype(np.int32) - mask = (ori2geo_tif[0, :, :] >= 0) & (ori2geo_tif[0, :, :] < width) & (ori2geo_tif[1, :, :] >= 0) & ( - ori2geo_tif[1, :, :] < height) - ori2geo_tif[0, :, :] = ori2geo_tif[0, :, :] * mask - ori2geo_tif[1, :, :] = ori2geo_tif[1, :, :] * mask - geo_tif_shape = geo_tif.shape - geo_tif_l1a = geo_tif[ori2geo_tif[1, :, :].reshape(-1), ori2geo_tif[0, :, :].reshape(-1)].reshape( - ori2geo_tif.shape[1], ori2geo_tif.shape[2]).astype(np.float32) - del ori2geo_tif, geo_tif - one_ids = np.where(mask == False) - geo_tif_l1a[one_ids[0], one_ids[1]] = np.nan - - ImageHandle.ImageHandler.write_img(out_l1a_img_path, '', [0, 0, 0, 0, 0, 0], geo_tif_l1a) - # save_temp_L1A(out_l1a_img_path,geo_tif_l1a) - return geo_tif_l1a - else: # 数值性插值 - mask = (ori2geo_tif[0, :, :] > 0) & (ori2geo_tif[0, :, :] < width - 1) & (ori2geo_tif[1, :, :] > 0) & ( - ori2geo_tif[1, :, :] < height - 1) - one_ids = np.where(mask == 1) - x, y = np.meshgrid(np.arange(0, width), np.arange(0, height)) - result_data = self.grid_interp_to_station([y.reshape(-1), x.reshape(-1), geo_tif.reshape(-1)], - ori2geo_tif[1, one_ids[0], one_ids[1]].reshape(-1), - ori2geo_tif[0, one_ids[0], one_ids[1]].reshape(-1), - method='linear').reshape(-1) - mask = mask.reshape(-1) - result_data_result = np.zeros((ori2geo_tif.shape[1], ori2geo_tif.shape[2])) - result_data_result[:, :] = np.nan - result_data_result = SAR_GEO.insert_data(result_data_result, one_ids[0].astype(np.int32), - one_ids[1].astype(np.int32), result_data) - ImageHandle.ImageHandler.write_img(out_l1a_img_path, '', [0, 0, 0, 0, 0, 0], result_data_result) - # save_temp_L1A(out_l1a_img_path,result_data_result) - return result_data_result - - def tran_lonlats_to_rowcols(self, lonlats, ori_sim_img_path): - """ - 功能:输入经纬度坐标,输出图像行列号 - 函数名称:tran_lonlats_to_rowcols(lonlats,out_rowcols,ori_sim_img_path) - Lonlats:经纬度坐标,示例[[120.53, 31.5], [120.61, 31.5], [120.53, 31.45], [120.61, 31.45]] - out_rowcols:图像行列号,示例[[0, 0], [7000, 0], [7000, 8000], [0, 8000]] - ori_sim_img_path:裁剪后模拟影像路径 - """ - ori2geo_tif = ImageHandle.ImageHandler.get_data(ori_sim_img_path) - min_lon = np.nanmin(ori2geo_tif[0, :, :]) - max_lon = np.nanmax(ori2geo_tif[0, :, :]) - min_lat = np.nanmin(ori2geo_tif[1, :, :]) - max_lat = np.nanmax(ori2geo_tif[1, :, :]) - - result = [] - for i in range(len(lonlats)): - p = lonlats[i] - if min_lon > p[0] or max_lon < p[0] or min_lat > p[1] or max_lat < p[1]: - result.append([-1, -1]) - continue - temp_x = np.square(ori2geo_tif[0, :, :] - p[0]) + np.square(ori2geo_tif[1, :, :] - p[1]) - r_c_list = [] - r_c = np.argmin(temp_x) - r_c = [r_c // temp_x.shape[1], r_c % temp_x.shape[1]] - r_c_list.append([r_c[0], r_c[1], ori2geo_tif[0, r_c[0], r_c[1]], ori2geo_tif[1, r_c[0], r_c[1]]]) - # 插值 - for i in range(r_c[0] - 3, r_c[0] + 3): - if i < 0 or i > temp_x.shape[0] - 1: - continue - for j in range(r_c[1] - 3, r_c[1] + 3): - if j < 0 or j > temp_x.shape[1] - 1: - continue - r_c_list.append([i, j, ori2geo_tif[0, i, j], ori2geo_tif[1, i, j]]) - r_c_list = np.array(r_c_list) - points = r_c_list[:, 2:] - f_r = scipy.interpolate.interp2d(r_c_list[:, 2], r_c_list[:, 3], r_c_list[:, 0], kind='linear') - f_c = scipy.interpolate.interp2d(r_c_list[:, 2], r_c_list[:, 3], r_c_list[:, 1], kind='linear') - tar_get_r = f_r(p[0], p[1])[0] - tar_get_c = f_c(p[0], p[1])[0] - if tar_get_r < ori2geo_tif.shape[1] and tar_get_c < ori2geo_tif.shape[2] and tar_get_r >= 0 and tar_get_c >= 0: - lon_temp = ori2geo_tif[0, int(round(tar_get_r)), int(round(tar_get_c))] - lon_lat = ori2geo_tif[1, int(round(tar_get_r)), int(round(tar_get_c))] - # 增加条件筛选 - result.append([tar_get_r, tar_get_c]) - else: - result.append([-1, -1]) - return result - - def tran_lonlats_to_L1A_rowcols(self, meas_data, ori_sim_path): - lonlats = [] - data_roi = [] - for data in meas_data: - lon = float(data[1]) - lat = float(data[2]) - if (lon > self._min_lon and lon < self._max_lon and lat > self._min_lat and lat < self._max_lat): - lonlats.append([lon, lat]) - data_roi.append(data) - - rowcols = self.tran_lonlats_to_rowcols(lonlats, ori_sim_path) - measdata_list = [] - for data, rowcol in zip(data_roi, rowcols): - if (rowcol[0] != -1 and rowcol[1] != -1): - measdata_list.append( - [round(rowcol[0]) - self._begin_r, round(rowcol[1]) - self._begin_c, float(data[3])]) - return measdata_list - - @staticmethod - def get_radius_of_influence(lalo_step, src_meta='radar2geo', ratio=3): - EARTH_RADIUS = 6378122.65 # m - """Get radius of influence based on the lookup table resolution in lat/lon direction""" - if src_meta == "geo2radar": - # geo2radar - radius = 100e3 - else: - # radar2geo - step_deg = max(np.abs(lalo_step)) - step_m = step_deg * np.pi / 180.0 * EARTH_RADIUS - radius = step_m * ratio - return radius - - def interp2d_station_to_grid(self, lon, lat, data, loc_range=[18, 54, 73, 135], - det_grid=1, method='linear', projCode=4326): - # 参考链接 https://blog.csdn.net/weixin_43718675/article/details/103497930 - ''' - func : 将站点数据插值到等经纬度格点 - inputs: - lon: 站点的经度 - lat: 站点的纬度 - data: 对应经纬度站点的 气象要素值 - loc_range: [lat_min,lat_max,lon_min,lon_max]。站点数据插值到loc_range这个范围 - det_grid: 插值形成的网格空间分辨率 - method: 所选插值方法,默认 0.125 - return: - - [lon_grid,lat_grid,data_grid] - ''' - # step1: 先将 lon,lat,data转换成 n*1 的array数组 - lon = np.array(lon).reshape(-1, 1) - lat = np.array(lat).reshape(-1, 1) - data = np.array(data).reshape(-1, 1) - - # step2:确定插值区域的经纬度网格 - lat_min = loc_range[0] # y - lat_max = loc_range[1] # y - lon_min = loc_range[2] # x - lon_max = loc_range[3] # x - gt = [0, 0, 0, 0, 0, 0] - gt[0] = lon_min # x - gt[1] = det_grid - gt[3] = lat_max # y - gt[5] = -det_grid - lat_count = int((lat_max - lat_min) / det_grid + 1) # y - lon_count = int((lon_max - lon_min) / det_grid + 1) # x - # 替换为pyresample 插值方法 - proj_osr = osr.SpatialReference() - proj_osr.ImportFromEPSG(projCode) - projection = proj_osr.ExportToPROJJSON() - # (lower_left_x、lower_left_y、upper_right_x、upper_right_y) - target_def = AreaDefinition("id1", "WGS84", "proj_id", projection, - lon_count, lat_count, [lon_min, lat_min, lon_max, lat_max]) - source_def = geometry.SwathDefinition(lons=lon, lats=lat) - lalo_step = [det_grid, -det_grid] - radius = TransImgL1A.get_radius_of_influence(lalo_step, src_meta='radar2geo') - result = pr.bilinear.resample_bilinear(data, source_def, target_def, - radius=radius, neighbours=32, - nprocs=8, fill_value=np.nan, - epsilon=0) - # - return result - - def geocoding(self, ori_geo_tif, produc_arr, pixel_delta=1, method='linear'): - # 参考链接 https://blog.csdn.net/weixin_43718675/article/details/103497930 - ori_geo_tif[np.isnan(ori_geo_tif)] = -1 - lon_data = ori_geo_tif[0, :, :].reshape(-1) - lat_data = ori_geo_tif[1, :, :].reshape(-1) - idx = np.where(lat_data != -1) - lat_data = lat_data[idx] - lon_data = lon_data[idx] - idx = np.where(lon_data != -1) - - lat_data = lat_data[idx] - lon_data = lon_data[idx] - # ########################################### - result = self.interp2d_station_to_grid(lon_data, lat_data, produc_arr, - [self._min_lat, self._max_lat, self._min_lon, self._max_lon], - det_grid=pixel_delta, method=method) - return result - - def l1a_2_geo(self, ori_geo_path, l1a_produc_path, geo_produc_path, method='linear'): - ori_geo_tif = ImageHandle.ImageHandler.get_data(ori_geo_path) - # l1a_produc = ImageHandle.ImageHandler.get_data(l1a_produc_path) - l1a_produc = ImageHandle.ImageHandler.get_band_array(l1a_produc_path, 1) - pixel_delta_y = (self._max_lat - self._min_lat) / (self._end_r - self._begin_r) # 0.001 - pixel_delta_x = (self._max_lon - self._min_lon) / (self._end_c - self._begin_c) - - lon_data = ori_geo_tif[0, :, :].reshape(-1) - lat_data = ori_geo_tif[1, :, :].reshape(-1) - l1a_produc = l1a_produc.reshape(-1) - idx = np.logical_not(np.isnan(lon_data)) - lat_data = lat_data[idx] - lon_data = lon_data[idx] - l1a_produc = l1a_produc[idx] - idx = np.logical_not(np.isnan(lat_data)) - lat_data = lat_data[idx] - lon_data = lon_data[idx] - l1a_produc = l1a_produc[idx] - - gt = [self._min_lon, pixel_delta_x, 0.0, - self._max_lat, 0.0, -pixel_delta_y] - [lat_min, lat_max, lon_min, lon_max] = [self._min_lat, self._max_lat, self._min_lon, self._max_lon] - lat_count = int((lat_max - lat_min) / pixel_delta_y + 1) # y - lon_count = int((lon_max - lon_min) / pixel_delta_x + 1) # x - - # 获取地理坐标系统信息,用于选取需要的地理坐标系统 - srs = osr.SpatialReference() - srs.ImportFromEPSG(4326) # 定义输出的坐标系为"WGS 84" - proj = srs.ExportToWkt() - - projection = srs.ExportToPROJJSON() - # (lower_left_x、lower_left_y、upper_right_x、upper_right_y) - target_def = AreaDefinition("id1", "WGS84", "proj_id", projection, - lon_count, lat_count, [lon_min, lat_min, lon_max, lat_max]) - lon_data = lon_data.reshape(-1, 1) - lat_data = lat_data.reshape(-1, 1) - l1a_produc = l1a_produc.reshape(-1, 1) - source_def = geometry.SwathDefinition(lons=lon_data, lats=lat_data) - lalo_step = [pixel_delta_x, -pixel_delta_y] - radius = TransImgL1A.get_radius_of_influence(lalo_step, src_meta='radar2geo') - geo_produc = pr.bilinear.NumpyBilinearResampler(source_def, target_def, neighbours=32, - radius_of_influence=radius, epsilon=0).resample(l1a_produc) - # geo_produc = pr.bilinear.resample_bilinear(l1a_produc, source_def, target_def, - # radius=radius, neighbours=32, - # nprocs=8, fill_value=np.nan, - # epsilon=0) - - ImageHandle.ImageHandler.write_img(geo_produc_path, proj, gt, geo_produc, np.nan) - - def l1a_2_geo_int(self, ori_geo_path, l1a_produc_path, geo_produc_path, method='nearest'): - ori_geo_tif = ImageHandle.ImageHandler.get_data(ori_geo_path) - # l1a_produc = ImageHandle.ImageHandler.get_data(l1a_produc_path) - l1a_produc = ImageHandle.ImageHandler.get_band_array(l1a_produc_path, 1) - pixel_delta_y = (self._max_lat - self._min_lat) / (self._end_r - self._begin_r) # 0.001 - pixel_delta_x = (self._max_lon - self._min_lon) / (self._end_c - self._begin_c) - - lon_data = ori_geo_tif[0, :, :].reshape(-1) - lat_data = ori_geo_tif[1, :, :].reshape(-1) - l1a_produc = l1a_produc.reshape(-1) - idx = np.logical_not(np.isnan(lon_data)) - lat_data = lat_data[idx] - lon_data = lon_data[idx] - l1a_produc = l1a_produc[idx] - idx = np.logical_not(np.isnan(lat_data)) - lat_data = lat_data[idx] - lon_data = lon_data[idx] - l1a_produc = l1a_produc[idx] - - gt = [self._min_lon, pixel_delta_x, 0.0, - self._max_lat, 0.0, -pixel_delta_y] - [lat_min, lat_max, lon_min, lon_max] = [self._min_lat, self._max_lat, self._min_lon, self._max_lon] - lat_count = int((lat_max - lat_min) / pixel_delta_y + 1) # y - lon_count = int((lon_max - lon_min) / pixel_delta_x + 1) # x - - # 获取地理坐标系统信息,用于选取需要的地理坐标系统 - srs = osr.SpatialReference() - srs.ImportFromEPSG(4326) # 定义输出的坐标系为"WGS 84" - proj = srs.ExportToWkt() - - projection = srs.ExportToPROJJSON() - # (lower_left_x、lower_left_y、upper_right_x、upper_right_y) - target_def = AreaDefinition("id1", "WGS84", "proj_id", projection, - lon_count, lat_count, [lon_min, lat_min, lon_max, lat_max]) - lon_data = lon_data.reshape(-1, 1) - lat_data = lat_data.reshape(-1, 1) - l1a_produc = l1a_produc.reshape(-1, 1) - source_def = geometry.SwathDefinition(lons=lon_data, lats=lat_data) - lalo_step = [pixel_delta_x, -pixel_delta_y] - radius = TransImgL1A.get_radius_of_influence(lalo_step, src_meta='radar2geo') - if method == 'linear': - geo_produc = pr.bilinear.resample_bilinear(l1a_produc, source_def, target_def, - radius=radius, neighbours=32, - nprocs=8, fill_value=0, - epsilon=0) - elif method == 'nearest': - geo_produc = pr.kd_tree.resample_nearest(source_def, l1a_produc, target_def, epsilon=0, - radius_of_influence=50000, - fill_value=0, nprocs=8 - ) - geo_produc = geo_produc[:, :, 0] - ImageHandle.ImageHandler.write_img(geo_produc_path, proj, gt, geo_produc) - - @property - def mask(self): - return self._mask - - -if __name__ == '__main__': - # ori_sim_path = r"I:\坐标转换\坐标转换接口\L1A数据(l1a_img_path数据)\RPC_ori_sim.tif" - # roi_Extend = [[120.53, 31.5], [120.61, 31.5], [120.61, 31.45], [120.53, 31.45]] - # conver_path = r"I:\坐标转换\坐标转换接口\裁剪后辅助数据(geo_img_path数据)\Covering_cut.tif" - # ndvi_path = r"I:\坐标转换\坐标转换接口\裁剪后辅助数据(geo_img_path数据)\NDVI_cut.tif" - # out_path = r"I:\坐标转换\SAR2GEO\test" - # - # tr = TransImgL1A(ori_sim_path,roi_Extend) - # tr.l1a_2_geo("I:/cut.tif", "I:/salinity.tif", "I:/salinity_geo2.tif") - ori_sim = r'D:\micro\WorkSpace\SurfaceRoughness\Temporary\preprocessed\ori_sim_preprocessed.tif' - product_tif = r'D:\micro\WorkSpace\SurfaceRoughness\Temporary\SurfaceRoughnessProduct_temp.tif' - result = r'D:\micro\WorkSpace\SurfaceRoughness\Temporary\SurfaceRoughnessProduct.tif' - method = 'linear' - """ - 31.14;31.50;120.34;120.75 - """ - # roi_Extend = [[102.12, 33.879], [102.327, 33.879], [102.327, 33.66], [102.12, 31.45]] - ori_sim_data = ImageHandle.ImageHandler.get_data(ori_sim) - lon = ori_sim_data[0, :, :] - lat = ori_sim_data[1, :, :] - min_lon = np.nanmin(lon) - max_lon = np.nanmax(lon) - min_lat = np.nanmin(lat) - max_lat = np.nanmax(lat) - print(np.nanmin(lon)) - print(np.nanmax(lon)) - print(np.nanmin(lat)) - print(np.nanmax(lat)) - - # roi_Extend = [[min_lon, max_lat], [max_lon, max_lat], [min_lon, min_lat], [max_lon, min_lat]] - roi_Extend = [[116.17328, 43.727577], [116.652504, 43.727577], [116.652504, 44.119164], [116.17328, 44.119164]] - # roi_Extend = [[108.51960117899473, 38.192443138079895], [109.62308480328566, 38.192443138079895], [109.62308480328566, 37.69300142375064], [108.51960117899473, 37.69300142375064]] - - tr = TransImgL1A(ori_sim, roi_Extend) - tr.l1a_2_geo_int(ori_sim, product_tif, result, method) - - pass -""" -import numpy as np -from pyresample import kd_tree, geometry -area_def = geometry.AreaDefinition('areaD', 'Europe (3km, HRV, VTC)', 'areaD', - {'a': '6378144.0', 'b': '6356759.0', - 'lat_0': '50.00', 'lat_ts': '50.00', - 'lon_0': '8.00', 'proj': 'stere'}, - 800, 800, - [-1370912.72, -909968.64, - 1029087.28, 1490031.36]) -data = np.fromfunction(lambda y, x: y*x, (50, 10)) -lons = np.fromfunction(lambda y, x: 3 + x, (50, 10)) -lats = np.fromfunction(lambda y, x: 75 - y, (50, 10)) -swath_def = geometry.SwathDefinition(lons=lons, lats=lats) -result = kd_tree.resample_nearest(swath_def, data,area_def, radius_of_influence=50000, epsilon=0.5) -""" diff --git a/landcover-L-SAR/tool/algorithm/xml/AlgXmlHandle.py b/landcover-L-SAR/tool/algorithm/xml/AlgXmlHandle.py deleted file mode 100644 index c5da2c8..0000000 --- a/landcover-L-SAR/tool/algorithm/xml/AlgXmlHandle.py +++ /dev/null @@ -1,730 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project :microproduct -@File :AlgXmlHandle.py -@Function :算法描述文件读写和检查 -@Contact :https://www.cnblogs.com/feifeifeisir/p/10893127.html -@Author :SHJ -@Date :2021/9/6 -@Version :1.0.0 -""" -import logging -from xml.etree.ElementTree import ElementTree -from tool.algorithm.image.ImageHandle import ImageHandler -from tool.file.fileHandle import fileHandle -import os -import re -import platform -import psutil -import multiprocessing -import ctypes -logger = logging.getLogger("mylog") -import glob - -class ManageAlgXML: - """ - 检查和读取XML文件信息 - """ - def __init__(self, xml_path): - self.in_path = xml_path - self.__tree = ElementTree() - self.__root = None - self.__alg_compt = None - self.__workspace_path = None - self.__taskID = None - self.__algorithm_name = None - self.__envs = {} - self.__input_paras = {} - self.__output_paras = {} - self.__init_flag = False - - - def init_xml(self): - """ - 初始化XML文件 - :return: True:初始化成功 False: 初始化失败 - """ - try: - self.__tree.parse(self.in_path) - except FileNotFoundError as ex: - msg = ex + "xml_path = " + self.in_path - raise Exception(msg) - except BaseException: - raise Exception("cannot open algXMl") - - self.__root = self.__tree.getroot() - if self.__root is None: - raise Exception("get root failed") - - self.__alg_compt = self.__root.find("AlgCompt") - if self.__alg_compt is None: - raise Exception("get AlgCompt failed") - - self.__workspace_path = self.__check_workspace_path() - if self.__workspace_path is None: - raise Exception("check workspace_path failed") - - self.__taskID = self.__check_task_id() - if self.__taskID is None: - raise Exception("check taskID failed") - - self.__algorithm_name = self.__check_algorithm_name() - if self.__algorithm_name is None: - raise Exception("check AlgorithmName failed") - - self.__envs = self.__check_environment() - if self.__envs is None or self.__envs == {}: - raise Exception("check environment failed") - - self.__input_paras = self.__check_input_para() - if self.__input_paras is None or self.__input_paras == {}: - raise Exception("check input para failed") - - self.__output_paras = self.__check_output_para() - - self.__init_flag = True - return True - - def get_workspace_path(self): - """ - 获取工作空间路径 - :return: 工作空间路径, None-异常 - """ - if not self.__init_flag: - raise Exception("XML is not initialized") - return self.__workspace_path - - def get_task_id(self): - """ - 获取任务ID - :return: taskID, None-异常 - """ - if not self.__init_flag: - raise Exception("XML is not initialized") - return self.__taskID - - def get_algorithm_name(self): - """ - 获取算法名 - :return: - """ - if not self.__init_flag: - raise Exception("AlgorithmName is not initialized") - return self.__algorithm_name - - def get_envs(self): - """ - 获取运行环境要求 - :return:运行环境要求, None-异常 - """ - if not self.__init_flag: - raise Exception("XML is not initialized") - return self.__envs - - def get_input_paras(self): - """ - 获取输入参数 - :return:输入参数, None-异常 - """ - if not self.__init_flag: - raise Exception("XML is not initialized") - return self.__input_paras - - def get_output_paras(self): - """ - 获取输出参数 - :return:输出参数, None-异常 - """ - if not self.__init_flag: - raise Exception("XML is not initialized") - return self.__output_paras - - def __check_workspace_path(self): - """ - 检查工作空间路径 - :return: 工作空间路径, None-异常 - """ - workspace_note = self.__root.find("WorkSpace") - workspace_path = str(workspace_note.text).replace("\n", "").replace(' ', '') #去除空格和回车 - if workspace_path is None: - raise Exception("'workspace_path' is None") - if not os.path.isdir(workspace_path): - raise Exception("'workspace_path' is not save:%s",workspace_path) - - if workspace_path[-1] != '\\': - workspace_path += "'\'" - - return workspace_path - - def __check_environment(self): - """ - 检查XML文件中运行环境要求 - :return: dic-运行环境要求, None-异常 - """ - env_note = self.__alg_compt.find("Environment") - - is_cluster = int(env_note.find("IsCluster").text.replace("\n", "").replace(' ', '')) - is_legal = is_cluster in [0, 1] - if not is_legal: - raise Exception("IsCluster is not 0 or 1") - - cluster_num = int(env_note.find("ClusterNum").text) - is_legal = cluster_num in [0, 1, 2, 3, 4, 5, 6, 7] - if not is_legal: - raise Exception("cluster_num is beyond [0,1,2,3,4,5,6,7]") - - operating_system = env_note.find("OperatingSystem").text.replace("\n", "").replace(' ', '') #去除空格和回车 - # is_legal = operating_system in ["Windows10", "Windows7", "WindowsXP"] - # if not is_legal: - # raise Exception("OperatingSystem is beyond [Windows10, Windows7, WindowsXP]") - - cpu = env_note.find("CPU").text.replace("\n", "").replace(' ', '') #去除空格和回车 - is_legal = cpu in ["单核", "双核", "3核", "4核", "6核", "8核"] - if not is_legal: - raise Exception("OperatingSystem is beyond [单核, 双核, 3核, 4核, 6核, 8核]") - - memory = env_note.find("Memory").text.replace("\n", "").replace(' ', '') #去除空格和回车 - is_legal = memory in ["1GB", "2GB", "4GB", "6GB", "8GB", "10GB", "12GB", "16GB"] - # if not is_legal: - # raise Exception("OperatingSystem is beyond [1GB, 2GB, 4GB, 6GB, 8GB, 10GB, 12GB, 16GB]") - - storage = env_note.find("Storage").text.replace("\n", "").replace(' ', '') #去除空格和回车 - is_legal = int(storage[:-2]) > 0 - if not is_legal: - raise Exception("Storage < 0GB") - - network_card = env_note.find("NetworkCard").text - # is_legal = network_card in ["无需求"] - # if not is_legal: - # # 输出异常 - # return - - band_width = env_note.find("Bandwidth").text - # is_legal = band_width in ["无需求"] - # if not is_legal: - # # 输出异常 - # return - - gpu = env_note.find("GPU").text - # is_legal = GPU in ["无需求"] - # if not is_legal: - # # 输出异常 - # return - envs = {"is_Cluster": is_cluster, "cluster_num": cluster_num, "operating_system": operating_system, - "CPU": cpu, "memory": memory} - envs.update({"Storage": storage, "network_card": network_card, "band_width": band_width, "GPU": gpu}) - return envs - - def __check_input_para(self): - """ - 检查XML文件中输入参数 - :return: dic-输入参数, None-异常 - """ - input_paras_note = self.__alg_compt.find("Inputs") - paras_num = int(input_paras_note.attrib.get("ParameterNum")) - para_list = input_paras_note.findall("Parameter") - - if paras_num != len(para_list): - msg ="'ParameterNum':"+ str(paras_num) + " != number of 'Parameter':" + str(len(para_list)) - logger.warning(msg) - - input_paras = {} - for para in para_list: - para_name = para.find("ParaName").text.replace("\n", "").replace(' ', '') #去除空格和回车 - para_chs_name = para.find("ParaChsName").text.replace("\n", "").replace(' ', '') #去除空格和回车 - para_type = para.find("ParaType").text.replace("\n", "").replace(' ', '') #去除空格和回车 - data_type = para.find("DataType").text.replace("\n", "").replace(' ', '') #去除空格和回车 - para_value = para.find("ParaValue").text.replace("\n", "").replace(' ', '') #去除空格和回车 - input_para = {"ParaName": para_name, "ParaChsName": para_chs_name, "ParaType": para_type, - "DataType": data_type, "ParaValue": para_value} - #print(para_name) - if para_type == "Value": - # max_value = para.find("MaxValue").text - # min_value = para.find("MinValue").text - # option_value = para.find("OptionValue").text.replace("\n", "").replace(' ', '') #去除空格和回车 - # input_para.update({"MaxValue": max_value, "MinValue": min_value, "OptionValue": option_value}) - # input_para.update({"OptionValue": option_value}) todo - pass - if para_name is None or para_type is None or para_value is None: - msg = 'there is None among para_name:' + para_name + ',para_type:' + para_type + 'or para_value:' + para_value + '!' - raise Exception(msg) - - input_paras.update({para_name: input_para}) - return input_paras - - def __check_output_para(self): - """ - 检查XML文件中输出参数 - :return: dic-输出参数, None-异常 - """ - output_paras_note = self.__alg_compt.find("Outputs") - paras_num = int(output_paras_note.attrib.get("ParameterNum")) - para_list = output_paras_note.findall("Parameter") - - if paras_num != len(para_list): - raise Exception("'ParameterNum' != number of 'Parameter'") - output_paras = {} - return output_paras - - def write_out_para(self, para_name, para_value): - """ - 写入输出参数 - """ - output_paras_note = self.__alg_compt.find("Outputs") - para_list = output_paras_note.findall("Parameter") - flag = False - for para in para_list: - if para.find("ParaName").text == para_name: - para.find("ParaValue").text = para_value - flag = True - if flag == False: - raise Exception('Cannot find Output Parameter:'+para_name+'!') - self.__tree.write(self.in_path, encoding="utf-8", xml_declaration=True) - - def __check_task_id(self): - """ - 检查任务ID - :return: taskID, None-异常 - """ - task_id_note = self.__root.find("TaskID") - task_id = str(task_id_note.text).replace("\n", "").replace(' ', '') #去除空格和回车 - if task_id is None: - raise Exception("'TaskID' is None") - return task_id - - def __check_algorithm_name(self): - - algorithm_name_note = self.__alg_compt.find("AlgorithmName") - algorithm_name = str(algorithm_name_note.text).replace("\n", "").replace(' ', '') #去除空格和回车 - if algorithm_name is None: - raise Exception("'AlgorithmName' is None") - return algorithm_name - - -class CheckSource: - """ - 检查配置文件中资源的完整性和有效性 - """ - def __init__(self, alg_xml_handle): - self.__alg_xml_handle = alg_xml_handle - self.imageHandler = ImageHandler() - self.__ParameterDic={} - - - def check_alg_xml(self): - """ - 检查算法配置文件 - """ - if self.__alg_xml_handle.init_xml(): - logger.info('init algXML succeed') - return True - else: - raise Exception('init algXML failed') - - def check_run_env(self): - """ - :return: True-正常,False-异常 - """ - envs = self.__alg_xml_handle.get_envs() - # 检查操作系统 - local_plat = platform.platform() - local_plat_list = local_plat.split("-") - flag = envs['operating_system'] == local_plat_list[0]+local_plat_list[1] - if flag is False: - msg = 'operating_system:' + local_plat_list[0] + local_plat_list[1] + ' is not ' + envs['operating_system'] - #raise Exception(msg) - - # 检查电脑显存 - mem = psutil.virtual_memory() - mem_total = int(round(mem.total / 1024 / 1024 / 1024, 0)) - mem_free = round(mem.free / 1024 / 1024 / 1024, 0) - env_memory = envs['memory'] - env_memory = int(env_memory[:-2]) - if env_memory > mem_total: - msg = 'memory_total ' + str(mem_total) + ' less than'+str(env_memory) + 'GB' - # raise Exception(msg) - - if env_memory >= mem_free: - msg = 'mem_free ' + str(mem_free) + 'GB less than' + str(env_memory) + 'GB' - logger.warning(msg) - - # 检查CPU核数 - env_cpu = envs['CPU'] - if env_cpu == "单核": - env_cpu_core_num = 1 - elif env_cpu == "双核": - env_cpu_core_num = 2 - elif env_cpu == "三核": - env_cpu_core_num = 3 - else: - env_cpu_core_num = int(env_cpu[:-1]) - - local_cpu_core_num = int(multiprocessing.cpu_count()/2) - if env_cpu_core_num > local_cpu_core_num: - msg = 'CPU_core_num ' + str(local_cpu_core_num) + 'core less than' + str(env_cpu_core_num) + ' core' - # raise Exception(msg) - - # 检查磁盘的内存 - env_storage = envs['Storage'] - env_storage = int(env_storage[:-2]) - workspace_path = self.__alg_xml_handle.get_workspace_path() - if not os.path.isdir(workspace_path): - raise Exception('workspace_path:%s do not exist!', workspace_path) - - local_storage = self.__get_free_space_mb(workspace_path) - if env_storage > local_storage: - msg = 'workspace storage ' + str(local_storage) + 'GB less than' + envs['Storage'] +"GB" - # raise Exception(msg) - - return True - - @staticmethod - def __get_free_space_mb(folder): - """ - :param folder:检查的路径 eg:'C:\\' - :return: folder/drive free space (GB) - """ - if platform.system() == 'Windows': - free_bytes = ctypes.c_ulonglong(0) - ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(folder), None, None, ctypes.pointer(free_bytes)) - return free_bytes.value / 1024 / 1024 / 1024 - else: - st = os.statvfs(folder) - return st.f_bavail * st.f_frsize / 1024 / 1024 - - def check_input_paras(self, input_para_names): - """ - :param input_para_names :需要检查参数的名称列表[name1,name2,...] - :return: 检测是否正常 - """ - workspace_path = self.__alg_xml_handle.get_workspace_path() - input_paras = self.__alg_xml_handle.get_input_paras() - for name in input_para_names: - para = input_paras[name] - if para is None: - msg = "check para:"+name + " is failed!"+"para is None!" - raise Exception(msg) - - if para['ParaType'] == 'File': - if para['DataType'] == 'tif': - if para['ParaValue'] != 'empty' and para['ParaValue'] != 'Empty'and para['ParaValue'] != '': - para_value_list = para['ParaValue'].split(";") - for para_value in para_value_list: - para_path = para_value - if self.__check_tif(para_path) is False: - msg = "check para:"+name + " is failed!" + "Path:" + para_path - raise Exception(msg) - - if para['DataType'] == 'xml': - para_path = para['ParaValue'] - if not os.path.exists(para_path): - raise Exception('para_file:%s is inexistent!', para_path) - - if para['DataType'] == 'File': - para_path = para['ParaValue'] - if os.path.isdir(para_path) is False: - msg = "check para:" + name + " is failed!" + "FilePath:" + para_path - raise Exception(msg) - if para["DataType"]=="ymal": - para_path = para['ParaValue'] - if os.path.isfile(para_path) is False: - msg = "check para: " + name + " is failed! " + " FilePath: " + para_path - raise Exception(msg) - - elif para['ParaType'] == 'Value': - if para['DataType'] == 'float' or para['DataType'] == 'int' or para['DataType'] == 'double': - if para['ParaValue'] is None: - msg = "check para:"+name + " is failed!"+"'ParaValue' is None" - raise Exception(msg) - if self.__is_number(para['ParaValue']) is False: - raise Exception("para:"+name+" is not number!") - # if (para['MaxValue'] is not None) and (self.__is_number(para['MaxValue']) is True): - # value = para['ParaValue'] - # max = para['MaxValue'] - # if float(value) > float(max): - # msg = "para:" + name + " > max, para:" + value + "max:" + max - # raise Exception(msg) - # if (para['MinValue'] is not None) and (self.__is_number(para['MinValue']) is True): - # value = para['ParaValue'] - # min = para['MinValue'] - # if float(value) < float(min): - # msg = "para:" + name + " < min, para:" + value + "min:" + min - # raise Exception(msg) - - self.__ParameterDic[name] = para['ParaValue'] - __workspace_path = workspace_path - __input_paras = input_paras - return True, self.__ParameterDic - - def check_output_paras(self, output_para_names): - """ - :param output_para_names :需要检查参数的名称列表[name1,name2,...] - :return: Ture or False - """ - workspace_path = self.__alg_xml_handle.get_workspace_path() - output_paras = self.__alg_xml_handle.get_output_paras() - - for name in output_para_names: - para = output_paras[name] - #print(para) - if para is None: - msg = "check para:" + name + " is failed!" + "para is None!" - raise Exception(msg) - - if para['ParaType'] == 'File': - if para['DataType'] == 'tif': - para_path = workspace_path + para['ParaValue'] - para_dir = os.path.split(para_path) - flag_isdir = os.path.isdir(para_dir[0]) - flag_istif = (para_dir[1].split(".", 1)[1] == "tif") - if flag_isdir and flag_istif is False: - msg = "check para:" + name + " is failed!" + para_path + "is invalid!" - raise Exception(msg) - - if para['DataType'] == 'File': - para_path = workspace_path + para['ParaValue'] - if os.path.isdir(para_path) is False: - os.makedirs(para_path) - if os.path.isdir(para_path) is False: - msg = "check para:" + name + " is failed!" + para_path + "is invalid!" - raise Exception(msg) - return True - - @staticmethod - def __is_number(str_num): - """ - :param str_num :检查str是否为float或者double - :return: True or False - """ - if str_num[0] == '-': - str_num = str_num[1:] - pattern = re.compile(r'(.*)\.(.*)\.(.*)') - if pattern.match(str_num): - return False - return str_num.replace(".", "").isdigit() - - def __check_tif(self, filename): - """ - :filename: 文件的路径 - :return: True or False - """ - if self.imageHandler.get_dataset(filename) is None: - msg = "read tif error!,finame: " + filename - raise Exception(msg) - return True - - -class InitPara: - def __init__(self,debug = False): - self._debug = debug - - @staticmethod - def init_processing_paras(input_paras): - """ - :param names:字典列表,每个字典为一个输入产品的配置信息 - """ - processing_paras = {} - for name in input_paras: - para = input_paras[name] - if para is None: - logger.error(name + "is None!") - return False - - if para['ParaType'] == 'File': - if para['DataType'] == 'tif' or para['DataType'] == 'csv': - para_value_list = para['ParaValue'].split(";") - if len(para_value_list) == 1: - para_path = para['ParaValue'] - if para_path != 'empty' and para_path != '': - processing_paras.update({name: para_path}) - else: - for n, para_value in zip(range(len(para_value_list)), para_value_list): - processing_paras.update({name+str(n): para_value}) - elif para['DataType'] == 'tar.gz': - paths = para['ParaValue'].split(';') - for n, path in zip(range(len(paths)), paths): - processing_paras.update({'sar_path' + str(n): path}) - else: - para_path = para['ParaValue'] - processing_paras.update({name: para_path}) - - elif para['ParaType'] == 'Value': - if para['DataType'] == 'float': - value = float(para['ParaValue']) - elif para['DataType'] == 'int': - value = int(para['ParaValue']) - else: # 默认string - value = para['ParaValue'] - processing_paras.update({name: value}) - elif para['ParaType'] == 'String': - value = para['ParaValue'] - if value == 'empty': - continue - else: - processing_paras.update({name: value}) - return processing_paras - - # 获取文件夹内的文件 - - @staticmethod - def get_tif_paths(file_dir,name): - in_tif_paths = [] - if os.path.exists(file_dir + name + '\\'): - in_tif_paths = list(glob.glob(os.path.join(file_dir + name + '\\', '*.tif'))) - in_tif_paths1 = list(glob.glob(os.path.join(file_dir + name + '\\', '*.tiff'))) - if in_tif_paths1 != []: - in_tif_paths = in_tif_paths + in_tif_paths1 - else: - in_tif_paths = list(glob.glob(os.path.join(file_dir, '*.tif'))) - in_tif_paths1 = list(glob.glob(os.path.join(file_dir, '*.tiff'))) - if in_tif_paths != []: - in_tif_paths = in_tif_paths + in_tif_paths1 - return in_tif_paths - - @staticmethod - def get_tif_paths_new(file_dir, name): - in_tif_paths = [] - if os.path.exists(file_dir + name + '\\'): - in_tif_paths = list(glob.glob(os.path.join(file_dir + name + '\\', '*.tif'))) - in_tif_paths1 = list(glob.glob(os.path.join(file_dir + name + '\\', '*.tiff'))) - if in_tif_paths1 != []: - in_tif_paths = in_tif_paths + in_tif_paths1 - else: - in_tif_paths = list(glob.glob(os.path.join(file_dir, '*.tif'))) - in_tif_paths1 = list(glob.glob(os.path.join(file_dir, '*.tiff'))) - if len(in_tif_paths) == 0: - in_tif_paths = in_tif_paths + in_tif_paths1 - return in_tif_paths - - @staticmethod - def get_polarization_mode(in_tif_paths): - pol_dic = {} - pola_list = [0,0,0,0] - for in_tif_path in in_tif_paths: - # 获取极化类型 - if '_HH_' in os.path.basename(in_tif_path): - pol_dic.update({'HH': in_tif_path}) - pola_list[0] = 1 - elif '_HV_' in os.path.basename(in_tif_path): - pol_dic.update({'HV': in_tif_path}) - pola_list[1] = 1 - elif '_VH_' in os.path.basename(in_tif_path): - pol_dic.update({'VH': in_tif_path}) - pola_list[2] = 1 - elif '_VV_' in os.path.basename(in_tif_path): - pol_dic.update({'VV': in_tif_path}) - pola_list[3] = 1 - elif 'LocalIncidenceAngle' in os.path.basename(in_tif_path) or 'ncidenceAngle' in os.path.basename(in_tif_path): - pol_dic.update({'LocalIncidenceAngle': in_tif_path}) - elif 'inc_angle' in os.path.basename(in_tif_path): - pol_dic.update({'inc_angle': in_tif_path}) - elif 'inci_Angle-ortho' in os.path.basename(in_tif_path): - pol_dic.update({'inci_Angle-ortho': in_tif_path}) - elif 'LocalincidentAngle-ortho' in os.path.basename(in_tif_path): - pol_dic.update({'LocalIncidentAngle-ortho': in_tif_path}) - elif 'ori_sim' in os.path.basename(in_tif_path): - pol_dic.update({'ori_sim': in_tif_path}) - elif 'sim_ori' in os.path.basename(in_tif_path): - pol_dic.update({'sim_ori': in_tif_path}) - pol_dic.update({'pola':pola_list}) - return pol_dic - - @staticmethod - def get_meta_paths(file_dir, name): - meta_xml_paths = [] - if os.path.exists(file_dir + name + '\\'): - meta_xml_paths = list(glob.glob(os.path.join(file_dir + name, '*.meta.xml'))) - else: - meta_xml_paths = list(glob.glob(os.path.join(file_dir, '*.meta.xml'))) - if meta_xml_paths is None or meta_xml_paths == []: - raise Exception('there is not .meta.xml in path: ', file_dir + '\\') - return meta_xml_paths - - @staticmethod - def get_incidence_xml_paths(file_dir, name): - meta_xml_paths = [] - if os.path.exists(file_dir + name + '\\'): - meta_xml_paths = list(glob.glob(os.path.join(file_dir + name, '*.incidence.xml'))) - else: - meta_xml_paths = list(glob.glob(os.path.join(file_dir, '*.incidence.xml'))) - if meta_xml_paths is None or meta_xml_paths == []: - raise Exception('there is not .incidence.xml in path: ', file_dir + '\\') - return meta_xml_paths - - - @staticmethod - def get_meta_dic(meta_xml_paths, name): - para_dic = {} - for mete_path in meta_xml_paths: - if name in mete_path: - para_dic.update({'META': mete_path}) - if para_dic is {}: - raise Exception('the name of .meta.xml is error!') - return para_dic - - @staticmethod - def get_incidence_dic(meta_xml_paths, name): - para_dic = {} - for mete_path in meta_xml_paths: - if name in mete_path: - para_dic.update({'Incidence': mete_path}) - if para_dic is {}: - raise Exception('the name of .incidence.xml is error!') - return para_dic - - - @staticmethod - def get_meta_dic_new(meta_xml_paths, name): - para_dic = {} - for mete_path in meta_xml_paths: - if name in os.path.basename(mete_path): - para_dic.update({'META': mete_path}) - else: - para_dic.update({'Origin_META': mete_path}) - if para_dic is {}: - raise Exception('the name of .meta.xml is error!') - return para_dic - - @staticmethod - def get_meta_dic_VP(meta_xml_paths, name): - para_dic = {} - for mete_path in meta_xml_paths: - if name in os.path.basename(mete_path): - para_dic.update({name + '_META': mete_path}) - else: - para_dic.update({name + '_Origin_META': mete_path}) - if para_dic is {}: - raise Exception('the name of .meta.xml is error!') - return para_dic - - def get_mult_tar_gz_inf(self,tar_gz_path, workspace_preprocessing_path): - para_dic = {} - name = os.path.split(tar_gz_path)[1].rstrip('.tar.gz') - para_dic.update({'name': name}) - - file_dir = os.path.join(workspace_preprocessing_path, name + '\\') - if self._debug == False: - fileHandle().de_targz(tar_gz_path, file_dir) - # 元文件字典 - para_dic.update(InitPara.get_meta_dic_VP(InitPara.get_meta_paths(file_dir, name), name)) - # tif路径字典 - pol_dic = InitPara.get_polarization_mode(InitPara.get_tif_paths(file_dir, name)) - parameter_path = os.path.join(file_dir, "orth_para.txt") - para_dic.update({name + "paraMeter": parameter_path}) - for key, in_tif_path in pol_dic.items(): - para_dic.update({name + '_' + key: in_tif_path}) - return para_dic - - - def get_mult_tar_gz_infs(self,processing_paras, workspace_preprocessing_path): - tif_names_list = [] - tar_inf_dic = {} - for key, value in processing_paras.items(): - if 'sar_path' in key: - para_dic = self.get_mult_tar_gz_inf(value, workspace_preprocessing_path) - tif_names_list.append(para_dic['name']) - para_dic.pop('name') - tar_inf_dic.update(para_dic) - tar_inf_dic.update({'name_list': tif_names_list}) - - return tar_inf_dic \ No newline at end of file diff --git a/landcover-L-SAR/tool/algorithm/xml/AnalysisXml.py b/landcover-L-SAR/tool/algorithm/xml/AnalysisXml.py deleted file mode 100644 index 8bbc228..0000000 --- a/landcover-L-SAR/tool/algorithm/xml/AnalysisXml.py +++ /dev/null @@ -1,135 +0,0 @@ -from xml.etree.ElementTree import ElementTree -import os - - -class DictXml: - def __init__(self, xml_path): - self.xml_path = xml_path - self.__tree = ElementTree() - self.__root = None - self.init_xml() - - def init_xml(self): - self.__root = self.__tree.parse(self.xml_path) - if self.__root is None: - raise Exception("get root failed") - - def get_extend(self): - productInfo = self.__root.find("imageinfo") - if productInfo is None: - raise Exception("get imageInfo failed") - - corner = productInfo.find("corner") - if corner is None: - raise Exception("get corner failed") - - topLeft = corner.find("topLeft") - if topLeft is None: - raise Exception("get topLeft failed") - - topRight = corner.find("topRight") - if topRight is None: - raise Exception("get topRight failed") - - bottomLeft = corner.find("bottomLeft") - if bottomLeft is None: - raise Exception("get bottomLeft failed") - - bottomRight = corner.find("bottomRight") - if bottomRight is None: - raise Exception("get bottomRight failed") - - point_upleft = [float(topLeft.find("longitude").text), float(topLeft.find("latitude").text)] - point_upright = [float(topRight.find("longitude").text), float(topRight.find("latitude").text)] - point_downleft = [float(bottomLeft.find("longitude").text), float(bottomLeft.find("latitude").text)] - point_downright = [float(bottomRight.find("longitude").text), float(bottomRight.find("latitude").text)] - scopes = [point_upleft, point_upright, point_downleft, point_downright] - - point_upleft_buf = [float(topLeft.find("longitude").text) - 0.5, float(topLeft.find("latitude").text) + 0.5] - point_upright_buf = [float(topRight.find("longitude").text) + 0.5, float(topRight.find("latitude").text) + 0.5] - point_downleft_buf = [float(bottomLeft.find("longitude").text) - 0.5, - float(bottomLeft.find("latitude").text) - 0.5] - point_downright_buf = [float(bottomRight.find("longitude").text) + 0.5, - float(bottomRight.find("latitude").text) - 0.5] - scopes_buf = [point_upleft_buf, point_upright_buf, point_downleft_buf, point_downright_buf] - return scopes - - -class xml_extend: - def __init__(self, xml_path): - self.xml_path = xml_path - self.__tree = ElementTree() - self.__root = None - self.init_xml() - - def init_xml(self): - self.__root = self.__tree.parse(self.xml_path) - if self.__root is None: - raise Exception("get root failed") - - def get_extend(self): - ProductBasicInfo = self.__root.find("ProductBasicInfo") - if ProductBasicInfo is None: - raise Exception("get ProductBasicInfo failed") - - SpatialCoverageInformation = ProductBasicInfo.find("SpatialCoverageInformation") - if SpatialCoverageInformation is None: - raise Exception("get SpatialCoverageInformation failed") - - TopLeftLongitude = SpatialCoverageInformation.find("TopLeftLongitude") - if TopLeftLongitude is None: - raise Exception("get TopLeftLongitude failed") - - TopLeftLatitude = SpatialCoverageInformation.find("TopLeftLatitude") - if TopLeftLatitude is None: - raise Exception("get TopLeftLatitude failed") - - TopRightLongitude = SpatialCoverageInformation.find("TopRightLongitude") - if TopRightLongitude is None: - raise Exception("get TopRightLongitude failed") - - TopRightLatitude = SpatialCoverageInformation.find("TopRightLatitude") - if TopRightLatitude is None: - raise Exception("get TopRightLatitude failed") - - BottomRightLongitude = SpatialCoverageInformation.find("BottomRightLongitude") - if BottomRightLongitude is None: - raise Exception("get BottomRightLongitude failed") - - BottomRightLatitude = SpatialCoverageInformation.find("BottomRightLatitude") - if BottomRightLatitude is None: - raise Exception("get BottomRightLatitude failed") - - BottomLeftLongitude = SpatialCoverageInformation.find("BottomLeftLongitude") - if BottomLeftLongitude is None: - raise Exception("get BottomLeftLongitude failed") - - BottomLeftLatitude = SpatialCoverageInformation.find("BottomLeftLatitude") - if BottomLeftLatitude is None: - raise Exception("get BottomLeftLatitude failed") - - point_upleft = [float(TopLeftLongitude.text), float(TopLeftLatitude.text)] - point_upright = [float(TopRightLongitude.text), float(TopRightLatitude.text)] - point_downleft = [float(BottomLeftLongitude.text), float(BottomLeftLatitude.text)] - point_downright = [float(BottomRightLongitude.text), float(BottomRightLatitude.text)] - scopes = [point_upleft, point_upright, point_downleft, point_downright] - - point_upleft_buf = [float(TopLeftLongitude.text) - 0.5, float(TopLeftLatitude.text) + 0.5] - point_upright_buf = [float(TopRightLongitude.text) + 0.5, float(TopRightLatitude.text) + 0.5] - point_downleft_buf = [float(BottomLeftLongitude.text) - 0.5, float(BottomLeftLatitude.text) - 0.5] - point_downright_buf = [float(BottomRightLongitude.text) + 0.5, float(BottomRightLatitude.text) - 0.5] - scopes_buf = [point_upleft_buf, point_upright_buf, point_downleft_buf, point_downright_buf] - return scopes - - -if __name__ == '__main__': - xml_path = r'E:\MicroWorkspace\GF3A_nanjing\GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422\GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422.meta.xml' - scopes, scopes_buf = DictXml(xml_path).get_extend() - print(scopes) - print(scopes_buf) -# path = r'D:\BaiduNetdiskDownload\GZ\lon.rdr' -# path2 = r'D:\BaiduNetdiskDownload\GZ\lat.rdr' -# path3 = r'D:\BaiduNetdiskDownload\GZ\lon_lat.tif' -# s = ImageHandler().band_merge(path, path2, path3) -# print(s) -# pass diff --git a/landcover-L-SAR/tool/algorithm/xml/CreatMetafile.py b/landcover-L-SAR/tool/algorithm/xml/CreatMetafile.py deleted file mode 100644 index 7fd728e..0000000 --- a/landcover-L-SAR/tool/algorithm/xml/CreatMetafile.py +++ /dev/null @@ -1,319 +0,0 @@ -""" -@Project :microproduct -@File :OnePlantHeight.PY -@Function :主函数 - -@Author :LMM -@Date :2021/10/19 14:39 -@Version :1.0.0 -""" -from xml.dom import minidom -from xml.etree.ElementTree import ElementTree, Element -import xml.dom.minidom -from lxml import etree -import codecs -import xml.etree.cElementTree as ET - - -class CreateMetafile: - """ - 生成元文件案例 - """ - def __init__(self, input_image_path, input_para_file, an_li_path, path): - """ - input_image_path: 影像头文件 - input_para_file: 配置文件 - an_li_path:案例路径 - path:保存路径 - """ - self.input_image_path = input_image_path - self.input_para_file = input_para_file - self.an_li_path= an_li_path - self.path = path - pass - - def create_xml(self): - """ - 读取元文件(只保留从头文件到sensor节点的部分) - 输出sensor的节点位置 - """ - tree = ElementTree() - tree.parse(self.input_image_path) # 影像头文件 - root = tree.getroot() - # 1、只保留从头文件到sensor节点的部分 - element_trees = list(root) - count = 0 - count_01=1 - for element in element_trees: - count = count+1 - if element.tag == "sensor": - element.tail = "\n\n\t" - count_01 = count-1 - for i in range(0, len(element_trees)): - if i > count_01: - root.remove(element_trees[i]) - # 2、只保留"satellite", "orbitType", "attiType", "Direction", "ReceiveTime", "sensor"的部分 - element_trees2 = list(root) - for i in element_trees2: - if i.tag not in ["satellite", "orbitType", "attiType", "Direction", "ReceiveTime", "sensor"]: - root.remove(i) - # 3、获取"sensor"节点的位置,并输出 - count2 = 0 - count2_01=1 - element_trees3 = list(root) - for element in element_trees3: - count2 = count2+1 - if element.tag == "sensor": - element.tail = "\n\n\t" - count2_01 = count2-1 - tree.write(self.path, encoding="utf-8", xml_declaration=True) - return count2_01 - - @staticmethod - def create_node(tag, property_map, content): - """ - fun: 新造一个节点 - para: tag:节点标签 - para: property_map:属性及属性值map - para: content: 节点闭合标签里的文本内容 - para: return 新节点 - """ - element = Element(tag, property_map) - element.text = content - element.tail = "\n\t" - return element - - def add_standard_xml(self, num): - """ - 模板直接写入到元文件中 - """ - tree = ElementTree() - tree.parse(self.path) # 影像头文件 - root = tree.getroot() - - tree2 = ElementTree() - tree2.parse(self.an_li_path) # 影像头文件 - root2 = tree2.getroot() - - productinfo = root2.find("productinfo") - root.insert(num + 1, productinfo) - processinfo = root2.find("processinfo") - root.insert(num + 2, processinfo) - tree.write(self.path, encoding="utf-8", xml_declaration=True) - - def add_img_xml(self, num,SrcImageName): - """添加影像信息""" - tree = ElementTree() - tree.parse(self.path) - root = tree.getroot() - - a = self.create_node("SrcImageName", {"desc": "原始影像名称"}, SrcImageName) - root.insert(num+1, a) - # root.append(a) - b = self.create_node("AlgCompt", {"desc": "算法信息"}, "\n\t\t") - b.tail = "\n\n\t" - # root.append(b) - root.insert(num+2, b) - tree.write(self.path, encoding="utf-8", xml_declaration=True) - - def add_info_xml(self): - """ - 向元文件中添加配置文件的部分节("AlgorithmName", "ChsName", "AlgorithmDesc", "Version", - "AlgorithmClass", "AlgorithmLevel", "AlgoirthmID", "Author") - """ - tree = ElementTree() - tree.parse(self.input_para_file) # 配置文件 - root = tree.getroot() - - tree2 = ElementTree() - tree2.parse(self.path) - root2 = tree2.getroot() - AlgCompt = root2.find("AlgCompt") - - a = root.find("AlgCompt") - - element_trees = list(a) - for element in element_trees: - if element.tag in ["AlgorithmName", "ChsName", "AlgorithmDesc", "Version", - "AlgorithmClass", "AlgorithmLevel", "AlgoirthmID", "Author"]: - element.tail = "\n\t\t" - AlgCompt.append(element) - if element.tag == "Author": - element.tail = "\n\t" - - tree2.write(self.path, encoding="utf-8", xml_declaration=True) - - def add_class_info(self, type_id_name, type_id_parent=None): - """ - 向元文件中: - 1.删除productinfo-productType信息; - 2.加入地物类别信息; - 输出: - - 1 - 101 - 耕地 - - - 5 - 502 - 草地 - - """ - tree = ElementTree() - tree.parse(self.path) # 配置文件 - root = tree.getroot() - productinfo = root.find("productinfo") - # element_trees = list(productinfo) - # for element in element_trees: - # if element.tag == "productType": - # productinfo.remove(element) # 移除 "productType" - productinfo.find("productConsumeTime").tail = "\n\t\t" # 定位到productConsumeTime,设置好位置 - b = self.create_node("LandCoverClass", {}, "\n\t\t\t") - b.tail = "\n\t\t" - productinfo_count=0 - for i in list(productinfo): - productinfo_count=productinfo_count+1 - if i.tag=="productConsumeTime": - break - productinfo.insert(productinfo_count, b) - - # productinfo.insert(num, b) # 插入LandCoverClass - class_num = 1 - for key, value in type_id_name.items(): - - LandCoverClass = productinfo.find("LandCoverClass") - name="Class"+str(class_num) - # name = "Class" - c = self.create_node(name, {}, "\n\t\t\t\t") - if class_num!=(len(type_id_name.keys())): - c.tail = "\n\t\t\t" - else: - c.tail = "\n\t\t" - LandCoverClass.append(c) # 插入LandCoverClass - - # LandCoverClass.find("Class")[num].tail = "\n\t\t\t" - aaa=LandCoverClass.find(name) - - if type_id_parent is not None: - parent_id = self.create_node("parent_id", {}, type_id_parent[key]) - parent_id.tail="\n\t\t\t\t" - LandCoverClass.find(name).append(parent_id) - id = self.create_node("id", {}, str(key)) - id.tail = "\n\t\t\t\t" - LandCoverClass.find(name).append(id) - covernm = self.create_node("covernm", {}, value) - covernm.tail = "\n\t\t\t" - LandCoverClass.find(name).append(covernm) - class_num=class_num+1 - tree.write(self.path, encoding="utf-8", xml_declaration=True) - - def rewrite_name(self): - """ - 修改class的名字: - class1->class - class2->class - """ - tree = ElementTree() - tree.parse(self.path) # 配置文件 - root = tree.getroot() - productinfo = root.find("productinfo") - LandCoverClass=productinfo.find("LandCoverClass") - element_trees = list(LandCoverClass) - for element in element_trees: - element.tag="Class" - tree.write(self.path, encoding="utf-8", xml_declaration=True) - - def OrthoInsertNode(self): - """正射算法专用,插入节点""" - tree = ElementTree() - tree.parse(self.path) # 影像头文件 - root = tree.getroot() - - # 插入节点 - count2 = 0 - count2_01=1 - element_trees3 = list(root) - for element in element_trees3: - count2 = count2+1 - if element.tag == "sensor": - element.tail = "\n\n\t" - count2_01 = count2-1 - b = self.create_node("l1aInfo", {}, "\n\t\t") - b.tail = "\n\n\t" - root.insert(count2_01+1, b) - - # 查询节点位置 - node_l1aInfo=root.find("l1aInfo") - - img_tree = ElementTree() - img_tree.parse(self.input_image_path) # 影像头文件 - img_root = img_tree.getroot() - - node_imageinfo = img_root.find("imageinfo") - node_processinfo=img_root.find("processinfo") - - ele_node_imageinfo = list(node_imageinfo) - ele_node_processinfo= list(node_processinfo) - - for i in ele_node_imageinfo: - if i.tag == "QualifyValue": - i.tail = "\n\t\t" - node_l1aInfo.append(i) - - for j in ele_node_processinfo: - if j.tag == "CalibrationConst": - j.tail = "\n\t" #后一个节点的位置 - node_l1aInfo.append(j) - tree.write(self.path, encoding="utf-8", xml_declaration=True) - - def process(self,SrcImageName): - """ - 不涉及到地表覆盖调用此函数 - """ - if self.input_image_path is None: - import xml.etree.cElementTree as ET - product = ET.Element("product") # 根节点tag= "product" - product.text = "\n\t" - tree = ET.ElementTree(product) - tree.write(self.path) - count = 0 - count_2 = -1 - else: - count = self.create_xml() - count_2 = count - self.add_standard_xml(count) - self.add_img_xml(count_2, SrcImageName) - self.add_info_xml() - - def process2(self, type_id_name, type_id_parent,SrcImageName): - """ - 涉及到地表覆盖的调用此函数 - type_id_name={"101":"耕地","502":"草地"} - type_id_parent={"101":"1","502":"5"} - """ - count = self.create_xml() - self.add_standard_xml(count) - self.add_img_xml(count,SrcImageName) - self.add_info_xml() - self.add_class_info(type_id_name, type_id_parent) - self.rewrite_name() - - def process3(self,SrcImageName): - """ - 正射调用此函数 - """ - if self.input_image_path is None: - import xml.etree.cElementTree as ET - product = ET.Element("product") # 根节点tag= "product" - product.text = "\n\t" - tree = ET.ElementTree(product) - tree.write(self.path) - count = 0 - else: - count = self.create_xml() - self.add_standard_xml(count) - self.add_img_xml(count, SrcImageName) - self.add_info_xml() - self.OrthoInsertNode() - diff --git a/landcover-L-SAR/tool/algorithm/xml/CreateMetaDict.py b/landcover-L-SAR/tool/algorithm/xml/CreateMetaDict.py deleted file mode 100644 index b37b4ac..0000000 --- a/landcover-L-SAR/tool/algorithm/xml/CreateMetaDict.py +++ /dev/null @@ -1,258 +0,0 @@ -import json -from xml.etree.ElementTree import ElementTree, Element -import shutil - -import xmltodict - -from tool.algorithm.image.ImageHandle import ImageHandler -from tool.algorithm.algtools.PreProcess import PreProcess as pp -from osgeo import gdal -import numpy as np -import datetime -import os -import glob -os.environ['PROJ_LIB'] = r"E:\soft\Anaconda\envs\micro\Lib\site-packages\osgeo\data\proj" - -class CreateMetaDict: - def __init__(self, image_path, origin_xml, pack_path, out_path1, out_path2): - self.ImageHandler = ImageHandler() - self.image_path = image_path - self.origin_xml = origin_xml - self.pack_path = pack_path - self.file_size = self.get_file_size() - self.out_path1 = out_path1 - self.out_path2 = out_path2 - self.timeDict = self.get_productTime() - pass - - def convertToDateTime(self, string): - dt = datetime.datetime.strptime(string, "%Y-%m-%dT%H:%M:%S.%f") - return dt - - def dateStrToStamp(self, dateStr): - st = datetime.datetime.strptime(dateStr, "%Y-%m-%dT%H:%M:%S.%f").timestamp() - return st - - def StampToDateTime(self, dateTime): - dt = datetime.datetime.fromtimestamp(dateTime) - return dt - - def calu_nature(self): - """ - 将productinfo节点需要填写的信息存入字典中 - image_path:影像路径 - image_pair:输入的压缩包中的极化对 例:hh,hv,vh,vv=【1,1,1,1】 - out_path1:地理转平面的输出路径 - out_path2:平面转地理的输出路径 - """ - - para_dict = {} - - proj = self.ImageHandler.get_projection(self.image_path) # 输出的影像若是投影坐标系则先转成地理坐标系 - keyword = proj.split("[", 2)[0] # 若是地理坐标系则pass - if keyword == "GEOGCS": - pass - elif keyword == "PROJCS": - pp.trans_projcs2geogcs(self.out_path2, self.image_path) - image_path = self.out_path2 - elif len(keyword) == 0 or keyword.strip() == "" or keyword.isspace() is True: - raise Exception('image projection is missing!') - - pp.trans_geogcs2projcs(self.out_path1, self.image_path) # 坐标投影, 地理转平面投影坐标 - imageinfo_widthspace = self.ImageHandler.get_geotransform(self.out_path1)[1] # 投影后的分辨率 - # imageinfo_heightspace = -self.ImageHandler.get_geotransform(out_path1)[5] # 投影后的分辨率 - # para_dict.update({"imageinfo_widthspace": imageinfo_widthspace}) - # para_dict.update({"imageinfo_heightspace": imageinfo_heightspace}) - - para_dict.update({"imageinfo_ProductResolution": imageinfo_widthspace}) - - para_dict.update({"imageinfo_ProductFormat": "GEOTIFF"}) - para_dict.update({"imageinfo_CompressionMethod": "None"}) - para_dict.update({"imageinfo_ProductSize": str(self.file_size) + "MB"}) #todo 产品总大小 - - get_scope = self.ImageHandler.get_scope(self.image_path) - point_upleft, point_upright, point_downleft, point_downright = get_scope[0], get_scope[1], get_scope[2], get_scope[3] - para_dict.update({"SpatialCoverageInformation_TopLeftLatitude": point_upleft[1]}) - para_dict.update({"SpatialCoverageInformation_TopLeftLongitude": point_upleft[0]}) - para_dict.update({"SpatialCoverageInformation_TopRightLatitude": point_upright[1]}) - para_dict.update({"SpatialCoverageInformation_TopRightLongitude": point_upright[0]}) - para_dict.update({"SpatialCoverageInformation_BottomLeftLatitude": point_downleft[1]}) - para_dict.update({"SpatialCoverageInformation_BottomLeftLongitude": point_downleft[0]}) - para_dict.update({"SpatialCoverageInformation_BottomRightLatitude": point_downright[1]}) - para_dict.update({"SpatialCoverageInformation_BottomRightLongitude": point_downright[0]}) - longitude_max = np.array([point_upleft[0], point_upright[0], point_downleft[0], point_downright[0]]).max() - longitude_min = np.array([point_upleft[0], point_upright[0], point_downleft[0], point_downright[0]]).min() - latitude_max = np.array([point_upleft[1], point_upright[1], point_downleft[1], point_downright[1]]).max() - latitude_min = np.array([point_upleft[1], point_upright[1], point_downleft[1], point_downright[1]]).min() - imageinfo_center_latitude = (latitude_max + latitude_min) / 2 - imageinfo_center_longitude = (longitude_max + longitude_min) / 2 - para_dict.update({"SpatialCoverageInformation_CenterLatitude": imageinfo_center_latitude}) - para_dict.update({"SpatialCoverageInformation_CenterLongitude": imageinfo_center_longitude}) - - para_dict.update({"TimeCoverageInformation_StartTime": self.timeDict.get("startTime")}) - para_dict.update({"TimeCoverageInformation_CenterTime": self.timeDict.get("centerTime")}) - para_dict.update({"TimeCoverageInformation_EndTime": self.timeDict.get("endTime")}) - - para_dict.update({"CoordinateReferenceSystemInformation_EarthEllipsoid": "WGS84"}) - para_dict.update({"CoordinateReferenceSystemInformation_MapProjection": "UTM"}) - para_dict.update({"CoordinateReferenceSystemInformation_ZoneNo": "None"}) - - para_dict.update({"MetaInfo_Unit": "none"}) # 设置单位 - para_dict.update({"MetaInfo_UnitDes": "无量纲"}) # 设置单位 - - # 补充ProductProductionInfo节信息 - data_name = os.path.basename(self.image_path) - strs = data_name.split("_") - para_dict.update({"DataSources_DataSource_Satellite": strs[0]}) - para_dict.update({"DataSources_DataSource_Sensor": strs[0]}) - - para_dict.update({"ObservationGeometry_SatelliteAzimuth": "None"}) - para_dict.update({"ObservationGeometry_SatelliteRange": "None"}) - - para_dict.update({"ProductProductionInfo_BandSelection": "1"}) - para_dict.update({"ProductProductionInfo_DataSourceDescription": "None"}) - para_dict.update({"ProductProductionInfo_DataSourceProcessingDescription": "参考产品介绍PDF"}) - productGentime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") - para_dict.update({"ProductProductionInfo_ProductionDate": productGentime}) - para_dict.update({"ProductProductionInfo_AuxiliaryDataDescription": ""}) - - # para_dict.update({"ProductPublishInfo_Processor": "德清院"}) # 生产者 - # para_dict.update({"ProductPublishInfo_DistributionUnit": "none"}) # 分发单位 - # para_dict.update({"ProductPublishInfo_ContactInformation": "none"}) # 联系信息 - return para_dict - - def get_productTime(self): - time_dict = {} - tree = ElementTree() - tree.parse(self.origin_xml) - root = tree.getroot() - startTime = " " - endTime = " " - centerTime = " " - - imagingTime = root.find("productInfo").find('sceneInfo') - for n in imagingTime: - if n.tag == 'start': - startTime = self.convertToDateTime(n.find('timeUTC').text) - if n.tag == 'stop': - endTime = self.convertToDateTime(n.find('timeUTC').text) - ct = (endTime.timestamp() + startTime.timestamp()) / 2 - time_dict.update({"startTime": startTime}) - time_dict.update({"centerTime": self.StampToDateTime(ct)}) - time_dict.update({"endTime": endTime}) - return time_dict - - def get_file_size(self): - in_tif_paths = list(glob.glob(os.path.join(self.pack_path, '*.tif'))) - in_tif_paths1 = list(glob.glob(os.path.join(self.pack_path, '*.tiff'))) - in_tif_paths += in_tif_paths1 - size = 0 - for file in in_tif_paths: - fsize = os.path.getsize(file) # 返回的是字节大小 - size += fsize - return round(size / float(1024*1024), 2) - - -class CreateProductXml: - def __init__(self, par_dict, model_path, xml_path): - self.par_dict = par_dict - self.xml_path = xml_path - shutil.copy(model_path, xml_path) - pass - - def create_standard_xml(self): - """将字典中的信息写入到copy的xml文件中""" - tree = ElementTree() - tree.parse(self.xml_path) # 影像头文件 - root = tree.getroot() - - productinfo = root.find("ProductBasicInfo") - for key, value in self.par_dict.items(): - if key.split("_")[0] == "imageinfo": - productinfo.find(key.split("_")[1]).text = str(value) - elif key.split("_")[0] == "SpatialCoverageInformation": - imageinfo = productinfo.find("SpatialCoverageInformation") - imageinfo.find(key.split("_")[1]).text = str(value) - elif key.split("_")[0] == "TimeCoverageInformation": - timeInfo = productinfo.find("TimeCoverageInformation") - timeInfo.find(key.split("_")[1]).text = str(value) - elif key.split("_")[0] == "CoordinateReferenceSystemInformation": - geoInfo = productinfo.find("CoordinateReferenceSystemInformation") - geoInfo.find(key.split("_")[1]).text = str(value) - elif key.split("_")[0] == "MetaInfo": - metaInfo = productinfo.find("MetaInfo") - metaInfo.find(key.split("_")[1]).text = str(value) - ProductProductionInfo = root.find("ProductProductionInfo") # 原始数据信息 - for key, value in self.par_dict.items(): - if key.split("_")[0] == "DataSources": - dataSources = ProductProductionInfo.find("DataSources") - dataSource = dataSources.find("DataSource") - dataSource.find(key.split("_")[2]).text = str(value) - elif key.split("_")[0] == "ObservationGeometry": - ObservationGeometry = ProductProductionInfo.find("ObservationGeometry") - ObservationGeometry.find(key.split("_")[1]).text = str(value) - elif key.split("_")[0] == "ProductProductionInfo": - ProductProductionInfo.find(key.split("_")[1]).text = str(value) - - # ProductPublishInfo = root.find("ProductPublishInfo") # 发布者信息 - # for key, value in self.par_dict.items(): - # if key.split("_")[0] == "ProductPublishInfo": - # ProductPublishInfo.find(key.split("_")[1]).text = str(value) - - tree.write(self.xml_path, encoding="utf-8", xml_declaration=True) - - -class OrthoAzimuth: - - @staticmethod - def FindInfomationFromJson(HeaderFile_dom_json, node_path_list): - """ - 在Json文件中,按照指定路径解析出制定节点 - """ - result_node = HeaderFile_dom_json - for nodename in node_path_list: - result_node = result_node[nodename] - return result_node - - @staticmethod - def get_Azimuth_incidence(Azimuth_path): - Azimuth_incidence = 0 - if not os.path.exists(Azimuth_path): - return Azimuth_incidence - with open(Azimuth_path) as f: - Azimuth_incidence = f.readline() - return Azimuth_incidence - - @staticmethod - def read_Azimuth_incidence(xml_path): - # tree = ElementTree() - # tree.parse(xml_path) - # root = tree.getroot() - # Azimuth_incidence = float(root.find('ProductProductionInfo').find('ObservationGeometry').find('SatelliteAzimuth').text) - # return Azimuth_incidence - with open(xml_path, 'r', encoding='utf-8') as fp: - HeaderFile_dom_str = fp.read() - HeaderFile_dom = xmltodict.parse(HeaderFile_dom_str) # 将XML转成json文本 - HeaderFile_dom_json = json.loads(json.dumps(HeaderFile_dom)) - node_path_list = ['Root', 'ProductProductionInfo', 'ObservationGeometry', 'SatelliteAzimuth'] - Azimuth_incidence = OrthoAzimuth.FindInfomationFromJson(HeaderFile_dom_json, node_path_list) - return Azimuth_incidence - -if __name__ == '__main__': - xml_path = r'D:\micro\LWork\SurfaceRoughness\Temporary\preprocessing\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-ortho\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-ortho.meta.xml' - a = OrthoAzimuth.read_Azimuth_incidence(xml_path) - print(a) - pass - # image_path = r'D:\Micro\WorkSpace\test\GF3B_MYC_QPSI_003581_E120.6_N31.3_20220729_L1B_h_h_L10000073024_db_RD_geo.tif' - # origin_xml = r'D:\Micro\WorkSpace\Ortho\Temporary\package\GF3B_MYC_QPSI_003581_E120.6_N31.3_20220729_L1A_AHV_L10000073024.meta.xml' - # tem_folder = r'D:\Micro\WorkSpace\test' - # pack_path = r'D:\Micro\WorkSpace\Ortho\Temporary\package' - # out_dem_path1 = os.path.join(tem_folder, "trans_dem_geo_projcs.tif") - # out_dem_path2 = os.path.join(tem_folder, "trans_dem_projcs_geo.tif") - # para_dict = CreateMetaDict(image_path, origin_xml, pack_path, out_dem_path1, out_dem_path2).calu_nature() - # - # model_path = r'D:\Project\microproduct\Ortho\product.xml' - # xml_path = r'D:\Micro\WorkSpace\test\test.xml' - # CreateProductXml(para_dict, model_path, xml_path).create_standard_xml() - - diff --git a/landcover-L-SAR/tool/config/ConfigeHandle.py b/landcover-L-SAR/tool/config/ConfigeHandle.py deleted file mode 100644 index 05c9423..0000000 --- a/landcover-L-SAR/tool/config/ConfigeHandle.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project :onestar -@File :ConfigeHandle.py -@Contact:https://blog.csdn.net/songlh1234/article/details/83316468 -@Author :SHJ -@Date :2021/11/23 16:57 -@Version :1.0.0 -""" -import os -import configparser - - -class Config: - """读写初始化配置文件""" - def __init__(self): - pass - - @staticmethod - def get(para_name, option='config', config_name='config.ini'): - config = configparser.ConfigParser() - config_path = os.path.join(os.getcwd(), config_name) - config.read(config_path, encoding='utf-8') - config.sections() - exe_name = config.get(option, para_name) - return exe_name - - def get_list(self, para_name, option='config', config_name='config.ini'): - config = configparser.ConfigParser() - config_path = os.path.join(os.getcwd(), config_name) - config.read(config_path, encoding='utf-8') - config.sections() - str_name = config.get(option, para_name) - # 去除空格和回车 - str_name = str(str_name).replace("\n", "").replace(' ', '') # 去除空格和回车 - # 分割成lists - name_list = str_name.split(',') - return name_list - - -if __name__ == '__main__': - # c = Config() - # a = c.get('exe_name') - # b = bool(c.get('debug')) - # d = int(c.get('cover_threshold')) - # f = float(c.get('ndvi_threshold')) - - print('done') \ No newline at end of file diff --git a/landcover-L-SAR/tool/csv/csvHandle.py b/landcover-L-SAR/tool/csv/csvHandle.py deleted file mode 100644 index 5ad7793..0000000 --- a/landcover-L-SAR/tool/csv/csvHandle.py +++ /dev/null @@ -1,265 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project : microproduct -@File : csvHandle.py -@Function : 读写csv文件 -@Contact : -@Author:SHJ -@Date:2022/11/6 -@Version:1.0.0 -""" -import random -import csv -import logging -import numpy as np -from tool.algorithm.image.ImageHandle import ImageHandler -from tool.algorithm.algtools.CoordinateTransformation import geo2imagexy -from tool.algorithm.transforml1a.transHandle import TransImgL1A -logger = logging.getLogger("mylog") - - -class csvHandle: - def __init__(self, row=0, col=0): - self.imageHandler = ImageHandler() - self.row = row - self.col = col - self.img_falg = False - if row != 0 and col != 0: - self.roi_img = np.zeros((row, col), dtype=float) - self.img_falg = True - - def get_roi_img(self): - if self.img_falg: - self.roi_img[self.roi_img == 0] = np.nan - return self.roi_img - else: - return np.array([]) - - @staticmethod - def readcsv(csv_path): - reader = csv.reader(open(csv_path, newline='')) - csv_list = [] - for line_data in reader: - csv_list.append(line_data) - return csv_list[1:] - - def trans_measuredata(self, meas_data, tif_path): - file_name = tif_path - dataset = self.imageHandler.get_dataset(file_name) - rows = self.imageHandler.get_img_height(file_name) - cols = self.imageHandler.get_img_width(file_name) - measdata_list = [] - logger.info('[MEASURE DATA]') - for data in meas_data: - lon = float(data[1]) - lat = float(data[2]) - coord = geo2imagexy(dataset, lon, lat) - row = round(coord[1]) - col = round(coord[0]) - - if row >= 0 and row <= rows and col >= 0 and col <= cols: - measdata_list.append([row, col, float(data[3])]) - logger.info([row, col, float(data[3])]) - else: - logger.warning("measure data: %s is beyond tif scope !", data) - pass - return measdata_list - - def write_roi_img_data(self, points, type_id): - if self.img_falg: - for p in points: - r = p[0] - c = p[1] - if r < self.row and c < self.col: - self.roi_img[r, c] = type_id - - - def trans_landCover_measuredata(self, meas_data, cuted_ori_sim_path, max_train_num =100000): - """ - 获取多边形区域内所有的点,分为训练集数据和测试集数据 - :para meas_data: csv读取的实测数据 - """ - type_data = {} - n = 1 - train_data_list = [] - for data in meas_data: - for d in data: - if d == '': - raise Exception('there are empty data!', data) - - type_id = int(data[1]) - type_name = data[2] - if type_id not in type_data.keys(): - train_data_list.append([n, type_id, type_name, []]) - type_data.update({type_id: type_name}) - n += 1 - - pointList = self.__roiPolygonAnalysis(data[3]) - for points in pointList: - roi_poly = [(float(lon), float(lat)) for (lon, lat) in points] - tr = TransImgL1A(cuted_ori_sim_path, roi_poly) - if tr._mask is not None: - points = tr.get_roi_points() - for train_data in train_data_list: - if train_data[1] == type_id: - train_data[3] += points - self.write_roi_img_data(points, type_id) - if train_data[3] == [] : - raise Exception('there are empty data!', train_data) - if len(train_data_list) <= 1: - raise Exception('there is only one label type!', train_data_list) - - for train_data in train_data_list: - logger.info(str(train_data[0]) + "," + str(train_data[2]) + "," + "num:" + str(len(train_data[3]))) - max_num = max_train_num - if (len(train_data[3]) > max_num): - logger.info("max number =" + str(max_num) + ", random select" + str(max_num) + " point as train data!") - train_data[3] = random.sample(train_data[3], max_num) - - return train_data_list - - def trans_landCover_measuredata_dic(self, meas_data, cuted_ori_sim_path,max_train_num=100000): - train_data_list = self.trans_landCover_measuredata(meas_data, cuted_ori_sim_path,max_train_num) - return self.trans_landCover_list2dic(train_data_list) - - @staticmethod - def trans_landCover_list2dic(train_data_list): - ids = [] - class_ids = [] - ch_names = [] - positions = [] - for data in train_data_list: - ids.append(data[0]) - class_ids.append(data[1]) - ch_names.append(data[2]) - positions.append(data[3]) - - train_data_dic = {} - train_data_dic.update({"ids": ids}) - train_data_dic.update({"class_ids": class_ids}) - train_data_dic.update({"ch_names": ch_names}) - train_data_dic.update({"positions": positions}) - return train_data_dic - - @staticmethod - def __roiPolygonAnalysis(roiStr): - """ - 将csv的POLY数据转为数组 - :para roiStr: poly数据 - :return pointList: 保存多边形的list - """ - pointList = [] - strContent = roiStr.replace("POLYGON", "") - # 解析轮廓字符串为二维数组 - bracketsList = [] - strTemp = '' - strList = [] - for c in strContent: - if c == '(': - bracketsList.append(c) - continue - elif c == ')': - if len(bracketsList) > 0: - bracketsList.pop(0) - if len(strTemp) > 0: - strList.append(strTemp) - strTemp = '' - else: - strTemp += c - for item in strList: - if len(item) == 0: - continue - pTempList = item.split(',') - pList = [] - for row in pTempList: - cells = row.split(' ') - if len(cells) != 2: - continue - point = [float(cells[0]), float(cells[1])] - pList.append(point) - pointList.append(pList) - return pointList - - def class_landcover_list(self, csv_path): - """ - 输出csv表中的前三列 - """ - reader = csv.reader(open(csv_path, newline='')) - class_list=[] - type_id_name = {} - type_id_parent = {} - for line_data in reader: - class_list.append(line_data) # class_list含有四列 - for data in class_list[1:]: - type_parent= data[0] - type_id = int(data[1]) - type_name = data[2] - - if type_id not in type_id_name.keys(): - type_id_name.update({type_id: type_name}) - type_id_parent.update({type_id: type_parent}) - return type_id_name, type_id_parent - - def trans_VegePhenology_measdata_dic(self, meas_data, cuted_ori_sim_path): - """ - 获取多边形区域内所有的点,分为训练集数据和测试集数据 - :para meas_data: csv读取的实测数据 - """ - train_data = [] - test_data = [] - type_data = {} - - for data in meas_data: - data_use_type = data[0] - sar_img_name = data[1] - name = sar_img_name.rstrip('.tar.gz') - - if data_use_type == 'train': - phenology_id = int(data[2]) - phenology_name = data[3] - if phenology_id not in type_data.keys(): - type_data.update({phenology_id: phenology_name}) - else: - phenology_id = -1 - - pointList = self.__roiPolygonAnalysis(data[4]) - l1a_points = [] - for points in pointList: - roi_poly = [(float(lon), float(lat)) for (lon, lat) in points] - tr = TransImgL1A(cuted_ori_sim_path, roi_poly) - l1a_points = tr.get_roi_points() - # l1a_points = tr.get_lonlat_points() - if data_use_type == 'train': - train_data.append([name, phenology_id, l1a_points, type_data[phenology_id]]) - elif data_use_type == 'test': - test_data.append([name, phenology_id, l1a_points]) - type_map = [] - for n, id in zip(range(len(type_data)), type_data): - type_map.append([n + 1, id, type_data[id]]) - - return train_data, test_data, type_map - - @staticmethod - def vegePhenology_class_list(csv_path): - """ - 输出csv表中的前三列 - """ - reader = csv.reader(open(csv_path, newline='')) - class_list=[] - type_id_name = {} - for line_data in reader: - class_list.append(line_data) # class_list含有四列 - for data in class_list[1:]: - type_id = data[2] - type_name = data[3] - - if type_id not in type_id_name.keys(): - if type_id.strip() != "": - type_id_name.update({type_id: type_name}) - return type_id_name - -# if __name__ == '__main__': - # csvh = csvHandle() - # csv_path = r"I:\preprocessed\VegetationPhenologyMeasureData_E118.9_N31.4.csv" - # data = csvh.trans_VegePhenology_measdata_dic(csvh.readcsv(csv_path),r"I:\preprocessed\GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422_RPC_ori_sim_preprocessed.tif") - # pass \ No newline at end of file diff --git a/landcover-L-SAR/tool/file/fileHandle.py b/landcover-L-SAR/tool/file/fileHandle.py deleted file mode 100644 index 28ce04e..0000000 --- a/landcover-L-SAR/tool/file/fileHandle.py +++ /dev/null @@ -1,88 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project : microproduct -@File : fileHandle.py -@Function : 文件创建、删除、解压、打包 -@Contact : -@Author:SHJ -@Date:2022/11/6 -@Version:1.0.0 -""" -import os -import tarfile -import shutil - -class fileHandle: - def __init__(self, debug_mode=False): - self.__debug_mode = debug_mode - - def creat_dirs(self, path_list): - """ - 创建文件夹 - """ - for path in path_list: - if os.path.exists(path): - if self.__debug_mode is True: - continue - self.del_folder(path) - os.makedirs(path) - else: - os.makedirs(path) - - def del_folder(self, dic): - """ - 删除整个文件夹 - """ - if self.__debug_mode is True: - return - if os.path.isdir(dic): - shutil.rmtree(dic) - - def del_file(self, path_data): - """ - 只删除文件,不删除文件夹 - """ - for i in os.listdir(path_data): # os.listdir(path_data)#返回一个列表,里面是当前目录下面的所有东西的相对路径 - file_data = path_data + '\\' + i # 当前文件夹的下面的所有东西的绝对路径 - if os.path.isfile(file_data) is True: # os.path.isfile判断是否为文件,如果是文件,就删除.如果是文件夹.递归给del_file. - os.remove(file_data) - else: - self.del_file(file_data) - - @staticmethod - def make_targz(output_filename, source_dir): - """ - 一次性打包整个根目录。空子目录会被打包。 - 如果只打包不压缩,将"w:gz"参数改为"w:"或"w"即可。 - :param output_filename:输出压缩包的完整路径,eg:'E:\test.tar.gz' - :param source_dir:需要打包的跟目录,eg: 'E:\testFfile\'打包文件夹里面的所有文件,'E:\testFfile'打包文件夹 - """ - dir = os.path.split(output_filename)[0] - if os.path.exists(dir) is False: - os.makedirs(dir) - with tarfile.open(output_filename, "w:gz") as tar: - tar.add(source_dir, arcname=os.path.basename(source_dir)) - - @staticmethod - def de_targz(tar_gz_path, file_dir): - name = os.path.split(tar_gz_path)[1].rstrip('.tar.gz') - if os.path.exists(file_dir) is False: - os.makedirs(file_dir) - # 解压 - t = tarfile.open(tar_gz_path) - t.extractall(path=file_dir) - - @staticmethod - def copyfile2dir(srcfile, dir): # 复制函数 - if not os.path.isfile(srcfile): - print("%s not exist!" % (srcfile)) - else: - fpath, fname = os.path.split(srcfile) # 分离文件名和路径 - if not os.path.exists(dir): - os.makedirs(dir) # 创建路径 - shutil.copy(srcfile, dir + fname) # 复制文件 - -# if __name__ == '__main__': -# file = fileHandle() -# file.del_floder("I:\preprocessed") -# pass \ No newline at end of file diff --git a/landcover-L-SAR/tool/logs/logHandler.py b/landcover-L-SAR/tool/logs/logHandler.py deleted file mode 100644 index b4cbad1..0000000 --- a/landcover-L-SAR/tool/logs/logHandler.py +++ /dev/null @@ -1,90 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -@Project :microproduct -@File :logHandler.py -@Author :SHJ -@Date :2021/9/6 -@Version :1.0.0 -""" -import logging -import os -# from logging import handlers -import time -import datetime - - -class LogHandler: - """ - 生成日志 - """ - __logger = logging.getLogger("mylog") - __format_str = logging.Formatter("[%(asctime)s] [%(process)d] [%(levelname)s] - %(module)s.%(funcName)s " - "(%(filename)s:%(lineno)d) - %(message)s") - __log_path = None - - @staticmethod - def init_log_handler(log_name): - """ - 初始化日志 - :param log_name: 日志保存的路径和名称 - :return: - """ - path = os.getcwd() - current_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(time.time())) - LogHandler.__log_path = os.path.join(path, log_name + current_time + ".log") - para_dir = os.path.split(LogHandler.__log_path) - if not os.path.exists(para_dir[0]): - os.makedirs(para_dir[0]) - # 删除七天以前的文件 - LogHandler.delete_outdate_files(para_dir[0], 7) - - # 方法1:普通日志 - LOG_FORMAT = "[%(asctime)s] [%(process)d] [%(levelname)s]- %(message)s ---from: %(module)s.%(funcName)s" \ - " (%(filename)s:Line%(lineno)d) " - DATE_FORMAT = "%m/%d/%Y %H:%M:%S" - fp = logging.FileHandler(LogHandler.__log_path, encoding='utf-8') - fs = logging.StreamHandler() - logging.basicConfig(level=logging.INFO, format=LOG_FORMAT, datefmt=DATE_FORMAT, handlers=[fp, fs]) # 调用 - - # 方法2:回滚日志 - # LogHandler.__logger.setLevel(logging.DEBUG) - # th = handlers.TimedRotatingFileHandler(filename=LogHandler.__log_path, when='S', interval=1, - # backupCount=2, encoding='utf-8') - # th.suffix = "%Y-%m-%d-%H-%M-%S.log" - # th.setFormatter(LogHandler.__format_str) - # th.setLevel(level=logging.DEBUG) - - # console = logging.StreamHandler() - # console.setLevel(logging.INFO) - # LogHandler.__logger.addHandler(console) - # LogHandler.__logger.addHandler(th) - - @staticmethod - def delete_outdate_files(path, date_interval=7): - """ - 删除目录下七天前创建的文件 - """ - current_time = time.strftime("%Y-%m-%d", time.localtime(time.time())) - current_timeList = current_time.split("-") - current_time_day = datetime.datetime(int(current_timeList[0]), int(current_timeList[1]), - int(current_timeList[2])) - for root, dirs, files in os.walk(path): - for item in files: - item_format = item.split(".", 2) - if item_format[1] == "log": - file_path = os.path.join(root, item) - create_time = time.strftime("%Y-%m-%d", time.localtime((os.stat(file_path)).st_mtime)) - create_time_list = create_time.split("-") - create_time_day = datetime.datetime(int(create_time_list[0]), int(create_time_list[1]), - int(create_time_list[2])) - time_difference = (current_time_day - create_time_day).days - if time_difference > date_interval: - os.remove(file_path) - -# -# if __name__ == "__main__": -# # eg2: -# log_handler = LogHandler() -# log_handler.init_log_handler(r"run_log\myrun1") -# logging.warning("1") -# print("done") diff --git a/landcover-L-SAR/tool/newimage.csv b/landcover-L-SAR/tool/newimage.csv deleted file mode 100644 index 6394f2b..0000000 --- a/landcover-L-SAR/tool/newimage.csv +++ /dev/null @@ -1,47 +0,0 @@ -sar_img_name,phenology_id,phenology_name,roi_polygon -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,10,water,"POLYGON((118.91799748 31.46893509,118.91762055 31.46674878,118.9210883 31.46637183,118.9210883 31.46855814,118.91799748 31.46893509))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,10,water,"POLYGON((118.90864966 31.46388396,118.90861196 31.46384627,118.90857427 31.46380857,118.90608654 31.46188613,118.90608654 31.46181074,118.90940351 31.46015216,118.91155201 31.46199921,118.90864966 31.46388396))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,10,water,"POLYGON((118.91898928 31.45778718,118.91893038 31.45478336,118.91893038 31.45472446,118.91898928 31.45472446,118.9246432 31.45472446,118.9247021 31.45472446,118.92499657 31.45872956,118.91898928 31.45778718))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,20,build,"POLYGON((118.89543794 31.46174102,118.89452125 31.4583153,118.8948831 31.45807405,118.89599277 31.46171689,118.89543794 31.46174102))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,20,build,"POLYGON((118.8940629 31.45653006,118.89280848 31.45312847,118.8932427 31.45308022,118.89326683 31.45308022,118.89442475 31.45636119,118.8940629 31.45653006))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,20,build,"POLYGON((118.89132626 31.44844806,118.89046628 31.4453566,118.89079168 31.44540309,118.89081492 31.44542633,118.89083817 31.44544958,118.89086141 31.44547282,118.89172139 31.44840157,118.89132626 31.44844806))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,20,build,"POLYGON((118.89028034 31.4441944,118.89016413 31.44256732,118.89044304 31.44256732,118.89046628 31.44259056,118.89048953 31.4426138,118.89051277 31.44266029,118.8907452 31.44472901,118.89028034 31.4441944))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,20,build,"POLYGON((118.89000143 31.44193973,118.88997819 31.44193973,118.88997819 31.44189324,118.88923442 31.43399026,118.8894436 31.43403675,118.89018737 31.44191648,118.89000143 31.44193973))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,20,build,"POLYGON((118.88897526 31.42114936,118.8888637 31.4205915,118.8888637 31.4205729,118.89468368 31.41977331,118.89470227 31.41977331,118.89472087 31.41977331,118.89499978 31.42042414,118.88897526 31.42114936))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,20,build,"POLYGON((118.88025459 31.42230226,118.88010583 31.42153986,118.88594441 31.42088902,118.885963 31.42088902,118.8866138 31.42155845,118.88025459 31.42230226))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,20,build,"POLYGON((118.87595933 31.42280433,118.87577339 31.42222788,118.87977114 31.42178159,118.87999427 31.42228367,118.87595933 31.42280433))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,20,build,"POLYGON((118.89870564 31.41809418,118.89826403 31.41748983,118.89826403 31.41746659,118.89828727 31.41744335,118.90193638 31.41511894,118.90261042 31.41551409,118.89870564 31.41809418))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,20,build,"POLYGON((118.86530883 31.42443948,118.86630754 31.42325911,118.87384328 31.42257814,118.87388867 31.42257814,118.87397946 31.42253274,118.87411565 31.42253274,118.87493278 31.42307752,118.87488738 31.42312292,118.87479659 31.42312292,118.86530883 31.42443948))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,30,road,"POLYGON((118.91830432 31.38444815,118.91828107 31.3844249,118.91828107 31.38440166,118.9183508 31.38433193,118.91958267 31.3826816,118.91960591 31.3826816,118.9223718 31.38421571,118.9223718 31.38423895,118.9223718 31.38426219,118.92146533 31.38628443,118.91830432 31.38444815))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,30,road,"POLYGON((118.93304021 31.37921823,118.93396992 31.37812576,118.93399316 31.37812576,118.93401641 31.37812576,118.93536449 31.37919499,118.93464396 31.38033395,118.93304021 31.37921823))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,30,road,"POLYGON((118.93629419 31.37882309,118.93627095 31.37882309,118.93627095 31.37879984,118.93701472 31.37756791,118.93752606 31.37780035,118.93752606 31.37782359,118.93666608 31.37905553,118.93629419 31.37882309))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,30,road,"POLYGON((118.93680553 31.38465734,118.9372239 31.38396002,118.93817686 31.38454112,118.9382001 31.38454112,118.93822334 31.38456437,118.93810713 31.38533142,118.93808389 31.38535467,118.93680553 31.38465734))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,30,road,"POLYGON((118.94384808 31.38312765,118.94420137 31.38271856,118.94421997 31.38271856,118.94423856 31.38271856,118.94505671 31.38325782,118.94453607 31.38387146,118.94384808 31.38312765))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,30,road,"POLYGON((118.94066848 31.37855322,118.94096598 31.37806975,118.94096598 31.37805115,118.94096598 31.37803256,118.94096598 31.37801396,118.94096598 31.37799537,118.94223039 31.37881356,118.94163538 31.37946439,118.94161678 31.37946439,118.94066848 31.37855322))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,30,road,"POLYGON((118.93942267 31.3813797,118.9396272 31.38108218,118.9396458 31.38108218,118.94048254 31.38154706,118.94022222 31.38204913,118.93942267 31.3813797))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,30,road,"POLYGON((118.94446169 31.38115656,118.94479639 31.38069168,118.94576329 31.38136111,118.94546578 31.38193756,118.94446169 31.38115656))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,30,road,"POLYGON((118.94968666 31.38693968,118.94968666 31.38690249,118.9498912 31.38660496,118.94990979 31.38660496,118.95063496 31.38701406,118.95033746 31.38740456,118.94968666 31.38693968))" -GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422-ortho,30,road,"POLYGON((118.95310799 31.37931563,118.95310799 31.37929703,118.9537216 31.37885075,118.95374019 31.37883215,118.95379598 31.37879496,118.95463271 31.37931563,118.95418645 31.3798363,118.95310799 31.37931563))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,10,water,"POLYGON((118.91799748 31.46893509,118.91762055 31.46674878,118.9210883 31.46637183,118.9210883 31.46855814,118.91799748 31.46893509))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,10,water,"POLYGON((118.90864966 31.46388396,118.90861196 31.46384627,118.90857427 31.46380857,118.90608654 31.46188613,118.90608654 31.46181074,118.90940351 31.46015216,118.91155201 31.46199921,118.90864966 31.46388396))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,10,water,"POLYGON((118.91898928 31.45778718,118.91893038 31.45478336,118.91893038 31.45472446,118.91898928 31.45472446,118.9246432 31.45472446,118.9247021 31.45472446,118.92499657 31.45872956,118.91898928 31.45778718))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,20,build,"POLYGON((118.89543794 31.46174102,118.89452125 31.4583153,118.8948831 31.45807405,118.89599277 31.46171689,118.89543794 31.46174102))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,20,build,"POLYGON((118.8940629 31.45653006,118.89280848 31.45312847,118.8932427 31.45308022,118.89326683 31.45308022,118.89442475 31.45636119,118.8940629 31.45653006))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,20,build,"POLYGON((118.89132626 31.44844806,118.89046628 31.4453566,118.89079168 31.44540309,118.89081492 31.44542633,118.89083817 31.44544958,118.89086141 31.44547282,118.89172139 31.44840157,118.89132626 31.44844806))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,20,build,"POLYGON((118.89028034 31.4441944,118.89016413 31.44256732,118.89044304 31.44256732,118.89046628 31.44259056,118.89048953 31.4426138,118.89051277 31.44266029,118.8907452 31.44472901,118.89028034 31.4441944))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,20,build,"POLYGON((118.89000143 31.44193973,118.88997819 31.44193973,118.88997819 31.44189324,118.88923442 31.43399026,118.8894436 31.43403675,118.89018737 31.44191648,118.89000143 31.44193973))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,20,build,"POLYGON((118.88897526 31.42114936,118.8888637 31.4205915,118.8888637 31.4205729,118.89468368 31.41977331,118.89470227 31.41977331,118.89472087 31.41977331,118.89499978 31.42042414,118.88897526 31.42114936))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,20,build,"POLYGON((118.88025459 31.42230226,118.88010583 31.42153986,118.88594441 31.42088902,118.885963 31.42088902,118.8866138 31.42155845,118.88025459 31.42230226))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,20,build,"POLYGON((118.87595933 31.42280433,118.87577339 31.42222788,118.87977114 31.42178159,118.87999427 31.42228367,118.87595933 31.42280433))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,20,build,"POLYGON((118.89870564 31.41809418,118.89826403 31.41748983,118.89826403 31.41746659,118.89828727 31.41744335,118.90193638 31.41511894,118.90261042 31.41551409,118.89870564 31.41809418))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,20,build,"POLYGON((118.86530883 31.42443948,118.86630754 31.42325911,118.87384328 31.42257814,118.87388867 31.42257814,118.87397946 31.42253274,118.87411565 31.42253274,118.87493278 31.42307752,118.87488738 31.42312292,118.87479659 31.42312292,118.86530883 31.42443948))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,30,road,"POLYGON((118.91830432 31.38444815,118.91828107 31.3844249,118.91828107 31.38440166,118.9183508 31.38433193,118.91958267 31.3826816,118.91960591 31.3826816,118.9223718 31.38421571,118.9223718 31.38423895,118.9223718 31.38426219,118.92146533 31.38628443,118.91830432 31.38444815))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,30,road,"POLYGON((118.93304021 31.37921823,118.93396992 31.37812576,118.93399316 31.37812576,118.93401641 31.37812576,118.93536449 31.37919499,118.93464396 31.38033395,118.93304021 31.37921823))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,30,road,"POLYGON((118.93629419 31.37882309,118.93627095 31.37882309,118.93627095 31.37879984,118.93701472 31.37756791,118.93752606 31.37780035,118.93752606 31.37782359,118.93666608 31.37905553,118.93629419 31.37882309))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,30,road,"POLYGON((118.93680553 31.38465734,118.9372239 31.38396002,118.93817686 31.38454112,118.9382001 31.38454112,118.93822334 31.38456437,118.93810713 31.38533142,118.93808389 31.38535467,118.93680553 31.38465734))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,30,road,"POLYGON((118.94384808 31.38312765,118.94420137 31.38271856,118.94421997 31.38271856,118.94423856 31.38271856,118.94505671 31.38325782,118.94453607 31.38387146,118.94384808 31.38312765))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,30,road,"POLYGON((118.94066848 31.37855322,118.94096598 31.37806975,118.94096598 31.37805115,118.94096598 31.37803256,118.94096598 31.37801396,118.94096598 31.37799537,118.94223039 31.37881356,118.94163538 31.37946439,118.94161678 31.37946439,118.94066848 31.37855322))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,30,road,"POLYGON((118.93942267 31.3813797,118.9396272 31.38108218,118.9396458 31.38108218,118.94048254 31.38154706,118.94022222 31.38204913,118.93942267 31.3813797))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,30,road,"POLYGON((118.94446169 31.38115656,118.94479639 31.38069168,118.94576329 31.38136111,118.94546578 31.38193756,118.94446169 31.38115656))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,30,road,"POLYGON((118.94968666 31.38693968,118.94968666 31.38690249,118.9498912 31.38660496,118.94990979 31.38660496,118.95063496 31.38701406,118.95033746 31.38740456,118.94968666 31.38693968))" -GF3_SAY_QPSI_013952_E118.9_N31.5_20190404_L1A_AHV_L10003923848-ortho,30,road,"POLYGON((118.95310799 31.37931563,118.95310799 31.37929703,118.9537216 31.37885075,118.95374019 31.37883215,118.95379598 31.37879496,118.95463271 31.37931563,118.95418645 31.3798363,118.95310799 31.37931563))" diff --git a/landcover-L-SAR/tool/testxmlreading.py b/landcover-L-SAR/tool/testxmlreading.py deleted file mode 100644 index c7147ff..0000000 --- a/landcover-L-SAR/tool/testxmlreading.py +++ /dev/null @@ -1,99 +0,0 @@ -#encoding=utf-8 -import os -import xml.etree.ElementTree as ET -import pandas as pd -import csv - -def xml2csv(xmlpath): - tree_obj = ET.parse(xmlpath) - - # 得到所有匹配Region 标签的Element对象的list集合 - list_Region = tree_obj.findall("Region") - for Region in list_Region: - # 几何面对应的类(phenology_name)在标签 - Region_dict = Region.attrib - phenology_name = Region_dict.get("name") - print(phenology_name) - list_GeometryDef = Region.findall("GeometryDef") - list_Polygon = list_GeometryDef[0].findall("Polygon") # 获得该类下的几何面list - for polygon in list_Polygon: - # 从polygon list中获取得到标签的数据 注意是空格分隔的和csv中不同 - Coordinates_list = coordinates = polygon.find('.//Coordinates').text.strip().split() - # POLYGON((119.035 31.51,119.035 31.50,119.033 31.50)) csv中 - print("value") - -# 向csv中写 -def csvfile(csvpath,data): - - with open(csvpath, 'a', newline='') as file: - # 2. step - writer = csv.writer(file) - # data example - #data = ["This", "is", "a", "Test"] - writer.writerow(data) - - -# Define the structure of the data -#data示例 student_header = ['name', 'age', 'major', 'minor'] -def csvcreateTitile(csvpath,data): - # 1. Open a new CSV file - with open(csvpath, 'w') as file: - # 2. Create a CSV writer - writer = csv.writer(file) - # 3. Write data to the file - writer.writerow(data) - -# 将列表中的坐标对转换为字符串 -def createcsv_roi_polygon(coordinates): - coord_str = ','.join([f'{coordinates[i]} {coordinates[i + 1]}' for i in range(0, len(coordinates), 2)]) - # 构建最终的POLYGON字符串 - polygon_str = f'POLYGON(({coord_str}))' - print(polygon_str) - return polygon_str - -def get_Azimuth_incidence(Azimuth_path): - Azimuth_incidence = 0 - if not os.path.exists(Azimuth_path): - print('get Azimuth_incidence failed!') - return Azimuth_incidence - with open(Azimuth_path) as f: - Azimuth_incidence = f.readline() - return Azimuth_incidence - -# if __name__ == '__main__': -# path = r"D:\micro\WorkSpace\Ortho1\Temporary\test.txt" -# value = get_Azimuth_incidence(path) -# print(value) -if __name__ == '__main__': - xmlpath = r"E:\MicroWorkspace\GF3-Deformation\GF3-yuan\micro-check\GF3_KSC_QPSI_036065_E116.4_N44.2_20230616_L1A_AHV_L10006792277.xml" - - tree_obj = ET.parse(xmlpath) - # csv_header = ['sar_img_name', 'phenology_id', 'phenology_name', 'roi_polygon'] - csv_header = ['parent_id', 'id', 'covernm', 'roi_polygon'] - csvpath = r"E:\MicroWorkspace\GF3-Deformation\GF3-yuan\micro-check\GF3_KSC_QPSI_036065_E116.4_N44.2_20230616_L1A_AHV_L10006792277.csv" - # csvcreateTitile(csvpath,csv_header) - csvfile(csvpath,csv_header) - # 得到所有匹配Region 标签的Element对象的list集合 - list_Region = tree_obj.findall("Region") - name_list = {} - count = 10 - for Region in list_Region: - # 几何面对应的类(phenology_name)在标签 - Region_dict = Region.attrib - phenology_name = Region_dict.get("name") - - if not phenology_name in name_list.keys(): - name_list.update({phenology_name: count}) - count += 10 - print(phenology_name) - # list_GeometryDef = Region.findall("GeometryDef") - list_Polygon = Region.findall(".//Polygon") # 获得该类下的几何面list - - for polygon in list_Polygon: - # 从polygon list中获取得到标签的数据 注意是空格分隔的和csv中不同 - Coordinates_list = coordinates = polygon.find('.//Coordinates').text.strip().split() - # 将坐标和ploygon对应的写入到.csv中 - polygon_str=createcsv_roi_polygon(Coordinates_list) - # POLYGON((119.035 31.51,119.035 31.50,119.033 31.50)) csv中 - data = ['0', name_list.get(phenology_name), phenology_name, polygon_str] - csvfile(csvpath, data) diff --git a/soilMoisture-L-SAR/SoilMoisture.xml b/soilMoisture-L-SAR/SoilMoisture.xml index 6f9fcae..e307261 100644 --- a/soilMoisture-L-SAR/SoilMoisture.xml +++ b/soilMoisture-L-SAR/SoilMoisture.xml @@ -36,7 +36,7 @@ File tar.gz Man - E:\MicroWorkspace\LT1B\LT230919\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-cal.tar.gz + F:\MicroWorkspace\LT1B\LT230919\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-cal.tar.gz Covering @@ -45,7 +45,7 @@ File tif Man - E:\MicroWorkspace\LT1B\LT230919\52T_LandCover_2023.tif + F:\MicroWorkspace\LT1B\LT230919\52T_LandCover_2023.tif CoveringIDs @@ -54,7 +54,7 @@ Value string Man - 1;4;5;6;7;11;10;20;30;50;60;70;71;72;73;74;80;90;255 + empty DEFAULT DEFAULT DEFAULT @@ -66,7 +66,7 @@ File tif Man - E:\MicroWorkspace\LT1B\LT230919\S2_NDVImed_202203_04.tif + F:\MicroWorkspace\LT1B\LT230919\S2_NDVImed_202203_04.tif NDVIScope @@ -100,7 +100,7 @@ File tif Man - E:\MicroWorkspace\LT1B\LT230919\S2_NDWImed_202203_04.tif + F:\MicroWorkspace\LT1B\LT230919\S2_NDWImed_202203_04.tif e1 @@ -183,7 +183,7 @@ File tar.gz Man - D:\micro\LWork\SoilMoisture\Output\SoilMoistureProduct.tar.gz + D:\micro\LWork\SoilMoisture\Output\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-cal-SMC.tar.gz DEFAULT DEFAULT DEFAULT diff --git a/soilMoisture-L-SAR/SoilMoistureALg.py b/soilMoisture-L-SAR/SoilMoistureALg.py index 931c719..de7789a 100644 --- a/soilMoisture-L-SAR/SoilMoistureALg.py +++ b/soilMoisture-L-SAR/SoilMoistureALg.py @@ -68,7 +68,9 @@ class MoistureAlg: cos_angle = np.cos(angle_array) tmp1 = tif_array - c * vwc_array * cos_angle tmp2 = np.exp(-2 * d * vwc_array * (1/cos_angle)) - bsc_array =c * vwc_array * cos_angle + tmp1/tmp2 # --- 公式计算错误 + # --- 公式计算错误 + bsc_array =c * vwc_array * cos_angle + tmp1/tmp2 + except BaseException as msg: logger.error(msg) diff --git a/soilMoisture-L-SAR/SoilMoistureMain.py b/soilMoisture-L-SAR/SoilMoistureMain.py index c71ea20..10698e6 100644 --- a/soilMoisture-L-SAR/SoilMoistureMain.py +++ b/soilMoisture-L-SAR/SoilMoistureMain.py @@ -10,6 +10,8 @@ [修改序列] [修改日期] [修改者] [修改内容] 1 2022-6-30 石海军 1.使用cover_roi_id来选取ROI区域; 2.内部处理使用地理坐标系(4326); """ +import glob + from tool.algorithm.algtools.PreProcess import PreProcess as pp from tool.algorithm.xml.AlgXmlHandle import ManageAlgXML, CheckSource,InitPara # 导入xml文件读取与检查文件 from tool.algorithm.image.ImageHandle import ImageHandler @@ -250,7 +252,17 @@ class MoistureMain: bp = BlockProcess() # block_size = bp.get_block_size(self.__rows, self.__cols,block_size_config) block_size = bp.get_block_size(self.__rows, self.__cols) - bp.cut(self.__workspace_preprocessed_path, self.__workspace_block_tif_path, ['tif', 'tiff'], 'tif', block_size) + logger.info('block size is %s!', block_size) + + pre_cuts = list(glob.glob(os.path.join(self.__workspace_preprocessed_path, '*.tif'))) + cut_dir = os.path.join(self.__workspace_preprocessed_path, 'cut_tif') + if not os.path.exists(cut_dir): + os.makedirs(cut_dir) + for cut_tif in pre_cuts: + tif_name = os.path.basename(cut_tif) + if 'HH' in tif_name or 'VV' in tif_name or 'NDWI' in tif_name or 'LocalIncidenceAngle' in tif_name or 'mask' in tif_name: + shutil.copy(cut_tif, os.path.join(cut_dir, tif_name)) + bp.cut_new(cut_dir, self.__workspace_block_tif_path, ['tif', 'tiff'], 'tif', block_size) logger.info('blocking tifs success!') img_dir, img_name = bp.get_file_names(self.__workspace_block_tif_path, ['tif']) @@ -265,29 +277,21 @@ class MoistureMain: hh_list = dir_dict[key] elif tmp == 'VV': vv_list = dir_dict[key] - elif tmp == 'VH': - vh_list = dir_dict[key] - elif tmp == 'HV': - hv_list = dir_dict[key] elif tmp == 'NDWI': ndwi_list = dir_dict[key] elif tmp == 'mask': mask_list = dir_dict[key] - if angle_list is None or hh_list is None or vv_list is None or vh_list is None or hv_list is None or ndwi_list is None: - logger.info('angle_list is None or hh_list is None or vv_list is None or vh_list is None or hv_list is None or ndwi_list is None') + if angle_list is None or hh_list is None or vv_list is None or ndwi_list is None or mask_list is None: + logger.info( + 'angle_list is None or hh_list is None or vv_list is None or vh_list is None or hv_list is None or ndwi_list is None') return False - if not len(angle_list) == len(hh_list) == len(vv_list) == len(vh_list) == len(hv_list) == len(ndwi_list): - logger.info('[len(angle_list) == len(hh_list) == len(vv_list) == len(vh_list) == len(hv_list) == len(ndwi_list)] is False!') + if not len(angle_list) == len(hh_list) == len(vv_list) == len(ndwi_list) == len(mask_list): + logger.info( + '[len(angle_list) == len(hh_list) == len(vv_list) == len(vh_list) == len(hv_list) == len(ndwi_list)] is False!') return False processes_num = min([len(angle_list), multiprocessing_num, multiprocessing.cpu_count() - 1]) - # f = Filter() - # f.lee_filter_multiprocess(hh_list, hh_list, FILTER_SIZE, processes_num) - # f.lee_filter_multiprocess(vv_list, vv_list, FILTER_SIZE, processes_num) - # f.lee_filter_multiprocess(vh_list, vh_list, FILTER_SIZE, processes_num) - # f.lee_filter_multiprocess(hv_list, hv_list, FILTER_SIZE, processes_num) - # 开启多进程处理 pool = multiprocessing.Pool(processes=processes_num) pl = [] for i in range(len(angle_list)): @@ -299,8 +303,8 @@ class MoistureMain: # 利用VWC、入射角 计算裸土后向散射系数 hh_bare_soil_bsc_path = self.__workspace_block_tif_processed_path + 'hh_bare_soil_bsc' + suffix vv_bare_soil_bsc_path = self.__workspace_block_tif_processed_path + 'vv_bare_soil_bsc' + suffix - vh_bare_soil_bsc_path = self.__workspace_block_tif_processed_path + 'vh_bare_soil_bsc' + suffix - hv_bare_soil_bsc_path = self.__workspace_block_tif_processed_path + 'hv_bare_soil_bsc' + suffix + # vh_bare_soil_bsc_path = self.__workspace_block_tif_processed_path + 'vh_bare_soil_bsc' + suffix + # hv_bare_soil_bsc_path = self.__workspace_block_tif_processed_path + 'hv_bare_soil_bsc' + suffix flag = alg.cal_bare_soil_bsc(hh_bare_soil_bsc_path, hh_list[i], vwc_path, angle_list[i], self.__processing_paras['Chh'], self.__processing_paras['Dhh']) # 裸土后向散射系统(线性值) if flag is False: @@ -310,13 +314,13 @@ class MoistureMain: if flag is False: return False - flag = alg.cal_bare_soil_bsc(vh_bare_soil_bsc_path, vh_list[i], vwc_path, angle_list[i], self.__processing_paras['Cvv'], self.__processing_paras['Dvv']) - if flag is False: - return False - - flag = alg.cal_bare_soil_bsc(hv_bare_soil_bsc_path, hv_list[i], vwc_path, angle_list[i], self.__processing_paras['Cvv'], self.__processing_paras['Dvv']) - if flag is False: - return False + # flag = alg.cal_bare_soil_bsc(vh_bare_soil_bsc_path, vh_list[i], vwc_path, angle_list[i], self.__processing_paras['Cvv'], self.__processing_paras['Dvv']) + # if flag is False: + # return False + # + # flag = alg.cal_bare_soil_bsc(hv_bare_soil_bsc_path, hv_list[i], vwc_path, angle_list[i], self.__processing_paras['Cvv'], self.__processing_paras['Dvv']) + # if flag is False: + # return False # 利用后向散射系数,计算土壤含水量 soil_moisture_path = self.__workspace_block_tif_processed_path + 'soil_moisture' + suffix @@ -340,7 +344,7 @@ class MoistureMain: h = ImageHandler.get_img_height(self.__preprocessed_paras['HH']) out_path = self.__workspace_processing_path[0:-1] tif_type = bp.get_tif_dtype(self.__preprocessed_paras['HH']) - bp.combine(data_dir, w, h, out_path, file_type=['tif'], datetype=tif_type) + bp.combine_new(data_dir, w, h, out_path, file_type=['tif'], datetype=tif_type) # 添加地理信息 soil_moisture_path = self.__workspace_processing_path + 'soil_moisture.tif' diff --git a/soilMoisture-L-SAR/config.ini b/soilMoisture-L-SAR/config.ini index 4967e61..07b0324 100644 --- a/soilMoisture-L-SAR/config.ini +++ b/soilMoisture-L-SAR/config.ini @@ -6,7 +6,7 @@ # 算法名称。修改临时工作区生成临时文件的名称,日志名称; exe_name = SoilMoisture # 开启调试模式则不删除临时工作区,True:开启调试,False:不开启调试 -debug = True +debug = False tar = SMC productLevel = 5 ######2-算法处理参数###### diff --git a/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-27-51.log b/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-27-51.log deleted file mode 100644 index 5280ea4..0000000 --- a/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-27-51.log +++ /dev/null @@ -1,14 +0,0 @@ -[11/22/2023 17:27:51] [17848] [INFO]- sysdir: D:\estar-proj\microproduct-L-SAR\soilMoisture-L-SAR ---from: SoilMoistureMain.check_source (SoilMoistureMain.py:Line79) -[11/22/2023 17:27:51] [17848] [INFO]- init algXML succeed ---from: AlgXmlHandle.check_alg_xml (AlgXmlHandle.py:Line319) -[11/22/2023 17:27:51] [17848] [ERROR]- run-time error! ---from: SoilMoistureMain. (SoilMoistureMain.py:Line435) -Traceback (most recent call last): - File "D:/estar-proj/microproduct-L-SAR/soilMoisture-L-SAR/SoilMoistureMain.py", line 427, in - if main_handler.check_source() is False: - File "D:/estar-proj/microproduct-L-SAR/soilMoisture-L-SAR/SoilMoistureMain.py", line 87, in check_source - if self.__check_handler.check_input_paras(input_para_names) is False: - File "D:\estar-proj\microproduct-L-SAR\soilMoisture-L-SAR\tool\algorithm\xml\AlgXmlHandle.py", line 414, in check_input_paras - if self.__check_tif(para_path) is False: - File "D:\estar-proj\microproduct-L-SAR\soilMoisture-L-SAR\tool\algorithm\xml\AlgXmlHandle.py", line 513, in __check_tif - raise Exception(msg) -Exception: read tif error!,finame: E:\MicroWorkspace\LT1B\LT230919\S2_NDWImed_202203_04.tif -[11/22/2023 17:27:51] [17848] [INFO]- running use time: 0:00:00.312218 ---from: SoilMoistureMain. (SoilMoistureMain.py:Line441) diff --git a/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-28-49.log b/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-28-49.log deleted file mode 100644 index bc5cbec..0000000 --- a/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-28-49.log +++ /dev/null @@ -1,46 +0,0 @@ -[11/22/2023 17:28:49] [31608] [INFO]- sysdir: D:\estar-proj\microproduct-L-SAR\soilMoisture-L-SAR ---from: SoilMoistureMain.check_source (SoilMoistureMain.py:Line79) -[11/22/2023 17:28:49] [31608] [INFO]- init algXML succeed ---from: AlgXmlHandle.check_alg_xml (AlgXmlHandle.py:Line319) -[11/22/2023 17:28:49] [31608] [INFO]- create new workspace success! ---from: SoilMoistureMain.__create_work_space (SoilMoistureMain.py:Line151) -[11/22/2023 17:32:33] [31608] [INFO]- check_source success! ---from: SoilMoistureMain.check_source (SoilMoistureMain.py:Line97) -[11/22/2023 17:32:33] [31608] [INFO]- progress bar: 10% ---from: SoilMoistureMain.check_source (SoilMoistureMain.py:Line98) -[11/22/2023 17:32:39] [31608] [INFO]- scope0:[[130.58788888888887, 47.876416666666664], [131.11544444444442, 47.876416666666664], [130.58788888888887, 47.427749999999996], [131.11544444444442, 47.427749999999996]] ---from: PreProcess.cal_intersect_shp (PreProcess.py:Line239) -[11/22/2023 17:32:39] [31608] [INFO]- scope1:[[130.58788888888887, 47.876416666666664], [131.11544444444442, 47.876416666666664], [130.58788888888887, 47.427749999999996], [131.11544444444442, 47.427749999999996]] ---from: PreProcess.cal_intersect_shp (PreProcess.py:Line239) -[11/22/2023 17:32:39] [31608] [INFO]- scope2:[[130.58788888888887, 47.876416666666664], [131.11544444444442, 47.876416666666664], [130.58788888888887, 47.427749999999996], [131.11544444444442, 47.427749999999996]] ---from: PreProcess.cal_intersect_shp (PreProcess.py:Line239) -[11/22/2023 17:32:39] [31608] [INFO]- scope3:[[130.58788888888887, 47.876416666666664], [131.11544444444442, 47.876416666666664], [130.58788888888887, 47.427749999999996], [131.11544444444442, 47.427749999999996]] ---from: PreProcess.cal_intersect_shp (PreProcess.py:Line239) -[11/22/2023 17:32:39] [31608] [INFO]- scope4:[[130.40576233571758, 47.936153520704124], [131.8327786879565, 47.936153520704124], [130.40576233571758, 47.10644445056424], [131.8327786879565, 47.10644445056424]] ---from: PreProcess.cal_intersect_shp (PreProcess.py:Line239) -[11/22/2023 17:32:39] [31608] [INFO]- scope5:[[130.00427774930557, 49.00453605317449], [132.01632432267647, 49.00453605317449], [130.00427774930557, 47.00425741002555], [132.01632432267647, 47.00425741002555]] ---from: PreProcess.cal_intersect_shp (PreProcess.py:Line239) -[11/22/2023 17:32:39] [31608] [INFO]- scope6:[[130.00427774930557, 49.00453605317449], [132.01632432267647, 49.00453605317449], [130.00427774930557, 47.00425741002555], [132.01632432267647, 47.00425741002555]] ---from: PreProcess.cal_intersect_shp (PreProcess.py:Line239) -[11/22/2023 17:32:39] [31608] [INFO]- scope7:[[130.58788888888887, 47.876416666666664], [131.11544444444442, 47.876416666666664], [130.58788888888887, 47.427749999999996], [131.11544444444442, 47.427749999999996]] ---from: PreProcess.cal_intersect_shp (PreProcess.py:Line239) -[11/22/2023 17:32:39] [31608] [INFO]- scope roi :[(130.58788888888887, 47.427749999999996), (130.58788888888887, 47.876416666666664), (131.11544444444442, 47.876416666666664), (131.11544444444442, 47.427749999999996)] ---from: PreProcess.cal_intersect_shp (PreProcess.py:Line245) -[11/22/2023 17:32:39] [31608] [INFO]- create intersect shp success! ---from: PreProcess.preprocessing (PreProcess.py:Line79) -[11/22/2023 17:32:55] [31608] [INFO]- cut HH success! ---from: PreProcess.cut_imgs (PreProcess.py:Line372) -[11/22/2023 17:33:10] [31608] [INFO]- cut VV success! ---from: PreProcess.cut_imgs (PreProcess.py:Line372) -[11/22/2023 17:33:25] [31608] [INFO]- cut VH success! ---from: PreProcess.cut_imgs (PreProcess.py:Line372) -[11/22/2023 17:33:41] [31608] [INFO]- cut HV success! ---from: PreProcess.cut_imgs (PreProcess.py:Line372) -[11/22/2023 17:33:41] [31608] [INFO]- cut Covering success! ---from: PreProcess.cut_imgs (PreProcess.py:Line372) -[11/22/2023 17:33:45] [31608] [INFO]- cut NDVI success! ---from: PreProcess.cut_imgs (PreProcess.py:Line372) -[11/22/2023 17:33:48] [31608] [INFO]- cut NDWI success! ---from: PreProcess.cut_imgs (PreProcess.py:Line372) -[11/22/2023 17:34:04] [31608] [INFO]- cut LocalIncidenceAngle success! ---from: PreProcess.cut_imgs (PreProcess.py:Line372) -[11/22/2023 17:34:04] [31608] [INFO]- cut images success! ---from: PreProcess.preprocessing (PreProcess.py:Line84) -[11/22/2023 17:34:04] [31608] [INFO]- resampling HH success! ---from: PreProcess.resampling_img (PreProcess.py:Line415) -[11/22/2023 17:34:04] [31608] [INFO]- resampling VV success! ---from: PreProcess.resampling_img (PreProcess.py:Line415) -[11/22/2023 17:34:05] [31608] [INFO]- resampling VH success! ---from: PreProcess.resampling_img (PreProcess.py:Line415) -[11/22/2023 17:34:05] [31608] [INFO]- resampling HV success! ---from: PreProcess.resampling_img (PreProcess.py:Line415) -[11/22/2023 17:34:06] [31608] [INFO]- resampling Covering success! ---from: PreProcess.resampling_img (PreProcess.py:Line415) -[11/22/2023 17:34:08] [31608] [INFO]- resampling NDVI success! ---from: PreProcess.resampling_img (PreProcess.py:Line415) -[11/22/2023 17:34:10] [31608] [INFO]- resampling NDWI success! ---from: PreProcess.resampling_img (PreProcess.py:Line415) -[11/22/2023 17:34:10] [31608] [INFO]- resampling LocalIncidenceAngle success! ---from: PreProcess.resampling_img (PreProcess.py:Line415) -[11/22/2023 17:34:10] [31608] [INFO]- preprocess_handle success! ---from: PreProcess.preprocessing (PreProcess.py:Line90) -[11/22/2023 17:34:10] [31608] [INFO]- progress bar: 40% ---from: SoilMoistureMain.preprocess_handle (SoilMoistureMain.py:Line164) -[11/22/2023 17:34:10] [31608] [ERROR]- run-time error! ---from: SoilMoistureMain. (SoilMoistureMain.py:Line435) -Traceback (most recent call last): - File "D:/estar-proj/microproduct-L-SAR/soilMoisture-L-SAR/SoilMoistureMain.py", line 431, in - if main_handler.process_handle(start) is False: - File "D:/estar-proj/microproduct-L-SAR/soilMoisture-L-SAR/SoilMoistureMain.py", line 227, in process_handle - radar_center_frequency = MetaDataHandler.get_RadarCenterFrequency(self.__processing_paras['Origin_META']) - File "D:\estar-proj\microproduct-L-SAR\soilMoisture-L-SAR\tool\algorithm\algtools\MetaDataHandler.py", line 105, in get_RadarCenterFrequency - RadarCenterFrequency = OrthoMetaData.get_RadarCenterFrequency(meta_file_path) - File "D:\estar-proj\microproduct-L-SAR\soilMoisture-L-SAR\tool\algorithm\algtools\MetaDataHandler.py", line 65, in get_RadarCenterFrequency - RadarCenterFrequency = float(root.find('sensor').find('RadarCenterFrequency').text) -AttributeError: 'NoneType' object has no attribute 'find' -[11/22/2023 17:34:10] [31608] [INFO]- running use time: 0:05:21.577426 ---from: SoilMoistureMain. (SoilMoistureMain.py:Line441) diff --git a/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-35-42.log b/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-35-42.log deleted file mode 100644 index ab271df..0000000 --- a/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-35-42.log +++ /dev/null @@ -1,255 +0,0 @@ -INFO:mylog:sysdir: D:\estar-proj\microproduct-L-SAR\soilMoisture-L-SAR -INFO:mylog:init algXML succeed -INFO:mylog:create new workspace success! -INFO:mylog:check_source success! -INFO:mylog:progress bar: 10% -INFO:root:scope0:[[130.58788888888887, 47.876416666666664], [131.11544444444442, 47.876416666666664], [130.58788888888887, 47.427749999999996], [131.11544444444442, 47.427749999999996]] -INFO:root:scope1:[[130.58788888888887, 47.876416666666664], [131.11544444444442, 47.876416666666664], [130.58788888888887, 47.427749999999996], [131.11544444444442, 47.427749999999996]] -INFO:root:scope2:[[130.58788888888887, 47.876416666666664], [131.11544444444442, 47.876416666666664], [130.58788888888887, 47.427749999999996], [131.11544444444442, 47.427749999999996]] -INFO:root:scope3:[[130.58788888888887, 47.876416666666664], [131.11544444444442, 47.876416666666664], [130.58788888888887, 47.427749999999996], [131.11544444444442, 47.427749999999996]] -INFO:root:scope4:[[130.40576233571758, 47.936153520704124], [131.8327786879565, 47.936153520704124], [130.40576233571758, 47.10644445056424], [131.8327786879565, 47.10644445056424]] -INFO:root:scope5:[[130.00427774930557, 49.00453605317449], [132.01632432267647, 49.00453605317449], [130.00427774930557, 47.00425741002555], [132.01632432267647, 47.00425741002555]] -INFO:root:scope6:[[130.00427774930557, 49.00453605317449], [132.01632432267647, 49.00453605317449], [130.00427774930557, 47.00425741002555], [132.01632432267647, 47.00425741002555]] -INFO:root:scope7:[[130.58788888888887, 47.876416666666664], [131.11544444444442, 47.876416666666664], [130.58788888888887, 47.427749999999996], [131.11544444444442, 47.427749999999996]] -INFO:root:scope roi :[(130.58788888888887, 47.427749999999996), (130.58788888888887, 47.876416666666664), (131.11544444444442, 47.876416666666664), (131.11544444444442, 47.427749999999996)] -INFO:mylog:create intersect shp success! -INFO:mylog:cut HH success! -INFO:mylog:cut VV success! -INFO:mylog:cut VH success! -INFO:mylog:cut HV success! -INFO:mylog:cut Covering success! -INFO:mylog:cut NDVI success! -INFO:mylog:cut NDWI success! -INFO:mylog:cut LocalIncidenceAngle success! -INFO:mylog:cut images success! -INFO:mylog:resampling HH success! -INFO:mylog:resampling VV success! -INFO:mylog:resampling VH success! -INFO:mylog:resampling HV success! -INFO:mylog:resampling Covering success! -INFO:mylog:resampling NDVI success! -INFO:mylog:resampling NDWI success! -INFO:mylog:resampling LocalIncidenceAngle success! -INFO:mylog:preprocess_handle success! -INFO:mylog:progress bar: 40% -INFO:mylog:trans_tif2mask success, path: D:\micro\LWork\SoilMoisture\Temporary\processing\angle_nan_mask.tif -INFO:mylog:trans_tif2mask success, path: D:\micro\LWork\SoilMoisture\Temporary\processing\tif_mask.tif -INFO:mylog:trans_tif2mask success, path: D:\micro\LWork\SoilMoisture\Temporary\processing\tif_mask_zero.tif -INFO:mylog:trans_tif2mask success, path: D:\micro\LWork\SoilMoisture\Temporary\processing\ndvi_mask.tif -INFO:mylog:create masks success! -INFO:mylog:combine_mask success, path: D:\micro\LWork\SoilMoisture\Temporary\processing\bare_land_mask.tif -INFO:mylog:combine_mask success, path: D:\micro\LWork\SoilMoisture\Temporary\processing\bare_land_mask.tif -INFO:mylog:combine_mask success, path: D:\micro\LWork\SoilMoisture\Temporary\processing\bare_land_mask.tif -INFO:mylog:combine_mask success, path: D:\micro\LWork\SoilMoisture\Temporary\processing\bare_land_mask.tif -INFO:mylog:combine_mask success! -INFO:mylog:cal_roi success, path: D:\micro\LWork\SoilMoisture\Temporary\preprocessed\LocalIncidenceAngle_preprocessed.tif -INFO:mylog:create ROI image success! -INFO:mylog:progress bar: 50% -INFO:mylog:lee process finish: D:\micro\LWork\SoilMoisture\Temporary\preprocessed\HH_preprocessed.tif -INFO:mylog:lee process finish: D:\micro\LWork\SoilMoisture\Temporary\preprocessed\VV_preprocessed.tif -INFO:mylog:lee process finish: D:\micro\LWork\SoilMoisture\Temporary\preprocessed\VH_preprocessed.tif -INFO:mylog:lee process finish: D:\micro\LWork\SoilMoisture\Temporary\preprocessed\HV_preprocessed.tif -INFO:mylog:blocking tifs success! -INFO:mylog:total:195, block:0 calculating soil_moisture! -INFO:mylog:total:195, block:1 calculating soil_moisture! -INFO:mylog:total:195, block:2 calculating soil_moisture! -INFO:mylog:total:195, block:3 calculating soil_moisture! -INFO:mylog:total:195, block:4 calculating soil_moisture! -INFO:mylog:total:195, block:5 calculating soil_moisture! -INFO:mylog:total:195, block:6 calculating soil_moisture! -INFO:mylog:total:195, block:7 calculating soil_moisture! -INFO:mylog:total:195, block:8 calculating soil_moisture! -INFO:mylog:total:195, block:9 calculating soil_moisture! -INFO:mylog:total:195, block:10 calculating soil_moisture! -INFO:mylog:total:195, block:11 calculating soil_moisture! -INFO:mylog:total:195, block:12 calculating soil_moisture! -INFO:mylog:total:195, block:13 calculating soil_moisture! -INFO:mylog:total:195, block:14 calculating soil_moisture! -INFO:mylog:total:195, block:15 calculating soil_moisture! -INFO:mylog:total:195, block:16 calculating soil_moisture! -INFO:mylog:total:195, block:17 calculating soil_moisture! -INFO:mylog:total:195, block:18 calculating soil_moisture! -INFO:mylog:total:195, block:19 calculating soil_moisture! -INFO:mylog:total:195, block:20 calculating soil_moisture! -INFO:mylog:total:195, block:21 calculating soil_moisture! -INFO:mylog:total:195, block:22 calculating soil_moisture! -INFO:mylog:total:195, block:23 calculating soil_moisture! -INFO:mylog:total:195, block:24 calculating soil_moisture! -INFO:mylog:total:195, block:25 calculating soil_moisture! -INFO:mylog:total:195, block:26 calculating soil_moisture! -INFO:mylog:total:195, block:27 calculating soil_moisture! -INFO:mylog:total:195, block:28 calculating soil_moisture! -INFO:mylog:total:195, block:29 calculating soil_moisture! -INFO:mylog:total:195, block:30 calculating soil_moisture! -INFO:mylog:total:195, block:31 calculating soil_moisture! -INFO:mylog:total:195, block:32 calculating soil_moisture! -INFO:mylog:total:195, block:33 calculating soil_moisture! -INFO:mylog:total:195, block:34 calculating soil_moisture! -INFO:mylog:total:195, block:35 calculating soil_moisture! -INFO:mylog:total:195, block:36 calculating soil_moisture! -INFO:mylog:total:195, block:37 calculating soil_moisture! -INFO:mylog:total:195, block:38 calculating soil_moisture! -INFO:mylog:total:195, block:39 calculating soil_moisture! -INFO:mylog:total:195, block:40 calculating soil_moisture! -INFO:mylog:total:195, block:41 calculating soil_moisture! -INFO:mylog:total:195, block:42 calculating soil_moisture! -INFO:mylog:total:195, block:43 calculating soil_moisture! -INFO:mylog:total:195, block:44 calculating soil_moisture! -INFO:mylog:total:195, block:45 calculating soil_moisture! -INFO:mylog:total:195, block:46 calculating soil_moisture! -INFO:mylog:total:195, block:47 calculating soil_moisture! -INFO:mylog:total:195, block:48 calculating soil_moisture! -INFO:mylog:total:195, block:49 calculating soil_moisture! -INFO:mylog:total:195, block:50 calculating soil_moisture! -INFO:mylog:total:195, block:51 calculating soil_moisture! -INFO:mylog:total:195, block:52 calculating soil_moisture! -INFO:mylog:total:195, block:53 calculating soil_moisture! -INFO:mylog:total:195, block:54 calculating soil_moisture! -INFO:mylog:total:195, block:55 calculating soil_moisture! -INFO:mylog:total:195, block:56 calculating soil_moisture! -INFO:mylog:total:195, block:57 calculating soil_moisture! -INFO:mylog:total:195, block:58 calculating soil_moisture! -INFO:mylog:total:195, block:59 calculating soil_moisture! -INFO:mylog:total:195, block:60 calculating soil_moisture! -INFO:mylog:total:195, block:61 calculating soil_moisture! -INFO:mylog:total:195, block:62 calculating soil_moisture! -INFO:mylog:total:195, block:63 calculating soil_moisture! -INFO:mylog:total:195, block:64 calculating soil_moisture! -INFO:mylog:total:195, block:65 calculating soil_moisture! -INFO:mylog:total:195, block:66 calculating soil_moisture! -INFO:mylog:total:195, block:67 calculating soil_moisture! -INFO:mylog:total:195, block:68 calculating soil_moisture! -INFO:mylog:total:195, block:69 calculating soil_moisture! -INFO:mylog:total:195, block:70 calculating soil_moisture! -INFO:mylog:total:195, block:71 calculating soil_moisture! -INFO:mylog:total:195, block:72 calculating soil_moisture! -INFO:mylog:total:195, block:73 calculating soil_moisture! -INFO:mylog:total:195, block:74 calculating soil_moisture! -INFO:mylog:total:195, block:75 calculating soil_moisture! -INFO:mylog:total:195, block:76 calculating soil_moisture! -INFO:mylog:total:195, block:77 calculating soil_moisture! -INFO:mylog:total:195, block:78 calculating soil_moisture! -INFO:mylog:total:195, block:79 calculating soil_moisture! -INFO:mylog:total:195, block:80 calculating soil_moisture! -INFO:mylog:total:195, block:81 calculating soil_moisture! -INFO:mylog:total:195, block:82 calculating soil_moisture! -INFO:mylog:total:195, block:83 calculating soil_moisture! -INFO:mylog:total:195, block:84 calculating soil_moisture! -INFO:mylog:total:195, block:85 calculating soil_moisture! -INFO:mylog:total:195, block:86 calculating soil_moisture! -INFO:mylog:total:195, block:87 calculating soil_moisture! -INFO:mylog:total:195, block:88 calculating soil_moisture! -INFO:mylog:total:195, block:89 calculating soil_moisture! -INFO:mylog:total:195, block:90 calculating soil_moisture! -INFO:mylog:total:195, block:91 calculating soil_moisture! -INFO:mylog:total:195, block:92 calculating soil_moisture! -INFO:mylog:total:195, block:93 calculating soil_moisture! -INFO:mylog:total:195, block:94 calculating soil_moisture! -INFO:mylog:total:195, block:95 calculating soil_moisture! -INFO:mylog:total:195, block:96 calculating soil_moisture! -INFO:mylog:total:195, block:97 calculating soil_moisture! -INFO:mylog:total:195, block:98 calculating soil_moisture! -INFO:mylog:total:195, block:99 calculating soil_moisture! -INFO:mylog:total:195, block:100 calculating soil_moisture! -INFO:mylog:total:195, block:101 calculating soil_moisture! -INFO:mylog:total:195, block:102 calculating soil_moisture! -INFO:mylog:total:195, block:103 calculating soil_moisture! -INFO:mylog:total:195, block:104 calculating soil_moisture! -INFO:mylog:total:195, block:105 calculating soil_moisture! -INFO:mylog:total:195, block:106 calculating soil_moisture! -INFO:mylog:total:195, block:107 calculating soil_moisture! -INFO:mylog:total:195, block:108 calculating soil_moisture! -INFO:mylog:total:195, block:109 calculating soil_moisture! -INFO:mylog:total:195, block:110 calculating soil_moisture! -INFO:mylog:total:195, block:111 calculating soil_moisture! -INFO:mylog:total:195, block:112 calculating soil_moisture! -INFO:mylog:total:195, block:113 calculating soil_moisture! -INFO:mylog:total:195, block:114 calculating soil_moisture! -INFO:mylog:total:195, block:115 calculating soil_moisture! -INFO:mylog:total:195, block:116 calculating soil_moisture! -INFO:mylog:total:195, block:117 calculating soil_moisture! -INFO:mylog:total:195, block:118 calculating soil_moisture! -INFO:mylog:total:195, block:119 calculating soil_moisture! -INFO:mylog:total:195, block:120 calculating soil_moisture! -INFO:mylog:total:195, block:121 calculating soil_moisture! -INFO:mylog:total:195, block:122 calculating soil_moisture! -INFO:mylog:total:195, block:123 calculating soil_moisture! -INFO:mylog:total:195, block:124 calculating soil_moisture! -INFO:mylog:total:195, block:125 calculating soil_moisture! -INFO:mylog:total:195, block:126 calculating soil_moisture! -INFO:mylog:total:195, block:127 calculating soil_moisture! -INFO:mylog:total:195, block:128 calculating soil_moisture! -INFO:mylog:total:195, block:129 calculating soil_moisture! -INFO:mylog:total:195, block:130 calculating soil_moisture! -INFO:mylog:total:195, block:131 calculating soil_moisture! -INFO:mylog:total:195, block:132 calculating soil_moisture! -INFO:mylog:total:195, block:133 calculating soil_moisture! -INFO:mylog:total:195, block:134 calculating soil_moisture! -INFO:mylog:total:195, block:135 calculating soil_moisture! -INFO:mylog:total:195, block:136 calculating soil_moisture! -INFO:mylog:total:195, block:137 calculating soil_moisture! -INFO:mylog:total:195, block:138 calculating soil_moisture! -INFO:mylog:total:195, block:139 calculating soil_moisture! -INFO:mylog:total:195, block:140 calculating soil_moisture! -INFO:mylog:total:195, block:141 calculating soil_moisture! -INFO:mylog:total:195, block:142 calculating soil_moisture! -INFO:mylog:total:195, block:143 calculating soil_moisture! -INFO:mylog:total:195, block:144 calculating soil_moisture! -INFO:mylog:total:195, block:145 calculating soil_moisture! -INFO:mylog:total:195, block:146 calculating soil_moisture! -INFO:mylog:total:195, block:147 calculating soil_moisture! -INFO:mylog:total:195, block:148 calculating soil_moisture! -INFO:mylog:total:195, block:149 calculating soil_moisture! -INFO:mylog:total:195, block:150 calculating soil_moisture! -INFO:mylog:total:195, block:151 calculating soil_moisture! -INFO:mylog:total:195, block:152 calculating soil_moisture! -INFO:mylog:total:195, block:153 calculating soil_moisture! -INFO:mylog:total:195, block:154 calculating soil_moisture! -INFO:mylog:total:195, block:155 calculating soil_moisture! -INFO:mylog:total:195, block:156 calculating soil_moisture! -INFO:mylog:total:195, block:157 calculating soil_moisture! -INFO:mylog:total:195, block:158 calculating soil_moisture! -INFO:mylog:total:195, block:159 calculating soil_moisture! -INFO:mylog:total:195, block:160 calculating soil_moisture! -INFO:mylog:total:195, block:161 calculating soil_moisture! -INFO:mylog:total:195, block:162 calculating soil_moisture! -INFO:mylog:total:195, block:163 calculating soil_moisture! -INFO:mylog:total:195, block:164 calculating soil_moisture! -INFO:mylog:total:195, block:165 calculating soil_moisture! -INFO:mylog:total:195, block:166 calculating soil_moisture! -INFO:mylog:total:195, block:167 calculating soil_moisture! -INFO:mylog:total:195, block:168 calculating soil_moisture! -INFO:mylog:total:195, block:169 calculating soil_moisture! -INFO:mylog:total:195, block:170 calculating soil_moisture! -INFO:mylog:total:195, block:171 calculating soil_moisture! -INFO:mylog:total:195, block:172 calculating soil_moisture! -INFO:mylog:total:195, block:173 calculating soil_moisture! -INFO:mylog:total:195, block:174 calculating soil_moisture! -INFO:mylog:total:195, block:175 calculating soil_moisture! -INFO:mylog:total:195, block:176 calculating soil_moisture! -INFO:mylog:total:195, block:177 calculating soil_moisture! -INFO:mylog:total:195, block:178 calculating soil_moisture! -INFO:mylog:total:195, block:179 calculating soil_moisture! -INFO:mylog:total:195, block:180 calculating soil_moisture! -INFO:mylog:total:195, block:181 calculating soil_moisture! -INFO:mylog:total:195, block:182 calculating soil_moisture! -INFO:mylog:total:195, block:183 calculating soil_moisture! -INFO:mylog:total:195, block:184 calculating soil_moisture! -INFO:mylog:total:195, block:185 calculating soil_moisture! -INFO:mylog:total:195, block:186 calculating soil_moisture! -INFO:mylog:total:195, block:187 calculating soil_moisture! -INFO:mylog:total:195, block:188 calculating soil_moisture! -INFO:mylog:total:195, block:189 calculating soil_moisture! -INFO:mylog:total:195, block:190 calculating soil_moisture! -INFO:mylog:total:195, block:191 calculating soil_moisture! -INFO:mylog:total:195, block:192 calculating soil_moisture! -INFO:mylog:total:195, block:193 calculating soil_moisture! -INFO:mylog:total:195, block:194 calculating soil_moisture! -INFO:mylog:[, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ] -INFO:mylog:progress bar: 80% -INFO:mylog:cal_roi success, path: D:\micro\LWork\SoilMoisture\Temporary\processing\product\LT1B_MONO_MYC_STRIP4_005860_E130.9_N47.7_20230327_SLC_AHV_L1A_0000086966-cal-SMC.tif -INFO:mylog:cal soil_moisture success! -INFO:mylog:process_handle success! -INFO:mylog:progress bar: 100% -INFO:mylog:successful production of SoilMoisture products! -INFO:mylog:running use time: 0:19:44.006074 diff --git a/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-53-44.log b/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-53-44.log deleted file mode 100644 index e69de29..0000000 diff --git a/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-53-45.log b/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-53-45.log deleted file mode 100644 index e69de29..0000000 diff --git a/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-53-46.log b/soilMoisture-L-SAR/run_log/SoilMoisture2023-11-22-17-53-46.log deleted file mode 100644 index e69de29..0000000 diff --git a/soilSalinity-L-SAR/SoilSalinityMain.py b/soilSalinity-L-SAR/SoilSalinityMain.py index ab0979d..d6fe6b4 100644 --- a/soilSalinity-L-SAR/SoilSalinityMain.py +++ b/soilSalinity-L-SAR/SoilSalinityMain.py @@ -49,6 +49,8 @@ csvh = csvHandle() soil_salinity_value_min = float(cf.get('product_value_min')) soil_salinity_value_max = float(cf.get('product_value_max')) pixelspace=float(cf.get('pixelspace')) +tar = r'-' + cf.get('tar') +productLevel = cf.get('productLevel') if cf.get('debug') == 'True': DEBUG = True else: @@ -103,7 +105,7 @@ class SalinityMain: self.__processing_paras.update(self.get_tar_gz_inf(self.__processing_paras["sar_path0"])) SrcImageName = os.path.split(self.__input_paras["AHV"]['ParaValue'])[1].split('.tar.gz')[0] - result_name = SrcImageName + "-salinty.tar.gz" + result_name = SrcImageName + tar + ".tar.gz" self.__out_para = os.path.join(self.__workspace_path, EXE_NAME, 'Output', result_name) self.__alg_xml_handler.write_out_para("SoilSalinityProduct", self.__out_para) #写入输出参数 @@ -261,13 +263,13 @@ class SalinityMain: # CreateMetafile(self.__processing_paras['META'], self.alg_xml_path, model_xml_path, meta_xml_path).process( # SrcImageName) model_path = "./product.xml" - meta_xml_path = os.path.join(self.__product_dic, SrcImageName + "-Salinity.meta.xml") + meta_xml_path = os.path.join(self.__product_dic, SrcImageName + tar + ".meta.xml") para_dict = CreateMetaDict(image_path, self.__processing_paras['Origin_META'], self.__workspace_processing_path, out_path1, out_path2).calu_nature() para_dict.update({"imageinfo_ProductName": "土壤盐碱度"}) para_dict.update({"imageinfo_ProductIdentifier": "SoilSalinity"}) - para_dict.update({"imageinfo_ProductLevel": "5A"}) + para_dict.update({"imageinfo_ProductLevel": productLevel}) para_dict.update({"ProductProductionInfo_BandSelection": "1,2"}) CreateProductXml(para_dict, model_path, meta_xml_path).create_standard_xml() @@ -404,7 +406,7 @@ class SalinityMain: # l1a图像坐标转换地理坐标 salinity_path = self.__workspace_processing_path + "salinity.tif" - SrcImageName = os.path.split(self.__input_paras["AHV"]['ParaValue'])[1].split('.tar.gz')[0] + '-Salinity.tif' + SrcImageName = os.path.split(self.__input_paras["AHV"]['ParaValue'])[1].split('.tar.gz')[0] + tar + '.tif' salinity_geo_path = os.path.join(self.__workspace_processing_path, SrcImageName) self.calInterpolation_bil_Wgs84_rc_sar_sigma(self.__processing_paras['paraMeter'], self.__preprocessed_paras['sim_ori'], salinity_path, salinity_geo_path) diff --git a/soilSalinity-L-SAR/config.ini b/soilSalinity-L-SAR/config.ini index 86f65dc..27ec360 100644 --- a/soilSalinity-L-SAR/config.ini +++ b/soilSalinity-L-SAR/config.ini @@ -2,7 +2,8 @@ # 定义config分组 [config] ######1-算法基本参数###### - +tar = SSAA +productLevel = 5 # 算法名称。修改临时工作区生成临时文件的名称,日志名称; exe_name = SoilSalinity # 开启调试模式则不删除临时工作区,True:开启调试,False:不开启调试 diff --git a/surfaceRoughness-L-SAR/SurfaceRoughnessMain.py b/surfaceRoughness-L-SAR/SurfaceRoughnessMain.py index 1825f88..a999362 100644 --- a/surfaceRoughness-L-SAR/SurfaceRoughnessMain.py +++ b/surfaceRoughness-L-SAR/SurfaceRoughnessMain.py @@ -42,6 +42,8 @@ cover_id_list = [] threshold_of_ndvi_min = 0 threshold_of_ndvi_max = 0 multiprocessing_num = int(cf.get('multiprocessing_num')) +tar = r'-' + cf.get('tar') +productLevel = cf.get('productLevel') if cf.get('debug') == 'True': DEBUG = True else: @@ -101,7 +103,7 @@ class MoistureMain: self.__processing_paras.update(self.get_tar_gz_inf(self.__processing_paras["sar_path0"])) SrcImageName = os.path.split(self.__input_paras["DualPolarSAR"]['ParaValue'])[1].split('.tar.gz')[0] - result_name = SrcImageName + "-Roughness.tar.gz" + result_name = SrcImageName + tar + ".tar.gz" self.__out_para = os.path.join(self.__workspace_path, EXE_NAME, 'Output', result_name) self.__alg_xml_handler.write_out_para("SurfaceRoughnessProduct", self.__out_para) #写入输出参数 @@ -326,7 +328,7 @@ class MoistureMain: bare_land_mask_path = roi().roi_process(para_names, self.__workspace_processing_path + "/roi/", self.__processing_paras, self.__preprocessed_paras) - SrcImageName = os.path.split(self.__input_paras["DualPolarSAR"]['ParaValue'])[1].split('.tar.gz')[0] + '-Roughness.tif' + SrcImageName = os.path.split(self.__input_paras["DualPolarSAR"]['ParaValue'])[1].split('.tar.gz')[0] + tar + '.tif' product_path = os.path.join(self.__product_dic, SrcImageName) # 获取影像roi区域 @@ -341,28 +343,14 @@ class MoistureMain: image_path = product_path out_path1 = os.path.join(tem_folder, "trans_geo_projcs.tif") out_path2 = os.path.join(tem_folder, "trans_projcs_geo.tif") - # par_dict = CreateDict(image_path, self.processinfo, out_path1, out_path2).calu_nature(start) - # model_xml_path = os.path.join(tem_folder, "creat_standard.meta.xml") # 输出xml路径 - # - # id_min = 0 - # id_max = 1000 - # threshold_of_ndvi_min = 0 - # threshold_of_ndvi_max = 1 - # set_threshold = [id_max, id_min, threshold_of_ndvi_min, threshold_of_ndvi_max] - # CreateStadardXmlFile(xml_path, self.alg_xml_path, par_dict, set_threshold, model_xml_path).create_standard_xml() - # + SrcImagePath = self.__input_paras["DualPolarSAR"]['ParaValue'] paths = SrcImagePath.split(';') SrcImageName=os.path.split(paths[0])[1].split('.tar.gz')[0] - # if len(paths) >= 2: - # for i in range(1, len(paths)): - # SrcImageName=SrcImageName+";"+os.path.split(paths[i])[1].split('.tar.gz')[0] - # meta_xml_path = self.__product_dic + EXE_NAME + "Product.meta.xml" - # CreateMetafile(self.__processing_paras['META'], self.alg_xml_path, model_xml_path, meta_xml_path).process(SrcImageName) # 文件夹打包 model_path = "./product.xml" - meta_xml_path = os.path.join(self.__product_dic, SrcImageName + "-Roughness.meta.xml") + meta_xml_path = os.path.join(self.__product_dic, SrcImageName + tar + ".meta.xml") para_dict = CreateMetaDict(image_path, self.__processing_paras['Origin_META'], self.__workspace_processing_path, out_path1, out_path2).calu_nature() @@ -370,7 +358,7 @@ class MoistureMain: para_dict.update({"imageinfo_ProductName": "地表粗糙度"}) para_dict.update({"imageinfo_ProductIdentifier": "SurfaceRoughness"}) - para_dict.update({"imageinfo_ProductLevel": "5A"}) + para_dict.update({"imageinfo_ProductLevel": productLevel}) para_dict.update({"ProductProductionInfo_BandSelection": "1,2"}) para_dict.update({"ObservationGeometry_SatelliteAzimuth": Azimuth_incidence}) CreateProductXml(para_dict, model_path, meta_xml_path).create_standard_xml() diff --git a/surfaceRoughness-L-SAR/config.ini b/surfaceRoughness-L-SAR/config.ini index 80fce69..08da7d3 100644 --- a/surfaceRoughness-L-SAR/config.ini +++ b/surfaceRoughness-L-SAR/config.ini @@ -2,7 +2,8 @@ # 定义config分组 [config] ######1-算法基本参数###### - +tar = SR +productLevel = 5 # 算法名称。修改临时工作区生成临时文件的名称,日志名称; exe_name = SurfaceRoughness # 开启调试模式则不删除临时工作区,True:开启调试,False:不开启调试 diff --git a/surfaceRoughness-L-SAR/surface_inversion_dubois.exe b/surfaceRoughness-L-SAR/surface_inversion_dubois.exe deleted file mode 100644 index 3e96d9b..0000000 Binary files a/surfaceRoughness-L-SAR/surface_inversion_dubois.exe and /dev/null differ diff --git a/surfaceRoughness-L-SAR/surface_inversion_histo.exe b/surfaceRoughness-L-SAR/surface_inversion_histo.exe deleted file mode 100644 index f1436f0..0000000 Binary files a/surfaceRoughness-L-SAR/surface_inversion_histo.exe and /dev/null differ diff --git a/surfaceRoughness-L-SAR/surface_inversion_oh.exe b/surfaceRoughness-L-SAR/surface_inversion_oh.exe deleted file mode 100644 index ab9bc09..0000000 Binary files a/surfaceRoughness-L-SAR/surface_inversion_oh.exe and /dev/null differ diff --git a/surfaceRoughness-L-SAR/surface_inversion_oh2004.exe b/surfaceRoughness-L-SAR/surface_inversion_oh2004.exe index db556f1..5c0e9ba 100644 Binary files a/surfaceRoughness-L-SAR/surface_inversion_oh2004.exe and b/surfaceRoughness-L-SAR/surface_inversion_oh2004.exe differ diff --git a/surfaceRoughness-L-SAR/surface_inversion_oh2004_v6.0.exe b/surfaceRoughness-L-SAR/surface_inversion_oh2004_v6.0.exe deleted file mode 100644 index 31d5a40..0000000 Binary files a/surfaceRoughness-L-SAR/surface_inversion_oh2004_v6.0.exe and /dev/null differ diff --git a/tool/algorithm/algtools/PreProcess.py b/tool/algorithm/algtools/PreProcess.py index e9b9155..3158632 100644 --- a/tool/algorithm/algtools/PreProcess.py +++ b/tool/algorithm/algtools/PreProcess.py @@ -375,6 +375,31 @@ class PreProcess: return {} return cutted_img_paths + def cut_imgs_VP(self, out_dir, para_names, processing_paras, shp_path, img_name): + """ + 使用矢量数据裁剪影像 + :param para_names:需要检查的参数名称 + :param shp_path:裁剪的shp文件 + """ + if len(para_names) == 0: + return {} + cutted_img_paths = {} + try: + for name in para_names: + if name == 'Covering': + img_name = img_name.split('_')[6] + '_' + output_path = os.path.join(out_dir, img_name + name + '_cut.tif') + else: + output_path = os.path.join(out_dir, name + '_cut.tif') + input_path = processing_paras[name] + self.cut_img(output_path, input_path, shp_path) + cutted_img_paths.update({name: output_path}) + logger.info('cut %s success!', name) + except BaseException: + logger.error('cut_img failed!') + return {} + return cutted_img_paths + @staticmethod def cut_img(output_path, input_path, shp_path): """ diff --git a/tool/algorithm/block/blockprocess.py b/tool/algorithm/block/blockprocess.py index b7794e9..abd4d10 100644 --- a/tool/algorithm/block/blockprocess.py +++ b/tool/algorithm/block/blockprocess.py @@ -25,9 +25,18 @@ class BlockProcess: @staticmethod def get_block_size(rows, cols): - block_size = 512 - if rows > 2048 and cols > 2048: - block_size = 1024 + # block_size = 512 + # if rows > 2048 and cols > 2048: + # block_size = 1024 + + block_size = 1024 + if rows <= 2048 or cols <= 2048: + block_size = 512 + elif 5 < (rows // 1024) < 10 or 5 < (cols // 1024) < 10: + block_size = 2048 + else: + block_size = 3072 + return block_size # def get_block_size(rows, cols, block_size_config): diff --git a/tool/algorithm/ml/machineLearning.py b/tool/algorithm/ml/machineLearning.py index e6b0475..a45efe3 100644 --- a/tool/algorithm/ml/machineLearning.py +++ b/tool/algorithm/ml/machineLearning.py @@ -70,7 +70,7 @@ class MachineLeaning: # 特征分块 bp = BlockProcess() block_size = bp.get_block_size(rows, cols) - + logger.info('block size is :%s', block_size) bp.cut(feature_tif_dir, workspace_block_tif_path, ['tif', 'tiff'], 'tif', block_size) img_dir, img_name = bp.get_file_names(workspace_block_tif_path, ['tif']) dir_dict_all = bp.get_same_img(img_dir, img_name) @@ -154,7 +154,7 @@ class MachineLeaning: name = os.path.split(path)[1] band = ImageHandler.get_bands(path) if band == 1: - features_array = np.zeros((1, 1024, 1024), dtype=float) + features_array = np.zeros((1, block_size, block_size), dtype=float) feature_array = ImageHandler.get_data(path) features_array[0, :, :] = feature_array else: diff --git a/tool/algorithm/polsarpro/AHVToPolsarpro.py b/tool/algorithm/polsarpro/AHVToPolsarpro.py index ef60b54..6e595a5 100644 --- a/tool/algorithm/polsarpro/AHVToPolsarpro.py +++ b/tool/algorithm/polsarpro/AHVToPolsarpro.py @@ -12,6 +12,8 @@ import os import numpy as np import glob import struct + +from tool.algorithm.algtools.MetaDataHandler import MetaDataHandler from tool.algorithm.image.ImageHandle import ImageHandler @@ -461,6 +463,65 @@ class AHVToPolsarpro: self._hh_hv_vh_vv_path_list = [] return out_dir + @staticmethod + def sar_backscattering_sigma(in_sar_tif, meta_file_path, out_sar_tif, replece_VV=False, is_DB=True): + + # 读取原始SAR影像 + proj, geotrans, in_data = ImageHandler.read_img(in_sar_tif) + + # 计算强度信息 + I = np.array(in_data[0], dtype="float32") + Q = np.array(in_data[1], dtype="float32") + + where_9999_0 = np.where(I == -9999) + where_9999_1 = np.where(Q == -9999) + I[where_9999_0] = 1.0 + Q[where_9999_1] = 1.0 + + I2 = np.square(I) + Q2 = np.square(Q) + intensity_arr = I2 + Q2 + + # 获取极化类型 + if 'HH' in os.path.basename(in_sar_tif): + polarization = 'HH' + elif 'HV' in os.path.basename(in_sar_tif): + polarization = 'HV' + elif 'VH' in os.path.basename(in_sar_tif): + polarization = 'VH' + elif 'VV' in os.path.basename(in_sar_tif): + polarization = 'VV' + if replece_VV: + polarization = 'HV' # 土壤水分算法中可能会用HV替换VV + elif 'DH' in os.path.basename(in_sar_tif): + polarization = 'HH' + else: + raise Exception('there are not HH、HV、VH、VV in path:', in_sar_tif) + + # 获取参数 + QualifyValue = MetaDataHandler.get_QualifyValue(meta_file_path, polarization) + Kdb = MetaDataHandler.get_Kdb(meta_file_path, polarization) + + # 计算后向散射系数 + # 对数形式 + coef_arr = 10 * (np.log10(intensity_arr * ((QualifyValue / 32767) ** 2))) - Kdb + coef_arr[np.isnan(coef_arr)] = -9999 + coef_arr[np.isinf(coef_arr)] = -9999 + coef_arr[where_9999_0] = -9999 + coef_arr[where_9999_1] = -9999 + ## 输出的SAR后向散射系数产品 + # ImageHandler.write_img(out_sar_tif, proj, geotrans, coef_arr, 0) + + tif_array = np.power(10.0, coef_arr / 10.0) # dB --> 线性值 后向散射系数 + + tif_array[np.isnan(tif_array)] = 0 + tif_array[np.isinf(tif_array)] = 0 + tif_array[where_9999_0] = 0 + tif_array[where_9999_1] = 0 + + ImageHandler.write_img(out_sar_tif, proj, geotrans, tif_array, 0) + return True + if __name__ == '__main__': diff --git a/tool/algorithm/xml/AnalysisXml.py b/tool/algorithm/xml/AnalysisXml.py index 8bbc228..e4b9f29 100644 --- a/tool/algorithm/xml/AnalysisXml.py +++ b/tool/algorithm/xml/AnalysisXml.py @@ -15,44 +15,48 @@ class DictXml: raise Exception("get root failed") def get_extend(self): - productInfo = self.__root.find("imageinfo") + global bottomRightLon, bottomLeftLon, topRightLon, topLeftLon, topLeftLat,\ + topRightLat, bottomLeftLat, bottomRightLat + productInfo = self.__root.find("productInfo") if productInfo is None: - raise Exception("get imageInfo failed") + raise Exception("get productInfo failed") - corner = productInfo.find("corner") - if corner is None: - raise Exception("get corner failed") + sceneInfo = productInfo.find("sceneInfo") + if sceneInfo is None: + raise Exception("get sceneInfo failed") - topLeft = corner.find("topLeft") - if topLeft is None: - raise Exception("get topLeft failed") + sceneCornerCoord = sceneInfo.findall("sceneCornerCoord") + if sceneCornerCoord is None: + raise Exception("get sceneCornerCoord failed") - topRight = corner.find("topRight") - if topRight is None: - raise Exception("get topRight failed") + for value in sceneCornerCoord: + if value.attrib.get('name') == 'topRight': + topRightLon = value.find('lon').text + topRightLat = value.find('lat').text + elif value.attrib.get('name') == 'topLeft': + topLeftLon = value.find('lon').text + topLeftLat = value.find('lat').text + elif value.attrib.get('name') == 'bottomRight': + bottomRightLon = value.find('lon').text + bottomRightLat = value.find('lat').text + elif value.attrib.get('name') == 'bottomLeft': + bottomLeftLon = value.find('lon').text + bottomLeftLat = value.find('lat').text - bottomLeft = corner.find("bottomLeft") - if bottomLeft is None: - raise Exception("get bottomLeft failed") - - bottomRight = corner.find("bottomRight") - if bottomRight is None: - raise Exception("get bottomRight failed") - - point_upleft = [float(topLeft.find("longitude").text), float(topLeft.find("latitude").text)] - point_upright = [float(topRight.find("longitude").text), float(topRight.find("latitude").text)] - point_downleft = [float(bottomLeft.find("longitude").text), float(bottomLeft.find("latitude").text)] - point_downright = [float(bottomRight.find("longitude").text), float(bottomRight.find("latitude").text)] + point_upleft = [float(topLeftLon), float(topLeftLat)] + point_upright = [float(topRightLon), float(topRightLat)] + point_downleft = [float(bottomLeftLon), float(bottomLeftLat)] + point_downright = [float(bottomRightLon), float(bottomRightLat)] scopes = [point_upleft, point_upright, point_downleft, point_downright] - point_upleft_buf = [float(topLeft.find("longitude").text) - 0.5, float(topLeft.find("latitude").text) + 0.5] - point_upright_buf = [float(topRight.find("longitude").text) + 0.5, float(topRight.find("latitude").text) + 0.5] - point_downleft_buf = [float(bottomLeft.find("longitude").text) - 0.5, - float(bottomLeft.find("latitude").text) - 0.5] - point_downright_buf = [float(bottomRight.find("longitude").text) + 0.5, - float(bottomRight.find("latitude").text) - 0.5] - scopes_buf = [point_upleft_buf, point_upright_buf, point_downleft_buf, point_downright_buf] - return scopes + point_upleft_buf = [float(topLeftLon) - 0.5, float(topLeftLat) + 0.5] + point_upright_buf = [float(topRightLon) + 0.5, float(topRightLat) + 0.5] + point_downleft_buf = [float(bottomLeftLon) - 0.5, + float(bottomLeftLat) - 0.5] + point_downright_buf = [float(bottomRightLon) + 0.5, + float(bottomRightLat) - 0.5] + scopes_buf = ([point_upleft_buf, point_upright_buf, point_downleft_buf, point_downright_buf],) + return scopes, scopes_buf class xml_extend: @@ -123,7 +127,7 @@ class xml_extend: if __name__ == '__main__': - xml_path = r'E:\MicroWorkspace\GF3A_nanjing\GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422\GF3_SAY_QPSI_011444_E118.9_N31.4_20181012_L1A_AHV_L10003515422.meta.xml' + xml_path = r"F:\MicroWorkspace\LT1B\LT1B_MONO_KRN_STRIP3_002875_E92.8_N39.9_20220907_GEC_HHHV_L2_0000035924\LT1B_MONO_KRN_STRIP3_002875_E92.8_N39.9_20220907_GEC_HHHV_L2_0000035924.meta.xml" scopes, scopes_buf = DictXml(xml_path).get_extend() print(scopes) print(scopes_buf) diff --git a/vegetationPhenology-L-SAR/VegetationPhenologyMain.py b/vegetationPhenology-L-SAR/VegetationPhenologyMain.py index 9104964..1412fbd 100644 --- a/vegetationPhenology-L-SAR/VegetationPhenologyMain.py +++ b/vegetationPhenology-L-SAR/VegetationPhenologyMain.py @@ -7,6 +7,7 @@ @Date :2021/9/6 @Version :1.0.0 """ +import csv import glob import logging import os @@ -44,6 +45,8 @@ else: EXE_NAME = cf.get('exe_name') LogHandler.init_log_handler('run_log\\' + EXE_NAME) logger = logging.getLogger("mylog") +tar = r'-' + cf.get('tar') +productLevel = cf.get('productLevel') FILTER_SIZE = int(cf.get('filter_size')) MAX_TRAN_NUM = int(cf.get('max_tran__num_per_class')) file =fileHandle(DEBUG) @@ -96,7 +99,7 @@ class PhenologyMain: SrcImagePath = self.__input_paras["AHVS"]['ParaValue'] paths = SrcImagePath.split(';') SrcImageName = os.path.split(paths[0])[1].split('.tar.gz')[0] - result_name = SrcImageName + "-VP.tar.gz" + result_name = SrcImageName + tar + ".tar.gz" self.__out_para = os.path.join(self.__workspace_path, EXE_NAME, 'Output', result_name) self.__alg_xml_handler.write_out_para("VegetationPhenologyProduct", self.__out_para) #写入输出参数 logger.info('check_source success!') @@ -165,8 +168,8 @@ class PhenologyMain: # 计算图像的轮廓,并求相交区域 intersect_shp_path = self.__workspace_preprocessing_path + 'IntersectPolygon.shp' scopes_roi = p.cal_intersect_shp(intersect_shp_path, para_names_geo, self.__processing_paras, scopes) - cutted_img_paths = p.cut_imgs(self.__workspace_preprocessing_path, para_names_geo, self.__processing_paras, - intersect_shp_path) + cutted_img_paths = p.cut_imgs_VP(self.__workspace_preprocessing_path, para_names_geo, self.__processing_paras, + intersect_shp_path, name) self.__preprocessed_paras.update({name + '_sim_ori': cutted_img_paths.get(name + '_sim_ori')}) self.__preprocessed_paras.update({name + '_Covering': cutted_img_paths.get('Covering')}) @@ -368,7 +371,9 @@ class PhenologyMain: """ # 生成每个时相的特征, 并提取训练集和测试集 # 每个时相的影像生成特征图 - X_train, Y_train = None, None + + X_train = [] + Y_train = [] flag = True total_name_list = [] X_test_dic = {} @@ -376,35 +381,45 @@ class PhenologyMain: feature_dir, train_data_dic = self.create_feature_single_tar(name) # 生成训练集 - X_train_part, Y_train_part, optimal_feature = ml.gene_optimal_train_set(train_data_dic, feature_dir, 0.07, 0.85) + # X_train_part, Y_train_part, optimal_feature = ml.gene_optimal_train_set(train_data_dic, feature_dir, 0.08, 0.7) + X_train_part, Y_train_part = ml.gene_train_set(train_data_dic, feature_dir) name_list = ml.get_name_list(feature_dir) - if len(optimal_feature) <= 0: - logger.error('特征筛选结果为空,无可用特征作为训练集') - continue + # 生成测试集合 + # X_test_path_list = ml.gene_test_set(feature_dir, optimal_feature) + + # X_test_dic.update({name: X_test_path_list}) + X_test_dic.update({name + '_features': feature_dir}) + + if X_train == []: + X_train = X_train_part + Y_train = Y_train_part + total_name_list = name_list + else: + X_train = np.vstack((X_train, X_train_part)) + Y_train = np.hstack((Y_train, Y_train_part)) + total_name_list = total_name_list + name_list + + logger.info("generate train and test set success!") + logger.info('progress bar: 30%') + + optimal_X_train, optimal_Y_train, optimal_feature = ml.sel_optimal_feature(X_train, Y_train, total_name_list, correlation_threshold=0.7) + + # RF + clf = ml.trainRF(optimal_X_train, optimal_Y_train) + logger.info('RF train success!') + + # 测试数据 + logger.info('mode testing') + for name in self.__processing_paras['name_list']: + feature_dir = X_test_dic.get(name + '_features') X_test_path_list = ml.gene_test_set(feature_dir, optimal_feature) - - X_test_dic.update({name: X_test_path_list}) - - X_train = X_train_part - Y_train = Y_train_part - - logger.info("generate train and test set success!") - logger.info('progress bar: 30%') - - # RF - clf = ml.trainRF(X_train, Y_train) - logger.info('RF train success!') - logger.info('progress bar: 80%') - - # 测试数据 - logger.info('mode testing') - in_tif_paths = list(glob.glob(os.path.join(feature_dir, '*.tif'))) rows = ImageHandler.get_img_height(in_tif_paths[0]) cols = ImageHandler.get_img_width(in_tif_paths[0]) proj_geo, geo_geo, cover_data_geo = self.imageHandler.read_img(in_tif_paths[0]) product_path = ml.predict_VP(clf, X_test_path_list, name, self.__workspace_processing_path, rows, cols) + # product_path = ml.predict_VP(clf, X_test_dic.get(name), name, self.__workspace_processing_path, rows, cols) proj, geo, cover_data = self.imageHandler.read_img(product_path) # 形态学(闭运算)去roi区域噪点 @@ -412,9 +427,9 @@ class PhenologyMain: kernel = np.ones((5, 5), np.uint8) cover_data = cv2.erode(cv2.dilate(cover_data, kernel), kernel) cover_data = np.int16(cover_data) - for id, class_id in zip(train_data_dic['ids'], train_data_dic['class_ids']): + train_dic = self.get_train_dic(self.__processing_paras['MeasuredData']) + for id, class_id in zip(train_dic['ids'], train_dic['class_ids']): cover_data[np.where(cover_data == id)] = class_id - roi_img = self.imageHandler.get_band_array(self.create_roi(in_tif_paths[0])) # 获取影像roi区域 cover_data_pro = cover_data * roi_img @@ -426,7 +441,7 @@ class PhenologyMain: mask_dir = os.path.join(self.__workspace_processing_path, name + '\\') bare_land_mask_path = roi().roi_process_VP(para_names, mask_dir, self.__processing_paras, self.__preprocessed_paras, name) - product_path_pro = os.path.join(self.__product_dic, os.path.basename(product_path).split('.tif')[0] + '-VP.tif') + product_path_pro = os.path.join(self.__product_dic, os.path.basename(product_path).split('.tif')[0] + tar + '.tif') # 获取影像roi区域 roi.cal_roi(product_path_pro, cover_geo_path, bare_land_mask_path, background_value=0) self.imageHandler.write_quick_view(product_path_pro, color_img=True) @@ -439,64 +454,28 @@ class PhenologyMain: # CreateProductXml(para_dict, model_path, out_xml).create_standard_xml() shutil.copy(meta_xml_path, out_xml) logger.info('mode test success!') + logger.info('progress bar: 80%') # 文件夹打包 file.make_targz(self.__out_para, self.__product_dic) logger.info('progress bar: 100%') - # """ - # 算法主处理函数 - # :return: True or False - # """ - # # 生成每个时相的特征, 并提取训练集和测试集 - # # 每个时相的影像生成特征图 - # X_train, Y_train = None, None - # flag = True - # total_name_list = [] - # test_data = [] - # X_test_dic = {} - # for name in self.__processing_paras['name_list']: - # feature_dir, train_data_dic, test_data_part, type_map = self.create_feature_single_tar(name) - # #生成训练集 - # X_train_part, Y_train_part = ml.gene_train_set(train_data_dic, feature_dir) - # name_list = ml.get_name_list(feature_dir) - # # 生成测试集合 - # rows, cols = self.get_name_rows_cols(name) - # name_featuresPath_dic_part = ml.vegetationPhenology_combine_feature(feature_dir, self.__workspace_processing_path, name, rows, cols, DEBUG) - # X_test_dic_part = self.gene_test_set(test_data_part, name_featuresPath_dic_part, name) - # X_test_dic.update(X_test_dic_part) - # if flag: - # X_train = X_train_part - # Y_train = Y_train_part - # total_name_list = name_list - # flag = False - # test_data = test_data_part - # else: - # X_train = np.vstack((X_train, X_train_part)) - # Y_train = np.hstack((Y_train, Y_train_part)) - # total_name_list = total_name_list + name_list - # test_data = test_data + test_data_part - # - # logger.info("create_features success!") - # logger.info('progress bar: 20%') - # - # optimal_X_train, optimal_Y_train, optimal_feature = ml.sel_optimal_feature(X_train, Y_train, total_name_list, correlation_threshold=0.7) - # - # logger.info("generate train and test set success!") - # logger.info('progress bar: 30%') - # - # #RF - # clf = ml.trainRF(optimal_X_train, optimal_Y_train) - # logger.info('svm train success!') - # logger.info('progress bar: 80%') - # - # # 测试数据 - # logger.info('mode testing') - # product_path = self.predict(clf, X_test_dic, optimal_feature, type_map, start) - # logger.info('mode test success!') - # self.create_meta_file(product_path) - # # 文件夹打包 - # file.make_targz(self.__out_para, self.__product_dic) - # logger.info('progress bar: 100%') + def get_train_dic(self, csv_path): + reader = csv.reader(open(csv_path, newline='')) + ids = [] + class_ids = [] + csv_list = [] + for line_data in reader: + csv_list.append(line_data) + for data in csv_list[1:]: + ids.append(data[0]) + class_ids.append(data[1]) + + train_data_dic = {} + train_data_dic.update({"ids": ids}) + train_data_dic.update({"class_ids": class_ids}) + + return train_data_dic + def predict(self, mode, X_test_dic, validity_list, type_map, start): # 测试数据 @@ -613,7 +592,7 @@ class PhenologyMain: out_path1, out_path2).calu_nature() para_dict.update({"imageinfo_ProductName": "植被物候"}) para_dict.update({"imageinfo_ProductIdentifier": "VegetationPhenology"}) - para_dict.update({"imageinfo_ProductLevel": "4"}) + para_dict.update({"imageinfo_ProductLevel": productLevel}) para_dict.update({"ProductProductionInfo_BandSelection": "1,2"}) para_dict.update({"ProductProductionInfo_AuxiliaryDataDescription": "Label"}) CreateProductXml(para_dict, model_path, meta_xml_path).create_standard_xml() diff --git a/vegetationPhenology-L-SAR/config.ini b/vegetationPhenology-L-SAR/config.ini index f4fbbae..0c8f398 100644 --- a/vegetationPhenology-L-SAR/config.ini +++ b/vegetationPhenology-L-SAR/config.ini @@ -3,6 +3,8 @@ [config] ######1-算法基本参数###### +tar = VP +productLevel = 5 # 算法名称。修改临时工作区生成临时文件的名称,日志名称; exe_name = VegetationPhenology # 开启调试模式则不删除临时工作区,True:开启调试,False:不开启调试