refactor: 使用动态路径替换硬编码路径.

This commit is contained in:
谢泓 2025-09-04 14:47:42 +08:00
parent 8883fd8d58
commit c19f334035
7 changed files with 24 additions and 7 deletions

View File

@ -39,7 +39,9 @@ import geopandas as gpd
import numpy as np import numpy as np
from rioxarray import open_rasterio from rioxarray import open_rasterio
sys.path.append("D:/NASA_EarthData_Script") # 动态获取项目根目录路径
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(project_root)
from utils.common_utils import setup_dask_environment, clip_image, mosaic_images from utils.common_utils import setup_dask_environment, clip_image, mosaic_images
from HLS_SuPER.HLS_Su import earthdata_search from HLS_SuPER.HLS_Su import earthdata_search

View File

@ -28,7 +28,9 @@ import logging
import earthaccess import earthaccess
from xarray import open_dataset from xarray import open_dataset
sys.path.append("D:/NASA_EarthData_Script") # 动态获取项目根目录路径
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(project_root)
from utils.common_utils import setup_dask_environment from utils.common_utils import setup_dask_environment
from HLS_SuPER.HLS_Su import earthdata_search from HLS_SuPER.HLS_Su import earthdata_search

View File

@ -20,7 +20,9 @@ import rioxarray as rxr
import dask.distributed import dask.distributed
import geopandas as gpd import geopandas as gpd
sys.path.append("D:/NASA_EarthData_Script") # 动态获取项目根目录路径
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(project_root)
from utils.common_utils import clip_image, reproject_image, setup_dask_environment from utils.common_utils import clip_image, reproject_image, setup_dask_environment
from HLS_SuPER.HLS_Su import earthdata_search from HLS_SuPER.HLS_Su import earthdata_search

View File

@ -48,7 +48,9 @@ import numpy as np
import xarray as xr import xarray as xr
from rioxarray import open_rasterio from rioxarray import open_rasterio
sys.path.append("D:/NASA_EarthData_Script") # 动态获取项目根目录路径
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(project_root)
from utils.common_utils import setup_dask_environment, clip_image, mosaic_images from utils.common_utils import setup_dask_environment, clip_image, mosaic_images
from HLS_SuPER.HLS_Su import earthdata_search from HLS_SuPER.HLS_Su import earthdata_search

View File

@ -28,7 +28,9 @@ import h5py
from osgeo import gdal from osgeo import gdal
import xarray as xr import xarray as xr
sys.path.append("D:/NASA_EarthData_Script") # 动态获取项目根目录路径
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(project_root)
from utils.common_params import EASE2_GRID_PARAMS, EPSG from utils.common_params import EASE2_GRID_PARAMS, EPSG
from utils.common_utils import ( from utils.common_utils import (

View File

@ -55,7 +55,9 @@ import logging
import time import time
from datetime import datetime, timedelta from datetime import datetime, timedelta
sys.path.append("D:\NASA_EarthData_Script") # 动态获取项目根目录路径
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(project_root)
class getInsituData: class getInsituData:

View File

@ -28,7 +28,9 @@ import geopandas as gpd
from datetime import datetime as dt from datetime import datetime as dt
import dask.distributed import dask.distributed
sys.path.append("D:/NASA_EarthData_Script") # 动态获取项目根目录路径
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(project_root)
from utils.common_utils import setup_dask_environment from utils.common_utils import setup_dask_environment
from HLS_Su import hls_search from HLS_Su import hls_search
@ -248,6 +250,8 @@ def format_tile_id(tile_id):
""" """
(Add) 格式化tile_id参数 (Add) 格式化tile_id参数
""" """
if tile_id is None:
return None
tile_id = tile_id.strip("'").strip('"') tile_id = tile_id.strip("'").strip('"')
return str(tile_id) return str(tile_id)
@ -481,6 +485,7 @@ def main():
# Defaults to the current directory # Defaults to the current directory
output_dir = os.getcwd() + os.sep output_dir = os.getcwd() + os.sep
os.makedirs(output_dir, exist_ok=True)
logging.info(f"Output directory set to: {output_dir}") logging.info(f"Output directory set to: {output_dir}")
# Format/Validate Dates # Format/Validate Dates